胶州空管前端代码
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.
 
 

78 lines
1.0 MiB

!function(){"use strict";var e=window.Glodon=window.Glodon||{};e.Version="2022-3-2-17-50",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}();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),c=h.getSize();i.push((new o).setFromCenterAndSize(h.getCenter(),c.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=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)},n=function(e,t,i){let n={};if(n[e])t&&t();else{let o=document.createElement("script");o.type="text/javascript",o.src=e,document.head.appendChild(o),n[e]=!0,o.readyState?o.onreadystatechange=function(){"loaded"==o.readyState||"complete"==o.readyState?(o.onreadystatechange=null,t&&t()):"uninitialized"==o.readyState&&(o.onreadystatechange=null,i&&i())}:(o.onload=function(){t&&t()},o.onerror=function(){i&&i()})}},o=function(e,t){e.length>1?n(e.shift(),(()=>{o(e,t)})):n(e.shift(),t)};t.ajax=i,t.promiseJSONRequest=function(e,t,n){let o;return o="string"==typeof e?{url:e,status:t}:e,new Promise((function(e,s){i(Object.assign({},o,{success:function(i){try{var n=JSON.parse(i)}catch(t){return e(i)}"success"==n.code||"noCode"==o.status?e("noCode"==t?n:n.data):s(`requestError,dataCode:${n.code}, dataMessage:${n.message}`)},failure:e=>{s(e)}}),n)}))},t.getScript=n,t.getScripts=o}(),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,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,c=0,d=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,c++),h=g(s,d++),l<76&&h<76&&l>66&&h>66&&(l=g(o,c,c),h=g(s,d,c=a),d=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));return!(/(?:iPhone)/.test(e)&&!r||o||n||r)},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.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,c=0;const d=Math.sqrt((i-e)*(i-e)+(n-t)*(n-t));if(0===d)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 c=d,[c,{x:i,y:n}];if(d<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)/d,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[d,{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 c=0,p=0;const f=(s-n)/o-i,m=-1/f,w=t-e*m;return c=(s-o*f-w)/(m-f),p=m*c+w,[d*Math.sin(l),{x:c,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,f=0;const m=(s-n)/o-i,w=-1/m,v=t-e*w;return p=(s-o*m-v)/(w-m),f=w*p+v,[u*Math.sin(l),{x:p,y:f}]},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==";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))}e.Bimface.Viewer.Viewer3D&&"Viewer3D"===t.viewerType&&(n=!0),document.addEventListener("keydown",(function(e){const t=e.keyCode||evt.which||evt.charCode;17==t?s=!0:18==t&&(r=!0)})),document.addEventListener("keyup",(function(e){const t=e.keyCode||evt.which||evt.charCode;17==t?s=!1:18==t&&(r=!1)})),o.addEventListener("mousedown",(function(e){t._opt.enableZoomRect||s||r||(l={x:e.clientX,y:e.clientY})})),o.addEventListener("mousemove",(function(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}})),o.addEventListener("mousewheel",h,!1),o.addEventListener("DOMMouseScroll",h,!1),o.addEventListener("mouseup",(function(e){l=!1,a=!1,o.removeClass("motion-translate"),o.removeClass("motion-rotate")}))},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("#")?document.getElementById(e.replace("#","")):e.indexof(".")?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,c=e.parentElement.offsetWidth,d=e.parentElement.offsetHeight,u=Math.min(r+t.x,c-l),g=Math.min(a+t.y,d-h),p=r+t.x<0?0:u>0&&u||0,f=a+t.y<0?0:g>0&&g||0;i&&0!=p&&0!=f||(e.style.left=`${p}px`,e.style.top=`${f}px`,e.style.transform="none",n.record&&n.record(p,f))};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",c)}else s={x:a.touches[0].clientX,y:a.touches[0].clientY},r.addEventListener("touchmove",c);n.start&&n.start(s)},c=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;case"all":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()},d=function(){a&&n.end&&n.end(s),a=!1,document.removeEventListener("mousemove",c),r.removeEventListener("touchmove",c)};i?(r.style.cursor=n.cursor,r.style.userSelect="none",r.addEventListener("mousedown",h),document.addEventListener("mouseup",d)):(r.addEventListener("touchend",d),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",c),document.addEventListener("touchmove",c))},c=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;case"all":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)},d=function(){s&&i.end&&i.end(o),s=!1,document.removeEventListener("mousemove",c),document.removeEventListener("touchmove",c)};n.addClass("bf-sizable"),n.appendChild(r),r.addEventListener("mousedown",h),r.addEventListener("touchstart",h),document.addEventListener("mouseup",d),document.addEventListener("touchend",d)}}(),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},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(){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 l=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");l.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}}};var h=l.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}}},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 c=window.hostConfig||{APIHost:"https://api.bimface.com",resourceHost:"https://m.bimface.com",staticHost:"https://static.bimface.com",dataEnvType:"BIMFACE",securityApi:!0};!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:`${c.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=`${c.resourceHost}/${t}/${r.preview.path}`,e.push(r))}n&&n(e)}})},t.getDrawingSheets=function(t,i,n){e.Web.Lang.Utility.HttpRequest.ajax({url:`${c.resourceHost}/${t}/metadata/drawings.json`,success:function(e){for(var t=JSON.parse(e).drawingList,o=0;o<t.length;o++){var s=t[o];if(s.viewInfo.id==i){n&&n(s);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,c=l-a;function d(e){return"FloorPlan"==e||"CeilingPlan"==e}function u(t,i,r,l,d){let u=e.x/n,g=(o-e.y)/o;if("Elevation"==d.viewType){g=(n-e.x)/n,u=e.y/o;var p=d.viewPoint.viewDirection;1!=Math.round(p[0])&&-1!=Math.round(p[1])||(u=(o-e.y)/o)}let f=(t-s)/h,m=(i-s)/h;if(u<f||u>m)return null;let w=(r-a)/c,v=(l-a)/c;if(g<w||g>v)return null;let y=(u-f)/(m-f),b=(g-w)/(v-w),x=((d.outline[2]-d.outline[0])*y+d.outline[0])*d.viewPoint.scale,E=((d.outline[3]-d.outline[1])*b+d.outline[1])*d.viewPoint.scale;return new THREE.Vector3(x,E,0)}let g=(i=t).portsAndViews;for(var p=0;p<g.length;p++){let e=g[p];if(!d(e.viewType))continue;let t=u(e.viewport[0],e.viewport[3],e.viewport[1],e.viewport[4],e);if(null!=t){if(d(e.viewType))null!==t&&(t.z=e.elevation);else if("Elevation"==e.viewType){var f=e.viewPoint.viewDirection,m=e.cropBox;0!=Math.round(f[0])?null!==t&&(t.z=t.y,t.y=t.x,t.x=f[0]<0?m[3]:m[0]):0!=Math.round(f[1])&&null!==t&&(t.z=t.y,t.y=f[1]<0?m[4]:m[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,c=l-a,d=(0-s)/h,u=l/c,g=(t.x-n*d)/n,p=(o*u-t.y)/o;return g=g*h*i.viewPoint.scale,p=p*c*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 c=h[t];if("FloorPlan"!==c.viewType)continue;let d=c.viewPoint.scale,u=c.outline[0]*d,g=c.outline[2]*d,p=c.outline[1]*d,f=c.outline[3]*d;if(e.x<u||e.x>g)continue;if(e.y<p||e.y>f)continue;let m=(e.x-u)/(g-u),w=(e.y-p)/(f-p),v=c.viewport[3]-c.viewport[0],y=c.viewport[4]-c.viewport[1];i(n*((c.viewport[0]+v*m-s)/(r-s)),o-o*((c.viewport[1]+y*w-a)/(l-a)),c)}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,c=l-a,d=(0-s)/(r-s),u=l/(l-a),g=e.x/(h*t.viewPoint.scale),p=e.y/(c*t.viewPoint.scale);return{x:g=g*n+n*d,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},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},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},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},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},Array.prototype.insert=function(e,t){return this.splice(e,0,t),this},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}},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}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").CoordinateConvertor=class{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(h.assertParamsType(t,i,"str")&&h.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(h.assertParamsType(t,i,"str")&&h.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])}};const d=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=d,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").Direction=Object.freeze({Horizontal:"Horizontal",Vertical:"Vertical"}),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Authentication").AuthenticationConfig=function(){return{APIHost:c.APIHost,viewToken:null,enableStorage:!1}};class u 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 u).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:c.APIHost,resourceHost:c.resourceHost,viewToken:null,modelId:null,modelType:"singleModel",dataEnvType:c.dataEnvType||"BIMFACE"}};var g,p,f,m,w,v,y,b=window.CLOUD=window.CLOUD||{};!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={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)},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){this._opt;var t={},i=[];this._helper;"integrateModel"==e.modelType?(t.Grids=[],n({url:`${e.relativeUrl}/data/files.json`,async:!1,success:function(i){JSON.parse(i).data.forEach((i=>{n({url:`${e.relativeUrl}/metadata/${i.fileId}/axisgrids/grids.json.gz`,async:!1,success:function(e){var i=b.AxisGridManager.adaptGridData(JSON.parse(e));t.Grids.push(...i.grids)}})}))}})):n({url:`${e.relativeUrl}/metadata/axisgrids/grids.json.gz`,async:!1,success:function(e){var i=b.AxisGridManager.adaptGridData(JSON.parse(e));t.Grids=i.grids}}),n({async:!1,url:`${e.relativeUrl}/metadata/levels.json`,success:function(e){t.Levels=JSON.parse(e).levels}}),n({async:!1,url:`${e.relativeUrl}/resource/v3/maps/output.json`,dataType:"text",success:function(t){var n=JSON.parse(t);for(var o in n){var s=n[o];null==s.id&&(s.id=o),s.path=`${e.relativeUrl}/resource/v3/maps/${s.id}.png`,s.name=o,i.push(s)}}});let o=t.Levels;if(o){let e=e=>{let t=!1;return i.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:t,floors:i}},getMapInfoAsync:function(e){return new Promise(((t,n)=>{let o={Grids:[]},s=[];const r=i=>{for(var n in i){var r=i[n];null==r.id&&(r.id=n),r.path=`${e.relativeUrl}/resource/v3/maps/${r.id}.png`,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--)}t({axisGrid:o,floors:s})};"integrateModel"!=e.modelType?Promise.allSettled([i(`${e.relativeUrl}/metadata/axisgrids/grids.json.gz`,"noCode"),i(`${e.relativeUrl}/metadata/levels.json`,"noCode"),i(`${e.relativeUrl}/resource/v3/maps/output.json`,"noCode")]).then((e=>{let[t,i,n]=e;var s=b.AxisGridManager.adaptGridData(t.value);o.Grids=s.grids,o.Levels=i.value.levels,r(n.value)})).catch(n):i(`${e.relativeUrl}/data/files.json`,"noCode").then((t=>{Promise.allSettled([i(`${e.relativeUrl}/metadata/levels.json`,"noCode"),i(`${e.relativeUrl}/resource/v3/maps/output.json`,"noCode"),...t.data.map((t=>i(`${e.relativeUrl}/metadata/${t.fileId}/axisgrids/grids.json.gz`,"noCode")))]).then((e=>{let[t,i,...n]=e;n.forEach((e=>{if(e.value){var t=b.AxisGridManager.adaptGridData(e.value);o.Grids.push(...t.grids)}})),o.Levels=t.value.levels,r(i.value)})).catch(n)}))}))},getLevels:function(e,t){let n=`${t.relativeUrl}/metadata/levels.json`;return e&&(n=`${t.relativeUrl}/metadata/${e}/levels.json`),i(n,"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")}};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={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.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)}))},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)}))},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){var t=i.getMapInfo(this._config);e&&e(t)},getMapInfoAsync:function(e,t){i.getMapInfoAsync(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},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)}))}},t.OfflineDataManager=n}(),g=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),p=(t,i)=>e.Web.Lang.Utility.HttpRequest.promiseJSONRequest(t,i,b.EnableStorage),f=e.Web.Lang.Utility.HttpRequest.ajax,m={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`;return p(i,"noCode")},getTreeNewData:function(e){var t=`${e.resourceHost}/${e.databagId}/data/tree.json`;return p(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 p(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 p(n)},fromIntegrateModel:function(t,i,n){var o=`${e.APIHost}/data/v2/integrations/${t}/drawingsheets?fileIdHash=${i}&elementId=${n}&view_token=${e.viewToken}`;return p(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 p(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 p(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 p(i)},getObjectData:function(e,t){if("singleModel"==e.modelType)var i=`${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.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?view_token=${e.viewToken}`}else i=`${e.APIHost}/data/v2/sections/${e.modelId}/elements/${t}?view_token=${e.viewToken}`;return p(i)},getFamilyData:function(e,t){let i=`${e.APIHost}/data/v2/rfaFiles/${e.modelId}/familyTypes/${t}?view_token=${e.viewToken}`;return p(i)},getEditedObjectData:function(e,t){if("singleModel"==e.modelType)var i=`${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.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?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 p(i)},getFiles:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/files?includeDrawingSheet=true&view_token=${e.viewToken}`;return p(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 p(n)},getLinkGraph:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/linkGraph?view_token=${e.viewToken}`;return p(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 p(n)}failure&&failure({})},getDrawingsheets:function(e,t){var i=`${e.APIHost}/data/v2/files/${t}/drawingsheets?fileId=${t}&view_token=${e.viewToken}`;return p(i)},getAllDrawingsheets:function(e,t){var i=`${e.resourceHost}/${e.integrateDrawings&&e.integrateDrawings.databagId||e.databagId}/metadata/drawings.json`;return p(i,"noCode")},getLinksJson:function(e,t){var i=`${e.resourceHost}/${e.databagId}/metadata/links.json`;return p(i,"noCode")},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 p(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 p(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 p({url:r,type:"post",data:JSON.stringify(s),headers:{"Content-Type":"application/json"}})},getMaterialJson:function(e,t,i){return p({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 p({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){this._opt;var t={},i=[];this._helper,"integrateModel"==e.modelType?(t.Grids=[],f({url:`${e.APIHost}/data/v2/integrations/${e.modelId}/files?includeDrawingSheet=true&view_token=${e.viewToken}`,async:!1,success:function(i){JSON.parse(i).data.forEach((i=>{f({url:`${e.resourceHost}/${e.databagId}/metadata/${i.fileId}/axisgrids/grids.json.gz`,async:!1,success:function(e){var i=b.AxisGridManager.adaptGridData(JSON.parse(e));t.Grids.push(...i.grids)}})}))}})):f({url:`${e.resourceHost}/${e.databagId}/metadata/axisgrids/grids.json.gz`,async:!1,success:function(e){var i=b.AxisGridManager.adaptGridData(JSON.parse(e));t.Grids=i.grids}}),f({async:!1,url:`${e.resourceHost}/${e.databagId}/metadata/levels.json`,success:function(e){t.Levels=JSON.parse(e).levels}}),f({async:!1,url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,dataType:"text",success:function(t){var n=JSON.parse(t);for(var o in n){var s=n[o];null==s.id&&(s.id=o),s.path=`${e.resourceHost}/${e.databagId}/resource/model/maps/${s.id}.png`,s.name=o,i.push(s)}}});let n=t.Levels;if(n){let e=e=>{let t=!1;return i.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t<n.length;t++)e(n[t].id)||(n.splice(t,1),t--)}return{axisGrid:t,floors:i}},getMapInfoAsync:function(e){return new Promise(((t,i)=>{let n={Grids:[]},o=[];const s=i=>{for(var s in i){var r=i[s];null==r.id&&(r.id=s),r.path=`${e.resourceHost}/${e.databagId}/resource/model/maps/${r.id}.png`,r.name=s,o.push(r)}let a=n.Levels;if(a){let e=e=>{let t=!1;return o.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--)}t({axisGrid:n,floors:o})};"integrateModel"!=e.modelType?Promise.allSettled([p(`${e.resourceHost}/${e.databagId}/metadata/axisgrids/grids.json.gz`,"noCode"),p(`${e.resourceHost}/${e.databagId}/metadata/levels.json`,"noCode"),p(`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,"noCode")]).then((e=>{let[t,i,o]=e;var r=b.AxisGridManager.adaptGridData(t.value);n.Grids=r.grids,n.Levels=i.value.levels,s(o.value)})).catch(i):p(`${e.APIHost}/data/v2/integrations/${e.modelId}/files?includeDrawingSheet=true&view_token=${e.viewToken}`,"noCode").then((t=>{Promise.allSettled([p(`${e.resourceHost}/${e.databagId}/metadata/levels.json`,"noCode"),p(`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,"noCode"),...t.data.map((t=>p(`${e.resourceHost}/${e.databagId}/metadata/${t.fileId}/axisgrids/grids.json.gz`,"noCode")))]).then((e=>{let[t,i,...o]=e;o.forEach((e=>{if(e.value){var t=b.AxisGridManager.adaptGridData(e.value);n.Grids.push(...t.grids)}})),n.Levels=t.value.levels,s(i.value)})).catch(i)}))}))},getLevels:function(e,t){let i=`${t.resourceHost}/${t.databagId}/metadata/levels.json`;return e&&(i=`${t.resourceHost}/${t.databagId}/metadata/${e}/levels.json`),p(i,"noCode")},getViews:function(e){var t={data:null,resourceHost:e.resourceHost};return f({url:`${e.resourceHost}/${e.databagId}/metadata/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewsById:function(e){var t={data:null,resourceHost:e.resourceHost};return f({url:`${e.resourceHost}/${e.databagId}/metadata/${e.fileId}/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewData:function(e){let t=`${e.resourceHost}/${e.databagId}/metadata/viewStates/${e.viewId}.json`;return p(t,"noCode")},getRooms:function(e){let t=`${e.resourceHost}/${e.databagId}/metadata/rooms.json`;return p(t,"noCode")},getRoomBoundary:function(e,t){let i=`${t.resourceHost}/${t.databagId}/metadata/roomsboundary/${e}.json`;return p(i,"noCode")},getCategoryVisibility:function(e){var t=`${e.resourceHost}/${e.databagId}/metadata/categoryVisibility.json`;return p(t,"noCode")},getText:function(e){var t=`${e.resourceHost}/${e.databagId}/metadata/text.json`;return p(t,"noCode")},getScheduleList:function(e){var t=`${e.resourceHost}/${e.databagId}/metadata/schedule.json`;return p(t,"noCode")},getScheduleById:function(e,t){var i=`${t.resourceHost}/${t.databagId}/metadata/schedule/${e}.txt`;return p(i,"noCode")},getSegmentGroups:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups?view_token=${e.viewToken}`;return p(t,"noCode")},getSegmentFromGroups:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups/${t}/segments?view_token=${e.viewToken}`;return p(i,"noCode")},getSegmentTree:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentTree?view_token=${e.viewToken}`;return p(t,"noCode")},getSegmentById:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}?view_token=${e.viewToken}`;return p(i,"noCode")},getSegmentElementIds:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}/elementIds?view_token=${e.viewToken}`;return p(i,"noCode")},getPartialElementsMetadata:function(e,t){var i=`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`;return p(i,"noCode")},getPartialElementsMetadataFile:function(e,t){return`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`},getDatabagResource:function(e,t){return`${e.resourceHost}/${t}/resource/v3/model`},getModelGroup:function(e,t){var i=`${e.resourceHost}/${e.databagId}/metadata/modelSetsTree.json`;return p(i,"noCode")},getManifest:function(e){var t=`${e.resourceHost}/${e.databagId}/manifest.json`;return p(t,"noCode")},getNestedComponents:function(e){var t=`${e.relativeUrl}/metadata/nestedComponents.json`;return p(t,"noCode")},getObjectMap:function(e){var t=`${e.relativeUrl}/metadata/objectMap.json.gz`;return p(t,"noCode")},getWalkthrough:function(e){var t=`${e.relativeUrl}/data_ext/walkthrough.json`;return p(t,"noCode")},getProjectInfo:function(e){var t=`${e.resourceHost}/${e.databagId}/metadata/project.json`;return p(t,"noCode")},getModelInfo:function(e){var t=`${e.relativeUrl}/resource/v3/model/config.json`;return p(t,"noCode")},getBimtileInfo:function(e,t){return p(`${e}/resource/v3/model/${t}`,"noCode")},getFeatureStyle:function(e){var t=`${e.relativeUrl}/resource/v3/model/featureStyle.json`;return p(t,"noCode")},getDimensions:function(e,t){let i=`${t.relativeUrl}/metadata/ModelDimensions.json`;return"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/ModelDimensions.json`),p(i,"noCode")}},g.OnlineDataProdiver=m,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}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){b.EnableStorage?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){b.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){var n=this;i.getTreeNewData(n._config).then((function(t){e&&e(t,n._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){var t=i.getMapInfo(this._config);e&&e(t)},getMapInfoAsync:function(e,t){i.getMapInfoAsync(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},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).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)}))}},t.OnlineDataManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=(e.Web.Lang.Utility.HttpRequest,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={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){this.dataManager.getTreeNewData(e,t)},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){this.dataManager.getMapInfo(e)},getMapInfoAsync:function(e,t){this.dataManager.getMapInfoAsync(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)}},t.MetaDataManager=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").FamilyDataManagerConfig=function(){return{resourceHost:c.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;n="Local"==o.dataEnvType?`./${o.databagId}/metadata/familyInfo.json`:`${o.resourceHost}/${o.databagId}/metadata/familyInfo.json`,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:c.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=(e.Web.Lang.Utility.HttpRequest,{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={},c=[],d=0,u=0,g=t[2],p=t[1];u<g;++u){a=4*o[r=2*(p+u)],l=o[r+1];var f=h[d=s[a]];void 0===f&&(f=[],h[d]=f,c.push(d)),f.push({key:n[s[a+1]],unit:n[s[a+3]],valueType:s[a+2],value:n[l]})}for(var m=[],w=(u=0,c.length);u<w;++u)d=c[u],m.push({group:n[d],items:h[d]});return m},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={},c=[],d=0,u=0,g=t[2],p=t[1];u<g;++u){a=4*o[r=2*(p+u)],l=o[r+1];var f=h[d=s[a]];void 0===f&&(f=[],h[d]=f,c.push(d)),f.push({key:n[s[a+1]],unit:n[s[a+3]],valueType:s[a+2],value:n[l]})}for(var m=[],w=(u=0,c.length);u<w;++u)d=c[u],m.push({group:n[d],items:h[d]});var v=this.getFamilyTypeProperties(t[3]);if(!v)return m;var y={},b=[];for(var x of m=v.concat(m))if(y[x.group]){var E=[].concat.apply(y[x.group].items,x.items),C=[];for(var M of E){var P=!0;for(var I of C)M.key==I.key&&(P=!1);P&&C.push(M)}y[x.group]={group:y[x.group].group,items:C}}else y[x.group]=x;for(var x in y)"基本属性"==y[x].group?b.unshift(y[x]):b.push(y[x]);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}},c=[];for(let e of s)c.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 c){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 d=o.groups[e+1],u=o.groups[e+2];for(var g in d)for(var p of d[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:c.APIHost,resourceHost:c.resourceHost,viewToken:null,modelId:null,modelType:"singleModel",dataEnvType:c.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(){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){if(!this._enable)return;const i=e=>(")"!==(e=e.toString())[e.length-1]&&(e+="()"),e),n=`${e=i(e)} is obsolete, please use ${t=i(t)} instead.`;this.setConsoleType("warn"),this.warn(n)}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=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._defaultUnit=void 0,this.getEventManager=function(){return t}});o.prototype.destroy=function(){this.getEventManager=null},o.prototype.init=function(){},o.prototype.getViewerType=function(e){return this.viewerType},o.prototype.addView=function(t,i,o){if(!n)return;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;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},t.Viewer=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingConfig=function(){return{domElement:null,resourceHost:c.resourceHost,staticHost:c.staticHost+"/api/Glodon",APIHost:c.APIHost,securityApi:c.securityApi,sdkUrl:null,staticPath:"/api/Glodon",enableLineWidth:!1,displayMode:0,enableHover:!0,enableViewport:!1}},function(){let t=Object.freeze({ViewAdded:"ViewAdded",ViewLoading:"ViewLoading",ComponentsSelectionChanged:"ComponentsSelectionChanged",SelectionChanged:"SelectionChanged",ComponentsHoverChanged:"ComponentsHoverChanged",Error:"Error",Loaded:"Loaded",LoadDrawing:"LoadDrawing",MouseClicked:"MouseClicked",MouseDragged:"MouseDragged",ContextMenu:"ContextMenu",Rendered:"Rendered",ViewChanged:"ViewChanged",ViewMoving:"ViewMoving",ViewMoved:"ViewMoved",ViewZooming:"ViewZooming",ViewZoomed:"ViewZoomed",Hover:"Hover",ZoomFactorChanged:"ZoomFactorChanged",ButtonOnToolbarClicked:"ButtonOnToolbarClicked",RectSelection:"RectSelection"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingEvent=t}(),function(){let t=Object.freeze({Pan:"pan",RectZoom:"rectZoom",Zoom:"zoom",AreaMeasure:"AreaMeasure",AngleMeasure:"AngleMeasure",Pick:"pick",Measure:"DistanceMeasure"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").NavigationModeDrawing=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=[]}setSnap2DList(e){this.snapList=e}getSnap2DList(){return this.snapList}setSnap3DList(e){this.snapList=e}getSnap3DList(){return this.snapList}setSnapConditions(e){this.snapConditions=e}getSnapConditions(){return this.snapConditions}}}(),function(){var t="Glodon.Bimface.Model.Drawing",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,"GlobalData"),s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics"),r=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),a=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),e.Bimface.Viewer.ViewerDrawingEvent);o.isInitialized=o.isInitialized||!1;const l={Window:1,Crossing:2};let h=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable(),c=["rgb(50,50,55)","rgb(255,255,255)","rgb(255,255,255)","rgb(50,50,55)"];class d extends e.Bimface.Viewer.Viewer{constructor(o){super(o),n.Viewer.call(this);e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(h){this.viewerType="ViewerDrawing";let n=o;this._opt=o,this.isInitialized=!1,this.hasBindEvents=!1,this.grids=null,this.cursorReady=!1,this.snapIsEnabled=!1,this.drawingConsole=new e.Web.Common.Console,this._cache={};var s=o.rootElement||r.create("div","bf-drawing-container"),l=o.domElement;this.drawingIndex=-1,this.isAlignment=!1,this.fileName=o.fileName,this.modelId=o.modelId,this.wrapElement=l,this.visible=!0,this.eventManager=o.eventManager,this.selfEventManager=new e.Web.Lang.EventManager,this.viewToken=o.viewToken;var c,d=o.domElement;d.addClass("viewerDrawingWrap"),d.id?c=d.id:(c=e.Web.Lang.Utility.UUID.createUUID(),d.id=c),n.domElement=s,this._domElement=d,this._viewConfig=n,this.rootElement=s,this.getDomElement=function(){return l},this.getRootElement=function(){return s},this.getViewer=function(){return this._drawingViewer},this.getEventManager=function(){return this.eventManager},this.getSelfEventManager=function(){return this.selfEventManager},this._pressAlt=!1,this._pressCtrl=!1,e.Bimface.WebglDrawingSheet.onLoadProgress=function(e){var t=document.querySelector(".bf-drawing-container .bf-loading-text");t&&e&&(t.innerText=parseInt(100*e)+"%")},this.getSelfEventManager().addEvent(a.Loaded,(function(){i.send(t,"Loaded",{eventId:"加载",loadModel:"expert",type:"drawing"})}))}else this._loadNotSuportPromptPage(o.domElement)}showLoading(){this.rootElement.style.zIndex=5;var e=r.create("div","bf-loading"),t=r.create("div","bf-loading-gif"),i=r.create("div","bf-loading-text");e.appendChild(t),e.appendChild(i),this.loading=e,this.rootElement.appendChild(e)}getIndexJson(t,i){e.Web.Lang.Utility.HttpRequest.ajax({url:`${t}/index.json`,success:function(e){var t=JSON.parse(e);t&&i(t)}})}createDrawingViewer(t,i){var n;"2"==this.version?n=e.Bimface.WebglDrawingSheet:(n=e.Bimface.DrawingSheet,this.isInitialized=!0);let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();var s=n.createDrawing(t,i);return s.mouseEditorMgr=o?this._drawingViewer&&this._drawingViewer.mouseEditorMgr||n.createMouseEditorManager(s):this._drawingViewer&&this._drawingViewer.mouseEditorMgr||n.createTouchEditorManager(s),s}enableViewport(e){this._drawingViewer.enableViewport&&this._drawingViewer.enableViewport(e)}showViewById(e){i.send(t,"showViewById"),this._drawingViewer.activeLayoutById(e||0),this.getEventManager().fireEvent(a.ViewChanged,e)}setPrintMode(e){this._drawingViewer&&(this._drawingViewer.setPrintMode(e,this.drawingIndex),this._drawingViewer.update(!0))}setDisplayMode(e){if(i.send(t,"setDisplayMode"),e=e||0,"1"==this.version&&3==e)return this.drawingConsole.updateDataSource("ViewerDrawing.setDisplayMode(3)");this.rootElement.style.background=c[e],0==e?"2"==this.version&&this._drawingViewer.setSelectWireframeColor(1,1,1,1):3!=e&&"2"==this.version&&this._drawingViewer.setSelectWireframeColor(.733,.733,.733,1),1!=e&&2!=e||"2"!=this.version?"2"==this.version&&this._drawingViewer.enableReplaceElementColor(!1):(this._drawingViewer.enableReplaceElementColor(!0),this._drawingViewer.replaceElementColor(1,1,1,0,0,0)),this._opt.displayMode=e;this.setPrintMode(["Normal","White","Black","Custom"][e])}getManifest(t){let i=e.Web.Lang.Utility.HttpRequest,n=this._viewMetaData||this._data,o=n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||this._viewConfig.resourceHost)+"/"+o+"/manifest.json");i.ajax({url:`${s}`,success:function(e){var i=JSON.parse(e);i&&t(i)},failure:function(e){t(e)}})}home(){let e="2"===this.version?.2:void 0;this.modelBBox?this._drawingViewer.zoomToWorldBox(this.modelBBox[0],this.modelBBox[1],e):this._drawingViewer.zoomToExtent(e),this._drawingViewer.update()}enableHover(e){i.send(t,"enableHover"),this._opt.enableHover=e,this._drawingViewer.enableHover(e)}loadWebGL(t,i,n,s,r,l){var h,c=this;this.grids=null,n&&(i=i+(s?"/"+s:"")+"/"+n),c._drawingViewer?h=c._drawingViewer:c._drawingViewer=h=t&&t._drawingViewer||c.createDrawingViewer(c.rootElement.id),h.viewer.SetPreLoad(!0),h.update(),e.Bimface.WebglDrawingSheet.addModel(i,h,(function(i,s,d){if(r){const e=d.data.find((e=>c.getCurrentViewId()==e.id));c.currentFrameBoundingBox=e.frames[r-1].bbox}c.drawingIndex=s;for(var u=document.querySelectorAll(".bf-drawing-container .bf-loading"),g=u.length,p=0;p<g;p++)u[p].remove();c.rootElement.style.zIndex=1,o.loading=!1,c.enableViewport(c._opt.enableViewport);var f=h.getLayouts();if(l&&f.length>1)c._drawingViewer.activeLayoutById(f[1].id);else if(n){var m,w=null;for(p=0;p<f.length;p++)if("Layout1"==f[p].name){w=f[p].id;break}w&&c.showViewById(w),this.model={Url:i.url+"/"},(m=new e.Bimface.RevitInterop).initialize(h,this.model.Url),c.revitInterop=m,c.revitInteropReady=!1,m.callback=()=>{c.revitInteropReady=!0}}e.Web.Lang.Utility.ClientHelper.getIsDesktop()?!c._drawingViewer.mouseEditorMgr&&(c._drawingViewer.mouseEditorMgr=e.Bimface.WebglDrawingSheet.createMouseEditorManager(h)):!c._drawingViewer.mouseEditorMgr&&(c._drawingViewer.mouseEditorMgr=e.Bimface.WebglDrawingSheet.createTouchEditorManager(h)),!c._drawingViewer.mouseEditorMgr.allEvent&&c._drawingViewer.mouseEditorMgr.bindEvents(),c.observer(c._drawingViewer.mouseEditorMgr),c._drawingViewer.mouseEditorMgr.activeEditorByName("pick"),window.addEventListener("resize",(function(){h&&h.onResize()})),c._drawingViewer.onViewChanges=function(){c.getEventManager().fireEvent(a.Rendered,c._drawingViewer)},c.setDisplayMode(c._opt.displayMode),!c._opt.enableViewport&&c.home(),c.getManifest((function(e){let i=(e=e||{}).Features,n=Object.assign({},i||{}),o=c._viewMetaData||c._data,s=!0,r=!0,l=!1,h=!1;i&&(s=i.HasLayout,r=i.HasMiniMap,l=i.HasText),(o.split&&o.split.databagId||o.config&&o.config.split)&&(h=!0),n=Object.assign(n,{HasLayout:s,HasMiniMap:r,HasText:l,HasSplitDrawing:h}),c._manifest=Object.assign(e,{Features:n}),t._manifest=Object.assign(e,{Features:n}),c.getSelfEventManager().fireEvent(a.Loaded,c.modelId,c._drawingViewer.mouseEditorMgr,c)})),c.cursorReady||(e.Web.Lang.Utility.MouseMotion.setCursor(c),c.cursorReady=!0),c.enableHover(c._opt.enableHover)}),r)}getViewMetaData(t,i,n){var o=this;let s,r=e.Bimface.Authentication.AuthenticationManager,a=new e.Bimface.Authentication.AuthenticationConfig;a.viewToken=t,a.APIHost=this._viewConfig.APIHost,s=n?new r(a):this.authenticate=new r(a),s.authenticate((function(e){let t=e.integrateDrawings&&e.integrateDrawings.databagId||e.databagId;e.drawingUrl=`${o._viewConfig.resourceHost}/${t}/resource/drawing`,i(e)}))}getViewScale(){return this._drawingViewer.getViewScale()}getObjectViews(){let e=this.getViews(),t={};for(let i=0;i<e.length;i++)t[e[i].name]=e[i].id;return t}observer(t){let i=null,n=this;t.observer=function(t,o,s,r,l,h){if("zoom"==t&&"exit"==o&&(n.getEventManager().fireEvent(a.ViewZoomed),n._opt.enableZoomRect=!1),"zoomFactorChanged"==o&&n.getEventManager().fireEvent(a.ZoomFactorChanged,s),("DistanceMeasure"==t||"AngleMeasure"==t||"AreaMeasure"==t)&&"change"==o){var c=n.getViewScale(),d=null;s&&"Distance"===s.type?d="measured"===s.status?{type:s.type,distance:s.distance*c,points:s.points,start:[s.start[0]*c,s.start[1]*c],end:[s.end[0]*c,s.end[1]*c],isOnLayout:s.isOnLayout}:{type:s.type,points:s.points}:s&&"Area"===s.type?d={type:"Area",points:s.points,area:"measured"===s.status&&s.area*c*c||null}:s&&"Angle"===s.type&&(d=s),"measuring"===s.status?n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,d):"measured"===s.status?n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,d):"reset"===s.status&&n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset)}if("pick"==t&&"selection"==o&&(n.getEventManager().fireEvent(a.ComponentsSelectionChanged,s),n.getEventManager().fireEvent(a.SelectionChanged,s)),"pick"==t&&"highlight"==o)if(s.length>0){if(i==s[0])return;let e=n._drawingViewer.toWorldPoint([r,l]);n.getEventManager().fireEvent(a.Hover,{objectId:s[0],clientPosition:{x:r,y:l},worldPosition:{x:e[0],y:e[1]},event:h}),i=s[0]}else i=null}}showLineWidth(e){i.send(t,"showLineWidth"),this._opt.enableLineWidth=e,this._drawingViewer.viewer.ShowLineWidth=e,this.update(!0)}loadModel(t,i,n){var s=this,r=this._drawingViewer,l=r.mouseEditorMgr;r.touchEditorMgr;this.grids=null,i&&(t=t+(n?"/"+n:"")+"/"+i,e.Bimface.DrawingSheet.loadGrids(t,(function(e){e&&(s.grids=e.grids,drawingConsole.info(e))}))),e.Bimface.DrawingSheet.loadModel(t,(function(t,n){if(s.drawingIndex=n,null!==t){if(r.setModel(t),r.clearSelection(s.drawingIndex),i){var h,c=r.getLayouts(),d=null;for(p=0;p<c.length;p++)if("Layout1"==c[p].name){d=c[p].id;break}d&&s.showViewById(d),(h=new e.Bimface.RevitInterop).initialize(r,this.model.Url),s.revitInterop=h}s.hasBindEvents||(l.bindEvents(),s.hasBindEvents=!0),s.observer(l),l.activeEditorByName("pick"),o.loading=!1;var u=(g=document.querySelectorAll(".bf-drawing-container .bf-loading")).length;for(p=0;p<u;p++)g[p].remove();s.rootElement.style.zIndex=1,window.addEventListener("resize",(function(){r&&r.onResize()})),r.onViewChanges=function(){s.getEventManager().fireEvent(a.Rendered,r)},s.enableViewport(s._opt.enableViewport),s.setDisplayMode(s._opt.displayMode),!s._opt.enableViewport&&s.home(),s.showLineWidth(s._opt.enableLineWidth),s.getManifest((function(e){let t=(e=e||{}).Features,i=Object.assign({},t||{}),n=s._viewMetaData||s._data,o=!0,r=!0,l=!1,h=!1;t&&(o=t.HasLayout,r=t.HasMiniMap,l=t.HasText),(n.split&&n.split.databagId||n.config&&n.config.split)&&(h=!0),i=Object.assign(i,{HasLayout:o,HasMiniMap:r,HasText:l,HasSplitDrawing:h}),s._manifest=Object.assign(e,{Features:i}),s.getSelfEventManager().fireEvent(a.Loaded,s.modelId,s._drawingViewer.mouseEditorMgr,s)})),s.cursorReady||(e.Web.Lang.Utility.MouseMotion.setCursor(s),s.cursorReady=!0),s.enableHover(s._opt.enableHover)}else{drawingConsole.warn("failed to load model!"),o.loading=!1;for(var g=document.querySelectorAll(".bf-drawing-container .bf-loading"),p=0;p<g.length;p++)g[p].remove();s.rootElement.style.zIndex=1}}))}loadIndexJson(e,t,i,n){let o=this,s=e.drawingUrl;t&&(s=s+(i?"/"+i:"")+"/"+t),this.url=s,this.getIndexJson(s,(function(e){var t=document.querySelector(".bf-drawing-container .bf-loading-text");o.version&&(o.prevVersion=o.version),"2"==e.metadata.version||"2"==e.metadata["version:"]?(o.version="2",t.innerText="0%"):(o.version="1",t.innerText=BimfaceLanguage.bf_load),n()}))}initialize(t,i,n,s){if(this.isInitialized)return!1;var r=this;if("bimView"==t.renderType&&t.subRenders&&0!=t.subRenders.length)for(var a=0;a<t.subRenders.length;a++)"drawingView"==t.subRenders[a].renderType&&(e.Bimface.DrawingSheet.sdkUrl=r._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||r._viewConfig.staticHost+"/"+t.subRenders[a].jsSDKVersion);else e.Bimface.DrawingSheet.sdkUrl=r._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||r._viewConfig.staticHost+"/"+t.jsSDKVersion;"2"==r.version||"2.0"==t.renderVersion?(!r.modelId&&(r.modelId=t.modelId),this.loadWebGL(s,t.drawingUrl,i,n)):e.Bimface.DrawingSheet.initialize((function(){r._drawingViewer=s&&s._drawingViewer||r.createDrawingViewer(r.rootElement.id),r.loadModel(t.drawingUrl,i,n),o.isInitialized=!0}))}setState(e){i.send(t,"setState"),this._drawingViewer&&(this._drawingViewer.setState(e),this._drawingViewer.update())}getLayerIdFromElementId(e){if(this._drawingViewer.getLayerIdFromElementId)return this._drawingViewer.getLayerIdFromElementId(e,this.drawingIndex)}getLayerById(e){for(var t=this.getLayers(),i=0,n=t.length;i<n;++i){var o=t[i];if(o.id==e)return o}return!1}getCurrentViewId(){return this._drawingViewer.getActiveLayoutId()}loadFrame(t,i,n){let o=this;this.showLoading(),this.getDomElement().addClass("drawingFrame"),this.getViewMetaData(t,(function(t){let s=t.drawingUrl;o.getIndexJson(s,(function(s){"2"==s.metadata.version||"2"==s.metadata["version:"]?o.version="2":o.version="1";let r,a=t.split&&t.split.databagId;r=a?e.Web.Lang.Utility.ClientHelper.formatURL((t.path||o._viewConfig.resourceHost)+"/"+a+"/resource/drawing/Frames"):t.drawingUrl+"/Frames",!o.modelId&&(o.modelId=t.modelId),o.loadWebGL(n,r,null,null,i,!0),o._viewMetaData=t}))}))}load(t,i,n,s){if(!h)return!1;var r=this,a=arguments;if(this.getDomElement().removeClass("drawingFrame"),o.loading)return setTimeout((function(){r.load.apply(r,a)}),500);o.loading=!0,r.isInitialized||o.isInitialized?t&&this.getViewMetaData(t,(function(e){r.loadIndexJson(e,i,n,(function(){"1"==r.version&&(r._drawingViewer=s&&s._drawingViewer||r.createDrawingViewer(r.rootElement.id)),!r.modelId&&(r.modelId=e.modelId),"2"==r.version?r.loadWebGL(s,e.drawingUrl,i,n):r.loadModel(e.drawingUrl,i,n),r._viewMetaData=e}))})):t&&this.getViewMetaData(t,(function(t){r._viewMetaData=t,r.loadIndexJson(t,i,n,(function(){var o=e.Bimface.Data.StatisticsDataManager.getInstance();o.modelType=t.modelType,o.modelId=t.modelId,r.initialize(t,i,n,s)}))})),this.showLoading()}clientToWorld(e){var t=this._drawingViewer.toWorldPoint([e.x,e.y]);return{x:t[0],y:t[1]}}update(e){this._drawingViewer.update(e)}removeSelectId(e){this._drawingViewer.removeSelectId(e,this.drawingIndex),this.update()}selectByIds(e){i.send(t,"selectByIds"),Array.isArray(e)||(e=[e]),this._onSelectionChanged(e),this._drawingViewer.selectByIds(e,this.drawingIndex),this.update()}hideObjects(e){e.all&&(this._drawingViewer.hideAllElements(this.drawingIndex),this.visible=!1),e.all||this._drawingViewer.hideElementsById(e.objectIds,this.drawingIndex),this.update()}verify(e,t,i,n,o){if(!e)return;let s=null,r=this.getViewer(),a=r.snapToPoint(e[0],e[1]),l=a.GetPoint(),h=a.GetID();if(0!=h){let e=a.GetSnapTypeName(),n=(function(e,t){if(!e)return!1;if(!t)return!0;let i=e.GetSnapTypeName();t.snapList.includes({PointOnLine:"line",Intersection:"intersection",MiddlePoint:"midpoint",EndPoint:"endpoint"}[i])}(a,this.snapMode),r.toScreenPoint(l));return r.mouseEditorMgr.editors[0].drawTmpPoint(t,i,n,e),this.tempSnapPoint={worldPoint:l,id:h,screenPoint:n,type:e},s=n,s}return this.tempSnapPoint=null,s}enterMode(){let t=this.getViewer();t.setPrintMode("Custom",this.drawingIndex),t.setGlobalColor(new e.Web.Graphics.Color("#ffffff"),this.drawingIndex),this.update()}setBackgroundColor(e){this.getRootElement().setCss({background:e.getRGBA()}),3===this._displayMode&&(c[3]=e.getRGBA())}startMoving(){let e=this;this.isAlignment=!0,this._drawingViewer.alignmentPoints=[];const t=e.getViewer(),i=e.getRootElement().style.backgroundColor;t.oldBackgoundColorBeforeMoving=i,e._drawingViewer.mouseEditorMgr.editors[0].setIsOnlySnap(!1),e._drawingViewer.mouseEditorMgr.editors[0].captureFail=function(t,i,n){return e.verify(t,i,n,!0),!1},this.enterMode(!0),e._drawingViewer.mouseEditorMgr.activeEditorByName("capture")}endMoving(){this.isAlignment=!1,this.selectId=null,this._drawingViewer.alignmentPoints=[],this.getViewer().mouseEditorMgr.activeEditorByName("pick"),this.enterMode(!1);const t=this.getViewer().displayModeBeofreMoving;this.setDisplayMode(t);if((this.getViewer().oldBackgoundColorBeforeMoving?this.getViewer().oldBackgoundColorBeforeMoving.match(/\((.+?)\)/g):[]).length>0){const t=RegExp.$1.split(",");this.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}delete this.getViewer().oldBackgoundColorBeforeMoving}getInformation(){return{modelId:this.modelId,wrap:this.wrapElement,drawing:this,visible:this.visible,fileName:this.fileName}}setDrawingTransformation(e){this.getViewer().setModelTransformation(e,this.drawingIndex)}clearHighlight(){this._drawingViewer.clearHighlight(this.drawingIndex),this.update(!0)}_checkIfSelectionChanged(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),t.length!==e.length||t.sort().toString()!==e.sort().toString()}_onSelectionChanged(e){if(this._selectionChangedInfo)clearTimeout(this._selectionChangedInfo.timeout);else{const e=this.getSelectedObjects();this._selectionChangedInfo={lastSelection:e}}this._selectionChangedInfo.timeout=setTimeout((()=>{this._checkIfSelectionChanged(this.getSelectedObjects(),this._selectionChangedInfo.lastSelection)&&(this.getEventManager().fireEvent(a.ComponentsSelectionChanged,e),this.getEventManager().fireEvent(a.SelectionChanged,this.getSelectedObjects())),delete this._selectionChangedInfo}),10)}clearSelection(){const e=Array.from(new Set(this._drawingViewer.getSelectedIds(this.drawingIndex)));this._onSelectionChanged(e),this._drawingViewer.clearSelection(this.drawingIndex),this.update()}getAxisGrid(t,i){let n=this._cache;if(n.AxisGrid)return i(n.AxisGrid);e.Web.Lang.Utility.HttpRequest.ajax({url:t,success:function(e){var t=JSON.parse(e);if(t){let e={},o=t.intersection;for(let t=0;t<o.length;t++){let i=o[t].axisGrids[0],n=o[t].axisGrids[1],s=i>n?n:i,r=i>n?i:n;e[s]||(e[s]={}),e[s][r]||(e[s][r]=[]),e[s][r].push(o[t].intersection)}n.AxisGrid=e,i(e)}}})}getAxisGridsIntersection(e,t){var i=`${this.url}/AxisGrid.json`;let n=[];this.getAxisGrid(i,(i=>{for(let t=0;t<e.length-1;t++){const o=e[t];for(let s=t+1;s<e.length;s++){const t=e[s];let r=o>t?t:o,a=o>t?o:t,l=i[r]&&i[r][a];l&&n.push({intersection:l,axisNames:[r,a]})}}t&&t(n)}))}_ajaxGet(t,i){e.Web.Lang.Utility.HttpRequest.ajax({url:t,success:function(e){var t=JSON.parse(e);t&&i(t)}})}getAxisInfo(e){var t=`${this.url}/AxisGrid.json`;this._ajaxGet(t,e)}getObjectsByBoundingBox(e,t,i,n=!1){return t.max.z=t.max.z||0,t.min.z=t.min.z||0,this._drawingViewer.getAllElementsByBoundingBox(e,t,l[i]||1,n,this.drawingIndex)}getObjectsByLayerId(e,t){let i=this._drawingViewer.getElementIdsByLayerId(e,t||this.getCurrentViewId(),this.drawingIndex),n=[];for(var o=0,s=i.size();o<s;++o)n.push(i.at(o));return n}getExternalReferencesList(e){let t=`${this.url}/externalBlocks.json`;this._ajaxGet(t,e)}fromLinkRevitId(e,n){return i.send(t,"fromLinkRevitId"),self.revitInterop.fromLinkRevitId(e,n)}getDrawingFrame(t){let i=this,n=i._viewMetaData||i._data,o=window.BimfaceLoaderConfig.dataEnvType,s=window.BimfaceLoaderConfig.viewToken;if(n)r(n);else if("Local"==o){let e=window.BimfaceLoaderConfig.path;i._ajaxGet(e,(function(t){var o=e.split("/");o.pop(),t.path=o.join("/")+"/",i._data=n,r(t)}))}else i.getViewMetaData(s,(function(e){r(e)}));function r(n){e.Web.Lang.Utility.HttpRequest;var o=n.split&&n.split.databagId||n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||i._viewConfig.resourceHost)+"/"+o+"/resource/drawing/Frames");i.getIndexJson(s,t)}}getLayerIdsByObjects(e){let t=[];for(let i=0;i<e.length;i++)t.push(this.getLayerIdFromElementId(e[i]));return t}getLayers(){return this._drawingViewer.getLayers(this.drawingIndex)}getModelPosition(n,o,s){i.send(t,"getModelPosition");var r=this.authenticate.data.databagId,a=null,l=this._drawingViewer.getModelBBox().GetMinPt(),h=this._drawingViewer.getModelBBox().GetMaxPt(),c=new THREE.Vector2(l[0],l[1]),d=new THREE.Vector2(h[0],h[1]),u=new THREE.Box2(c,d);let g,p=new THREE.Vector2;u.getSize(p),o&&void 0!==o.x&&void 0!==o.y?g=o:Array.isArray(o)&&(g={x:o[0],y:o[1]});var f=(g.x-u.min.x)/p.x,m=(g.y-u.min.y)/p.y,w=new THREE.Vector3(f,m);e.Web.Graphics.Utility.Relation.getDrawingSheets(r,n,(function(t){(a=t).viewType=t.viewInfo.viewType;var i=a.viewInfo.preview.width,n=a.viewInfo.preview.height,o=new THREE.Vector2(i*w.x,n*(1-w.y)),r=e.Web.Graphics.Utility.Relation.point2DToPoint3D(o,a);s&&s(r)}))}getObjectBoundingBox(e){return e=parseInt(e),this._drawingViewer.getObjectBoundingBox(e,this.drawingIndex)}getRenderInfo(e){let t=this;this.getViewMetaData(t.viewToken,(function(i){let n=i.drawingUrl;t.getIndexJson(n,(function(t){e&&e(t)}))}))}getSelectedObjects(){return this._drawingViewer.getSelectedIds(this.drawingIndex)}getDrawingFeatures(t){if(this._drawingFeatures)t(this._drawingFeatures);else{let i=this,n=this._viewMetaData||this._data,o=n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||i._viewConfig.resourceHost)+"/"+o+"/resource/drawing/drawingFeatures.json.gz");this._ajaxGet(s,(function(e){i._drawingFeatures=e,t(e)}))}}getTextById(e,t){this.getDrawingFeatures((function(i){let n=[];if(i){let t=[i.text.model].concat(i.text.layouts);for(let i=0;i<t.length;i++){let o=t[i].data;for(let t=0;t<o.length;t++)for(let i=0;i<o[t].items.length;i++){o[t].items[i].id==e&&n.push(o[t].content)}}}t(n)}))}getViews(){return this._drawingViewer.getLayouts(this.drawingIndex)}getScaleFactor(){return this._drawingViewer.getAlignScale(this.drawingIndex)}changeLayers(e){i.send(t,"changeLayers"),this._drawingViewer.changeLayers(e,this.drawingIndex),this.update()}hideLayers(e){const n=this.getLayers();i.send(t,"hideLayers");for(let t=0;t<n.length;t++)(e.all||e.layerIds.indexOf(n[t].id)>-1||e.layerIds.indexOf(n[t].id.toString())>-1)&&(n[t].visible=!1);this.changeLayers(n)}highlight(e){if(e.objectIds&&e.objectIds.map((e=>{this._drawingViewer.highlightById(parseInt(e),this.drawingIndex)})),e.layerIds){const t=this.getCurrentViewId();e.layerIds.map((e=>{const i=this._drawingViewer.getElementIdsByLayerId(e,t,this.drawingIndex);this._drawingViewer.highlightByIds(i,this.drawingIndex)}))}this.update(!0)}overrideObjectsColor(e,t){t instanceof s.Color?(e.all?this._drawingViewer.setGlobalColor(t,this.drawingIndex):this._drawingViewer.overrideElementsColorById(e.objectIds,t,this.drawingIndex),this.update()):this.drawingConsole.error("param use Glodon.Web.Graphics.Color")}overrideLayersColor(e,t){if(t instanceof s.Color){if(e.all){const e=this.getLayers();let i=[];e.map((e=>i.push(e.id))),this._drawingViewer.setColorByLayerId(i,t.red/255,t.green/255,t.blue/255,t.alpha,this.drawingIndex)}else this._drawingViewer.setColorByLayerId(e.layerIds,t.red/255,t.green/255,t.blue/255,t.alpha,this.drawingIndex);this.update()}else this.drawingConsole.error("param use Glodon.Web.Graphics.Color")}getTextByBoundingBox(e,t){const i=null==e.viewId?this.getCurrentViewId():e.viewId,n=this.getViews(),{min:o,max:s}=e.boundingBox;this.getDrawingFeatures((function(e){if(e){let r,a=[];if(0==i)r=e.text.model.data;else{const t=n.find((e=>e.id==i));r=e.text.layouts.find((e=>e.name==t.name)).data}for(let e=0;e<r.length;e++){let t=r[e].content,i=r[e].items;for(let e=0;e<i.length;e++){const n=i[e].bbox,r={min:{x:n[0],y:n[1]},max:{x:n[2],y:n[3]}};r.min.x>o.x&&s.x>r.max.x&&o.y<r.min.y&&s.y>r.max.y&&a.push({content:t,boundingBox:r})}}let l=a;if(a.length>0){a.sort(((e,t)=>t.boundingBox.min.y-e.boundingBox.min.y));const e=a[Math.ceil(a.length/2)-1],t=e.boundingBox.max.y-e.boundingBox.min.y;l=[];const i=e=>{let n=e[0],o=[n];for(let s=1;s<e.length;s++){const r=e[s];if(!(Math.abs(r.boundingBox.min.y-n.boundingBox.min.y)<t))return o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),l=l.concat(o),i(e.slice(s));o.push(r),n=r}o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),l=l.concat(o)};i(a)}t(l)}else t(null)}))}restoreObjectsColor(e){e.all&&this._drawingViewer.restoreGlobalColor(this.drawingIndex),e.all||this._drawingViewer.restoreElementsColorById(e.objectIds,this.drawingIndex),this.update(!0)}restoreLayersColor(e){if(e.all){let e=[];this.getLayers().map((t=>{e.push(t.id)})),this._drawingViewer.resetColorByLayerId(e,this.drawingIndex)}e.all||this._drawingViewer.resetColorByLayerId(e.layerIds,this.drawingIndex),this.update()}scale(e,t){this._drawingViewer.scaleDrawing(e,t,this.drawingIndex)}search(e,t,i){if(!e||void 0===e.text||""===e.text||!t)return this.drawingConsole.error("搜索文本内容和回调函数不能为空");let n=this;this.getDrawingFeatures((function(o){if(o){o.text.model.name="Model";let i=[o.text.model].concat(o.text.layouts),s=[],r=n.getObjectViews();for(let t=0;t<i.length;t++){let o=i[t].data,a=i[t].name;for(let t=0;t<o.length;t++)if(o[t].content.indexOf(e.text)>-1){let e=[];for(let i=0;i<o[t].items.length;i++){let s=o[t].items[i],r=s.bbox;n.currentFrameBoundingBox&&(n.currentFrameBoundingBox[0]>r[0]||n.currentFrameBoundingBox[1]>r[1]||n.currentFrameBoundingBox[2]<r[2]||n.currentFrameBoundingBox[3]<r[3])||e.push({id:s.id,boundingBox:{max:{x:r[2],y:r[3]},min:{x:r[0],y:r[1]}}})}e.length>0&&s.push({viewId:r[a],content:o[t].content,modelId:n.modelId,data:e})}}t(s)}else i(null)}))}select(e){let t=[];e.objectIds&&!Array.isArray(e.objectIds)&&(t=[e.objectIds]),e.layerIds&&e.layerIds.map((e=>{const i=this.getObjectsByLayerId(e);t=[...new Set([...t,...i])]})),e.objectIds&&(t=[...new Set([...t,...e.objectIds])]),this._onSelectionChanged(t),this._drawingViewer.selectByIds(t,this.drawingIndex),this.update()}setOpacity(e){this._drawingViewer.setGlobalOpacity(e,this.drawingIndex),this.update(!0)}showObjects(e){e.all&&this._drawingViewer.showAllElements(this.drawingIndex),!e.all&&e.objectIds&&this._drawingViewer.showElementsById(e.objectIds,this.drawingIndex),this.update()}showLayers(e){const n=this.getLayers();i.send(t,"showLayers");for(let t=0;t<n.length;t++)(e.all||e.layerIds.indexOf(n[t].id)>-1||e.layerIds.indexOf(n[t].id.toString())>-1)&&(n[t].visible=!0);this.changeLayers(n)}zoomToObject(e){i.send(t,"zoomToObject");const n=e.ratio||.5;this.clearSelection(this.drawingIndex),this._drawingViewer.zoomToObject(e.objectId,n,this.drawingIndex),this.selectByIds(e.objectId)}toModelId(e){return i.send(t,"toModelId"),this.revitInterop.toRevitId(e)}}n.Drawing=d}(),function(){var t="Glodon.Bimface.Viewer.ViewerDrawing",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,"GlobalData"),s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),r=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics"),a=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),l=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),e.Bimface.Viewer.ViewerDrawingEvent);o.isInitialized=o.isInitialized||!1;const h={Window:1,Crossing:2};let c=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable(),d=["rgb(50,50,55)","rgb(255,255,255)","rgb(255,255,255)","rgb(50,50,55)"],u=function(o){n.Viewer.call(this);let s=e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(c){var r=this;this.viewerType="ViewerDrawing";let n=o;this._opt=o,this.isInitialized=!1,this.hasBindEvents=!1,this.grids=null,this.cursorReady=!1,this.snapIsEnabled=!1,this.console=new e.Web.Common.Console,this._cache={},this.loadedDrawings=[];var d=a.create("div","bf-drawing-container ");if(s)u=a.create("div","bf-drawing-wrap");else{var u=a.create("div","bf-drawing-wrap bf-mobile"),g=o.domElement.offsetWidth,p=o.domElement.offsetHeight;u.style.fontSize=90*Math.min(g,p,414)/750+"px"}var f,m=o.domElement;m.addClass("viewerDrawingWrap"),m.id?f=m.id:(f=e.Web.Lang.Utility.UUID.createUUID(),m.id=f),d.id="Drawing"+f,d.setCss({width:"100%",height:"100%",position:"relative",zIndex:1,background:0==this._opt.displayMode?"rgb(50, 50, 55)":""}),u.setCss({width:"100%",height:"100%",position:"relative",overflow:"hidden"}),u.appendChild(d),m.appendChild(u),n.domElement=d,this._domElement=m,this._viewConfig=n,this.rootElement=d,this.getDomElement=function(){return u},this.getRootElement=function(){return d},this.getViewer=function(){return this._drawingViewer},this._pressAlt=!1,this._pressCtrl=!1;let c=null,w=null;s?(document.addEventListener("keydown",(e=>{var t=e.keyCode||e.which||e.charCode;18==t?this._pressAlt=!0:17==t&&(this._pressCtrl=!0)})),document.addEventListener("keyup",(e=>{var t=e.keyCode||e.which||e.charCode;18==t?this._pressAlt=!1:17==t&&(this._pressCtrl=!1)})),u.addEventListener("mouseleave",(()=>{this._pressAlt=!1,this._pressCtrl=!1})),u.addEventListener("mousedown",(function(e){this.oldMouseX=e.clientX,this.oldMouseY=e.clientY;let t=r.getDomElement().getBoundingClientRect(),i={x:e.clientX-t.left,y:e.clientY-t.top};0===e.button&&"2"==(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version&&(r._pressCtrl||r._pressAlt)&&(e.stopPropagation(),c=i)})),u.addEventListener("mousemove",(function(e){if(c&&(r._pressCtrl||r._pressAlt)){e.stopPropagation();let t=r.getDomElement().getBoundingClientRect();w={x:e.clientX-t.left,y:e.clientY-t.top},r.getEventManager().fireEvent(l.RectSelection,{rectSelectStart:c,rectSelectEnd:w,finish:!1})}}),!0),u.addEventListener("mouseup",(function(e){var t,i,n=Math.abs(this.oldMouseX-e.clientX)<=1&&Math.abs(this.oldMouseY-e.clientY)<=1,o=this.getBoundingClientRect(),s={};if(b={x:t=e.clientX-o.left,y:i=e.clientY-o.top},0===e.button)if("2"==(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version&&c&&(n?(y&&r.getViewer().dom.removeChild(v),c=null,y=!1):r.getEventManager().fireEvent(l.RectSelection,{rectSelectStart:c,rectSelectEnd:w,finish:!0})),n){if(!e.target.hasClass("bf-drawable-context")&&"canvas"!=e.target.tagName.toLocaleLowerCase()&&!e.target.hasClass("bf-rect-selcetion"))return;var a,h=[],d=[],u=[];if(a=r._drawingViewer.toWorldPoint([t,i]),r._opt.enableHover&&(r._drawingViewer.preSelect(t,i,!1,!1),r.loadedDrawings.length>0?r.loadedDrawings.map((e=>{const t=r._drawingViewer.getHighlightIds(e.drawing.drawingIndex);t.length>0&&(h=[...h,...t],d.push(e.drawing.modelId),u.push(e.drawing.drawingIndex))})):h=r._drawingViewer.getHighlightIds()),(s={worldPosition:{x:a[0],y:a[1]},clientPosition:b,objectId:h[0]||null,clientX:e.clientX,clientY:e.clientY,event:e}).objectId){let e=r.getLayerIdFromElementId(s.objectId,r.loadedDrawings.length>0&&u[0]||0),t=r.loadedDrawings.length>0?r.getDrawing(d[0]).getLayerById(e):r.getLayerById(e);s.layerId=e||null,s.layerName=t&&t.name||null,r.loadedDrawings.length>0&&(s.modelId=d[0])}else s.layer=null;if(r.grids&&(s.grid=r.getNearestGrid({x:t,y:i})),r.snapIsEnabled){var g=r._drawingViewer.snapToPoint(t,i);if(g.GetPoint().length>0){var p=g.GetSnapType(),f={x:g.GetPoint()[0],y:g.GetPoint()[1]},m=r._drawingViewer.toScreenPoint([f.x,f.y]),b={x:m[0],y:m[1]};s.snapPoint={type:p,clientPosition:b,worldPosition:f}}}s.selfDrawing=r,r.getEventManager().fireEvent(l.MouseClicked,s);const n=r.getSelectedElements();r._pressCtrl&&(n.indexOf(s.objectId)>-1?r.removeSelectId(s.objectId):r.selectByIds(s.objectId,r.loadedDrawings.length>0?s.modelId?r.getDrawing(s.modelId).drawingIndex:r.loadedDrawings[0].drawing.drawingIndex:0,!0)),r._pressAlt&&console.log(s)}else s={clientPosition:b},r.getEventManager().fireEvent(l.MouseDragged,s);else if(2===e.button&&"2"==(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version&&n){let t=r.getDomElement().getBoundingClientRect(),i={x:e.clientX-t.left,y:e.clientY-t.top},n={width:t.width,height:t.height};var x={};x.clientPosition=i,x.containerBox=n,r.getEventManager().fireEvent(l.ContextMenu,x)}}))):(d.addEventListener("touchstart",(function(e){if(e.target.hasClass("bf-drawable-context")||"canvas"==e.target.tagName.toLocaleLowerCase()){var t=e.targetTouches[0];this.oldTouchX=t.clientX,this.oldTouchY=t.clientY}})),d.addEventListener("touchend",(function(e){var t,i,n,o=e.changedTouches[0],s=this.oldTouchX==o.clientX&&this.oldTouchY==o.clientY,a=this.getBoundingClientRect(),h={};if(n={x:t=o.clientX-a.left,y:i=o.clientY-a.top},s){if(!e.target.hasClass("bf-drawable-context")&&"canvas"!=e.target.tagName.toLocaleLowerCase())return;var c,d;if(d=r._drawingViewer.toWorldPoint([t,i]),r._drawingViewer.preSelect(t,i,!1,!1),c=r._drawingViewer.getHighlightIds(),(h={worldPosition:{x:d[0],y:d[1]},clientPosition:n,objectId:c[0]||null,clientX:o.clientX,clientY:o.clientY,event:e}).objectId){let e=r.getLayerIdFromElementId(h.objectId,r.loadedDrawings.length>0&&r.loadedDrawings[0].drawingIndex||0),t=r.getLayerById(e);h.layerId=e||null,h.layerName=t&&t.name||null}else h.layer=null;r.grids&&(h.grid=r.getNearestGrid({x:t,y:i})),h.selfDrawing=r,r.getEventManager().fireEvent(l.MouseClicked,h)}else h={clientPosition:n},r.getEventManager().fireEvent(l.MouseDragged,h)})));const v=a.create("div","bf-rect-selcetion");let y=!1;r.addEventListener(l.RectSelection,(function(e){const{finish:t}=e;if(c&&w){const e={x:Math.min(c.x,w.x),y:Math.min(c.y,w.y)},i={x:Math.max(c.x,w.x),y:Math.max(c.y,w.y)},n=c.x<w.x?"Window":"Crossing";if(t&&y){if(y=!1,r.getViewer().dom.removeChild(v),c&&w&&(r._pressCtrl||r._pressAlt)){const t=r.clientToWorld(e),o=r.clientToWorld(i),s={min:{x:t.x,y:o.y},max:{x:o.x,y:t.y}};let a=[];if(r.loadedDrawings.length>0?r.loadedDrawings.map((e=>{const t=e.drawing.getObjectsByBoundingBox(r.getCurrentViewId(),s,h[n]);a=[...a,...t]})):a=r.getElementsByBoundingBox(r.getCurrentViewId(),s,h[n]),a.length&&a.length>0){r.loadedDrawings.length>0?r.loadedDrawings.map((e=>{r._drawingViewer[r._pressCtrl?"selectElementsByBoundingBox":"removeSelectElementIdsByBoundingBox"](r.getCurrentViewId(),s,h[n],e.drawing.drawingIndex)})):r._drawingViewer[r._pressCtrl?"selectElementsByBoundingBox":"removeSelectElementIdsByBoundingBox"](r.getCurrentViewId(),s,h[n]),r.update();const e=r.getSelectedElements();r.getEventManager().fireEvent(l.SelectionChanged,e)}}}else{const t=Math.abs(c.x-w.x),i=Math.abs(c.y-w.y);v.setCss({left:`${e.x}px`,top:`${e.y}px`,width:`${t}px`,height:`${i}px`,zIndex:1,background:"rgba(185,255,235,0.3)",border:`2px ${"Window"===n?"solid":"dashed"} rgba(0,130,94,1)`}),r.getViewer().dom.appendChild(v),y=!0}}t&&(c=null,w=null)})),e.Bimface.WebglDrawingSheet.onLoadProgress=function(e){var t=document.querySelector(".bf-drawing-container .bf-loading-text");t&&e&&(t.innerText=parseInt(100*e)+"%")},r.addEventListener(l.Loaded,(function(){i.send(t,"Loaded",{eventId:"加载",loadModel:"expert",type:"drawing"})}))}else this._loadNotSuportPromptPage(o.domElement)};s.Type.inheritPrototype(u,n.Viewer),u.prototype=Object.assign({},n.Viewer.prototype,{addModel:function(n,s,r,a){if(i.send(t,"addModel"),!c||this._data&&this._data.renderVersion!=n.renderVersion)return console.log("this model can not be added."),!1;var l=e.Bimface.Data.StatisticsDataManager.getInstance();l.modelType=n.modelType,l.modelId=n.modelId,this.getDomElement().removeClass("drawingFrame");var h,d,u=this,g=(u.getViewer(),u._opt,n.dataPath,n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId),p=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||this._viewConfig.resourceHost)+"/"+g+"/resource/drawing");if(n.drawingUrl=p,u._data=n,null!=a){d=!0;let t=n.split&&n.split.databagId;h=t?e.Web.Lang.Utility.ClientHelper.formatURL((n.path||u._viewConfig.resourceHost)+"/"+t+"/resource/drawing/Frames"):p+"/Frames"}else h=p,d=!1;d&&this.getDomElement().addClass("drawingFrame");u.isInitialized||o.isInitialized?u.loadIndexJson(n,s,r,(function(){"1"==u.version||"1"==u.prevVersion?u.destroy(!0):u.destroy(),"1"==u.version&&(u._drawingViewer=u.createDrawingViewer(u.rootElement.id)),u._drawingViewer&&u._drawingViewer.clearAll(),"2"==u.version?u.loadWebGL(h,s,r,a):u.loadModel(h,s,r),u._viewMetaData=n})):u.loadIndexJson(n,s,r,(function(){"1"==u.version||"1"==u.prevVersion?u.destroy(!0):u.destroy();var t=n.sdkPath?n.sdkPath+"/bimface":n.sdkPath;if("bimView"==n.renderType&&n.subRenders&&0!=n.subRenders.length)for(var i=0;i<n.subRenders.length;i++)"drawingView"==n.subRenders[i].renderType&&(e.Bimface.DrawingSheet.sdkUrl=u._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||t||u._viewConfig.staticHost+"/"+n.subRenders[i].jsSDKVersion);else e.Bimface.DrawingSheet.sdkUrl=u._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||t||u._viewConfig.staticHost+"/"+n.jsSDKVersion;"2"==u.version?u.loadWebGL(h,s,r,a,d):e.Bimface.DrawingSheet.initialize((function(){u._drawingViewer=u.createDrawingViewer(u.rootElement.id),u.loadModel(h,s,r),o.isInitialized=!0}))})),this.showLoading()},showLoading:function(){this.rootElement.style.zIndex=5;var e=a.create("div","bf-loading"),t=a.create("div","bf-loading-gif"),i=a.create("div","bf-loading-text");e.appendChild(t),e.appendChild(i),this.loading=e,this.rootElement.appendChild(e)},enableHover(e){i.send(t,"enableHover"),this._opt.enableHover=e,this._drawingViewer.enableHover(e)},enableSnap(e){i.send(t,"enableSnap"),this.snapIsEnabled=e,this._drawingViewer.mouseEditorMgr.enableSnap(e)},enablePickEffect(e){this._drawingViewer.mouseEditorMgr.enablePickEffect(e)},setSnapMode(e){i.send(t,"setSnapMode"),this.snapMode=e,this.getViewer().setSnapMode(e)},destroy(e){if(this._drawingViewer&&this._drawingViewer.mouseEditorMgr&&this._drawingViewer.mouseEditorMgr.unbindAllEvent(),e){this._drawingViewer=null;for(var t=document.querySelectorAll("#"+this.rootElement.id+" canvas"),i=0;i<t.length;i++)t[i].remove()}this.hasBindEvents=!1},enableMiniMap:function(n,o,s){i.send(t,"enableMiniMap");var r=this._drawingViewer;if(!0===n){if(1==r.hasMinimap())return void r.enableMinimap(!0);var a=this.rootElement.id,l={width:300,height:240},h=this._viewConfig.resourceHost,c=this.authenticate&&this.authenticate.data.databagId||this._data.databagId,d=h+"/"+c+"/thumbnail/512.png",u=h+"/"+c+"/resource/preview/Model_4028.json";e.Web.Lang.Utility.HttpRequest.ajax({url:u,success:function(e){var t=JSON.parse(e).boundingbox,i=h(t.minPoint),n=h(t.maxPoint);function h(e){var t=e.indexOf("{"),i=e.indexOf("}"),n=e.slice(t+1,i).split(",");return{x:parseFloat(n[0]),y:parseFloat(n[1])}}r.createMinimap(a,d,l.width,l.height,s),o&&o(),r.setMinimapBoundingBox({min:i,max:n})}})}else r.enableMinimap(!1)},getDrawingFrame(t){this.obsoleteOld("ViewerDrawing.getDrawingFrame","ViewerDrawing.getDrawing(modelId).getDrawingFrame");let i=this;i.loadedDrawings.length>0&&(i._viewMetaData=i.loadedDrawings[0].drawing._viewMetaData);let n=i._viewMetaData||i._data,o=window.BimfaceLoaderConfig.dataEnvType,s=window.BimfaceLoaderConfig.viewToken;if(n)r(n);else if("Local"==o){let e=window.BimfaceLoaderConfig.path;i._ajaxGet(e,(function(t){var o=e.split("/");o.pop(),t.path=o.join("/")+"/",i._data=n,r(t)}))}else i.getViewMetaData(s,(function(e){r(e)}));function r(n){e.Web.Lang.Utility.HttpRequest;var o=n.split&&n.split.databagId||n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||i._viewConfig.resourceHost)+"/"+o+"/resource/drawing/Frames");i.getIndexJson(s,t)}},loadFrame(t,i){let n=this;this.destroy(),this.showLoading(),this.getDomElement().addClass("drawingFrame"),this.getViewMetaData(t,(function(t){let o=t.drawingUrl;n.getIndexJson(o,(function(o){"2"==o.metadata.version||"2"==o.metadata["version:"]?n.version="2":n.version="1";let s,r=t.split&&t.split.databagId;s=r?e.Web.Lang.Utility.ClientHelper.formatURL((t.path||n._viewConfig.resourceHost)+"/"+r+"/resource/drawing/Frames"):t.drawingUrl+"/Frames",n._drawingViewer&&n._drawingViewer.clearAll(),n.loadWebGL(s,null,null,i,!0),n._viewMetaData=t}))}))},load:function(t,i,n){if(!c)return!1;var s=this,r=arguments,a=this.getDomElement();if(a.removeClass("drawingFrame"),o.loading)return setTimeout((function(){s.load.apply(s,r)}),500);o.loading=!0,s.isInitialized||o.isInitialized?t&&this.getViewMetaData(t,(function(e){s.loadIndexJson(e,i,n,(function(){"1"==s.version||"1"==s.prevVersion?s.destroy(!0):s.destroy(),"1"==s.version&&(s._drawingViewer=s.createDrawingViewer(s.rootElement.id)),s._drawingViewer&&s._drawingViewer.clearAll(),"2"==s.version?s.loadWebGL(e.drawingUrl,i,n):s.loadModel(e.drawingUrl,i,n),s._viewMetaData=e}))})):t&&this.getViewMetaData(t,(function(t){s._viewMetaData=t,s.loadIndexJson(t,i,n,(function(){"1"==s.version||"1"==s.prevVersion?s.destroy(!0):s.destroy();var o=e.Bimface.Data.StatisticsDataManager.getInstance();o.modelType=t.modelType,o.modelId=t.modelId,s.initialize(t,i,n)}))})),this.showLoading()},loadIndexJson:function(e,t,i,n){let o=this,s=e.drawingUrl;t&&(s=s+(i?"/"+i:"")+"/"+t),this.url=s,this.getIndexJson(s,(function(e){var t=document.querySelector(".bf-drawing-container .bf-loading-text");o.version&&(o.prevVersion=o.version),"2"==e.metadata.version||"2"==e.metadata["version:"]?(o.version="2",t.innerText="0%"):(o.version="1",t.innerText=BimfaceLanguage.bf_load),n()}))},getViews:function(){return this.obsoleteOld("ViewerDrawing.getViews","ViewerDrawing.getDrawing(modelId).getViews"),this._drawingViewer.getLayouts(this.loadedDrawings.length>0?this.loadedDrawings[0].drawing.drawingIndex:0)},getModelPosition:function(n,o,s){var r;i.send(t,"getModelPosition"),this.obsoleteOld("ViewerDrawing.getModelPosition","ViewerDrawing.getDrawing(modelId).getModelPosition"),r=this.loadedDrawings.length<1?this.authenticate.data.databagId:this.loadedDrawings[0].drawing.authenticate.data.databagId;var a=null,l=this._drawingViewer.getModelBBox().GetMinPt(),h=this._drawingViewer.getModelBBox().GetMaxPt(),c=new THREE.Vector2(l[0],l[1]),d=new THREE.Vector2(h[0],h[1]),u=new THREE.Box2(c,d);let g,p=new THREE.Vector2;u.getSize(p),o&&void 0!==o.x&&void 0!==o.y?g=o:Array.isArray(o)&&(g={x:o[0],y:o[1]});var f=(g.x-u.min.x)/p.x,m=(g.y-u.min.y)/p.y,w=new THREE.Vector3(f,m);e.Web.Graphics.Utility.Relation.getDrawingSheets(r,n,(function(t){(a=t).viewType=t.viewInfo.viewType;var i=a.viewInfo.preview.width,n=a.viewInfo.preview.height,o=new THREE.Vector2(i*w.x,n*(1-w.y)),r=e.Web.Graphics.Utility.Relation.point2DToPoint3D(o,a);s&&s(r)}))},getLayers:function(e=!1){let t=this.obsoleteOld("ViewerDrawing.getLayers","ViewerDrawing.getDrawing(modelId).getLayers",e);return this._drawingViewer.getLayers(t)},getLayerIdFromElementId:function(e,t){if(this._drawingViewer.getLayerIdFromElementId)return this._drawingViewer.getLayerIdFromElementId(e,t)},changeLayers:function(e){i.send(t,"changeLayers");let n=0;this.loadedDrawings.length>0&&(n=this.loadedDrawings[0].drawing.drawingIndex),this._drawingViewer.changeLayers(e,n),this.update()},getColor:function(e){return`rgba(${255&e}, ${e>>8&255}, ${e>>16&255}, 1)`},hideLayer:function(e,n=!1){this.obsoleteOld("ViewerDrawing.hideLayer","ViewerDrawing.getDrawing(modelId).hideLayers",n),i.send(t,"hideLayer");for(var o=this.getLayers(!0),s=0,r=o.length;s<r;++s){var a=o[s];if(a.id==e){a.visible=!1;break}}this.changeLayers(o)},getLayerById:function(e){for(var t=this.getLayers(!0),i=0,n=t.length;i<n;++i){var o=t[i];if(o.id==e)return o}return!1},showLayer:function(e,n=!1){this.obsoleteOld("ViewerDrawing.showLayer","ViewerDrawing.getDrawing(modelId).showLayers",n),i.send(t,"showLayer");for(var o=this.getLayers(!0),s=0,r=o.length;s<r;++s){var a=o[s];if(a.id==e){a.visible=!0;break}}this.changeLayers(o)},hideAllLayers:function(){this.obsoleteOld("ViewerDrawing.hideAllLayers","ViewerDrawing.getDrawing(modelId).hideLayers"),i.send(t,"hideAllLayers");for(var e=this.getLayers(!0),n=0,o=e.length;n<o;++n){e[n].visible=!1}this.changeLayers(e)},showAllLayers:function(e=!1){i.send(t,"showAllLayers"),this.obsoleteOld("ViewerDrawing.showAllLayers","ViewerDrawing.getDrawing(modelId).showLayers",e);for(var n=this.getLayers(!0),o=0,s=n.length;o<s;++o){n[o].visible=!0}this.changeLayers(n)},hideAllElements:function(){const e=this.obsoleteOld("ViewerDrawing.hideAllElements","ViewerDrawing.getDrawing(modelId).hideObjects");this._drawingViewer.hideAllElements(e),this.update()},showAllElements:function(e=!1){const t=this.obsoleteOld("ViewerDrawing.showAllElements","ViewerDrawing.getDrawing(modelId).showObjects",e);this._drawingViewer.showAllElements(t),this.update()},getElementBoxColor(){i.send(t,"getElementBoxColor");let n=this._drawingViewer.getElementBoxColor();return new e.Web.Graphics.Color(n.red,n.green,n.blue,n.alpha)},getBoundingBoxStyle(){return{color:this.getElementBoxColor(),type:this.getElementBoxStyle()}},setElementBoxColor(e){i.send(t,"setElementBoxColor"),this._drawingViewer.setElementBoxColor(e.red,e.green,e.blue,e.alpha)},getElementBoxStyle(){return i.send(t,"getElementBoxStyle"),this._drawingViewer.getElementBoxStyle()},setElementBoxStyle(e){i.send(t,"setElementBoxStyle");if(-1!=["Rectangle","CloudRect"].indexOf(e))return this._drawingViewer.setElementBoxStyle(e);console.error("params error!")},setBoundingBoxStyle(e){i.send(t,"setBoundingBoxStyle"),e.type&&this.setElementBoxStyle(e.type),e.color&&this.setElementBoxColor(e.color)},showViewById:function(e){i.send(t,"showViewById"),this._drawingViewer.activeLayoutById(e||0),this.getEventManager().fireEvent(l.ViewChanged,e)},getCurrentViewId:function(){return this._drawingViewer.getActiveLayoutId()},rectZoom:function(){i.send(t,"rectZoom"),this._drawingViewer.mouseEditorMgr.activeEditorByName("zoom"),this._opt.enableZoomRect=!0},getZoomFactor:function(){return this._drawingViewer.getZoomFactor()},getCurrentState:function(){return this._drawingViewer.getState()},setState:function(e){i.send(t,"setState"),this._drawingViewer&&(this._drawingViewer.setState(e),this._drawingViewer.update())},createSnapshotAsync:function(e,n){i.send(t,"createSnapshotAsync"),e&&(e=`rgba(${e.red},${e.green},${e.blue},${e.alpha})`),n&&n(this._drawingViewer.snapshot(e))},enableFullScreen:function(t){var i=this.getDomElement();t?e.Web.Lang.Utility.FullScreen.fullScreen(i):e.Web.Lang.Utility.FullScreen.exitFullScreen()},home:function(){let e="2"===this.version?.2:void 0;this.modelBBox?this._drawingViewer.zoomToWorldBox(this.modelBBox[0],this.modelBBox[1],e):this._drawingViewer.zoomToExtent(e),this._drawingViewer.update()},getViewMetaData:function(t,i,n){var o=this;let s,r=e.Bimface.Authentication.AuthenticationManager,a=new e.Bimface.Authentication.AuthenticationConfig;a.viewToken=t,a.APIHost=this._viewConfig.APIHost,s=n?new r(a):this.authenticate=new r(a),s.authenticate((function(e){let t=e.integrateDrawings&&e.integrateDrawings.databagId||e.databagId;e.drawingUrl=`${o._viewConfig.resourceHost}/${t}/resource/drawing`,i(e)}))},getIndexJson:function(t,i){e.Web.Lang.Utility.HttpRequest.ajax({url:`${t}/index.json`,success:function(e){var t=JSON.parse(e);t&&i(t)}})},initialize:function(t,i,n){if(this.isInitialized)return!1;var s=this;if("bimView"==t.renderType&&t.subRenders&&0!=t.subRenders.length)for(var r=0;r<t.subRenders.length;r++)"drawingView"==t.subRenders[r].renderType&&(e.Bimface.DrawingSheet.sdkUrl=s._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||s._viewConfig.staticHost+"/"+t.subRenders[r].jsSDKVersion);else e.Bimface.DrawingSheet.sdkUrl=s._viewConfig.sdkUrl||BimfaceSDKLoader.sdkUrlForWebApp||s._viewConfig.staticHost+"/"+t.jsSDKVersion;"2"==s.version||"2.0"==t.renderVersion?this.loadWebGL(t.drawingUrl,i,n):e.Bimface.DrawingSheet.initialize((function(){s._drawingViewer=s.createDrawingViewer(s.rootElement.id),s.loadModel(t.drawingUrl,i,n),o.isInitialized=!0}))},loadWebGL(t,i,n,s,r){var a,h=this;this.grids=null,i&&(t=t+(n?"/"+n:"")+"/"+i),h._drawingViewer?a=h._drawingViewer:h._drawingViewer=a=h.createDrawingViewer(h.rootElement.id),a.viewer.SetPreLoad(!0),a.update(),e.Bimface.WebglDrawingSheet.loadModel(t,h.rootElement.id,a,(function(t){for(var n=document.querySelectorAll(".bf-drawing-container .bf-loading"),s=n.length,c=0;c<s;c++)n[c].remove();h.rootElement.style.zIndex=1,o.loading=!1,h.enableViewport(h._opt.enableViewport);var d=a.getLayouts();if(r&&d.length>1)h._drawingViewer.activeLayoutById(d[1].id);else if(i){var u,g=null;for(c=0;c<d.length;c++)if("Layout1"==d[c].name){g=d[c].id;break}g&&h.showViewById(g),a.model={Url:t.url+"/"},u=new e.Bimface.RevitInterop,h.loadedDrawings.length>0?u.initialize(a,h.loadedDrawings[0].drawing.model.Url):u.initialize(a),a.revitInterop=u,h.revitInteropReady=!1,u.callback=()=>{h.revitInteropReady=!0}}let p=e.Web.Lang.Utility.ClientHelper.getIsDesktop();h._drawingViewer.mouseEditorMgr=p?e.Bimface.WebglDrawingSheet.createMouseEditorManager(a):e.Bimface.WebglDrawingSheet.createTouchEditorManager(a),h._drawingViewer.mouseEditorMgr.bindEvents(),h.observer(h._drawingViewer.mouseEditorMgr),h._drawingViewer.mouseEditorMgr.activeEditorByName("pick"),window.addEventListener("resize",(function(){a&&a.onResize()})),h._drawingViewer.onViewChanges=function(){h.getEventManager().fireEvent(l.Rendered,h._drawingViewer)},h.setDisplayMode(h._opt.displayMode),!h._opt.enableViewport&&h.home(),h.getManifest((function(e){let t=(e=e||{}).Features,i=Object.assign({},t||{}),n=h._viewMetaData||h._data,o=!0,s=!0,r=!1,a=!1;t&&(o=t.HasLayout,s=t.HasMiniMap,r=t.HasText),(n.split&&n.split.databagId||n.config&&n.config.split)&&(a=!0),i=Object.assign(i,{HasLayout:o,HasMiniMap:s,HasText:r,HasSplitDrawing:a}),h._manifest=Object.assign(e,{Features:i}),h.getEventManager().fireEvent(l.Loaded,h._drawingViewer.mouseEditorMgr)})),h.cursorReady||(e.Web.Lang.Utility.MouseMotion.setCursor(h),h.cursorReady=!0),h.enableHover(h._opt.enableHover)}),s)},observer(t){let i=null,n=this;t.observer=function(t,o,s,r,a,h){if("zoom"==t&&"exit"==o&&(n.getEventManager().fireEvent(l.ViewZoomed),n._opt.enableZoomRect=!1),"zoomFactorChanged"==o&&n.getEventManager().fireEvent(l.ZoomFactorChanged,s),("DistanceMeasure"==t||"AngleMeasure"==t||"AreaMeasure"==t)&&"change"==o){var c=n.getViewScale(),d=null;s&&"Distance"===s.type?d="measured"===s.status?{type:s.type,distance:s.distance*c,points:s.points,start:[s.start[0]*c,s.start[1]*c],end:[s.end[0]*c,s.end[1]*c],isOnLayout:s.isOnLayout}:{type:s.type,points:s.points}:s&&"Area"===s.type?d={type:"Area",points:s.points,area:"measured"===s.status&&s.area*c*c||null}:s&&"Angle"===s.type&&(d=s),"measuring"===s.status?n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,d):"measured"===s.status?n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,d):"reset"===s.status&&n.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset)}if("pick"==t&&"selection"==o&&(n.getEventManager().fireEvent(l.ComponentsSelectionChanged,s),n.getEventManager().fireEvent(l.SelectionChanged,s)),"pick"==t&&"highlight"==o)if(s.length>0){if(i==s[0])return;let e=n._drawingViewer.toWorldPoint([r,a]);n.getEventManager().fireEvent(l.Hover,{objectId:s[0],clientPosition:{x:r,y:a},worldPosition:{x:e[0],y:e[1]},event:h}),i=s[0]}else i=null}},createDrawingViewer:function(t,i,n=!1){var o;"2"==this.version||n?o=e.Bimface.WebglDrawingSheet:(o=e.Bimface.DrawingSheet,this.isInitialized=!0);let s=e.Web.Lang.Utility.ClientHelper.getIsDesktop();var r=o.createDrawing(t,i);return r.mouseEditorMgr=s?o.createMouseEditorManager(r):o.createTouchEditorManager(r),r},zoomToBoundingBox:function(e,t=.5){if("2"!==this.version&&this.loadedDrawings.length<1)return void console.log("Drawing of old version doesn't support zoomToBoundingBox.");if(!e)return void console.log("Parameter boundingBox is required.");let i,n;"[object Object]"===e.toString()?(i=[e.min.x,e.min.y,0],n=[e.max.x,e.max.y,0]):(i=e[0].concat([0]),n=e[1].concat([0])),this.getViewer().zoomToWorldBox(i,n,t),this.update()},getAxisGridsIntersection:function(e,t){var i;this.loadedDrawings.length>0?(i=`${this.loadedDrawings[0].drawing.url}/AxisGrid.json`,this.obsoleteOld("ViewerDrawing.getAxisGridsIntersection","ViewerDrawing.getDrawing(modelId).getAxisGridsIntersection")):i=`${this.url}/AxisGrid.json`;let n=[];this.getAxisGrid(i,(i=>{for(let t=0;t<e.length-1;t++){const o=e[t];for(let s=t+1;s<e.length;s++){const t=e[s];let r=o>t?t:o,a=o>t?o:t,l=i[r]&&i[r][a];l&&n.push({intersection:l,axisNames:[r,a]})}}t&&t(n)}))},getAxisGrid:function(t,i){let n=this._cache;if(n.AxisGrid)return i(n.AxisGrid);e.Web.Lang.Utility.HttpRequest.ajax({url:t,success:function(e){var t=JSON.parse(e);if(t){let e={},o=t.intersection;for(let t=0;t<o.length;t++){let i=o[t].axisGrids[0],n=o[t].axisGrids[1],s=i>n?n:i,r=i>n?i:n;e[s]||(e[s]={}),e[s][r]||(e[s][r]=[]),e[s][r].push(o[t].intersection)}n.AxisGrid=e,i(e)}}})},toRevitId:function(e){return this.console.obsolete("ViewerDrawing.toRevitId","ViewerDrawing.toModelId"),this.toModelId(e)},toLinkRevitId:function(e,n){return i.send(t,"toLinkRevitId"),this._drawingViewer.revitInterop.toLinkRevitId(e,n)},fromRevitId:function(e){return this.loadedDrawings.length>0?this.loadedDrawings[0].drawing.revitInterop.fromRevitId(e):this._drawingViewer.revitInterop.fromRevitId(e)},fromLinkRevitId:function(e,n){return i.send(t,"fromLinkRevitId"),this.obsoleteOld("ViewerDrawing.fromLinkRevitId","ViewerDrawing.getDrawing(modelId).fromLinkRevitId"),this._drawingViewer.revitInterop.fromLinkRevitId(e,n)},toModelId:function(e){return this.obsoleteOld("ViewerDrawing.toModelId","ViewerDrawing.getDrawing(modelId).toModelId"),i.send(t,"toModelId"),this._drawingViewer.revitInterop.toRevitId(e)},toDrawingId:function(e,n){if(i.send(t,"toDrawingId"),this.loadedDrawings.length>0){if(!n)return this.loadedDrawings[0].drawing.revitInterop.fromRevitId(e);{const t=()=>{const t=this.loadedDrawings[0].drawing.revitInterop.fromRevitId(e);n(t)};this.revitInteropReady?t():this.loadedDrawings[0].drawing.revitInterop.callback=()=>{this.revitInteropReady=!0,t()}}}else{if(!n)return this._drawingViewer.revitInterop.fromRevitId(e);{const t=()=>{const t=this._drawingViewer.revitInterop.fromRevitId(e);n(t)};this.revitInteropReady?t():this._drawingViewer.revitInterop.callback=()=>{this.revitInteropReady=!0,t()}}}},zoomToObject:function(e,n){let o=this.obsoleteOld("ViewerDrawing.zoomToObject","ViewerDrawing.getDrawing(modelId).zoomToObject");if(i.send(t,"zoomToObject"),n=e.ratio||n||.5,this.clearSelection(),this.loadedDrawings.length>0){const t=this.loadedDrawings.find((t=>t.drawing.modelId==e.modelId));t&&(o=t.drawing.drawingIndex,e.ratio=n,t.drawing.zoomToObject(e))}else this._drawingViewer.zoomToObject("object"==typeof e?e.objectId:e,n,o),this._drawingViewer.canSelectInBlock()?this.selectIdWithBlock(0,"object"==typeof e?e.objectId:e):this.selectByIds("object"==typeof e?e.objectId:e,o,!0)},zoomToObjectWithBlock:function(e,t,i){i=i||.5,this.clearSelection(),this._drawingViewer.zoomToObjectWithBlock(e,t[0],i);for(var n=0;n<t.length;n++)this.selectIdWithBlock(e,t[n]);this.update()},setZoomRatio:function(e){((e=e||1.1)>=2||e<0)&&(e=1.9),this._drawingViewer.setZoomRatio(e)},getZoomRatio:function(){return this._drawingViewer.getZoomRatio()},_checkIfSelectionChanged:function(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),t.length!==e.length||t.sort().toString()!==e.sort().toString()},_onSelectionChanged:function(e){if(this._selectionChangedInfo)clearTimeout(this._selectionChangedInfo.timeout);else{const e=this.getSelectedElements();this._selectionChangedInfo={lastSelection:e}}this._selectionChangedInfo.timeout=setTimeout((()=>{this._checkIfSelectionChanged(this.getSelectedElements(),this._selectionChangedInfo.lastSelection)&&(this.getEventManager().fireEvent(l.ComponentsSelectionChanged,e),this.getEventManager().fireEvent(l.SelectionChanged,this.getSelectedElements())),delete this._selectionChangedInfo}),10)},selectByIds:function(e,n,o=!1){const s=this.obsoleteOld("ViewerDrawing.selectByIds","ViewerDrawing.getDrawing(modelId).select",o);i.send(t,"selectByIds"),Array.isArray(e)||(e=[e]),this._onSelectionChanged(e),this._drawingViewer.selectByIds(e,n||s),this.update()},removeSelectId:function(e){this.loadedDrawings.length>0?this.loadedDrawings.map((t=>this._drawingViewer.removeSelectId(e,t.drawing.drawingIndex))):this._drawingViewer.removeSelectId(e),this.update()},getSelectedElements:function(){if(this.loadedDrawings.length>0){let e=[];return this.loadedDrawings.map((t=>{e=[...e,...this._drawingViewer.getSelectedIds(t.drawing.drawingIndex)]})),e}return this._drawingViewer.getSelectedIds()},getSelectedObjects:function(){let e=[];return this.loadedDrawings.map((t=>{const i=this._drawingViewer.getSelectedIds(t.drawing.drawingIndex),n={modelId:t.drawing.modelId,ids:i};e.push(n)})),e},selectIdWithBlock:function(e,t){("string"==typeof e||e instanceof String)&&(e=parseInt(e)),("string"==typeof t||t instanceof String)&&(t=parseInt(t)),this._drawingViewer.selectIdWithBlock(e,t)},clearDrawingSelections:function(e){const t=Array.from(new Set(this._drawingViewer.getSelectedIds(e)));this._onSelectionChanged(t),this._drawingViewer.clearSelection(e)},clearSelection:function(){this.loadedDrawings.length>0?this.loadedDrawings.map((e=>{this.clearDrawingSelections(e.drawing.drawingIndex)})):this.clearDrawingSelections(),this.update(!0)},showLineWidth:function(e){i.send(t,"showLineWidth"),this._opt.enableLineWidth=e,this._drawingViewer.viewer.ShowLineWidth=e,this.update(!0)},isEnableLineWidth:function(){return this._opt.enableLineWidth},loadModel:function(t,i,n){var s=this,r=this._drawingViewer,a=r.mouseEditorMgr;r.touchEditorMgr;this.grids=null,i&&(t=t+(n?"/"+n:"")+"/"+i,e.Bimface.DrawingSheet.loadGrids(t,(function(e){e&&(s.grids=e.grids,console.log(e))}))),e.Bimface.DrawingSheet.loadModel(t,(function(t){if(null!==t){if(r.setModel(t),r.clearSelection(),i){var n,h=r.getLayouts(),c=null;for(g=0;g<h.length;g++)if("Layout1"==h[g].name){c=h[g].id;break}c&&s.showViewById(c),n=new e.Bimface.RevitInterop,s.loadedDrawings.length>0?n.initialize(r,s.loadedDrawings[0].drawing.model.Url):n.initialize(r),r.revitInterop=n}s.hasBindEvents||(a.bindEvents(),s.hasBindEvents=!0),s.observer(a),a.activeEditorByName("pick"),o.loading=!1;var d=(u=document.querySelectorAll(".bf-drawing-container .bf-loading")).length;for(g=0;g<d;g++)u[g].remove();s.rootElement.style.zIndex=1,window.addEventListener("resize",(function(){r&&r.onResize()})),r.onViewChanges=function(){s.getEventManager().fireEvent(l.Rendered,r)},s.enableViewport(s._opt.enableViewport),s.setDisplayMode(s._opt.displayMode),!s._opt.enableViewport&&s.home(),s.showLineWidth(s._opt.enableLineWidth),s.getManifest((function(e){let t=(e=e||{}).Features,i=Object.assign({},t||{}),n=s._viewMetaData||s._data,o=!0,r=!0,a=!1,h=!1;t&&(o=t.HasLayout,r=t.HasMiniMap,a=t.HasText),(n.split&&n.split.databagId||n.config&&n.config.split)&&(h=!0),i=Object.assign(i,{HasLayout:o,HasMiniMap:r,HasText:a,HasSplitDrawing:h}),s._manifest=Object.assign(e,{Features:i}),s.getEventManager().fireEvent(l.Loaded,s._drawingViewer.mouseEditorMgr)})),s.cursorReady||(e.Web.Lang.Utility.MouseMotion.setCursor(s),s.cursorReady=!0),s.enableHover(s._opt.enableHover)}else{console.log("failed to load model!"),o.loading=!1;for(var u=document.querySelectorAll(".bf-drawing-container .bf-loading"),g=0;g<u.length;g++)u[g].remove();s.rootElement.style.zIndex=1}}))},setNavigationMode:function(e){i.send(t,"setNavigationMode"),"rectZoom"==e?this.rectZoom():this._drawingViewer.mouseEditorMgr.activeEditorByName(e)},zoomIn:function(){this._drawingViewer.zoomPan(1.1)},zoomOut:function(){this._drawingViewer.zoomPan(.9)},zoom:function(e){this._drawingViewer.zoomPan(e)},resize:function(){this._drawingViewer.onResize()},worldToClient:function(e){var t=this._drawingViewer.toScreenPoint([e.x,e.y]);return{x:t[0],y:t[1]}},clientToWorld:function(e){var t=this._drawingViewer.toWorldPoint([e.x,e.y]);return{x:t[0],y:t[1]}},update:function(e){this._drawingViewer.update(e)},render:function(){this._drawingViewer.update(!0)},setPrintMode:function(e){this._drawingViewer&&(this.loadedDrawings.length>0?this.loadedDrawings.map((t=>t.drawing.drawingIndex>-1&&this._drawingViewer.setPrintMode(e,t.drawing.drawingIndex))):this._drawingViewer.setPrintMode(e),this._drawingViewer.update(!0))},setGlobalOpacity:function(e){this.loadedDrawings.length>0?this.loadedDrawings.map((t=>this._drawingViewer.setGlobalOpacity(e,t.drawing.drawingIndex))):"1"==this.version?this._drawingViewer.dc.setGlobalOpacity(e):this._drawingViewer.setGlobalOpacity(e),this._drawingViewer.update(!0)},setBackgroundColor:function(e){this.rootElement.style.background=e.getRGBA(),3===this._opt.displayMode&&(d[3]=e.getRGBA())},restoreBackgroundColor:function(){3===this._opt.displayMode&&(d[3]=d[0]),this.rootElement.style.background=d[this._opt.displayMode]},setDisplayMode:function(e){if(i.send(t,"setDisplayMode"),e=e||0,"1"==this.version&&3==e)return this.console.updateDataSource("ViewerDrawing.setDisplayMode(3)");this.rootElement.style.background=d[e],0==e?"2"==this.version&&this._drawingViewer.setSelectWireframeColor(1,1,1,1):3!=e&&"2"==this.version&&this._drawingViewer.setSelectWireframeColor(.733,.733,.733,1),1!=e&&2!=e||"2"!=this.version?"2"==this.version&&(this.loadedDrawings.length>0?this.loadedDrawings.map((e=>this._drawingViewer.enableReplaceElementColor(!1,e.drawing.drawingIndex))):this._drawingViewer.enableReplaceElementColor(!1)):this.loadedDrawings.length>0?this.loadedDrawings.map((e=>{this._drawingViewer.enableReplaceElementColor(!0,e.drawing.drawingIndex),this._drawingViewer.replaceElementColor(1,1,1,0,0,0,e.drawing.drawingIndex)})):(this._drawingViewer.enableReplaceElementColor(!0),this._drawingViewer.replaceElementColor(1,1,1,0,0,0)),this._opt.displayMode=e;this.setPrintMode(["Normal","White","Black","Custom"][e])},getGlobalOpacity:function(){return this._drawingViewer.dc.getGlobalOpacity()},setGlobalColor:function(e){e instanceof r.Color?(this.loadedDrawings.length>0?this.loadedDrawings.map((t=>{this._drawingViewer.setGlobalColor(e,t.drawing.drawingIndex)})):this._drawingViewer.setGlobalColor(e),this._drawingViewer.update(!0)):console.error("param use Glodon.Web.Graphics.Color ")},restoreGlobalColor:function(){if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.restoreGlobalColor");this.loadedDrawings.length>0?this.loadedDrawings.map((e=>this._drawingViewer.restoreGlobalColor(e.drawing.drawingIndex))):this._drawingViewer.restoreGlobalColor(),this._drawingViewer.update(!0)},getGlobalColor:function(){if(3==this.getDisplayMode())return this._drawingViewer.getGlobalColor();console.error("Only available when using customized display mode.")},restoreGlobalOpacity:function(){this._drawingViewer.dc.restoreGlobalOpacity(),this._drawingViewer.update(!0)},getDisplayMode:function(){return this._opt.displayMode},getViewScale:function(){return this._drawingViewer.getViewScale()},setViewScale:function(e){this._drawingViewer.setViewScale(e)},setSnapDistance:function(e){"number"!=typeof e||e<0||e>25||this._drawingViewer.setSnapDistance(e)},showMergedBoundingBoxById:function(t,i){let n=[];for(const e of t)n.push(this.getObjectBoundingBox(e));let o=e.Web.Algorithm.BoundingBoxUtil,s=o.toThreeJsBox2(n,i),r=o.mergeBoundingBox(s),a=o.toDrawingBox2(r);for(const e of a)this._drawingViewer.showElementBoxByBBox(e,0);this._drawingViewer.update()},showElementBox:function(e,t){this.showElementBoxByBBox(this.getObjectBoundingBox(e),t)},showElementBoxByBBox:function(e,t){if("[object Object]"===e.toString()&&(e=[[e.min.x,e.min.y],[e.max.x,e.max.y]]),t){t=Math.min(t,100)/100;var i=Math.max(e[1][1]-e[0][1],e[1][0]-e[0][0])}this._drawingViewer.showElementBoxByBBox(e,t&&i*t),this._drawingViewer.update()},showBoundingBox:function(e,t=0){Array.isArray(e)&&(e={min:{x:e[0][0],y:e[0][1]},max:{x:e[1][0],y:e[1][1]}}),t=Math.min(t,100)/100;const i=Math.max(e.max.y-e.min.y,e.max.x-e.min.x);this._drawingViewer.showElementBoxByBBox(e,t&&i*t),this._drawingViewer.update()},hideElementBox:function(e){this._drawingViewer.hideElementBox(parseInt(e)),this._drawingViewer.update(!0)},clearElementBox:function(){this._drawingViewer.clearElementBox(),this._drawingViewer.update(!0)},getObjectBoundingBox:function(e){e=parseInt(e);let t=this.obsoleteOld("ViewerDrawing.getObjectBoundingBox","ViewerDrawing.getDrawing(modelId).getObjectBoundingBox");return this._drawingViewer.getObjectBoundingBox(e,t)},toViewportBoundingBox:function(e,t){return t=parseInt(t)||0,this._drawingViewer.toViewportBoundingBox(e[0],e[1],t)},getVisibleBoxIds:function(){return this._drawingViewer.getVisibleBoxIds()},enableHighlightEvent:function(e){this._drawingViewer.enableHighlightEvent(e)},highlightById:function(e){const t=this.obsoleteOld("ViewerDrawing.highlightById","ViewerDrawing.getDrawing(modelId).highlight");if(Array.isArray(e))for(var i=0,n=e.length;i<n;i++)this._drawingViewer.highlightById(parseInt(e[i]),t);else this._drawingViewer.highlightById(parseInt(e),t);this._drawingViewer.update(!0)},clearHighlight:function(){this.loadedDrawings.length>0?this.loadedDrawings.map((e=>{this._drawingViewer.clearHighlight(e.drawing.drawingIndex)})):this._drawingViewer.clearHighlight(),this._drawingViewer.update(!0)},ignoreImage:function(e){this._drawingViewer.dc.ignoreImage=e,this._drawingViewer.update(!0)},clientToModelWorld:function(e){var t=this._drawingViewer.viewer.ToModelWorldPoint([e.x,e.y]);return[t[0],t[1]]},getNearestGrid:function(t){t=this.clientToModelWorld(t);for(var i=this.grids,n=null,o=i.length-1;o>=0;o--){var s=i[o].gridInfo;s.distance=e.Web.Lang.Utility.ClientHelper.PointToLineDistance(t[0],t[1],s.start.x,s.start.y,s.end.x,s.end.y),n?n.distance[0]>s.distance[0]&&(n=s):n=s}return n},scale(e,t){const i=this.obsoleteOld("ViewerDrawing.scale","ViewerDrawing.getDrawing(modelId).scale");this._drawingViewer.scaleDrawing(e,t,i)},getScaleFactor(){const e=this.obsoleteOld("ViewerDrawing.getScaleFactor","ViewerDrawing.getDrawing(modelId).getScaleFactor");return this._drawingViewer.getAlignScale(e)},getExternalReferencesList(e){let t;this.loadedDrawings.length>0?(t=`${this.loadedDrawings[0].drawing.url}/externalBlocks.json`,this.obsoleteOld("ViewerDrawing.getExternalReferencesList","ViewerDrawing.getDrawing(modelId).getExternalReferencesList")):t=`${this.url}/externalBlocks.json`,this._ajaxGet(t,e)},getAlignState(){return this._drawingViewer.getAlignState()},setAlignState(e){this._drawingViewer.setAlignState(e)},setModelTransformation(e){this._drawingViewer.setModelTransformation&&this._drawingViewer.setModelTransformation(e),this.update()},overrideElementsColorById(e,t){const i=this.obsoleteOld("ViewerDrawing.overrideElementsColorById","ViewerDrawing.getDrawing(modelId).overrideObjectsColor");if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.overrideElementsColorById");t instanceof r.Color?this._drawingViewer.overrideElementsColorById(e,t,i):console.error("param use Glodon.Web.Graphics.Color ")},restoreElementsColorById(e){const t=this.obsoleteOld("ViewerDrawing.restoreElementsColorById","ViewerDrawing.getDrawing(modelId).restoreObjectsColor");if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.restoreElementsColorById");this._drawingViewer.restoreElementsColorById(e,t)},addImage(e,t,i,n,o){let s=this._drawingViewer.customManager,r=s.markups,a=this,l=new Image;l.src=t;for(let t=0;t<r.length;t++){if(r[t].id==e)return console.error("id"+e+"已经存在,图片添加失败!"),!1}s.setStyle("Chartlet"),s.add([i.x,n.y],[n.x,i.y],0,l,e),l.onload=function(){a.update(),o&&o()},this.calculateBBox()},calculateBBox(){let e=this._drawingViewer.customManager.markups,t=this._drawingViewer.getModelBBox().GetMinPt(),i=this._drawingViewer.getModelBBox().GetMaxPt();for(let o=0;o<e.length;o++){var n=e[o];n.min&&(t[0]=Math.min(n.min[0],t[0]),t[1]=Math.min(n.min[1],t[1]),i[0]=Math.max(n.max[0],i[0]),i[1]=Math.max(n.max[1],i[1]))}this.modelBBox=[t,i]},clearImages(){this._drawingViewer.customManager.markups=[],this.modelBBox=null},removeImagesById(e){let t=this._drawingViewer.customManager.markups;for(let n=0;n<e.length;n++){var i=e[n];for(let e=0;e<t.length;e++){if(t[e].id==i){t.splice(e,1);break}}}this.calculateBBox(),this.update()},enableViewport(e){this._drawingViewer.enableViewport&&this._drawingViewer.enableViewport(e)},getRenderInfo(e,t){let i=this;this.getViewMetaData(e,(function(e){let n=e.drawingUrl;i.getIndexJson(n,(function(e){t&&t(e)}))}))},getAxisInfo:function(e){var t;this.loadedDrawings.length>0?(t=`${this.loadedDrawings[0].drawing.url}/AxisGrid.json`,this.obsoleteOld("ViewerDrawing.getAxisInfo","ViewerDrawing.getDrawing(modelId).getAxisInfo")):t=`${this.url}/AxisGrid.json`,this._ajaxGet(t,e)},getManifest:function(t){let i=e.Web.Lang.Utility.HttpRequest,n=this._viewMetaData||this._data,o=n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||this._viewConfig.resourceHost)+"/"+o+"/manifest.json");i.ajax({url:`${s}`,success:function(e){var i=JSON.parse(e);i&&t(i)},failure:function(e){t(e)}})},_ajaxGet:function(t,i){e.Web.Lang.Utility.HttpRequest.ajax({url:t,success:function(e){var t=JSON.parse(e);t&&i(t)}})},hideElementsById:function(e){let t=this.obsoleteOld("ViewerDrawing.hideElementsById","ViewerDrawing.getDrawing(modelId).hideObjects");this._drawingViewer.hideElementsById&&this._drawingViewer.hideElementsById(e,t)},showElementsById:function(e){const t=this.obsoleteOld("ViewerDrawing.showElementsById","ViewerDrawing.getDrawing(modelId).showObjects");this._drawingViewer.showElementsById&&this._drawingViewer.showElementsById(e,t)},getObjectViews:function(){let e=this.getViews(),t={};for(let i=0;i<e.length;i++)t[e[i].name]=e[i].id;return t},getElementsByBoundingBox(e,t,i,n=!1){t.max.z=t.max.z||0,t.min.z=t.min.z||0;let o=this.obsoleteOld("ViewerDrawing.getElementsByBoundingBox","ViewerDrawing.getDrawing(modelId).getObjectsByBoundingBox");return this._drawingViewer.getAllElementsByBoundingBox(e,t,h[i]||1,n,o)},getTextByBoundingBox:function(e,t){this.obsoleteOld("ViewerDrawing.getTextByBoundingBox","ViewerDrawing.getDrawing(modelId).getTextByBoundingBox");let{viewId:i,boundingBox:n}=e;i=null==i?this.getCurrentViewId():i;const o=this.getViews(),{min:s,max:r}=n;this.getDrawingFeatures((function(e){if(e){let n,a=[];if(0==i)n=e.text.model.data;else{const t=o.find((e=>e.id==i));n=e.text.layouts.find((e=>e.name==t.name)).data}for(let e=0;e<n.length;e++){let t=n[e].content,i=n[e].items;for(let e=0;e<i.length;e++){const n=i[e].bbox,o={min:{x:n[0],y:n[1]},max:{x:n[2],y:n[3]}};o.min.x>s.x&&r.x>o.max.x&&s.y<o.min.y&&r.y>o.max.y&&a.push({content:t,boundingBox:o})}}let l=a;if(a.length>0){a.sort(((e,t)=>t.boundingBox.min.y-e.boundingBox.min.y));const e=a[Math.ceil(a.length/2)-1],t=e.boundingBox.max.y-e.boundingBox.min.y;l=[];const i=e=>{let n=e[0],o=[n];for(let s=1;s<e.length;s++){const r=e[s];if(!(Math.abs(r.boundingBox.min.y-n.boundingBox.min.y)<t))return o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),l=l.concat(o),i(e.slice(s));o.push(r),n=r}o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),l=l.concat(o)};i(a)}t(l)}else t(null)}))},getTextByElementId:function(e,t){if(void 0===e||!t)return console.error("图元ID和回调函数不能为空");this.getDrawingFeatures((function(i){if(i){let n=[i.text.model].concat(i.text.layouts),o=[];for(let t=0;t<n.length;t++){let i=n[t].data;for(let t=0;t<i.length;t++){let n=i[t].content,s=i[t].items;for(let t=0;t<s.length;t++)if(s[t].id==e){o.push(n);break}}}t(o)}else t(null)}))},getDrawingFeatures:function(t){if(this._drawingFeatures)t(this._drawingFeatures);else{this.loadedDrawings.length>0&&(this._viewMetaData=this.loadedDrawings[0].drawing._viewMetaData);const i=this._viewMetaData||this._data;let n=this,o=i.integrateDrawings&&i.integrateDrawings.databagId||i.databagId,s=e.Web.Lang.Utility.ClientHelper.formatURL((i.path||n._viewConfig.resourceHost)+"/"+o+"/resource/drawing/drawingFeatures.json.gz");this._ajaxGet(s,(function(e){n._drawingFeatures=e,t(e)}))}},getLayerIdsByElements(e){let t=this.obsoleteOld("ViewerDrawing.getLayerIdsByElements","ViewerDrawing.getDrawing(modelId).getObjectsByLayerId"),i=[];for(let n=0;n<e.length;n++)i.push(this.getLayerIdFromElementId(e[n],t));return i},overrideLayersColorById(e,t){const i=this.obsoleteOld("ViewerDrawing.overrideLayersColorById","ViewerDrawing.getDrawing(modelId).overrideLayersColor");if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.overrideLayersColorById");if(t instanceof r.Color){const{red:n,green:o,blue:s,alpha:r}=t;this._drawingViewer.setColorByLayerId(e,n/255,o/255,s/255,r,i),this.update()}else console.error("param use Glodon.Web.Graphics.Color ")},restoreLayersColorById(e){const t=this.obsoleteOld("ViewerDrawing.restoreLayersColorById","ViewerDrawing.getDrawing(modelId).restoreLayersColor");this._drawingViewer.resetColorByLayerId(e,t),this.update()},searchText:function(e,t){if(this.console.obsolete("ViewerDrawing.searchText(text, callback)","ViewerDrawing.search(option, successCallback, failureCallback)"),void 0===e||""===e||!t)return console.error("搜索文本内容和回调函数不能为空");let i=this;this.getDrawingFeatures((function(n){if(n){n.text.model.name="Model";let o=[n.text.model].concat(n.text.layouts),s=[],r=i.getObjectViews();for(let t=0;t<o.length;t++){let i=o[t].data,n=o[t].name;for(let t=0;t<i.length;t++)if(i[t].content.indexOf(e)>-1){let e=[];for(let n=0;n<i[t].items.length;n++){let o=i[t].items[n].bbox;e.push({max:{x:o[2],y:o[3]},min:{x:o[0],y:o[1]}})}s.push({viewId:r[n],content:i[t].content,boundingBox:e})}}t(s)}else t(null)}))},highlightByLayerId(e,t){const i=this.obsoleteOld("ViewerDrawing.highlightByLayerId","ViewerDrawing.getDrawing(modelId).highlight");if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.highlightByLayerId");let n=this._drawingViewer.getElementIdsByLayerId(e,t||"0",i);this._drawingViewer.highlightByIds(n,i),this.update()},getElementsByLayerId(e,t){let i=this.obsoleteOld("ViewerDrawing.getElementsByLayerId","ViewerDrawing.getDrawing(modelId).getObjectsByLayerId");if("1"==this.version)return this.console.updateDataSource("ViewerDrawing.getElementsByLayerId");let n=this._drawingViewer.getElementIdsByLayerId(e,t||"0",i),o=[];for(var s=0,r=n.size();s<r;++s)o.push(n.at(s));return o},getTextById(e,t){this.obsoleteOld("ViewerDrawing.getTextById","ViewerDrawing.getDrawing(modelId).getTextById"),this.getDrawingFeatures((function(i){let n=[];if(i){let t=[i.text.model].concat(i.text.layouts);for(let i=0;i<t.length;i++){let o=t[i].data;for(let t=0;t<o.length;t++)for(let i=0;i<o[t].items.length;i++){o[t].items[i].id==e&&n.push(o[t].content)}}}t(n)}))},search:function(e,t,i){if(!e||void 0===e.text||""===e.text||!t)return console.error("搜索文本内容和回调函数不能为空");let n=this;if(this.loadedDrawings.length>0){let s=[],r=0;function o(e){s=[...s,...e],r+=1}this.loadedDrawings.map((t=>{t.drawing.search(e,o,i)}));const a=setInterval((function(){r==n.loadedDrawings.length&&(t(s),clearInterval(a))}),100)}else this.getDrawingFeatures((function(o){if(o){o.text.model.name="Model";let i=[o.text.model].concat(o.text.layouts),s=[],r=n.getObjectViews();for(let t=0;t<i.length;t++){let n=i[t].data,o=i[t].name;for(let t=0;t<n.length;t++)if(n[t].content.indexOf(e.text)>-1){let e=[];for(let i=0;i<n[t].items.length;i++){let o=n[t].items[i],s=o.bbox;e.push({id:o.id,boundingBox:{max:{x:s[2],y:s[3]},min:{x:s[0],y:s[1]}}})}s.push({viewId:r[o],content:n[t].content,data:e})}}t(s)}else i(null)}))},createWrap:function(e){return a.create("div",this.rootElement.id+e)},moveDrawing(e,t){let i=this.getViewer();i.alignDrawing([0,0],[e[0],e[1]],t),i.update(!0)},verify(e,t,i,n,o){let s=function(e,t){if(!e)return!1;if(!t)return!0;let i=e.GetSnapTypeName();return t.snapList.includes({PointOnLine:"line",Intersection:"intersection",MiddlePoint:"midpoint",EndPoint:"endpoint"}[i])};if(!e)return;let r=this.getViewer(),a=null;for(var l=0;l<this.loadedDrawings.length;l++)if(this.loadedDrawings[l].drawingIndex!=t){let t=r.snapToPoint(e[0],e[1]),i=t.GetPoint(),n=t.GetID();if(0!=n){let o=t.GetSnapTypeName();if(!s(t,this.snapMode))continue;return e=r.toScreenPoint(i),this.tempSnapPoint={worldPoint:i,id:n,screenPoint:e,type:o},a=e,a}}return this.tempSnapPoint=null,a},onMouseClick:function(e){let t=-1;if(this.loadedDrawings.length>0&&this.loadedDrawings.find((e=>{e.drawing.isAlignment&&(t=e.drawing.drawingIndex)})),t>-1){let i=this.getViewer().toModelWorld([e.clientPosition.x,e.clientPosition.y]);this._drawingViewer.alignmentPoints.push({x:i[0],y:i[1]});let n=this._drawingViewer.alignmentPoints;if(1==n.length){let t=this.getViewer(),i=t.snapToPoint(e.clientPosition.x,e.clientPosition.y),o=i.GetPoint();if(0!=i.GetID())n[0]={x:o[0],y:o[1]};else{let i=[e.clientPosition.x,e.clientPosition.y];if(i){let e=t.toModelWorld(i).slice(0,2);n[0]={x:e[0],y:e[1]}}}}else if(2==n.length){let i=this.getViewer();"capture"!=i.mouseEditorMgr.editors[0].name&&this.setNavigationMode("capture");let o=this.verify([e.clientPosition.x,e.clientPosition.y],t);if(o){let e=i.toModelWorld(o).slice(0,2);n[1]={x:e[0],y:e[1]}}this.moveDrawing([n[1].x-n[0].x,n[1].y-n[0].y],t),this._drawingViewer.alignmentPoints=[]}}else if(this.snapping){var i=this.getViewer().snapToPoint(e.clientPosition.x,e.clientPosition.y);if(0!=i.GetID()){var n=i.GetSnapType(),o={x:i.GetPoint()[0],y:i.GetPoint()[1]},s=this.getViewer().toScreenPoint([o.x,o.y]),r={x:s[0],y:s[1]};e.snapPoint={type:n,clientPosition:r,worldPosition:o}}else this.tempSnapPoint&&(e.snapPoint={type:this.tempSnapPoint.type,clientPosition:{x:this.tempSnapPoint.screenPoint[0],y:this.tempSnapPoint.screenPoint[1]},worldPosition:{x:this.tempSnapPoint.worldPoint[0],y:this.tempSnapPoint.worldPoint[1]}})}},_handleDrawingMouseClick:e=>{e.selfDrawing.onMouseClick(e)},loadDrawing:function(t,i){if("object"==typeof t){const n=this,o=t.modelId,s=t.frameId,r=t.viewToken;if(this.loadedDrawings.length>0&&(this.oldState=this._drawingViewer&&this.getCurrentState()),o){if(this.loadedDrawings.find((e=>e.modelId==o)))return this.console.error(`Failed to load drawing with ID ${o}, a drawing with the same ID already exists`),!1}if(!r)return!1;this.getViewMetaData(r,(function(t){let a=new e.Bimface.Viewer.ViewerDrawingConfig;a.drawingUrl=t.drawingUrl,a.viewToken=r,a.enableViewport=n._viewConfig.enableViewport,a._drawingViewer=n._drawingViewer,a.rootElement=n.getRootElement(),a.domElement=n.getDomElement(),a.fileName=t.name,a.modelId=o,a.eventManager=n.getEventManager();const l=e.Bimface.Viewer.ViewerDrawingEvent;let h;h=new e.Bimface.Viewer.Drawing(a),s?h.loadFrame(r,s,n):h.load(r,null,null,n);const c={modelId:o,wrap:n.getDomElement(),drawing:h,fileName:t.name};n.loadedDrawings.push(c);const d=n.getEventManager().container;let u=!0;if(d[l.MouseClicked]&&d[l.MouseClicked].length>0){d[l.MouseClicked].find((e=>e==n._handleDrawingMouseClick))&&(u=!1)}return u&&n.addEventListener(l.MouseClicked,n._handleDrawingMouseClick),h.getSelfEventManager().addEvent(l.Loaded,(function(t,o,s){!n._drawingViewer&&(n._drawingViewer=c.drawing.getViewer()),n.loadedDrawings.length>1&&n.oldState&&n.setState(n.oldState);const r=n.getRootElement().style.backgroundColor;n.setDisplayMode(n.getDisplayMode());if((r?r.match(/\((.+?)\)/g):[]).length>0){const t=RegExp.$1.split(",");n.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}const a=n.loadedDrawings.find((e=>e.drawing.drawingIndex==s.drawingIndex));a&&!a.modelId&&(a.modelId=s.modelId),n.getEventManager().fireEvent(l.Loaded,t,o,s),n.getEventManager().fireEvent(l.LoadDrawing,n),n.getEventManager().fireEvent(l.ViewChanged,n),i&&i(o)})),!0}))}"string"==typeof t&&(1==arguments.length&&this.load(arguments[0]),2==arguments.length&&this.loadFrame(arguments[0],arguments[1]))},loadDrawings:function(e,t){const i=this;this._drawingViewer||(i._drawingViewer=i.createDrawingViewer(i.getRootElement().id,null,!0));const n=[];e.map((e=>{if(n.includes(e.modelId))return this.console.error(`Failed to load drawing with ID ${e.modelId}, a drawing with the same ID already exists`),!1;n.push(e.modelId),this.loadDrawing(e,t)}))},getDrawing:function(e){if(null!=e){const t=this.loadedDrawings.find((t=>t.modelId==e));return t?t.drawing:void this.console.error("modelId is not exist!")}return this.loadedDrawings[0].drawing},removeDrawing:function(e){if(!e)return this.console.error("modelId is necessary!"),!1;const t=this.getDrawing(e);this.getViewer().releaseModel(t.drawingIndex),this.loadedDrawings.removeObjectByAttribute("modelId",e),this.update(),this.getEventManager().fireEvent(l.ViewChanged,self)},clearBoundingBox:function(){this._drawingViewer.clearElementBox(),this._drawingViewer.update(!0)},obsoleteOld(e,t,i=!1){let n=0;return this.loadedDrawings.length>0&&(!i&&this.loadedDrawings.length>1&&e&&t&&this.console.obsolete(e,t),n=this.loadedDrawings[0].drawing.drawingIndex),n}}),n.ViewerDrawing=u}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingSetConfig=function(){return{domElement:null,resourceHost:c.resourceHost,staticHost:c.staticHost+"/api/Glodon",APIHost:c.APIHost,securityApi:c.securityApi,sdkUrl:null,staticPath:"/api/Glodon",enableLineWidth:!1,displayMode:0,enableHover:!0,enableViewport:!1}},function(){let t=Object.freeze({ViewAdded:"ViewAdded",ViewLoading:"ViewLoading",ComponentsSelectionChanged:"ComponentsSelectionChanged",SelectionChanged:"SelectionChanged",ComponentsHoverChanged:"ComponentsHoverChanged",Error:"Error",Loaded:"Loaded",MouseClicked:"MouseClicked",ActiveViewChanged:"ActiveViewChanged",MouseDragged:"MouseDragged",ContextMenu:"ContextMenu",Rendered:"Rendered",ViewChanged:"ViewChanged",ViewMoving:"ViewMoving",ViewMoved:"ViewMoved",ViewZooming:"ViewZooming",ViewZoomed:"ViewZoomed",AddDrawing:"AddDrawing",Hover:"Hover",ZoomFactorChanged:"ZoomFactorChanged"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingSetEvent=t}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"GlobalData"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),e.Bimface.Viewer.ViewerDrawingSetEvent);i.isInitialized=i.isInitialized||!1;let r=["rgb(50,50,55)","rgb(255,255,255)","rgb(255,255,255)","rgb(50,50,55)","rgb(50,50,55)"];const a=e.Bimface.Data.StatisticsDataManager.getInstance(),l=new e.Web.Common.Console;let h=function(i){t.Viewer.call(this);this.viewerType="ViewerDrawingSet";let n=i;this._opt=i,this.isAlignment=!1,this.sets=[],this.activeState=null,this._displayMode=i.displayMode,this._state={},this.hasInit=!1,this._databagId=null;var r,l=o.create("div","bf-drawingSet-container "),h=i.domElement;h.id?r=h.id:(r=e.Web.Lang.Utility.UUID.createUUID(),h.id=r),l.id="DrawingSet"+r,l.setCss({width:"100%",height:"100%",position:"relative"}),h.appendChild(l),n.domElement=l,this.getRenderInfo=function(e,t){let i=this;this.getViewMetaData(e,(function(e){let n=e.drawingUrl;i.getIndexJson(n,(function(e){t&&t(e)}))}))},this._domElement=h,this._viewConfig=n,this.rootElement=l,this.haveActiveDrawing=!1,this.getRootElement=function(){return l},this.addEventListener(s.Loaded,(function(){a.send("Glodon.Bimface.Viewer.ViewerDrawingSet","Loaded",{eventId:"加载",loadModel:"expert",type:"DrawingSet"})}))};n.Type.inheritPrototype(h,t.Viewer),h.prototype=Object.assign({},t.Viewer.prototype,{addDrawing:function(t,i,n){var o=this;let s="object"==typeof arguments[0]?arguments[0]:{id:t,viewToken:i,callback:n},r=[];return o.sets.forEach((e=>{r=[...r,e.id]})),s&&s.id&&r.indexOf(s.id)>-1?(l.warn(`DrawingId("id":"${s.id}" ) is already existed.`),!1):(this.getViewMetaData(s.viewToken,(function(t){let i=new e.Bimface.Viewer.ViewerDrawingSetConfig,n=o.createWrap(s.id);i.domElement=n,i.drawingUrl=t.drawingUrl,i.displayMode=o._displayMode,i.viewToken=s.viewToken,i.enableViewport=o._viewConfig.enableViewport,o.getViewMetaData(s.viewToken,(function(e){o._databagId=e.databagId}));let r,a=e.Bimface.Viewer.ViewerDrawingSetEvent;r=new e.Bimface.Viewer.ViewerDrawing(i),s.frameId?r.loadFrame(s.viewToken,s.frameId):r.load(s.viewToken);let l={id:s.id,wrap:n,viewerDrawing:r,active:!1,visible:!0,fileName:t.name};o.sets.push(l),o.haveActiveDrawing||(o.haveActiveDrawing=!0,o.setActiveDrawing(s.id,!0)),r.addEventListener(a.MouseClicked,(function(e){o.onMouseClick(s.id,e)})),r.addEventListener(a.Rendered,(function(e){o.activeState=e.getState(),o.sync(),o.getEventManager().fireEvent(a.Rendered,o)})),r.addEventListener(a.Loaded,(function(t){const i=o.getRootElement().style.backgroundColor;o.setDisplayMode(o.getDisplayMode()),o.hasInit||(o.getEventManager().fireEvent(a.Loaded,o),o.hasInit=!0),o.getEventManager().fireEvent(a.AddDrawing,o),o.getEventManager().fireEvent(a.ViewChanged,o),s.callback&&s.callback(t);if((i?i.match(/\((.+?)\)/g):[]).length>0){const t=RegExp.$1.split(",");o.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}})),r.addEventListener(a.ViewZoomed,(function(){o.getEventManager().fireEvent(a.ViewZoomed,o)})),r.addEventListener(a.ZoomFactorChanged,(function(e){o.getEventManager().fireEvent(a.ZoomFactorChanged,e)})),r.addEventListener(a.MouseDragged,(function(e){o.getEventManager().fireEvent(a.MouseDragged,e)})),r.addEventListener(a.ContextMenu,(function(e){o.getEventManager().fireEvent(a.ContextMenu,e)})),r.addEventListener(a.SelectionChanged,(function(e){o.getEventManager().fireEvent(a.SelectionChanged,e)}))})),!0)},addDrawings:function(e,t){let i=e.slice(),n=i.shift(),o=n.id,s=t,r=this;null==o&&(o=Date.now());let a=this.addDrawing(n);var l=function(){let e=i.shift();if(e){let t=e.id;null==t&&(t=Date.now()),r.addDrawing(e)}else s&&s(r),r.removeEventListener("AddDrawing",l)};a||(a=!0,l()),this.addEventListener("AddDrawing",l)},getDrawingFrame(e,t){this.getDrawingById(e).viewerDrawing.getDrawingFrame((e=>{t&&t(e)}))},sync:function(){let e=this.sets,t=this.activeState;for(var i=0;i<e.length;i++)e[i].active||e[i].viewerDrawing.setState(t)},setNavigationMode:function(e){this.getActiveDrawing().viewerDrawing.setNavigationMode(e)},removeDrawing:function(e){if(null==e||null==e)return console.error("id is necessary!"),!1;let t=this.getDrawingById(e);t.active&&(1==this.sets.length?this.haveActiveDrawing=!1:this.setActiveDrawing(this.sets[this.sets[0].id==e?1:0].id)),t.wrap.remove(),this.sets.removeObjectByAttribute("id",e),this.getEventManager().fireEvent(s.ViewChanged,self)},rectZoom:function(){this._state.rectZoom=!0,this.getActiveDrawing().viewerDrawing.rectZoom()},enableFullScreen:function(t){var i=this.getRootElement();t?e.Web.Lang.Utility.FullScreen.fullScreen(i):e.Web.Lang.Utility.FullScreen.exitFullScreen();let n=this;setTimeout((()=>{n.getActiveDrawing().viewerDrawing.resize()}),500)},getCurrentState:function(){let e=[],t=this.sets;for(var i=0;i<t.length;i++){let{id:n,active:o,visible:s,viewerDrawing:r}=t[i],a=this.getOffsetDistance(n),l={id:n,active:o,visible:s,alignState:r.getAlignState(),allState:r.getCurrentState(),translate:a};e.push(l)}return e},setCurrentState:function(e){let t=this.sets;for(var i=0;i<t.length;i++){let{id:n,active:o,visible:s,viewerDrawing:r}=t[i],a=e.getObjectByAttribute("id",n);a&&(a.visible!=s&&(a.visible?this.showDrawing(n):this.hideDrawing(n)),a.active&&!o&&this.setActiveDrawing(n),a.alignState&&r.setAlignState(a.alignState),a.allState&&r.setState(a.allState))}},setModelTransformation(e,t){this.getDrawingById(e).viewerDrawing.setModelTransformation(t)},onMouseClick:function(e,t){t.id=e;let i=this.alignmentPoints,n=this.getSelectDrawing(),o=n.viewerDrawing.getViewer();if(this.isAlignment){if(this.selectId){let e=o.toModelWorld([t.clientPosition.x,t.clientPosition.y]);this.alignmentPoints.push({x:e[0],y:e[1]})}else this.alignmentPoints.push(t.worldPosition);if(1==i.length){let e=o,n=e.snapToPoint(t.clientPosition.x,t.clientPosition.y),s=n.GetPoint();if(0!=n.GetID())i[0]={x:s[0],y:s[1]};else{let n=this.verify([t.clientPosition.x,t.clientPosition.y]);if(n){let t=e.toModelWorld(n).slice(0,2);i[0]={x:t[0],y:t[1]}}}}else if(2==i.length){let e=o;"capture"!=e.mouseEditorMgr.editors[0].name&&n.viewerDrawing.setNavigationMode("capture");let s=this.verify([t.clientPosition.x,t.clientPosition.y]);if(s){let t=e.toModelWorld(s).slice(0,2);i[1]={x:t[0],y:t[1]}}this.moveDrawing(n.id,[i[1].x-i[0].x,i[1].y-i[0].y]),this.alignmentPoints=[]}}else if(this.snapping){var r=o.snapToPoint(t.clientPosition.x,t.clientPosition.y);if(0!=r.GetID()){var a=r.GetSnapType(),l={x:r.GetPoint()[0],y:r.GetPoint()[1]},h=o.toScreenPoint([l.x,l.y]),c={x:h[0],y:h[1]};t.snapPoint={type:a,clientPosition:c,worldPosition:l}}else this.tempSnapPoint&&(t.snapPoint={type:this.tempSnapPoint.type,clientPosition:{x:this.tempSnapPoint.screenPoint[0],y:this.tempSnapPoint.screenPoint[1]},worldPosition:{x:this.tempSnapPoint.worldPoint[0],y:this.tempSnapPoint.worldPoint[1]}})}this.getEventManager().fireEvent(s.MouseClicked,t)},convertCoordinates(e,t,i){let n=this.getDrawingById(e),o=this.getDrawingById(t),s=n.viewerDrawing.worldToClient({x:i[0],y:i[1]});return o.viewerDrawing.clientToWorld(s)},showDrawing(e){let t=this.getDrawingById(e);t.wrap.setCss({display:"block"}),t.visible=!0},hideDrawing(e){let t=this.getDrawingById(e);t.active?console.log("can't hide active drawing"):(t.wrap.setCss({display:"none"}),t.visible=!1)},moveDrawing(e,t){let i=this.getDrawingById(e);i.viewerDrawing.getViewer().alignDrawing([0,0],[t[0],t[1]]),i.viewerDrawing.update(!0)},startMoving(){let e=this;this.isAlignment=!0,this.alignmentPoints=[];let t=this.getActiveDrawing(),i=t.viewerDrawing.getViewer();const n=this.getDisplayMode();i.displayModeBeofreMoving=n;const o=e.getRootElement().style.backgroundColor;i.oldBackgoundColorBeforeMoving=o,t.viewerDrawing.setNavigationMode("capture"),i.mouseEditorMgr.editors[0].setIsOnlySnap(!1),i.mouseEditorMgr.editors[0].captureFail=function(t,i,n){return e.verify(t,i,n,!0),!1},this.enterMode(!0)},render(){this.getActiveDrawing().viewerDrawing.render()},enableSnap(e){let t=this,i=this.getActiveDrawing(),n=i.viewerDrawing.getViewer();this.snapping=e,e?(i.viewerDrawing.setNavigationMode("capture"),n.mouseEditorMgr.editors[0].setIsOnlySnap(!0),n.mouseEditorMgr.editors[0].captureFail=function(e,i,n){return t.verify(e,i,n,!0,!0),!1}):i.viewerDrawing.setNavigationMode("pick")},setSnapMode(e){let t=this.getActiveDrawing().viewerDrawing;this.snapMode=e,t.getViewer().setSnapMode(e)},enterMode(t){let i;i=t?this.getSelectDrawing():this.getActiveDrawing();for(var n=this.sets,o=0;o<n.length;o++)if(n[o].id!=i.id)n[o].viewerDrawing.setPrintMode("Custom"),n[o].viewerDrawing.setGlobalColor(new e.Web.Graphics.Color("#7D888A"));else if(t)n[o].viewerDrawing.setPrintMode("Custom"),0==this._displayMode?n[o].viewerDrawing.setGlobalColor(new e.Web.Graphics.Color("#ffffff")):n[o].viewerDrawing.setGlobalColor(new e.Web.Graphics.Color("#000000"));else{n[o].viewerDrawing.setPrintMode(["Normal","White","Black","Custom"][this._displayMode])}},selectDrawing(e){this.selectId=e,this.enterMode(!0)},verify(e,t,i,n,o){let s=function(e,t){if(!e)return!1;if(!t)return!0;let i=e.GetSnapTypeName();return t.snapList.includes({PointOnLine:"line",Intersection:"intersection",MiddlePoint:"midpoint",EndPoint:"endpoint"}[i])};if(!e)return;let r=this.sets,a=null,l=this.getActiveDrawing().id,h=n?l:this.selectId||l;for(var c=0;c<r.length;c++)if(r[c].id!=h){let n=r[c].viewerDrawing.getViewer(),o=n.snapToPoint(e[0],e[1]),l=o.GetPoint(),h=o.GetID();if(0!=h){let r=o.GetSnapTypeName();if(!s(o,this.snapMode))continue;let c=this.getActiveDrawing().viewerDrawing.getViewer();return e=n.toScreenPoint(l),c.mouseEditorMgr.editors[0].drawTmpPoint(t,i,e,r),this.tempSnapPoint={worldPoint:l,id:h,screenPoint:e,type:r},a=e,a}}return this.tempSnapPoint=null,a},getSelectDrawing(){return this.selectId?this.getDrawingById(this.selectId):this.getActiveDrawing()},getViews(e){const t=this.getDrawingById(e);return!!t&&t.viewerDrawing.getViews()},endMoving(){this.isAlignment=!1,this.selectId=null;let t=this.getActiveDrawing();t.viewerDrawing.setNavigationMode("pick"),this.enterMode(!1);const i=t.viewerDrawing.getViewer().displayModeBeofreMoving;this.setDisplayMode(i);if((t.viewerDrawing.getViewer().oldBackgoundColorBeforeMoving?t.viewerDrawing.getViewer().oldBackgoundColorBeforeMoving.match(/\((.+?)\)/g):[]).length>0){const t=RegExp.$1.split(",");this.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}delete t.viewerDrawing.getViewer().displayModeBeofreMoving,delete t.viewerDrawing.getViewer().oldBackgoundColorBeforeMoving},createWrap:function(e){var t=o.create("div",this.rootElement.id+e);return this.rootElement.appendChild(t),t},getOffsetDistance:function(e){return this.getDrawingById(e).viewerDrawing.getViewer().getAlignTranslate()},setActiveDrawing:function(e,t){if(null==e||null==e)return console.error("id is necessary!"),!1;let i=this.sets.getObjectByAttribute("active",!0);if(i&&i.id==e)return;i&&(i.active=!1,i.wrap.setCss({"z-index":0}),i.viewerDrawing.clearSelection());let n=this.getDrawingById(e);n.active=!0,n.wrap.setCss({"z-index":5});let o=this.getRootElement().querySelector(".bf-drawable-context");o&&n.wrap.querySelector(".bf-drawing-container ").appendChild(o),t||this.setDisplayMode(this.getDisplayMode()),this.getEventManager().fireEvent(s.ActiveViewChanged,this),this.snapping&&this.enableSnap(!0)},getActiveDrawing:function(){return this.sets.getObjectByAttribute("active",!0)},getDrawingById:function(e){if(null==e||null==e)return console.error("id is necessary!"),!1;return this.sets.getObjectByAttribute("id",e)},createSnapshotAsync(e,t){let i,n=document.createElement("canvas"),o=this.getRootElement();n.width=o.clientWidth,n.height=o.clientHeight,e&&(e=`rgba(${e.red},${e.green},${e.blue},${e.alpha})`);var s=n.getContext("2d");s.beginPath(),s.fillStyle=e||o.style.background,s.fillRect(0,0,n.width,n.height),this.sets.reverse().forEach((e=>{if(e.active)i=e.viewerDrawing.getViewer().snapshotPure();else{let t=e.viewerDrawing.getViewer().snapshotPure();s.drawImage(t,0,0)}})),s.drawImage(i,0,0),t(n.toDataURL())},showLineWidth(e){this.sets.forEach((t=>{t.viewerDrawing.showLineWidth(e)}))},getBBox(e){let t=this.sets.getObjectByAttribute("id",e).viewerDrawing.getViewer().getModelBBox(),i=t.GetMinPt(),n=t.GetMaxPt();return{min:i.slice(0,2),max:n.slice(0,2)}},zoomToBoundingBox:function(e,t=.5){this.getActiveDrawing().viewerDrawing.zoomToBoundingBox(e,t)},home(){let e,t,i,n=this.sets;for(var o=0;o<n.length;o++){let{id:s,active:r,viewerDrawing:a}=n[o],l=this.getOffsetDistance(s),h=this.getBBox(s);r&&(i=a),e?(e=[Math.min(h.min[0]+l[0],e[0]),Math.min(h.min[1]+l[1],e[1])],t=[Math.max(h.max[0]+l[0],t[0]),Math.max(h.max[1]+l[1],t[1])]):(e=[h.min[0]+l[0],h.min[1]+l[1]],t=[h.max[0]+l[0],h.max[1]+l[1]])}i.getViewer().zoomToWorldBox([e[0],e[1],0],[t[0],t[1],0],1),i.update(),this.activeState=i.getCurrentState(),this.sync(),this.getEventManager().fireEvent(s.Rendered,self)},setOpacityByIds:function(e,t){e.forEach((e=>{this.getDrawingById(e).viewerDrawing.setGlobalOpacity(t)}))},setBackgroundColor:function(e){this.getRootElement().setCss({background:e.getRGBA()}),3===this._displayMode&&(r[3]=e.getRGBA())},restoreBackgroundColor:function(){3===this._displayMode&&(r[3]=r[0]),this.getRootElement().setCss({background:r[this._displayMode]})},setDisplayMode:function(t){t=t||0,this.sets.forEach((i=>{"2"==i.viewerDrawing.version&&i.viewerDrawing.getViewer().enableReplaceElementColor(!1),i.active?i.viewerDrawing.setDisplayMode(t):0==t?(i.viewerDrawing.setPrintMode("Custom"),i.viewerDrawing.setGlobalColor(new e.Web.Graphics.Color("#7D888A"))):4==t?i.viewerDrawing.setPrintMode("Normal"):(i.viewerDrawing.setPrintMode("Custom"),i.viewerDrawing.setGlobalColor(new e.Web.Graphics.Color("#778BA3")))})),this.getRootElement().setCss({background:r[t]}),this._displayMode=t},getDisplayMode:function(){return this._displayMode},getViewMetaData:function(t,i){var n=this;let o=e.Bimface.Authentication.AuthenticationManager,s=new e.Bimface.Authentication.AuthenticationConfig;s.viewToken=t,s.APIHost=this._viewConfig.APIHost,(this.authenticate=new o(s)).authenticate((function(e){e.drawingUrl=`${n._viewConfig.resourceHost}/${e.databagId}/resource/drawing`,i(e)}))},getIndexJson:function(t,i){e.Web.Lang.Utility.HttpRequest.ajax({url:`${t}/index.json${this.offline?".gz":""}`,success:function(e){var t=JSON.parse(e);t&&i(t)}})},getExternalReferences:function(t,i,n){const o=e.Web.Lang.Utility.HttpRequest,s=this.getDrawingById(t);if(!s)return!1;const r=s.viewerDrawing.authenticate&&s.viewerDrawing.authenticate.data.databagId,a=`${this._viewConfig.resourceHost}/${r}/resource/drawing/reference.json`;o.ajax({url:`${a}`,success:function(e){var t=JSON.parse(e);t&&i&&i(t.references)},failure:function(e){n&&n(e)}})},getManifest:function(t){let i=e.Web.Lang.Utility.HttpRequest,n=`${this._viewConfig.resourceHost}/${this._databagId}/manifest.json`;i.ajax({url:`${n}`,success:function(e){var i=JSON.parse(e);i&&t(i)},failure:function(e){t(e)}})},enableViewport:function(e){this.getActiveDrawing().viewerDrawing.enableViewport(e)},getSelectedElements:function(){return this.getActiveDrawing().viewerDrawing.getSelectedElements()}}),t.ViewerDrawingSet=h}(),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:c.resourceHost,onCameraChanged:null,inMoveOnAxisGrid:null}},w=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),v=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),(y=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 b.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,v.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}}),v.ajax({async:!1,url:`${t.host}/${t.viewer._data.databagId}/metadata/levels.json`,success:function(e){i.Levels=JSON.parse(e).levels}}),v.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})}},w.MiniMap=y,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:c.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}();
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var x=function(e,t){return(x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function E(e,t){function i(){this.constructor=e}x(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var C,M=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}(),P=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);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 c=Math.round(o.x-h.x),d=Math.round(o.y-h.y);return{position:o,abcName:l.abcName,numeralName:l.numeralName,offsetX:c,offsetY:d}}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),c=new THREE.Plane;if(c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),2!=s.length)return null;var d=s[0],u=s[1].clone().sub(d).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}(),I=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 E(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}(M),T=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 E(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}(M),D=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 E(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}(M),S=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return E(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new D(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}(M),B=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 P,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 E(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 I(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 c=t.points.map(n);e.add(new T(c,o,i))}}));var a=r.positions.map(n);e.add(new S(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,c=4*(i+4)*this.multiplyZoomFactor;a>r?(this.bIsShowAxisGrid&&(l=this.boxSize.x*e/(e-c)),h=l/r):a<r&&(this.bIsShowAxisGrid&&(h=this.boxSize.y*t/(t-c)),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,c=0;c<l;c++){n=(e=this.horizLineElements[c]).name,o=e.v1.clone(),s=e.v2.clone();for(var d=0;d<h;d++){i=(t=this.verticalLineElements[d]).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 I&&n.isMatch(e))return n}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(M),_=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 E(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}(M);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(C||(C={}));var k,A,L=function(){function e(){this.bIsMouseDown=!1,this.name=C.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"}(k||(k={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(A||(A={}));var V,R=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"}(V||(V={}));var O=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=C.Zoom_Editor,n.eventManager=i,n.vfData=t.getData(),n.vfViewer=t,n}return E(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&&N.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=[],c=this.vfData.getCorner("Virtual","LB");c[0]-=o.x,c[1]-=o.y,h.push(c[0]*l+o.x),h.push(c[1]*l+o.y),this.vfData.setZoomFactor(s);var d=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(u),r=h[0]-d[0],a=h[1]-d[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}N.panOffsetX+=r,N.panOffsetY+=a,N.panOffsetXForCamera+=r,N.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:k.ZOOM_MOUSE_WHEEL,data:{offsetX:N.panOffsetX,offsetY:N.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,c=(o[1]-i.y)*n+i.y;this.vfData.setZoomFactor(e);var d=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(t),l[0]=h-d[0],l[1]=c-d[1];var u=0,g=0,p=this.vfData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),c<p[1]&&(l[1]+=p[1]-c,g++),h=(s[0]-i.x)*n+i.x,c=(s[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","LT");h>f[0]&&0==u&&(l[0]+=f[0]-h,u++),c>f[1]&&0==g&&(l[1]+=f[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var m=this.vfData.getCorner("Origin","RT");h<m[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(a[0]-i.x)*n+i.x,c=(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++),c<w[1]&&0==g&&(l[1]+=w[1]-c,g++),l},t.prototype.enableMode=function(e){if(e==V.Min)this.zoomFactors=this.totalZoomFactors;else if(e==V.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}(L),N=function(e){function t(i,n){var o=e.call(this)||this;return o.name=C.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 E(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:k.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");O.offsetXForZoomAndPan=e[0]-t[0],O.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(L),H=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.build(),t}return E(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),N.panOffsetXForCamera=0,N.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}(M),z=function(){function e(e){this.resourceGrids=e,this.floorPlaneBox=new THREE.Box2}return e.prototype.get=function(){return this.resourceGrids},e}(),W=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;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){for(var t=this.resourceLevels,i=0;i<t.length;i++){var n=t[i];if(n.id==e)return n.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}(),U=function(){function e(e){this.resourcePlanes=e}return e.prototype.find=function(e){for(var t=0;t<this.resourcePlanes.length;t++){var i=this.resourcePlanes[t];if(i.id==e)return i}},e.prototype.getFloorPlaneBox=function(e){var t=this.find(e);return t?t.boundingBox||t.BoundingBox:void 0},e.prototype.getUrl=function(e){var t=this.find(e);return t?t.path||t.Path:void 0},e.prototype.getElevation=function(e){var t=this.find(e);return t?t.Elevation:void 0},e.prototype.getName=function(e){var t=this.find(e);return t?t.name||t.Name:void 0},e}(),F=function(e){function t(t,i){var n=e.call(this)||this;return n.radius=t,n.material=i,n.build(),n}return E(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}(M),G=function(e){function t(){var t=e.call(this)||this;return t.tipNodeBackgroundColor="#fff",t.tipNodeColor="#000",t.initialize(),t.build(),t}return E(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}(M),j=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 P,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 z(e.Grids),this.dataLevels=new W(e.Levels)},e.prototype.setPlanes=function(e){this.dataFloorPlanes=new U(e)},e.prototype.setFloorPlaneId=function(e){this.floorPlaneId=e,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),t=this.dataFloorPlanes.getName(this.floorPlaneId),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 B(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 H;var t=this.getOriginSize();this.cameraNode.setPanelSize(t),this.drawableItems.push(this.cameraNode)}this.intersectPoint=new F(3),this.drawableItems.push(this.intersectPoint),this.tipNode=new G,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 _(this.dataFloorPlanes.getUrl(this.floorPlaneId),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 H)return i}},e.prototype.getElevationById=function(){return this.dataLevels.getElevation(this.floorPlaneId)},e.prototype.updateMovement=function(){this.getFloorPlaneNode().move(N.panOffsetX,N.panOffsetY);var e=this.getAxisGridNode();e&&e.move(N.panOffsetX,N.panOffsetY);var t=this.getCameraNode();t.move(N.panOffsetXForCamera,N.panOffsetYForCamera),t.rotate()},e.prototype.getCorner=function(e,t){var i=[],n=[];"Origin"==e?(i=[0,0],n=this.getOriginSize()):"Virtual"==e&&(i=[N.panOffsetX,N.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}(),$=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 P,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:k.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:k.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(){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),r=new THREE.Matrix4;r.copy(s).invert();var a=this.viewerFloorData.getFloorPlaneBox();a.getCenter(this.bBoxCenter);var l=new THREE.Vector3(a.min.x,a.min.y,this.bBoxCenter.z).applyMatrix4(s),h=new THREE.Vector3(a.min.x,a.max.y,this.bBoxCenter.z).applyMatrix4(s),c=new THREE.Vector3(a.max.x,a.min.y,this.bBoxCenter.z).applyMatrix4(s),d=new THREE.Plane;d.setFromCoplanarPoints(l,h,c),d.projectPoint(n,this.projectedCameraPosition),this.projectedCameraPosition.applyMatrix4(r),d.projectPoint(o,this.projectedTargetPosition),this.projectedTargetPosition.applyMatrix4(r);var u=this.projectedTargetPosition.clone().sub(this.projectedCameraPosition);u.z=0,u.normalize();var g=n.clone();g.applyMatrix4(r);var p=g.clone(),f=this.viewerFloorData.getSize(),m={width:f[0]/2,height:f[1]/2},w=this.viewerFloorData.getAxisGridBox2D();this.algorithm.worldToNormalizedPoint(p,w),this.algorithm.normalizedPointToScreen(p,m);var v=this.viewerFloorData.getCameraNode();if(v.setOpacity("1.0"),u.length()<1e-5)v.setCameraArrowOpacity("0.0"),v.setOffsetAndRotate(p.x+N.panOffsetX,p.y+N.panOffsetY,0);else{var y=new THREE.Vector3(0,0,1),b=new THREE.Vector3(1,0,0),x=this.algorithm.isAngleGreaterThanPi(b,u,y),E=THREE.Math.radToDeg(b.angleTo(u));x||(E*=-1),v.setBigCamera(),v.setOffsetAndRotate(p.x+N.panOffsetX,p.y+N.panOffsetY,E),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 G?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}(),X=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}(),Y=function(e){function t(t,i){var n=e.call(this)||this;return n.name=C.PICK_Editor,n.vfViewer=t,n.vfData=t.getData(),n.algorithm=new P,n.highlightControl=new X(n.vfData),n.cameraProjectedPosZ=t.getManHeight(),n.mapClickMode="default",n.lastMousePoint=new THREE.Vector2,n.eventManager=i,n.bIsEnableHover=!0,n}return E(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+=O.offsetXForZoomAndPan,t.y+=+O.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,N.panOffsetX,N.panOffsetY)}}},t.prototype.onMouseUp=function(e){this.bIsMouseDown=!1,this.lastMousePoint.x===e.clientX&&this.lastMousePoint.y===e.clientY&&this.locateByClientPoint(e.clientX+O.offsetXForZoomAndPan,e.clientY+O.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 c=new THREE.Vector2(h.intersectionPoint.x,h.intersectionPoint.y);if(l.sub(c).lengthSq()<9){var d=c.clone(),u={width:s[0]/2,height:s[1]/2};this.algorithm.screenToNormalizedPoint(d,u),this.algorithm.normalizedPointToWorld(d,a),n.set(d.x,d.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:k.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:k.PICK_MOUSE_UP,data:g}),!0}console.warn("Click point out of boundary.")},t.prototype.setClickMode=function(e){this.mapClickMode=e},t}(L),Z=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(k.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})),this.eventManager.addEventListener(k.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:k.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),c=String(i[2*l]-r/2),d=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",c),s.setAttribute("y1",d),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:k.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 c=[t[i],t[i+1]];n=this.isPointInCircle(e,c,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,c=i+(o-i)*h,d=n+(s-n)*h;return Math.sqrt((e-c)*(e-c)+(d-t)*(d-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}(),q=function(e){function t(t,i){var n=e.call(this)||this;return n.name=C.RECTPICK_Editor,n.eventManager=i,n.viewerFloorData=t.getData(),n.naviAction=new Z(t),n.vfViewer=t,n.algorithm=new P,n}return E(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:k.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]+O.offsetXForZoomAndPan,y:e[1]+O.offsetYForZoomAndPan},i={x:e[2]+O.offsetXForZoomAndPan,y:e[3]+O.offsetYForZoomAndPan},n=this.algorithm.getCuttingBoxOnCanvas(t,i,this.viewerFloorData.getSize(),this.viewerFloorData.getAxisGridBox2D()),o=this.viewerFloorData.getFloorPlaneBox();return n.min.z=o.min.z,n.max.z=o.max.z,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}),P.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+=O.offsetXForZoomAndPan,i.y+=O.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-O.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+a.left,t.clientY=r.intersectionPoint.y-O.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+a.top}return t},t}(L),K=function(){function e(e,t,i){this.eventManager=new R,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(C.PICK_Editor),this.enableEditor(C.PAN_Editor),this.enableEditor(C.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()==C.PICK_Editor&&e.button!=A.Left||(n.getName()==C.RECTPICK_Editor&&e.button!=A.Left||n.getName()==C.PAN_Editor&&e.button==A.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()==C.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()==C.PICK_Editor&&e.button!=A.Left||(n.getName()==C.RECTPICK_Editor&&e.button!=A.Left||n.getName()==C.PAN_Editor&&e.button==A.Left||n.onMouseUp(e))}},e.prototype.onMouseWheel=function(e){var t=this.find(C.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(C.RECTPICK_Editor);e instanceof q&&e.clear()},e.prototype.clearZoomAndPan=function(){N.clear(),O.clear(),this.viewerFloorData.setZoomFactor(1);var e=this.find(C.Zoom_Editor);e instanceof O&&e.setZoonIndex(0)},e.prototype.getBoundingBoxIsolate=function(){var e=this.find(C.RECTPICK_Editor);if(e instanceof q)return e.getBoundingBoxIsolate()},e.prototype.setMapClickMode=function(e){var t=this.find(C.PICK_Editor);t instanceof Y&&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 C.PICK_Editor:t.push(new Y(this.vfViewer,this.eventManager));break;case C.RECTPICK_Editor:t.push(new q(this.vfViewer,this.eventManager));break;case C.PAN_Editor:t.push(new N(this.vfViewer,this.eventManager));break;case C.Zoom_Editor:t.push(new O(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(C.Zoom_Editor);t instanceof O&&t.enableMode(e)},e.prototype.setZoomFactors=function(e){var t=this.find(C.Zoom_Editor);t instanceof O&&t.setZoomFactors(e)},e}(),J=function(){function e(e,t){this.vfData=new j,this.vfView=new $(e,t,this.vfData),this.bIsEnableFloorPlaneChangedEvent=!0;var i=this.getMapContainer();this.vfEditor=new K(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){this.vfData.setFloorPlaneId(e);var t=this.vfData.getProperZoomFactors();this.vfEditor.setZoomFactors(t),N.clear(),this.bIsEnableFloorPlaneChangedEvent&&this.vfEditor.getEventManager().dispatchEvent({type:k.Floor_Plane_Changed,elevation:this.vfData.getElevationById()}),this.vfEditor.getEventManager().dispatchEvent({type:k.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(V.Max),this.vfEditor.enableEditor(C.RECTPICK_Editor),this.vfEditor.enablePickHover(!0)):(this.clearRectPick(),this.vfEditor.setZoomMode(V.Min),this.vfEditor.disableEditor(C.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(){this.vfView.updateCameraNode()},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())},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:N.panOffsetX,y:N.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=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),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;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 J(s,n.domElement),i.viewerFloor.registerCameraHeightChanged(b.EVENTS.ON_CAMERA_HEIGHT_CHANGED),i._helper=this,i._useEngineMap=n.viewer._opt.enableRealisticMiniMap,i.renderCB=function(){i._inited&&i.viewerFloor.renderCameraNode()},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)})),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":"")]((e=>{s=[...e.floors,...s],r=e.axisGrid.Grids?[...e.axisGrid.Grids,...r]:r,a=e.axisGrid.Levels?[...e.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=(l=this).getEventManager(),o=e.Bimface.Plugins.Map.MapEvents,s=l._opt;let r=this.EventType;if(this.viewerFloor.addEventListener(r.PICK_MOUSE_UP,(function(e){n.fireEvent(o.MouseClicked,e.data)})),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){l.viewerFloor.enableFloorPlaneChangedEvent(!1),l.showFloorById(e.id),l.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,o=s.viewer.sceneToWorld(i.position.clone()),r=new THREE.Vector3(o.x,o.y,n+l._manHeight);const h=t.getBoundingBoxWorld();r.z=Math.min(r.z,h.max.z);var a=s.viewer.worldToScene(r);t.cameraControl.flyToPointWithParallelEye(new THREE.Vector3(a.x,a.y,a.z))}})),l.viewerFloor.enableFloorPlaneChangedEvent(!1),l._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 s=t.viewerFloor.vfData.getDataFloorPlanes().getFloorPlaneBox(o[e].id);let a=new THREE.Box3(new THREE.Vector3(s.Min.X,s.Min.Y,s.Min.Z),new THREE.Vector3(s.Max.X,s.Max.Y,s.Max.Z));a.applyMatrix4(i.getScene().getMatrixGlobal()),r.boundingbox.push(a),r.height.push(n.elevation)}}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 a=e.getObjectByAttribute("name",this.defaultFloorPlane);0==a?this.showFloorById(e[0].id):this.showFloorById(a.id)}l.viewerFloor.enableFloorPlaneChangedEvent(!0),l._inited=!0}else{var l;(l=this).viewerFloor.setFlip(!0);const t=s.viewer,i=t.getViewer().getBoundingBoxWorld(),n={Min:i.min,Max:i.max};l.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};l.viewerFloor.setAxisGridData(r);let a=[];a.push({id:o,name:o,path:e,BoundingBox:n}),l._floors=a,l.viewerFloor.setPlanes(a),l.showFloorById(o),l._inited=!0},a={};a.maxPixel=l._opt.maxPixel,a.spacing=l._refreshHeight,a.successCallback=r,l.mapManager.removeCreateMapEvent(),l.mapManager.createMapByCamera(a),t.getViewer().getModelManager().dispatchEvent({type:b.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){this.viewerFloor.setFloorPlaneId(e),this.viewerFloor.destroy(),this.viewerFloor.rebuildData(),this.viewerFloor.render()},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,mapViewer: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"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap").MapViewerEvent=t}();
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var Q=function(e,t){return(Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function ee(e,t){function i(){this.constructor=e}Q(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var te,ie=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}(),ne=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);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 c=Math.round(o.x-h.x),d=Math.round(o.y-h.y);return{position:o,abcName:l.abcName,numeralName:l.numeralName,offsetX:c,offsetY:d}}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),c=new THREE.Plane;if(c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,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),c.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(c,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),2!=s.length)return null;var d=s[0],u=s[1].clone().sub(d).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}(),oe=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 ee(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}(ie),se=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 ee(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}(ie),re=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 ee(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}(ie),ae=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return ee(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new re(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}(ie),le=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 ne,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 ee(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 oe(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 c=t.points.map(n);e.add(new se(c,o,i))}}));var a=r.positions.map(n);e.add(new ae(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,c=4*(i+4)*this.multiplyZoomFactor;a>r?(this.bIsShowAxisGrid&&(l=this.boxSize.x*e/(e-c)),h=l/r):a<r&&(this.bIsShowAxisGrid&&(h=this.boxSize.y*t/(t-c)),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,c=0;c<l;c++){n=(e=this.horizLineElements[c]).name,o=e.v1.clone(),s=e.v2.clone();for(var d=0;d<h;d++){i=(t=this.verticalLineElements[d]).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 oe&&n.isMatch(e))return n}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(ie),he=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 ee(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}(ie);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(te||(te={}));var ce,de,ue,ge=function(){function e(){this.bIsMouseDown=!1,this.name=te.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"}(ce||(ce={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(de||(de={})),function(e){e.Min="Min",e.Max="Max"}(ue||(ue={}));var pe,fe=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=te.Zoom_Editor,n.eventManager=i,n.vfData=t.getData(),n.vfViewer=t,n}return ee(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&&me.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=[],c=this.vfData.getCorner("Virtual","LB");c[0]-=o.x,c[1]-=o.y,h.push(c[0]*l+o.x),h.push(c[1]*l+o.y),this.vfData.setZoomFactor(s);var d=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(u),r=h[0]-d[0],a=h[1]-d[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}me.panOffsetX+=r,me.panOffsetY+=a,me.panOffsetXForCamera+=r,me.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:ce.ZOOM_MOUSE_WHEEL,data:{offsetX:me.panOffsetX,offsetY:me.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,c=(o[1]-i.y)*n+i.y;this.vfData.setZoomFactor(e);var d=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(t),l[0]=h-d[0],l[1]=c-d[1];var u=0,g=0,p=this.vfData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),c<p[1]&&(l[1]+=p[1]-c,g++),h=(s[0]-i.x)*n+i.x,c=(s[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","LT");h>f[0]&&0==u&&(l[0]+=f[0]-h,u++),c>f[1]&&0==g&&(l[1]+=f[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var m=this.vfData.getCorner("Origin","RT");h<m[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(a[0]-i.x)*n+i.x,c=(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++),c<w[1]&&0==g&&(l[1]+=w[1]-c,g++),l},t.prototype.enableMode=function(e){if(e==ue.Min)this.zoomFactors=this.totalZoomFactors;else if(e==ue.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}(ge),me=function(e){function t(i,n){var o=e.call(this)||this;return o.name=te.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 ee(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:ce.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");fe.offsetXForZoomAndPan=e[0]-t[0],fe.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(ge),we=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.build(),t}return ee(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),me.panOffsetXForCamera=0,me.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}(ie),ve=function(){function e(e){this.resourcePlanes=e}return e.prototype.find=function(e){for(var t=0;t<this.resourcePlanes.length;t++){var i=this.resourcePlanes[t];if(i.id==e)return i}},e.prototype.getFloorPlaneBox=function(e){var t=this.find(e);return t?t.boundingBox||t.BoundingBox:void 0},e.prototype.getUrl=function(e){var t=this.find(e);return t?t.path||t.Path:void 0},e.prototype.getElevation=function(e){var t=this.find(e);return t?t.Elevation:void 0},e.prototype.getName=function(e){var t=this.find(e);return t?t.name||t.Name:void 0},e}(),ye=function(e){function t(){return e.call(this)||this}return ee(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}(ne),be=function(){function e(e,t){this.point2D=new THREE.Vector2;var i=e[0],n=e[1],o=t[0],s=t[1],r=n.clone().sub(i).length()/s.clone().sub(o).length();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),c=(new THREE.Matrix3).scale(r,r);this.mapToModelMatrix=l.clone().multiply(c).multiply(h).multiply(a);var d=(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=d.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}(),xe=function(e){function t(t,i){var n=e.call(this)||this;return n.radius=t,n.material=i,n.build(),n}return ee(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}(ie);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(pe||(pe={}));var Ee,Ce,Me=function(){function e(){this.bIsMouseDown=!1,this.name=pe.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"}(Ee||(Ee={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(Ce||(Ce={}));var Pe,Ie=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"}(Pe||(Pe={}));var Te=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=pe.Zoom_Editor,n.eventManager=i,n.nmData=t.getData(),n.nmViewer=t,n}return ee(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&&De.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 c=a/(p=this.zoomFactors[this.currentIdx-1]),d=[],u=this.nmData.getCorner("Virtual","LB");u[0]-=r.x,u[1]-=r.y,d.push(u[0]*c+r.x),d.push(u[1]*c+r.y),this.nmData.setZoomFactor(a);var g=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(p),l=d[0]-g[0],h=d[1]-g[1]}else{var p=this.zoomFactors[this.currentIdx+1],f=this.boundsChecking(a,p,r);l=f[0],h+=f[1]}De.panOffsetX+=l,De.panOffsetY+=h,De.panOffsetXForCamera+=l,De.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:Ee.ZOOM_MOUSE_WHEEL,data:{offsetX:De.panOffsetX,offsetY:De.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&&De.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(t){var l=s/(u=this.zoomFactors[this.currentIdx-1]),h=[],c=this.nmData.getCorner("Virtual","LB");c[0]-=o.x,c[1]-=o.y,h.push(c[0]*l+o.x),h.push(c[1]*l+o.y),this.nmData.setZoomFactor(s);var d=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(u),r=h[0]-d[0],a=h[1]-d[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}De.panOffsetX+=r,De.panOffsetY+=a,De.panOffsetXForCamera+=r,De.panOffsetYForCamera+=a,this.nmData.setZoomFactor(i),this.nmViewer.destroy(),this.nmData.destroy(),this.nmData.build(),this.nmViewer.update(),this.nmData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:Ee.ZOOM_MOUSE_WHEEL,data:{offsetX:De.panOffsetX,offsetY:De.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,c=(o[1]-i.y)*n+i.y;this.nmData.setZoomFactor(e);var d=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(t),l[0]=h-d[0],l[1]=c-d[1];var u=0,g=0,p=this.nmData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),c<p[1]&&(l[1]+=p[1]-c,g++),h=(s[0]-i.x)*n+i.x,c=(s[1]-i.y)*n+i.y;var f=this.nmData.getCorner("Origin","LT");h>f[0]&&0==u&&(l[0]+=f[0]-h,u++),c>f[1]&&0==g&&(l[1]+=f[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var m=this.nmData.getCorner("Origin","RT");h<m[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(a[0]-i.x)*n+i.x,c=(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++),c<w[1]&&0==g&&(l[1]+=w[1]-c,g++),l},t.prototype.enableMode=function(e){if(e==Pe.Min)this.zoomFactors=this.totalZoomFactors;else if(e==Pe.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}(Me),De=function(e){function t(i,n){var o=e.call(this)||this;return o.name=pe.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 ee(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){this.bIsMouseDown},t.prototype.onMouseUp=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:Ee.PAN_MOUSE_MOVE,data:{offsetX:t.panOffsetX,offsetY:t.panOffsetY,zoomFactor:this.nmData.getZoomFactor()}}),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");Te.offsetXForZoomAndPan=e[0]-t[0],Te.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(Me),Se=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 ye,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 ve(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 be(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 le(!1,this.getSize(),this.bIsShowAxisGrid,this.getZoomFactor()),this.buildFloorPlane(),this.bIsShowCameraNode){this.cameraNode=new we;var e=this.getOriginSize();this.cameraNode.setPanelSize(e),this.drawableItems.push(this.cameraNode)}this.intersectPoint=new xe(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 he(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 we)return i}},e.prototype.updateMovement=function(){var e=this.getFloorPlaneNode();this.imgPosition=e.move(De.panOffsetX,De.panOffsetY);var t=this.getAxisGridNode();t&&t.move(De.panOffsetX,De.panOffsetY);var i=this.getCameraNode();i.move(De.panOffsetXForCamera,De.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=[De.panOffsetX,De.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}(),Be=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 ye,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,i=(this.viewer.getScene().getMatrixGlobal(),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:Ee.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),c=new THREE.Vector3(r.max.x,r.min.y,this.bBoxCenter.z).applyMatrix4(s),d=new THREE.Plane;d.setFromCoplanarPoints(l,h,c),d.projectPoint(n,this.projectedCameraPosition),this.projectedCameraPosition.applyMatrix4(this.inverseMatrix),d.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(),f=this.navigationMapData.getCameraNode();if(f){var m=this.navigationMapData.getImageSize(),w={width:m[0]/2,height:m[1]/2};this.navigationMapData.getAxisGridBox2D();if(this.getData().worldToNormalizedPoint(p),this.algorithm.normalizedPointToScreen(p,w),f.setOpacity("1.0"),u.length()<1e-5)f.setCameraArrowOpacity("0.0"),f.setOffsetAndRotate(p.x+De.panOffsetX,p.y+De.panOffsetY,0);else{var v=new THREE.Vector3(0,0,1),y=new THREE.Vector3(1,0,0);this.rotateMatrix.identity(),this.rotateMatrix.rotate(this.navigationMapData.getRotateAngle()),u.applyMatrix3(this.rotateMatrix);var b=this.algorithm.isAngleGreaterThanPi(y,u,v),x=THREE.Math.radToDeg(y.angleTo(u));b||(x*=-1),f.setBigCamera(),f.setOffsetAndRotate(p.x+De.panOffsetX,p.y+De.panOffsetY,x),f.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}(),_e=function(e){function t(t,i){var n=e.call(this)||this;return n.name=pe.PICK_Editor,n.nmViewer=t,n.nmData=t.getData(),n.algorithm=new ye,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 ee(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+Te.offsetXForZoomAndPan,e.clientY+Te.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 c=this.algorithm.normalizePointByZoomFactor(s,r,n,a);this.algorithm.normalizedPointToScreen(c,{width:r[0]/2,height:r[1]/2});var d=this.algorithm.getIntersectionToMinDistance(this.nmData.getIntersections(),c);if(d&&d.intersectionPoint){var u=new THREE.Vector2(d.intersectionPoint.x,d.intersectionPoint.y);if(c.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 f=o.clone(),m=this.nmData.getHeight();isNaN(m)||(f.z=m),this.nmData.updateMovement();var w=this.algorithm.getContainerOffsetToClient(s),v={x:i.clientX-w.left,y:i.clientY-w.top},y=this.nmData.getPicPosition(v);return this.eventManager.dispatchEvent({type:Ee.PICK_MOUSE_UP,data:{worldPosition:f.clone(),picPosition:y,clientPosition:v,screenPosition:{x:i.clientX,y:i.clientY}}}),this.algorithm.transformWorldPoint(this.nmViewer.getViewer(),f),this.algorithm.flyToPointWithParallelEye(this.nmViewer.getViewer(),f),!0}console.warn("Click point out of boundary.")},t}(Me),ke=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(Ee.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor),t.nmViewer.updateCameraNode()})),this.eventManager.addEventListener(Ee.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:Ee.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),c=String(i[2*l]-r/2),d=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",c),s.setAttribute("y1",d),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:Ee.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 c=[t[i],t[i+1]];n=this.isPointInCircle(e,c,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,c=i+(o-i)*h,d=n+(s-n)*h;return Math.sqrt((e-c)*(e-c)+(d-t)*(d-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}(),Ae=function(e){function t(t,i){var n=e.call(this)||this;return n.name=pe.RECTPICK_Editor,n.eventManager=i,n.nmData=t.getData(),n.naviAction=new ke(t),n.nmViewer=t,n.algorithm=new ye,n}return ee(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:Ee.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]+Te.offsetXForZoomAndPan,y:e[1]+Te.offsetYForZoomAndPan},i={x:e[2]+Te.offsetXForZoomAndPan,y:e[3]+Te.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}),ye.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+=Te.offsetXForZoomAndPan,i.y+=Te.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-Te.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+l.left,t.clientY=a.intersectionPoint.y-Te.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+l.top}return t},t}(Me),Le=function(){function e(e,t,i){this.eventManager=new Ie,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(pe.PICK_Editor),this.enableEditor(pe.Zoom_Editor),this.enableEditor(pe.PAN_Editor),this.enableEditor(pe.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(pe.Zoom_Editor);n&&n.scale(e,t,i)},e.prototype.onMouseWheel=function(e){var t=this.find(pe.Zoom_Editor);t&&t.onMouseWheel(e)},e.prototype.onContextmenu=function(e){e.preventDefault()},e.prototype.clearRectPick=function(){var e=this.find(pe.RECTPICK_Editor);e instanceof Ae&&e.clear()},e.prototype.getBoundingBoxIsolate=function(){var e=this.find(pe.RECTPICK_Editor);if(e instanceof Ae)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()==pe.PICK_Editor&&e.button!=Ce.Left||(n.getName()==pe.RECTPICK_Editor&&e.button!=Ce.Left||n.getName()==pe.PAN_Editor&&e.button==Ce.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()==pe.PICK_Editor&&e.button!=Ce.Left||(n.getName()==pe.RECTPICK_Editor&&e.button!=Ce.Left||n.getName()==pe.PAN_Editor&&e.button==Ce.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()==pe.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(){De.clear(),Te.clear(),this.navigationMapData.setZoomFactor(1);var e=this.find(pe.Zoom_Editor);e instanceof Te&&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 pe.PICK_Editor:t.push(new _e(this.nmViewer,this.eventManager));break;case pe.RECTPICK_Editor:t.push(new Ae(this.nmViewer,this.eventManager));break;case pe.PAN_Editor:t.push(new De(this.nmViewer,this.eventManager));break;case pe.Zoom_Editor:t.push(new Te(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(pe.Zoom_Editor);t instanceof Te&&t.enableMode(e)},e.prototype.setZoomFactors=function(e){var t=this.find(pe.Zoom_Editor);t instanceof Te&&t.setZoomFactors(e)},e}(),Ve=function(){function e(e,t,i){this.nmData=new Se,this.nmData.setSize(t.offsetWidth,t.offsetHeight),this.nmView=new Be(e,t,this.nmData),this.setAnchor(i);var n=this.getMapContainer();this.nmEditor=new Le(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),De.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(Pe.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:De.panOffsetX,y:De.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||!t.mapViewer)return console.log("viewer is not defined."),!1;t.domElement=t.mapViewer.domElement,this._opt=t,this.id=t.id,this.eventManager=t.mapViewer.eventManager,this.EventType={PICK_MOUSE_UP:2002,Camera_Height_Changed:5e3,ZOOM_MOUSE_WHEEL:6e3,NavigationMap_Rect_Changed:8e3,NavigationMap_Rect_Destroyed:80001};var i=t.viewer.getViewer();switch(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.MapViewerEvent;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);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 Ve(this.viewer,this.mapContainer,h),this.navigationMap.registerCameraHeightChanged(b.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;n.successCallback=i=>{const o=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 c=n.maxPixel,d=n.maxPixel;h>1?d/=h:c/=h;const u={modelAnchors:a,mapAnchors:{point1:new THREE.Vector2(0,d),point2:new THREE.Vector2(c,0)},url:i,domElement:e.domElement,isProfile:e.isProfile};this.associateModel(u),t&&t()},this.cloudMapManager.removeCreateMapEvent(),this.cloudMapManager.createMapByHeight(n)}setProfileAutoHeight(e,t,i){let n={maxPixel:800};n.successCallback=i=>{const o=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 c=n.maxPixel,d=n.maxPixel;h>1?d/=h:c/=h;const u={modelAnchors:a,mapAnchors:{point1:new THREE.Vector2(0,d),point2:new THREE.Vector2(c,0)},url:i,domElement:e.domElement,isProfile:e.isProfile};this.associateModel(u),t&&t()},this.cloudMapManager.createMapByCamera(n),this.viewer.modelManager.dispatchEvent({type:b.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();const t=this.navigationMap.getBoundingBox();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();const e=this.navigationMap.getBoundingBox();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}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.map=null,this.domElement=[]}};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var Re=function(e,t){return(Re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function Oe(e,t){function i(){this.constructor=e}Re(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Ne,He,ze=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;var r=new THREE.MeshBasicMaterial({color:this.faceDefaultColor,side:THREE.DoubleSide}),a=new Float32Array(3*e.length);t.setAttribute("position",new THREE.BufferAttribute(a,3).copyVector3sArray(e)),t.setIndex(new THREE.BufferAttribute(n,1));var l=new THREE.Mesh(t,r);return l.componentId=this.componentId,l},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}(),We=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 Oe(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)),c=[];if(0!==o.x){var d=o.x>0?this.width:-this.width;c.push((new THREE.Vector3).setX(d).add(s))}if(0!==o.y){var u=o.y>0?this.width:-this.width;c.push((new THREE.Vector3).setY(u).add(s))}if(0!==o.z){var g=o.z>0?this.width:-this.width;c.push((new THREE.Vector3).setZ(g).add(s))}2===c.length&&(r.push(l.clone().add(s)),r.push(l.clone().add(c[0])),r.push(h.clone().add(c[0])),r.push(h.clone().add(s)),r.push(h.clone().add(c[1])),r.push(l.clone().add(c[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}(ze),Ue=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 Oe(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}(ze),Fe=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 Oe(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,c=0;c<this.indices.length;c++){var d=this.indices[c];h.expandByPoint(this.vertices[d])}for(var u=h.getCenter(new THREE.Vector3).normalize(),g=[],p=0;p<e.length;p++){var f=e[p];g.push(f.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;var s=new THREE.BufferGeometry,r=new Float32Array(3*e.length),a=new Float32Array(2*this.vertexUvs.length);s.setAttribute("position",new THREE.BufferAttribute(r,3).copyVector3sArray(e)),s.setAttribute("uv",new THREE.BufferAttribute(a,2).copyVector2sArray(this.vertexUvs)),s.setIndex(new THREE.BufferAttribute(i,1));var l=new THREE.MeshBasicMaterial({map:this.texture,side:THREE.DoubleSide,transparent:!1});this.mesh=new THREE.Mesh(s,l),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),c=new THREE.Vector2(h.x,h.y);"x"==s?c=new THREE.Vector2(h.y,h.z):"y"==s&&(c=new THREE.Vector2(h.x,h.z)),t.push(c)}return t},t}(ze),Ge=function(){function e(e,t){this.languageType=e,this.initialize(),this.scene=new THREE.Scene,this.callback=t,this.buildEdges(),this.buildCorners(),this.buildFaces()}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){var s=new Fe(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 We(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 Ue(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.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}(),je=function(){function e(e,t){this.container=e,this.bimCubeData=t,this.activeCamera=new THREE.OrthographicCamera(-110,110,110,-110,.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}(),$e=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}(),Xe=function(){function e(e,t,i){this.eventManager=new $e,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:$e.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}(),Ye=function(){function e(e,t,i){this.callback=i,this.functionsUnexecuted=[];var n=this;this.bimCubeData=new Ge(t,(function(){n.bimCubeView=new je(e,n.bimCubeData),n.bimCubeEditor=new Xe(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()}}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.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 Ye(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()}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:140,height:140,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,c=new e.Bimface.UI.Menu.MenuItemConfig;c.id="home";var d=new e.Bimface.UI.Menu.MenuItem(c);d.setText(BimfaceLanguage.bf_viewHouse_home),d.element.addClass("bf-menu-item1"),n.getEventManager().addEvent(r.ToolbarHomeClick,(function(){i.switchHomeView()})),d.addEventListener(s.Click,(function(){i.switchHomeView(),i.hide()})),this.switchHomeView=function(){var e=n.getCustomHomeview(),t=n.getDefaultHomeview(),i=e||t,o=i.name;"orth"==o&&g.setText(BimfaceLanguage.bf_viewHouse_perspective),"persp"==o&&g.setText(BimfaceLanguage.bf_viewHouse_orthographic),n.setCameraStatus(i,(function(){0==n.getCameraAnimation()&&n.render()}))};var u=new e.Bimface.UI.Menu.MenuItemConfig;u.id="orthographic";var g=new e.Bimface.UI.Menu.MenuItem(u);g.setText(BimfaceLanguage.bf_viewHouse_orthographic),g.element.addClass("bf-menu-item1"),g.addEventListener(s.Click,(function(){i.hide(),g.element.textContent==BimfaceLanguage.bf_viewHouse_orthographic?(n.setCameraType("OrthographicCamera"),n.render(),g.setText(BimfaceLanguage.bf_viewHouse_perspective)):(n.setCameraType("PerspectiveCamera"),n.render(),g.setText(BimfaceLanguage.bf_viewHouse_orthographic))})),this.orthographic=g;var p=new e.Bimface.UI.Menu.MenuItemConfig;p.id="setAsHome";var f=new e.Bimface.UI.Menu.MenuItem(p);f.setText(BimfaceLanguage.bf_viewHouse_setAsHome),f.element.addClass("bf-menu-item1"),f.addEventListener(s.Click,(function(){i.hide();var e=n.getCameraStatus();n.recordCustomHomeview(e)}));var m=new e.Bimface.UI.Menu.MenuItemConfig;m.id="resetHome";var w=new e.Bimface.UI.Menu.MenuItem(m);w.setText(BimfaceLanguage.bf_viewHouse_resetHome),w.element.addClass("bf-menu-item1"),w.addEventListener(s.Click,(function(){i.hide(),n.recordCustomHomeview(null)}));var v=new e.Bimface.UI.Menu.Spacer;v.element.style.backgroundColor="#D0D6D6";var y=new e.Bimface.UI.Menu.Spacer;y.element.style.backgroundColor="#D0D6D6",this.menu.addControl(d),this.menu.addControl(v),this.menu.addControl(g),this.menu.addControl(y),this.menu.addControl(f),this.menu.addControl(w),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(){this.viewer=null,this.menu=null,this.orthographic=null},a.addEventListener("mousedown",(function(e){h&&i.hide()}))},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=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),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 c=i.createNS("path","");c.setAttribute("fill","#BCC0C2"),c.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 d=i.createNS("polygon","");d.setAttribute("fill","#E3E9EC"),d.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"),c.setAttribute("fill","#32D3A6"),d.setAttribute("fill","#BAFFEC"),u.setAttribute("fill","#32D3A6")})),a.addEventListener("mouseout",(function(){h.setAttribute("fill","#E3E9EC"),c.setAttribute("fill","#BCC0C2"),d.setAttribute("fill","#E3E9EC"),u.setAttribute("fill","#BCC0C2")})),l.appendChild(h),l.appendChild(c),l.appendChild(d),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"},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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),function(e){this._opt=e,this.init()});i.prototype={init:function(){var e,t=this._opt;if(t.viewer)e=new b.Extensions.AnnotationHelper3D(t.viewer.getViewer());else{if(!t.domElement)return alert("domElement must not be empty."),!1;(e=new b.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"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationTypeOption=t}(),Ne=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),(He=function(e){}).prototype={init:function(){var e,t=this._opt;e=new b.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(){}},Ne.AnnotationViewer3dManager=He,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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),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 b.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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),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}();
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var Ze=function(e,t){return(Ze=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function qe(e,t){function i(){this.constructor=e}Ze(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Ke,Je=function(){return(Je=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}).apply(this,arguments)},Qe=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,t,i,n))},e.prototype.addMarkup=function(e,t){t.drawEnd=!0,this.markupManager.add(t),"function"==typeof e.itemCompleted&&e.itemCompleted(t)},e.prototype.redraw=function(e){},e.prototype.onExit=function(e){},e.prototype.onMouseMove=function(e,t,i,n){},e}(),et=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.setColor=function(e){e&&(this.highLight=e)},e.prototype.getColor=function(){return this.strokeStyle},e}(),tt=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),s=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),r=.5*Math.abs(s[0]-o[0]),a=.5*Math.abs(s[1]-o[1]),l=this.getCenter(e);t.save(),t.translate(l[0],l[1]),t.rotate(this.rotation),t.beginPath(),t.ellipse(0,0,r,a,0,0,2*Math.PI),t.restore(),t.closePath(),this.fillStyle&&t.fill(),t.stroke(),i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth,i.ctx.fillStyle=this.fillStyle,i.drawEllips(o,s,l,this.rotation,n,r,a)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]),n=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=[];return o.push(t[0],t[1]),o.push(t[0],n[1]),o.push(t[0],i[1]),o.push(n[0],i[1]),o.push(i[0],i[1]),o.push(i[0],n[1]),o.push(i[0],t[1]),o.push(n[0],t[1]),o},t}(et);!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"}(Ke||(Ke={}));var it=Ke,nt=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth(),r=e.markupManager.getFillStyleState()?e.markupManager.getFillColor():void 0;this.markup=new tt([],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."),it.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,it.FINISHED)},t}(Qe),ot=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),s=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),r=this.getCenter(e);t.save(),t.translate(r[0],r[1]),t.rotate(this.rotation),t.beginPath(),t.rect(-.5*(s[0]-o[0]),-.5*(s[1]-o[1]),s[0]-o[0],s[1]-o[1]),t.restore(),t.closePath(),this.fillStyle&&t.fill(),t.stroke(),i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth,i.ctx.fillStyle=this.fillStyle,i.drawRect(this,o,s,r,this.rotation,n)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]),n=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=[];return o.push(t[0],t[1]),o.push(t[0],n[1]),o.push(t[0],i[1]),o.push(n[0],i[1]),o.push(i[0],i[1]),o.push(i[0],n[1]),o.push(i[0],t[1]),o.push(n[0],t[1]),o},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}(et),st=Ke,rt=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth(),r=e.markupManager.getFillStyleState()?e.markupManager.getFillColor():void 0;this.markup=new ot([],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."),st.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,st.FINISHED)},t}(Qe),at=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),s=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),r=10+this.lineWidth,a=o[0],l=o[1],h=s[0],c=s[1],d=180*Math.atan2(l-c,a-h)/Math.PI,u=(d+30)*Math.PI/180,g=(d-30)*Math.PI/180,p=r*Math.cos(u),f=r*Math.sin(u),m=r*Math.cos(g),w=r*Math.sin(g),v=a-p,y=l-f,b=[(o[0]+s[0])/2,(o[1]+s[1])/2];t.fillStyle=t.strokeStyle,t.beginPath(),v=h+p,y=c+f,t.moveTo(v,y),t.lineTo(h,c),v=h+m,y=c+w,t.lineTo(v,y),t.closePath(),t.fill(),t.beginPath(),t.moveTo(a,l),p=(r-3)*Math.cos(u),f=(r-3)*Math.sin(u);var x=[h+(p+(m=(r-3)*Math.cos(g)))/2,c+(f+(w=(r-3)*Math.sin(g)))/2];t.lineTo(x[0],x[1]),t.stroke(),i.drawArrow(this,a,l,h,c,p,f,m,w,b,this.rotation,n,o,s)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]);return t.concat(i)},t}(et),lt=Ke,ht=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth();this.markup=new at([],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."),lt.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,lt.FINISHED)},t}(Qe),ct=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),s=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),r=this.getCenter(e);t.save(),t.translate(r[0],r[1]),t.rotate(this.rotation),t.beginPath(),t.moveTo(-.5*(s[0]-o[0]),-.5*(s[1]-o[1])),t.lineTo(.5*(s[0]-o[0]),.5*(s[1]-o[1])),t.moveTo(-.5*(s[0]-o[0]),.5*(s[1]-o[1])),t.lineTo(.5*(s[0]-o[0]),-.5*(s[1]-o[1])),t.stroke(),t.restore(),i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth,i.drawCross(o,s,r,this.rotation,n)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]),n=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=[];return o.push(t[0],t[1]),o.push(t[0],n[1]),o.push(t[0],i[1]),o.push(n[0],i[1]),o.push(i[0],i[1]),o.push(i[0],n[1]),o.push(i[0],t[1]),o.push(n[0],t[1]),o},t}(et),dt=Ke,ut=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth();this.markup=new ct([],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."),dt.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,dt.FINISHED)},t}(Qe),gt=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}(),pt=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.markupManager.getMarkupCenter(e,n);o||(o=[0,0]),t.save(),t.translate(o[0],o[1]),t.rotate(this.rotation),t.beginPath(),i.ctx.save(),i.ctx.translate(o[0],o[1]),i.ctx.rotate(this.rotation),i.ctx.beginPath(),i.ctx.strokeStyle="rgba("+(2*n+2)+",60,60,1)",i.ctx.fillStyle="rgba("+(2*n+2)+",60,255,1)",i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth;for(var s=1,r=this.drawPoints.length;s<r;s++){var a=e.worldToClientPoint([this.drawPoints[s-1][0],this.drawPoints[s-1][1],this.drawPoints[s-1][2]]),l=e.worldToClientPoint([this.drawPoints[s][0],this.drawPoints[s][1],this.drawPoints[s][2]]),h=void 0;if(1==s&&(t.moveTo(a[0]-o[0],a[1]-o[1]),i.ctx.moveTo(a[0]-o[0],a[1]-o[1])),this.editPt&&this.editPt[s-1])h=e.worldToClientPoint([this.editPt[s-1][0],this.editPt[s-1][1],this.editPt[s-1][2]]);else if(this.controlPt[s-1]&&s<r-1)h=e.worldToClientPoint([this.controlPt[s-1][0],this.controlPt[s-1][1],this.controlPt[s-1][2]]);else{h=this.getControlPt(a,l);var c=e.clientToWorldPoint(h);c[0]&&c[1]&&(this.controlPt[s-1]=c)}t.quadraticCurveTo(h[0]-o[0],h[1]-o[1],l[0]-o[0],l[1]-o[1]),i.ctx.quadraticCurveTo(h[0]-o[0],h[1]-o[1],l[0]-o[0],l[1]-o[1])}i.ctx.stroke(),this.close&&this.fillStyle&&t.fill(),t.stroke(),t.restore(),i.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 gt.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*gt.distanceByArr(e,t),s=[t[1]-e[1],e[0]-t[0]];return s=gt.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){if(null==t)return this.drawPoints;var i=e.markupManager.getMarkupBbox(e,t),n=[i[0],i[1]],o=[i[2],i[3]],s=[(n[0]+o[0])/2,(n[1]+o[1])/2],r=[];return r.push(n[0],n[1]),r.push(n[0],s[1]),r.push(n[0],o[1]),r.push(s[0],o[1]),r.push(o[0],o[1]),r.push(o[0],s[1]),r.push(o[0],n[1]),r.push(s[0],n[1]),r},t}(et),ft=Ke,mt=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i.bFirstCloudMarkup=!0,i.uncertainty=!1,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){if(this.bFirstCloudMarkup){if(e.markupManager.hitTest(e,t,i)>-1)return;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth(),r=e.markupManager.getFillStyleState()?e.markupManager.getFillColor():void 0;this.markup=new pt([],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 ft.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]]);gt.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}(Qe),wt=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),s=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),r=this.getCenter(e),a=s[1]-o[1],l=s[0]-o[0],h=Math.abs(l),c=Math.abs(a),d=h/this.baseUnit,u=c/this.baseUnit,g=parseInt(d),p=parseInt(u),f=0==g?h:h/g,m=0==p?c:c/p;t.save(),t.translate(r[0],r[1]),t.rotate(this.rotation),t.beginPath(),i.ctx.save(),i.ctx.translate(r[0],r[1]),i.ctx.rotate(this.rotation),i.ctx.beginPath();var w=[-h/2,-c/2],v=[h/2,c/2];i.ctx.strokeStyle="rgba("+(2*n+2)+",40,40,1)",i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth,t.lineJoin="round",this.drawSide("orientation",f,h,w[0],w[1],t,null,n,i,!0),this.drawSide("portrait",m,c,v[0],w[1],t,null,n,i),this.drawSide("orientation",f,h,v[0],v[1],t,!0,n,i),this.drawSide("portrait",m,c,w[0],v[1],t,!0,n,i),this.fillStyle&&t.fill(),t.stroke(),t.restore(),i.ctx.stroke(),i.ctx.restore()}},t.prototype.drawSide=function(e,t,i,n,o,s,r,a,l,h){var c,d=0,u=0,g=i/t,p=n,f=o;"orientation"==e?d=t:u=t;for(var m=0;m<g;m++){h&&0==m&&s.moveTo(n,o),c=r?[n-d,o-u]:[n+d,o+u],d&&Math.abs(c[0]-p)>i?c[0]=r?p-i:p+i:u&&Math.abs(c[1]-f)>i&&(c[1]=r?f-i:f+i);var w=this.getControlPt([n,o],c);s.quadraticCurveTo(w[0],w[1],c[0],c[1]),l.drawCloudRect(n,o,w,c,a),n=c[0],o=c[1]}},t.prototype.getControlPt=function(e,t,i){var n=[(e[0]+t[0])/2,(e[1]+t[1])/2],o=.5*gt.distanceByArr(e,t),s=[t[1]-e[1],e[0]-t[0]];return s=gt.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){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]),n=[(t[0]+i[0])/2,(t[1]+i[1])/2],o=[];return o.push(t[0],t[1]),o.push(t[0],n[1]),o.push(t[0],i[1]),o.push(n[0],i[1]),o.push(i[0],i[1]),o.push(i[0],n[1]),o.push(i[0],t[1]),o.push(n[0],t[1]),o},t}(et),vt=Ke,yt=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth(),r=e.markupManager.getFillStyleState()?e.markupManager.getFillColor():void 0;this.markup=new wt([],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."),vt.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,vt.FINISHED)},t}(Qe),bt=function(e){function t(t,i,n,o,s,r,a,l,h){var c=e.call(this)||this;c.rotation=r||0,c.textAreaId=a||null,c.center=l||null,c.markupType="Text",c.drawPoints=h?t:[t],c.pureText=i,c.userText=i,c.strokeStyle=n,c.fontSize=o,c.fontFamily=s;var d=document.createElement("canvas");return c.virtualCtx=d.getContext("2d"),c.bNeedHitByBbox=!1,c}return qe(t,e),t.prototype.draw=function(e,t,i,n){var o=e.worldToClientPoint(this.drawPoints[0]),s=this.getTextBbox(e),r=[(s[2]+s[0])/2,(s[3]+s[1])/2];this.center&&(r=e.worldToClientPoint(this.center)),t.save(),t.translate(r[0],r[1]),t.rotate(this.rotation),t.beginPath(),i.init(r,this.rotation),t.fillStyle=t.strokeStyle,t.font=this.fontSize+"px "+this.fontFamily,t.zIndex=120,i.ctx.font="bold "+this.fontSize+"px "+this.fontFamily,i.ctx.strokeStyle="rgba("+(2*n+2)+",80,80,1)",i.ctx.fillStyle="rgba("+(2*n+2)+",80,80,1)";for(var a=this.userText.split(/\n/),l=0;l<a.length;l++){t.fillText(a[l],o[0]-r[0],o[1]-r[1]+(l+1)*this.fontSize),i.ctx.fillText(a[l],o[0]-r[0],o[1]-r[1]+(l+1)*this.fontSize);var h=a[l].replace(/[a-z]/g,"aa").replace(/[^\u0000-\u00ff]/g,"aaaa").replace(/[A-Z]/g,"aaa").replace(/[0-9]/g,"aa").length;i.ctx.fillRect(o[0]-r[0],o[1]-r[1]+l*this.fontSize,h*this.fontSize*4/14,20)}t.restore(),i.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;for(var t=(this.pureText||this.userText).split(/\n/),i=e[0],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){var t=e.worldToClientPoint(this.drawPoints[0]);if(this.drawPoints[1]){o=e.worldToClientPoint(this.drawPoints[1]);var i=[(t[0]+o[0])/2,(t[1]+o[1])/2]}else var n=this.getTextBbox(e),o=(i=[(n[2]+n[0])/2,(n[3]+n[1])/2],[n[2],n[3]]);var s=[];return s.push(t[0],t[1]),s.push(t[0],i[1]),s.push(t[0],o[1]),s.push(i[0],o[1]),s.push(o[0],o[1]),s.push(o[0],i[1]),s.push(o[0],t[1]),s.push(i[0],t[1]),s},t}(et),xt=Ke,Et=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 qe(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 xt.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,c=e.markupManager.getFontSize(),d=i.style.fontFamily,u=new bt(l,n,h,c,d,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(){event.stopImmediatePropagation()})),i.addEventListener("mouseup",(function(){event.stopImmediatePropagation()})),i.addEventListener("mousemove",(function(){event.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=i.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=e.markupManager.getColor(),i.style.position="fixed",i.style.lineHeight="100%",i.style.width="10px",i.style.paddingLeft="6px",i.style.overflow="hidden",i.style.webkitUserSelect="auto",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=e.markupManager.getFontFamily(),i.style.fontSize=e.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}(Qe),Ct=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 qe(t,e),t.prototype.draw=function(e,t,i,n){if(!(this.drawPoints.length<2)){var o=e.markupManager.getMarkupCenter(e,n);o||(o=[0,0]),t.save(),t.translate(o[0],o[1]),t.rotate(this.rotation),t.beginPath(),t.lineJoin="round",i.init(o,this.rotation),i.ctx.lineWidth=kt.isMobile?18:this.lineWidth+i.lineWidth;for(var s=1,r=this.drawPoints.length;s<r;s++){var a=e.worldToClientPoint([this.drawPoints[s-1][0],this.drawPoints[s-1][1],this.drawPoints[s-1][2]]),l=e.worldToClientPoint([this.drawPoints[s][0],this.drawPoints[s][1],this.drawPoints[s][2]]);1==s&&t.moveTo(a[0]-o[0],a[1]-o[1]),t.lineTo(l[0]-o[0],l[1]-o[1]),i.drawPolyline(a,l,o,this.rotation,n)}this.close&&this.fillStyle&&(t.fill(),this.bNeedHitByBbox=!0),t.stroke(),t.restore(),i.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 gt.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){if(null==t)return this.drawPoints;var i=e.markupManager.getMarkupBbox(e,t),n=[i[0],i[1]],o=[i[2],i[3]],s=[(n[0]+o[0])/2,(n[1]+o[1])/2],r=[];return r.push(n[0],n[1]),r.push(n[0],s[1]),r.push(n[0],o[1]),r.push(s[0],o[1]),r.push(o[0],o[1]),r.push(o[0],s[1]),r.push(o[0],n[1]),r.push(s[0],n[1]),r},t}(et),Mt=Ke,Pt=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i.bFirstCloudMarkup=!0,i.uncertainty=!1,i}return qe(t,e),t.prototype.begin=function(e,t,i,n){if(this.bFirstCloudMarkup){if(e.markupManager.hitTest(e,t,i)>-1)return;var o=e.markupManager.getColor(),s=e.markupManager.getLineWidth(),r=e.markupManager.getFillStyleState()?e.markupManager.getFillColor():void 0;this.markup=new Ct([],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 Mt.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}(Qe),It=Ke,Tt=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 Et(this.markupManager).createDiv(Et.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){var n=e.markupManager.get(this.highLightId);this.canvas.style.cursor="",this.highLightId=-1}if(this.curIndex>=0){if(!(n=e.markupManager.get(this.curIndex)))return;i&&e.markupManager.hitTest(e,i[0],i[1])==this.curIndex&&e.isEnableAnnotationPick&&(this.canvas.style.cursor="pointer",this.highLightId=this.curIndex)}if(this.editIndex>=0){if(0==e.markupManager.markups.length)return this.editIndex,!1;var o=e.markupManager.getMarkupBbox(e,this.editIndex);if(!o)return;var s=[o[0],o[1]],r=[o[2],o[3]],a=(n=e.markupManager.get(this.editIndex)).getGrips(e,this.editIndex),l=e.markupManager.getMarkupCenter(e,this.editIndex);if(!l)return;t.save(),t.translate(l[0],l[1]),"Arrow"!=n.markupType&&t.rotate(n.rotation),t.beginPath(),t.lineWidth="1",t.strokeStyle="red",t.fillStyle="#ffffff";var h=(n.lineWidth||0)/2;4!=a.length&&(e.operationTypes&&!e.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",e.operationTypes&&!e.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 c=void 0,d=void 0;if("Arrow"==n.markupType){e.operationTypes&&!e.operationTypes.includes("Stretch")&&(t.strokeStyle="#999999");var u=e.markupManager.getMarkupSize(e,this.editIndex),g=Math.sqrt(u[0]*u[0]+u[1]*u[1]),p=u[0]/g*3,f=u[1]/g*3;t.beginPath(),t.arc(a[0]-l[0]+(a[0]<a[2]?-p/2:p/2),a[1]-l[1]+(a[1]<a[3]?-f/2:f/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]?f:-f),4,0,2*Math.PI,!1),t.fill(),t.stroke(),t.closePath()}else{e.operationTypes&&!e.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 m=0;m<a.length;m+=2){t.beginPath(),e.operationTypes&&!e.operationTypes.includes("Stretch")?t.strokeStyle="#999999":t.strokeStyle="red";var w=[a[m],a[m+1]];if("Text"==n.markupType)c=1,d=1;else{var v=e.worldToClientPoint(n.drawPoints[0]),y=e.worldToClientPoint(n.drawPoints[1]);c=v[0]<y[0]?1:-1,d=v[1]<y[1]?1:-1}switch(m){case 0:t.arc(w[0]-l[0]-h*c,w[1]-l[1]-h*d,4,0,2*Math.PI,!1);break;case 2:t.arc(w[0]-l[0]-h*c,w[1]-l[1],4,0,2*Math.PI,!1);break;case 4:t.arc(w[0]-l[0]-h*c,w[1]-l[1]+h*d,4,0,2*Math.PI,!1);break;case 6:t.arc(w[0]-l[0],w[1]-l[1]+h*d,4,0,2*Math.PI,!1);break;case 8:t.arc(w[0]-l[0]+h*c,w[1]-l[1]+h*d,4,0,2*Math.PI,!1);break;case 10:t.arc(w[0]-l[0]+h*c,w[1]-l[1],4,0,2*Math.PI,!1);break;case 12:t.arc(w[0]-l[0]+h*c,w[1]-l[1]-h*d,4,0,2*Math.PI,!1);break;case 14:t.arc(w[0]-l[0],w[1]-l[1]-h*d,4,0,2*Math.PI,!1)}t.fill(),t.stroke(),t.closePath()}}t.restore(),this.MarkupVirtualPad.drawEdit(s,r,l,n,a,this.editIndex,p,f,h,[c,d])}},e.prototype.canCreateMarkup=function(e){if(-1==this.curIndex)return!0;var t=e.markupManager.get(this.curIndex);if(!t)return!0;var i=t.getGrips(e);return this.editIndex!=this.curIndex&&0!=i.length&&"Text"!=t.markupType},e.prototype.setMarkupType=function(e){if(!kt.isMobile||"cloud"!==e&&"polyline"!==e){switch(this.tool&&this.tool.onExit(),this.crtMarkupType=e,this.start=!1,e){case"ellips":this.tool=new nt(this.markupManager);break;case"rectangle":this.tool=new rt(this.markupManager);break;case"arrow":this.tool=new ht(this.markupManager);break;case"cross":this.tool=new ut(this.markupManager);break;case"cloud":this.tool=new mt(this.markupManager);break;case"cloud-rect":this.tool=new yt(this.markupManager);break;case"text":this.tool=new Et(this.markupManager);break;case"polyline":this.tool=new Pt(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=e.markupManager.hitTest(e,t,i,!0);var r=this.MarkupVirtualPad.isEdge(t,i);if(!e.isEnableAnnotationPick||this.curIndex<0&&this.canCreateMarkup(e)&&!r){if(this.editIndex>-1)return this.editIndex=-1,void this.redraw(e);if(n==It.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==It.RightButton&&this.tool.begin(e,t,i,n)}this.bFirstClick=!0;var a=this.editIndex;if(this.preEdit=a,this.curIndex>=0){var l=e.markupManager.get(this.curIndex).markupType;if(kt.isMobile&&("Cloud"===l||"Polyline"===l))return;if(e.hasOwnProperty("isEnableAnnotationPick")&&!e.isEnableAnnotationPick)return;this.editIndex=this.curIndex,this.inEditMode=!0,this.redraw(e)}else this.editIndex=-1,this.redraw(e);this.editIndex!=a&&e.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=e.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=e.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?e.operationTypes&&e.operationTypes.includes("Rotate")&&(e.markupManager.gripRotate(e,this.editIndex,this.firstPos,r),this.redraw(e,r)):this.currentGrip>=0&&this.currentGrip<9?e.operationTypes&&e.operationTypes.includes("Stretch")&&(e.markupManager.gripDragging(e,this.editIndex,this.currentGrip,this.firstPos,r),this.redraw(e,r)):e.operationTypes&&e.operationTypes.includes("Move")&&(e.markupManager.translatePos(e,this.editIndex,this.firstPos,r),this.redraw(e,r))}else this.bFirstClick=!0,this.currentGrip=-1,this.curIndex=e.markupManager.hitTest(e,t,i),this.redraw(e,[t,i])},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.onEditing(e,t,i,n),this.start&&(-1!=this.curIndex&&this.editIndex==this.curIndex||It.FINISHED==this.tool.end(e,t,i,n)&&(this.start=!1)),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)&&e.operationTypes&&e.operationTypes.includes("Delete")&&(e.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=e.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=e.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"};e.onClick(Je(Je({},s),o))}}this.isEndDrawingForRightClick=!0},e.prototype.onDoubleClick=function(e,t){var i=this.formatEventOffset(e,t),n=e.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=e.markupManager.get(n),s={clientPosition:{x:t.clientX,y:t.clientY},screenPosition:{x:t.screenX,y:t.screenY}};e.onDoubleClick(Je(Je({},s),o))}e.operationTypes&&e.operationTypes.includes("Edit")&&(this.tool.onDoubleClick&&this.tool.onDoubleClick(e,t),this.editText(e))},e.prototype.onDoubleTouch=function(e,t){e.operationTypes&&e.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=e.markupManager.get(this.curIndex);if(t){var i=t.getPoints();if("Text"==t.markupType){""!=Et.lastTextareaId&&(this.textMarkupTool?this.textMarkupTool.initDom(e):this.tool.initDom(e));var n=new Et(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],It.LelftButton),n.setEditBox(t.getTextSize()),this.device.isMobileApple||this.device.isPc||setTimeout((function(){n.reposition(e)}),500),e.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 Pt||this.tool instanceof mt)&&(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);e.markupManager.viewer.alwaysMode&&2==t.button&&(e.markupManager.hitTest(e,n.x,n.y,!0)>-1&&(t.preventDefault(),t.stopPropagation()));return this.end(e,n.x,n.y,t.buttons)},e.prototype.onTouchstart=function(e,t){var i=this.formatEventOffset(e,t);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){return this.end(e,this.touchPos[0],this.touchPos[1],1)},e.prototype.isPanMode=function(e){return e==It.MiddleButton||e==It.RightButton},e.prototype.formatEventOffset=function(e,t){var i,n,o=this.canvas.getBoundingClientRect();return kt.isMobile?(i=t.touches[0].pageX-(o.x||o.left),n=t.touches[0].pageY-(o.y||o.top)):(i=t.clientX-(o.x||o.left),n=t.clientY-(o.y||o.top)),{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)},e.prototype.getStart=function(){return this.start},e}(),Dt=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,c=n.fontSize,d=n.rotation,u=n.fontFamily,g=n.textAreaId,p=n.center,f=n.markupId,m=n.controlPt,w=null;switch(n.markupType){case"Ellipse":w=new tt(o,s,r,d,a);break;case"Rectangle":w=new ot(o,s,r,d,a);break;case"Arrow":w=new at(o,s,r);break;case"Cross":w=new ct(o,s,r,d);break;case"Cloud":w=new pt(o,s,r,m,d,a,l);break;case"CloudRect":w=new wt(o,s,r,d,a);break;case"Text":if(2==o.length&&"number"==typeof o[0]){if(w=new bt(o,h,s,c,u,d,g,p,!0),n.pureText){var v=w.getTextSize();w.resizeText(v)}}else w=new bt(o[0],h,s,c,u,d,g,p);break;case"Polyline":w=new Ct(o,s,r,d,a,l);break;default:console.log("Current type is not supported.")}f&&(w.markupId=f),t.push(w)}return t},e}(),St=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}return e.prototype.toString=function(e){return Dt.markups2string(e||this.markups)},e.prototype.fromString=function(e){return Dt.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=(kt.isMobile,s.lineWidth),t.fillStyle=s.fillStyle,t.fontFamily=s.fontFamily,s.highLight&&(t.strokeStyle=s.highLight,s.highLight=null),s.draw(e,t,this.MarkupVirtualPad,n)}},e.prototype.getColor=function(){return this.strokeStyle},e.prototype.setColor=function(e){this.strokeStyle=e},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=e.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=gt.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.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=[],c=0;c<a.length;c++)h[c]=e.worldToClientPoint(a[c]),h[c][0]+=s,h[c][1]+=r,l[c]=e.clientToWorldPoint(h[c]);if(o.setPoints(l),"Cloud"==o.markupType){var d=(o.editPt&&o.originEditPt||o.controlPt&&o.originControlPt).slice();if(d){var u=[];for(c=0;c<d.length;c++)u[c]=e.worldToClientPoint(d[c]),u[c][0]+=s,u[c][1]+=r,d[c]=e.clientToWorldPoint(u[c]);o.editPt?o.editPt=d:o.controlPt=d}}}},e.prototype.isPointInCircle=function(e,t,i){return gt.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),c=Math.acos(h),d=(i[1]-s[1])/(i[0]-s[0]),u=this.getY(i[0],i[1],d,n[0]),g=this.getX(i[0],i[1],d,n[1]);i[0]>s[0]&&i[1]<s[1]?n[0]<g&&n[1]<u&&(c=2*Math.PI-c):i[0]>s[0]&&i[1]>s[1]?n[0]>g&&n[1]<u&&(c=2*Math.PI-c):i[0]<s[0]&&i[1]>s[1]?n[0]>g&&n[1]>u&&(c=2*Math.PI-c):i[0]<s[0]&&i[1]<s[1]&&n[0]<g&&n[1]>u&&(c=2*Math.PI-c),o.rotation=o.originRotation+c},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,t),l=this.getMarkupSize(e,t),h=l.slice(),c=this.getMarkupCenter(e,t),d=c.slice();if("Arrow"==s.markupType){var u=o[0]-n[0],g=o[1]-n[1],p=e.worldToClientPoint(r[0]),f=e.worldToClientPoint(r[1]);switch(i){case 0:p[0]+=u,p[1]+=g;break;case 4:f[0]+=u,f[1]+=g;break;default:console.log("default grip id."+i)}return p=e.clientToWorldPoint(p),f=e.clientToWorldPoint(f),void s.setPoints([p,f])}var m=this.rotateTransform(n[0],n[1],s.rotation,o[0],o[1]),w=m[0]-n[0],v=m[1]-n[1];switch(i){case 0:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[1]-=v,h[0]-=w;break;case 1:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),h[0]-=w;break;case 2:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[1]+=v,h[0]-=w;break;case 3:d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[1]+=v;break;case 4:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[0]+=w,h[1]+=v;break;case 5:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),h[0]+=w;break;case 6:d[0]+=.5*w*Math.cos(s.rotation),d[1]+=.5*w*Math.sin(s.rotation),d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[1]-=v,h[0]+=w;break;case 7:d[0]-=.5*v*Math.sin(s.rotation),d[1]+=.5*v*Math.cos(s.rotation),h[1]-=v}if("Cloud"!=s.markupType&&"Polyline"!=s.markupType){var y=[d[0]-.5*h[0],d[1]-.5*h[1]],b=[d[0]+.5*h[0],d[1]+.5*h[1]];"Text"==s.markupType&&s.resizeText(h),y=e.clientToWorldPoint(y),b=e.clientToWorldPoint(b),s.setPoints([y,b])}else this.draggingMultipleGrip(e,s,i,n,o,w,v,a,l,h,c,d)},e.prototype.draggingMultipleGrip=function(e,t,i,n,o,s,r,a,l,h,c,d){var u=t.originPoints.slice(),g=c[0]-l[0]/2,p=c[1]-l[1]/2,f=d[0]-h[0]/2,m=d[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]+f,n[1]=a/l[1]*h[1]+m,t[i]=e.clientToWorldPoint(n)}return t},v=w(u);if(t.setPoints(v),"Cloud"==t.markupType){var y=(t.originEditPt||t.originControlPt).slice();t.editPt=w(y)}},e}(),Bt=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=kt.isMobile?18:2}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 c=this.ctx;if(c.save(),c.translate(i[0],i[1]),"Arrow"!=n.markupType&&c.rotate(n.rotation),c.beginPath(),c.lineWidth=n.lineWidth+2,c.fillStyle="rgba("+(2*s+2)+",255,255,1)",c.fillRect(-.5*(t[0]-e[0]),-.5*(t[1]-e[1]),t[0]-e[0],t[1]-e[1]),c.fillStyle=c.strokeStyle="rgba("+(2*s+2)+",100,255,1)",c.arc(0,e[1]-i[1]-20,13,0,2*Math.PI,!1),c.fill(),"Arrow"==n.markupType)c.fillStyle=c.strokeStyle="rgba("+(2*s+2)+",110,255,1)",c.beginPath(),c.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),10,0,2*Math.PI,!1),c.fill(),c.stroke(),c.closePath(),c.fillStyle=c.strokeStyle="rgba("+(2*s+2)+",150,255,1)",c.beginPath(),c.arc(o[2]-i[0]+(o[0]<o[2]?r:-r),o[3]-i[1]+(o[1]<o[3]?a:-a),10,0,2*Math.PI,!1),c.fill(),c.stroke(),c.closePath();else for(var d=h[0],u=h[1],g=0;g<o.length;g+=2){c.fillStyle=c.strokeStyle="rgba("+(2*s+2)+","+(5*g+110)+",255,1)",c.beginPath();var p=[o[g],o[g+1]],f=this.isMobile?6:3;switch(g){case 0:c.arc(p[0]-i[0]-l*d,p[1]-i[1]-l*u,f,0,2*Math.PI,!1);break;case 2:c.arc(p[0]-i[0]-l*d,p[1]-i[1],f,0,2*Math.PI,!1);break;case 4:c.arc(p[0]-i[0]-l*d,p[1]-i[1]+l*u,f,0,2*Math.PI,!1);break;case 6:c.arc(p[0]-i[0],p[1]-i[1]+l*u,f,0,2*Math.PI,!1);break;case 8:c.arc(p[0]-i[0]+l*d,p[1]-i[1]+l*u,f,0,2*Math.PI,!1);break;case 10:c.arc(p[0]-i[0]+l*d,p[1]-i[1],f,0,2*Math.PI,!1);break;case 12:c.arc(p[0]-i[0]+l*d,p[1]-i[1]-l*u,f,0,2*Math.PI,!1);break;case 14:c.arc(p[0]-i[0],p[1]-i[1]-l*u,f,0,2*Math.PI,!1)}c.fill(),c.stroke(),c.closePath()}c.restore()},e.prototype.drawArrow=function(e,t,i,n,o,s,r,a,l,h,c,d,u,g){var p=t-s,f=i-r,m=this.ctx;m.save(),m.lineWidth=kt.isMobile?18:e.lineWidth+this.lineWidth,m.strokeStyle="rgba("+(2*d+2)+",20,20,1)",m.fillStyle="rgba("+(2*d+2)+",20,255,1)",m.beginPath(),m.moveTo(t,i),m.lineTo(n,o),p=n+s,f=o+r,m.moveTo(p,f),m.lineTo(n,o),p=n+a,f=o+l,m.lineTo(p,f),m.stroke(),m.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=kt.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.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>100)return(o-110)/10}return-1},e}(),_t=Ke,kt=function(){function e(t,i){var n=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),s=(/(?:Chrome|CriOS)/.test(e),/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e));return{isPc:!(/(?:iPhone)/.test(e)&&!s||n||i||s),isMobileApple:/(?:iPhone|iPad)/.test(e)}},this.work=!1,this.alwaysMode=!1,this.restoreState=!1,this.firstTouch=0,this.modelViewer=t,this.canvas=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.ctx=this.canvas.getContext("2d"),this.wrapDom=i,this.canvas.style.display="none",e.isMobile=!this.getDevice().isPc,i.appendChild(this.canvas),this.bindEvent();var o=this;this.viewer=t.getViewer?t.getViewer():t,this.viewer.wrapDom=i,this.MarkupVirtualPad=new Bt(this.viewer,i,e.isMobile),this.viewer.markupManager=this.markupManager=new St(this.MarkupVirtualPad,this),this.editor=this.viewer.markupEditor=new Tt(this.canvas,this.markupManager,this.MarkupVirtualPad,this.getDevice(),this.modelViewer),this.editor.markupManager=this.viewer.markupManager,this.viewer.onSelectChange=function(e){},this.viewer.onClick=function(e){},this.viewer.itemCompleted=function(e){},this.viewer.onDoubleClick=function(e){},this.viewer.isEnableAnnotationPick=!0,this.viewer.operationTypes=["Delete","Edit","Move","Rotate","Stretch"],this.initOnresize=window.onresize,window.onresize=function(){o.canvas.width=i.clientWidth,o.canvas.height=i.clientHeight,o.MarkupVirtualPad.canvas.width=i.clientWidth,o.MarkupVirtualPad.canvas.height=i.clientHeight,o.modelViewer.resize(),o.update(),"[object Function]"===toString.call(o.initOnresize)&&o.initOnresize()},e.isMobile&&(this.offsetHeight=this.wrapDom.offsetHeight,setInterval((function(){var e=n.wrapDom.offsetHeight;n.offsetHeight!=e&&(n.offsetHeight=e,n.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.hideCanvas=function(){this.canvas.style.display="none"},e.prototype.showCanvas=function(){this.canvas.style.display="block"},e.prototype.startDrawing=function(){this.work=!0,this.alwaysMode=!1,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.bindEvent=function(){this.getDevice().isPc?(this.wrapDom.addEventListener("dblclick",this.onDoubleClick.bind(this),!1),this.wrapDom.addEventListener("mousedown",this.onMouseDown.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)},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=Dt.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),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(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.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==_t.LelftButton?(e.stopPropagation(),this.editor.onMouseDown(this.viewer,e)):this.editor.onMouseDown(this.viewer,e)))},e.prototype.onTouchstart=function(e){if(!this.alwaysMode&&"CANVAS"==e.target.tagName.toUpperCase()){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.preventDefault(),e.buttons==_t.LelftButton&&e.stopPropagation(),this.editor.onTouchstart(this.viewer,e),this.containerSize=this.getContainerSize()))}},e.prototype.onMouseMove=function(e){this.alwaysMode?this.update():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.alwaysMode||"CANVAS"!=e.target.tagName.toUpperCase())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.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.alwaysMode||"CANVAS"!=e.target.tagName.toUpperCase()||(!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.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;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?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.work&&("textarea"!=document.activeElement.tagName.toLowerCase()&&e.stopPropagation(),this.editor.onKeyDown(this.viewer,e))},e.prototype.onKeyUp=function(e){this.work&&"textarea"!=document.activeElement.tagName.toLowerCase()&&(e.preventDefault(),e.stopPropagation())},e}(),At=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.modelViewer.addEventListener("Rendered",(function(){n.update()})),n.viewer.clientToWorldPoint=function(e){return n.viewer.toWorldPoint(e)},n.viewer.worldToClientPoint=function(e){return e?n.viewer.toScreenPoint([e[0],e[1]]):[]},n}return qe(t,e),t.prototype.getCurrentState=function(){return{annotationList:this.getAnnotationList(),state:JSON.parse(this.modelViewer.getCurrentState())}},t.prototype.startDrawing=function(){this.canvas.style.zIndex=10,this.work=!0,this.alwaysMode=!1,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.hideCanvas()},t.prototype.setState=function(e){if("string"!=typeof e.state&&(e.state=JSON.stringify(e.state)),this.modelViewer.setState(e.state),"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;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),e(i.toDataURL())},t.prototype.switchMode=function(){},t}(kt),Lt=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.modelViewer.addEventListener("Rendered",(function(){n.update()})),n.viewer.clientToWorldPoint=function(e){return n.viewer.views[n.modelViewer._defaultViewId].toWorldPoint(e)},n.viewer.worldToClientPoint=function(e){return e?n.viewer.views[n.modelViewer._defaultViewId].toScreenPoint([e[0],e[1]]):[]},n}return qe(t,e),t.prototype.getCurrentState=function(){return{annotationList:this.getAnnotationList(),state:JSON.parse(this.modelViewer.getCurrentState())}},t.prototype.startDrawing=function(){this.canvas.style.zIndex=10,this.work=!0,this.alwaysMode=!1,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.hideCanvas()},t.prototype.setState=function(e){if("string"!=typeof e.state&&(e.state=JSON.stringify(e.state)),this.modelViewer.setState(e.state),"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;var i=t.getContext("2d");i.beginPath(),i.drawImage(this.canvas,0,0);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}(kt),Vt=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.cameraControl=n.viewer.cameraControl,n.viewBox={width:1e3,height:1e3},n.viewer.clientToWorldPoint=function(e){var t={x:e[0],y:e[1],z:0},i=n.viewer.canvasToWorld(t);return[i.x,i.y,i.z]},n.viewer.worldToClientPoint=function(e){var t={x:e[0],y:e[1],z:e[2]||0},i=n.viewer.worldToCanvas(t);return[i.x,i.y]},n}return qe(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.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;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),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 at(a,s["stroke-color"],s["stroke-width"],o.rotation);break;case 7:n=new wt(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 pt(l[0],s["stroke-color"],s["stroke-width"],l[1],o.rotation,r&&s["fill-color"],!0)).close=!0;break;case 1:n=new ot(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 2:n=new tt(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 3:n=new ct(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}),c=this.worldToClient(o.position),d=this.viewer.clientToWorldPoint([c.x,c.y]);n=new bt(this.viewer.clientToWorldPoint([h.x,h.y]),decodeURIComponent(o.text),s["stroke-color"],s["font-size"],s["font-family"],o.rotation,null,d)}t.push(n)}return t},t.prototype.getCloudPoints=function(e){for(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,c=1;c<r.length;c+=2){var d=new window.THREE.Vector3,u=this.viewBoxToWorld({x:parseInt(r[c-1]),y:parseInt(r[c])},e.originSize);d.x=u.x,d.y=u.y,d.z=0,d.applyMatrix4(s);var g=this.worldToClient(d),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}(kt),Rt=Ke,Ot=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.absoluteBasePoint=null,n.screenBasePoint=null,n.zoomFactor={x:1,y:1},n.viewBox={width:1e3,height:1e3},n.viewer.clientToWorldPoint=function(e){var t=n.viewer.clientToWorld({x:e[0],y:e[1]});return[t.x,t.y]},n.viewer.worldToClientPoint=function(e){var t=n.viewer.worldToClient({x:e[0],y:e[1]});return[t.x,t.y]},n}return qe(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),"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 at(a,s["stroke-color"],s["stroke-width"],o.rotation);break;case 7:n=new wt(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 pt(l[0],s["stroke-color"],s["stroke-width"],l[1],o.rotation,r&&s["fill-color"]);break;case 1:n=new ot(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 2:n=new tt(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 3:n=new ct(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}),c=this.worldToClient(o.position),d=this.viewer.clientToWorldPoint([c.x,c.y]);n=new bt(this.viewer.clientToWorldPoint([h.x,h.y]),decodeURIComponent(o.text),s["stroke-color"],s["font-size"],s["font-family"],o.rotation,null,d)}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){for(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,c=1;c<r.length;c+=2){var d=new window.THREE.Vector3,u=this.viewBoxToWorld({x:parseInt(r[c-1]),y:parseInt(r[c])},e.originSize);d.x=u.x,d.y=u.y,d.z=0,d.applyMatrix4(s);var g=this.worldToClient(d),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==Rt.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}(kt);!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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),function(t){var i=t.viewer;this._opt=t,this.isShowAnnotation=!1,this.historyQueue=[],e.Bimface.Viewer.Viewer3D&&"Viewer3D"===i.viewerType?this._helper=new Vt(i,i._opt.domElement):e.Bimface.Viewer.Viewer2D&&i instanceof e.Bimface.Viewer.Viewer2D?(this.isViewer2D=!0,this._helper=new Ot(i,i._opt.domElement.querySelector(".bf-image"))):e.Bimface.Viewer.ViewerPDF&&i instanceof e.Bimface.Viewer.ViewerPDF?this._helper=new Lt(i,i._opt.domElement.querySelector(".bf-pdf-outer")):this._helper=new At(i,i._opt.domElement),this._helper.viewer.onSelectChange=e=>{this.onSelectChange(e)},this._helper.viewer.itemCompleted=e=>{this.itemCompleted(e)},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.viewer.onClick=e},itemCompleted(e){this._helper.viewer.itemCompleted=e},onDoubleClick(e){this._helper.viewer.onDoubleClick=e},enablePick(e){this._helper.viewer.isEnableAnnotationPick=e},setOperationMode(e){"[object Array]"===Object.prototype.toString.call(e)&&(this._helper.viewer.operationTypes=e)},restoreOperationMode(){this._helper.viewer.operationTypes=["Delete","Edit","Move","Rotate","Stretch"]},getAnnotationList:function(){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._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._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.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)}},n.AnnotationManager=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationToolbarConfig=function(){},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.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),e.Bimface.Plugins.Annotation.AnnotationToolbarEvent),o=function(t){var o=this._eventManager=new e.Web.Lang.EventManager,s=t.viewer,r=e.Bimface.Viewer.ViewerDrawing&&s instanceof e.Bimface.Viewer.ViewerDrawing;this.isDrawing=r;var a=e.Bimface.Viewer.ViewerPDF&&s instanceof e.Bimface.Viewer.ViewerPDF;this.isPDF=a;var l=i.create("div","bf-annotation bf-hide");this.domElement=l;var h=e.Bimface.Plugins.Annotation.AnnotationTypeOption,c=new e.Bimface.Plugins.Annotation.AnnotationManagerConfig,d=c.lineColor;c.viewer=s,c.windowAdaption=t.windowAdaption,c.annotationCallback=t.annotationCallback;var u=new e.Bimface.UI.Toolbar.ToolbarConfig;u.element=l,u.className="bf-toolbar bf-toolbar-annotation";var g=this.annotationToolbar=new e.Bimface.UI.Toolbar.Toolbar(u);this.annotationToolbar=g,r&&(c.annotationToolbar=g);var p=this._annotationManager=new e.Bimface.Plugins.Annotation.AnnotationManager(c);s.getDomElement().appendChild(l),l.addEventListener("mousedown",(function(e){e.stopPropagation()})),l.addEventListener("touchstart",(function(e){e.stopPropagation()})),l.addEventListener("touchmove",(function(e){e.stopPropagation()}));var f=new e.Bimface.UI.Toolbar.ToolbarConfig;f.element=l,f.className="bf-toolbar bf-toolbar-control";var m=new e.Bimface.UI.Toolbar.Toolbar(f),w=new e.Bimface.UI.Button.ButtonConfig;w.className="bf-button gld-bf-narrow ",w.title="箭头",r&&(w.id="arrow"),w.groupName="Annotation";var v=new e.Bimface.UI.Button.SingleButton(w);v.addEventListener("Click",(function(){p.setAnnotationType(h.Arrow),Y.show(),ie.hide()})),g.addControl(v);var y=new e.Bimface.UI.Button.ButtonConfig;y.className="bf-button gld-bf-n-cloud",y.title="云线框",y.groupName="Annotation";var b=new e.Bimface.UI.Button.SingleButton(y);b.addEventListener("Click",(function(){p.setAnnotationType(h.CloudRect),Y.show(),ie.hide()})),g.addControl(b);var x=new e.Bimface.UI.Button.ButtonConfig;x.className="bf-button gld-bf-ncloud",x.title="云线",x.groupName="Annotation";var E=new e.Bimface.UI.Button.SingleButton(x);E.addEventListener("Click",(function(){p.setAnnotationType(h.Cloud),Y.show(),ie.hide()})),g.addControl(E);var C=new e.Bimface.UI.Button.ButtonConfig;C.className="bf-button gld-bf-n-ployline",C.title="折线",C.groupName="Annotation";var M=new e.Bimface.UI.Button.SingleButton(C);M.addEventListener("Click",(function(){p.setAnnotationType(h.Polyline),Y.show(),ie.hide()})),g.addControl(M);var P=new e.Bimface.UI.Button.ButtonConfig;P.className="bf-button gld-bf-nrectangle",P.title="矩形",P.groupName="Annotation";var I=new e.Bimface.UI.Button.SingleButton(P);I.addEventListener("Click",(function(){p.setAnnotationType(h.Rectangle),Y.show(),ie.hide()})),g.addControl(I);var T=new e.Bimface.UI.Button.ButtonConfig;T.className="bf-button gld-bf-noval",T.title="椭圆",T.groupName="Annotation";var D=new e.Bimface.UI.Button.SingleButton(T);D.addEventListener("Click",(function(){p.setAnnotationType(h.Ellips),Y.show(),ie.hide()})),g.addControl(D);var S=new e.Bimface.UI.Button.ButtonConfig;S.className="bf-button gld-bf-mark",S.title="X",S.groupName="Annotation";var B=new e.Bimface.UI.Button.SingleButton(S);B.addEventListener("Click",(function(){p.setAnnotationType(h.Cross),Y.show(),ie.hide()})),g.addControl(B);var _=new e.Bimface.UI.Button.ButtonConfig;_.className="bf-button gld-bf-ntext",_.title="文字",_.groupName="Annotation";var k=new e.Bimface.UI.Button.SingleButton(_);k.addEventListener("Click",(function(){p.setAnnotationType(h.Text),Y.hide(),ie.show()})),g.addControl(k);var A=new e.Bimface.UI.Button.ButtonConfig;A.className="bf-combobox bf-color",A.title="颜色",r&&(A.id="color");var L=new e.Bimface.UI.Button.ComboBox(A),V=new e.Bimface.UI.Button.ButtonConfig;V.className="bf-button bf-color",V.title="红",r&&(V.id="red");var R=new e.Bimface.UI.Button.ComboBoxOptionButton(V);R.color=new e.Web.Graphics.Color(208,2,27,1);var O=i.create("div","bf-color-button");O.setCss({backgroundColor:`#${R.color.getHEX()}`}),R.setHtml(O.outerHTML),L.addControl(R);var N=new e.Bimface.UI.Button.ButtonConfig;N.className="bf-button bf-color",N.title="黄";var H=new e.Bimface.UI.Button.ComboBoxOptionButton(N);H.color=new e.Web.Graphics.Color(245,166,35,1);var z=i.create("div","bf-color-button");z.setCss({backgroundColor:`#${H.color.getHEX()}`}),H.setHtml(z.outerHTML),L.addControl(H);var W=new e.Bimface.UI.Button.ButtonConfig;W.className="bf-button bf-color",W.title="蓝";var U=new e.Bimface.UI.Button.ComboBoxOptionButton(W);U.color=new e.Web.Graphics.Color(74,144,226,1);var F=i.create("div","bf-color-button");F.setCss({backgroundColor:`#${U.color.getHEX()}`}),U.setHtml(F.outerHTML),L.addControl(U);var G=new e.Bimface.UI.Button.ButtonConfig;G.className="bf-button bf-color",G.title="绿";var j=new e.Bimface.UI.Button.ComboBoxOptionButton(G);j.color=new e.Web.Graphics.Color(126,211,33,1);var $=i.create("div","bf-color-button");$.setCss({backgroundColor:`#${j.color.getHEX()}`}),j.setHtml($.outerHTML),L.addControl(j),g.addControl(L),(X=new e.Bimface.UI.Button.ButtonConfig).className="bf-combobox",X.title="粗细",r&&(X.id="line");var X,Y=new e.Bimface.UI.Button.ComboBox(X);(X=new e.Bimface.UI.Button.ButtonConfig).className="bf-button bf-line",X.title="细",r&&(X.id="fine");var Z=new e.Bimface.UI.Button.ComboBoxOptionButton(X);Z.lineWidth=3;var q=i.create("div","bf-line-button");q.setCss({height:`${Z.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-Z.lineWidth)/2+"px 4px"}),Z.element.appendChild(q),Y.addControl(Z),X.title="中";var K=new e.Bimface.UI.Button.ComboBoxOptionButton(X);K.lineWidth=6;var J=i.create("div","bf-line-button");J.setCss({height:`${K.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-K.lineWidth)/2+"px 4px"}),K.element.appendChild(J),Y.addControl(K),X.title="粗";var Q=new e.Bimface.UI.Button.ComboBoxOptionButton(X);Q.lineWidth=10;var ee=i.create("div","bf-line-button");ee.setCss({height:`${Q.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-Q.lineWidth)/2+"px 4px"}),Q.element.appendChild(ee),Y.addControl(Q),L.addEventListener("Change",(function(e){p.setLineColor(e.color);(d=e.color).getHEX();q.setCss({height:`${Z.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-Z.lineWidth)/2+"px 4px"}),J.setCss({height:`${K.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-K.lineWidth)/2+"px 4px"}),ee.setCss({height:`${Q.lineWidth}px`,backgroundColor:`#${d.getHEX()}`,margin:(32-Q.lineWidth)/2+"px 4px"});var t=Y.getCurrentControl();Y.setSelectedControlById(t.getId())})),Y.addEventListener("Change",(function(e){p.setLineWidth(e.lineWidth)})),g.addControl(Y);var te=new e.Bimface.UI.Button.ButtonConfig;te.className="bf-combobox bf-font-button",te.title="字号";var ie=new e.Bimface.UI.Button.ComboBox(te),ne=new e.Bimface.UI.Button.ButtonConfig;ne.className="bf-button bf-size",ne.title="14";var oe=new e.Bimface.UI.Button.ComboBoxOptionButton(ne);oe.fontSize=14,oe.setHtml("14"),ie.addControl(oe),ne.title="18";var se=new e.Bimface.UI.Button.ComboBoxOptionButton(ne);se.fontSize=18,se.setHtml("18"),ie.addControl(se),ne.title="24";var re=new e.Bimface.UI.Button.ComboBoxOptionButton(ne);re.fontSize=24,re.setHtml("24"),ie.addControl(re),ie.addEventListener("Change",(function(e){p.setFontSize(e.fontSize)})),ie.hide(),g.addControl(ie);var ae=new e.Bimface.UI.Button.ButtonConfig;ae.className="bf-save",ae.title=BimfaceLanguage.bf_general_save;var le=new e.Bimface.UI.Button.SingleButton(ae);le.setHtml(BimfaceLanguage.bf_general_save),le.addEventListener("Click",(function(){r||a?o.fireEvent(n.Saved,{annotationList:p.getAnnotationList()}):o.fireEvent(n.Saved,{annotationList:p.getAnnotationList(),state:p.getCurrentState()}),p.endDrawing(),l.addClass("bf-hide")})),m.addControl(le);var he=new e.Bimface.UI.Button.ButtonConfig;he.className="bf-cancel",he.title=BimfaceLanguage.bf_general_cancel;var ce=new e.Bimface.UI.Button.SingleButton(he);ce.setHtml(BimfaceLanguage.bf_general_cancel),ce.addEventListener("Click",(function(){p.endDrawing(),o.fireEvent(n.Cancelled),l.addClass("bf-hide")})),m.addControl(ce),this.getEventManager=function(){return o}};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.domElement.removeClass("bf-hide")},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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),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 b.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 b.View3dAdapter(i);i.addCallbacks("render",this._renderCallback)}this._tagHelper=new b.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 Nt{constructor(){}}Nt.ifExploded=function(e,t,i){let n=Glodon.Bimface.Viewer.ViewerDrawing&&e instanceof Glodon.Bimface.Viewer.ViewerDrawing,o=Glodon.Bimface.Viewer.ViewerDrawingSet&&e instanceof Glodon.Bimface.Viewer.ViewerDrawingSet;if(n||o||t instanceof Glodon.Bimface.Plugins.Drawable.ClusterTag)return t;const s=e.getViewer(),r=s.modelManager.explosionManager;let a=t.modelId;if(i&&t.layerId)a=e.getLayerManager().getLayer(t.layerId).modelId.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),c=s.modelManager.getModel(a).modelExplosion;let d=()=>{if(h&&r.isExploded(a)){let e=t.worldPosition||t.getOriginalPosition(),i=c.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,d();{if(i)return t;const e=s.modelManager.getModel("ExtrudeBodyManager");return e&&e.getNode(t._config.objectId)&&(t._isBindRoom=!0),t}}return d()},Nt.getExplodedOffsetByLevelName=function(e,t){for(const i of e)if(i.name===t)return i.explodedHeight-i.elevation;return 0},Nt.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}}},Nt.attachExplosionOffset=function(e,t,i){if(!i.worldPosition&&!i.position)return;const n=i._config.objectId;let o=null;if(n){o=e.modelManager.getModel(i.modelId).modelExplosion.getExplosionTranslationByObjId(n),i.explosionOffset.x+=o.x,i.explosionOffset.y+=o.y,i.explosionOffset.z+=o.z}else o=this.getCenterExplosionOffset(e,t,i),i.explosionOffset.x=o.x,i.explosionOffset.y=o.y,i.explosionOffset.z=o.z},Nt.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});r.prototype={draw:function(e){},onClick:function(e){o.send(n,"onClick"),this._onclick=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]},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.forceHide=!0},show:function(){o.send(n,"show"),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={};i[o]=!0;let s=e.modelManager.getBoundingBoxByIds(i),r=this.assoiatedComponentBbox,a=s;if(r){let e=a.getCenter().clone();e.sub(r.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=a.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;let n=e.getViewer(),o={};o[i]=!0,n.modelManager.getBoundingBoxByIds(o).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}},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};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(t){o.call(this,t);let i=this;this.viewer=t.viewer,this._isDragging=!1,this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&this.viewer instanceof e.Bimface.Viewer.ViewerGIS;let n=s.create("img","bf-drawable-image");var r;n.draggable=!1,n.src=t.src,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,n.style.opacity=`${t.opacity}`,n.style.transform=`rotate(${t.angle}deg)`,this._config=t,this._domElement=n,this.clientPosition={};t.draggable&&s.drag({element:n,cursor:"pointer",end:function(e){i._isDragging=!1;var t,n=i.viewer,o="Viewer3D"===n.getViewerType(),s={x:e.x-r.x+i.clientPosition.x,y:e.y-r.y+i.clientPosition.y};if(o){var a=n.pickByPoint(s);if(!a||!a.objectId)return void i.update();if(a.objectId){i._config.objectId=a.objectId;let e=n.getViewer().getComponentInfoByUserId(a.objectId);i.levelName=e&&e.userData&&e.userData.levelName,i.setInitialExplosionInfo(n),i.clearExplosionOffset(),i.needForceUpdate=!0}t=a.worldPosition}else if(i._isViewerGIS){let e=n.getDomElement().getBoundingClientRect(),t=n.getViewer().pickByPoint({x:s.x+e.left,y:s.y+e.top});if(!t||!t.meshId)return void i.update();t.meshId&&(i._config.objectId=t.meshId),i.worldPosition=t.worldPosition}else t=n.clientToWorld(s);t?(i.worldPosition=t,i.update(),i._onenddrag&&i._onenddrag(i)):i.update()},start:function(e){r=e},move:function(){i._isDragging=!0}}),n.addEventListener("mouseup",(function(e){var t=e||window.event;"0"==t.button&&i._onclick&&(!i._isDragging||r.x==t.clientX&&r.y==t.clientY)&&i._onclick(i)})),n.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)})),n.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation()}))};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.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},getSrc:function(){return this._config.src},setSrc:function(e){i.send(t,"setSrc"),this._config.src=e,this._domElement.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._domElement.style.transform=`rotate(${e}deg)`}},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};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=e.Bimface.Viewer.ViewerDrawing&&t.viewer instanceof e.Bimface.Viewer.ViewerDrawing,a=r.create("div","bf-drawable-text");a.style.width=`${t.width}px`,a.style.height=`${t.height}px`;let l=r.create("div","bf-drawable-contentwrap");var h;a.appendChild(l),this._domElement=a,this.name="customItem",this._contentElement=l,this._config=t,this.clientPosition={},this.setContent(t.content);let c=r.create("div","bf-tooltip");c.style.display="none",c.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${t.tooltip}</span></div></div>`,c.style.left=`${t.width}px`,c.style.top=`-${t.height}px`;var d=t.tipCSS;for(var u in d)c.style[u]=d[u];this.tipElement=c,a.appendChild(c);t.draggable&&r.drag({element:a,cursor:"pointer",end:function(t){i._isDragging=!1;var n,s=i.viewer,r=e.Bimface.Viewer.Viewer3D&&"Viewer3D"===s.viewerType,a=e.Bimface.Viewer.ViewerGIS&&s instanceof e.Bimface.Viewer.ViewerGIS,l={x:t.x-h.x+i.clientPosition.x,y:t.y-h.y+i.clientPosition.y};if(r){let e=s.getDomElement().getBoundingClientRect(),t=s.pickByPoint({x:l.x+e.left,y:l.y+e.top});if(!t||!t.objectId)return void i.update();if(t.objectId){i._config.objectId=t.objectId;let e=s.getViewer().getComponentInfoByUserId(t.objectId);i.levelName=e&&e.userData&&e.userData.levelName,i.setInitialExplosionInfo(s),i.clearExplosionOffset(),i.needForceUpdate=!0}n=t.worldPosition}else if(a){let e=s.getDomElement().getBoundingClientRect(),t=s.getViewer().pickByPoint({x:l.x+e.left,y:l.y+e.top});if(!t||!t.meshId)return void i.update();t.meshId&&(i._config.objectId=t.meshId),n=t.worldPosition}else if(o){var c=s.getViewer().toWorldPoint([l.x,l.y]);n={x:c[0],y:c[1]}}else n=s.clientToWorld(l);n?(i.worldPosition=n,i.update(),i._onenddrag&&i._onenddrag(i)):i.update()},start:function(e){h=e},move:function(){i._isDragging=!0}}),a.style.width=`${t.width}px`,a.style.height=`${t.height}px`,a.style.opacity=`${t.opacity}`,a.addEventListener("mouseover",(function(e){i.tipElement&&i.tipElement.querySelector("span").innerText.length>0&&(i.tipElement.style.display="block")})),a.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),a.addEventListener("keydown",(function(e){e.stopPropagation()})),n&&a.addEventListener("mouseup",(function(e){var t=e||window.event;"0"==t.button&&i._onclick&&(!i._isDragging||h.x==t.clientX&&h.y==t.clientY)&&i._onclick(i)})),a.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)})),a.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation()})),a.addEventListener("touchstart",(function(e){(e||window.event).stopPropagation()})),a.addEventListener("touchmove",(function(e){(e||window.event).stopPropagation()})),!n&&a.addEventListener("touchend",(function(e){var n=e||window.event;n.stopPropagation(),i._onclick&&(!t.draggable||h.x==n.changedTouches[0].clientX&&h.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`},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 e={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:"1px",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};return Object.assign({},i,e)}}(),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"),c=s.createNS("circle","bf-drawable-lead-point"),d=s.createNS("g","bf-drawable-group"),u=t.viewer;this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&u instanceof e.Bimface.Viewer.ViewerGIS,i._text=t.text,this.name="LeadLabel",this.isAssociateComponentHide=!1,r.setCss(t.containerCss),a.innerText=i._text.replace(/\n/g," "),r.style.width=parseFloat(t.width)+"px",r.style.height=parseFloat(t.height)+"px";let g=Math.trunc((t.height-8)/18);var p;a.style.webkitLineClamp=g||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,c.setAttribute("r",t.pointCss.radius),c.style.fill=t.pointCss.backgroundColor,c.setAttribute("stroke-width",t.pointCss.borderWidth),c.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),c.setAttribute("cx",0),c.setAttribute("cy",18-t.offset.y),this._isDragging=!1;t.draggable&&s.drag({element:r,cursor:"pointer",start:function(e){p=e},move:function(e){i._isDragging=!0;var n=e.x-p.x+i.clientPosition.x,o=e.y-p.y+i.clientPosition.y;d.setAttribute("transform",`translate(${n},${o+t.offset.y-18})`)},end:function(e){i._isDragging=!1;var t="Viewer3D"===u.viewerType,n=u.getDomElement().getBoundingClientRect(),o={x:e.x-p.x+i.clientPosition.x+n.left,y:e.y-p.y+i.clientPosition.y+n.top};if(t){var s=u.pickByPoint(o);if(s){if(i.setWorldPosition(s.worldPosition),i.bindComponentById(s.objectId,s.modelId),s.objectId){i._config.objectId=s.objectId,i._config.modelId=s.modelId;let e=u.getViewer().getComponentInfoByUserId(s.objectId,s.modelId);i.levelName=e&&e.userData&&e.userData.levelName,i.needForceUpdate=!0}i.setInitialExplosionInfo(u),i.clearExplosionOffset()}u.render()}else if(i._isViewerGIS){let e=u.getDomElement().getBoundingClientRect(),t=u.getViewer().pickByPoint({x:o.x+e.left,y:o.y+e.top});if(!t||!t.meshId)return void i.update();t.meshId&&(i._config.objectId=t.meshId),i.worldPosition=t.worldPosition}else{var r=u.clientToWorld(o);r&&i.setWorldPosition(r),u.update()}i._dragEnd&&i._dragEnd()}}),r.addEventListener("mousedown",(function(e){(e=e||event).stopPropagation()})),n&&r.addEventListener("click",(function(e){(e=e||event).stopPropagation(),i._click&&i._click(i)})),!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)})),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")})),d.appendChild(h),d.appendChild(l),d.appendChild(c),i._objectId=t.objectId,i._modelId=t.modelId,i._container=r,i._domTextArea=a,i._svgGroup=d,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,r=this._config.viewer,a=this._objectId,l=this._modelId;if(r&&a&&!this._isViewerGIS){var h=r.getModel(l).getComponentStatus(a);if("hidden"==h||"translucent"==h)return this.hide(),void(this.isAssociateComponentHide=!0);this.isAssociateComponentHide&&(this.show(),this.isAssociateComponentHide=!1)}!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.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._container.style.display="none",this._svgGroup.style.display="none"},show:function(){i.send(t,"show"),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.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"))},resetClientPosition:function(e){const t=this._container,i=this._config;"Viewer3D"!==i.viewer.viewerType&&"ViewerGIS"!==i.viewer.viewerType||(e=i.viewer.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()}}),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})}}();
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var Ht=function(e,t){return(Ht=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function zt(e,t){function i(){this.constructor=e}Ht(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Wt=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||e.apply(n,o),clearTimeout(i),i=setTimeout((function(){i=void 0}),t)}},e}(),Ut=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 Wt.getContainerOffsetToClient(e||this.domContainer)},e}();window.Glodon.Bimface.Marker={};var Ft=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 zt(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}(Ut);window.Glodon.Bimface.Marker.View3dAdapter=Ft;var Gt=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.vfData,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 zt(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=new window.THREE.Vector3(e.x,e.y,e.z),i=this.minimap.getAxisGridBox2D();this.worldToNormalizedPoint(t,i);var n=this.getDomContainerBounds(),o={width:n.width/2,height:n.height/2};return this.normalizedPointToScreen(t,o),t.x+=o.width,t.y+=o.height,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}(Ut);window.Glodon.Bimface.Marker.View2dAdapter=Gt;var jt=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 zt(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.getMinimap().getDrawingContentsBbox(),i=this.getDomContainerBounds(),n=Math.abs(t.max.x-t.min.x),o=Math.abs(t.max.y-t.min.y);return{x:i.height*(e.x-t.min.x)/n+(i.width-i.height)/2,y:i.height*(t.max.y-e.y)/o}},t}(Ut);window.Glodon.Bimface.Marker.DrawingdAdapter=jt;var $t,Xt=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.onKeyUpBinded=this.onKeyUp.bind(this)}return e.prototype.addDomEventListeners=function(){this.shape.addEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.addEventListener("touchstart",this.onMouseDownBinded,!0),window.addEventListener("keyup",this.onKeyUpBinded)},e.prototype.removeDomEventListeners=function(){this.shape.removeEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.removeEventListener("touchstart",this.onMouseDownBinded,!0),window.removeEventListener("keyup",this.onKeyUpBinded)},e.prototype.onMouseDown=function(e){e.preventDefault(),e.stopPropagation(),this.select(e.button)},e.prototype.onKeyUp=function(e){switch(e.keyCode){case 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=Wt.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=Wt.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}(),Yt=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=Xt.shapeTypes.BUBBLE,n.createShape(),n.addDomEventListeners(),n}return zt(t,e),t}(Xt),Zt=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}(),qt=function(e){function t(t,i,n,o){var s=e.call(this,t,i)||this;return s.shapeType=Xt.shapeTypes.COMMON,s.pictureSize=o||{width:20,height:20},s.createShape(n),s.addDomEventListeners(),s}return zt(t,e),t.prototype.createShape=function(e){this.shape=Zt.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}(Xt),Kt=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=Xt.shapeTypes.COMMON,n.createShape(),n.addDomEventListeners(),n}return zt(t,e),t.prototype.createShape=function(){this.shape=Zt.makeFlag()},t}(Xt),Jt=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.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&&(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=Zt.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=Zt.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.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||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.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=Xt.getDefaultStyle();t["fill-color"]=this.getMarkerColor(e.shapeType,e.state);var i,n=e.id||this.generateMarkerId(),o=Xt.shapeTypes;switch(e.shapeType){case o.BUBBLE:i=new Yt(n,this);break;case o.COMMON:(i=new qt(n,this,e.state,e.size)).setRatio(this.markersRatioW,this.markersRatioH),i.reset();break;case o.FLAG:default:i=new Kt(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,c=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}};c.max.x=n.boundingBox.max.x,c.max.y=n.boundingBox.max.y,c.max.z=n.boundingBox.max.z,c.min.x=n.boundingBox.min.x,c.min.y=n.boundingBox.min.y,c.min.z=n.boundingBox.min.z;var d={id:s,userId:r,position:h,boundingBox:c,shapeType:a,state:l};this.createMarker(d)}},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.setMarkerRightClickCallback=function(e){this.markerRightClickCallback=e},e.prototype.zoomAndPanMarkerById=function(e,t,i,n){var o=this.mapGroupMarkers,s=this.svg.getAttribute("width"),r=this.svg.getAttribute("height"),a=new THREE.Vector2(.5*s,.5*r);for(var l in o){var h=o[l];if(h instanceof Array){var c=h.getObjectByAttribute("id",e);if(c){var d=c.getClientPosition(),u=c.pictureSize.width*c.ratioW,g=c.pictureSize.height*c.ratioH,p=new THREE.Vector2(d.x,d.y).clone().sub(a);p.multiplyScalar(n);var f="translate("+(a.x+p.x-.5*u+t)+","+(a.y+p.y-.5*g+i)+")";c.shape.setAttribute("transform",f)}}}},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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");let s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");var r=function(t){o.call(this,t);var i=this,n=this._viewer=t.viewer.getViewer();if(this.miniTagConfig=t,this._config=t,i.worldPosition=t.worldPosition,this._renderCallback=function(){i.resize()},"ViewerDrawing"==t.viewer.viewerType){this.mapHelper=t.minimap;var s=new e.Bimface.Marker.DrawingdAdapter(this.mapHelper,t.viewer)}else if(t.minimap){this.mapHelper=t.minimap;s=new e.Bimface.Marker.View2dAdapter(this.mapHelper,n);this.mapHelper.setMinimapResizeCallback((function(e){s.resize(e),r._tagHelper.updateGroupName(),r._tagHelper.updateDomContainer(),r._tagHelper.resize(e),r._tagHelper.updateByGroup()})),this.mapHelper.setPlaneChangedCallback((function(){r._tagHelper.updateGroupName(),r._tagHelper.updateByGroup()}));const o={Floor_Plane_Changed_For_Panel:3001,ZOOM_MOUSE_WHEEL:6e3,PAN_MOUSE_MOVE:7e3};this.mapHelper.viewerFloor.addEventListener(o.ZOOM_MOUSE_WHEEL,(function(e){var t=e.data;i.zoomAndPan(t.offsetX,t.offsetY,t.zoomFactor)})),this.mapHelper.viewerFloor.addEventListener(o.PAN_MOUSE_MOVE,(function(e){var t=e.data;i.zoomAndPan(t.offsetX,t.offsetY,t.zoomFactor)})),this.mapHelper.viewerFloor.addEventListener(o.Floor_Plane_Changed_For_Panel,(function(e){var t=i.mapHelper.viewerFloor,n=t.getPanOffset();i.zoomAndPan(n.x,n.y,t.vfData.zoomFactor)}))}else{s=new e.Bimface.Marker.View3dAdapter(n);n.addCallbacks("render",this._renderCallback)}null==r._tagHelper&&(r._tagHelper=new Jt(s),r._tagHelper.disableInteractions(!0)),a()},a=function(){r._tagHelper.isInitialized()||r._tagHelper.init()},l=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,{draw:function(){var e=this.miniTagConfig;!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:e.objectId,worldPosition:e.worldPosition,floorList:e.floorList},{shape:2,image:e.src,size:{width:e.width,height:e.height}});var t=this.mapHelper.viewerFloor;if(t){var i=t.getPanOffset();this.zoomAndPan(i.x,i.y,t.vfData.zoomFactor)}},show:function(){i.send(t,"show"),r._tagHelper.setVisible(this.id,!0)},hide:function(){i.send(t,"hide"),r._tagHelper.setVisible(this.id,!1)},getFloorList:function(){return this.miniTagConfig.floorList},setFloorList:function(e){i.send(t,"setFloorList"),this.miniTagConfig.floorList=e,l(this.id),this.draw()},getHeight:function(){return this.miniTagConfig.height},setHeight:function(e){i.send(t,"setHeight"),this.miniTagConfig.height=e,l(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;l(this.id),n.objectId=e,this.draw()},getSrc:function(){return this.miniTagConfig.src},setSrc:function(e){i.send(t,"setSrc"),this.miniTagConfig.src=e,l(this.id),this.draw()},getWidth:function(){return this.miniTagConfig.width},setWidth:function(e){i.send(t,"setWidth"),this.miniTagConfig.width=e,l(this.id),this.draw()},getWorldPosition:function(){return this.miniTagConfig.worldPosition},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.miniTagConfig.worldPosition=e,l(this.id),this.draw()},onClick:function(e){i.send(t,"onClick"),r._tagHelper.setMarkerClickCallback(e)},onRightClick:function(e){i.send(t,"onRightClick"),r._tagHelper.setMarkerRightClickCallback(e)},onEndDrag:function(e){i.send(t,"onEndDrag")},zoomAndPan:function(e,t,i){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,t.onClickCallback&&t.onClickCallback({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox})}))},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;e<=99?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;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;this.bIsEnableMinitagUpdate=!0,this.boxMap={},i._enableRender=t.enableRender,n.addEventListener("Rendered",(function(e){i.bIsEnableMinitagUpdate=!1,i.update(e),i.bIsEnableMinitagUpdate=!0}));let c=()=>{let t=n.getViewer();t.registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(i=>{let n=this.getAllItems();for(let o=0,s=n.length;o<s;o++)n[o]instanceof e.Bimface.Plugins.Drawable.MiniTag||Nt.attachExplosionOffset(t,i.extent,n[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 c=0;c<s;c++){let e=l[c],t=l[c+1],i=l[c-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 d=n.getLayerManager();let u=this._items;for(let e=0,t=u.length;e<t;e++){if(!u[e].getWorldPosition())continue;const t=d.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)})),c()):(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 c=0;c<o;c++){let t=e.floorInfos[c],n=e.floorInfos[c+1],s=e.floorInfos[c-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)})),c());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}}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)o.push(n),this.update();else{let e=Nt.ifExploded(s,n,this._isViewerGIS);e&&("Viewer3D"===this._viewer.getViewerType()&&e.setInitialExplosionInfo(this._viewer),o.push(e),this._enableRender&&this.update())}}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){let e=Nt.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer)}else for(const t of e)this._items.push(t);this._enableRender&&this.update()}clear(){i.send(t,"clear"),this._items=[],this._context.rootDomElement.innerHTML="",this._context.domContainer=null,this._context.svgContainer=null,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=Nt.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.section&&!this.section.isIncluded(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 c="default";i>=o&&(c="mini"),n.clientPosition=t[i].clientPosition,t[i]instanceof e.Bimface.Plugins.Drawable.MiniTag&&0==this.bIsEnableMinitagUpdate||t[i].draw(n,c)}}}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}},$t=e.Bimface.Data.StatisticsDataManager.getInstance(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster").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}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){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){for(const i of this.clusterItems)this.isViewer3D&&0===i.calcClusterLevel()?i.clearClusterTags():((e||i.isNeedClustering())&&i.clustering(t),i.updateClusterTags(this.enableAnimation))}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}},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 Qt{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),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._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 ei{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 ti{constructor(){}}ti.time=300,ti.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?ti.ZoomInPlay(t,i,n,o,a):ti.ZoomOutPlay(t,i,n,o,a,l))},ti.getCluster=function(e,t){for(const i of e)if(i.id===t)return i},ti.getClusterTag=function(e,t){for(const i of e)if(i.clusterBbox.id===t)return i},ti.getIndices=function(e){let t=[];for(const i of e.points)t.push(i.index);return t},ti.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.clientPosition},ti.ZoomInPlay=function(e,t,i,n,o,s){for(const n of i){if(n.id===n.parent)continue;const i=n.parent,s=ti.getClusterTag(t,i);for(const r of t)if(r.clusterBbox.id===i){const t=ti.getClusterTag(e,n.id),i=r.clusterBbox.center;let a=null;if(t){a=t.clusterBbox.center,ti.CreateZoomAnimation(t,s,i,a,!0);continue}const l=ti.getIndices(n);for(const e of l){let t=o[e];a=ti.getEndClientPosition(t),a&&(t.setContainerVisible(!0),ti.CreateZoomAnimation(t,s,i,a,!0))}}}},ti.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(),c=h-16,d=0,u=()=>{const o=requestAnimationFrame(u);if(d>=1)return d=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)})(d),h=(new Date).valueOf();const a=h-c;c=h,d+=a/this.time};u()},ti.ZoomOutPlay=function(e,t,i,n,o,s){for(const r of i){const i=r.children;if(0===i.length)continue;const a=ti.getClusterTag(e,r.id);if(a)for(const e of i){const i=ti.getClusterTag(t,e),l=r.center;let h=null;if(i){h=i.clusterBbox.center,ti.CreateZoomOutAnimation(i,a,h,l,s);continue}const c=ti.getCluster(n,e),d=ti.getIndices(c);for(const e of d){let t=o[e];h=ti.getEndClientPosition(t),h&&ti.CreateItemZoomOutAnimation(t,a,h,l,s)}}}},ti.CreateZoomOutAnimation=function(e,t,i,n,o){const s=e.getContainer();o._context.rootDomElement.appendChild(s),ti.CreateZoomAnimation(e,t,i,n,!1,(()=>{t.show(),s.remove()}))},ti.CreateItemZoomOutAnimation=function(e,t,i,n,o){e.setContainerVisible(!0),e.isInAnimation=!0,ti.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.viewer=i.viewer,this.isViewer3D="Viewer3D"===i.viewer.getViewerType()||"ViewerGIS"===i.viewer.getViewerType(),this.impl=this.isViewer3D?new Qt(i):new ei(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}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}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)}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,this.onClickCallback&&o.onClick(this.onClickCallback),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(),this._getContainer().update();const i={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};ti.Play(i),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}},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"});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"});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 ii{}ii.xmlns="http://www.w3.org/2000/svg",ii.makeCircle=function(e){var t=document.createElementNS(ii.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},ii.makeConcentricCircle=function(e){var t=document.createElementNS(ii.xmlns,"g"),i=document.createElementNS(ii.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},ii.makeLine=function(e){var t=document.createElementNS(ii.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},ii.makeDashLine=function(e){let t=ii.makeLine(e);return t.setAttribute("stroke-dasharray",e.dashArray||"10 8"),t},ii.makePath=function(e){var t=document.createElementNS(ii.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},ii.makePolyline=function(e){var t=document.createElementNS(ii.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},ii.makePolygon=function(e){var t=document.createElementNS(ii.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},ii.calcPolylinePoints=function(e){for(var t="",i=0;i<e.length;i++)t+=e[i].x+","+e[i].y+" ";return t},ii.makeRectangle=function(e){var t=document.createElementNS(ii.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},ii.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=ii.makeDefs();return n.appendChild(t),n},ii.makeText=function(e){var t=document.createElementNS(ii.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(ii.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},ii.makeDefs=function(){return document.createElementNS(this.xmlns,"defs")},ii.measureText=function(e,t='14px "Microsoft YaHei'){var i=document.createElement("canvas").getContext("2d");return i.font=t,i.measureText(e).width},ii.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)},ii.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},ii.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},ii.calcSpatialArea=function(e){let t=new THREE.Vector3,i=new THREE.Vector3;const n=e.length;if(n<3)return 0;let o=0,s=new THREE.Triangle;for(let r=2;r<n;r++){let n=s.clone().set(e[r-1],e[r],e[0]),a=n.getArea();if(r>2){let o=s.getNormal(t),l=n.getNormal(i),h=o.angleTo(l);if((Math.abs(h-3.1415)<2e-4||Math.abs(h)<2e-4)&&(s.containsPoint(e[r])||n.containsPoint(e[r-2]))){let e=s.getArea();a=Math.abs(a-e)-e}}o+=a,s.copy(n)}return o},ii.calcProjectedArea=function(e){let t=[];return e.forEach((e=>{let i=e.clone();i.z=0,t.push(i)})),this.calcSpatialArea(t)},ii.cutFillAnalysis=null,ii.calcSurfaceArea=function(e,t){let i=0;if(e.length<3||!t)return this.console.warn("Parameter points or viewer is invalid."),i;let n=t.getViewer(),o=e.map((e=>n.worldToDrawing(e)));return ii.cutFillAnalysis?ii.cutFillAnalysis.effectOpt({boundary:o}):ii.cutFillAnalysis=new CLOUD.CutFillMeasure({boundary:o,viewer:t}),i=ii.cutFillAnalysis.getTotalSuperficialArea(),i};class ni{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=>ii.distanceToSegment(e,i.start,i.end)<=t))}}class oi extends ni{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=ii.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=ii.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 c=ii.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(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"Elevation"!==this.type&&(i=ii.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=ii.measureText(e)),{offsetRect:o,offsetText:s,width:i+=10}}}class si extends ni{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=ii.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=ii.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});this.notationSelected.push(h);let c=ii.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#A4A8AE",fontsize:14,content:t});if(this.notationUnselected.push(c),this.svgGroup=[],this.type==Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Position){var d=ii.makeRectangle({x:s.offsetArrow.x,y:s.offsetArrow.y,width:7,height:7,radius:0,fillColor:this.defaultColor,fillOpacity:this.annotationStyle.fillOpacity});d.setAttribute("transform",`rotate(45 ${s.offsetArrow.x} ${s.offsetArrow.y})`),this.svgGroup.push(d)}return this.svgGroup.push(r),this.svgGroup.push(c),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=ii.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=ii.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=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 o=i.createNS("circle","bf-measure-handle");o.setAttribute("stroke-width",0),o.setAttribute("r",t.width),o.setAttribute("fill",n.getRGB()),o.style.fill=n.getRGB();let s=i.createNS("line","bf-measure-line");s.style.strokeWidth=2,s.style.stroke=n.getRGB();let r=i.createNS("polygon","bf-measure-rect");r.setAttribute("fill",n.getRGBA()),r.setAttribute("stroke",n.getRGB()),r.setAttribute("stroke-width",1);var a=i.createNS("path","bf-measure-foot");a.setAttribute("fill","none"),a.setAttribute("stroke",n.getRGB()),a.setAttribute("stroke-width",2),this.hoverFoot=a,this.hoverPoint=o,this.hoverLine=s,this.hoverPanel=r,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 si(this.measureType):new oi(this.measureType),this.isReserverd=!1,this.hoverPositionUpdated=!1};o.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=ii.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this._svg.appendChild(t)},drawTerminalPoint(e){let t=ii.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.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",e.hoverPosition.x),t.setAttribute("cy",e.hoverPosition.y),e.svg.appendChild(t);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-12} v 12 h 12 M ${t},${i-7} h 7 v 7`),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 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){let e=this.stretchOnDirection(s[0],s[1],o.width),t=this.stretchOnDirection(s[2],s[3],o.width);s=e.concat(t)}if(1!=h){let e=this.stretchOnDirection(s[0],s[3],o.height),t=this.stretchOnDirection(s[1],s[2],o.height);s=[e[0],t[0],t[1],e[1]]}let c="";for(let e=0;e<s.length;e++)c+=s[e].x+",",c+=s[e].y+" ";n.setAttribute("points",c),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=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=(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 ri{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(),c=n.create("span","bf-measure-number");c.style.backgroundColor=e.color.getRGBA(),this.points=[o,s,r],this.lines=[l,h],this.angleLine=a,this.text=c});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 ri.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 c=this.stretchOnDirection(s[0],s[1],o.width),d=this.stretchOnDirection(s[2],s[3],o.width);s=c.concat(d)}if(1!=h){c=this.stretchOnDirection(s[0],s[3],o.height),d=this.stretchOnDirection(s[1],s[2],o.height);s=[c[0],d[0],d[1],c[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 ai=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),li=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class hi extends ai.MeasureItem{constructor(t){super(t),this.opt=t,this.maxPointsNum=1;const i=new e.Web.Graphics.Color(17,218,183,.2),n=li.createNS("circle","bf-measure-handle");n.setAttribute("r",t.width),n.setAttribute("fill",i.getRGB()),n.style.fill=i.getRGB();const o=li.createNS("line","bf-measure-line");o.style.strokeWidth=2,o.style.stroke=i.getRGB();const s=li.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={};["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.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}),r.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(e){let t=this.getPoints();if(0===t.length)return;let{point:i}=t[0];this._result.pointInfo=t[0];const n=i.clone().add(e.clone().multiplyScalar(1)),o=(e,t)=>{const i=this.viewer.getComponentsByRaycaster(n,t),s=this.viewer.getComponentsByRaycaster(n,t.clone().negate());return this._result[e]=i.length>0&&s.length>0?{enable:!0,direction:t,positiveIntersects:i,negativeIntersects:s,positiveIndex:0,negativeIndex:0}:{enable:!1},this.nextButtons[`positive_${e}`].position=i.length>1?i[0].position:void 0,"Z"!==e&&(this.nextButtons[`negative_${e}`].position=s.length>1?s[0].position:void 0),o};let s,r,a;return Math.abs(1-Math.abs(e.z))<.001?(s=new THREE.Vector3(1,0,0),r=new THREE.Vector3(0,1,0),a=new THREE.Vector3(0,0,1)):(s=e.clone().cross(new THREE.Vector3(0,0,1)),s.x<0&&s.negate(),r=e.clone().cross(s),r.y<0&&r.negate(),a=e),o("X",s)("Y",r)("Z",a),this.showDragButton(i),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(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.opt.measure.measureByInfo(this.getMeasureResult()),this.nextButtons[e].position=n[o].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))}setButtonPosition(e,t,i){e.style.top=`${i}px`,e.style.left=`${t}px`}}ai.MeasureLaserClearDistanceItem=hi;class ci{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="ViewerGIS"===this.viewer.getViewerType()?new si(i):new oi(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=[];var o=this.viewer.getViewer(),s=this.viewer.getDomElement().getBoundingClientRect(),r=o.worldPointsToClient(e,t);if(r){e=new n(r.start.x-s.left,r.start.y-s.top),t=new n(r.end.x-s.left,r.end.y-s.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),c=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),-t);return n.push({start:h,end:c}),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(ii.distanceToSegment(e,this.hitTestSegments[i],this.hitTestSegments[i+1])<=t)return!0}return!1}}class di extends ci{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult=t.distance,this.selectElements=[],this.unSelectElements=[],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.calAuxLines(),i=this.calcTerminalLines(e,Math.PI/2,6.5);this.attachSingleLine(e),this.attachTerminalLines(i);this.attachAuxLines(t,["#CC021B","#7CCF21","#4A90E2"]),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(n);this.viewer.isInViewFrustum(n)&&(this.attachNotation([o,o]),this.notation.dropShadow(this.filterUrl),this.unselect())}attachTerminalPoints(e){for(const t of e){let e=ii.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=ii.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=ii.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=ii.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.id);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=[e[0],i,n,e[1]],r=this.viewer.getViewer(),a=0;a<s.length-1;a++){var l=r.worldPointsToClient(s[a],s[a+1]);if(l)l.start.x-=t.left,l.start.y-=t.top,l.end.x-=t.left,l.end.y-=t.top;else{l={start:{x:-1,y:-1},end:{x:-1,y:-1}}}o.push(l)}return o}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=ri.formatDistance(t,this.measureParams);return i+=ri.getPostFix(e,!1),i.split(",").join("")}}class ui extends ci{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();this.hitTestSegments=e;for(let t=0;t<e.length-1;t++){let i=ii.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=ii.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=ii.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 ri.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}}class gi extends ci{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.elevationPoint=t.points[0],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=ii.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.elevationPoint.z.toString(),i=ri.formatDistance(t,this.measureParams);return i+=ri.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.worldToClient(t);let i=new THREE.Vector2(t.x-12,t.y-22),n=new THREE.Vector2(t.x+58,t.y-22);return ii.distanceToSegment(e,i,n)<=22||this.notation.hitTest(e)}}class pi extends ci{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=ii.makePolyline({color:this.defaultColor,width:2,points:ii.calcPolylinePoints(n)});this.svgGroup.push(o)}if(0===e.length)return void this.unselect();let i=ii.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=ri.formatDistance(t,this.measureParams);return i+=ri.getPostFix(e,!1),i.split(",").join("")}}class fi extends ci{constructor(e,i,n,o){super(e,n,i.type,o),this.filterUrl=i.filterUrl,this.worldPositions=i.points,this.measureResult=i.area,this.boundaryPoints=[],this.scratchVector=new t,this.setMeasureParams({precision:i.precision,scale:i.scale,unit:i.unit})}initialize(){let e=new o,t=this.worldPositions;var i="";this.boundaryPoints=[];for(var s=0;s<=t.length;s++){let o=this.worldToClient(t[s%t.length]),r=ii.makeCircle({position:o,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(r),r.setAttribute("filter",this.filterUrl),this.unSelectElements.push(r),this.boundaryPoints.push(o),e.expandByPoint(new n(o.x,o.y)),i+=o.x+","+o.y+" "}var r=ii.makePolyline({color:this.defaultColor,fillColor:this.defaultColor,width:2,points:i});r.setAttribute("fill-opacity",.2),this.svgGroup.insert(0,r);var a=e.getCenter(this.scratchVector);let l=this.notation.drawAnnotation(a,this.getMeasureResult());for(const e of l)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect(),!this.isShow&&this.hide()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=ri.formatArea(t,this.measureParams);return i+=ri.getPostFix(e,!0),i.split(",").join("")}worldToClient(e){let t=[],i=this.viewer.getViewer();if(e.isActiveLayoutElement)t=i.toScreenPoint(e.point);else{const n=e.point?e.point:e;t=i.toViewportScreenPoint(n)}return{x:t[0],y:t[1]}}setViewId(e){this.viewId=e}getViewId(){return this.viewId}hitTest(e){let t=this.boundaryPoints;return ii.isPointInPolygon(e,t)}}class mi extends di{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.measureResult=t.distance,this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit}),this.isOnLayoutMeasure=t.isOnLayout}initialize(){let e=this.calAuxLines(),t=[];t.push(e[0].start,e[1].end),this.hitTestSegments=t;let i=this.calcTerminalLines(t,Math.PI/2,6.5);this.attachSingleLine(t),this.attachTerminalLines(i);this.attachAuxLines(e,["#7CCF21","#CC021B"]),this.attachTerminalPoints(t),this.attachNotation(t),this.notation.dropShadow(this.filterUrl),this.unselect(),!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]),o=this.worldToClient(e[t+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=ri.formatDistance(t,this.measureParams);return i+=ri.getPostFix(e,!1),i.split(",").join("")}worldToClient(e){if(this.isOnLayoutMeasure){let t=this.viewer.getViewer().toViewportScreenPoint([e.x,e.y]);return{x:t[0],y:t[1]}}return this.viewer.worldToClient(e)}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class wi extends ui{constructor(e,t,i,n){super(e,t,i,n),this.isOnLayoutMeasure=t.isOnLayout}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);e.push(new n(o.x,o.y))}return e}worldToClient(e){if(this.isOnLayoutMeasure){let t=this.viewer.getViewer().toViewportScreenPoint([e.x,e.y]);return{x:t[0],y:t[1]}}return this.viewer.worldToClient(e)}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class vi extends ci{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[0]),this.hitTestSegments.push(e[1]),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=ii.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=ii.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){let t=ii.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=ri.formatDistance(i,this.measureParams),i+=ri.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=ri.formatDistance(o,this.measureParams),o+=ri.getPostFix(e,!1),{distance:n,totalDistance:o}}}class yi extends ci{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.pointPos=t.positions,this.item=t.item,this.curves=t.curves,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[0]),this.hitTestSegments.push(e[1]),this.attachSelectedTerminalPoints(e[0]),this.attachSelectedTerminalPoints(e[1]),this.attachUnselectedTerminalPoints(e[0]),this.attachUnselectedTerminalPoints(e[1]))}this.attachNotations(),this.unselect()}}attachSelectedTerminalPoints(e){let t=ii.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=ii.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.pointPos[i].midPoint.x,y:this.pointPos[i].midPoint.y,z:this.pointPos[i].midPoint.z},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.curves.forEach((e=>{this.item&&this.item.deleteCurveById(e.id)}))}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=ri.formatDistance(i,this.measureParams),i+=ri.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=ri.formatDistance(o,this.measureParams),o+=ri.getPostFix(e,!1),{distance:n,totalDistance:o}}}class bi extends ci{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=ii.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=ii.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 ii.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=ri.formatPrecision(i.latitude.toString(),o),a=ri.formatPrecision(i.longitude.toString(),o),l=ri.formatDistance(t.toString(),s);return l+=ri.getPostFix(e,!1),`经度:${a} ° \n纬度:${r} ° \n高程:${l}`}}class xi extends ci{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=ii.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=ii.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=ii.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=ri.formatDistance(t,this.measureParams),t+=ri.getPostFix(e,!1),i=i.toString(),i=ri.formatDistance(i,this.measureParams),i+=ri.getPostFix(e,!1),n=n.toString(),n=ri.formatDistance(n,this.measureParams),n+=ri.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}}class Ei extends ci{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=ii.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=ii.makePolygon({points:t,width:this.lineWidth,color:this.defaultColor,fillColor:this.fillColor.getRGBA()});this.svgGroup.push(i)}attachUnselectedTerminalPoints(e){let t=ii.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=ri.formatArea(t,this.measureParams),t+=ri.getPostFix(e,!0),t}}class Ci extends Ei{constructor(e,t,i,n){super(e,t,i,n)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class Mi{constructor(t){t&&(this._opt=t,this.measurePoints=t.points||[],this.fillColor=t.fillColor||new e.Web.Graphics.Color("#f35801",.2),this.borderColor=t.color||new e.Web.Graphics.Color("#f35801",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 Pi extends Ei{constructor(e,t,i,n){super(e,t,i,n),this.measureSurfaceMesh=null}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new Mi({fillColor:new Glodon.Web.Graphics.Color("#f35801",.2),color:new Glodon.Web.Graphics.Color("#f35801",1),width:this.lineWidth})),super.initialize()}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 Ii extends ci{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),c=o.distance;let d=this.calcLine(l,h);if(2!==d.length)return i;let u=ii.makeLine({start:d[0],end:d[1],color:s,lineWidth:this.lineWidth});this.svgGroup.push(u);let g=this.calcTerminalLines(d,5*Math.PI/6,8);for(let e=0;e<g.length;e++){let t=[];t.push(g[e].start,d[e],g[e].end);let i=ii.makePolyline({color:s,width:this.lineWidth,points:ii.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},f=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(f.x,f.y,f.z);const l=100;if(f=r.clone().add(a.clone().sub(r).normalize().multiplyScalar(l)),n(f)||(f=r.clone().add(a.clone().sub(r).normalize().multiplyScalar(-l))),!n(f))return i}let m=this.notation.drawAnnotation({x:f.x,y:f.y},this.getMeasureResult(c),this.id,s);t.push(m)}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=ri.formatDistance(i,this.measureParams);return n+=ri.getPostFix(t,!1),n.split(",").join("")}}class Ti extends ci{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=ri.formatCubic(t,this.measureParams);return i=i+ri.getPostFix(e,!1)+"³",i.split(",").join("")}}class Di{constructor(e){this.viewer=e}make(e,t,i,n){let o=null,s="ViewerDrawing"===this.viewer.getViewerType(),r={defaultColor:`#${n._opt.color.getHEX()}`};switch(e){case"Distance":o=s?new mi(this.viewer,t,i,r):new di(this.viewer,t,i,r);break;case"Angle":o=s?new wi(this.viewer,t,i,r):new ui(this.viewer,t,i,r);break;case"MinimumDistance":o=new pi(this.viewer,t,i,r);break;case"Elevation":o=new gi(this.viewer,t,i,r);break;case"Area":o=new fi(this.viewer,t,i,r);break;case"GroundlineDistance":o=new yi(this.viewer,t,i,r);break;case"PolylineDistance":o=new vi(this.viewer,t,i,r);break;case"Position":o=new bi(this.viewer,t,i,r);break;case"TriangleDistance":o=new xi(this.viewer,t,i,r);break;case"SpatialArea":o=new Ei(this.viewer,t,i,r);break;case"ProjectedArea":o=new Ci(this.viewer,t,i,r);break;case"SurfaceArea":o=new Pi(this.viewer,t,i,r);break;case"LaserClearDistance":o=new Ii(this.viewer,t,i,r);break;case"Volume":o=new Ti(this.viewer,t,i,r)}return o.initialize(),o}}class Si{constructor(t,i){this.domContainer=t,this.measureItems=i,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.isEnableSelection)return;let t=new n(e.clientX,e.clientY);t.x-=this.offset.left,t.y-=this.offset.top;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.isEnableSelection)return;let t=new n(e.clientX,e.clientY);t.x-=this.offset.left,t.y-=this.offset.top;let i=this.hitTest(t);this.mousedownHitItem=i,i&&(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.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 Bi{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 c=document.createElementNS(this.xmlns,"feMergeNode");c.setAttribute("in","SourceGraphic"),a.appendChild(l),a.appendChild(h),a.appendChild(c),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 _i{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 Di(t,i),this.hookViewer3DEvents()}hookViewer3DEvents(){this.selectionControl=new Si(this.domContainer,this.itemList),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()})),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.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);"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]&&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}}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);e.id;this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit}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 Bi({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.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=null,s=[],a=null,l=null,h=function(t){var n=t.viewer,o=this,s=new e.Web.Lang.EventManager,r=i.create("div","bf-measure-conext");o.isOpen=!1,n.addEventListener("Rendered",(function(){o.isOpen&&o.update()})),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(b.EVENTS.ON_MEASURE_PICK,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(b.EVENTS.ON_VOLUME_MEASURE_END,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(b.EVENTS.ON_MEASURE_RESET,(function(t){o.isOpen&&(o.measureItem.reset(),o.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset))}))};h.prototype={init:function(){var e=this.context,t=this._opt.viewer;t.getDomElement().appendChild(e.rootDomElement),t.getModels().forEach((e=>{e.setSelectedComponentsById()}));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 _i(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.enableMeasureCursor();let t=this._opt.viewer.getViewer();if(this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.Volume?(t.editorManager.disableTool(b.EditToolMode.PICK_BY_MEASURE),t.editorManager.enableTool(t,b.EditToolMode.VOLUME_MEASURE)):(t.editorManager.disableTool(b.EditToolMode.VOLUME_MEASURE),t.editorManager.enableTool(t,b.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),t.measure=this,t.measureType=this.type,this.measureItem=new e.Bimface.Plugins.Measure[`Measure${this.type}Item`](t),this._measureItemMap[this.type]=this.measureItem}},switchOn:function(){this.isOpen||(this.activeByMeasureType(),this.isOpen=!0,this.drawableManager.setIsEnableSelection(!0))},switchOff:function(){if(this.isOpen){this.hideDragButton();var e=this,t=e._opt.viewer.getViewer();this.disableMeasureCursor(),t.editorManager.disableTool(b.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(b.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(),h=i.measureItem;if(t){n=t.pickPoint?t.pickPoint:null,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 d=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation,u=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance;const n=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance;if(d)h.redo(),h.addPoint(t.pickPoint),h.draw(this.context);else if(u&&t.userId)h.addPoint({userId:t.userId,modelId:t.modelId});else if(c&&t.objectId){for(let e in this.drawableManager.mapMeasureInfo){let i=this.drawableManager.mapMeasureInfo[e].points[0];if(i.modelId===t.modelId&&i.userId===t.objectId){this.drawableManager.removeItemById(e);break}}this.volumeResult=t.volume,this.volumePosition=t.position,h.addPoint({userId:t.objectId,modelId:t.modelId})}else n?t.userId&&h.addPoint({componentId:t.userId,modelId:t.modelId,point:t.pickPoint}):(h.addPoint(this.context.footPoint?o:t.pickPoint),i.update());h.getPoints().length==h.maxPointsNum?this.measureByInfo(this.getInfo()):(r||this.drawableManager.clear(!0),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||this.drawableManager.clear(!0),this.drawableManager.addItem(t),i||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,t),this.measureItem.reset(!1)},measureMinimum:function(){},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 t=this.measureItem,i=this.context,r=this._opt.viewer,h=r.getDomElement(),c=h.getBoundingClientRect(),d=r.getViewer(),u=t.getPoints(),g=[],p=[];if(i.svg.innerHTML="",i.footPoint=null,n?(i.hoverPosition=r.worldToClient(n),i.hoverPositionDS=d.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=r.worldToClient(s[0]),i.lineEndPoint=r.worldToClient(s[1]);var f=new THREE.Vector2(i.lineStartPoint.x,i.lineStartPoint.y),m=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(f),y=!w.containsPoint(m),x={start:f,end:m},E=b.CameraUtil.lineIntersectWithRect(x,w);if(v&&y)2==E.length&&(i.lineStartPoint=E[0],i.lineEndPoint=E[1]);else if(v||y)for(var C=new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y),M=v?m.clone():f.clone(),P=M.clone().sub(C).normalize(),I=0;I<E.length;I++){if(M.clone().sub(E[I]).normalize().dot(P)>0){i.lineStartPoint=M,i.lineEndPoint=E[I];break}}let e=u[u.length-1];if(e){let t=s[0].clone(),n=s[1].clone();const a=t.x-n.x,l=t.y-n.y,h=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(l,2)+Math.pow(h,2);let d=new THREE.Vector3(t.x+c*a,t.y+c*l,t.z+c*h),u=r.worldToClient(d);new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y).distanceTo(u)<=5&&(i.footPoint=u,i.hoverPosition=u,o=d)}}if("Panel"==i.hoverObjectType){i.normal=d.getScene().worldToDrawing(l),i.normal.normalize();var T=d.cameraControl,D=new THREE.Plane;D.setFromNormalAndCoplanarPoint(i.normal,i.hoverPositionDS);var S=new THREE.Vector2(i.hoverPosition.x-10,i.hoverPosition.y-10),B=new THREE.Vector2(i.hoverPosition.x+10,i.hoverPosition.y-10),_=i.hoverPositionDS,k=T.getRaycaster(S.x,S.y);if(this._p1=k.ray.intersectPlane(D,this._p1),k=T.getRaycaster(B.x,B.y),this._p2=k.ray.intersectPlane(D,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),L=new THREE.Vector3(0,1,0),V=new THREE.Vector3(0,0,1),R=Math.abs(i.normal.clone().dot(A))<=.0025,O=Math.abs(i.normal.clone().dot(V))<=.0025;if(R&&O)var N=A.clone(),H=V.clone();else N=L.clone().cross(i.normal).normalize(),H=i.normal.clone().cross(N).normalize();var z=this._p1.distanceTo(this._p2)/2,W=N.clone().multiplyScalar(z),U=H.clone().multiplyScalar(z),F=_.clone().sub(W).add(U),G=_.clone().add(W).add(U),j=_.clone().sub(W).sub(U),$=_.clone().add(W).sub(U),X=[];X.push(F,G,$,j);for(var Y=[],Z=T.getContainerDimensions(),q=0;q<X.length;q++){var K=b.CameraUtil.drawingToCanvas(T.camera,X[q],Z.width,Z.height);Y.push(new THREE.Vector3(K.x,K.y,0))}i.clientPts=Y}for(I=0;I<g.length-1;I++){if(ne=d.worldPointsToClient(g[I],g[I+1])){var J={x:ne.start.x-c.left,y:ne.start.y-c.top};p.push(J)}}if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance&&u.length==t.maxPointsNum){var Q={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],Q,ee,u[1]];for(q=0;q<ie.length-1;q++){var ne;(ne=d.worldPointsToClient(ie[q],ie[q+1]))&&(ne.start.x-=c.left,ne.start.y-=c.top,ne.end.x-=c.left,ne.end.y-=c.top),te.push(ne)}i.auxLines=te}i.clientPoints=p,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.points=o}else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume)t.volumeResult=this.volumeResult,t.volumePosition=this.volumePosition,t.notSupport=!this.volumeResult,t.points=o;else if(t.points=o,this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance)o&&2==o.length&&(t.distanceX=Math.abs(o[1].x-o[0].x),t.distanceY=Math.abs(o[1].y-o[0].y),t.distanceZ=Math.abs(o[1].z-o[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 r=new THREE.Vector3(o[0].x-o[1].x,o[0].y-o[1].y,o[0].z-o[1].z),a=new THREE.Vector3(o[2].x-o[1].x,o[2].y-o[1].y,o[2].z-o[1].z),h=r.angleTo(a);t.angle=180*h/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()},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return this._opt.viewer._defaultUnit}},t.MeasureViewer3D=h}(),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 _i(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),n._disableContextMenu=!0,requestAnimationFrame((()=>delete n._disableContextMenu))})),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.addEventListener("Reset",(()=>{this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset),n._disableContextMenu=!0,requestAnimationFrame((()=>delete n._disableContextMenu))}))};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()}`};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`},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.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=ri.formatDistance(i,this.measureParams),i+=ri.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=ri.formatDistance(o,this.measureParams),o+=ri.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=ri.formatDistance(t,this.measureParams),t+=ri.getPostFix(e,!1),i=i.toString(),i=ri.formatDistance(i,this.measureParams),i+=ri.getPostFix(e,!1),n=n.toString(),n=ri.formatDistance(n,this.measureParams),n+=ri.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=ii.makeLine({start:e.clientPoints[0],end:e.hoverPosition,color:this.measureItemConfig.color.getRGBA(),lineWidth:this.measureItemConfig.width});e.svg.appendChild(t)}let t=ii.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=ii.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=ii.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=ri.formatArea(t,this.measureParams),t+=ri.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){let n=this.viewer.clientToWorld(i),o=[...t];o.push(n),this.measureSurfaceMesh||(this.measureSurfaceMesh=new Mi({fillColor:new e.Web.Graphics.Color("#f35801",.2),color:new e.Web.Graphics.Color("#f35801",1),width:this.borderWidth})),this.measureSurfaceMesh.setMeasurePoints(o),this.viewer.render()},drawTerminals(e,t){t&&e.concat(t);e.forEach((e=>{let t=ii.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.groundCurve=new Map,this.currentCurves=[],this.groundInfos=[],this.externalObjectManager=new e.Bimface.Viewer.ExternalObjectManager(this.viewer),this.previewCurve=null,this.mesh=null});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.clearPreview(),this.groundInfos=[],this.currentCurves=[]},redo(){this.clearPreview(),this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?this.measurePoints.pop():this.measurePoints=[];let e=this.groundInfos.pop();if(e){let t=this.groundCurve.get(e.id);if(t){t.groundCurve&&t.groundCurve.dispose();let i=this.externalObjectManager.getObjectIdByName(`${e.id}`);this.externalObjectManager.removeById(i)}}},deleteCurveById(e){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var t=this._svg.childNodes,i=t.length-1;i>-1;i--)this._svg.removeChild(t[i]);this._svg.innerHTML=""}this.clearPreview();let n=this.groundCurve.get(e);if(n){n.groundCurve&&n.groundCurve.dispose();let t=this.externalObjectManager.getObjectIdByName(`${e}`);this.externalObjectManager.removeById(t)}this.groundInfos=[]},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.clearPreview(),this.groundCurve.forEach(((e,t)=>{e.groundCurve&&e.groundCurve.dispose();let i=this.externalObjectManager.getObjectIdByName(`${t}`);this.externalObjectManager.removeById(i)})),this.groundCurve.clear(),this.groundInfos=[]},createGroundCurve(t){if(t){var i=new b.Raycaster,n=new THREE.Vector3,o=this.viewer.getViewer().cameraControl.getIntersectContext(null),s=new b.IntersectHelper(this.viewer.getViewer());i.camera=o.camera,i.viewportSize=o.viewportSize;var r=[];t.getPoints(100).forEach((e=>{n.copy(e),(n=this.viewer.worldToScene(e)).y=1e4,i.set(n,new THREE.Vector3(0,-1,0));let t=s.getObjectsByRaycaster(o,i,!0);if(t.length>0){let e;e=this.viewer.sceneToWorld(t[0].point),r.push(e)}else r.push(e)})),t=null,this.previewCurve=new e.Bimface.Plugins.Geometry.SplineCurve(r),this.previewCurve.setWidth(3),this.previewCurve.setColor(new e.Web.Graphics.Color("#f35801",1)),this.previewCurve.projectToGround(!0),this.groundInfos.push({id:"preview",length:this.previewCurve.length,midPoint:this.previewCurve.getPointByParameter(.5),endPoint:this.previewCurve.getPointByParameter(1),status:"finished"}),this.externalObjectManager&&this.externalObjectManager._addObject("preview",this.previewCurve)}},clearPreview(){if(this.previewCurve){for(let e=0;e<this.groundInfos.length;e++)"preview"===this.groundInfos[e].id&&this.groundInfos.splice(e,1);let e=this.externalObjectManager.getObjectIdByName("preview");this.externalObjectManager.removeById(e),this.previewCurve.dispose(),this.previewCurve=null}},savePreview(){if(this.previewCurve){let t=e.Web.Lang.Utility.UUID.createUUID();if(this.groundCurve.set(t,this.previewCurve),this.currentCurves.push({id:t,curve:this.previewCurve}),this.groundInfos.push({id:t,length:this.previewCurve.length,midPoint:this.previewCurve.getPointByParameter(.5),endPoint:this.previewCurve.getPointByParameter(1),status:"finished"}),this.externalObjectManager){let e=this.externalObjectManager.getObjectIdByName("preview");this.externalObjectManager.removeById(e),this.externalObjectManager._addObject(`${t}`,this.previewCurve)}}},createPath(e,t,i){let 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;let s,r=[];r.push(n),r.push(o),s=new THREE.CatmullRomCurve3(r),s.tension=0,s.type="catmullrom",this.createGroundCurve(s)},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0===this.measureEnd&&this.measurePoints.length!=this.maxPointsNum)return this.maxPointsNum=this.measurePoints.length,void this.clearPreview();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 void this.clearPreview()}this.measurePoints.push(e),this.savePreview(),this.setIsReserverd(!1)},draw:function(e,t){if(this.clearPreview(),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.createPath(this.measurePoints[this.measurePoints.length-1],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.createPath(this.measurePoints[this.measurePoints.length-1],this.nextMeasurePoint),this.drawNotations()}},drawNotations(){let e=null,t=0;for(let i=0;i<this.groundInfos.length;i++){let n=this.groundInfos[i],o={x:n.midPoint.x,y:n.midPoint.y,z:n.midPoint.z},s=this.viewer.worldToClient(o);this.viewer.isInViewFrustum(o)&&this.drawNotation([s,s],this.formatDistance(n.length)),t+=n.length,i===this.groundInfos.length-1&&(e=n.endPoint)}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=ri.formatDistance(i,this.measureParams),i+=ri.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 _i(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(b.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.registerEventListener(b.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(b.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.unregisterEventListener(b.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(b.EditToolMode.PICK_BY_MEASURE),i.editorManager.enableTool(i,b.EditToolMode.VOLUME_MEASURE)):(i.editorManager.disableTool(b.EditToolMode.VOLUME_MEASURE),i.editorManager.enableTool(i,b.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(b.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(b.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.pickPlane?(s="Panel",a=t.normal):t.pickLine?(s="Line",o=t.pickLine):s=t.pickPoint?"Point":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)),r||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,i.getInfo(!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(),c=e.getPoints(),d=[],u=[];if(this.context.svg.innerHTML="",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!=c.length&&(d=c.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),f=new THREE.Box2;f.min.set(r.clientLeft,r.clientTop),f.max.set(f.min.x+r.clientWidth,f.min.y+r.clientHeight);var m=!f.containsPoint(g),w=!f.containsPoint(p),v={start:g,end:p},y=b.CameraUtil.lineIntersectWithRect(v,f);if(m&&w)2==y.length&&(t.lineStartPoint=y[0],t.lineEndPoint=y[1]);else if(m||w)for(var x=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y),E=m?p.clone():g.clone(),C=E.clone().sub(x).normalize(),M=0;M<y.length;M++){if(E.clone().sub(y[M]).normalize().dot(C)>0){t.lineStartPoint=E,t.lineEndPoint=y[M];break}}}if("Panel"==t.hoverObjectType){t.normal=h.getScene().worldToDrawing(a),t.normal.normalize();var P=h.cameraControl,I=new THREE.Plane;I.setFromNormalAndCoplanarPoint(t.normal,t.hoverPositionDS);var T=new THREE.Vector2(t.hoverPosition.x-10,t.hoverPosition.y-10),D=new THREE.Vector2(t.hoverPosition.x+10,t.hoverPosition.y-10),S=t.hoverPositionDS,B=P.getRaycaster(T.x,T.y);if(this._p1=B.ray.intersectPlane(I,this._p1),B=P.getRaycaster(D.x,D.y),this._p2=B.ray.intersectPlane(I,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var _=new THREE.Vector3(1,0,0),k=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,0,1),L=Math.abs(t.normal.clone().dot(_))<=.0025,V=Math.abs(t.normal.clone().dot(A))<=.0025;if(L&&V)var R=_.clone(),O=A.clone();else R=k.clone().cross(t.normal).normalize(),O=t.normal.clone().cross(R).normalize();var N=this._p1.distanceTo(this._p2)/2,H=R.clone().multiplyScalar(N),z=O.clone().multiplyScalar(N),W=S.clone().sub(H).add(z),U=S.clone().add(H).add(z),F=S.clone().sub(H).sub(z),G=S.clone().add(H).sub(z),j=[];j.push(W,U,G,F);for(var $=[],X=P.getContainerDimensions(),Y=0;Y<j.length;Y++){var Z=b.CameraUtil.drawingToCanvas(P.camera,j[Y],X.width,X.height);$.push(new THREE.Vector3(Z.x,Z.y,0))}t.clientPts=$}for(M=0;M<d.length-1;M++){var q=h.worldPointsToClient(d[M],d[M+1]);if(q){var K={x:q.start.x-l.left,y:q.start.y-l.top};u.push(K)}}t.clientPoints=u;let J=this.getInfo(!0,d);e.draw(t,J)},getInfo:function(t,i){var n={},o=this.measureItem,s=this._opt.viewer;i=i||o.getPoints();switch(n.type=this.type,n.id=e.Web.Lang.Utility.UUID.createUUID(),n.points=i,this.type){case e.Bimface.Plugins.Measure.MeasureTypeOption.Angle:if(3==i.length){var r=new THREE.Vector3(i[0].x-i[1].x,i[0].y-i[1].y,i[0].z-i[1].z),a=new THREE.Vector3(i[2].x-i[1].x,i[2].y-i[1].y,i[2].z-i[1].z),l=r.angleTo(a);n.angle=180*l/Math.PI}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Position:if(1==i.length){n.coordinateSystem="GCJ-02";let e=s.worldToLatLon(i[0]);n.lonLat={longitude:e.lon,latitude:e.lat},n.altitude=i[0].z}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance:if(i&&i.length>=2){let e=i.length;n.distance=[],n.totalDistance=0;for(let t=1;t<e;t++){let e=i[t].distanceTo(i[t-1]);n.distance.push(e),n.totalDistance+=e}}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.GroundlineDistance:if(i&&i.length>=2){n.distance=[],n.totalDistance=0,n.positions=[],n.item=o,n.curves=o.currentCurves;for(let e=0;e<o.groundInfos.length;e++){let t=o.groundInfos[e];n.distance.push(t.length),n.totalDistance+=t.length;let i={midPoint:t.midPoint,endPoint:t.endPoint};n.positions.push(i)}}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.TriangleDistance:if(2==i.length){n.distance=n.points[0].distanceTo(n.points[1]);let e=i[0].clone(),t=0,o=0;i[0].z<i[1].z?(e.set(i[0].x,i[0].y,i[1].z),t=e.distanceTo(i[1]),o=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]),o=e.distanceTo(i[1])),Object.assign(n,{horizontalDistance:t,verticalDistance:o})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:if(i.length>=3&&t){let e=ii.calcSpatialArea(i);Object.assign(n,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:if(i.length>=3&&t){let e=ii.calcProjectedArea(i);Object.assign(n,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:if(i.length>=3&&t){let e=ii.calcSurfaceArea(i,s);Object.assign(n,{area:e})}}return n},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"}},t.MeasureViewerGIS=l}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),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){var o=t.viewer;if(o){var s=new e.Web.Lang.EventManager,r=n.create("div","bf-measure-conext");this.context={rootDomElement:r},this.id="Measure",this._opt=t,this.type=t.measureType,this.getEventManager=function(){return s},"Viewer3D"===o.getViewerType()?(i.MeasureViewer3D.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewer3D.prototype)):"ViewerGIS"===o.getViewerType()?(i.MeasureViewerGIS.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewerGIS.prototype)):(i.MeasureDrawing.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureDrawing.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){switch(i){case"Viewer3D":t.units={distance:t.lengthUnits,elevation:t.lengthUnits};break;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||e.Bimface.Common.Units.LengthUnits.None;switch(i){case"Viewer3D":t.units={distance:o,elevation:r};break;case"ViewerGIS":t.units={distance:o,elevation:r,area:a};break;case"ViewerDrawing":t.units={distance:s,area:l}}},_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.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(){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()},getMeasureParams:function(t){let i={scale:this.getScale(),defaultUnit:this.getDefaultUnit()};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;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.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=t.worldPosition,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};s.prototype={getId:function(){return this.id},getWorldPosition:function(){return this.position},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.originalPosition=this.position=e,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={};n[i]=!0;let o=e.modelManager.getBoundingBoxByIds(n),s=this.assoiatedComponentBbox,r=o;if(s){let e=r.getCenter(this.scratchVector).clone();e.sub(s.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=r.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.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(),n={};n[i]=!0;let o=t.modelManager.getBoundingBoxByIds(n);o.isEmpty()?(this._config.objectId=null,console.log("Cannot find component with Id "+i)):this.assoiatedComponentBbox=o.clone()}},getCurrentPosition:function(){return 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.");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("ViewerGIS"===t.viewer.getViewerType()&&"ShpPoint"===t.type)this._helper=new b.ShpPointMarker(s,t.layerId);else{if(t.viewer.marker3DContainer)return t.viewer.marker3DContainer;t.viewer.marker3DContainer=this,this._helper=new b.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===b.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===b.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===b.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===b.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(b.EVENTS.ON_CLICK_MARKER3D_PICK,r._pick),s.registerEventListener(b.EVENTS.ON_CLICK_MARKER3D_PICK,r._rightPick),s.registerEventListener(b.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 c=0;c<n;c++){let t=e.floorInfos[c],i=e.floorInfos[c+1],o=e.floorInfos[c-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 c=[];for(var d=0;d<s;d++){let e=h[d],t=h[d+1],i=h[d-1];if(c.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}),c.length==s){this.boxMap[o]=c;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=c.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)})));let a=t.viewer.getViewer();a.registerEventListener(b.EVENTS.ON_EXPLOSION,(e=>{let t=this.getAllItems();for(const i of t)Nt.attachExplosionOffset(a,e.extent,i);this.update()}))}addItem(e){i.send(t,"addItem"),e.container=this;let n=Nt.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(b.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=Nt.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(b.EVENTS.ON_CLICK_PICK,this._pick),o&&n.unregisterEventListener(b.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()}}}(),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}},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(r._sectionPlane&&(r._sectionPlane.hidePlane(),r._sectionPlane.exit()),o.enableHatch(n.isHatchEnabled),n.hatchByMaterial&&r.getViewer().getClipCapsManager().enableHatchByMaterial(n.hatchByMaterial,!0),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()}else console.log("Viewer2D is not supported.")});r.prototype={hookEvens:function(){var e=this._viewer.getViewer(),t=this._viewer.getDomElement();e.registerEventListener(b.EVENTS.ON_CLIP_HOVER,(function(e){e.onClipBox?t.style.cursor=`url(${a}),auto`:t.removeAttribute("style")}));var i=this;e.registerEventListener(b.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,b.EditToolMode.CLIP_BY_BOX),this._sectionBox=new b.ClipPlaneService(e),b.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),this.hookEvens()},addEventListener:function(e,t){this.eventManager.addEvent(e,t)},removeEventListener:function(e,t){this.eventManager.removeEvent(e,t)},setBox:function(e){o.send(n,"setBox"),this._sectionBox.getEditor().calculateOffsetByBox(e.min,e.max),b.GlobalData.ClippingCapsType==b.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},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.getViewer().getScene();b.ClipPlaneManager.getInstance(t).enable(e,e)},fitToModel:function(){o.send(n,"fitToModel"),this.reset();var e=this._sectionBox.recalculate().clone();e.isEmpty()&&e.expandByPoint(new THREE.Vector3),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=b.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.editorManager.disableTool(b.EditToolMode.CLIP_BY_BOX),e.getClipCapsManager().resetClippingCapsStatus(),i.removeAttribute("style"),this._sectionBox=null,this._opt.viewer._sectionBox=null,t=null,this.eventManager.fireEvent(this.sectionBoxEvent.SectionBoxUpdate,null),e.unregisterEventListener(b.EVENTS.ON_CLIP_HOVER,(function(e){e.onClipBox?i.style.cursor=`url(${a}),auto`:i.removeAttribute("style")}))},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},setState:function(e){this._sectionBox.loadState(e)},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.applyMatrix4(i),t},setSectionBox:function(e){o.send(n,"setSectionBox");var t=this._opt.viewer,i=t.getViewer().getScene(),s=b.ClipPlaneManager.getInstance(i),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){const t=this._opt.viewer;for(const i of e){if(i.layerId){const e=t.getLayerManager().getLayer(i.layerId);if(!e)continue;i.modelId=e.getModelId()}let e;i.modelId&&(e=t.getModel(i.modelId)),void 0!==e&&(i.objectIds?e.localClippingComponentsById(i.objectIds):i.objectData?e.localClippingComponentsByObjectData(i.objectData):e.localClippingComponentsByObjectData([]))}this._sectionBox.update(),this._opt.viewer.render()},clearFilter(){this.restoreObjects()},changeClipDirection(e){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").changeDirection(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),c=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),d=new THREE.Vector3(-a.y,a.x,0),u=Math.abs(l.dot(d)/d.length()),g=Math.abs(h.z);let p=new THREE.Box3;p.min=new THREE.Vector3(e.x-c,e.y-u,e.z-g),p.max=new THREE.Vector3(e.x+c,e.y+u,e.z+g),this.setBox(p),a.y<0&&(a.x=-a.x,a.y=-a.y);const f=THREE.Math.radToDeg(Math.acos(a.clone().normalize().dot(new THREE.Vector3(1,0,0))));this.rotateByAxis("ZAxis",f)},enableHatch(e){b.GlobalData.ClippingCapsType!=e&&b.GlobalData.ClippingCapsType!=b.EnumClippingCapsTypes.ClipPlane&&(b.GlobalData.ClippingCapsType=e?b.EnumClippingCapsTypes.ClipBox:b.EnumClippingCapsTypes.None,this._sectionBox&&this._sectionBox.visibleCapsWireframe(e),e&&this._sectionBox&&this._sectionBox.getEditor().clipPlanes.reCalculateClippingIds())},isHatchEnabled:()=>b.GlobalData.ClippingCapsType==b.EnumClippingCapsTypes.ClipBox},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,hatchByMaterial:!1}},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");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");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=b.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(),b.GlobalData.ClippingCaps=!1,!(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){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),t.fillClipPlane.calculateClippingIds(),b.GlobalData.ClippingCaps=!0,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(){1==e.circleXMouseDown&&(e.fillClipPlane.calculateClippingIds(),b.GlobalData.ClippingCaps=!0,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(){1==e.circleYMouseDown&&(e.fillClipPlane.calculateClippingIds(),b.GlobalData.ClippingCaps=!0,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(),b.GlobalData.ClippingCaps=!1;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(),c=e.config.styles;e.coordinateSystem.drawClipPlaneCircle("tipArcZ",h.start.clone(),c.auxCircleRadius,e.coordinateSystem.dirX,l);var d=e.coordinateSystem.drawingToCanvas(h.start.clone()),u=e.coordinateSystem.drawingToCanvas(h.endY.clone());e.coordinateSystem.drawAxisY(d,u,t.highLight),e.coordinateSystem.drawCubeX("cubeX",u,c.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(),b.GlobalData.ClippingCaps=!1;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(),c=e.config.styles;e.coordinateSystem.drawClipPlaneCircle("tipArcZ",h.start.clone(),c.auxCircleRadius,e.coordinateSystem.dirX.clone(),l.clone());var d=e.coordinateSystem.drawingToCanvas(h.start.clone()),u=e.coordinateSystem.drawingToCanvas(h.endX.clone());e.coordinateSystem.drawAxisX(d,u,t.highLight),e.coordinateSystem.drawCubeY("cubeY",u,c.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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");t.CoordinateSystem=class{constructor(t){this.viewer=t;let i=this.viewer.getViewer();this.cameraControl=i.cameraControl,this.fillClipPlane=b.FillClipPlaneManager.getInstance(i.getScene()),this.container=i.domElement,this.config=new e.Bimface.Plugins.Section.CoordinateSystemConfig,this.drawingImpl=new e.Bimface.Plugins.Section.CoordinateDrawer(this,i),this.coordinateAction=new e.Bimface.Plugins.Section.CoordinateAction(this,this.drawingImpl),this.updateBinded=this.update.bind(this),this.initialize()}initialize(){this.enable=!0,this.boundingBox=new THREE.Box2,this.bRegisterArrowEvent=!1,this.bRegisterAuxCircleEvent=!1,this.mapDrawableName={ORIGIN:"origin",AXISX:"axisX",AXISY:"axisY",CUBEX:"cubeX",CUBEY:"cubeY",AXISZ:"axisZ",ARROW:"arrow",DASHLINE:"dashLine",TIPARC_X:"tipArcX",TIPARC_Y:"tipArcY",TIPARC_Z:"tipArcZ",DASHLINE_X:"dashLineX",DASHLINE_Y:"dashLineY"}}setDirection(e){this.planeDirection=e}saveTransform(e){this.savedCamera=e.clone()}drawingToCanvas(e,t){var i=this.getCoordinateAxis().start.clone(),n=this.cameraControl.camera,o=new THREE.Vector3,s=this.viewer.getViewer();if(null==this.cameraToCenter){var r=s.getCamera(),a=s.getScene().getOriginalBoundingBoxWorld().clone();a.applyMatrix4(s.getScene().geometryGroup.matrix),n.setStandardView(b.EnumStandardView.ISO,a),n.zoomToBBox(a),i=this.getCoordinateAxis().start.clone(),this.cameraToCenter=i.clone().sub(n.position.clone()).length(),this.defaultDistance=1500;var l=s.getScene().getMatrixGlobal(),h=b.CameraUtil.parseCameraInfo(r),c=b.Camera.worldToDrawing(h,l);(d=new THREE.Vector3).subVectors(c.target,c.position),n.LookAt(c.target,d,c.up),this.cameraControl.update(!0,!0)}else{var d=i.clone().sub(n.position.clone()).normalize(),u=n.position.clone().sub(i.clone()).length();o=d.multiplyScalar(this.defaultDistance-u)}var g=this.container.offsetWidth,p=this.container.offsetHeight;!1!==t&&n.isPerspective&&e.add(o);var f=b.CameraUtil.drawingToCanvas(n,e,g,p);return new THREE.Vector2(f.x,f.y)}getCoordinateAxis(){var e=this.fillClipPlane.renderClipPlane.normal.clone(),t=this.fillClipPlane.getCoordinate(),i=t.axisY.clone(),n=e.clone().cross(i.clone());this.fillClipPlane.normalIndex>3&&(i=(n=t.axisX.clone()).clone().cross(e.clone()));var o=this.config.styles,s=this.fillClipPlane.position.clone(),r=s.clone().add(n.clone().multiplyScalar(o.axisXLength)),a=s.clone().add(i.clone().multiplyScalar(o.axisYLength)),l=s.clone().add(e.clone().multiplyScalar(o.axisZLength));return this.dirX=n,this.dirY=i,{start:s,endX:r,endY:a,endZ:l}}drawOrigin(e,t){var i=this.mapDrawableName,n={center:e,radius:t,color:this.config.colors.default};this.drawingImpl.makeCircle(i.ORIGIN,n)}drawAxisX(e,t,i){var n=this.mapDrawableName,o={start:e,end:t,width:this.config.styles.axisXWidth,color:i||this.config.colors.default};this.drawingImpl.makeLine(n.AXISX,o)}drawAxisY(e,t,i){var n=this.mapDrawableName,o=this.config,s={start:e,end:t,width:o.styles.axisYWidth,color:i||o.colors.default};this.drawingImpl.makeLine(n.AXISY,s)}drawAxisZ(e,t){var i=this.mapDrawableName,n=this.config,o={start:e,end:t,width:n.styles.axisZWidth,color:n.colors.arrow};this.drawingImpl.makeLine(i.AXISZ,o),this.drawingImpl.attach(),0==this.bRegisterArrowEvent&&(this.coordinateAction.registerArrowEvents(),this.bRegisterArrowEvent)}updateAxisZ(){var e=this.getCoordinateAxis(),t=this.drawingToCanvas(e.start.clone()),i=this.drawingToCanvas(e.endZ.clone()),n=this.mapDrawableName,o={start:t,end:i,color:this.config.colors.default};this.drawingImpl.makeLine(n.AXISZ,o)}drawArrow(e,t){var i=this.mapDrawableName,n={start:e,end:t};this.drawingImpl.makeLine(i.AXISZ,n),this.drawingImpl.attach(),this.drawingImpl.setColor(i.AXISZ,this.config.colors.default),0==this.bRegisterArrowEvent&&(this.coordinateAction.registerArrowEvents(),this.bRegisterArrowEvent)}drawClipPlaneCircle(e,t,i,n,o){for(var s={center:t.clone(),radius:i,normal:n.clone(),rotateAxis:o.clone()},r=this.config.styles.segments,a=this.discreteCircle(s,r),l="",h=0;h<r;h++)l+=a[h].x+","+a[h].y,l+=" ";l+=a[0].x+","+a[0].y;var c={points:l+=" ",color:this.config.colors.default,width:2};this.drawingImpl.makePolyline(e,c)}drawTipArc(e,t,i,n,o){var s={center:t.clone(),radius:i,normal:n.clone(),rotateAxis:o.clone()},r=this.config.styles,a=r.tipArcRightCounts,l=r.tipArcLeftCounts,h=r.segments,c=this.discreteCircle(s,h);e==this.mapDrawableName.TIPARC_X?(this.discretePointsX=c,a=r.tipArcLeftCounts,l=r.tipArcRightCounts):this.discretePointsY=c;for(var d="",u=h-a-1;u<h;u++)d+=c[u].x+","+c[u].y,d+=" ";for(var g=0;g<=l;g++)d+=c[g].x+","+c[g].y,d+=" ";var p={points:d,color:this.config.colors.tipArcX};e==this.mapDrawableName.TIPARC_X?(this.drawingImpl.makePolyline(e,p),this.coordinateAction.registerTipArcXEvents()):e==this.mapDrawableName.TIPARC_Y&&(p.color=this.config.colors.tipArcY,this.drawingImpl.makePolyline(e,p),this.coordinateAction.registerTipArcYEvents())}drawTipLine(e,t,i){var n=this.drawingToCanvas(t.clone(),!1),o=this.drawingToCanvas(i.clone(),!1),s=this.config,r={start:n,end:o,color:s.colors.tipLine,dashArray:s.styles.dashArray};this.drawingImpl.makeDashLine(e,r),this.drawingImpl.show(e,!1)}drawCubeX(e,t,i){var n={center:t,radius:i,color:this.config.colors.cubeX};this.drawingImpl.makeCircle(e,n)}drawCubeY(e,t,i,n){var o={center:t,radius:i,color:n||this.config.colors.cubeY};this.drawingImpl.makeCircle(e,o)}discreteCircle(e,t){for(var i=e.center.clone(),n=e.radius,o=e.rotateAxis.clone(),s=e.normal.clone(),r=[],a=0;a<t;a++){s.applyAxisAngle(o,2*Math.PI/t);var l=i.clone().add(s.clone().multiplyScalar(n)),h=this.drawingToCanvas(l.clone());r.push(h)}return r}arcToCircle(e){var t="",i=this.discretePointsX;e==this.mapDrawableName.TIPARC_Y&&(i=this.discretePointsY);for(var n=0,o=i.length;n<o;n++)t+=i[n].x+","+i[n].y,t+=" ";t+=i[0].x+","+i[0].y;var s={points:t+=" ",color:this.config.colors.highLight};this.drawingImpl.makePolyline(e,s)}circleToArc(e){var t=this.config.styles,i=t.tipArcLeftCounts,n=t.tipArcRightCounts,o=t.segments,s=this.discretePointsX,r={color:this.config.colors.tipArcX};e==this.mapDrawableName.TIPARC_Y&&(s=this.discretePointsY,r.color=this.config.colors.tipArcY,i=t.tipArcRightCounts,n=t.tipArcLeftCounts);for(var a="",l=o-i-1;l<o;l++)a+=s[l].x+","+s[l].y,a+=" ";for(var h=0;h<=n;h++)a+=s[h].x+","+s[h].y,a+=" ";r.points=a,this.drawingImpl.makePolyline(e,r)}update(e){if(1==e||1!=this.bIsCoordinateHided){var t=this.getCoordinateAxis(),i=this.drawingToCanvas(t.start.clone()),n=this.drawingToCanvas(t.endX.clone()),o=this.drawingToCanvas(t.endY.clone()),s=this.drawingToCanvas(t.endZ.clone());null==this.createRefs&&(this.drawingImpl.makeDefs("refs"),this.createRefs=!0),this.cOrigin=i.clone(),this.drawAxisZ(i,s),this.drawAxisX(i,n),this.drawAxisY(i,o);var r=this.config.styles,a=this.mapDrawableName,l=this.fillClipPlane.renderClipPlane.normal.clone();this.drawClipPlaneCircle(a.TIPARC_Z,t.start.clone(),r.auxCircleRadius,this.dirX,l),this.drawTipArc(a.TIPARC_X,t.start.clone(),r.auxCircleRadius,l,this.dirX),this.drawTipArc(a.TIPARC_Y,t.start.clone(),r.auxCircleRadius,l,this.dirY);var h=this.fillClipPlane.getSideLength()/2,c=t.start.clone().add(this.dirX.clone().multiplyScalar(h)),d=t.start.clone().sub(this.dirX.clone().multiplyScalar(h));this.drawTipLine(a.DASHLINE_X,c,d);var u=t.start.clone().add(this.dirY.clone().multiplyScalar(h)),g=t.start.clone().sub(this.dirY.clone().multiplyScalar(h));this.drawTipLine(a.DASHLINE_Y,u,g),this.drawOrigin(i,r.originRadius);var p=this.discretePointsX[44].clone();this.drawCubeX(a.CUBEX,p,r.cubeRadius);var f=this.discretePointsY[134].clone();this.drawCubeY(a.CUBEY,f,r.cubeRadius),this.updateBbox()}}hide(e){this.drawingImpl.hideAll(e),this.bIsCoordinateHided=e}destroy(){this.drawingImpl.destroy()}updateBbox(){this.boundingBox.makeEmpty();for(var e=0;e<this.discretePointsX.length;e++){var t=this.discretePointsX[e].clone();this.boundingBox.expandByPoint(t)}for(e=0;e<this.discretePointsY.length;e++){t=this.discretePointsY[e].clone();this.boundingBox.expandByPoint(t)}var i=this.getCoordinateAxis(),n=this.drawingToCanvas(i.start.clone()),o=this.drawingToCanvas(i.endZ.clone());this.boundingBox.expandByPoint(n),this.boundingBox.expandByPoint(o),this.boundingBox.expandByScalar(5)}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(n._sectionBox&&(n._sectionBox.hideBox(),!1!==t.exitSectionBox&&n._sectionBox.exit()),b.GlobalData.ClippingCapsType=b.EnumClippingCapsTypes.ClipPlane,t.hatchByMaterial&&n.getViewer().getClipCapsManager().enableHatchByMaterial(t.hatchByMaterial,!1),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),i.init(),i.setPlane(t.plane),this._boxSize=new THREE.Vector3}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),b.GlobalData.ClippingCaps=!0,o.editorManager.enableTool(o,b.EditToolMode.CLIP_FILL),this._sectionTool=b.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),this.hookEvens()},hookEvens:function(){var t=this.coordinateSystem,i=this._opt.viewer.getViewer(),n=o.throttle;i.registerEventListener(b.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),i.registerEventListener(b.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),i.registerEventListener(b.EVENTS.ON_EDITOR_ZOOM,n(t.updateBinded,50)),i.registerEventListener(b.EVENTS.ON_CAMERA_ANIMATION_UPDATE,n(t.updateBinded,50)),i.registerEventListener(b.EVENTS.ON_EDITOR_END,(function(){t.update(!0)})),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.clientX,e.event.clientY);t.insideBoundingBox(n)?t.hide(!1):t.hide(!0)}},onClipMouseMove:function(){this.coordinateSystem.update()},exit:function(){var t=this._opt.viewer.getViewer(),i=b.FillClipPlaneManager.getInstance(t.getScene());this.borderParamWidth&&this.borderParamHeight&&this.setBorder(this.borderParamWidth,this.borderParamHeight,!1),this.clearFilter(),t.editorManager.disableTool(b.EditToolMode.CLIP_FILL),i.clearCapsWireframe(),b.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(b.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),t.unregisterEventListener(b.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),this._opt.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,this.onFloorExplosionBinded)},setProgress:function(e){i.send(t,"setProgress");var n=1-e/50;this._progress=e,this._sectionTool.setProcess(n),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds()},setOriginProgress:function(e){var t=e/100;this._progress=e,this._sectionTool.setProcess(t),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds()},getOriginProgress:function(){return 100*this._sectionTool.getProcess()},getProgress:function(){return 50*(1-this._sectionTool.getProcess())},setPlane:function(e){i.send(t,"setPlane");var n=s[this._direction]+r[e];this._plane=e,this._sectionTool.changeNormal(n),this.setProgress(this._opt.progress)},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)},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)},showPlane:function(){i.send(t,"showPlane"),this._sectionTool&&(this._sectionTool.visible=!0),this.enableCoordinate=!0},rotateByAxis:function(e,n){if(i.send(t,"rotateByAxis"),"YAxis"===e||"ZAxis"===e){var o="",a=0,l=s[this.getDirection()]+r[this._plane];0==l||1==l?(a="YAxis"===e?-n:n,o="YAxis"===e?"y":"z"):2==l||3==l?(a="YAxis"===e?-n:n,o="YAxis"===e?"x":"z"):4!=l&&5!=l||(a="YAxis"===e?n:-n,o="YAxis"===e?"x":"y"),a="Reverse"===this._direction?n:a,this._sectionTool&&(this._sectionTool.rotateAngleOffset(a,o),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds())}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.showPlane():this.hidePlane()},getState:function(){return this._sectionTool.store()},isIncluded:function(e){var t=this._opt.viewer,i=t.getViewer().getScene(),n=b.FillClipPlaneManager.getInstance(i),o=n.renderClipPlane.normal.clone().normalize(),s=n.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){var o=this._opt.viewer;e=o.worldToScene(e),t=o.worldToScene(t);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 c=1,d=r.clone().projectOnPlane(h);if(0!=d.length){d.normalize(),c=l.clone().cross(d).y>0?1:-1;let e=l.clone().angleTo(d);this.rotateByAxis("ZAxis",e*THREE.Math.RAD2DEG*c)}let u=d.clone().angleTo(r.clone());c=r.y<0?1:-1,this.rotateByAxis("YAxis",u*THREE.Math.RAD2DEG*c),this._sectionTool.position.copy(a),this._sectionTool.center.copy(a),this._sectionTool.update(),this._sectionTool.clearCapsWireframe()},setState:function(e){i.send(t,"setState"),this._sectionTool.restore(e)},restoreRotation:function(){this._sectionTool.restoreRotation()},getSectionPlane:function(){var e=this._opt.viewer,t=this._sectionTool.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.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.quaternion.copy(s),this._sectionTool.position.copy(i),this._sectionTool.update(),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds()},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.position),this._sectionTool.update(),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds()},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;if("Viewer3D"===i.viewerType)for(var n=0;n<t.length;n++){if((s=t[n]).modelId){var o=i.getModel(s.modelId);o?s.objectIds||s.objectData?s.objectIds?o.localClippingComponentsById(s.objectIds):s.objectData&&o.localClippingComponentsByObjectData(s.objectData):i.getViewer().modelManager.getModel(o.modelId).enableLocalClippingMode(!0):console.warn("invalid modelId.")}else console.warn("invalid modelId.")}else if(i instanceof e.Bimface.Viewer.ViewerGIS)for(n=0;n<t.length;n++){var s;if(!(s=t[n]).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(),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()},setBorder(t,i,n){this.borderParamWidth=t,this.borderParamHeight=i;var o=20,s=20;"Viewer3D"===this._opt.viewer.viewerType?(o=this._opt.viewer.getViewer().worldToDrawing({x:t,y:0,z:0}).x,s=this._opt.viewer.getViewer().worldToDrawing({x:i,y:0,z:0}).x):this._opt.viewer instanceof e.Bimface.Viewer.ViewerGIS&&(o=t||o,s=i||s),o=Math.max(1,o),s=Math.max(1,s),this._sectionTool.setBorder(o,s,n)},drawComponentContours(){let e=this._opt.viewer.getViewer().getScene().getOrCreateObjectGroup(b.ObjectGroupType.CAPSWIREFRAME,{globalSpace:!0});const t=this._sectionTool.capsIntersectContour;for(const i in t){const n=t[i],o=this._opt.viewer.getModel(i).getModelTransformation();(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}},n.SectionPlane=a}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionRegionConfig=class{constructor(){const e={viewer:null,boundary:null,height:0};for(let t in e)this[t]=e[t]}};class ki{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(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.reset()}else console.log("Viewer2D is not supported.")}init(){let e=this.boundary[0].z;this.height<0&&(e+=this.height);let t=this.boundary.map((t=>new THREE.Vector3(t.x,t.y,e)));t.push(t[0]),ki.isClockwiseBoundary(t)||t.reverse(),b.ClipRegionManager.setClipRegion(this.cloudViewer,t,Math.abs(this.height)),this._viewer.render()}changeClipDirection(e){this.clipDirection=e,b.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(){b.ClipRegionManager.exit(this.cloudViewer),this._viewer.render(),this._viewer._sectionRegion=null}hide(){b.ClipRegionManager.hide(this.cloudViewer),this._viewer.render()}show(){b.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())}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=ki,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough").WalkthroughConfig=function(){return{viewer:null,time:10,stopCallback: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"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");n.Walkthrough=class{constructor(e){var t=e.viewer,i=t.getViewer();t?"Viewer3D"===t.getViewerType()||"ViewerGIS"===t.getViewerType()?(this._viewer=t,this.bPause=!1,this.cameraStatus=null,this._walkthrough=new b.Walkthrough,this._player=new b.WalkthroughPlayer(i),this._player.setWalkthrough(this._walkthrough),e.stopCallback&&this._player.addStopPlayCallback(e.stopCallback),this.setWalkthroughTime(e.time)):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"),h.assertType(e,"obj")?e.frameTime?this._walkthrough.setWalkthroughTime(e.frameTime):this._walkthrough.setWalkthroughTime(e.totalTime):this._walkthrough.setWalkthroughTime(e)}play(e){i.send(t,"play");var n=this._viewer.getViewer(),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.play(),this.bPause=!1}pause(){i.send(t,"pause"),this.bPause=!0,this.cameraStatus=this._viewer.getCameraStatus(),this._player.pause()}stop(){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}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(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 c=0,d=l.length;c<d;c++){var u=l[c].databagId;if(u){var g=null;n[u]?g=n[u]:(g={databag:t.getDatabagResource(u),metadata:t.getPartialElementsMetadataFile(u),fileId:l[c].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 c=this._viewer.getSegmentManager().getSegmentIdsByPartialElementId(e);return c&&(t[e]=c),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)}registerEvent(){var t=e.Bimface.Viewer.Viewer3DEvent,i=this,n=this.viewer.getEventManager(),o=null;const s="AxisGrids";function r(e){var r=!0,a=e.point,l=e.height,h=e.snapLines,c=e.nearestPoint,d=h.intersectLines,u=h.gridLine,g=i.viewer.worldToClient(a),p=i.viewer.worldToClient(c.toGridLine),f=i.viewer.worldToClient(c.toIntersection),m=i.distance(g,p),w=i.distance(g,f),v=null;if(w<=i.snapMinDistance&&void 0!==d){i.highlightIntersectLines.show(),i.highlightLine.hide();var y=d[0],b=d[1];v=y.name+"-"+b.name,i.highlightIntersectLines.setHeight(l),i.highlightIntersectLines.setLine(y,b),i.highlightIntersectLines.setPoint(c.toIntersection),i.highlightIntersectLines.update()}else m<=i.snapMinDistance?(v=u.name,i.highlightLine.show(),i.highlightIntersectLines.hide(),i.highlightLine.setHeight(l),i.highlightLine.setLine(u),i.highlightLine.update(l)):(o=null,i.highlightLine.hide(),i.highlightIntersectLines.hide(),r=!1);return o!=v&&(w<=i.snapMinDistance||m<=i.snapMinDistance)&&(n.fireEvent(t.Hover,{objectType:s,objectId:v,worldPosition:a}),o=v),r}this.viewer.addEventListener(t.AxisGridHover,(function(e){for(const t of e.snaps){if(r(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 a=CLOUD.AxisGridManager.getInstance(n,s);if(e&&"mousewheel"==e.type){var l=n.getMatrixGlobal(),h=new THREE.Vector2(e.clientX,e.clientY),c=t.cameraControl.getRaycaster(h.x,h.y),d=a.getIntersectPoints(c,l),u=a.snapOnFloors(d);if(u&&0==u.length)return i.highlightLine.hide(),void i.highlightIntersectLines.hide();for(const e of u){if(r(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 Ai{constructor(){}}Ai.distanceToSegment=function(e,t,i){let n=this.nearestPointOnSegment(e,t,i);return e.distanceTo(n)},Ai.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 Li{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 Li)for(const i of t.getDrawables())e.appendChild(i);else e.appendChild(t)}))}detach(){for(const t of this.drawables){if(t instanceof Li)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 Vi extends Li{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=ii.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=ii.makeLine(n);o.setAttribute("marker-end","url(#"+this.id+")"),this.drawables.push(o)}setDefault(){this.drawables[1].style.stroke=this.color,document.getElementById(this.id).children[0].style.fill=this.color}setGray(){this.drawables[1].style.stroke=this.grayColor,document.getElementById(this.id).children[0].style.fill=this.grayColor}select(){this.drawables[1].style.stroke=this.highlightColor,document.getElementById(this.id).children[0].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(){document.getElementById(this.id).children[0].style.display="none",this.drawables[1].style.display="none"}show(){this.drawables[1].style.display="block",document.getElementById(this.id).children[0].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 Ri{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=ii.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=ii.calcPolylinePoints(i),t.width="1px",t.color="rgba(0,0,0,0)",t.fillColor="rgba(50, 211, 166, 0.1)";let n=ii.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 Vi({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=Ai.distanceToSegment(t,r[0],r[1]);return l<=this.hitTestEpsilon?"up-segment":(l=Ai.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{this.makeEditPoints(),this.makeEditEdges(),this.makeBoundary();let 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(){this.editHeight=new Ri;let 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 c=new i.EditEdge([l,o]);this.editEdges.splice(s+1,0,c),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=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId),i=t.min,n=t.max,o=[],s=(i.y+n.y)/2;o.push(new THREE.Vector3(i.x,s,this.roomHeightOffset.to)),o.push(new THREE.Vector3(i.x,s,this.roomHeightOffset.from)),o.push(new THREE.Vector3(n.x,s,this.roomHeightOffset.from)),o.push(new THREE.Vector3(n.x,s,this.roomHeightOffset.to));let r=[];for(const e of o)r.push(this.viewer.worldToClient(e));return this.roomHeightOnCanvas=r[1].y-r[0].y,r}updateRoomHeightOffset(e,t){let i=this.roomHeightOnCanvas,n=(this.roomHeightOffset.to-this.roomHeightOffset.from)/i,o=100;"m"===this.viewer._defaultUnit&&(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]}}}(),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,Ai.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=Ai.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 Oi{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"),this.bIsOnEditing=!1,this.viewer=e.viewer,this.lastAnimationState=null,this.restoreCameraStatus=null,this.roomInfo=this.viewer.mapCustomizedRoom[e.roomId],this.roomId=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=this.viewer.getEventManager(),o=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer,hasInitialized:!0}).getBoundaryByRoomId(this.roomId);const s=(new THREE.Matrix4).fromArray(this.viewer.getDefaultModel().getModelTransformation());for(let e=0;e<o.length;e++){let t=(new THREE.Vector3).fromArray(o[e]);t.applyMatrix4(s),o[e]=t.toArray()}this.roomData=new n.RoomData(this.viewer,o),this.roomData.setEditRoomId(this.roomId),this.roomView=new n.RoomView(this.roomData,this.svgContainer),this.roomView.setEventManager(t),this.activeEditor=new n.PickEditor(this.roomView)}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);let i=this;this.viewer.setView(e.Bimface.Viewer.ViewOption.Top,(()=>{i.viewHouseVisibility=i.viewer._getViewHouseVisibility(),i.viewHouseVisibility&&i.viewer.hideViewHouse(),i.viewer._enableCursor(!1),t.getFilter().deactivateAll(),i.viewer._enableSelectionChanged(!1),i.viewer.setCameraAnimation(!1),i.viewer.setCameraType("OrthographicCamera"),i.viewer.enableOrbit(!1),i.viewer.hideRoomsById([this.roomId]),i.roomData.build(),i.roomView.attachDrawables(),i.roomView.addCloudViewerEvents(t),i.viewer.render()}))}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,t=(this.roomInfo.offset,[]),i=[];const n=(new THREE.Matrix4).fromArray(this.viewer.getDefaultModel().getModelTransformation()),o=(new THREE.Matrix4).copy(n).invert();for(const n of this.roomData.getEditPoints()){let s=n.getWorldPosition();s[2]=e;let r=(new THREE.Vector3).fromArray(s);r.applyMatrix4(o),s=r.toArray(),t.push(s),i.push({x:s[0],y:s[1],z:e})}let s=this.viewer.createBoundary(t),r=this.roomData.getRoomHeightOffset();return{boundary:s,outerBoundary:i,height:r[1]-r[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;this.viewer.createRoom(t.boundary,t.height,t.id,i,n);let o=this.roomData.getRoomHeightOffset(),s=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer});s.setBottomHeightByRoomId(this.roomId,o[0]),s.setTopHeightByRoomId(this.roomId,o[1])}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,e[1]+a);n.setProgress(l)}this.isInHeightEditor=!1;let o=this;this.viewer.setCameraStatus(this.restoreCameraStatus,(function(){o.viewer.render()}))}makeSectionPlane(){let t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.roomId),i=(t.min.y+t.max.y)/2,n=this.viewer.getViewer().getBoundingBoxWorld(),o=this._calcSectionPlaneProgress(n.min.y,n.max.y,i),s=this.viewer._sectionPlane;s&&(s.setPlane("Y"),s.setDirection("Reverse"),s.setProgress(o))}_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 Oi(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=new e.Bimface.Plugins.SpatialRelation.Room({viewer:t}).getRoomBoundingBoxById(this.roomId);t.zoomToBoundingBox(o,(function(){})),t.setCameraType("OrthographicCamera"),i.getData().build(),i.update(),this.viewer.setCameraAnimation(n)}))}activateByRoomId(t){this.isInHeightEditor=!1,this.roomId=t,this.roomInfo=this.viewer.mapCustomizedRoom[t];let 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=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.DrawingHelper=class{constructor(e){t.send("Bimface.Plugins.RevitHelpers","DrawingHelper"),this.viewer3D=e.viewer,this.databagId=e.viewer._data.databagId,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 i=e.viewer.getViewer().getScene();this.customPlaneManager=CLOUD.CustomPlaneManager.getInstance(i),this.initialize()}initialize(){let e=this;"integrateModel"==this.viewer3D._data.modelType&&null!=this.viewer3D._data.integrateDrawings?e._config.viewer.getLinksJson((function(t){t&&e.formatLinksData(t)})):"singleModel"==this.viewer3D._data.modelType&&this.getViews((function(t){let n=JSON.parse(t).viewList;for(let t=0;t<n.length;t++){const s=n[t];if(s.preview.path&&e.supportViewTypeMap[s.viewType]){e.drawingIds.push(s.id);var o=i.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 i.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:c,links:d}=a;l.indexOf("]")>0?r=n(l,h,c,o):t[h]?t[h]instanceof Array?t[h].push(o):t[h]=[o,t[h]]:t[h]=o,d.length>0&&i(d,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.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 n=this;this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager.getViewsById(e,(function(o){if(!o.data)return t&&t([]);n.integrateDataViews[e]=o,n.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&&n.supportViewTypeMap[t.viewType]){n.drawingIds.push(t.id);var a=i.DrawingView.toObject(t.viewPoint);a.origin.z+=t.elevation;var l={id:t.id,name:t.name,viewPort:a};r.push(l),n.drawingViews.push(t)}}n.drawingList=n.drawingList.concat(r),n.integrateDrawingList[e]=r,t&&t(r)}))}isInclude(e){return this.drawingIds.indexOf(e)>=0}getDrawingList(e,t){if(!e)return this.drawingList;this.getViewsById(e,(function(e){t&&t(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,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()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers").DrawingHelperConfig=function(){return{viewer:null}};class Ni{constructor(e,t,i,n){this.viewer3D=e,this.objectType=t,this.name="Editor",this._eventManager=i,this.isEditing=!1,"ExternalObject"===t&&"Viewer3D"===this.viewer3D.viewerType&&(this.externalObjectManager=new Glodon.Bimface.Plugins.ExternalObject.ExternalObjectManager(e))}begin(e){this.isEditing=!0;let t=this.getCanvasPosition(new THREE.Vector2(e.clientX,e.clientY));this.mouseDownPoint=t.clone(),this.hitItem=this.hitTest(t),this.hitItem&&"Model"===this.objectType&&this._fireModelEvent("ModelTransformStart")}onEditing(e){}end(e){this.hitItem&&"Model"===this.objectType&&this._fireModelEvent("ModelTransformEnd"),this.isEditing=!1}hitTest(e){let t=[...this.dataDrawables.getAllDrawables()].reverse();for(const i of t){let t=i.hitTest(e);if(t)return t}return null}getCanvasPosition(e){let t=this.viewer3D.getDomElement().getBoundingClientRect(),i=new THREE.Vector3(e.x,e.y);return i.x-=t.left,i.y-=t.top,i}setEditedObjectId(e){if(this.editedObjectId=e,this.viewer3D instanceof Glodon.Bimface.Viewer.ViewerGIS){const t=this.viewer3D.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i<t.length;i++){const n=t[i].getExternalObjectManager();if(n.getAllObjectIds().includes(e)){this.externalObjectManager=n;break}}}}getEditedObjectId(){return this.editedObjectId}setDrawables(e){this.dataDrawables=e}getDrawables(){return this.dataDrawables}getBoundingBoxWorld(){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundingBoxWorld()}_fireModelEvent(e){const t=this.viewer3D.getModel(this.editedObjectId),i=this._eventManager;let n={modelId:this.editedObjectId,transformation:t.getModelTransformation()};i.fireEvent(e,n)}updateController(e){}}class Hi extends Ni{constructor(e,t,i,n){super(e,t,i,n),this.dataDrawables=null,this.isMouseDown=!1,this.mouseDownPoint=null,this.hitItem=null,this.lastHoveredItem=null,this.name="Translation",this.translationController=n,this._center=new THREE.Vector3}begin(e){super.begin(e),this.hitItem&&(e.preventDefault(),e.stopPropagation())}onEditing(e){let t=this.getCanvasPosition(new THREE.Vector2(e.clientX,e.clientY)),i=this.viewer3D.getViewer();if(this.getBoundingBoxWorld().getCenter(this._center),this.hitItem){let n,o,s=this.dataDrawables.getRotationMatrix(),r=this.viewer3D.sceneToWorld(i.camera.position.clone()),a=t.clone().sub(this.mouseDownPoint),l=e.clientX,h=e.clientY,c=i.cameraControl.getRaycaster(l,h),d=this.viewer3D.sceneToWorld(c.ray.direction).normalize();if(this.hitItem.isArrow()){if(0==a.length())return;let e;switch(this.hitItem.id){case"arrowX":if(!this.translationController.X)return;e=new THREE.Vector3(1,0,0).applyMatrix4(s).normalize();break;case"arrowY":if(!this.translationController.Y)return;e=new THREE.Vector3(0,-1,0).applyMatrix4(s).normalize();break;case"arrowZ":if(!this.translationController.Z)return;e=new THREE.Vector3(0,0,1).applyMatrix4(s).normalize()}n=new THREE.Ray(this._center.clone(),e);let t=d.clone().cross(d.clone().cross(e));o=new THREE.Plane(t);let i=-o.distanceToPoint(r);o.set(t,i),n.intersectsPlane(o)||n.set(n.origin.clone(),e.clone().negate())}else{if(0==a.length()||!this.checkTranslateEN(this.hitItem))return;let e;switch(this.hitItem.id){case"xy":e=new THREE.Vector3(0,0,-1);break;case"xz":e=new THREE.Vector3(0,1,0);break;case"yz":e=new THREE.Vector3(-1,0,0)}e.applyMatrix4(s).normalize(),o=new THREE.Plane(e);let t=-o.distanceToPoint(this._center);if(o.set(e,t),n=new THREE.Ray(r,d),!n.intersectsPlane(o))return}let u=new THREE.Vector3;n.intersectPlane(o,u),this.mouseDownOffset=this.mouseDownOffset||u.clone().sub(this._center);let g=u.clone().sub(this._center).sub(this.mouseDownOffset);this.setObjectTranslation(g),this.dataDrawables.update(),this.dataDrawables.setGray(),this.hitItem.select(),this.hitItem.magnify(),this.dataDrawables.hideAll(),this.hitItem.show(),this.mouseDownPoint.copy(t),e.preventDefault(),e.stopPropagation()}else{let e=this.hitTest(t);e?this.checkTranslateEN(e)&&(this.dataDrawables.setGray(),e.magnify(),e.select(),this.lastHoveredItem=e):(this.dataDrawables.setDefault(),this.lastHoveredItem&&this.lastHoveredItem.resetSize(),this.lastHoveredItem=null)}}end(e){super.end(e),this.hitItem&&(e.preventDefault(),e.stopPropagation(),this.dataDrawables.showAll(),this.hitItem=null),this.mouseDownOffset=null}setObjectTranslation(e){const t=this.objectType;if("ExternalObject"===t)this.externalObjectManager.translate(this.editedObjectId,e);else if("Model"===t){this.viewer3D.getModel(this.editedObjectId).setModelTranslation(e),this._fireModelEvent("ModelTransforming")}}updateController(e){null!=e.X&&(this.translationController.X=e.X),null!=e.Y&&(this.translationController.Y=e.Y),null!=e.Z&&(this.translationController.Z=e.Z)}checkTranslateEN(e){let t=!0,i=e.id;return e.isArrow()?("arrowY"!==i||this.translationController.Y||(t=!1),"arrowZ"!==i||this.translationController.Z||(t=!1),"arrowX"!==i||this.translationController.X||(t=!1)):("xz"!==i||this.translationController.X&&this.translationController.Z||(t=!1),"xy"!==i||this.translationController.X&&this.translationController.Y||(t=!1),"yz"!==i||this.translationController.Y&&this.translationController.Z||(t=!1)),t}}class zi{constructor(){}}zi.discreteCircle=function(e){let t=e.center.clone(),i=t.clone().distanceTo(e.arcStartPt),n=e.normal.clone(),o=e.arcStartPt.clone().sub(t).normalize(),s=[],r=e.rotateAngle/(Math.PI/180);for(let e=0;e<r;e++){o.applyAxisAngle(n,Math.PI/180);let e=t.clone().add(o.clone().multiplyScalar(i));s.push(e)}return e.rotateAngle==2*Math.PI&&s.push(s[0]),s},zi.drawingToCanvas=function(e,t){let i=this.getCoordinateAxis().start.clone(),n=this.cameraControl.camera,o=new THREE.Vector3;if(null==this.cameraToCenter){let e=this.viewer.getCamera(),t=this.viewer.getScene().getBoundingBox();n.setStandardView(CLOUD.EnumStandardView.ISO,t),n.zoomToBBox(t),i=this.getCoordinateAxis().start.clone(),this.cameraToCenter=i.clone().sub(n.position.clone()).length();let o=this.viewer.getScene().getMatrixGlobal(),s=CLOUD.CameraUtil.parseCameraInfo(e),r=CLOUD.Camera.worldToDrawing(s,o),a=new THREE.Vector3;a.subVectors(r.target,r.position),n.LookAt(r.target,a,r.up),this.cameraControl.update(!0,!0)}else{let e=i.clone().sub(n.position.clone()).normalize(),t=n.position.clone().sub(i.clone()).length();o=e.multiplyScalar(this.cameraToCenter-t)}let s=this.container.offsetWidth,r=this.container.offsetHeight;!1!==t&&n.isPerspective&&e.add(o);let a=CLOUD.CameraUtil.drawingToCanvas(n,e,s,r);return new THREE.Vector2(a.x,a.y)},zi.minDistanceToPoints=function(e,t,i){let n=-1,o=Number.POSITIVE_INFINITY;for(let a=0;a<i;a++){let i=(s=e,((r=t[a]).x-s.x)**2+(r.y-s.y)**2);i<o&&(o=i,n=a)}var s,r;return n},zi.computeSegmentsIntersect=function(e,t,i,n){var o=(e.x-i.x)*(t.y-i.y)-(e.y-i.y)*(t.x-i.x),s=(e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x);if(o*s>0)return!1;var r=(i.x-e.x)*(n.y-e.y)-(i.y-e.y)*(n.x-e.x);if(r*((i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x))>0)return!1;var a=r/(s-o),l=a*(t.x-e.x),h=a*(t.y-e.y);return{x:e.x+l,y:e.y+h}};class Wi extends Ni{constructor(e,t,i,n){super(e,t,i,n),this.dataDrawables=null,this.isMouseDown=!1,this.mouseDownPoint=null,this.hitItem=null,this.rotateAngle=0,this.lastHoveredItem=null,this.name="Rotation",this.rotationController=n}begin(e){if(super.begin(e),this.hitItem){let t=this.getCanvasPosition(new THREE.Vector2(e.clientX,e.clientY)),i=this.hitItem.getId(),n=this.dataDrawables.quarterRings.getFullRingPts(i);this.lastHitIndex=zi.minDistanceToPoints(t,n,90),this.firstHitIndex=this.lastHitIndex,e.preventDefault(),e.stopPropagation()}}onEditing(e){let t=this.getCanvasPosition(new THREE.Vector2(e.clientX,e.clientY));if(this.hitItem){let i=this.hitItem.getId();if(!this.checkRotationEN(i))return;this.dataDrawables.isOnQuarterRing&&this.dataDrawables.toFullRing(i),this.dataDrawables.hideAll(),this.hitItem.show();let n=this.dataDrawables.quarterRings.getFullRingPts(i),o=zi.minDistanceToPoints(t,n,360),s=(o-this.lastHitIndex)*(Math.PI/180);if(this.rotateAngle+=s/(Math.PI/180),0===s)return;this.dataDrawables.updateRotationTips(i,this.firstHitIndex,o,this.rotateAngle),this.lastHitIndex=o,this.setRotation(s),this.dataDrawables.updateBoundingBox(),this.viewer3D.render(),this.mouseDownPoint.copy(t),e.preventDefault(),e.stopPropagation()}else{let e=this.hitTest(t);e?this.checkRotationEN(e.getId())&&(this.dataDrawables.setGray(),e.magnify(),e.select(),this.lastHoveredItem=e):(this.dataDrawables.setRotationEN(),this.lastHoveredItem&&this.lastHoveredItem.resetSize(),this.lastHoveredItem=null)}}end(e){super.end(e),this.hitItem&&(e.preventDefault(),e.stopPropagation(),this.dataDrawables.isOnQuarterRing||(this.dataDrawables.fromFullRing(this.hitItem.getId()),this.dataDrawables.removeRotationTips()),this.rotateAngle=0,this.dataDrawables.showAll(),this.hitItem=null)}setRotation(e){const t=this.objectType,i=this.hitItem.getId(),n=this.dataDrawables.getEditObjectCenter();if("ExternalObject"===t){if("xy"===i){if(!this.rotationController.Z)return;this.externalObjectManager.setRotationZ(this.editedObjectId,n,e)}if("xz"===i){if(!this.rotationController.Y)return;this.externalObjectManager.setRotationY(this.editedObjectId,n,-e)}if("yz"===i){if(!this.rotationController.X)return;this.externalObjectManager.setRotationX(this.editedObjectId,n,e)}}else if("Model"==t){const t=this.viewer3D.getModel(this.editedObjectId);if("xy"===i){if(!this.rotationController.Z)return;t.setModelRotationZ(n,e)}if("xz"===i){if(!this.rotationController.Y)return;t.setModelRotationY(n,-e)}if("yz"===i){if(!this.rotationController.X)return;t.setModelRotationX(n,e)}this._fireModelEvent("ModelTransforming")}}updateController(e){null!=e.X&&(this.rotationController.X=e.X),null!=e.Y&&(this.rotationController.Y=e.Y),null!=e.Z&&(this.rotationController.Z=e.Z)}checkRotationEN(e){let t=!0;return"xz"!==e||this.rotationController.Y||(t=!1),"xy"!==e||this.rotationController.Z||(t=!1),"yz"!==e||this.rotationController.X||(t=!1),t}}class Ui extends Ni{constructor(e,t,i,n){super(e,t,i,n),this.dataDrawables=null,this.isMouseDown=!1,this.mouseDownPoint=null,this.hitItem=null,this.lastHoveredItem=null,this.name="Scaling",this.scaleController=n,this.windowHight=this.viewer3D.getDomElement().getBoundingClientRect().height}begin(e){super.begin(e),this.hitItem&&(e.preventDefault(),e.stopPropagation())}onEditing(e){let t=this.getCanvasPosition(new THREE.Vector2(e.clientX,e.clientY));if(this.hitItem){let i=t.clone().sub(this.mouseDownPoint);if(0==i.length())return;let n=i.clone().projectOnVector(this.hitItem.getDirection()),o=i.clone().angleTo(this.hitItem.getDirection())<=Math.PI/2?1:-1,s=n.length();if(!this.checkScalerEnable(this.hitItem.id))return;let r=this.dataDrawables.getDirection(this.hitItem.id),a=1+o*(s/this.windowHight);r.multiplyScalar(a),0===r.x&&(r.x=1),0===r.y&&(r.y=1),0===r.z&&(r.z=1);let l=this.dataDrawables.getOppositeSideCenter(this.hitItem.id);this.setObjectScale(l,r),this.dataDrawables.update(this.hitItem.id),this.dataDrawables.hideAll(),this.hitItem.show(),this.hitItem.magnify(),this.mouseDownPoint.copy(t),e.preventDefault(),e.stopPropagation()}else{let e=this.hitTest(t);e?this.checkScalerEnable(e.id)&&(this.dataDrawables.update(e.id),this.dataDrawables.setGray(),e.magnify(),e.select(),this.lastHoveredItem=e):(this.dataDrawables.setDefault(),this.lastHoveredItem&&this.lastHoveredItem.resetSize(),this.dataDrawables.updateHighlightBBoxFace(),this.lastHoveredItem=null)}}end(e){super.end(e),this.hitItem&&(e.preventDefault(),e.stopPropagation(),this.dataDrawables.showAll(),this.hitItem=null)}setObjectScale(e,t){const i=this.objectType;"ExternalObject"===i?this.externalObjectManager.scaleOnBasePoint(this.getEditedObjectId(),e,t):"Model"===i&&(this.viewer3D.getModel(this.getEditedObjectId()).setModelScale(e,t),this._fireModelEvent("ModelTransforming"))}updateController(e){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)}checkScalerEnable(e){let t=!0;switch(e){case"CoordOrigin":this.scaleController.Uniform||(t=!1);break;case"x+":case"x-":this.scaleController.X||(t=!1);break;case"y+":case"y-":this.scaleController.Y||(t=!1);break;case"z+":case"z-":this.scaleController.Z||(t=!1)}return t}}class Fi extends Li{constructor(e){super(),this.config=e,this.colors=["#FF2905","#1922FB","#32D3A6"]}update(e){if(this.drawables.length>0){let t=0;for(const i of this.drawables)i.update(e.slice(5*t,5*(t+1))),t++;return}let t=["xy","xz","yz"];for(let i=0;i<3;i++){let n=new Gi({id:t[i]});n.update(e.slice(5*i,5*(i+1))),this.drawables.push(n)}}hitTest(e){for(const t of this.drawables){let i=new THREE.Vector2(e.x,e.y),n=t.hitTest(i);if(n)return n}return null}setGray(){for(const e of this.drawables)e.setGray()}setDefault(){for(const e of this.drawables)e.setDefault()}hide(){for(const e of this.drawables)e.hide()}show(){for(const e of this.drawables)e.show()}}class Gi extends Li{constructor(e){super(),this.id=e.id}update(e){this.drawables=[];let t=this.makePolyline(e);this.drawables.push(t)}makePolyline(e){let t={};return t.points=ii.calcPolylinePoints(e),t.width="3px",t.fillColor="#F99D0B",t.color="#F99D0B",this.position=new THREE.Vector2,e.forEach((e=>{this.position.x+=e.x,this.position.y+=e.y})),this.position.multiplyScalar(.2),ii.makePolyline(t)}hitTest(e){return new THREE.Vector2(e.x,e.y).clone().distanceTo(this.position)<=this.hitTestEpsilon?this:null}setGray(){for(const e of this.drawables)e.style.fill=this.grayColor,e.style.stroke=this.grayColor}setDefault(){for(const e of this.drawables)e.style.fill="#F99D0B",e.style.stroke="#F99D0B"}select(){for(const e of this.drawables)e.style.fill=this.highlightColor,e.style.stroke=this.highlightColor}getDirection(){let 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;return"xy"==this.id?n.addVectors(e,t).normalize():"xz"==this.id?n.addVectors(e,i).normalize():"yz"==this.id&&n.addVectors(t,i).normalize(),n}getLocalCoordAxis(){let e=new THREE.Vector3(1,0,0),t=new THREE.Vector3(0,-1,0),i=new THREE.Vector3(0,0,1),n=[];return"xy"==this.id?n.push(e,t):"xz"==this.id?n.push(e,i):"yz"==this.id&&n.push(t,i),n}hide(){for(const e of this.drawables)e.style.display="none"}show(){for(const e of this.drawables)e.style.display="block"}}class ji extends Li{constructor(e){super(),this.config=e,this.start=null,this.target=null,this.isEffectedByOthers=!!e.isEffectedByOthers}update(e,t){this.drawables=[];let i={color:this.config.color,lineWidth:"1px",start:e,end:t},n=ii.makeDashLine(i);this.drawables.push(n)}setGray(){if(this.isEffectedByOthers){this.drawables[0].setAttribute("stroke",this.grayColor)}}setDefault(){if(this.isEffectedByOthers){this.drawables[0].setAttribute("stroke",this.config.color)}}hide(){if(this.isEffectedByOthers){this.drawables[0].style.display="none"}}show(){if(this.isEffectedByOthers){this.drawables[0].style.display="block"}}}class $i extends Li{constructor(e){super(),this.config=e||{},this.colors=e.colors}update(e,t){if(this.drawables.length>0){let i=0;for(const n of this.drawables){let o=this.toVector2(e),s=this.toVector2(t[i]);n.update(o,s),i++}}else for(let i=0;i<t.length;i++){let n=new ji({color:this.colors[Math.floor(i)],isEffectedByOthers:this.config.isEffectedByOthers}),o=this.toVector2(e),s=this.toVector2(t[i]);n.update(o,s),this.drawables.push(n)}}hitTest(e){for(const t of this.drawables){let i=new THREE.Vector2(e.x,e.y),n=t.hitTest(i);if(n)return n}return null}setGray(){for(const e of this.drawables)e.setGray()}setDefault(){for(const e of this.drawables)e.setDefault()}hide(){for(const e of this.drawables)e.hide()}show(){for(const e of this.drawables)e.show()}}class Xi extends Li{constructor(){super(),this.coordinateOrigin=new THREE.Vector3,this.style.length=130,this.style.axisX={},this.style.axisX.color="#FF2905",this.style.axisY={},this.style.axisY.color="#1922FB",this.style.axisZ={},this.style.axisZ.color="#32D3A6",this.axisColors=["#FF2905","#1922FB","#32D3A6"],this.markerIds=["arrowX","arrowY","arrowZ"],this.arrowTargets=[]}update(e,t){this.arrowTargets=[];let i=new THREE.Vector2(e.x,e.y);if(this.drawables.length>0){let e=0;for(const n of t){let t=new THREE.Vector2(n.x,n.y);this.drawables[e++].update(i,t)}return}let n=0;for(const e of t){let t=new THREE.Vector2(e.x,e.y),o=new Vi({id:this.markerIds[n],color:this.axisColors[n++]});o.update(i,t),this.drawables.push(o)}}getDefaultStyle(){return{lineWidth:"4px",color:"#FF2905"}}hitTest(e){for(const t of this.drawables){let i=new THREE.Vector2(e.x,e.y),n=t.hitTest(i);if(n)return n}return null}setDefault(){for(const e of this.drawables)e.setDefault()}select(){for(const e of this.drawables)e.select()}setGray(){for(const e of this.drawables)e.setGray()}hide(){for(const e of this.drawables)e.hide()}show(){for(const e of this.drawables)e.show()}getOrigin(){return this.coordinateOrigin}setOrigin(e){this.coordinateOrigin.set(e.x,e.y,e.z)}}class Yi extends Li{constructor(e){super(),this.domContainer=e,this.style.color="#11DAB7",this.style.backColor="#939E9C",this.style.border="1px"}update(e,t,i){this.drawables=[];const n=(n,o)=>{let s=!1;(i[n]||i[o])&&(s=!0),t.indexOf(n)<0&&t.indexOf(o)<0&&this.makePolyline([e[n],e[o]],s)};n(0,1),n(1,5),n(5,4),n(4,0),n(0,3),n(1,2),n(5,6),n(4,7),n(3,2),n(2,6),n(6,7),n(7,3)}getDrawables(){return this.drawables}makePolyline(e,t){let i,n,o=this.getDefaultStyle(t),s=this.domContainer.width.baseVal.value,r=this.domContainer.height.baseVal.value,a=[];const l=(e,t)=>{let i={x:0,y:0},n={x:0,y:r},o={x:s,y:r},a={x:s,y:0},l=[];const h=(i,n)=>{let o=zi.computeSegmentsIntersect(e,t,i,n);o&&l.push(o)};return h(i,n),h(n,o),h(o,a),h(a,i),l},h=e=>e.x>=0&&e.x<=s&&e.y>=0&&e.y<=r,c=()=>{if(a.length>0){if(i){let e=a[a.length-1];h(e);let t=l(e,i);1===t.length&&a.push(t[0])}o.points=ii.calcPolylinePoints(a),this.drawables.push(ii.makePolyline(o))}if(a=[],n<e.length-1){let t=l(i,e[n+1]);1===t.length?a.push(t[0]):2===t.length&&(o.points=ii.calcPolylinePoints(t),this.drawables.push(ii.makePolyline(o)))}i=void 0};for(n=0;n<e.length;n++){const t=e[n];h(t)?a.push(t):(i=t,c())}a.length>0&&c()}getDefaultStyle(e){return{color:!0===e?this.style.backColor:this.style.color,width:this.style.border}}}class Zi{constructor(e,t,i,n,o){this.viewer3D=e,this.domContainer=t,this.objectId=i,this.objectType=n,this.controller=o,this.scratchVector=new THREE.Vector3,this._center=new THREE.Vector3,this._cCenter=new THREE.Vector3,this._quarterCenter=new THREE.Vector3,this._modelCenter=new THREE.Vector3,this._bCenter=new THREE.Vector3,this.updateFactor(),this.initialize()}initialize(){}updateFactor(){const e=this.getBoundingBoxWorld().getCenter(this.scratchVector),t=this.viewer3D.getViewer().camera,i=this.viewer3D.sceneToWorld(t.position),n=e.clone().sub(new THREE.Vector3(i.x,i.y,i.z)).length(),o=2*Math.tan(t.fov*Math.PI/360)*n,s=this.viewer3D.getDomElement().offsetHeight;this.factor=o/s}updateBoundingBox(){let e=this.viewer3D.getViewer(),t=[],i=this.getBoundaryPoints(),n=[],o=[],s={},r=new THREE.Vector3,a=new THREE.Plane(this.viewer3D.sceneToWorld(e.camera.getWorldDirection(r)).normalize()),l=this.viewer3D.sceneToWorld(e.camera.position),h=a.distanceToPoint(l);a.constant=-h;this.getBoundingBoxWorld().getCenter(this._center);let c=[];const d=this._center.clone().distanceTo(l);i.forEach((e=>{t.push(e);const i=t.length-1;a.distanceToPoint(e)<0&&n.push(i);let r=this.viewer3D.worldToClient(e);r.index=i;const h={distance:e.distanceTo(l),index:i,screenPoint:r};s[i]=!0,c.push(h.screenPoint),o.push(h)}));(e=>{if(n.length>0||c[0].x===c[4].x&&c[0].y===c[4].y||c[1].x===c[5].x&&c[1].y===c[5].y||c[2].x===c[6].x&&c[2].y===c[6].y||c[3].x===c[7].x&&c[3].y===c[7].y){for(let e=0;e<8;++e)s[e]=!1;return}let i=[];((e,t,i)=>{let n,o,s=(e,t,i)=>(t.x-e.x)*(i.y-e.y)-(i.x-e.x)*(t.y-e.y),r=(e,t)=>(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y),a=0,l=2,h=new Object;for(n=1;n<i;n++)(e[n].y<e[a].y||e[n].y==e[a].y&&e[n].x<e[a].x)&&(a=n);h=e[0],e[0]=e[a],e[a]=h;let c=i;for(n=1;n<c-1;n++){for(a=n,o=n+1;o<c;o++){let t=s(e[0],e[a],e[o]);if(t>0)a=o;else if(0==t){c--,r(e[0],e[o])-r(e[0],e[a])>0?(e[a]=e[o],e[o]=e[c],o--):(h=e[c],e[c]=e[o],e[o]=h)}}h=e[n],e[n]=e[a],e[a]=h}for(t.push(e[0]),t.push(e[1]),t.push(e[2]),n=3;n<c;n++){for(;!(s(e[n],t[l-1],t[l])<0);)l--,t.pop();l++,t.push(e[n])}})(c,i,8);for(let e=0;e<i.length;++e)s[i[e].index]=!1;for(let i=0;i<t.length;++i)!1!==s[e[i].index]&&d>e[i].distance&&(s[e[i].index]=!1)})(o);let u=[];for(const e of t)u.push(this.viewer3D.worldToClient(e));this.boundingBox||(this.boundingBox=new Yi(this.domContainer),this.drawables.push(this.boundingBox)),this.boundingBox.detach(),this.boundingBox.update(u,n,s),this.boundingBox.attach(this.domContainer)}getBoundaryPoints(){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundaryPoints(this.objectId);return this.viewer3D.getViewer().getModelManager().getModel(this.objectId).getBoundaryPoints()}getBoundingBoxWorld(){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(this.objectId);return this.viewer3D.getViewer().getModelManager().getModel(this.objectId).getBoundingBoxWorld()}getTransformMatrix(){if("ExternalObject"===this.objectType){let e=this.viewer3D.getExternalComponentManager().getTransform(this.objectId);return(new THREE.Matrix4).compose(e.position,e.rotate,e.scale)}return this.viewer3D.getViewer().getModelManager().getModel(this.objectId).getTransformMatrix().clone()}getRotationMatrix(){let e=new THREE.Matrix4,t=this.getTransformMatrix();return e.extractRotation(t),e}}class qi extends Zi{constructor(e,t,i,n,o){super(e,t,i,n,o)}initialize(){this.drawables=[],this.updateBoundingBox(),this.updateCoordinateAxis(),this.updateFaces(),this.addCloudViewerEvents()}updateFaces(){this.getBoundingBoxWorld().getCenter(this.scratchVector);let e=this.getRotationMatrix(),t=20*this.factor,i=new THREE.Vector3(t,0,0).applyMatrix4(e),n=new THREE.Vector3(0,-t,0).applyMatrix4(e),o=new THREE.Vector3(0,0,t).applyMatrix4(e),s=[];t*=.3;let r=this.scratchVector.clone().add(new THREE.Vector3(t,-t,0).applyMatrix4(e));s.push(r),s.push(r.clone().add(i)),s.push(r.clone().add(i).add(n)),s.push(r.clone().add(n)),s.push(r);let a=this.scratchVector.clone().add(new THREE.Vector3(t,0,t).applyMatrix4(e));s.push(a),s.push(a.clone().add(i)),s.push(a.clone().add(i).add(o)),s.push(a.clone().add(o)),s.push(a);let l=this.scratchVector.clone().add(new THREE.Vector3(0,-t,t).applyMatrix4(e));s.push(l),s.push(l.clone().add(n)),s.push(l.clone().add(n).add(o)),s.push(l.clone().add(o)),s.push(l);let h=[];for(const e of s)h.push(this.viewer3D.worldToClient(e));this.faceArray||(this.faceArray=new Fi,this.drawables.push(this.faceArray)),this.faceArray.detach(),this.faceArray.update(h),this.faceArray.attach(this.domContainer),this.setTranslateEN()}updateCoordinateAxis(){let e=this.getBoundingBoxWorld(),t=this.getRotationMatrix(),i=[];i.push(new THREE.Vector3(1,0,0).applyMatrix4(t)),i.push(new THREE.Vector3(0,-1,0).applyMatrix4(t)),i.push(new THREE.Vector3(0,0,1).applyMatrix4(t));let n=new THREE.Vector3;n=this.viewer3D.worldToClient(e.getCenter(n)),this.coordinateAxis||(this.coordinateAxis=new Xi,this.drawables.push(this.coordinateAxis)),this.coordinateAxis.setOrigin(n);let o=[];for(const t of i){let i=t.clone().multiplyScalar(130*this.factor).add(e.getCenter(this.scratchVector)),n=this.viewer3D.worldToClient(i);o.push(n)}this.dashlineArray||(this.dashlineArray=new $i({length:116,colors:["#FF2905","#1922FB","#32D3A6"]}),this.drawables.push(this.dashlineArray)),this.dashlineArray.detach(),this.dashlineArray.update(n,o),this.dashlineArray.attach(this.domContainer),this.coordinateAxis.detach(),this.coordinateAxis.update(n,o),this.coordinateAxis.attach(this.domContainer),this.setTranslateEN()}getDirection(e){return"arrowX"===e?new THREE.Vector3(1,0,0):"arrowY"===e?new THREE.Vector3(0,-1,0):new THREE.Vector3(0,0,1)}attach(){this.boundingBox.attach(this.domContainer)}addCloudViewerEvents(){let e=this.viewer3D.getViewer();this.updateBinded=this.update.bind(this),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}removeCloudViewerEvents(){let e=this.viewer3D.getViewer();e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}update(){document.getElementsByClassName("bf-ObjectEditor-svg")[0].setAttribute("transform","translate(0,0)"),this.updateFactor(),this.updateBoundingBox(),this.updateCoordinateAxis(),this.updateFaces()}getAllDrawables(){return this.drawables}setDefault(){for(const e of this.getAllDrawables())e.setDefault()}setGray(){for(const e of this.getAllDrawables())e.setGray()}select(e){for(const t of this.getAllDrawables())if(t.select(e))return}hideAll(){for(const e of this.getAllDrawables())e.hide()}showAll(){for(const e of this.getAllDrawables())e.show()}dispose(){this.domContainer.innerHTML="",this.boundingBox=null,this.CoordinateAxis=null,this.removeCloudViewerEvents()}updateController(e){null!=e.X&&(this.controller.X=e.X),null!=e.Y&&(this.controller.Y=e.Y),null!=e.Z&&(this.controller.Z=e.Z)}setTranslateEN(){!this.faceArray||this.faceArray.drawables.length<=0||(this.controller.Y?(this.coordinateAxis.drawables[1].show(),this.dashlineArray.drawables[1].hide()):(this.coordinateAxis.drawables[1].hide(),this.dashlineArray.drawables[1].show(),this.faceArray.drawables[0].hide(),this.faceArray.drawables[2].hide()),this.controller.Z?(this.coordinateAxis.drawables[2].show(),this.dashlineArray.drawables[2].hide()):(this.coordinateAxis.drawables[2].hide(),this.dashlineArray.drawables[2].show(),this.faceArray.drawables[2].hide(),this.faceArray.drawables[1].hide()),this.controller.X?(this.coordinateAxis.drawables[0].show(),this.dashlineArray.drawables[0].hide()):(this.coordinateAxis.drawables[0].hide(),this.dashlineArray.drawables[0].show(),this.faceArray.drawables[1].hide(),this.faceArray.drawables[0].hide()),this.controller.X&&this.controller.Y&&this.faceArray.drawables[0].show(),this.controller.X&&this.controller.Z&&this.faceArray.drawables[1].show(),this.controller.Z&&this.controller.Y&&this.faceArray.drawables[2].show())}}class Ki extends Li{constructor(){super(),this.hitTestEpsilon=18,this.id="CoordOrigin",this.style.color="#11DAB7",this.style.border="1px"}update(e,t,i=!0){this.drawables=[];let n=e;this.makePolyline([n[0],n[1],n[5],n[4],n[0]],i),this.makePolyline([n[3],n[2],n[6],n[7],n[3]],i),this.makePolyline([n[0],n[3],n[7],n[4],n[0]],i),this.makePolyline([n[1],n[2],n[6],n[5],n[1]],i),this.makePolyline([n[5],n[6],n[7],n[4],n[5]],i),this.makePolyline([n[1],n[2],n[3],n[0],n[1]],i),this.position=new THREE.Vector2(t.x,t.y)}getDrawables(){return this.drawables}makePolyline(e,t){let i=this.getDefaultStyle();i.points=ii.calcPolylinePoints(e),t&&(i.width="0px",i.fillColor="#F99D0B"),this.drawables.push(ii.makePolyline(i))}getDefaultStyle(){return{color:"#11DAB7",width:"1px"}}setGray(){for(const e of this.drawables)e.style.fill=this.grayColor}setDefault(){for(const e of this.drawables)e.style.fill="#F99D0B"}select(){for(const e of this.drawables)e.style.fill=this.highlightColor}hide(){for(const e of this.drawables)e.style.display="none"}show(){for(const e of this.drawables)e.style.display="block"}hitTest(e){return new THREE.Vector2(e.x,e.y).distanceTo(this.position)<=this.hitTestEpsilon?this:null}getDirection(){return new THREE.Vector3(1,0,0)}}class Ji extends Li{constructor(e){super(),this.id="HighlightBBoxFace",this.update(e)}update(e){this.drawables=[],e&&this.makePolyline(e)}makePolyline(e){let t={width:"0px",fillColor:"#E3FFF7",opacity:.6};t.points=ii.calcPolylinePoints(e),this.drawables.push(ii.makePolyline(t))}setGray(){}}class Qi extends Zi{constructor(e,t,i,n,o){super(e,t,i,n,o)}initialize(){this.drawables=[],this.arrows=[],this.updateBoundingBox(),this.updateBboxArrow(),this.updateCoordOrigin(),this.addCloudViewerEvents()}updateCoordOrigin(){let e=this.getBoundingBoxWorld(),t=this.getRotationMatrix(),i=20*this.factor,n=new THREE.Vector3;e=(new THREE.Box3).setFromCenterAndSize(e.getCenter(n),new THREE.Vector3(i,i,i)),e.getCenter(this._bCenter);let o=[];o.push(new THREE.Vector3(e.max.x,e.max.y,e.max.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.min.x,e.max.y,e.max.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.min.x,e.min.y,e.max.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.max.x,e.min.y,e.max.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.max.x,e.max.y,e.min.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.min.x,e.max.y,e.min.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.min.x,e.min.y,e.min.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter)),o.push(new THREE.Vector3(e.max.x,e.min.y,e.min.z).sub(this._bCenter).applyMatrix4(t).add(this._bCenter));let s=[];for(const e of o)s.push(this.viewer3D.worldToClient(e));n=this.viewer3D.worldToClient(e.getCenter(n)),this.coordOrigin||(this.coordOrigin=new Ki,this.drawables.push(this.coordOrigin)),this.coordOrigin.detach(),this.coordOrigin.update(s,n),this.coordOrigin.attach(this.domContainer),this.setScaleEN()}updateBboxArrow(){let e=this.getBoundingBoxWorld(),t=[];t.push(this.getOppositeSideCenter("x+")),t.push(this.getOppositeSideCenter("x-")),t.push(this.getOppositeSideCenter("y+")),t.push(this.getOppositeSideCenter("y-")),t.push(this.getOppositeSideCenter("z+")),t.push(this.getOppositeSideCenter("z-"));let i=[];for(const e of t)i.push(this.viewer3D.worldToClient(e.clone()));let n=new THREE.Vector3;n=this.viewer3D.worldToClient(e.getCenter(n)),n=new THREE.Vector2(n.x,n.y);let o=[];for(const i of t){let t=i.clone(),n=new THREE.Vector3,s=t.clone().sub(e.getCenter(n).clone()).normalize().multiplyScalar(50*this.factor).add(t),r=this.viewer3D.worldToClient(s);o.push(r)}this.arrowArray||(this.arrowArray=new en({id:1,color:"#FF0000"}),this.drawables.push(this.arrowArray)),this.arrowArray.detach(),this.arrowArray.update(i,o),this.arrowArray.attach(this.domContainer),this.dashlineArray||(this.dashlineArray=new $i({colors:["#FF2905","#1922FB","#32D3A6"]})),this.dashlineArray.detach(),this.dashlineArray.update(n,[i[1],i[2],i[5]]),this.dashlineArray.attach(this.domContainer),this.setScaleEN()}getDirection(e){return e.includes("x")?new THREE.Vector3(1,0,0):e.includes("y")?new THREE.Vector3(0,1,0):e.includes("z")?new THREE.Vector3(0,0,1):new THREE.Vector3(1,1,1)}addCloudViewerEvents(){let e=this.viewer3D.getViewer();this.updateBinded=this.update.bind(this),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}removeCloudViewerEvents(){let e=this.viewer3D.getViewer();e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}update(e){document.getElementsByClassName("bf-ObjectEditor-svg")[0].setAttribute("transform","translate(0,0)"),this.updateFactor(),this.updateHighlightBBoxFace(e),this.updateBoundingBox(),this.updateBboxArrow(),this.updateCoordOrigin()}getOppositeSideCenter(e){let t=this.getBoundaryPoints(),i=null;const n=(e,i,n,o)=>{let s=t[e],r=t[i],a=t[n],l=t[o];return(new THREE.Vector3).add(s).add(r).add(a).add(l).multiplyScalar(.25)};switch(e){case"x+":i=n(0,3,7,4);break;case"x-":i=n(1,2,6,5);break;case"y+":i=n(0,1,5,4);break;case"y-":i=n(2,3,7,6);break;case"z+":i=n(0,1,2,3);break;case"z-":i=n(4,5,6,7);break;default:i=n(0,1,2,3).add(n(4,5,6,7)).multiplyScalar(.5)}return i}updateHighlightBBoxFace(e){if(!e&&this.highlightBBoxFace)return void this.highlightBBoxFace.detach();let t=this.getBoundaryPoints(),i=null;const n=(e,i,n,o)=>{let s=this.viewer3D.worldToClient(t[e]);return[s,this.viewer3D.worldToClient(t[i]),this.viewer3D.worldToClient(t[n]),this.viewer3D.worldToClient(t[o]),s]};switch(e){case"x-":i=n(0,3,7,4);break;case"x+":i=n(1,2,6,5);break;case"y-":i=n(0,1,5,4);break;case"y+":i=n(2,3,7,6);break;case"z-":i=n(0,1,2,3);break;case"z+":i=n(4,5,6,7)}this.highlightBBoxFace||(this.highlightBBoxFace=new Ji,this.drawables.push(this.highlightBBoxFace)),this.highlightBBoxFace.detach(),this.highlightBBoxFace.update(i),this.highlightBBoxFace.attach(this.domContainer)}getAllDrawables(){return this.drawables}setDefault(){for(const e of this.getAllDrawables())e.setDefault()}setGray(){for(const e of this.getAllDrawables())e.setGray()}select(e){for(const t of this.getAllDrawables())if(t.select(e))return}hideAll(){for(const e of this.getAllDrawables())e.hide()}showAll(){for(const e of this.getAllDrawables())e.show()}dispose(){this.domContainer.innerHTML="",this.boundingBox=null,this.coordOrigin=null,this.arrowArray=null,this.removeCloudViewerEvents()}updateController(e){null!=e.X&&(this.controller.X=e.X),null!=e.Y&&(this.controller.Y=e.Y),null!=e.Z&&(this.controller.Z=e.Z),null!=e.Uniform&&(this.controller.Uniform=e.Uniform)}setScaleEN(){!this.coordOrigin||this.coordOrigin.drawables.length<=0||(this.controller.Y?(this.arrowArray.drawables[2].show(),this.arrowArray.drawables[3].show()):(this.arrowArray.drawables[2].hide(),this.arrowArray.drawables[3].hide()),this.controller.Z?(this.arrowArray.drawables[4].show(),this.arrowArray.drawables[5].show()):(this.arrowArray.drawables[4].hide(),this.arrowArray.drawables[5].hide()),this.controller.X?(this.arrowArray.drawables[0].show(),this.arrowArray.drawables[1].show()):(this.arrowArray.drawables[0].hide(),this.arrowArray.drawables[1].hide()),this.controller.Uniform?this.coordOrigin.show():this.coordOrigin.hide())}}class en extends Li{constructor(e){super(),this.config=e,this.colors=["#FF2905","#1922FB","#32D3A6"]}update(e,t){if(this.drawables.length>0){let i=0;for(const n of this.drawables)n.update(this.toVector3(e[i]),this.toVector3(t[i])),i++;return}let i=["x-","x+","y-","y+","z-","z+"];for(let n=0;n<e.length;n++){let o=new Vi({id:i[n],color:this.colors[Math.floor(n/2)],length:40});o.update(this.toVector3(e[n]),this.toVector3(t[n])),this.drawables.push(o)}}hitTest(e){for(const t of this.drawables){let i=new THREE.Vector2(e.x,e.y),n=t.hitTest(i);if(n)return n}return null}setGray(){for(const e of this.drawables)e.setGray()}setDefault(){for(const e of this.drawables)e.setDefault()}hide(){for(const e of this.drawables)e.hide()}show(){for(const e of this.drawables)e.show()}}class tn extends Li{constructor(e){super(),this.id=e.id,this.config=e,this.config.highlightWidth="2px"}update(e){this.drawables=[],this.boundaryPts=e;let t={};t.points=ii.calcPolylinePoints(e),t.width="1px",t.color=this.config.color,t.fillColor=this.config.color,t.opacity=this.config.opacity;let i=ii.makePolyline(t);this.drawables.push(i),delete t.fillColor,delete t.opacity;let n=ii.makePolyline(t);this.drawables.push(n)}setGray(){let e=this.drawables[0];e.style.opacity=this.config.opacity,e.style.fill=this.grayColor;let t=this.drawables[1];t.setAttribute("stroke",this.grayColor),t.setAttribute("stroke-width","1px")}setDefault(){let e=this.drawables[0];e.style.opacity=this.config.opacity,e.style.fill=this.config.color;let t=this.drawables[1];t.setAttribute("stroke",this.config.color),t.setAttribute("stroke-width","1px")}select(){let e=this.drawables[0];e.style.opacity=this.config.opacity,e.style.fill=this.highlightColor;let t=this.drawables[1];t.setAttribute("stroke",this.highlightColor),t.setAttribute("stroke-width",this.config.highlightWidth)}hitTest(e){return ii.isPointInPolygon(e,this.boundaryPts)?this:null}hide(){this.drawables[0].style.display="none",this.drawables[1].style.display="none"}show(){this.drawables[0].style.display="block",this.drawables[1].style.display="block"}getBoundaryPts(){return this.boundaryPts}}class nn extends Li{constructor(e){super(),this.config=e,this.colors=["#32D3A6","#1922FB","#FF2905"],this.ids=["xy","xz","yz"]}update(e){if(this.drawables.length>0){let t=0;for(const i of this.drawables)i.update(e[t++])}else for(let t=0;t<e.length;t++){let i=new tn({color:this.colors[t],opacity:.15,id:this.ids[t]});i.update(e[t]),this.drawables.push(i)}}hitTest(e){for(const t of this.drawables){let i=new THREE.Vector2(e.x,e.y),n=t.hitTest(i);if(n)return n}return null}setDefault(){for(const e of this.drawables)e.setDefault()}setGray(){for(const e of this.drawables)e.setGray()}hide(){for(const e of this.drawables)e.hide()}show(){for(const e of this.drawables)e.show()}getFullRingPts(e){let t=null;return"xy"===e&&(t=this.drawables[0]),"xz"===e&&(t=this.drawables[1]),"yz"===e&&(t=this.drawables[2]),t?t.getBoundaryPts():[]}}class on extends Li{constructor(e){super(),this.id=e.id,this.config=e,this.mapColors={xy:"#32D3A6",xz:"#1922FB",yz:"#FF2905"}}updateRingTip(e,t){this.drawables=[],this.boundaryPts=e;let i={};i.points=ii.calcPolylinePoints(e),i.width="1px",i.color=this.mapColors[t],i.fillColor=this.mapColors[t];let n=ii.makePolyline(i);this.drawables.push(n)}updateRotationAxis(e,t,i){let n=ii.makeDashLine({color:this.mapColors[i],start:e,end:t});this.drawables.push(n)}updateRotationRangeLines(e,t,i,n){let o=ii.makeLine({color:this.mapColors[n],start:e,end:t});this.drawables.push(o);let s=ii.makeLine({color:this.mapColors[n],start:e,end:i});this.drawables.push(s)}hide(){for(const e of this.drawables)e.style.display="none"}show(){for(const e of this.drawables)e.style.display="block"}}class sn extends Li{constructor(){super(),this.backgroundColor="#111111",this.initialize()}initialize(){this.notationSegment={},this.notationOutline=null,this.annotationStyle={height:30,radius:3}}update(e,t){var i=this.calcAnnotationStyle(t,e),n=ii.makeRectangle({x:i.offsetRect.x,y:i.offsetRect.y,width:i.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:this.backgroundColor}),o=ii.makeText({x:i.offsetText.x,y:i.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});return this.drawables=[],this.drawables.push(n),this.drawables.push(o),this.drawables}calcAnnotationStyle(e,t){var i=0,n=new THREE.Vector2(t.x,t.y),o=new THREE.Vector2(t.x,t.y);return i=ii.measureText(e),n.x-=i/2,n.y-=this.annotationStyle.height/2,o.x=n.x+15,o.y=n.y+20,{offsetRect:n,offsetText:o,width:i+=30}}}class rn extends Zi{constructor(e,t,i,n,o){super(e,t,i,n,o)}initialize(){this.drawables=[],this.isOnQuarterRing=!0,this.rotationAxisLength=400,this.updateBoundingBox(),this.updateCoordinateAxis(),this.updateQuarterRings(),this.addCloudViewerEvents()}updateQuarterRings(e){this.getBoundingBoxWorld().getCenter(this._quarterCenter);let t=55*this.factor,i=this.getRotationMatrix(),n=new THREE.Vector3(2*t,0,0).applyMatrix4(i),o=new THREE.Vector3(0,-2*t,0).applyMatrix4(i),s=new THREE.Vector3(0,0,2*t).applyMatrix4(i),r=22/19,a=[Math.PI/2,Math.PI/2,Math.PI/2];this.isOnQuarterRing||("xy"===e&&(a[0]=2*Math.PI),"xz"===e&&(a[1]=2*Math.PI),"yz"===e&&(a[2]=2*Math.PI));let l=.02,h=this._quarterCenter.clone().add(new THREE.Vector3(l*t,-.02*t,0).applyMatrix4(i)),c=h.clone().add(o),d=h.clone().add(o.clone().multiplyScalar(r)),u=this._calcRingPts(h,s,c,d,a[0]),g=this._quarterCenter.clone().add(new THREE.Vector3(l*t,0,l*t).applyMatrix4(i));c=g.clone().add(n),d=g.clone().add(n.clone().multiplyScalar(r));let p=this._calcRingPts(g,o,c,d,a[1]),f=this._quarterCenter.clone().add(new THREE.Vector3(0,-.02*t,l*t).applyMatrix4(i));c=f.clone().add(s),d=f.clone().add(s.clone().multiplyScalar(r));let m=this._calcRingPts(f,n,c,d,a[2]);this.quarterRings||(this.quarterRings=new nn,this.drawables.push(this.quarterRings)),this.quarterRings.detach(),this.quarterRings.update([u,p,m]),this.setRotationEN(),this.quarterRings.attach(this.domContainer)}updateRotationTips(e,t,i,n){let o=this.getRotationMatrix(),s=this.quarterRings.getFullRingPts(e),r=s[t],a=s[i],l=this.getEditObjectCenter();this.rotationTips||(this.rotationTips=new on({})),this.rotationTips.detach();let h=[],c=[],d=i-t>0?1:-1;Math.abs(i-t>180)&&(d=-d);for(let e=t;e!=i+d;e+=d){e>=360&&(e=0),e<0&&(e=359),h.push(s[e]);let t=720-e+1;c.push(s[t])}let u=h.concat(c.reverse());this.rotationTips.updateRingTip(u,e);let g=new THREE.Vector3(0,0,1).applyMatrix4(o);"xz"===e&&(g=new THREE.Vector3(0,1,0).applyMatrix4(o)),"yz"===e&&(g=new THREE.Vector3(1,0,0).applyMatrix4(o));let p=this.calcSegment(l,g,400);this._clientCenter||(this._clientCenter=this.viewer3D.worldToClient(l)),this.rotationTips.updateRotationAxis(p[0],p[1],e),this.rotationTips.updateRotationRangeLines(this._clientCenter,r,a,e),this.rotationTips.attach(this.domContainer),this.rotateNotation||(this.rotateNotation=new sn),this.rotateNotation.detach();let f=this._calcNotationPos(this._clientCenter,a,48),m=n;m>180&&(m-=360),this.rotateNotation.update(f,m+"°"),this.rotateNotation.attach(this.domContainer)}removeRotationTips(){this.rotationTips&&this.rotationTips.detach(),this.rotateNotation&&this.rotateNotation.detach(),delete this._clientCenter,delete this._clientAixsStart,delete this._clientAixsEnd}_calcRingPts(e,t,i,n,o){let s=[...zi.discreteCircle({center:e.clone(),arcStartPt:i,rotateAngle:o,normal:t.clone().normalize()}),...zi.discreteCircle({center:e.clone(),arcStartPt:n,rotateAngle:o,normal:t.clone().normalize()}).reverse()],r=[];for(const e of s)r.push(this.viewer3D.worldToClient(e));return this.isOnQuarterRing&&r.push(r[0]),r}_calcNotationPos(e,t,i){let n=new THREE.Vector2(e.x,e.y),o=new THREE.Vector2(t.x,t.y),s=o.clone().sub(n).normalize();return o.add(s.multiplyScalar(i))}getScale(e,t,i){let n=this.viewer3D.worldToClient(e),o=this.viewer3D.worldToClient(t),s=new THREE.Vector2(n.x,n.y),r=new THREE.Vector2(o.x,o.y);return i/s.distanceTo(r)}toFullRing(e){this.isOnQuarterRing=!1,this.updateQuarterRings(e)}fromFullRing(e){this.isOnQuarterRing=!0,this.updateQuarterRings(e)}updateCoordinateAxis(){let e=this.getBoundingBoxWorld(),t=this.getRotationMatrix(),i=[];i.push(new THREE.Vector3(1,0,0).applyMatrix4(t)),i.push(new THREE.Vector3(0,-1,0).applyMatrix4(t)),i.push(new THREE.Vector3(0,0,1).applyMatrix4(t));const n=this.viewer3D.worldToClient(e.getCenter(this._cCenter));let o=[];for(const t of i){let i=t.clone().multiplyScalar(130*this.factor).add(e.getCenter(this._center)),n=this.viewer3D.worldToClient(i);o.push(n)}this.dashlineArray||(this.dashlineArray=new $i({length:130,isEffectedByOthers:!0,colors:["#FF2905","#1922FB","#32D3A6"]}),this.drawables.push(this.dashlineArray)),this.dashlineArray.detach(),this.dashlineArray.update(n,o),this.setRotationEN(),this.dashlineArray.attach(this.domContainer)}getDirection(e){return"arrowX"===e?new THREE.Vector3(1,0,0):"arrowY"===e?new THREE.Vector3(0,-1,0):new THREE.Vector3(0,0,1)}calcSegment(e,t,i){if(!this._clientAixsStart||!this._clientAixsEnd){let n=t.clone().normalize().multiplyScalar(i*this.factor/2),o=e.clone().add(n),s=e.clone().sub(n);this._clientAixsStart=this.viewer3D.worldToClient(o.clone()),this._clientAixsEnd=this.viewer3D.worldToClient(s.clone())}return[this._clientAixsStart,this._clientAixsEnd]}addCloudViewerEvents(){let e=this.viewer3D.getViewer();this.updateBinded=this.update.bind(this),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}removeCloudViewerEvents(){let e=this.viewer3D.getViewer();e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}update(){this.updateFactor(),this.updateBoundingBox(),this.updateCoordinateAxis(),this.updateQuarterRings()}getAllDrawables(){return this.drawables}setDefault(){for(const e of this.getAllDrawables())e.setDefault()}setGray(){for(const e of this.getAllDrawables())e.setGray()}select(){for(const e of this.getAllDrawables())if(e.select())return}hideAll(){for(const e of this.getAllDrawables())e.hide()}showAll(){for(const e of this.getAllDrawables())e.show()}dispose(){this.domContainer.innerHTML="",this.boundingBox=null,this.CoordinateAxis=null,this.removeCloudViewerEvents()}getEditObjectCenter(){return this.getBoundingBoxWorld().getCenter(this._modelCenter),this._modelCenter}updateController(e){null!=e.X&&(this.controller.X=e.X),null!=e.Y&&(this.controller.Y=e.Y),null!=e.Z&&(this.controller.Z=e.Z)}setRotationEN(){!this.quarterRings||this.quarterRings.drawables.length<=0||(this.controller.Y?(this.quarterRings.drawables[1].setDefault(),this.dashlineArray.drawables[1].setDefault()):(this.quarterRings.drawables[1].setGray(),this.dashlineArray.drawables[1].setGray()),this.controller.Z?(this.quarterRings.drawables[0].setDefault(),this.dashlineArray.drawables[2].setDefault()):(this.quarterRings.drawables[0].setGray(),this.dashlineArray.drawables[2].setGray()),this.controller.X?(this.quarterRings.drawables[2].setDefault(),this.dashlineArray.drawables[0].setDefault()):(this.quarterRings.drawables[2].setGray(),this.dashlineArray.drawables[0].setGray()))}}let an=Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Web.Lang.Utility.Dom"),ln=Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Bimface.Plugins.ObjectEditor");class hn{constructor(e,t){this.viewer=e,this.editObjectType=t,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.domContainer=an.create("div","bf-ObjectEditor-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=an.createNS("svg","bf-ObjectEditor-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 e=new Glodon.Web.Lang.EventManager;this.getEventManager=function(){return e},this.activeEditor=new Hi(this.viewer,this.editObjectType,e,this.translationController),this._update=()=>this.activeEditor&&!this.activeEditor.isEditing&&this.updateController(),this.viewer.addEventListener("ModelTransformed",this._update),this.viewer.addEventListener("CameraPositionChanged",this._update)}setEditedObjectId(e){switch(this.editedObjectId=e,this.activeEditor.setEditedObjectId(e),this.dispose(),this.activeEditor.name){case"Translation":let e=new qi(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.translationController);this.activeEditor.setDrawables(e);break;case"Scaling":let t=new Qi(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.scaleController);this.activeEditor.setDrawables(t)}}attachInitDrawables(){let e=new qi(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.translationController);this.activeEditor.setDrawables(e)}getEditedObjectId(){return this.editedObjectId}activateEditor(e){switch(this.dispose(),e){case"Translation":this.activeEditor=new Hi(this.viewer,this.editObjectType,this.getEventManager(),this.translationController);let e=new qi(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.translationController);this.activeEditor.setDrawables(e);break;case"Scaling":this.activeEditor=new Ui(this.viewer,this.editObjectType,this.getEventManager(),this.scaleController);let t=new Qi(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.scaleController);this.activeEditor.setDrawables(t);break;case"Rotation":this.activeEditor=new Wi(this.viewer,this.editObjectType,this.getEventManager(),this.rotationController);let i=new rn(this.viewer,this.svgContainer,this.editedObjectId,this.editObjectType,this.rotationController);this.activeEditor.setDrawables(i)}this.activeEditor.setEditedObjectId(this.editedObjectId)}dispose(){if(this.activateEditor){let e=this.activeEditor.getDrawables();e&&e.dispose()}}hide(){this.domContainer.style.display="none"}show(){this.domContainer.style.display=""}onExit(){this.viewer.removeEventListener("ModelTransformed",this._update),this.viewer.removeEventListener("CameraPositionChanged",this._update),this.dispose(),this.removeDomEventListeners(),this.destroySvgContainer(),this.isExitNow=!0}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.domContainer.removeChild(this.svgContainer),this.svgContainer=null,this.viewer.getDomElement().removeChild(this.domContainer),this.domContainer=null}onMouseDown(e){this.isExitNow||e.button===THREE.MOUSE.LEFT&&this.activeEditor.begin(e)}onMouseMove(e){this.isExitNow||this.activeEditor.onEditing(e)}onMouseUp(e){this.isExitNow||e.button===THREE.MOUSE.LEFT&&(this.activeEditor.end(e),this.activeEditor.dataDrawables.update())}onMouseDoubleClick(e){this.isExitNow||(e.preventDefault(),e.stopPropagation())}onWindowResize(){this.activeEditor&&this.activeEditor.dataDrawables&&this.activeEditor.dataDrawables.update()}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)}if(this.activeEditor.name===t){this.activeEditor.updateController(e);let t=this.activeEditor.getDrawables();t&&t.updateController(e)}this.onWindowResize()}}ln.ObjectEditorManager=hn;const cn="Exit",dn="EditingModeChanged";let un=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class gn{constructor(e){this.viewer=e.viewer,this.objectId=e.objectId,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},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||("Viewer3D"===this.viewer.viewerType?this.viewer.hideViewHouse():this.viewer.hideNorthArrow(),this.setBimfaceUIVisibility(!1),this.modelEditor.show(),this.switchToolbarAllHide||this.switchToolbar.show(),this.objectEditorManager.show())}hide(){this._destroyed||("Viewer3D"===this.viewer.viewerType?this.viewer.showViewHouse():this.viewer.showNorthArrow(),this.setBimfaceUIVisibility(!0),this.modelEditor.hide(),this.switchToolbar.hide(),this.objectEditorManager.hide())}exit(){this._destroyed||(this.hide(),this._getEventManager().fireEvent(cn),this.objectEditorManager.onExit(),delete this.viewer._objectEditorToolbar,this.destroy())}destroy(){this.viewer.getDomElement().removeChild(this.domElement),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(){const t=this;let i=[];const n=un.create("div","bf-roomEditorToolbar");if(t.domElement=n,n.addEventListener("mousedown",(e=>(e.stopPropagation(),!1))),void 0===this.switchToolbar){var o=e.Bimface.UI.Toolbar.ToolbarConfig();o.className="bf-toolbar bf-toolbar-roomEditor",o.element=n,o.buttons=["ModelEditingTranslate","ModelEditingRotate","ModelEditingScale"],this.viewer.getDomElement().appendChild(n),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(o),i.push(this.switchToolbar)}let s=e.Bimface.UI.Control.ControlEvent,r=this.switchToolbar.getControls();this.uncheckOthers("Translation",r);let a=["Translation","Rotation","Scaling"];t._editingMode="Translation";for(let e=0;e<r.length;e++){let i=r[e];i.addEventListener(s.Click,(function(){if(i.isChecked()){t.objectEditorManager.activateEditor(a[e]),t.uncheckOthers(i.getId(),r);let n="Scaling"===i.getId()?"Scale":i.getId();t._getEventManager().fireEvent(dn,{previousEditingMode:t._editingMode,followingEditingMode:n}),t._editingMode=n}else i.toggleCheckedState()}))}const l=new e.Bimface.UI.Toolbar.ToolbarConfig;l.element=n,l.className="bf-toolbar bf-toolbar-roomEditor";let h=t.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(l);t.modelEditor=h,i.push(h);const c=new e.Bimface.UI.Button.ButtonConfig;c.className="bf-modeleditor-cancel",c.title=BimfaceLanguage.bf_general_exit;const d=new e.Bimface.UI.Button.SingleButton(c);d.setHtml("退出"===BimfaceLanguage.bf_general_exit?"退 出":BimfaceLanguage.bf_general_exit),d.addEventListener("Click",(()=>{this.exit()})),h.addControl(d),this.viewer.getDomElement().appendChild(n),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)}}function pn(e){let t=e.modelId;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:{}}},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 gn{constructor(e){t.send("Bimface.Plugins.ModelEditor","ModelEditorToolbar"),e.objectId=pn(e),super(e),this.name="ModelEditorToolbar",this.editedId=e.objectId,this.initialize(),this.toolBarDom()}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedModelId(e){super.setEditedObjectId(e)}getEditedModelId(){return super.getEditedObjectId()}setEditedModel(e){const t=pn({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()}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 hn(this.viewer,"Model"),this.objectEditorManager.setEditedObjectId(this.objectId)}}}(),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").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.urlMap={},n.externalObjectManager=this,this.enableLight=!1,this.console=new e.Web.Common.Console,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)}_addObject(t,i,n,o){if(!this.getObjectIdByName(t)){if(!this.enableLight){let e=i.children.filter((e=>"AmbientLight"!==e.type));i.children=e}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),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 c=this;function d(){if(CLOUD.Utils.isDefined(t.objectData)){let e=c.getObjectIdByName(s);c.setObjectData(e,t.objectData)}i&&i()}if(CLOUD.Utils.isDefined(t.object)){const e=this._addObject(s,t.object,l,h);if(e)return d(),e;o&&o()}else if(CLOUD.Utils.isDefined(r)){if(this.urlMap[a]&&!0===this.urlMap[a].pending){this.urlMap[a].callbackList.push(d),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 d();this.urlMap[a]={},this.urlMap[a].pending=!0,this.urlMap[a].callbackList=[],this.urlMap[a].callbackList.push(d),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 c=[];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=>{c.push(`${o}/lib/loaders/${e}`)}))}n.getScripts(c,(()=>{const{objectUrl:e,mtlUrl:n}=r,o=e.split(".").pop().toUpperCase(),c=a[o].loaderName;let d=new THREE[c];if(void 0===n)d.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(),d.setMaterials(n),d.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,n}getObjectIdByName(e){for(var t in this._objects)if(this._objects[t]===e)return t}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){return!1!==t&&(t=!0),this._viewer.getExternalObjectConverter().convertToExternalObject(e,e,t)}_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=this.getAllChildrenId(e);i&&i.length>0&&i.forEach((e=>this._manager.setAccumulateTransform(e,t))),this._manager.setAccumulateTransform(e,t),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}rotateOnBasePoint(e,t,i,n){let o=this.getAllChildrenId(e);o&&o.length>0&&o.forEach((e=>this._manager.rotateOnBasePoint(e,t,i,n))),this._manager.rotateOnBasePoint(e,t,i,n),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}scaleOnBasePoint(e,t,i){this._manager.scaleOnBasePoint(e,t,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}getBoundingBoxById(e){return 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&&(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.getTransform(e);if(t&&t.position){var i=t.position;return{x:i.x,y:i.y,z:i.z}}}offset(e,t){var i=this._getValid3dParam(t);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){return t.matrix.clone().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),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()}play(e,t=0){this.isAnimatable(e)?this._manager.play(e,t):console.warn("there is no animation in the mesh")}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],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).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}}const{worldPosition:i,worldVector: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).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){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{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={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{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)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").ExternalObjectEditorToolbarConfig=function(){return{viewer:null,id:null,app:null,buttonVisibility:{},translationController:{},rotationController:{},scaleController:{}}};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").ExternalObjectEditorToolbarEvent={Exit:"Exit",EditingModeChanged:"EditingModeChanged"};!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 gn{constructor(e){t.send("Bimface.Plugins.ExternalObject","ExternalObjectEditorToolbar"),e.objectId=e.id,super(e),this.name="ExternalObjectEditorToolbar",this.initialize(),this.toolBarDom()}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedExternalObjectId(e){super.setEditedObjectId(e)}getEditedExternalObjectId(){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 hn(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,!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){this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager.getRooms((function(t){e&&e(t)}))}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?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 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.`),t}setBoundaryByRoomId(e,t){let i,n=this.viewer3D.getCustomizedRoom();if(e in n){let o=n[e];if(this.viewer3D.clearRoomsById(e),"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");i.offsetZ-=o.offset[0],this.viewer3D.createRoomByOffset(i,o.offset,e,o.faceColor,o.frameColor),this.viewer3D.render();let s={id:e,unit:"m2",value:null},r=this._getRoomBoundaryById(e);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)return this.allComponentIds;this.allComponentIds=new Array;let e=this.viewer3D.getViewer().getFilter().getObjectsMap(),t=Object.keys(e);for(let i=0;i<t.length;i++){let n=e[t[i]],o=Object.keys(n);this.allComponentIds.push(...o)}return 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(let n=0;n<r.length;n++){let o=r[n],a=this.viewer3D.getViewer().getComponentInfoByUserId(o).boundingBox;this.roomContains(e,a,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;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);if(t){let e=t.boundingBox,i=t.offset;return e.min.z=i[0],e.max.z=i[1],e}if(this.mapRoomBbox[e])return this.mapRoomBbox[e]}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]);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=[i.offset[0],t];this.viewer3D.createRoomByOffset(s,r,e,n.faceColor,n.frameColor)}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]);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,i.offset[1]];this.viewer3D.createRoomByOffset(s,r,e,n.faceColor,n.frameColor)}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,c=t.min.y,d=t.max.y,u=this.tolerence;return i==this.toleranceType.STRICT?l>=o-u&&h<=s+u&&c>=r-u&&d<=a+u:i==this.toleranceType.ORDINARY||i==this.toleranceType.LENIENT?l<=s+u&&h>=o-u&&c<=a+u&&d>=r-u:void 0}isRoomBoundaryContainBoundingBoxByXY(e,t,i){let n=this.toFivePos(t),o=this._getRoomBoundaryById(e),s=0;for(let e=0;e<n.length;e++){const t=n[e];this.containsInBoundary(t,o)&&s++}let r=!1;return i==this.toleranceType.STRICT?r=5==s:i==this.toleranceType.ORDINARY?r=s>=3:i==this.toleranceType.LENIENT&&(r=s>=1),r}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],c=t[a].y||t[a][1],d=t[l].x||t[l][0],u=t[l].y||t[l][1];c>s!=u>s&&o<(d-h)*(s-c)/(u-c)+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);if(!this.containsInBoundary(e,n,i))return!1;if(o&&o.find((t=>this.containsInBoundary(e,t,i))))return!1;let s=Number(e.z.toFixed(10)),r=this.getRoomBoundingBoxById(t),a=Number(r.min.z.toFixed(10)),l=Number(r.max.z.toFixed(10));return i?s>a&&s<l:s>=a&&s<=l}}}(),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");let i=Object.freeze({Saved:"Saved",Cancelled:"Cancelled"});t.RoomEditorToolbarEvent=i}(),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"),o=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Application.UI.Button"),e.Bimface.Plugins.SpatialRelation.RoomEditorToolbarEvent);n.RoomEditorToolbar=class{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,this.initialize(),this.toolBarDom()}initialize(){const t=e.Bimface.Plugins.RoomEditing,i=new t.RoomEidtorConfig;i.viewer=this.viewer,i.roomId=this.roomId,this.roomEditor=new t.RoomEditor(i),this.roomEditor.onEnter(),this.registerRoomEditorEvents()}toolBarDom(){const t=this;let n=[];const s=i.create("div","bf-roomEditorToolbar");if(t.domElement=s,void 0===this.switchToolbar){var r=e.Bimface.UI.Toolbar.ToolbarConfig();r.className="bf-toolbar bf-toolbar-roomEditor",r.element=s,r.buttons=["RoomEditingDrag","RoomEditingAdd","RoomEditingDelete","RoomEditingHeight"],this.viewer.getDomElement().appendChild(s),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 c=new e.Bimface.UI.Toolbar.ToolbarConfig;c.element=s,c.className="bf-toolbar bf-toolbar-roomEditor";let d=t.roomToolbar=new e.Bimface.UI.Toolbar.Toolbar(c);t.roomToolbar=d,n.push(d);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(o.Saved,i),t.update()})),d.addControl(g);const p=new e.Bimface.UI.Button.ButtonConfig;p.className="bf-cancel",p.title=BimfaceLanguage.bf_general_cancel;const f=new e.Bimface.UI.Button.SingleButton(p);f.setHtml(BimfaceLanguage.bf_general_cancel),f.addEventListener("Click",(function(){t.eventManager.fireEvent(o.Cancelled),t.exit()})),d.addControl(f),this.viewer.getDomElement().appendChild(s)}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.roomEditor.setBimfaceUIVisibility(!1),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)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation").RoomEditorToolbarConfig=function(){return{viewer:null,roomId:null,app: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.RevitHelpers"));i.MEPTopologyHelper=class{constructor(e){t.send("Bimface.Plugins.RevitHelpers","MEPTopologyHelper"),this.databagId=e.viewer._data.databagId,this.modelType=e.viewer._data.modelType}_findNetworkById(t,i){var n,o=this;o._FILEID_CACHE!=o.fileId&&(o._API_CACHE=null),"integrateModel"==o.modelType?(n=`${c.resourceHost}/${o.databagId}/metadata/${o.fileId}/mepsystem.json`,o._FILEID_CACHE=o.fileId):n=`${c.resourceHost}/${o.databagId}/metadata/mepsystem.json`,o._API_CACHE?o._getNetwork(t,o._API_CACHE,(function(e){i(e)})):e.Web.Lang.Utility.HttpRequest.ajax({url:n,success:function(e){var n=JSON.parse(e);o._API_CACHE=n,o._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),c=s.applyMatrix4(a),d=r.applyMatrix4(a);this.planTranslation=l.clone().add(c).multiplyScalar(.5),this.planTranslation.add(this.coordViewPoint);let u=h.clone().sub(l).length(),g=d.clone().sub(l).length(),p=new THREE.Vector3(-g/2,-u/2,i),f=new THREE.Vector3(g/2,u/2,i);return new THREE.Box3(p,f)}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),o=i.createNS("circle","bf-snap-handle");o.setAttribute("r",t.width),o.setAttribute("fill",n.getRGB()),o.style.fill=n.getRGB();var s=i.createNS("line","bf-snap-line");s.style.strokeWidth=2,s.style.stroke=n.getRGB();var r=i.createNS("polygon","bf-snap-rect");r.setAttribute("fill",n.getRGBA()),r.setAttribute("stroke",n.getRGB()),r.setAttribute("stroke-width",1),this.hoverLine=s,this.hoverPoint=o,this.hoverPanel=r,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,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 c=this.stretchOnDirection(s[0],s[1],o.width),d=this.stretchOnDirection(s[2],s[3],o.width);s=c.concat(d)}if(1!=h){c=this.stretchOnDirection(s[0],s[3],o.height),d=this.stretchOnDirection(s[1],s[2],o.height);s=[c[0],d[0],d[1],c[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)}}}),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},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){this.isNeedSnap(e)&&(n=e.pickPoint?e.pickPoint:null,e.pickPlane?(s="Panel",r=e.normal):e.pickLine?(s="Line",o=e.pickLine):s=e.pickPoint?"Point":null,this.update())},isNeedSnap:function(e){if(!this.snapMode)return!0;if(!e||!e.userId)return this.reset(),!1;let t=this.snapMode.getSnap3DList(),i="face",n="line",o="endpoint",s=!1;e.pickPlane?s=t.includes(i):e.pickLine?s=t.includes(n):e.pickPoint&&(s=t.includes(o));let r=this.snapMode.getSnapConditions(),a=this._opt.viewer.getViewer().getUserdataByUserId(e.userId),l=this.isMatchConditions(a,r),h=s&&l;return h||this.reset(),h},isMatchConditions:function(e,t){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=[],c=[];if(this.context.svg.innerHTML="",n?(e.pickPoint=n,e.hoverPosition=t.worldToClient(n),e.hoverPositionDS=l.getScene().worldToDrawing(n)):e.hoverPosition=null,e.hoverObjectType=s,"Line"==s&&2==o.length){e.lineStartPoint=t.worldToClient(o[0]),e.lineEndPoint=t.worldToClient(o[1]);var d=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(d),f=!g.containsPoint(u),m={start:d,end:u},w=b.CameraUtil.lineIntersectWithRect(m,g);if(p&&f)2==w.length&&(e.lineStartPoint=w[0],e.lineEndPoint=w[1]);else if(p||f)for(var v=new THREE.Vector2(e.hoverPosition.x,e.hoverPosition.y),y=p?u.clone():d.clone(),x=y.clone().sub(v).normalize(),E=0;E<w.length;E++){if(y.clone().sub(w[E]).normalize().dot(x)>0){e.lineStartPoint=y,e.lineEndPoint=w[E];break}}}if("Panel"==e.hoverObjectType){e.normal=l.getScene().worldToDrawing(r),e.normal.normalize();var C=l.cameraControl,M=new THREE.Plane;M.setFromNormalAndCoplanarPoint(e.normal,e.hoverPositionDS);var P=new THREE.Vector2(e.hoverPosition.x-10,e.hoverPosition.y-10),I=new THREE.Vector2(e.hoverPosition.x+10,e.hoverPosition.y-10),T=e.hoverPositionDS,D=C.getRaycaster(P.x,P.y);if(this._p1=D.ray.intersectPlane(M,this._p1),D=C.getRaycaster(I.x,I.y),this._p2=D.ray.intersectPlane(M,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var S=new THREE.Vector3(1,0,0),B=new THREE.Vector3(0,1,0),_=new THREE.Vector3(0,0,1),k=Math.abs(e.normal.clone().dot(S))<=.0025,A=Math.abs(e.normal.clone().dot(_))<=.0025;if(k&&A)var L=S.clone(),V=_.clone();else L=B.clone().cross(e.normal).normalize(),V=e.normal.clone().cross(L).normalize();var R=this._p1.distanceTo(this._p2)/2,O=L.clone().multiplyScalar(R),N=V.clone().multiplyScalar(R),H=T.clone().sub(O).add(N),z=T.clone().add(O).add(N),W=T.clone().sub(O).sub(N),U=T.clone().add(O).sub(N),F=[];F.push(H,z,U,W);for(var G=[],j=C.getContainerDimensions(),$=0;$<F.length;$++){var X=b.CameraUtil.drawingToCanvas(C.camera,F[$],j.width,j.height);G.push(new THREE.Vector3(X.x,X.y,0))}e.clientPts=G}for(E=0;E<h.length-1;E++){var Y=l.worldPointsToClient(h[E],h[E+1]);if(Y){var Z={x:Y.start.x-a.left,y:Y.start.y-a.top};c.push(Z)}}e.clientPoints=c,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(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough");t.WalkthroughManager=class{constructor(e){var t=e.viewer;t?"Viewer3D"===t.getViewerType()||"ViewerGIS"===t.getViewerType()?(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}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").NorthArrowConfig=function(){return{domElement:null,viewer:null,right:10,top:10}};class fn{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 c=this._rotate*Math.PI/180;this._camera.setCameraFromYawPitch({yaw:c,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 mn{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}};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 wn{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.panInLat(!1);break;case"right":e.panInLat(!0)}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 vn{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()}init(){this.drawElements((()=>{this.addDomElementEvents(),this.northArrowYaw=new fn(this.elements.yaw,this.domElement,this._camera),this.northArrowPitch=new mn({pitchUp:this.elements.pitchUp,pitchDown:this.elements.pitchDown},this._camera),this.northArrowZoom=new vn({zoomIn:this.elements.zoomIn,zoomOut:this.elements.zoomOut},this._camera),this.northArrowPan=new wn({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=[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,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=()=>{if(this.enableScale){var e=Date.now();if(!(e<this.lastUpdateTime+250)){this.lastUpdateTime=e;var t=this._opt.viewer.getViewer().camera,i=this._opt.viewer.getViewer().getViewportSize();if(t.position.y<0)this.domElement.style.display="none";else{var o=new THREE.Vector3(i.width/2,i.height-1),s=new THREE.Vector3(i.width/2+1,i.height-1),r=this._opt.viewer.getViewer().pickByPoint(o,!0),a=this._opt.viewer.getViewer().pickByPoint(s,!0);if(r&&a&&r.worldPosition&&a.worldPosition){var l=r.worldPosition.distanceTo(a.worldPosition);if(this._pixelDistance=l,l<0)this.domElement.style.display="none";else{for(var h,c=n.length-1;!h&&c>=0;--c)n[c]/l<=120&&(h=n[c]);if(h){var d;this._value=h,d=h>=1e3?(h/1e3).toString()+"km":h.toString()+"m",this.labelElement.textContent=d;var u=this.labelElement.getBoundingClientRect().width||43;this.labelElement.setAttribute("x",70-u/2),this.labelElement.setAttribute("y",23);var g=h/l,p="M"+(70-g/2).toString()+" 20 L"+(70-g/2).toString()+" 28 L"+(70+g/2).toString()+" 28 L"+(70+g/2).toString()+" 20";this.barElement.setAttribute("d",p),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"}}}},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");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,this._mousemoveCallback=e=>{if(!this.enable)return;if(this.isMouseClicked)return;let t=this._opt.viewer.getViewer().pickByPoint(e);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)},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}drawElements(){const{credit:t,text:i,link:n,copyright:o}=this._opt;switch(t){case e.Bimface.Common.Credit.None:this.domElement.innerHTML="";break;case e.Bimface.Common.Credit.OSM:this.domElement.innerHTML=`\n <div class='copyright'>©<a class='text' href='${n}' target='_blank'>OpenStreetMap</a> contributors</div>\n `;break;default: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.element=o.create("div","bf-search-toolbar"),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._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){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]))},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("gld-bf-search")?this.clickSearch():t.hasClass("gld-bf-arrowup")?this.clickArrow():t.hasClass("gld-bf-arrowdown")&&this.clickArrow(!0)})),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){if(i.send(t,"update"),this.element.innerHTML=`<input value="${this._data.text||""}" 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>`,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)}},n.Search=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox").SkyBoxStyle=Object.freeze({BlueSky:"BlueSky",CloudySky:"CloudySky",DarkNight:"DarkNight",Galaxy:"Galaxy",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}}}(),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 yn=Object.freeze({Release:"Release",Debug:"Debug"}),bn=Object.freeze({Normal:"Normal",DrawingView:"drawingView"}),xn=Object.freeze({BIMFACE:"BIMFACE",Local:"Local"}),En=Object.freeze({zh_CN:"zh_CN",en_GB:"en_GB",sv_SE:"sv_SE"}),Cn=Object.freeze({Normal:"Normal",Bake:"Bake"});window.BimfaceSDKLoaderConfig=function(){if(window.hostConfig){for(let e in window.hostConfig)c[e]=window.hostConfig[e];c.securityApi=window.hostConfig.securityApi}return{staticHost:`${c.staticHost}/api`,APIHost:c.APIHost,language:"zh_CN",viewToken:null,configuration:yn.Release,dataEnvType:c.dataEnvType||"BIMFACE",viewType:bn.Normal,visualStyle:Cn.Bake,version:"",securityApi:c.securityApi}},window.BimfaceEnvOption=xn,window.BimfaceLanguageOption=En,window.BimfaceConfigrationOption=yn,window.BimfaceViewTypeOption=bn,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.enableSkyBox(!0)}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()}}_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)):i=this._style==e.Bimface.Plugins.SkyBox.SkyBoxStyle.Customized?e.Bimface.Plugins.SkyBox.SkyBoxStyle.CloudySky:this._style,0==o.length&&i){var s=(n.dataEnvType==xn.Local?n.sdkPath:c.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)}destroy(){this._viewer.getViewer().removeGround(),this._ground=null}setElevation(e){this._ground.setElevation(e)}getElevation(){return 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=60,this.outerCircleFillStyle="rgba(255, 255, 255, 0.3)",this.outerCircleBorderWidth=2,this.outerCircleBorderColor="#999999",this.innerCircleRadius=50,this.innerCircleFillStyle="rgba(204, 204, 204, 0.5)",this.innerCircleBorderWidth=2,this.ballOuterCircleRadius=60,this.ballOuterCircleFillStyle="rgba(255, 255, 255, 0.3)",this.ballOuterCircleBorderWidth=1,this.ballOuterCircleBorderColor="#999999",this.ballInnerCircleRadius=30,this.ballInnerCircleFillStyle="rgba(255, 255, 255, 0.8)",this.ballInnerCircleBorderWidth=2,this.ballDirectionCircleRadius=6,this.ballDirectionCircleFillStyle="rgba(50, 211, 166, 1)",this.ballDirectionCircleBorderWidth=1,this.triangleWidth=20,this.triangleFillStyle="rgba(204, 204, 204, 0.5)",this.triangleBorderWidth=2,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,o=this.getCoordinate(),s=[o.endZ.x-o.start.x,o.endZ.y-o.start.y],r=[t.x-e.x,t.y-e.y],a=this.vectorAngle(s,r);i.touchMoveCallback(this.center,Math.sqrt(Math.pow(r[0],2)+Math.pow(r[1],2))*Math.cos(a))}else{this.draw(n);let e=this.getRealPoint(t);i.touchMoveCallback(e)}}onTouchEnd(e,t,i){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,!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.clashResult={},this.currentIndex=0,this.hasModelA=!1,this.hasModelB=!1,this.isIntegrateA=!1,this.isIntegrateB=!1;var o=new e.Bimface.UI.Panel.PanelConfig;o.title=BimfaceLanguage.bf_panel_clashDetective_clashDetective,o.className="bf-panel clash-detective-panel-wrapper",o.id="clashDetective";let s=e.Web.Lang.Utility.ClientHelper.getIsDesktop();o.css=s?{right:"10px",top:"10px",width:"300px",height:"416px"}:{left:0,top:0,width:"100%",height:"100%"};var r=new e.Bimface.UI.Panel.Panel(o);let a,l;r.addEventListener("Hide",(()=>{this.clearIsolation();let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item"),this.currentIndex=0})),this.clashDetectivePanel=r,this.viewer.clashDetectivePanel=r,this.makeOthersTranslucent=e.Bimface.Viewer.IsolateOption.MakeOthersTranslucent,n._updateModelName=function(e){l=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdA)),!l||e!=n.modelIdA&&e!=l.modelId||(n.hasModelA=!0,a=document.getElementById("cdModelAName"),a&&(a.setAttribute("class","active"),a.removeAttribute("title"),a.innerText=`${l._data.name}${n.isIntegrateA?"(集成模型)":""}`)),l=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdB)),!l||e!=n.modelIdB&&e!=l.modelId||(n.hasModelB=!0,a&&(a=document.getElementById("cdModelBName"),a.setAttribute("class","active"),a.removeAttribute("title"),a.innerText=`${l._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.isolateComponentsById(i),this.zoomToBoundingBox(i.position,this.unitType)}zoomToBoundingBox(e,t){let i={},n={};"Millimeter"===t?(i={x:e.x+2e3,y:e.y+2e3,z:e.z+2e3},n={x:e.x-2e3,y:e.y-2e3,z:e.z-2e3}):(i={x:e.x+2,y:e.y+2,z:e.z+2},n={x:e.x-2,y:e.y-2,z:e.z-2});let o={max:i,min:n};this.viewer.zoomToBoundingBox(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}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 i=JSON.parse(e);"success"==i.code?t&&t(i.data):o(i)},failure:e=>{o(JSON.parse(e))}})}else o(r)},failure:e=>{o(JSON.parse(e))}})}}}(),function(e){function t(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var i={};t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=12)}([function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"distance",value:function(e,t){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}},{key:"center",value:function(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}},{key:"centerByArr",value:function(e,t){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}},{key:"distanceByArr",value:function(e,t){var i=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(i*i+n*n)}},{key:"angleByArr",value:function(e,t,i){var 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}},{key:"normalize",value:function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return[e[0]/t,e[1]/t]}},{key:"isPointInBBox",value: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}();t.default=o},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.mouseDownPt=null}return n(e,[{key:"init",value:function(e){this.notify("enter")}},{key:"redraw",value:function(e){e.updateOverlays()}},{key:"onDrawing",value:function(e,t){}},{key:"begin",value:function(e,t,i,n){}},{key:"end",value:function(e,t,i,n){}},{key:"onKeyDown",value:function(e,t){this.keyDown&&this.keyDown(e,t)}},{key:"onKeyUp",value:function(e,t){this.keyUp&&this.keyUp(e,t)}},{key:"onDoubleClick",value:function(e,t){}},{key:"onMouseWheel",value:function(e,t){var i=this;(e.hover||this.timer)&&(this.timer&&clearTimeout(this.timer),e.hover=!1,e.viewer.ClearHighlight(),this.timer=setTimeout((function(){e.hover=!0,i.timer=null}),750));var n=t.deltaY||-t.wheelDelta||t.detail,o=Math.abs(e.ratio-1)+1,s=n<0?o:1/o,r=e.getZoomFactor();n>0&&r<.15||(e.zoomPan(s,t.offsetX,t.offsetY),this.observer&&this.observer(null,"zoomFactorChanged",e.getZoomFactor()))}},{key:"onMouseMove",value:function(e,t){var i=this.formatEventOffset(e,t);this.isPanMode(t.buttons)&&e.panTo(i.x,i.y),this.onEditing(e,i.x,i.y,t.buttons)}},{key:"onMouseDown",value:function(e,t){var i=this.formatEventOffset(e,t);this.mouseDownPt=i,e.setStartPoint(i.x,i.y),this.begin(e,i.x,i.y,t.buttons)}},{key:"onMouseUp",value:function(e,t){var i=this.formatEventOffset(e,t);return this.end(e,i.x,i.y,t.button)}},{key:"onEditing",value:function(e,t,i,n){}},{key:"onExit",value:function(e){this.notify("exit")}},{key:"formatEventOffset",value:function(e,t){var i=t.offsetX,n=t.offsetY;if("CANVAS"!=t.target.tagName.toLocaleUpperCase()){var o=e.dom.getBoundingClientRect();i=t.clientX-o.x,n=t.clientY-o.y}return{x:i,y:n}}},{key:"notify",value:function(e,t,i,n,o){this.observer&&this.observer(this.name,e,t,i,n,o)}},{key:"isPanMode",value:function(t){return t==e.MiddleButton||t==e.RightButton}},{key:"sameAsMousedownPt",value:function(e,t){if(!this.mouseDownPt)return!1;var i=this.mouseDownPt.x,n=this.mouseDownPt.y;return e===i&&t===n}}]),e}();o.CONTINUE=0,o.FINISHED=1,o.LelftButton=1,o.RightButton=2,o.MiddleButton=4,o.MouseMode=1,o.TouchMode=2,t.default=o},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};n.Measure={lineWidth:3,color:"#F99D0B",snapColor:"#11DAB7",auxLineDash:[6,4],auxLineWidth:1,auxColorX:"#7CCF21",auxColorY:"#CC021B",outlineColor:"#FFFFFF",outlineWidth:2},n.Zoom={color:"#00ff00",lineWidth:2},t.default=n},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(14)),r=n(i(6)),a=n(i(7)),l=function(){function e(t,i,n,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var a=document.getElementById(o);this.width=a.clientWidth,this.height=a.clientHeight,this.viewer=Module.createViewer(o,this.width,this.height),this.divId=o,this.dom=a,this.dc=s.default.create(t,i,n),this.ratio=1.1,this.drawHandle=null,this.scale=1,this.snapDistance=5,this.hover=!0,this.bindRendering=this.rendering.bind(this),this.customManager=new r.default,this.onViewChanges=function(){};var l=this;this.dc.overlayDrawers.custom=function(e){l.customManager.draw(l,e)},this.sendHighlightMsg=!0}return o(e,[{key:"setZoomRatio",value:function(e){this.ratio=e}},{key:"getZoomRatio",value:function(){return this.ratio}},{key:"getViewScale",value:function(e){return this.scale}},{key:"setViewScale",value:function(e){this.scale=e}},{key:"setSnapDistance",value:function(e){this.snapDistance=e}},{key:"snapshot",value:function(e){var t=this.dc.canvasMain,i=(this.dc.canvasOverlay,this.getDivId()),n=document.getElementById(i),o=document.createElement("canvas");o.width=n.clientWidth,o.height=n.clientHeight;var s=o.getContext("2d");return s.beginPath(),s.fillStyle=e||t.style.background,s.fillRect(0,0,o.width,o.height),s.drawImage(t,0,0),o.toDataURL()}},{key:"snapshotPure",value:function(){var e=this.dc.canvasMain,t=(this.dc.canvasOverlay,this.getDivId()),i=document.getElementById(t),n=document.createElement("canvas");n.width=i.clientWidth,n.height=i.clientHeight;var o=n.getContext("2d");return o.beginPath(),o.drawImage(e,0,0),n}},{key:"setBackgroundColor",value:function(e){this.dc.setBackgroundColor(e)}},{key:"showFilledFace",value:function(e){this.viewer.FilledFace=e}},{key:"isShowFilledFace",value:function(){return this.viewer.FilledFace}},{key:"setModel",value:function(e){var t;if(this.viewer.SetModel(e),this.dc.setResourceUrl(e.Url),this.viewer.UpdateVisibleSettings(),null!=e.indexJson.sealImages)for(t=0;t<e.indexJson.sealImages.length;++t){var i=e.indexJson.sealImages[t],n=i.path.split("\\"),o=n[n.length-1];this.viewer.AddSealImage(o,parseFloat(i.x),parseFloat(i.y),parseFloat(i.width),parseFloat(i.height))}}},{key:"rendering",value:function(){this.viewer.Draw(this.dc)>0?this.rendering():(this.updateOverlays(),requestAnimationFrame(this.bindRendering))}},{key:"getDivId",value:function(){return this.divId}},{key:"getModel",value:function(){return this.viewer.GetModel()}},{key:"getViewAngle",value:function(){return this.viewer.ViewAngle}},{key:"setViewAngle",value:function(e){this.viewer.ViewAngle=e,this.update()}},{key:"getLayers",value:function(){for(var e=[],t=this.getModel(),i=t.GetLayerIds(),n=0,o=i.size();n<o;++n){var s=i.get(n),r=t.GetLayer(s);null!=r?e.push({id:r.Id,name:r.Name,color:r.Color,visible:r.Visible}):console.log("Layer not found!"+s)}return e}},{key:"changeLayers",value:function(e){for(var t=this.getModel(),i=0;i<e.length;++i){var n=e[i];t.GetLayer(n.id).Visible=n.visible}this.viewer.UpdateVisibleSettings()}},{key:"getLayouts",value:function(){var e=[],t=this.getModel(),i=t.GetLayoutIds();e.push({id:0,name:"Model"});for(var n=0,o=i.size();n<o;++n){var s=i.get(n),r=t.GetLayout(s);e.push({id:r.Id,name:r.Name})}return e}},{key:"activeLayoutById",value:function(e){this.viewer.ActiveLayout(e),this.update()}},{key:"getActiveLayoutId",value:function(){return this.viewer.GetActiveLayoutId()}},{key:"isModelView",value:function(){return 0==this.getActiveLayoutId()}},{key:"updateOverlays",value:function(){this.dc.drawingOverlay(this.width,this.height)}},{key:"update",value:function(e){1==e&&(this.viewer.RequstDraw(Module.EnumRedrawHints.FinialDraw),this.onViewChanges());var t=this;null!==t.drawHandle&&cancelAnimationFrame(t.drawHandle),this.minimap&&this.minimap.update(),t.drawHandle=requestAnimationFrame((function e(){t.viewer.Draw(t.dc)>0?t.drawHandle=requestAnimationFrame(e):(t.drawHandle=null,t.updateOverlays())}))}},{key:"onResize",value:function(){this.resize(this.dom.clientWidth,this.dom.clientHeight)}},{key:"clearAll",value:function(){this.dc.clearAll(this.width,this.height)}},{key:"resize",value:function(e,t){this.width=e||this.dom.clientWidth,this.height=t||this.dom.clientHeight,this.dc.resize(e,t),this.viewer.Resize(e,t),this.update(),this.onViewChanges()}},{key:"zoomToExtent",value:function(e){null==e&&(e=1),this.viewer.ZoomToExtent(e),this.onViewChanges()}},{key:"zoomToObject",value:function(e,t){null==t&&(t=1),("string"==typeof e||e instanceof String)&&(e=parseInt(e)),this.viewer.ZoomToElement(e,t),this.onViewChanges()}},{key:"zoomToObjectWithBlock",value:function(e,t,i){null==i&&(i=1),("string"==typeof e||e instanceof String)&&(e=parseInt(e)),("string"==typeof t||t instanceof String)&&(t=parseInt(t)),this.viewer.ZoomToElementWithBlock(e,t,i),this.onViewChanges()}},{key:"setStartPoint",value:function(e,t){this.startX=e,this.startY=t}},{key:"zoom",value:function(e,t,i,n){this.viewer.ZoomToRect(e,t,i,n),this.update(!0),this.onViewChanges()}},{key:"panTo",value:function(e,t){return this.startX&&this.startY?(this.offsetX=e-this.startX,this.offsetY=t-this.startY,(0!=this.offsetX||0!=this.offsetY)&&(this.viewer.Pan(this.offsetX,this.offsetY),this.update(),this.startX=e,this.startY=t,this.onViewChanges(),!0)):(this.startX=e,this.startY=t,!1)}},{key:"zoomPan",value:function(e,t,i){this.offsetX=(t||this.width/2)-this.width/2,this.offsetY=(i||this.height/2)-this.height/2,this.viewer.ZoomPan(e,this.offsetX,this.offsetY),this.update(),this.onViewChanges()}},{key:"preSelect",value:function(e,t,i){return i?this.viewer.PreSelect(this.startX,this.startY,e,t):this.viewer.PreSelect(e,t,e,t)}},{key:"select",value:function(){this.viewer.Select()}},{key:"getSelectedIds",value:function(){for(var e=[],t=this.viewer.GetSelection(),i=0,n=t.size();i<n;++i)e.push(t.get(i));return e}},{key:"getHighlightIds",value:function(){for(var e=[],t=this.viewer.GetHighlightIds(),i=0,n=t.size();i<n;++i)e.push(t.get(i));return e}},{key:"clearSelection",value:function(){this.viewer.ClearSelection()}},{key:"clearHighlight",value:function(){this.viewer.ClearHighlight()}},{key:"selectByIds",value:function(e){var t=this.viewer.GetSelection();t.resize(0,0);for(var i=0,n=e.length;i<n;++i)t.push_back(parseInt(e[i]));this.viewer.SelectIds(t)}},{key:"highlightById",value:function(e){this.viewer.HighlightId(parseInt(e))}},{key:"getObjectBoundingBox",value:function(e){var t=this.getModel().FindElement(e);if(t){var i=t.BoundingBox;return[i.GetMinPt(),i.GetMaxPt()]}return null}},{key:"enableHover",value:function(e){this.hover=e}},{key:"toWorldPoint",value:function(e){return this.viewer.ToWorldPoint(e)}},{key:"toScreenPoint",value:function(e){return this.viewer.ToScreenPoint(e)}},{key:"toViewportScreenPoint",value:function(e){return this.viewer.ToViewportScreenPoint(e)}},{key:"toModelWorld",value:function(e){return this.viewer.ToModelWorldPoint(e)}},{key:"snapToPoint",value:function(e,t,i){return null==i&&(i=this.snapDistance),this.viewer.SnapToPoint(e,t,i)}},{key:"snapToPoint2",value:function(e,t,i,n,o){return null==o&&(o=this.snapDistance),this.viewer.SnapToPoint2(e,t,i,n,o)}},{key:"getZoomFactor",value:function(){var e=this.viewer.GetWorldSize();return this.viewer.WorldScale/Math.min(1/e[0],1/e[1])}},{key:"getState",value:function(){var e={ver:1,WorldScale:this.viewer.WorldScale,ViewAngle:this.viewer.ViewAngle,ViewCenter:this.viewer.ViewCenter,ZoomFactor:this.getZoomFactor()};return JSON.stringify(e)}},{key:"setState",value:function(e){var t=JSON.parse(e);return 1===t.ver&&(this.viewer.WorldScale=t.WorldScale,this.viewer.ViewAngle=t.ViewAngle,this.viewer.ViewCenter=t.ViewCenter,this.viewer.UpdateViewMatrix(),!0)}},{key:"getAlignState",value:function(){var e={ver:1,AlignMatrixCol1:this.viewer.GetAlignMatrixCol(0),AlignMatrixCol2:this.viewer.GetAlignMatrixCol(1),AlignMatrixCol3:this.viewer.GetAlignMatrixCol(2),AlignMatrixCol4:this.viewer.GetAlignMatrixCol(3)};return JSON.stringify(e)}},{key:"setAlignState",value:function(e){var t=JSON.parse(e);return 1===t.ver&&(null!=t.AlignMatrixCol1&&null!=t.AlignMatrixCol1&&(this.viewer.SetAlignMatrixCol(0,t.AlignMatrixCol1),this.viewer.SetAlignMatrixCol(1,t.AlignMatrixCol2),this.viewer.SetAlignMatrixCol(2,t.AlignMatrixCol3),this.viewer.SetAlignMatrixCol(3,t.AlignMatrixCol4)),this.viewer.UpdateViewMatrix(),!0)}},{key:"showElementBox",value:function(e){null!=e&&e>0&&this.viewer.ShowElementBox(e)}},{key:"selectExistValue",value:function(e,t,i){if(e){if(i%2==1)return e.x;if(i%2==0)return e.y}if(!e)return t[Math.floor(i/3)][i%2==0?1:0]}},{key:"showElementBoxByBBox",value:function(e,t){e&&this.customManager.add([this.selectExistValue(e.max,e,1),this.selectExistValue(e.max,e,2),this.selectExistValue(e.min,e,3),this.selectExistValue(e.min,e,4)],t)}},{key:"setElementBoxColor",value:function(e,t,i,n){this.customManager.setColor(e,t,i,n)}},{key:"getElementBoxColor",value:function(){return this.customManager.getColor()}},{key:"getElementBoxStyle",value:function(){return this.customManager.getStyle()}},{key:"setElementBoxStyle",value:function(e){this.customManager.setStyle(e)}},{key:"hideElementBox",value:function(e){null!=e&&e>0&&this.viewer.HideElementBox(e)}},{key:"clearElementBox",value:function(){this.viewer.ClearElementBox(),this.customManager.clear()}},{key:"getVisibleBoxIds",value:function(){for(var e=[],t=this.viewer.GetVisibleBoxIds(),i=0;i<t.size();++i)e.push(t.get(i));return e}},{key:"enableHighlightEvent",value:function(e){this.sendHighlightMsg=e}},{key:"isHighlightEventEnabled",value:function(){return this.sendHighlightMsg}},{key:"addClickCallback",value:function(e){this.clickCallback=e}},{key:"getClickCallback",value:function(){return this.clickCallback}},{key:"getModelBBox",value:function(){return this.viewer.GetModelBBox()}},{key:"enableSelectInBlock",value:function(){this.viewer.EnableSelectInBlock()}},{key:"disableSelectInBlock",value:function(){this.viewer.DisableSelectInBlock()}},{key:"canSelectInBlock",value:function(){return this.viewer.CanSelectInBlock()}},{key:"getSelectionWithBlock",value:function(){return this.viewer.GetSelectionWithBlock()}},{key:"GetHighlightIdsWithBlock",value:function(){return this.viewer.GetHighlightIdsWithBlock()}},{key:"highlightIdWithBlock",value:function(e,t){this.viewer.HighlightIdWithBlock(e,t)}},{key:"selectIdWithBlock",value:function(e,t){this.viewer.SelectIdWithBlock(e,t)}},{key:"createMinimap",value:function(e,t,i,n,o){0!=this.isModelView()?null==this.minimap&&(this.minimap=new a.default(e,t,i,n,o),this.minimap.setDrawingImpl(this),this.minimap.initialize()):console.warn("Only model view support minimap.")}},{key:"enableMinimap",value:function(e){0!=this.isModelView()?this.minimap&&this.minimap.enableMiniMap(e):console.warn("Only model view support minimap.")}},{key:"setMinimapBoundingBox",value:function(e){0!=this.isModelView()?this.minimap&&this.minimap.setDrawingContentsBbox(e):console.warn("Only model view support minimap.")}},{key:"setMinimapOffset",value:function(e){this.minimap.setOffset(e)}},{key:"hasMinimap",value:function(){return 0==this.isModelView()?void console.warn("Only model view support minimap."):null!=this.minimap}},{key:"setGlobalColor",value:function(e){this.dc.customColor=e}},{key:"getGlobalColor",value:function(){return this.dc.customColor}},{key:"setPrintMode",value:function(e){this.dc.setPrintMode(e)}},{key:"zoomToWorldBox",value:function(e,t,i){null==i&&(i=1);var n=this.getModelBBox();n.SetMinMax(e,t),this.viewer.ZoomToWorldBox(n,i)}},{key:"alignDrawing",value:function(e,t){this.viewer.AlignDrawing(e,t)}},{key:"getAlignTranslate",value:function(){return this.viewer.GetAlignTranslate()}},{key:"scaleDrawing",value:function(e,t){this.viewer.AlignDrawingWithScale(e,t)}},{key:"getAlignScale",value:function(){return this.viewer.GetAlignScale()}},{key:"getViewportBBox",value:function(e){var t=this.viewer.GetViewportBBox(e),i=t.GetMinPt(),n=t.GetMaxPt();return{min:[i[0],i[1]],max:[n[0],n[1]]}}},{key:"getCustomManager",value:function(){return this.customManager}},{key:"setSnapMode",value:function(e){this.snapMode=e}},{key:"getSnapMode",value:function(){return this.snapMode}}]),e}();t.default=l},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(1)),r=n(i(2)),a=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var e=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.step=0,e.tmpPoint=null,e.viewPort=null,e.originPoint=null,e.points=[],e.isMatchSnapMode=!0,e.isEnableSnap=!0,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"drawSnapPoint",value:function(e,t){if(this.drawing2D||(this.drawing2D=e,this.ctx=t),!this.ctx&&(this.ctx=t),null!=this.tmpPoint&&(0!=this.tmpPoint.GetID()||"Intersection"==this.tmpPoint.GetSnapTypeName())){if(!this.isMatchSnapMode)return!0;this.isFootPoint=!1;var i=void 0,n=this.tmpPoint;if(this.points[0]&&this.step>0){var o=e.toScreenPoint(this.points[0].GetPoint()),s=this.tmpPointScreenPoint;i=(n=e.snapToPoint2(s[0],s[1],o[0],o[1])).GetSnapTypeName()}else i=this.tmpPoint.GetSnapTypeName();var r;return r=e.viewer.IsActiveLayoutElement(n.GetID())?e.toScreenPoint(n.GetPoint()):e.toViewportScreenPoint(n.GetPoint()),this.drawTmpPoint(e,t,r,i),!0}return this.finalScreenPoint=null,this.captureFail(this.tmpPointScreenPoint),!1}},{key:"captureFail",value:function(e){}},{key:"drawTmpPoint",value:function(e,t,i,n){this.isEnableSnap&&(e=e||this.drawing2D,(t=t||this.ctx).strokeStyle=t.fillStyle=r.default.Measure.snapColor,t.beginPath(),"EndPoint"==n?(t.lineWidth=2,t.rect(i[0]-4,i[1]-4,8,8),t.stroke()):"PointOnLine"==n?(t.arc(i[0],i[1],4.5,0,2*Math.PI,!0),t.fill()):"MiddlePoint"==n?(t.lineWidth=2,t.moveTo(i[0],i[1]-4),t.lineTo(i[0]-5,i[1]+4),t.lineTo(i[0]+5,i[1]+4),t.closePath(),t.stroke()):"FootPoint"==n?(this.isFootPoint=!0,t.lineWidth=2,t.moveTo(i[0]-6,i[1]-6),t.lineTo(i[0]-6,i[1]+6),t.lineTo(i[0]+6,i[1]+6),t.moveTo(i[0]-6,i[1]-1),t.lineTo(i[0]+1,i[1]-1),t.lineTo(i[0]+1,i[1]+6),t.stroke()):"Intersection"==n&&(t.lineWidth=2,t.moveTo(i[0]-4,i[1]-4),t.lineTo(i[0]+4,i[1]+4),t.moveTo(i[0]-4,i[1]+4),t.lineTo(i[0]+4,i[1]-4),t.stroke()),this.finalScreenPoint=i,this.tmpPointScreenPoint=i)}},{key:"onDrawing",value:function(e,t){if(this.drawSnapPoint(e,t),this.markPoint){var i=e.toScreenPoint(this.markPoint.slice(0,2));t.beginPath(),t.lineWidth=2,t.strokeStyle=r.default.Measure.color,t.fillStyle=t.strokeStyle,t.moveTo(i[0]-7.5,i[1]),t.lineTo(i[0]+7.5,i[1]),t.moveTo(i[0],i[1]-7.5),t.lineTo(i[0],i[1]+7.5),t.stroke(),t.rect(i[0]-2.5,i[1]-2.5,5,5),t.fill(),this.tmpPointScreenPoint&&(t.save(),t.lineDashOffset=10,t.setLineDash([3,3]),t.globalAlpha=.5,t.strokeStyle="#FF9D0B",t.moveTo(i[0],i[1]),t.lineTo(this.tmpPointScreenPoint[0],this.tmpPointScreenPoint[1]),t.stroke(),t.restore())}}},{key:"setIsOnlySnap",value:function(e){this.onlySnap=e}},{key:"begin",value:function(e,t,i,n){1!=n||this.onlySnap||(this.markPoint?this.markPoint=null:this.finalScreenPoint?this.markPoint=e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):this.markPoint=e.toModelWorld([t,i]),this.redraw(e))}},{key:"onEditing",value:function(e,t,i,n){this.tmpPointScreenPoint=[t,i],this.tmpPoint=e.snapToPoint(t,i),this.isMatchSnapMode=this.matchSnapMode(this.tmpPoint,e.getSnapMode()),this.redraw(e)}},{key:"end",value:function(e,t,i,n){}},{key:"onExit",value:function(e){this.redraw(e)}},{key:"setIsEnableSnap",value:function(e){this.isEnableSnap=e}},{key:"matchSnapMode",value:function(e,t){if(!e)return!1;if(!t)return!0;var i=e.GetSnapTypeName();return t.snapList.includes({PointOnLine:"line",Intersection:"intersection",MiddlePoint:"midpoint",EndPoint:"endpoint"}[i])}}]),t}(s.default);t.default=a},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function e(t,i,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,i);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(n):void 0},r=n(i(0)),a=n(i(10)),l=n(i(2)),h=n(i(4)),c=n(i(22)),d=function(e){function t(e,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.worldPtForOtherDrawing={},n.pressShift=!1,n.parallel=!1,n.viewPortBBox={},n.viewPortBBoxMask={},n.auxMobileMeasureTool=a.default.isDesktop()?null:new c.default(e,n),n.color=i.color||l.default.Measure.color,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"reset",value:function(){this.step=0,this.points=[],this.tmpPoint=null,this.needMaskVPId=0}},{key:"captureFail",value:function(e){return!1}},{key:"clearSnapPoint",value:function(){this.finalScreenPoint=null,this.tmpPoint=null}},{key:"needToMaskViewport",value:function(e,t){if(null==this.needMaskVPId||0==this.needMaskVPId)return!1;var i=void 0,n=void 0;if(this.viewPortBBoxMask[this.needMaskVPId])i=this.viewPortBBoxMask[this.needMaskVPId].min,n=this.viewPortBBoxMask[this.needMaskVPId].max;else{var o=e.getViewportBBox(this.needMaskVPId);i=o.min,n=o.max,this.viewPortBBoxMask[this.needMaskVPId]={min:i,max:n}}var s=e.toScreenPoint(i),r=e.toScreenPoint(n);return t.globalAlpha=.7,0==e.dc.printMode?t.fillStyle="#444444":t.fillStyle="#DDDDDD",t.fillRect(s[0],s[1],r[0]-s[0],r[1]-s[1]),!0}},{key:"worldToScreen",value:function(e,t){for(var i=[],n=0;n<t.length;n++){var o=t[n],s=o.GetPoint();s=o.GetID()&&!e.viewer.IsActiveLayoutElement(o.GetID())?e.toViewportScreenPoint(s):e.toScreenPoint(s),i.push(s)}return i}},{key:"drawMask",value:function(e,t){if(this.showMask){var i=void 0,n=void 0;if(this.viewPortBBox[this.viewPort])i=this.viewPortBBox[this.viewPort].min,n=this.viewPortBBox[this.viewPort].max;else{var o=e.getViewportBBox(this.needMaskVPId);i=o.min,n=o.max,this.viewPortBBox[this.viewPort]={min:i,max:n}}var s=e.toScreenPoint(i),r=e.toScreenPoint(n);t.globalAlpha=.7,0==e.dc.printMode?t.fillStyle="#444444":t.fillStyle="#DDDDDD",t.fillRect(0,0,3e3,3e3),t.globalCompositeOperation="destination-out",t.globalAlpha=1,t.fillRect(s[0],s[1],r[0]-s[0],r[1]-s[1]),t.globalCompositeOperation="source-over"}}},{key:"parallelDetect",value:function(e,t){if(this.pressShift&&this.tmpPoint){var i=this.worldToScreen(e,[this.tmpPoint])[0],n=t[t.length-1];this.originPoint=i;var o=Math.abs(i[0]-n[0]),s=Math.abs(i[1]-n[1]),r=o<10,a=s<10;r||a?(r&&a?o>s?(i=[i[0],n[1]],this.parallel="Y"):(i=[n[0],i[1]],this.parallel="X"):r?(i=[n[0],i[1]],this.parallel="X"):(i=[i[0],n[1]],this.parallel="Y"),this.tmpPoint=e.snapToPoint(i[0],i[1])):this.parallel=!1}else this.parallel=!1}},{key:"onDrawing",value:function(e,t){if(this.drawMask(e,t),this.showMask||this.needToMaskViewport(e,t)||this.drawSnapPoint(e,t),0!=this.points.length){var i=this.worldToScreen(e,this.points);this.parallelDetect(e,i);var n=this.tmpPoint?this.worldToScreen(e,[this.tmpPoint])[0]:null;t.strokeStyle=this.color,t.lineWidth=l.default.Measure.lineWidth;var o=n?i.length+1:i.length;if(o>=2)for(var s=1;s<o;s++){var r=i[s-1],a=n&&s==o-1?n:i[s];t.beginPath(),t.moveTo(r[0],r[1]),t.lineTo(a[0],a[1]),t.stroke()}for(var h=0;h<i.length;h++){var c=i[h];this.strokeCircle(t,c),t.fillStyle=t.strokeStyle,t.beginPath(),t.arc(c[0],c[1],4,0,2*Math.PI,!0),t.fill()}}}},{key:"begin",value:function(e,t,i,n){}},{key:"end",value:function(e,t,i,n){if(!(this.showMask||this.needMaskVPId>0)){if(this.isPanMode(n)){if(this.sameAsMousedownPt(t,i)){if(0==this.points.length)return;this.reset(),this.notify("change",{type:"Distance",status:"reset"})}}else{var o=e.toModelWorld([t,i]);if(0==this.step&&(this.points=[],this.viewPort=o[2],-1==o[2]?this.firstPointOutsideVP=!0:this.firstPointOutsideVP=!1),this.parallel||(this.finalScreenPoint?(this.points[this.step]=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]),this.worldPtForOtherDrawing[this.step]=e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]])):(this.points[this.step]=e.snapToPoint(t,i),this.worldPtForOtherDrawing[this.step]=null)),o[2]!=this.viewPort)return this.points.splice(1,1);if(this.step=this.step+1,this.tmpPoint=null,this.step>=2){var s=this.points[0].GetPoint(),a=this.points[1].GetPoint(),l=[s,a];if(this.worldPtForOtherDrawing[0])l[0]=this.worldPtForOtherDrawing[0];else if(!this.points[0].GetID()){var h=e.toScreenPoint(s),c=e.toModelWorld(h);c[2]>0&&(l[0]=c)}if(this.worldPtForOtherDrawing[1])l[1]=this.worldPtForOtherDrawing[1];else if(!this.points[1].GetID()){var d=e.toScreenPoint(a),u=e.toModelWorld(d);u[2]>0&&(l[1]=u)}"X"==this.parallel?l[1][0]=l[0][0]:"Y"==this.parallel&&(l[1][1]=l[0][1]);var g=r.default.distanceByArr(l[0],l[1]);this.notify("change",{distance:g,type:"Distance",status:"measured",start:l[0],end:l[1],points:l,isOnLayout:o[2]>0}),this.points=[],this.step=0,this.pressShift=!1,this.parallel=!1,this.viewPort=null}else{var p=this.points[0].GetPoint();this.notify("change",{type:"Distance",status:"measuring",points:[p],end:null})}}this.redraw(e)}}},{key:"onEditing",value:function(e,t,i,n){if(this.tmpPointScreenPoint=[t,i],this.tmpPoint=e.snapToPoint(t,i),this.step>0){var o=e.toModelWorld([t,i]);this.viewPort&&o[2]!=this.viewPort&&-1!=this.viewPort?this.showMask=!0:this.showMask=!1,this.firstPointOutsideVP&&o[2]>0?this.needMaskVPId=o[2]:this.needMaskVPId=0}this.redraw(e)}},{key:"keyDown",value:function(e,t){this.pressShift||16!=t.keyCode||0==this.step?27==t.keyCode&&this.step>0&&(this.points.pop(),this.step--,this.redraw(e)):(this.pressShift=!0,this.redraw(e),this.onDrawing(e,this.ctx))}},{key:"keyUp",value:function(e,t){this.pressShift=!1,16==t.keyCode&&0!=this.step&&this.originPoint&&this.onEditing(e,this.originPoint[0],this.originPoint[1])}},{key:"onExit",value:function(e){this.reset(),this.redraw(e),s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onExit",this).call(this,e)}},{key:"strokeCircle",value:function(e,t){e.save(),e.globalCompositeOperation="source-over",e.strokeStyle=l.default.Measure.outlineColor,e.lineWidth=l.default.Measure.outlineWidth,e.beginPath(),e.arc(t[0],t[1],5,0,2*Math.PI,!0),e.stroke(),e.closePath(),e.restore()}}]),t}(h.default);t.default=d},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(15)),r=n(i(16)),a=n(i(17)),l=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.markups=[],this.red=255,this.green=0,this.blue=0,this.alpha=1,this.strokeStyle="rgba(255,0,0,1)",this.lineWidth=3,this.fontSize=14,this.fontFamily="Arial",this.type="Rectangle",this.fillStyle="red",this.enableFillStyle=!1}return o(e,[{key:"add",value:function(e,t,i,n,o){var l=void 0,h={strokeStyle:this.strokeStyle,lineWidth:this.lineWidth};switch(this.type){case"Rectangle":l=new s.default(e,t,h,i);break;case"CloudRect":l=new r.default(e,t,h,i);break;case"Chartlet":l=new a.default(n,e,t,o,i)}this.markups.push(l)}},{key:"setColor",value:function(e,t,i,n){this.red=e,this.green=t,this.blue=i,this.alpha=n,this.strokeStyle="rgba("+e+","+t+","+i+","+n+")"}},{key:"getColor",value:function(){return{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}}},{key:"setStyle",value:function(e){this.type=e}},{key:"getStyle",value:function(){return this.type}},{key:"clear",value:function(){this.markups=[]}},{key:"draw",value: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=s.lineWidth,t.fillStyle=s.fillStyle,s.draw(e,t)}}},{key:"setFillColor",value:function(e){this.enableFillStyle=!0,this.fillStyle=e}},{key:"setFillStyleState",value:function(e){this.enableFillStyle=e}},{key:"setLineWidth",value:function(e){this.lineWidth=e}},{key:"setFont",value:function(e){this.font=e}},{key:"get",value:function(e){return this.markups[e]}},{key:"remove",value:function(e){e<0||this.markups.splice(e,1)}},{key:"setFontSize",value:function(e){this.fontSize=e}},{key:"getMarkupSize",value:function(e,t){var i=this.getMarkupBbox(e,t);return[Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1])]}},{key:"setFontFamily",value:function(e){this.fontFamily=e}},{key:"translatePos",value:function(e,t,i,n){for(var o=(this.getMarkupCenter(e,t),n[0]-i[0]),s=n[1]-i[1],r=this.markups[t],a=r.getPoints(),l=0;l<a.length;l+=2)a[l]+=o,a[l+1]+=s;r.setPoints(a)}},{key:"hitGrip",value:function(e,t,i){for(var n=this.markups[i].getGrips(e),o=0;o<n.length;o+=2){var s=[n[o],n[o+1]];if(s=e.toScreenPoint(s),this.isPointInCircle(t,s,8))return 4==n.length?0==o?0:4:o/2}return-1}}]),e}();t.default=l},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(i(18)),s=function(){function e(t,i,n,s,r){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.width=n||300,this.height=s||240,this.imageUrl=i,this.domContainer=document.getElementById(t),this.xmlns="http://www.w3.org/2000/svg",this.naviAlgorithm=new o.default,this.boundingBox=null,this.originalDrawingContentsBbox=null,this.drawingImpl=null,this.isEnabled=!0,this.workerType=r}return n(e,[{key:"initialize",value:function(){this.initMinimapContainer(),this.initImageNode(this.imageUrl),this.initOutline(),this.initSvgRect()}},{key:"getMapContainer",value:function(){return this.wrapContainer}},{key:"initMinimapContainer",value:function(){this.wrapContainer=document.createElement("div"),this.minimapContainer=document.createElementNS(this.xmlns,"svg"),this.wrapContainer.appendChild(this.minimapContainer),this.minimapContainer.setAttribute("class","minimap");var e={width:this.width+"",height:this.height+""};this.setAttribute(this.minimapContainer,e);var t={position:"absolute","z-index":10,right:"10px",height:"240px",bottom:"61px",display:"block",backgroundColor:"#000000",opacity:"0.88"};"pid-transfer"===this.workerType&&(t.backgroundColor="#FFFFFF"),this.setStyle(this.wrapContainer,t),this.domContainer.appendChild(this.wrapContainer);var i=this;this.wrapContainer.addEventListener("mousedown",(function(e){i.bMousedown=!0,e.stopPropagation()})),this.wrapContainer.addEventListener("mouseup",(function(e){if(1==i.bMousedown){i.bMousedown=!1,e.stopPropagation();var t={x:e.offsetX,y:e.offsetY},n=i.naviAlgorithm;n.minimapToNormalizedPoint(t,i.getMinimapContentsBbox()),n.normalizedPointToWorld(t,i.getDrawingContentsBbox());var o=i.drawingImpl.toScreenPoint([t.x,t.y]),s=i.drawingImpl.toScreenPoint([i.lastPoint.x,i.lastPoint.y]),r=[s[0]-o[0],s[1]-o[1]];i.drawingImpl.viewer.Pan(r[0],r[1]),i.drawingImpl.update(),i.drawingImpl.onViewChanges()}}))}},{key:"setOffset",value:function(e){var t=this.minimapContainer;this.setStyle(t,e)}},{key:"initImageNode",value:function(e){this.svgImage=document.createElementNS(this.xmlns,"image"),this.svgImage.href.baseVal=e;var t={preserveAspectRatio:"xMidYMid meet",width:this.width+"",height:this.height+""};this.setAttribute(this.svgImage,t),this.minimapContainer.appendChild(this.svgImage)}},{key:"initSvgRect",value:function(){this.svgRect=document.createElementNS(this.xmlns,"rect");this.setAttribute(this.svgRect,{width:"300",height:"240"});this.setStyle(this.svgRect,{position:"absolute",display:"block",fillOpacity:"0.1",fill:"#11DAB7",stroke:"#11DAB7",strokeWidth:"2px"}),this.minimapContainer.appendChild(this.svgRect),this.resize(this.width-2,this.height-2),this.moveTo(1,1)}},{key:"initOutline",value:function(){this.outline=document.createElementNS(this.xmlns,"rect");this.setAttribute(this.outline,{width:"300",height:"240"});this.setStyle(this.outline,{position:"absolute",fill:"none",stroke:"#555555",strokeWidth:"1px"}),this.minimapContainer.appendChild(this.outline)}},{key:"moveTo",value:function(e,t){this.svgRect.setAttribute("transform","translate("+e+","+t+")")}},{key:"resize",value:function(e,t){var i={width:e+"",height:t+""};this.setAttribute(this.svgRect,i)}},{key:"setStyle",value:function(e,t){for(var i in t)e.style[i]=t[i]}},{key:"setAttribute",value:function(e,t){for(var i in t)e.setAttribute(i,t[i])}},{key:"enableMiniMap",value:function(e,t){var i={display:"none"};!0===e&&(i.display="block"),1!=t&&(this.isEnabled=e),this.setStyle(this.minimapContainer,i)}},{key:"setDrawingImpl",value:function(e){this.drawingImpl=e}},{key:"getMinimapContentsBbox",value:function(){var e=this.height,t=this.width,i=(this.width-this.height)/2,n=this.width/2,o=this.height/2;return{min:{x:n-t/2+i,y:o-e/2},max:{x:n+t/2-i,y:o+e/2}}}},{key:"setDrawingContentsBbox",value:function(e){this.setOriginalDrawingContentsBbox(e);var t=Math.abs(e.max.x-e.min.x),i=Math.abs(e.max.y-e.min.y),n=(e.max.x+e.min.x)/2,o=(e.max.y+e.min.y)/2,s=Math.max(t,i);e.min.x=n-s/2,e.min.y=o-s/2,e.max.x=n+s/2,e.max.y=o+s/2,null==this.lastPoint&&(this.lastPoint={x:(e.min.x+e.max.x)/2,y:(e.min.y+e.max.y)/2}),this.boundingBox=e}},{key:"getDrawingContentsBbox",value:function(){return this.boundingBox}},{key:"setOriginalDrawingContentsBbox",value:function(e){var t=JSON.parse(JSON.stringify(e));this.originalDrawingContentsBbox=t}},{key:"getOriginalDrawingContentsBbox",value:function(){return JSON.parse(JSON.stringify(this.originalDrawingContentsBbox))}},{key:"update",value:function(){if(0!=this.drawingImpl.isModelView()){this.enableMiniMap(this.isEnabled);var e=this.domContainer.clientWidth,t=this.domContainer.clientHeight,i=this.drawingImpl.toWorldPoint([0,t]),n=this.drawingImpl.toWorldPoint([e,0]);this.lastPoint={x:(n[0]+i[0])/2,y:(n[1]+i[1])/2};var o={x:i[0],y:i[1]},s={x:n[0],y:n[1]},r=this.naviAlgorithm,a=this.getOriginalDrawingContentsBbox(),l={min:o,max:s};if(r.containsBox(l,a))return this.resize(this.width-2,this.height-2),void this.moveTo(1,1);r.worldToNormalizedPoint(o,this.getDrawingContentsBbox()),r.normalizedPointToMinimap(o,this.getMinimapContentsBbox()),r.worldToNormalizedPoint(s,this.getDrawingContentsBbox()),r.normalizedPointToMinimap(s,this.getMinimapContentsBbox());var h=[(o.x+s.x)/2,(o.y+s.y)/2],c=Math.abs(s.x-o.x),d=Math.abs(s.y-o.y);a={min:{x:h[0]-c/2,y:h[1]-d/2},max:{x:h[0]+c/2,y:h[1]+d/2}},l={min:{x:0,y:0},max:{x:this.width,y:this.height}};var u=r.intersect(a,l);r.boundsChecking(u,{x:this.width,y:this.height}),h=[(u.min.x+u.max.x)/2,(u.min.y+u.max.y)/2],c=Math.abs(u.max.x-u.min.x),d=Math.abs(u.max.y-u.min.y),this.resize(c,d),this.moveTo(h[0]-c/2,h[1]-d/2)}else this.enableMiniMap(!1,!0)}}]),e}();t.default=s},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=(n(i(3)),i(0)),r=n(s),a=n(i(1)),l=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.TouchMode));return i.rltTopHeight=i.relativeHight(e),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"relativeHight",value:function(e){var t=e.getDivId();return document.getElementById(t).getBoundingClientRect().top}},{key:"__getMobileEvt",value: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 0==e.touches.length&&(i=e.changedTouches[0],t.push({x:i.pageX,y:i.pageY})),t.length<=1?{isMulti:!1,point:t[0]}:{isMulti:!0,distance:r.default.distance(t[0],t[1]),point:t}}},{key:"onTouchStart",value:function(e){var t=this.__getMobileEvt(e),i=this.getEditor();if(t.isMulti){var n=r.default.center(t.point[0],t.point[1]);this.drawing2D.setStartPoint(n.x,n.y)}else this.isMeasureEditor()?(t.point.y-=this.rltTopHeight,i.auxMobileMeasureTool.onTouchStart(t)):(this.drawing2D.setStartPoint(t.point.x,t.point.y-this.rltTopHeight),i.begin(this.drawing2D,t.point.x,t.point.y-this.rltTopHeight,1));this.startEvent=t}},{key:"onTouchEnd",value:function(e){var t=e.changedTouches,i=this.getEditor();if(1==t.length){if(this.isMeasureEditor()){var n=this.__getMobileEvt(e);return n.point.y-=this.rltTopHeight,void i.auxMobileMeasureTool.onTouchEnd(n)}if(i.end(this.drawing2D,t[0].pageX,t[0].pageY-this.rltTopHeight,1)===a.default.FINISHED&&(i.onExit(this.drawing2D),this.editors.pop()),1==e.touches.length){var o=e.touches[0];this.drawing2D.setStartPoint(o.pageX,o.pageY-this.rltTopHeight)}}}},{key:"onTouchMove",value:function(e){var t=this.__getMobileEvt(e),i=this.getEditor();if(t.isMulti){if(!this.startEvent.distance)return;var n=t.distance/this.startEvent.distance;if(1!=n){var o=t.point;this.drawing2D.zoomPan(n,(o[0].x+o[1].x)/2,(o[0].y+o[1].y)/2),this.observer&&this.observer(null,"zoomFactorChanged",this.drawing2D.getZoomFactor())}}else this.isMeasureEditor()?(t.point.y-=this.rltTopHeight,i.auxMobileMeasureTool.onTouchMove(t)):i.onEditing(this.drawing2D,t.point.x,t.point.y-this.rltTopHeight,1);this.startEvent=t}},{key:"bindEvents",value:function(){var e=this;this.allEvent={onTouchStart:function(t){"textarea"!==t.target.tagName.toLocaleLowerCase()&&t.preventDefault(),e.onTouchStart(t)},onTouchEnd:function(t){"textarea"!==t.target.tagName.toLocaleLowerCase()&&t.preventDefault(),e.onTouchEnd(t)},onTouchMove:function(t){t.preventDefault(),e.onTouchMove(t)}};var t=e.getDom();t.addEventListener("touchstart",this.allEvent.onTouchStart,!1),t.addEventListener("touchend",this.allEvent.onTouchEnd,!1),t.addEventListener("touchmove",this.allEvent.onTouchMove,!1)}},{key:"unbindAllEvent",value:function(){var e=this.getDom();e.removeEventListener("touchstart",this.allEvent.onTouchStart,!1),e.removeEventListener("touchend",this.allEvent.onTouchEnd,!1),e.removeEventListener("touchmove",this.allEvent.onTouchMove,!1)}},{key:"isMeasureEditor",value:function(){var e=this.getEditorName();return"DistanceMeasure"==e||"AngleMeasure"==e||"AreaMeasure"==e}}]),t}(n(i(9)).default);t.default=l},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=(n(i(3)),i(1)),r=(n(s),i(19)),a=n(r),l=n(i(20)),h=n(i(21)),c=n(i(5)),d=n(i(23)),u=n(i(24)),g=n(i(4)),p=function(){function e(t,i){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.drawing2D=t,this.id="editor-"+i,this.mode=i,this.editors=[],this.editors.push(new l.default),this.observer=null,e.editorMode=this.mode;var n=this;t.dc.overlayDrawers[this.id]=function(e){for(var i=0;i<n.editors.length;++i)n.editors[i].onDrawing(t,e)}}return o(e,[{key:"destroy",value:function(){delete this.drawing2D.dc.overlayDrawers[this.id],this.drawing2D=null}},{key:"getDom",value:function(){return this.drawing2D.dom}},{key:"getEditor",value:function(){return this.editors[this.editors.length-1]}},{key:"getEditorName",value:function(){return this.getEditor().name}},{key:"activeEditorByName",value:function(e,t){if("zoom"==e){var i=this.editors.length;if(i>0&&this.editors[i-1].name==e)return}else this.getEditor().onExit(this.drawing2D),this.editors=[];var n=null;switch(e){case"zoom":n=new a.default;break;case"pick":n=new h.default;break;case"pan":n=new l.default;break;case"DistanceMeasure":n=new c.default(this.drawing2D,t);break;case"AngleMeasure":n=new u.default(this.drawing2D,t);break;case"AreaMeasure":n=new d.default(this.drawing2D,t);break;case"capture":n=new g.default}n.name=e,n.mode=this.mode,n.observer=this.observer,n.init(this.drawing2D),this.editors.push(n)}},{key:"enableSnap",value:function(e){this.getEditor().enableSnap&&this.getEditor().enableSnap(e)}},{key:"enablePickEffect",value:function(e){this.getEditor().enablePickEffect&&this.getEditor().enablePickEffect(e)}},{key:"setSnapMode",value:function(e){this.getEditor().setSnapMode&&this.getEditor().setSnapMode(e)}}]),e}();p.editorMode=-1,t.default=p},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"isDesktop",value:function(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),i=/(?:SymbianOS)/.test(e)||t,n=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),s=(/(?:Chrome|CriOS)/.test(e),/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e));return!(/(?:iPhone)/.test(e)&&!s||n||i||s)}}]),e}();t.default=o},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=(n(i(3)),i(1)),r=n(s),a=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r.default.MouseMode))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"onDoubleClick",value:function(e){this.getEditor().onDoubleClick(this.drawing2D,e)}},{key:"onMouseDown",value:function(e){this.getEditor().onMouseDown(this.drawing2D,e);var t=this.drawing2D.getClickCallback();t&&t([e.offsetX,e.offsetY])}},{key:"onMouseUp",value:function(e){var t=this.getEditor();t.onMouseUp(this.drawing2D,e)===r.default.FINISHED&&(t.onExit(this.drawing2D),this.editors.pop())}},{key:"onMouseMove",value:function(e){this.getEditor().onMouseMove(this.drawing2D,e)}},{key:"onMouseWheel",value:function(e){this.getEditor().onMouseWheel(this.drawing2D,e)}},{key:"onKeyDown",value:function(e){var t=this.getEditor();t.onKeyDown(this.drawing2D,e)==r.default.FINISHED&&(t.onExit(this.drawing2D),this.editors.pop())}},{key:"onKeyUp",value:function(e){var t=this.getEditor();t.onKeyUp(this.drawing2D,e)==r.default.FINISHED&&(t.onExit(this.drawing2D),this.editors.pop())}},{key:"unbindAllEvent",value:function(){var e=this.getDom();e.removeEventListener("dblclick",this.allEvent.onDoubleClick,!1),e.removeEventListener("mousedown",this.allEvent.onMouseDown,!1),e.removeEventListener("mouseup",this.allEvent.onMouseUp,!1),e.removeEventListener("mousemove",this.allEvent.onMouseMove,!1),e.removeEventListener("mousewheel",this.allEvent.onMouseWheel,!1),e.removeEventListener("DOMMouseScroll",this.allEvent.onMouseWheel,!1),document.removeEventListener("keydown",this.allEvent.onKeyDown),document.removeEventListener("keyup",this.allEvent.onKeyUp)}},{key:"bindEvents",value:function(){var e=this;this.allEvent={onDoubleClick:function(t){t.preventDefault(),e.onDoubleClick(t)},onMouseDown:function(t){t.preventDefault(),e.onMouseDown(t)},onMouseMove:function(t){e.onMouseMove(t)},onMouseWheel:function(t){t.preventDefault(),e.onMouseWheel(t)},onMouseUp:function(t){t.preventDefault(),e.onMouseUp(t)},onKeyDown:function(t){e.onKeyDown(t)},onKeyUp:function(t){e.onKeyUp(t)}};var t=e.getDom();t.addEventListener("dblclick",this.allEvent.onDoubleClick,!1),t.addEventListener("mousedown",this.allEvent.onMouseDown,!1),t.addEventListener("mouseup",this.allEvent.onMouseUp,!1),t.addEventListener("mousemove",this.allEvent.onMouseMove,!1),t.addEventListener("mousewheel",this.allEvent.onMouseWheel,!1),t.addEventListener("DOMMouseScroll",this.allEvent.onMouseWheel,!1),t.oncontextmenu=function(e){e.preventDefault()},document.addEventListener("keydown",this.allEvent.onKeyDown),document.addEventListener("keyup",this.allEvent.onKeyUp)}}]),t}(n(i(9)).default);t.default=a},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}var o=n(i(13)),s=n(i(25)),r=n(i(28)),a={preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){e=Array.prototype.slice.call(arguments).join(" "),console.log(e)},progress:function(e,t,i){""==e?(console.log("Initialized."),o.default.ready()):console.log(e)},locateFile:function(e){return o.default.sdkUrl+e},setStatus:function(e){if(a.setStatus.last||(a.setStatus.last={time:Date.now(),text:""}),e!==a.setStatus.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);t?a.progress(e,100*parseInt(t[2]),100*parseInt(t[4])):a.progress(e,null,null)}},totalDependencies:0,monitorRunDependencies:function(e){this.totalDependencies=Math.max(this.totalDependencies,e),a.setStatus(e?"Preparing... ("+(this.totalDependencies-e+1)+"/"+this.totalDependencies+")":"Complete.")}};a.setStatus("20180528"),o.default.loadModel=function(e,t,i){var n=new XMLHttpRequest,s=this;n.onreadystatechange=function(){if(n.readyState===XMLHttpRequest.DONE)if(200===n.status||0==n.status){var r=a.LoadCallback.extend("LoadCallback",{OnLoad:function(e){e.indexJson=JSON.parse(n.responseText),t(e)},OnError:function(){t(null)},OnDownloading:function(e){o.default.onLoadProgress(e)}}),l=JSON.parse(n.responseText),h=!0;0!=l.metadata.gz&&"false"!=l.metadata.gz||(h=!1);var c=new r;a.loadModel(e+"/",c,h)}else 404===n.status&&(i?s.loadModel(e,t):t(null))},n.open("GET",e+"/index.json"+(i?".gz":"")),n.send()},o.default.loadGrids=function(e,t){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(i.readyState===XMLHttpRequest.DONE)if(200===i.status||0==i.status){var e=JSON.parse(i.responseText);t(e)}else 404===i.status&&t(null)},i.open("GET",e+"/grids.json"),i.send()},s.default.loadModel=function(e,t,i,n,o,r){var a=new XMLHttpRequest,l=this;a.onreadystatechange=function(){if(a.readyState===XMLHttpRequest.DONE)if(200===a.status||0==a.status){var h=JSON.parse(a.responseText),c=!0;if(!o){0!=h.metadata.gz&&"false"!=h.metadata.gz||(c=!1);var d=0,u=0;null!=h.metadata.translate_x&&null!=h.metadata.translate_x&&(d=parseFloat(h.metadata.translate_x)),null!=h.metadata.translate_y&&null!=h.metadata.translate_y&&(u=parseFloat(h.metadata.translate_y))}var g=i.viewer,p=new i.butterfly.LoadReactor,f=function e(t){1==g.PrepareModel()?(g.translateX=d,g.translateY=u,t(g)):setTimeout((function(){e(t)}),500)};p.OnLoad=function(){f(n),i.update()},p.OnDownloading=function(e){s.default.onLoadProgress(1-e)},p.OnError=function(){console.error("error when parse")},o&&(e=e+"/"+o),g.url=e,g.Load(e,p,c)}else 404===a.status&&(r?l.loadModel(e,t,i,n,o):n(null))},a.open("GET",e+"/index.json"+(r?".gz":"")),a.send()},s.default.addModel=function(e,t,i,n,o){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===XMLHttpRequest.DONE)if(200===r.status||0==r.status){var a=JSON.parse(r.responseText),l=!0;if(!n){0!=a.metadata.gz&&"false"!=a.metadata.gz||(l=!1);var h=0,c=0;null!=a.metadata.translate_x&&null!=a.metadata.translate_x&&(h=parseFloat(a.metadata.translate_x)),null!=a.metadata.translate_y&&null!=a.metadata.translate_y&&(c=parseFloat(a.metadata.translate_y))}var d=t.viewer,u=new t.butterfly.LoadReactor,g=0,p=function e(t){1==d.PrepareModel()?(d.translateX=h,d.translateY=c,t(d,g,a)):setTimeout((function(){e(t)}),500)};u.OnLoad=function(){p(i),t.update()},u.OnDownloading=function(e){s.default.onLoadProgress(1-e)},u.OnError=function(){console.error("error when parse")},n&&(e=e+"/"+n),d.url=e,g=d.AddModel(e,u,l)}else 404===r.status&&(o?self.addModel(e,t,i,n):i(null))},r.open("GET",e+"/index.json"),r.send()},s.default.loadGrids=function(e,t){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(i.readyState===XMLHttpRequest.DONE)if(200===i.status||0==i.status){var e=JSON.parse(i.responseText);t(e)}else 404===i.status&&t(null)},i.open("GET",e+"/grids.json"),i.send()},window.Module=a,window.Glodon=window.Glodon||{},window.Glodon.Bimface=window.Glodon.Bimface||{},window.Glodon.Bimface.DrawingSheet=o.default,window.Glodon.Bimface.WebglDrawingSheet=s.default,window.Glodon.Bimface.RevitInterop=r.default},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(3)),r=n(i(8)),a=n(i(11)),l=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"initialize",value:function(t){void 0!==t&&(e.ready=t);var i=document.getElementsByTagName("HEAD").item(0),n=document.createElement("script");n.type="text/javascript",n.src=e.sdkUrl+"/mdvjs.js",i.appendChild(n)}},{key:"ready",value:function(){console.log("Drawing2D engine is ready!")}},{key:"onLoadProgress",value:function(e){console.log(e)}},{key:"loadModel",value:function(e,t){console.log("not implemented!")}},{key:"createDrawing",value:function(e){var t=document.getElementById(e),i=document.createElement("canvas");i.id=e+"-main-drawing",i.width=t.clientWidth,i.height=t.clientHeight,i.style.position="absolute",t.appendChild(i);var n=document.createElement("canvas");n.id=e+"-aux-drawing",n.width=t.clientWidth,n.height=t.clientHeight,n.style.position="absolute",t.appendChild(n);var o=document.createElement("canvas");return o.id=e+"-ovl-drawing",o.width=t.clientWidth,o.height=t.clientHeight,o.style.position="absolute",t.appendChild(o),new s.default(i,n,o,e)}},{key:"createMouseEditorManager",value:function(e){return new a.default(e)}},{key:"createTouchEditorManager",value:function(e){return new r.default(e)}}]),e}();l.sdkUrl="js/",t.default=l},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(i(0)),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"create",value:function(e,t,i){var n=new(Module.DeviceContext.extend("DeviceContext",{initialize:function(e,t){this.canvasMain=e,this.canvasTemp=t,this.canvasOverlay=i,this.ctxMain=this.canvasMain.getContext("2d"),this.ctxTemp=this.canvasTemp.getContext("2d"),this.ctxOverlay=this.canvasOverlay.getContext("2d"),this.inPath=!1,this.fontSize=12,this.colorTable={},this.faceColorTable={},this.globalOpacity=null,this.Normal=0,this.White=1,this.Black=2,this.Gray=3,this.Custom=4,this.printMode=this.Normal,this.printColorTable={},this.printFaceColorTable={},this.resUrl="",this.images={},this.ignoreImage=!1,this.targetId=0,this.overlayDrawers={},this.customColor=-1},drawingOverlay:function(e,t){var i=this.ctxOverlay;i.clearRect(0,0,e,t);var n=this.overlayDrawers;for(var o in n)n[o](i)},setBackgroundColor:function(e){this.canvasMain.style.background=e},setPrintMode:function(e){if("Normal"==e)this.printMode=this.Normal;else if("Gray"==e)this.printMode=this.Gray;else if("Black"==e)this.printMode=this.Black;else if("White"==e)this.printMode=this.White;else{if("Custom"!=e)return;this.printMode=this.Custom}},setResourceUrl:function(e){this.resUrl=e},setGlobalOpacity:function(e){this.globalOpacity=e},getGlobalOpacity:function(){return this.globalOpacity},restoreGlobalOpacity:function(){this.globalOpacity=null},getHexColor:function(e){var t=null===this.globalOpacity?1:this.globalOpacity;if(this.printMode==this.Custom&&null!=this.customColor.red)return null==this.globalOpacity&&1!=this.customColor.alpha&&(t=this.customColor.alpha),"rgba("+this.customColor.red+","+this.customColor.green+","+this.customColor.blue+","+t+")";var i=e>>16,n=e>>8&255,o=255&e;if(2==this.printMode||1==this.printMode&&255==i&&255==n&&255==o)return"rgba(0,0,0,"+t+")";if(3==this.printMode){var s=255==i&&255==n&&255==o?0:.299*i+.587*n+.114*o;return this.printColorTable[e]="rgba("+s+","+s+","+s+","+t+")",this.printColorTable[e]}return this.colorTable[e]="rgba("+o+","+n+","+i+","+t+")",this.colorTable[e]},getFaceColor:function(e){var t=null===this.globalOpacity?.9:this.globalOpacity;if(this.printMode==this.Custom&&null!=this.customColor.red)return null==this.globalOpacity&&1!=this.customColor.alpha&&(t=this.customColor.alpha),"rgba("+this.customColor.red+","+this.customColor.green+","+this.customColor.blue+","+t+")";var i=e>>16,n=e>>8&255,o=255&e;if(2==this.printMode||1==this.printMode&&255==i&&255==n&&255==o)return"rgba(0,0,0,"+t+")";if(3==this.printMode){var s=255==i&&255==n&&255==o?0:.299*i+.587*n+.114*o;return this.printFaceColorTable[e]="rgba("+s+","+s+","+s+","+t+")",this.printFaceColorTable[e]}return this.faceColorTable[e]="rgba("+o+","+n+","+i+","+t+")",this.faceColorTable[e]},resize:function(e,t){this.canvasMain.setAttribute("width",e),this.canvasMain.setAttribute("height",t),this.canvasTemp.setAttribute("width",e),this.canvasTemp.setAttribute("height",t),this.canvasOverlay.setAttribute("width",e),this.canvasOverlay.setAttribute("height",t)},clearAll:function(e,t){this.ctxMain.clearRect(0,0,e,t),this.ctxTemp.clearRect(0,0,e,t),this.ctxOverlay.clearRect(0,0,e,t)},SetTarget:function(e){0==e?this.ctx=this.ctxMain:(this.ctx=this.ctxTemp,this.ctx.strokeStyle="#ff0000"),this.targetId=e},BeginDraw:function(e,t){this.ctx.clearRect(t[0],t[1],t[2],t[3])},EndDraw:function(e){},BeginPath:function(){this.inPath=!0,this.ctx.beginPath()},EndPath:function(e,t){this.inPath=!1,e&&(this.ctx.fillStyle=this.getFaceColor(t),this.ctx.closePath(),this.ctx.fill()),this.ctx.stroke()},BeginClip:function(e){e&&(this.ctx.save(),this.ctx.clip())},EndClip:function(e){e&&this.ctx.restore()},SetLineColor:function(e){var t=this.getHexColor(e);this.ctx.strokeStyle=t,this.ctx.fillStyle=t},SetLineWidth:function(e){this.ctx.lineWidth=e},SetLineDash:function(e,t){if(0!=e)if(1!=e){for(var i=[],n=0,o=t.size();n<o;++n)i.push(t.get(n));this.ctx.setLineDash(i)}else this.ctx.setLineDash([10]);else this.ctx.setLineDash([])},SetFont:function(e){this.fontSize=e,this.ctx.font=this.fontSize+"px 仿宋"},DrawPoint:function(e,t,i){},DrawLine:function(e,t){if(this.inPath)this.ctx.moveTo(e[0],e[1]),this.ctx.lineTo(t[0],t[1]);else{for(var i=this.ctx.getLineDash(),n=0,o=0;o<i.length;++o)n+=i[o];this.ctx.beginPath(),this.ctx.moveTo(e[0],e[1]),(e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])<n*n&&this.ctx.setLineDash([]),this.ctx.lineTo(t[0],t[1]),this.ctx.stroke(),this.ctx.setLineDash(i)}},DrawArc:function(e,t,i,n){this.inPath?this.ctx.arc(e[0],e[1],t,-i,-n,!0):(this.ctx.beginPath(),this.ctx.arc(e[0],e[1],t,-i,-n,!0),this.ctx.stroke())},DrawRec:function(e,t){this.inPath?this.ctx.rect(e[0],e[1],t[0]-e[0],t[1]-e[1]):(this.ctx.beginPath(),this.ctx.rect(e[0],e[1],t[0]-e[0],t[1]-e[1]),this.ctx.stroke())},DrawCloudRec:function(e,t,i){var n=e,o=t;i=i||this.ctx,n=[n[0]+18/3.5,n[1]+18/3.5];var s=(o=[o[0]-18/3.5,o[1]-18/3.5])[1]-n[1],r=o[0]-n[0],a=Math.abs(r),l=Math.abs(s),h=parseInt(a/18),c=parseInt(l/18),d=0==h?a:a/h,u=0==c?l:l/c;i.beginPath(),this.drawSide("orientation",d,a,n[0],n[1],i),this.drawSide("orientation",d,a,n[0]+a,n[1]+l,i,!0),this.drawSide("portrait",u,l,n[0]+a,n[1],i),this.drawSide("portrait",u,l,n[0],n[1]+l,i,!0),i.stroke()},drawSide:function(e,t,i,n,o,s,r){var a=0,l=0,h=i/t,c=void 0,d=n,u=o;"orientation"==e?a=t:l=t;for(var g=0;g<h;g++){s.moveTo(n,o),c=r?[n-a,o-l]:[n+a,o+l],a&&Math.abs(c[0]-d)>i?c[0]=r?d-i:d+i:l&&Math.abs(c[1]-u)>i&&(c[1]=r?u-i:u+i);var p=this.getControlPt([n,o],c);s.quadraticCurveTo(p[0],p[1],c[0],c[1]),n=c[0],o=c[1]}},getControlPt:function(e,t,i){var n=[(e[0]+t[0])/2,(e[1]+t[1])/2],s=.4*o.default.distanceByArr(e,t),r=[t[1]-e[1],e[0]-t[0]];return r=o.default.normalize(r),[n[0]+r[0]*s,n[1]+r[1]*s]},DrawPolyline:function(e){var t=e.size();if(!(t<1))if(this.inPath){this.pt=e.get(0),this.ctx.moveTo(this.pt[0],this.pt[1]);for(var i=1;i<t;++i)this.pt=e.get(i),this.ctx.lineTo(this.pt[0],this.pt[1])}else{for(var n=this.ctx.getLineDash(),o=0,s=0;s<n.length;++s)o+=n[s];this.ctx.beginPath(),this.pt=e.get(0),this.ctx.moveTo(this.pt[0],this.pt[1]);for(var r=1;r<t;++r){(this.pt[0]-e.get(r)[0])*(this.pt[0]-e.get(r)[0])+(this.pt[1]-e.get(r)[1])*(this.pt[1]-e.get(r)[1])<o*o?this.ctx.setLineDash([]):this.ctx.setLineDash(n),this.pt=e.get(r),this.ctx.lineTo(this.pt[0],this.pt[1]),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.moveTo(this.pt[0],this.pt[1])}this.ctx.setLineDash(n)}},DrawText:function(e,t){this.ctx.fillText(e,t[0],t[1])},DrawTextW:function(e,t,i){0!=i?(this.ctx.save(),this.ctx.translate(t[0],t[1]),this.ctx.rotate(i),this.ctx.fillText(e,0,0),this.ctx.restore()):this.ctx.fillText(e,t[0],t[1])},DrawImageImpl:function(e,t,i,n,o,s,r){function a(t,i,n,o,s,r){0==r?e.drawImage(t,i,n,o,s):(e.save(),e.translate(i,n+s),e.rotate(r),e.drawImage(t,0,-s,o,s),e.restore())}var l=this,h=l.images[t];if(l.ignoreImage)return!1;void 0===h?((h=new Image).onload=function(){a(h,i,n,o,s,r),l.images[t]=h},h.src=t):a(h,i,n,o,s,r)},DrawImage:function(e,t,i,n,o,s){this.DrawImageImpl(this.ctx,this.resUrl+"image/"+e,t,i,n,o,s)}}));return n.initialize(e,t),n}}]),e}();t.default=s},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(t,i,n,o){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.min=t,this.max=i,this.markupType="Rect",this.strokeStyle=n.strokeStyle,this.lineWidth=n.lineWidth||4,this.fontSize=14,this.fontFamily="Arial",this.margin=o||0,this.fillStyle="white",this.id=""}return n(e,[{key:"draw",value:function(e,t){var i=e.toScreenPoint([this.min[0]-this.margin,this.min[1]-this.margin]),n=e.toScreenPoint([this.max[0]+this.margin,this.max[1]+this.margin]);if(e.dc.ctx)e.dc.ctx.strokeStyle=this.strokeStyle,e.dc.SetLineWidth(this.lineWidth),e.dc.SetLineDash(0),e.dc.DrawRec([i[0],n[1]],[n[0],i[1]]);else{e.dc.ctxOverlay.strokeStyle=this.strokeStyle,e.dc.ctxOverlay.lineWidth=this.lineWidth;var o=[i[0],n[1]],s=[n[0],i[1]];this.inPath?e.dc.ctxOverlay.rect(o[0],o[1],s[0]-o[0],s[1]-o[1]):(e.dc.ctxOverlay.beginPath(),e.dc.ctxOverlay.rect(o[0],o[1],s[0]-o[0],s[1]-o[1]),e.dc.ctxOverlay.stroke())}}}]),e}();t.default=o},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(t,i,n,o){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.min=t,this.max=i,this.margin=o||0,this.markupType="CloudRect",this.strokeStyle=n.strokeStyle,this.lineWidth=n.lineWidth||4,this.fontSize=14,this.fontFamily="Arial",this.fillStyle="white",this.id=""}return n(e,[{key:"draw",value:function(e,t){var i=e.toScreenPoint([this.min[0]-this.margin,this.min[1]-this.margin]),n=e.toScreenPoint([this.max[0]+this.margin,this.max[1]+this.margin]);e.dc.ctx?(e.dc.ctx.strokeStyle=this.strokeStyle,e.dc.SetLineWidth(this.lineWidth),e.dc.SetLineDash(0),e.dc.DrawCloudRec([i[0],n[1]],[n[0],i[1]])):(e.dc.ctxOverlay.strokeStyle=this.strokeStyle,e.dc.ctxOverlay.lineWidth=this.lineWidth,e.dc.DrawCloudRec([i[0],n[1]],[n[0],i[1]],e.dc.ctxOverlay))}}]),e}();t.default=o},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(t,i,n,o,s){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.min=i,this.max=n,this.markupType="Chartlet",this.margin=s||0,this.id=o,this.img=t}return n(e,[{key:"draw",value:function(e){var t=e.toScreenPoint([this.min[0]-this.margin,this.min[1]-this.margin]),i=e.toScreenPoint([this.max[0]+this.margin,this.max[1]+this.margin]),n=i[0]-t[0],o=i[1]-t[1];e.dc.ctx?e.dc.ctx.drawImage(this.img,t[0],t[1],n,o):e.dc.ctxOverlay.drawImage(this.img,t[0],t[1],n,o)}}]),e}();t.default=o},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,[{key:"worldToNormalizedPoint",value:function(e,t){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;e.x=(e.x-t.min.x)/i*2-1,e.y=(e.y-t.min.y)/n*2-1,e.y=-e.y}},{key:"normalizedPointToWorld",value:function(e,t){e.y=-e.y;var i=t.max.x-t.min.x,n=t.max.y-t.min.y;e.x=.5*(e.x+1)*i+t.min.x,e.y=.5*(e.y+1)*n+t.min.y}},{key:"normalizedPointToMinimap",value:function(e,t){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;e.x=.5*(e.x+1)*i+t.min.x,e.y=.5*(e.y+1)*n+t.min.y}},{key:"minimapToNormalizedPoint",value:function(e,t){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;e.x=(e.x-t.min.x)/i*2-1,e.y=(e.y-t.min.y)/n*2-1}},{key:"containsBox",value:function(e,t){return e.min.x<=t.min.x&&t.max.x<=e.max.x&&e.min.y<=t.min.y&&t.max.y<=e.max.y}},{key:"intersect",value:function(e,t){var i={x:0,y:0},n={x:0,y:0};return i.x=Math.max(e.min.x,t.min.x),i.y=Math.max(e.min.y,t.min.y),n.x=Math.min(e.max.x,t.max.x),n.y=Math.min(e.max.y,t.max.y),{min:i,max:n}}},{key:"boundsChecking",value:function(e,t){0===e.min.x&&e.min.x++,0===e.min.y&&e.min.y++,e.max.x===t.x&&e.max.x--,e.max.y===t.y&&e.max.y--}},{key:"intersectsBox",value:function(e,t){return!(e.max.x<t.min.x||e.min.x>t.max.x||e.max.y<t.min.y||e.min.y>t.max.y)}}]),e}();t.default=o},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(1)),r=n(i(2)),a=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var e=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.startPt=[0,0],e.endPt=null,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"onDrawing",value:function(e,t){null!=this.endPt&&(t.strokeStyle=r.default.Zoom.color,t.lineWidth=r.default.Zoom.lineWidth,t.strokeRect(this.startPt[0],this.startPt[1],this.endPt[0]-this.startPt[0],this.endPt[1]-this.startPt[1]))}},{key:"begin",value:function(e,t,i,n){n==s.default.LelftButton&&(this.startPt[0]=t,this.startPt[1]=i,this.starting=!0)}},{key:"onEditing",value:function(e,t,i,n){this.starting&&(this.endPt=[t,i],this.redraw(e))}},{key:"end",value:function(e,t,i,n){return!this.starting||t==this.startPt[0]&&i==this.startPt[1]||e.zoom(this.startPt[0],this.startPt[1],t,i),this.endPt=null,this.redraw(e),s.default.FINISHED}}]),t}(s.default);t.default=a},function(e,t,i){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),r=function(e){function t(){return n(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),s(t,[{key:"begin",value:function(e,t,i,n){this.isPanMode(n)||(this.start=!0)}},{key:"onEditing",value:function(e,t,i,n){this.start&&e.panTo(t,i)}},{key:"end",value:function(e,t,i,n){1==this.start&&(e.update(!0),this.start=!1)}}]),t}(function(e){return e&&e.__esModule?e:{default:e}}(i(1)).default);t.default=r},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function e(t,i,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,i);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(n):void 0},s=function(e){return e&&e.__esModule?e:{default:e}}(i(4)),r=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var e=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.snapIsEnabled=!1,e.pickEnabled=!0,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"init",value:function(e){o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"init",this).call(this,e),this.picked=!1,this.preSelectCount=0}},{key:"begin",value:function(e,t,i,n){n==s.default.LelftButton?(this.picked=!0,this.start=!0):n==s.default.MiddleButton&&(this.moving=!0,this.start=!0),this.mode==s.default.TouchMode&&(this.pickMode=!0,e.isHighlightEventEnabled()&&this.notify("highlight",e.getHighlightIds(),t,i))}},{key:"onEditing",value:function(e,t,i,n,o){if(this.mode==s.default.TouchMode)e.panTo(t,i)&&(this.pickMode=this.picked=!1);else if(this.pickMode=!0,e.hover){var r=e.preSelect(t,i,1===n,!0);if(r==this.preSelectCount&&0==this.preSelectCount||(e.update(),this.preSelectCount=r),e.isHighlightEventEnabled()&&this.notify("highlight",e.getHighlightIds(),t,i,o),this.snapIsEnabled){this.tmpPointScreenPoint=[t,i],this.tmpPoint=e.snapToPoint(t,i),this.isMatchSnapMode=this.matchSnapMode(this.tmpPoint,e.getSnapMode());var a=e.dc.ctxOverlay;this.redraw(e,a)}}}},{key:"end",value:function(e,t,i,n){!0===this.pickMode&&this.picked&&this.pickEnabled&&(e.select(),e.update(),this.notify("selection",e.getSelectedIds()),this.pickMode=!1,this.picked=!1),this.start&&(this.start=!1)}},{key:"onMouseMove",value:function(e,t){var i=this.formatEventOffset(e,t);if(t.ctrlKey||t.altKey||!this.isPanMode(t.buttons))this.onEditing(e,i.x,i.y,t.buttons,t);else if(this.start&&e.panTo(i.x,i.y)&&(this.pickMode=this.picked=!1),this.snapIsEnabled){this.tmpPointScreenPoint=[i.x,i.y],this.tmpPoint=e.snapToPoint(i.x,i.y),this.isMatchSnapMode=this.matchSnapMode(this.tmpPoint,e.getSnapMode());var n=e.dc.ctxOverlay;this.redraw(e,n)}}},{key:"isPanMode",value:function(e){return 0!=e}},{key:"enableSnap",value:function(e){this.snapIsEnabled=e}},{key:"enablePickEffect",value:function(e){this.pickEnabled=e}}]),t}(s.default);t.default=r},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(t,i){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.drawing2D=t,this.touchEndCounts=0,this.editor=i,this.outerCircleRadius=60,this.outerCircleFillStyle="rgba(255, 255, 255, 0.3)",this.outerCircleBorderWidth=2,this.outerCircleBorderColor="#999999",this.innerCircleRadius=50,this.innerCircleFillStyle="rgba(204, 204, 204, 0.5)",this.innerCircleBorderWidth=2,this.triangleWidth=20,this.triangleFillStyle="rgba(204, 204, 204, 0.5)",this.triangleBorderWidth=2,this.triangleBorderColor="#999999";var n={x:t.width/2,y:t.height/2};this.draw(this.updateAuxMeasure(n))}return n(e,[{key:"setEditor",value:function(e){this.editor=e}},{key:"updateAuxMeasure",value:function(e){this.center=e;var t={outerCircle:{}};t.outerCircle.center=e,t.outerCircle.radius=this.outerCircleRadius,t.innerCircle={},t.innerCircle.center=e,t.innerCircle.radius=this.innerCircleRadius,t.triangle=[];var i={x:e.x-this.outerCircleRadius,y:e.y-this.outerCircleRadius};return 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}),t}},{key:"draw",value:function(e){var t=this.drawing2D.dc.ctxOverlay,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();var 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();var 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()}},{key:"getRealPoint",value:function(e){var t=this.outerCircleRadius,i=this.outerCircleRadius;return{x:e.x-t,y:e.y-i}}},{key:"onTouchStart",value:function(e){}},{key:"onTouchMove",value:function(e){if(this.touchOnAux(e)){var t=this.updateAuxMeasure({x:e.point.x,y:e.point.y});this.draw(t);var i=this.editor,n=this.getRealPoint(e.point);i.onEditing(this.drawing2D,n.x,n.y,1)}}},{key:"onTouchEnd",value:function(e,t){if(this.touchOnAux(e)){var i=this.editor,n=this.getRealPoint(e.point);++this.touchEndCounts%2==1&&this.drawing2D.setStartPoint(n.x,n.y),this.touchEndCounts%2==0&&i.end(this.drawing2D,n.x,n.y,1),!t&&i.redraw(this.drawing2D),i.clearSnapPoint()}}},{key:"redraw",value:function(){if(this.center){var e=this.updateAuxMeasure(this.center);this.draw(e)}}},{key:"touchOnAux",value:function(e){var t=this.center,i=this.outerCircleRadius,n=e.point.x,o=e.point.y,s=t.x-n,r=t.y-o;return Math.sqrt(s*s+r*r)<=i}}]),e}();t.default=o},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function e(t,i,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,i);if(void 0===o){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in o)return o.value;var r=o.get;return void 0!==r?r.call(n):void 0},r=n(i(5)),a=(n(i(0)),i(10)),l=n(a),h=n(i(2)),c=function(e){function t(e,i){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"onDrawing",value:function(e,i){if(l.default.isDesktop()){if(this.drawMask(e,i),this.showMask||this.needToMaskViewport(e,i)||this.drawSnapPoint(e,i),0!==this.points.length){i.strokeStyle=this.color,i.lineWidth=h.default.Measure.lineWidth,i.fillStyle=i.strokeStyle;var n=this.worldToScreen(e,this.points);this.parallelDetect(e,n);var o=this.tmpPoint?this.worldToScreen(e,[this.tmpPoint])[0]:null,r=o?n.concat([o]):n,a=r.length;if(2==a){var c=r[0],d=r[1];i.beginPath(),i.moveTo(c[0],c[1]),i.lineTo(d[0],d[1]),i.stroke()}else if(a>2)for(var u=1;u<a+1;u++){var g=r[u-1],p=u==a?r[0]:r[u];i.beginPath(),i.moveTo(g[0],g[1]),i.lineTo(p[0],p[1]),i.stroke()}for(var f=o?a-1:a,m=0;m<f;m++){var w=r[m];this.strokeCircle(i,w),i.beginPath(),i.arc(w[0],w[1],4,0,2*Math.PI,!0),i.fill()}}}else s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onDrawing",this).call(this,e,i)}},{key:"begin",value:function(e,t,i,n){}},{key:"end",value:function(e,t,i,n){if(!(this.showMask||this.needMaskVPId>0))if(this.isPanMode(n)){if(this.sameAsMousedownPt(t,i)&&this.step<3){if(0==this.step)return;this.points=[],this.step=0,this.redraw(e),this.notify("change",{type:"Area",status:"reset"})}else if(this.sameAsMousedownPt(t,i)&&this.step>=3){var o=this.getArea(this.points.slice()),s=[],r=!0,a=!1,h=void 0;try{for(var c,d=this.points[Symbol.iterator]();!(r=(c=d.next()).done);r=!0){var u=c.value,g=u.GetID()>0&&!e.viewer.IsActiveLayoutElement(u.GetID());s.push({point:u.GetPoint(),isActiveLayoutElement:!g})}}catch(e){a=!0,h=e}finally{try{!r&&d.return&&d.return()}finally{if(a)throw h}}this.pressShift=!1,this.parallel=!1,this.viewPort=null,this.points=[],this.step=0,this.redraw(e),this.notify("change",{area:o,type:"Area",status:"measured",points:s})}}else{var p=e.toModelWorld([t,i]);if(0==this.step&&(this.viewPort=p[2],-1==p[2]?this.firstPointOutsideVP=!0:this.firstPointOutsideVP=!1),this.finalScreenPoint){var f=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]);this.worldPtForOtherDrawing[this.step]=e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]])}else{f=e.snapToPoint(t,i);this.worldPtForOtherDrawing[this.step]=null}if(this.parallel?this.points[this.step]=this.tmpPoint:this.points[this.step]=f,p[2]!=this.viewPort)return this.points.splice(1,1);this.step++,this.tmpPoint=null;var m=this.points,w=m.length,v=m[0].GetPoint(),y=f.GetPoint();if(w>2&&!l.default.isDesktop()&&this.isClosePath(e,v,y)){this.pressShift=!1,this.parallel=!1,this.viewPort=null;var b=this.getArea(m.slice()),x=[],E=!0,C=!1,M=void 0;try{for(var P,I=m[Symbol.iterator]();!(E=(P=I.next()).done);E=!0){var T=P.value,D=T.GetID()>0&&!e.viewer.IsActiveLayoutElement(T.GetID());x.push({point:T.GetPoint(),isActiveLayoutElement:!D})}}catch(e){C=!0,M=e}finally{try{!E&&I.return&&I.return()}finally{if(C)throw M}}this.notify("change",{area:b,type:"Area",status:"measured",points:x}),this.points=[],this.step=0}else{var S=[],B=!0,_=!1,k=void 0;try{for(var A,L=m[Symbol.iterator]();!(B=(A=L.next()).done);B=!0){var V=A.value,R=V.GetID()>0&&!e.viewer.IsActiveLayoutElement(V.GetID());S.push({point:V.GetPoint(),isActiveLayoutElement:!R})}}catch(e){_=!0,k=e}finally{try{!B&&L.return&&L.return()}finally{if(_)throw k}}this.notify("change",{type:"Area",status:"measuring",points:S})}this.redraw(e)}}},{key:"isClosePath",value:function(e,t,i){var n=e.toScreenPoint(t),o=e.toScreenPoint(i);return Math.abs(n[0]-o[0])<6&&Math.abs(n[1]-o[1])<6}},{key:"getArea",value:function(e){for(var t=e.length,i=0;i<t;i++)e[i]=this.worldPtForOtherDrawing[i]||e[i].GetPoint();if(t<3)return 0;var n=e[0][1]*(e[t-1][0]-e[1][0]);for(i=1;i<t;++i)n+=e[i][1]*(e[i-1][0]-e[(i+1)%t][0]);return Math.abs(n/2)}}]),t}(r.default);t.default=c},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(5)),r=n(i(0)),a=(n(i(2)),function(e){function t(e,i){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"end",value:function(e,t,i,n){if(!(this.showMask||this.needMaskVPId>0)){if(this.isPanMode(n)){if(this.sameAsMousedownPt(t,i)){if(0==this.points.length)return;this.reset(),this.notify("change",{type:"Angle",status:"reset"})}}else{var o=e.toModelWorld([t,i]);if(0==this.step&&(this.points=[],this.viewPort=o[2],-1==o[2]?this.firstPointOutsideVP=!0:this.firstPointOutsideVP=!1),this.parallel||(this.finalScreenPoint?(this.points[this.step]=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]),this.worldPtForOtherDrawing[this.step]=e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]])):(this.points[this.step]=e.snapToPoint(t,i),this.worldPtForOtherDrawing[this.step]=null)),this.step>0){var s=this.points[this.step].GetPoint(),a=this.points[this.step-1].GetPoint();if(s[0]==a[0]&&s[1]==a[1])return}if(o[2]!=this.viewPort)return this.points.splice(1,1);if(this.step=this.step+1,this.tmpPoint=null,this.step>=3){for(var l=[],h=this.points,c=0;c<h.length;c++){var d=h[c].GetPoint();if(this.worldPtForOtherDrawing[c])d=this.worldPtForOtherDrawing[c];else if(this.points[c].GetID()){var u=e.toScreenPoint(d),g=e.toModelWorld(u);g[2]>0&&(d=g)}l.push(d)}"X"==this.parallel?l[2][0]=l[0][0]:"Y"==this.parallel&&(l[2][1]=l[0][1]);var p=r.default.angleByArr(l[0],l[1],l[2]);this.notify("change",{angle:p,type:"Angle",status:"measured",points:l,isOnLayout:o[2]>0}),this.points=[],this.step=0,this.pressShift=!1,this.parallel=!1,this.viewPort=null}else{for(var f=[],m=0;m<this.points.length;m++)f.push(this.points[0].GetPoint());this.notify("change",{type:"Angle",status:"measuring",points:f})}}this.redraw(e)}}}]),t}(s.default));t.default=a},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(26)),r=n(i(8)),a=n(i(11)),l=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"initialize",value:function(t){void 0!==t&&(e.ready=t);var i=document.getElementsByTagName("HEAD").item(0),n=document.createElement("script");n.type="text/javascript",i.appendChild(n)}},{key:"ready",value:function(){console.log("Drawing2D engine is ready!")}},{key:"onLoadProgress",value:function(e){console.log(e)}},{key:"loadModel",value:function(e,t,i){console.log("not implemented!")}},{key:"addModel",value:function(e,t,i){console.log("not implemented!")}},{key:"createDrawing",value:function(t){var i=document.getElementById(t),n=(i=document.getElementById(t),document.createElement("canvas"));n.id=t+"-main-drawing",n.width=i.clientWidth,n.height=i.clientHeight,n.style.position="absolute",i.appendChild(n);var o=BimButterfly({canvas:n});n.getContext("webgl",{preserveDrawingBuffer:!0});for(var r=new o.DrawingView("No.1");e.drawingIDs.indexOf(r.ptr)>-1;)r=new o.DrawingView("No.1");e.drawingIDs.push(r.ptr),r.Create(i.clientWidth,i.clientHeight);var a=document.createElement("canvas");a.id=t+"-aux-drawing",a.width=i.clientWidth,a.height=i.clientHeight,a.style.position="absolute",i.appendChild(a);var l=document.createElement("canvas");return l.id=t+"-ovl-drawing",l.width=i.clientWidth,l.height=i.clientHeight,l.style.position="absolute",i.appendChild(l),new s.default(n,a,l,t,r,o)}},{key:"createMouseEditorManager",value:function(e){return new a.default(e)}},{key:"createTouchEditorManager",value:function(e){var t=new r.default(e);return e.auxMobileMeasureTool=t.auxMobileMeasureTool,t}}]),e}();l.sdkUrl="js/",l.drawingIDs=[],t.default=l},function(e,t,i){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=n(i(27)),r=n(i(6)),a=n(i(7)),l=function(){function e(t,i,n,o,a,l){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),console.log(a.GetId());var h=document.getElementById(o);this.width=h.clientWidth,this.height=h.clientHeight,this.viewer=a,this.translateX=null!=a.translateX?a.translateX:0,this.translateY=null!=a.translateY?a.translateY:0,this.divId=o,this.dom=h,this.dc=s.default.create(t,i,n),this.ratio=1.1,this.drawHandle=null,this.scale=1,this.snapDistance=5,this.hover=!0,this.bindRendering=this.rendering.bind(this),this.butterfly=l,this.opacity={0:1},this.customManager=new r.default,this.onViewChanges=function(){};var c=this;this.dc.overlayDrawers.custom=function(e){c.customManager.draw(c,e)},this.sendHighlightMsg=!0,this.url=null!=a.url?a.url+"/":null,this.model={Url:null!=a.url?a.url+"/":null}}return o(e,[{key:"getUrl",value:function(){return this.url}},{key:"setUrl",value:function(e){this.url=e}},{key:"setZoomRatio",value:function(e){this.ratio=e}},{key:"getZoomRatio",value:function(){return this.ratio}},{key:"getViewScale",value:function(e){return this.scale}},{key:"setViewScale",value:function(e){this.scale=e}},{key:"setSnapDistance",value:function(e){this.snapDistance=e}},{key:"snapshot",value:function(e){var t=this.dc.canvasMain,i=(this.dc.canvasOverlay,this.getDivId()),n=document.getElementById(i),o=document.createElement("canvas");o.width=n.clientWidth,o.height=n.clientHeight;var s=o.getContext("2d");return s.beginPath(),s.fillStyle=e||t.style.background,s.fillRect(0,0,o.width,o.height),s.drawImage(t,0,0),o.toDataURL()}},{key:"snapshotPure",value:function(){var e=this.dc.canvasMain,t=(this.dc.canvasOverlay,this.getDivId()),i=document.getElementById(t),n=document.createElement("canvas");n.width=i.clientWidth,n.height=i.clientHeight;var o=n.getContext("2d");return o.beginPath(),o.drawImage(e,0,0),n}},{key:"setBackgroundColor",value:function(e){this.dc.setBackgroundColor(e)}},{key:"showFilledFace",value:function(e){this.viewer.FilledFace=e}},{key:"isShowFilledFace",value:function(){return this.viewer.FilledFace}},{key:"setModel",value:function(e){var t;if(console.error("abondon! DON't use this function"),this.viewer.SetModel(e),this.dc.setResourceUrl(e.Url),this.viewer.UpdateVisibleSettings(),null!=e.indexJson.sealImages)for(t=0;t<e.indexJson.sealImages.length;++t){var i=e.indexJson.sealImages[t],n=i.path.split("\\"),o=n[n.length-1];this.viewer.AddSealImage(o,parseFloat(i.x),parseFloat(i.y),parseFloat(i.width),parseFloat(i.height))}}},{key:"rendering",value:function(){this.viewer.Draw(),this.rendering(),this.updateOverlays()}},{key:"getDivId",value:function(){return this.divId}},{key:"getModel",value:function(){return console.log("carefully to use getModel()"),this.model}},{key:"getViewAngle",value:function(){return this.viewer.GetViewAngle()}},{key:"setViewAngle",value:function(e){this.viewer.SetViewAngle(e)}},{key:"getLayers",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetLayerIds(e),n=0,o=i.size();n<o;++n){var s=i.at(n),r=this.viewer.GetLayer(s,e);null!=r?t.push({id:r.id,name:r.name,color:r.color,visible:r.visible}):console.log("Layer not found!"+s)}return t}},{key:"changeLayers",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=0;i<e.length;++i){var n=e[i];n.visible?this.viewer.ShowByLayerId(n.id,t):this.viewer.HideByLayerId(n.id,t)}}},{key:"getLayouts",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetLayoutIds(e),n=this.viewer.GetLayoutNames(e),o=0,s=i.size();o<s;++o){var r=i.at(o);t.push({id:r,name:n.at(o)})}return t}},{key:"activeLayoutById",value:function(e){this.viewer.ActiveLayout(e),this.update()}},{key:"getActiveLayoutId",value:function(){return this.viewer.GetActiveLayoutId()}},{key:"isModelView",value:function(){return 0==this.getActiveLayoutId()}},{key:"updateOverlays",value:function(){this.dc.drawingOverlay(this.width,this.height,this)}},{key:"update",value:function(e){1==e&&this.onViewChanges(),this.viewer.RequestDraw();var t=this;null!==t.drawHandle&&cancelAnimationFrame(t.drawHandle),this.minimap&&this.minimap.update(),t.drawHandle=requestAnimationFrame((function e(){t.viewer.Draw()>0?t.drawHandle=requestAnimationFrame(e):(t.drawHandle=null,t.updateOverlays())}))}},{key:"onResize",value:function(){this.resize(this.dom.clientWidth,this.dom.clientHeight)}},{key:"clearAll",value:function(){for(var e=this.viewer.GetDrawingCount(),t=0;t<e;t++)this.viewer.ReleaseModel(t);this.dc.clearAll(this.width,this.height)}},{key:"releaseModel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.viewer.ReleaseModel(e)}},{key:"resize",value:function(e,t){this.width=e||this.dom.clientWidth,this.height=t||this.dom.clientHeight,this.dc.resize(e,t),this.viewer.Resize(e,t),this.update(),this.onViewChanges()}},{key:"zoomToExtent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.2;this.viewer.ZoomToExtent(e),this.onViewChanges()}},{key:"zoomToObject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;("string"==typeof e||e instanceof String)&&(e=parseInt(e)),this.viewer.ZoomToElement(e,t,i),this.onViewChanges()}},{key:"zoomToObjectWithBlock",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;("string"==typeof e||e instanceof String)&&(e=parseInt(e)),("string"==typeof t||t instanceof String)&&(t=parseInt(t)),this.viewer.ZoomToElementWithBlock(e,t,i),this.onViewChanges()}},{key:"getElementsByBoundingBox",value:function(e,t,i){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=this.viewer.GetElementIdsByBoundingBoxMinMax(e,t.min.x,t.min.y,0,t.max.x,t.max.y,0,i,n),s=[],r=0,a=o.size();r<a;++r){var l=o.at(r);s.push(l)}return s}},{key:"getAllElementsByBoundingBox",value:function(e,t,i,n){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=this.viewer.GetAllElementIdsByBoundingBoxMinMax(e,t.min.x,t.min.y,t.min.z,t.max.x,t.max.y,t.max.z,i,!n,o),r=[],a=0,l=s.size();a<l;++a){var h=s.at(a);r.push(h)}return r}},{key:"selectElementsByBoundingBox",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.viewer.SelectElementIdsByBoundingBoxMinMax(e,t.min.x,t.min.y,0,t.max.x,t.max.y,0,i,n)}},{key:"removeSelectElementIdsByBoundingBox",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.viewer.RemoveSelectElementIdsByBoundingBoxMinMax(e,t.min.x,t.min.y,0,t.max.x,t.max.y,0,i,n)}},{key:"zoomToWorldBox",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;this.viewer.ZoomToWorldBoxMinMax(e[0],e[1],e[2],t[0],t[1],t[2],i)}},{key:"setStartPoint",value:function(e,t){this.startX=e,this.startY=t}},{key:"hideAllElements",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.viewer.HideAllElements(e)}},{key:"zoom",value:function(e,t,i,n){this.viewer.ZoomToRect(e,t,i,n),this.update(!0),this.onViewChanges()}},{key:"panTo",value:function(e,t){return this.startX&&this.startY?(this.offsetX=e-this.startX,this.offsetY=t-this.startY,(0!=this.offsetX||0!=this.offsetY)&&(this.viewer.Pan(this.offsetX,this.offsetY),this.update(),this.startX=e,this.startY=t,this.onViewChanges(),!0)):(this.startX=e,this.startY=t,!1)}},{key:"zoomPan",value:function(e,t,i){this.offsetX=(t||this.width/2)-this.width/2,this.offsetY=(i||this.height/2)-this.height/2,this.viewer.ZoomPan(this.offsetX,this.offsetY,e),this.update(),this.onViewChanges()}},{key:"preSelect",value:function(e,t,i,n){return i?this.viewer.PreSelect(this.startX,this.startY,e,t,n):this.viewer.PreSelect(e,t,e,t,n)}},{key:"select",value:function(){this.viewer.Select()}},{key:"getSelectedIds",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetSelection(e),n=0,o=i.size();n<o;++n)t.push(i.at(n));return t}},{key:"getHighlightIds",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetHighlightIds(e),n=0,o=i.size();n<o;++n)t.push(i.at(n));return t}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.viewer.ClearSelection(e),this.hover||this.viewer.ClearHighlight(e)}},{key:"clearHighlight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.viewer.ClearHighlight(e)}},{key:"selectByIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n<o;++n)i.push_back(parseInt(e[n]));this.viewer.SelectIds(i,t)}},{key:"highlightById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.viewer.HighlightId(parseInt(e),t)}},{key:"highlightByIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.viewer.HighlightIds(e,t)}},{key:"removeSelectId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.viewer.RemoveSelectId(e,t)}},{key:"getObjectBoundingBox",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=this.viewer.GetObjectBoundingBox(e,t),n=i.GetMinPt(),o=i.GetMaxPt();return[[n.x+this.translateX,n.y+this.translateY,n.z],[o.x+this.translateX,o.y+this.translateY,o.z]]}},{key:"toViewportBoundingBox",value:function(e,t,i){var n=this.viewer.ToViewportBoxMinMax(e[0],e[1],e[2],t[0],t[1],t[2],i),o=n.GetMinPt(),s=n.GetMaxPt();return[[o.x+this.translateX,o.y+this.translateY,o.z],[s.x+this.translateX,s.y+this.translateY,s.z]]}},{key:"getViewportBBox",value:function(e){var t=this.viewer.GetViewportBBox(e),i=t.GetMinPt(),n=t.GetMaxPt();return{min:[i.x,i.y],max:[n.x,n.y]}}},{key:"enableHover",value:function(e){this.hover=e}},{key:"normalizePt",value:function(e){return e.constructor==Array?null==e[2]?{x:e[0],y:e[1]}:{x:e[0],y:e[1],z:e[2]}:null!=e.x&&null!=e.y?e:null}},{key:"toWorldPoint",value:function(e){var t=this.normalizePt(e),i=this.viewer.ToWorldPointXY(t.x,t.y);return[i.x+this.translateX,i.y+this.translateY]}},{key:"toScreenPoint",value:function(e){var t=this.normalizePt(e);t.x=t.x-this.translateX,t.y=t.y-this.translateY;var i=this.viewer.ToScreenPointXY(t.x,t.y);return[i.x,i.y]}},{key:"toViewportScreenPoint",value:function(e){var t=this.normalizePt(e);t.x=t.x-this.translateX,t.y=t.y-this.translateY;var i=this.viewer.ToViewportScreenPointXY(t.x,t.y);return[i.x,i.y,i.z]}},{key:"toModelWorld",value:function(e){var t=this.normalizePt(e),i=this.viewer.ToModelWorldPointXY(t.x,t.y);return[i.x+this.translateX,i.y+this.translateY,i.z]}},{key:"snapToPoint",value:function(e,t,i){null==i&&(i=this.snapDistance);var n=this.viewer.SnapToPoint(e,t,i),o=[n.snapPoint.x+this.translateX,n.snapPoint.y+this.translateY,null!=n.snapPoint.z?n.snapPoint.z:-1],s=["None","Vertex","PointOnLine","Inner","PointInText","FootPoint","MiddlePoint","EndPoint","Intersection"],r=n.snapID,a=n.snapType;return{GetPoint:function(){return o},GetID:function(){return r},GetSnapType:function(){return a},GetSnapTypeName:function(){return n.snapType<s.length?s[a]:s[0]}}}},{key:"snapToPoint2",value:function(e,t,i,n,o){null==o&&(o=this.snapDistance);var s=this.viewer.SnapToPoint2(e,t,i,n,o),r={x:s.snapPoint.x+this.translateX,y:s.snapPoint.y+this.translateY,z:null!=s.snapPoint.z?s.snapPoint.z:-1},a=["None","Vertex","PointOnLine","Inner","PointInText","FootPoint","MiddlePoint","EndPoint","Intersection"],l=s.snapID,h=s.snapType;return{GetPoint:function(){return r},GetID:function(){return l},GetSnapType:function(){return h},GetSnapTypeName:function(){return s.snapType<a.length?a[s.snapType]:a[0]}}}},{key:"getZoomFactor",value:function(){var e=this.viewer.GetWorldSize();return this.viewer.GetWorldScale()/Math.min(1/e.x,1/e.y)}},{key:"getState",value:function(){var e={ver:1,WorldScale:this.viewer.GetWorldScale(),ViewAngle:this.viewer.GetViewAngle(),ViewCenter:{x:this.viewer.GetViewCenter().x,y:this.viewer.GetViewCenter().y},ZoomFactor:this.getZoomFactor()};return JSON.stringify(e)}},{key:"setState",value:function(e){var t,i=JSON.parse(e);return 1===i.ver&&(this.viewer.SetWorldScale(i.WorldScale),this.viewer.SetViewAngle(i.ViewAngle),t=i.ViewCenter instanceof Array?{x:i.ViewCenter[0],y:i.ViewCenter[1]}:{x:i.ViewCenter.x,y:i.ViewCenter.y},this.viewer.SetViewCenter(t.x,t.y),this.viewer.UpdateViewMatrix(),!0)}},{key:"showElementBox",value:function(e){null!=e&&e>0&&this.viewer.ShowElementBox(e)}},{key:"selectExistValue",value:function(e,t,i){if(e){if(i%2==1)return e.x;if(i%2==0)return e.y}if(!e)return t[Math.floor(i/3)][i%2==0?1:0]}},{key:"showElementBoxByBBox",value:function(e,t){e&&this.customManager.add([this.selectExistValue(e.min,e,1),this.selectExistValue(e.min,e,2)],[this.selectExistValue(e.max,e,3),this.selectExistValue(e.max,e,4)],t)}},{key:"setElementBoxColor",value:function(e,t,i,n){this.customManager.setColor(e,t,i,n)}},{key:"getElementBoxColor",value:function(){return this.customManager.getColor()}},{key:"getElementBoxStyle",value:function(){return this.customManager.getStyle()}},{key:"setElementBoxStyle",value:function(e){this.customManager.setStyle(e)}},{key:"hideElementBox",value:function(e){null!=e&&e>0&&this.viewer.HideElementBox(e)}},{key:"clearElementBox",value:function(){this.viewer.ClearElementBox(),this.customManager.clear()}},{key:"getVisibleBoxIds",value:function(){for(var e=[],t=this.viewer.GetVisibleBoxIds(),i=0;i<t.size();++i)e.push(t.get(i));return e}},{key:"enableHighlightEvent",value:function(e){this.sendHighlightMsg=e}},{key:"isHighlightEventEnabled",value:function(){return this.sendHighlightMsg}},{key:"addClickCallback",value:function(e){this.clickCallback=e}},{key:"getClickCallback",value:function(){return this.clickCallback}},{key:"setColorByLayerId",value:function(e,t,i,n,o){for(var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,r=0;r<e.length;r++)this.viewer.SetColorByLayerId(e[r],t,i,n,o,s)}},{key:"resetColorByLayerId",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=0;i<e.length;i++)this.viewer.ResetColorByLayerId(e[i],t)}},{key:"getModelBBox",value:function(){var e=this.viewer.GetModelBBox();return new function(e,t,i,n){this.GetMinPt=function(){return[e.x+i,e.y+n,e.z]},this.GetMaxPt=function(){return[t.x+i,t.y+n,t.z]}}(e.GetMinPt(),e.GetMaxPt(),this.translateX,this.translateY)}},{key:"enableSelectInBlock",value:function(){this.viewer.EnableSelectInBlock()}},{key:"disableSelectInBlock",value:function(){this.viewer.DisableSelectInBlock()}},{key:"canSelectInBlock",value:function(){return this.viewer.CanSelectInBlock()}},{key:"getSelectionWithBlock",value:function(){return this.viewer.GetSelectionWithBlock()}},{key:"GetHighlightIdsWithBlock",value:function(){return this.viewer.GetHighlightIdsWithBlock()}},{key:"highlightIdWithBlock",value:function(e,t){this.viewer.HighlightIdWithBlock(e,t)}},{key:"selectIdWithBlock",value:function(e,t){this.viewer.SelectIdWithBlock(e,t)}},{key:"createMinimap",value:function(e,t,i,n,o){0!=this.isModelView()?null==this.minimap&&(this.minimap=new a.default(e,t,i,n,o),this.minimap.setDrawingImpl(this),this.minimap.initialize()):console.warn("Only model view support minimap.")}},{key:"enableMinimap",value:function(e){0!=this.isModelView()?this.minimap&&this.minimap.enableMiniMap(e):console.warn("Only model view support minimap.")}},{key:"setMinimapBoundingBox",value:function(e){0!=this.isModelView()?this.minimap&&this.minimap.setDrawingContentsBbox(e):console.warn("Only model view support minimap.")}},{key:"setMinimapOffset",value:function(e){this.minimap.setOffset(e)}},{key:"hasMinimap",value:function(){return 0==this.isModelView()?void console.warn("Only model view support minimap."):null!=this.minimap}},{key:"setGlobalColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.dc.printMode[t]==this.dc.Custom&&(this.dc.customColor[t]=e),this.dc.globalColor[t]=e,this.setElementColor(e.red,e.green,e.blue,e.alpha,t)}},{key:"setGlobalOpacity",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;
//!!
this.opacity[t]=e,this.viewer.SetGlobalOpacity(e,t)}},{key:"getGlobalOpacity",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.opacity[e]||1}},{key:"restoreGlobalColor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.dc.printMode[e]==this.dc.Custom?this.setGlobalColor({red:128,green:128,blue:128,alpha:1},e):this.dc.printMode[e]==this.dc.Black?this.setGlobalColor({red:0,green:0,blue:0,alpha:1},e):this.viewer.RestoreGlobalColor(e)}},{key:"getGlobalColor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.dc.globalColor[e]||{red:128,green:128,blue:128,alpha:1}}},{key:"setPrintMode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.dc.setPrintMode(e,t),"Black"==e?(this.setGlobalColor({red:0,green:0,blue:0,alpha:1},t),this.viewer.RestoreOverrideElementsColor(t)):"Custom"==e?(this.setGlobalColor(this.dc.customColor[t]||this.dc.customColor[0],t),this.viewer.RestoreOverrideElementsColor(t)):(this.viewer.RestoreGlobalColor(t),this.viewer.RestoreOverrideElementsColor(t))}},{key:"overrideElementsColorById",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=.0039*t.red,o=.0039*t.green,s=.0039*t.blue,r=new this.butterfly.ObjectIDList;r.clear();for(var a=0,l=e.length;a<l;a++)r.push_back(e[a]);this.viewer.OverrideElementsColorById(r,n,o,s,t.alpha,i),this.update()}},{key:"restoreElementsColorById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n<o;n++)i.push_back(e[n]);this.viewer.RestoreElementsColorById(i,t),this.update()}},{key:"setClearColor",value:function(e,t,i,n){var o=.0039*e,s=.0039*t,r=.0039*i;this.viewer.SetClearColor(o,s,r,n)}},{key:"setElementColor",value:function(e,t,i,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=.0039*e,r=.0039*t,a=.0039*i;this.viewer.SetGlobalColor(s,r,a,n,o)}},{key:"alignDrawing",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.viewer.AlignDrawing(e[0],e[1],t[0],t[1],i)}},{key:"getAlignTranslate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.viewer.GetAlignTranslate(e);return[t.x,t.y]}},{key:"scaleDrawing",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.viewer.AlignDrawingWithScale(null==e.x?e[0]:e.x,null==e.y?e[1]:e.y,t,i),this.update()}},{key:"getAlignScale",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.viewer.GetAlignScale(e)}},{key:"getAlignState",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.viewer.GetAlignMatrixCol(0,e),i={x:t.x,y:t.y,z:t.z,w:t.w},n=this.viewer.GetAlignMatrixCol(1,e),o={x:n.x,y:n.y,z:n.z,w:n.w},s=this.viewer.GetAlignMatrixCol(2,e),r={x:s.x,y:s.y,z:s.z,w:s.w},a=this.viewer.GetAlignMatrixCol(3,e),l={x:a.x,y:a.y,z:a.z,w:a.w},h={ver:1,AlignMatrixCol1:[i.x,i.y,i.z,i.w],AlignMatrixCol2:[o.x,o.y,o.z,o.w],AlignMatrixCol3:[r.x,r.y,r.z,r.w],AlignMatrixCol4:[l.x,l.y,l.z,l.w]};return JSON.stringify(h)}},{key:"setAlignState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=JSON.parse(e);return 1===i.ver&&(null!=i.AlignMatrixCol1&&null!=i.AlignMatrixCol1&&(this.viewer.SetAlignMatrixCol(0,i.AlignMatrixCol1[0],i.AlignMatrixCol1[1],i.AlignMatrixCol1[2],i.AlignMatrixCol1[3],t),this.viewer.SetAlignMatrixCol(1,i.AlignMatrixCol2[0],i.AlignMatrixCol2[1],i.AlignMatrixCol2[2],i.AlignMatrixCol2[3],t),this.viewer.SetAlignMatrixCol(2,i.AlignMatrixCol3[0],i.AlignMatrixCol3[1],i.AlignMatrixCol3[2],i.AlignMatrixCol3[3],t),this.viewer.SetAlignMatrixCol(3,i.AlignMatrixCol4[0],i.AlignMatrixCol4[1],i.AlignMatrixCol4[2],i.AlignMatrixCol4[3],t)),this.viewer.UpdateViewMatrix(),!0)}},{key:"setModelTransformation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.viewer.SetAlignMatrixCol(0,e[0],e[1],0,0,t),this.viewer.SetAlignMatrixCol(1,e[4],e[5],0,0,t),this.viewer.SetAlignMatrixCol(2,e[8],e[9],1,0,t),this.viewer.SetAlignMatrixCol(3,e[12],e[13],0,1,t),this.viewer.UpdateViewMatrix()}},{key:"activeDrawing",value:function(e){this.viewer.ActiveDrawing(e)}},{key:"getActiveDrawing",value:function(){return this.viewer.GetActiveDrawingIndex()}},{key:"getDrawingCount",value:function(){return this.viewer.GetDrawingCount()}},{key:"replaceElementColor",value:function(e,t,i,n,o,s){var r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;this.viewer.RaplaceElementColor(e,t,i,n,o,s,r)}},{key:"enableReplaceElementColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.viewer.EnableRaplaceElementColor(e,t)}},{key:"enableViewport",value:function(e){this.viewer.EnaleViewport(e),this.update()}},{key:"getLayerIdFromElementId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.viewer.GetLayerIdFromElementId(e,t)}},{key:"hideElementsById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n<o;n++)i.push_back(e[n]);this.viewer.HideElementsById(i,t)}},{key:"showElementsById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n<o;n++)i.push_back(e[n]);this.viewer.ShowElementsById(i,t)}},{key:"showAllElements",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.viewer.ShowAllElements(e)}},{key:"getCustomManager",value:function(){return this.customManager}},{key:"setSnapMode",value:function(e){this.snapMode=e}},{key:"getSnapMode",value:function(){return this.snapMode}},{key:"setSelectWireframeColor",value:function(e,t,i,n){this.viewer.SetSelectWireframeColor(e,t,i,n)}},{key:"getElementIdsByLayerId",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.viewer.GetElementIdsByLayerId(e,t,i)}}]),e}();t.default=l},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(i(0)),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,[{key:"initialize",value:function(e,t,i){this.canvasMain=e,this.canvasTemp=t,this.canvasOverlay=i,this.ctxMain=this.canvasMain.getContext("2d"),this.ctxTemp=this.canvasTemp.getContext("2d"),this.ctxOverlay=this.canvasOverlay.getContext("2d"),this.inPath=!1,this.fontSize=12,this.colorTable={},this.faceColorTable={},this.globalOpacity=null,this.Normal=0,this.White=1,this.Black=2,this.Gray=3,this.Custom=4,this.printMode={0:this.Normal},this.printColorTable={},this.printFaceColorTable={},this.resUrl="",this.images={},this.ignoreImage=!1,this.targetId=0,this.overlayDrawers={},this.customColor={0:{red:128,green:128,blue:128,alpha:1}},this.globalColor={0:this.customColor[0]}}},{key:"drawingOverlay",value:function(e,t,i){var n=this.ctxOverlay;n.clearRect(0,0,e,t);var o=this.overlayDrawers;for(var s in o)o[s](n);var r=i.mouseEditorMgr.getEditor().auxMobileMeasureTool;r&&r.redraw()}},{key:"setBackgroundColor",value:function(e){this.canvasMain.style.background=e}},{key:"setPrintMode",value:function(e,t){if("Normal"==e)this.printMode[t]=this.Normal;else if("Gray"==e)this.printMode[t]=this.Gray;else if("Black"==e)this.printMode[t]=this.Black;else if("White"==e)this.printMode[t]=this.White;else{if("Custom"!=e)return;this.printMode[t]=this.Custom}}},{key:"setResourceUrl",value:function(e){this.resUrl=e}},{key:"setGlobalOpacity",value:function(e){this.globalOpacity=e}},{key:"getGlobalOpacity",value:function(){return this.globalOpacity}},{key:"restoreGlobalOpacity",value:function(){this.globalOpacity=null}},{key:"getHexColor",value:function(e){var t=null===this.globalOpacity?1:this.globalOpacity;if(this.printMode[0]==this.Custom&&null!=this.customColor[0].red)return null==this.globalOpacity&&1!=this.customColor[0].alpha&&(t=this.customColor[0].alpha),"rgba("+this.customColor[0].red+","+this.customColor[0].green+","+this.customColor[0].blue+","+t+")";var i=e>>16,n=e>>8&255,o=255&e;if(2==this.printMode[0]||1==this.printMode[0]&&255==i&&255==n&&255==o)return"rgba(0,0,0,"+t+")";if(3==this.printMode[0]){var s=255==i&&255==n&&255==o?0:.299*i+.587*n+.114*o;return this.printColorTable[e]="rgba("+s+","+s+","+s+","+t+")",this.printColorTable[e]}return this.colorTable[e]="rgba("+o+","+n+","+i+","+t+")",this.colorTable[e]}},{key:"getFaceColor",value:function(e){var t=null===this.globalOpacity?.9:this.globalOpacity;if(this.printMode[0]==this.Custom&&null!=this.customColor[0].red)return null==this.globalOpacity&&1!=this.customColor[0].alpha&&(t=this.customColor[0].alpha),"rgba("+this.customColor[0].red+","+this.customColor[0].green+","+this.customColor[0].blue+","+t+")";var i=e>>16,n=e>>8&255,o=255&e;if(2==this.printMode[0]||1==this.printMode[0]&&255==i&&255==n&&255==o)return"rgba(0,0,0,"+t+")";if(3==this.printMode[0]){var s=255==i&&255==n&&255==o?0:.299*i+.587*n+.114*o;return this.printFaceColorTable[e]="rgba("+s+","+s+","+s+","+t+")",this.printFaceColorTable[e]}return this.faceColorTable[e]="rgba("+o+","+n+","+i+","+t+")",this.faceColorTable[e]}},{key:"resize",value:function(e,t){this.canvasMain.setAttribute("width",e),this.canvasMain.setAttribute("height",t),this.canvasTemp.setAttribute("width",e),this.canvasTemp.setAttribute("height",t),this.canvasOverlay.setAttribute("width",e),this.canvasOverlay.setAttribute("height",t)}},{key:"clearAll",value:function(e,t){this.ctxTemp.clearRect(0,0,e,t),this.ctxOverlay.clearRect(0,0,e,t)}},{key:"SetTarget",value:function(e){0==e?this.ctx=this.ctxMain:(this.ctx=this.ctxTemp,this.ctx.strokeStyle="#ff0000"),this.targetId=e}},{key:"BeginDraw",value:function(e,t){this.ctx.clearRect(t[0],t[1],t[2],t[3])}},{key:"EndDraw",value:function(e){}},{key:"BeginPath",value:function(){this.inPath=!0,this.ctx.beginPath()}},{key:"EndPath",value:function(e,t){this.inPath=!1,e&&(this.ctx.fillStyle=this.getFaceColor(t),this.ctx.closePath(),this.ctx.fill()),this.ctx.stroke()}},{key:"BeginClip",value:function(e){e&&(this.ctx.save(),this.ctx.clip())}},{key:"EndClip",value:function(e){e&&this.ctx.restore()}},{key:"SetLineColor",value:function(e){var t=this.getHexColor(e);this.ctx.strokeStyle=t,this.ctx.fillStyle=t}},{key:"SetLineWidth",value:function(e){this.ctx.lineWidth=e}},{key:"SetLineDash",value:function(e,t){if(0!=e)if(1!=e){for(var i=[],n=0,o=t.size();n<o;++n)i.push(t.get(n));this.ctx.setLineDash(i)}else this.ctx.setLineDash([10]);else this.ctx.setLineDash([])}},{key:"SetFont",value:function(e){this.fontSize=e,this.ctx.font=this.fontSize+"px 仿宋"}},{key:"DrawPoint",value:function(e,t,i){}},{key:"DrawLine",value:function(e,t){if(this.inPath)this.ctx.moveTo(e[0],e[1]),this.ctx.lineTo(t[0],t[1]);else{for(var i=this.ctx.getLineDash(),n=0,o=0;o<i.length;++o)n+=i[o];this.ctx.beginPath(),this.ctx.moveTo(e[0],e[1]),(e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])<n*n&&this.ctx.setLineDash([]),this.ctx.lineTo(t[0],t[1]),this.ctx.stroke(),this.ctx.setLineDash(i)}}},{key:"DrawArc",value:function(e,t,i,n){this.inPath?this.ctx.arc(e[0],e[1],t,-i,-n,!0):(this.ctx.beginPath(),this.ctx.arc(e[0],e[1],t,-i,-n,!0),this.ctx.stroke())}},{key:"DrawRec",value:function(e,t){this.inPath?this.ctx.rect(e[0],e[1],t[0]-e[0],t[1]-e[1]):(this.ctx.beginPath(),this.ctx.rect(e[0],e[1],t[0]-e[0],t[1]-e[1]),this.ctx.stroke())}},{key:"DrawCloudRec",value:function(e,t,i){var n=e,o=t;i=i||this.ctx,n=[n[0]+18/3.5,n[1]+18/3.5];var s=(o=[o[0]-18/3.5,o[1]-18/3.5])[1]-n[1],r=o[0]-n[0],a=Math.abs(r),l=Math.abs(s),h=parseInt(a/18),c=parseInt(l/18),d=0==h?a:a/h,u=0==c?l:l/c;i.beginPath(),this.drawSide("orientation",d,a,n[0],n[1],i),this.drawSide("orientation",d,a,n[0]+a,n[1]+l,i,!0),this.drawSide("portrait",u,l,n[0]+a,n[1],i),this.drawSide("portrait",u,l,n[0],n[1]+l,i,!0),i.stroke()}},{key:"drawSide",value:function(e,t,i,n,o,s,r){var a=0,l=0,h=i/t,c=void 0,d=n,u=o;"orientation"==e?a=t:l=t;for(var g=0;g<h;g++){s.moveTo(n,o),c=r?[n-a,o-l]:[n+a,o+l],a&&Math.abs(c[0]-d)>i?c[0]=r?d-i:d+i:l&&Math.abs(c[1]-u)>i&&(c[1]=r?u-i:u+i);var p=this.getControlPt([n,o],c);s.quadraticCurveTo(p[0],p[1],c[0],c[1]),n=c[0],o=c[1]}}},{key:"getControlPt",value:function(e,t,i){var n=[(e[0]+t[0])/2,(e[1]+t[1])/2],s=.4*o.default.distanceByArr(e,t),r=[t[1]-e[1],e[0]-t[0]];return r=o.default.normalize(r),[n[0]+r[0]*s,n[1]+r[1]*s]}},{key:"DrawPolyline",value:function(e){var t=e.size();if(!(t<1))if(this.inPath){this.pt=e.get(0),this.ctx.moveTo(this.pt[0],this.pt[1]);for(var i=1;i<t;++i)this.pt=e.get(i),this.ctx.lineTo(this.pt[0],this.pt[1])}else{for(var n=this.ctx.getLineDash(),o=0,s=0;s<n.length;++s)o+=n[s];this.ctx.beginPath(),this.pt=e.get(0),this.ctx.moveTo(this.pt[0],this.pt[1]);for(var r=1;r<t;++r){(this.pt[0]-e.get(r)[0])*(this.pt[0]-e.get(r)[0])+(this.pt[1]-e.get(r)[1])*(this.pt[1]-e.get(r)[1])<o*o?this.ctx.setLineDash([]):this.ctx.setLineDash(n),this.pt=e.get(r),this.ctx.lineTo(this.pt[0],this.pt[1]),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.moveTo(this.pt[0],this.pt[1])}this.ctx.setLineDash(n)}}},{key:"DrawText",value:function(e,t){this.ctx.fillText(e,t[0],t[1])}},{key:"DrawTextW",value:function(e,t,i){0!=i?(this.ctx.save(),this.ctx.translate(t[0],t[1]),this.ctx.rotate(i),this.ctx.fillText(e,0,0),this.ctx.restore()):this.ctx.fillText(e,t[0],t[1])}},{key:"DrawImageImpl",value:function(e,t,i,n,o,s,r){function a(t,i,n,o,s,r){0==r?e.drawImage(t,i,n,o,s):(e.save(),e.translate(i,n+s),e.rotate(r),e.drawImage(t,0,-s,o,s),e.restore())}var l=this,h=l.images[t];if(l.ignoreImage)return!1;void 0===h?((h=new Image).onload=function(){a(h,i,n,o,s,r),l.images[t]=h},h.src=t):a(h,i,n,o,s,r)}},{key:"DrawImage",value:function(e,t,i,n,o,s){this.DrawImageImpl(this.ctx,this.resUrl+"image/"+e,t,i,n,o,s)}}],[{key:"create",value:function(t,i,n){var o=new e;return o.initialize(t,i,n),o}}]),e}();t.default=s},function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.revitIds={}}return n(e,[{key:"initialize",value:function(e,t){function i(e){return new Promise((function(t,i){var n=new XMLHttpRequest;n.open("GET",e),n.onload=function(){200==n.status||0==n.status?t(JSON.parse(n.response)):i(n.statusText)},n.send()}))}var n=this;n.revitIds={},n.linkRevitIds={},n.revitToCad={};var o,s=t||e.getModel().Url,r=s+"index.json",a=s+"revitIds.json",l=!1,h=".gz";i(r).then((function(e){return o=e,0!=e.metadata.gz&&"false"!=e.metadata.gz||(h=""),i(a+=h)}),(function(e){console.warn(e)})).then((function(e){if(n.revitIds=e,n.callback&&n.callback(),o.metadata.hasOwnProperty("links")&&""!=o.metadata.links)return l=!0,i(r=s+o.metadata.links)})).then((function(t){if(0!=l){n.linkRevitIds=t,t&&e.enableSelectInBlock();var o=[],r=[];for(var a in n.linkRevitIds)if(0!=a){var c=i(s+"links/"+a+".json"+h);r.push(c),o.push(a)}Promise.all(r).then((function(e){for(var t=0;t<e.length;t++){var i=e[t],s={};for(var r in i)n.revitIds[r]=i[r],s.hasOwnProperty(i[r])||(s[i[r]]=[]),s[i[r]].push(r);var a=o[t];n.revitToCad[n.linkRevitIds[a]]=s}}))}}),(function(e){console.warn(e)}))}},{key:"toRevitId",value:function(e){return this.revitIds[e]}},{key:"toLinkRevitId",value:function(e,t){return 0==e||null==this.linkRevitIds?this.toRevitId(t):this.linkRevitIds.hasOwnProperty(e)?{fileId:this.linkRevitIds[e],revitId:this.toRevitId(t)}:this.toRevitId(e)}},{key:"fromRevitId",value:function(e){var t=this.revitIds;for(var i in t)if(t[i]==e)return i}},{key:"fromLinkRevitId",value:function(e,t){if(0==e||null==this.linkRevitIds||""==e)return this.fromRevitId(t);var i=0;for(var n in this.linkRevitIds)this.linkRevitIds[n]==e&&(i=n);var o=this.revitToCad[e];return o?{blockId:i,ids:o[t]}:null}}]),e}();t.default=o}]),window.Glodon=e}();