!function(){"use strict";var e=window.Glodon=window.Glodon||{};e.Version="2024-10-16-16-6",function(){function t(e,t){let i=t.split("."),n=e,o=i.length;for(let e=0;ei;var r=navigator.userAgent,a=/(?:Android)/.test(r),l=/(?:Firefox)/.test(r),h=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;o=/(?:iPad|PlayBook)/.test(r)||a&&!/(?:Mobile)/.test(r)||l&&/(?:Tablet)/.test(r)||h;var c=Math.min(e,i);e=c<=320?320:c>320&&c<=414?c:c>414&&c<1024?420:450,s=e/10+"px"}d();i.getIsHorizontal=()=>n,i.getIsTablet=()=>o,i.getFontSize=()=>s}(window);class t{constructor(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}clone(){return new this.constructor(this.x,this.y,this.z)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}distanceToSquared(e){var t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}}class i{constructor(e,i){this.min=e||new t(1/0,1/0,1/0),this.max=i||new t(-1/0,-1/0,-1/0)}getSize(){return new t(this.max.x-this.min.x,this.max.y-this.min.y,this.max.z-this.min.z)}setFromCenterAndSize(e,i){let n=new t(i.x,i.y).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}getCenter(){return new t(this.min.x+this.max.x,this.min.y+this.max.y,this.min.z+this.max.z).multiplyScalar(.5)}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.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{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{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;i1){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;tthis.max.x||e.max.ythis.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{i.success&&i.success(e.responseText,e.responseXML)},o=e=>{i.failure&&i.failure(e)},s=(e,t)=>{var n;(n=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")).onreadystatechange=function(){if(4==n.readyState){var i=n.status;if(i>=200&&i<300||304==i||0===i&&"file:"===window.location.protocol){let{responseText:t,responseXML:i}=n;e({responseText:t,responseXML:i})}else t(i)}},n.open(i.type,i.url,i.async);for(let e in i.headers)n.setRequestHeader(e,i.headers[e]);n.send(i.data)};t?CLOUD.Storage.IndexedDBHelper.loadWithStorage("InfoData",i.url,(()=>new Promise(s)),n,o):s(n,o)},o=function(e,t,n){if(void 0===i[e]){let o=document.createElement("script");o.type="text/javascript",o.src=e,document.head.appendChild(o),i[e]={callbacks:[],failCallbacks:[]},i[e].callbacks.push(t),i[e].failCallbacks.push(n),o.readyState?o.onreadystatechange=function(){"loaded"==o.readyState||"complete"==o.readyState?(o.onreadystatechange=null,i[e].callbacks.map((e=>{e&&e()})),i[e]=!0):"uninitialized"==o.readyState&&(o.onreadystatechange=null,i[e].failCallbacks.map((e=>{e&&e()})),i[e]=!1)}:(o.onload=function(){i[e].callbacks.map((e=>{e&&e()})),i[e]=!0},o.onerror=function(){i[e].failCallbacks.map((e=>{e&&e()})),i[e]=!1})}else!0===i[e]?t&&t():!1===i[e]?n&&n():(i[e].callbacks.push(t),i[e].failCallbacks.push(n))},s=function(e,t,i){let o;return o="string"==typeof e?{url:e,status:t}:e,new Promise((function(e,s){n(Object.assign({},o,{success:function(i){try{var n=JSON.parse(i)}catch(t){return e(i)}"success"==n.code||"noCode"==o.status||"bimfaceservice-0000"==n.code?e("noCode"==t?n:n.data):s(`requestError,dataCode:${n.code}, dataMessage:${n.message}`)},failure:e=>{s(e)}}),i)}))},r={singleModel:"fileId",integrateModel:"integrateId",compareModel:"compareId"};t.ajax=n,t.promiseJSONRequest=s,t.getScript=o,t.getScripts=function(e,t){e.length<=1?o(e.shift(),t):Promise.all(e.map((e=>new Promise(((t,i)=>{o(e,(()=>{t()}))}))))).then((()=>{t&&t()}))},t.promiseJsonFunction=function(e){if("Fast"===(e.loadMode||"Fast"))return s(e.url,e.status,e.enableStorage);{let{APIHost:t,path:i,fileId:n,viewToken:o,modelType:a}=e;return s(`${t}/data/v1/databag/resource-stream?${r[a]||"fileId"}=${n}&view_token=${o}&path=${i}`,e.status,e.enableStorage)}},t.getUrl=function(e){if("Strict"==(e.loadMode||"Fast")){let{APIHost:t,path:i,fileId:n,viewToken:o,modelType:s,workerType:a}=e;return`${t}/data/v1/databag/resource-stream?${a?"workerType="+a+"&":""}${r[s]||"fileId"}=${n}&view_token=${o}&path=${i}`}return e.url}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.FullScreen");t.fullScreen=function(e){if(!e)return!1;e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()},t.exitFullScreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()},t.onFullScreenChanged=function(e){var t=function(){e&&e()};document.onfullscreenchange=t,"onwebkitfullscreenchange"in document?document.onwebkitfullscreenchange=t:document.documentElement.onwebkitfullscreenchange=t,document.onmozfullscreenchange=t,document.onmsfullscreenchange=t},t.isFullScreen=function(){return document.webkitIsFullScreen||!!document.mozFullScreenElement||!!document.msFullScreenElement||!1}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.ClientHelper"),i=null;if(t.getIsDesktop)return;var n=function(e,t,i){i=i||"asc";var n=!1;return t?t.indexOf(".")>-1&&(n=!0):t="name",e=e.sort((function(e,o){if(n){var s=r(e,t),a=r(o,t);return"asc"==i?s.localeCompare(a):a.localeCompare(s)}return"asc"==i?e[t].localeCompare(o[t]):o[t].localeCompare(e[t])})),s(e,t,n)};var o=function(e,t){return function(i,n){var o,s;t?(o=r(i,e),s=r(n,e)):(o=i[e],s=n[e]);var a,l,h=1,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 l1;return!(/(?:iPhone)/.test(e)&&!r||o||n||r||a)},t.getIsMac=()=>/macintosh|mac os x/i.test(navigator.userAgent),t.getIsChrome=()=>/(?:Chrome|CriOS)/.test(navigator.userAgent),t.setNavigatorType=function(e){i=e},t.getIsIphone=function(){var e=navigator.userAgent;return/(?:iPhone)/.test(e)},t.getIsTablet=function(){var e=navigator.userAgent,t=/(?:Android)/.test(e),i=/(?:Firefox)/.test(e),n=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;return/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||i&&/(?:Tablet)/.test(e)||n},t.getDeviceType=function(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),i=/(?:SymbianOS)/.test(e)||t,n=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),s=/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),r=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1,a=/(?:iPhone)/.test(e)&&!s;return s||r?"PAD":a||n||i?"MOBILE":"PC"},t.getBrowserType=function(){var e=navigator.userAgent,t="";return e.indexOf("Opera")>-1||e.indexOf("OPR")>-1?t="Opera":e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1||window.ActiveXObject||"ActiveXObject"in window?t="IE":e.indexOf("Edge")>-1?t="Edge":e.indexOf("Firefox")>-1?t="Firefox":e.indexOf("Safari")>-1&&-1==e.indexOf("Chrome")?t="Safari":e.indexOf("Safari")>-1&&e.indexOf("Chrome")>-1&&(t="Chrome"),t},t.getBrowserVersion=function(){var e,t={},i=navigator.userAgent.toLowerCase();return(e=i.match(/rv:([\d.]+)\) like gecko/))||(e=i.match(/msie ([\d\.]+)/))?t.ie=e[1]:(e=i.match(/edge\/([\d\.]+)/))?t.edge=e[1]:(e=i.match(/firefox\/([\d\.]+)/))?t.firefox=e[1]:(e=i.match(/(?:opera|opr).([\d\.]+)/))?t.opera=e[1]:(e=i.match(/chrome\/([\d\.]+)/))?t.chrome=e[1]:(e=i.match(/version\/([\d\.]+).*safari/))&&(t.safari=e[1]),t.ie?t.ie:t.edge?t.edge:t.firefox?t.firefox:t.chrome?t.chrome:t.opera?t.opera:t.safari?t.safari:"Unkonwn"},t.formatTime=(e="",t=(new Date).getTime())=>{let i,n,o;e=e||"YYYY-mm-dd HH:MM:SS",n=10==t.toString().length?new Date(1e3*parseInt(t)):new Date(parseInt(t));const s={Y:n.getFullYear().toString(),m:(n.getMonth()+1).toString(),d:n.getDate().toString(),H:n.getHours().toString(),M:n.getMinutes().toString(),S:n.getSeconds().toString()};for(var r in s)i=new RegExp("("+r+"+)").exec(e),i&&(o=1==i[1].length?s[r]:s[r].padStart(i[1].length,"0"),e=e.replace(i[1],o));return e},t.getDesktopType=function(){var e=navigator.userAgent.toLowerCase(),t="",i="";return e.indexOf("win")>-1?(t="Windows",e.indexOf("windows nt 5.0")>-1?t="Windows 2000":e.indexOf("windows nt 5.1")>-1||e.indexOf("windows nt 5.2")>-1?t="Windows XP":e.indexOf("windows nt 6.0")>-1?t="Windows Vista":e.indexOf("windows nt 6.1")>-1||e.indexOf("windows 7")>-1?t="Windows 7":e.indexOf("windows nt 6.2")>-1||e.indexOf("windows 8")>-1?t="Windows 8":e.indexOf("windows nt 6.3")>-1?t="Windows 8.1":(e.indexOf("windows nt 6.2")>-1||e.indexOf("windows nt 10.0")>-1)&&(t="Windows 10"),e.indexOf("win64")>-1?i="win64":e.indexOf("win32")>-1&&(i="win32")):e.indexOf("mac")>-1?t="Mac":e.indexOf("x11")>-1||e.indexOf("unix")>-1||e.indexOf("sunname")>-1||e.indexOf("bsd")>-1?t="Unix":e.indexOf("linux")>-1&&(t="Linux"),{name:t,type:i}},t.getIsIE=function(){return!(!window.ActiveXObject&&!("ActiveXObject"in window))},t.formatURL=function(e){var t=function(e){return e.replace("viewToken.json","").replace(/\.\//g,"/").replace(/\/\//g,"/")};if(e.indexOf("://")>-1){var i=e.split("://");e=i[0]+"://"+t(i[1])}else e="//"===e.slice(0,2)?"//"+t(e.slice(2)):"./"!=e.slice(0,2)?t(e):"."+t(e.slice(1));return e},t.sortByName=n,t.sortByRules=function(e,t,i){i=i||"asc";var n=!1;return t?t.indexOf(".")>-1&&(n=!0):t="name",e=e.sort(o(t,n)),s(e,t,n)},t.PointToLineDistance=function(e,t,i,n,o,s){let r,a,l,h,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(d1e-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 m=(s-n)/o-i,f=-1/m,w=t-e*f;return c=(s-o*m-w)/(f-m),p=f*c+w,[d*Math.sin(l),{x:c,y:p}]}if(n===s?r=i1e-5&&(h=1),r=Math.acos(h),s>n&&(r=2*Math.PI-r)),h=(e-o)/u,h-1>1e-5&&(h=1),a=Math.acos(h),s>t&&(a=2*Math.PI-a),l=a-r,l<0&&(l=-l),l>Math.PI&&(l=2*Math.PI-l),l>Math.PI/2)return[u,{x:o,y:s}];if(i===o)return[u*Math.sin(l),{x:i,y:t}];if(n===s)return[u*Math.sin(l),{x:e,y:n}];let p=0,m=0;const f=(s-n)/o-i,w=-1/f,v=t-e*w;return p=(s-o*f-v)/(w-f),m=w*p+v,[u*Math.sin(l),{x:p,y:m}]},t.isWebGLAvailable=function(){try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},t.isWebGL2Available=function(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},t.sortByGroupName=function(e,t,i,o){let s=((e,t)=>e.reduce(((e,i)=>({...e,[i[t]]:[...e[i[t]]||[],i]})),{}))(e,t),r=[];for(let e in s)r=[...r,...n(s[e],i,o)];return r}}();var s,r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAbCAYAAAH3zbSEAAAAAXNSR0IArs4c6QAAAn5JREFUSA29lr9uGkEQxu8A47MTKSf5j2RbjnDhAAUVVKbhBeiiNHmLPIxbt64i+QF4A3iBpEiUIkWUCEVBcSz/uXy/1S1aH3fxcoKM9LG7szv77c7MzhEEQRAKFWEutXkvCKoMqkmS3Foly+vCa6ugjdwBm907imoo+8QqwjCMavp5axVqzWTUarWuNKg6E/MurJvCS2F+lHR2Q+0XFkSiuU6VjxrRbaHg3OyyIJVut3sj7cHCjBTWOZ+zkzJKrLMa2UnGISvyJtAZy/F4vDDf6/VMUAaaOVyYDYKv6OpsPZ1Ok06nc6Hxs5yFharNfr9/qdmGkOvuIksTBjH/KVpQpJ9MJhF+fCha8ITe2EXcOU/+pdfGhrmQIC8E7mLuDEgzmwrufFGfI99iiIcJNv27FGqeliPuOhwOyekTwZu9KSPSeSAslRg8r7NljbhXLNBOBR/ZZhFOiRW7Tz4Wdo0y6QSmhrArfBd8xKzFcE+M33ws7Box7mN4qmh8sEqfVmXnFTHzjpuzaaWMkbEvbUg4ZjrzG7Uku49Qi2c4x01yH0PK4p013FJIfmWt4jg+H41G76SHpWzlyG5rxnwETqkaVFAeS7vdfi8duX8k8D0r7UfZ5gqbGtKUbKBxQ+CFLlWFtd5LcC+BfCHwQCkJPFDqifuB1rC0wAHwFiFK6KCoyb0fUQgIB8EDqwAeO9D+5MWesEHqQmyLXUv9mUC5XZXA8TzdjPYnt+QfxU6K3yiFVZMSPurljxSG9JjsdWUdYxEeC3VcC0zVVrtugQc+kyzN7M3cW6+iz/7iasJnWGH+n0JmcQJT4vj3t2Yx75Tsperwx9hm2DpuD5l9Gdd/AVIlXMI9fgkPAAAAAElFTkSuQmCC",a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAABBpJREFUWAntVUtLG1EUniRjEo2amKjVxBiFqlAXRUVFEBFKF6KLgii47kIKXVX36rra0lXRnd1IFftYqFAoBFyJ2AdUixqoMU18a3ylSZwk/b6pCRmfP6AZuJlz7znfd8797rkTQUg9KQVSCqQUSClwgwKxWEzV0NBgrq6u/tbf36/m/IZw2cUYxhJD7G0Y9XWEJGlsbKw5Ozv7qlKp7h8eHuoGBgZuLYAxjCWGWHKQ67o8VxISMDMz8yASiUyUlZUZV1ZWhNra2jvRaPTAarVGpqamHsF+AVLHObFbrVY/a21t/eDz+TSwc+bn57fKy8uF1dXVQ41G09HS0vIZvNGLhVyqjMmR4LEkSZ/a2tqMw8PDMgZzQzgc1kxPT7cj+WRzc7ODPg7aXKOPMYwliD5ykIucVymhKKCjo4MJXoFspKurS+jr6xOysrLkAtLS0rSwtfANIaEwODgo1NTUyIM21+hjDGMJIpYc5CInuZlDJjz/kQtgo9TV1VnW1tZGIftTVCr09PQkxwk4U7Xb7S5ErJ2EFx+u0RcKhQyMTfaTi5zkZg7mijenHNjZ2aluamoK4ux0ycBkGzvQYGeyHNzZdQ+SZzL2Oj9zMBdzMkb+qaysVB0dHaVXVVU9B/l7Vjs0NKTg4K4sFksIBDsjIyMKHydjY2MCfUjOY1I0N7nISW7mYC7mJE4hFSSKVVRUvMvPz39LQlwp4fj4mHGJJzc3943T6RR6e3uFhYUFgTeENtfgG00EwiCWHOQiJ7mZIzlGPJ/wegS0Wu02Agx2u33GYDD40LlPlpeX9YzBmUUxwkVFRU7s1DQ7O9uOpCb6cM38BQUFkzabzQmlwhjyUXZ3dwsulytYWlr62mw2f8f6b+bA9yEAmHwlE1KxOx0Ohx7yWJDADhkdfr+/en19vQsAa319/T1cJz9IbPDdxTsfI50FoLA/GNvAufD2iqJompubW0LP+IqLi8dMJtMX+NzAebKzs/fQzMGJiYkIsYlmWVpaimEHUcgYCgQCQZBIOp3uBIAf+/v7FbA/Go3GDRTBZpWADeN9iiL8SLoF28PkiDvd3d214mv4EB+ilzj3n/D9wvdhHfaex+MJxZOzgIQCnPBBs6hxVbR6vT4bUxtIefUkyOzC2sbBwUEMdgZGJpLLUsMfwtGdYARycnJUwWCwEDZVEjE2wOPF2lFJSUkY/Iqv4aUC4kXgLe7s7GShcgtsqJm2h/k+uldaXFwkToNzl/Gbm5tsrAh8MfjEvLw8M46NuDOc+R7m7GTpYnKsXVaAi3ywKxWaCCch6kAi4ljC2L1Cvn+Ryl/2ElTQZWRkaFE8TkwK4ZMsQQlF98dRimsYX+SbAAJxfQJer/cYf0LB8fFxhXzJ8XGbMYwlhtibkscxqXdKgf9bgb8e4D98kWiZrgAAAABJRU5ErkJggg==",l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAbCAYAAAH3zbSEAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAHaADAAQAAAABAAAAGwAAAABRO+PxAAADA0lEQVRIDbWWzW5SQRTHuQUpYhNbPwpipLcYaNPEBFrcdGP6AG7rW/AMvoE7l76AMXHhyoUvUEi61hhxVRottYmmfhb/v8kMXO7l41LtSQ5zvs/MmXOGm0iMgEsB2cOUGK8ncEIjqNfrjh+9LlhxVuvckL/nefOpkL+H9fzu7i5ZMjAWlm3mFBYoqsLfVukWdrRvDGR96qTBVTkvB/kovbW1Re7toObw8LC3ubn5GdndoMLSGJc8PFut1v2wgeR7RhlWOJ5tJ5rNpuP7K8WZ6MlZk4rfL4Tyz0v2sx9iQCRrtdoTnf9Rt9tda7fbX1Bl7HF3RF8Z2EaolUaj0aMMGxsbz6VNY5G2zlwxVzIJCb5k7dNsmwgV4YGwv33R44Ai3RK+xcBsm44gYtwVvyFn4xnjx247Y6qtCHmha2sCToOvMuhMMxqrT0qzoC38KBQKj3O5XLbT6byRrD+HztP3/cVSqfQxn88XZfMaefn4+LhXqVReiC4I5xCGIEVrUwbuV7pl9GXr5ItmB6MgTTPgRHPIYIUCXRcyYtzrH+EoYBd3hPeEtKGZWarKJZsp0zoOSILdNeF3CFprVWgaWus0WJTBB6LQTmz1SBgHONopGVMq1vs4Hs5GY1fk0DyCs0J21J3FCnJuR854FnqZ42Q8o6pMBpWNm/1Mtgc4gjjRbo4XmcAgiMjiAvEc4hOJwzN0270iDAv/PerrZ5L7Qpor7kmwy1ar1afusXSzgQydi8UztEZSkmnQXorfEfpCEo4bOKkiwAFW9LQfkcwBNDJ0QmwS/C8U7cm2RfvCWZPJxQANspzJZB6sr6+/UqITEBoZOiE25mfRvp9L4oNfFOhnBSpDGUnAyVZZbXwaL0lWjBjyhBRd1guEG4p9YI7qkthPgBPxv5zsP6xU7qoOtOdikZR2/oYgqIC/ACAP+Uwjlal5EC6CV64y+ZgrTxiZw/A3U5iXzxCE9WHeGpt8kWRDkSYwY4JO8Biozp10EGJ2itLyQtwUUm/Wf51ThYgA0/BJ+I71L+HkiMry77z4AAAAAElFTkSuQmCC";e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.MouseMotion").setCursor=function(t){let i,n=!1,o=t.getDomElement(),s=!1,r=!1,a=!1,l=null;function h(){n&&"walk"==t.getViewer().getEditorManager().editor.name||(o.addClass("motion-zoom"),i=Date.now(),setTimeout((()=>{Date.now()-i>180&&o.removeClass("motion-zoom")}),200))}function c(e){const t=e.keyCode||e.which||e.charCode;17==t?s=!0:18==t&&(r=!0)}function d(e){const t=e.keyCode||e.which||e.charCode;17==t?s=!1:18==t&&(r=!1)}function u(e){t._opt.enableZoomRect||s||r||(l={x:e.clientX,y:e.clientY})}function g(e){if(l&&!a&&!s&&!r&&!(Math.abs(l.x-e.clientX)<2&&Math.abs(l.y-e.clientY)<2)){if(n){let i=t.getUseLeftHandedInput();if("walk"==t.getViewer().getEditorManager().editor.name)1==e.buttons&&o.addClass("motion-rotate");else{let n=t._getIsCursorEnabled();1==e.buttons?n&&o.addClass(i?"motion-rotate":"motion-translate"):o.addClass(i?"motion-translate":"motion-rotate")}}else 1==e.buttons&&o.addClass("motion-translate");a=!0}}function p(e){l=!1,a=!1,o.removeClass("motion-translate"),o.removeClass("motion-rotate")}return e.Bimface.Viewer.Viewer3D&&"Viewer3D"===t.viewerType&&(n=!0),document.addEventListener("keydown",c),document.addEventListener("keyup",d),o.addEventListener("mousedown",u),o.addEventListener("mousemove",g),o.addEventListener("mousewheel",h,!1),o.addEventListener("DOMMouseScroll",h,!1),o.addEventListener("mouseup",p),function(){o.removeEventListener("mousemove",g),o.removeEventListener("mousewheel",h),o.removeEventListener("DOMMouseScroll",h),o.removeEventListener("mousedown",u),o.removeEventListener("mouseup",p),document.removeEventListener("keydown",c),document.removeEventListener("keyup",d)}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").create=function(e,t){var i=document.createElement(e);return i.setAttribute("class",t),i},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").createNS=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return i.setAttribute("class",t),i},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").select=function(e){return e.indexOf("#")>-1?document.getElementById(e.replace("#",""))||[]:e.indexOf(".")>-1?document.getElementsByClassName(e.replace(".","")):document.getElementsByTagName(e)},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").drag=function(t){let i=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),n=Object.assign({element:null,handle:null,axis:"all",cursor:"move",distance:0,start:null,move:null,stop:null,bBoxDetection:!1},t),o=n.element;if(!o)return!1;let s,r=n.handle||o,a=!1,l=this;this.resize=function(e,t,i){t=t||{x:0,y:0};let o=e.getBoundingClientRect(),s=e.parentElement.getBoundingClientRect(),r=o.left-s.left,a=o.top-s.top;var l=e.offsetWidth,h=e.offsetHeight,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,m=a+t.y<0?0:g>0&&g||0;i&&0!=p&&0!=m||(e.style.left=`${p}px`,e.style.top=`${m}px`,e.style.transform="none",n.record&&n.record(p,m))};let h=function(e){var t,o,a=e;if(i){if(t=a.button,!((o=navigator.userAgent).indexOf("compatible")>-1&&o.indexOf("MSIE")>-1&&!isOpera?1==t:0==t))return;s={x:a.clientX,y:a.clientY},document.addEventListener("mousemove",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;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.xMath.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,callback:null},e),this._opt.from=this._opt.from||this._opt.min,this._opt.to=this._opt.to||this._opt.max,this.init()};i.prototype={init:function(){var e=t.create("div","bf-multiple-range"),i=t.create("div","bf-range-track"),n=t.create("span","bf-slider bf-slider-min");n.id="minSlider",n.type="minimum";var o=t.create("span","bf-slider bf-slider-max");o.id="maxSlider",o.type="maximum",this._state={from:this._opt.from,to:this._opt.to},i.style.backgroundColor=this._opt.currentColor,e.style.backgroundColor=this._opt.defaultColor,e.appendChild(i),e.appendChild(n),e.appendChild(o),this._opt.element.appendChild(e),this._track=i,this._sliders={min:n,max:o},this._element=e,this.bindEvent(),this.update(!1)},bindEvent:function(){var e,t,i=this,n=!1,o=function(i){i=i||event;t=i.screenX,e=this,n=!0};this._sliders.min.addEventListener("mousedown",o),this._sliders.max.addEventListener("mousedown",o),document.addEventListener("mousemove",(function(o){if(n){var s=(o=o||event).screenX-t,r=Math.round(s/i._pix/i._opt.step)*i._opt.step;0!=r&&(t=r*i._pix+t,"minimum"==e.type?i._state.from+=r:i._state.to+=r,i.recalculate(e),i.update(!0))}})),document.addEventListener("mouseup",(function(){n?(n=!1,e=null,i._opt.callback&&i._opt.callback()):(e=null,n=!1)}))},update:function(e){var t=this._sliders.min.offsetWidth,i=this._sliders.max.offsetWidth;if(!this._pix){var n=(this._element.offsetWidth-t-i)/(this._opt.max-this._opt.min);this._pix=n}var o=(this._state.from-this._opt.min)*this._pix,s=(this._state.to-this._opt.min)*this._pix+t+i;this._track.style.left=`${o+t/2}px`,this._track.style.width=s-o-t/2-i/2+"px",this._sliders.min.style.left=`${o}px`,this._sliders.max.style.left=`${s}px`,this._opt.change&&e&&this._opt.change(this._state)},recalculate:function(e){this._state.to>=this._opt.max&&(this._state.to=this._opt.max),this._state.from<=this._opt.min&&(this._state.from=this._opt.min),e&&("maximum"==e.type&&this._state.to<=this._state.from&&(this._state.to=this._state.from),"minimum"==e.type&&this._state.from>=this._state.to&&(this._state.from=this._state.to))},getProgress:function(){return this._state},setProgress:function(e){this._state=e,this.recalculate(),this.update(!1)}},t.multipleRange=i}(),HTMLElement.prototype.tap=function(e){var t;this.addEventListener("touchstart",(function(e){t=Date.now()})),this.addEventListener("touchend",(function(i){Date.now()-t<200&&e(i)}))},(window.ActiveXObject||"ActiveXObject"in window)&&(HTMLElement.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)},window.Element&&((s=Element.prototype).matches=s.matches||s.matchesSelector||s.webkitMatchesSelector||s.msMatchesSelector||function(e){for(var t=this,i=(t.parentNode||t.document).querySelectorAll(e),n=-1;i[++n]&&i[n]!=t;);return!!i[n]}),window.Element&&function(e){e.closest=e.closest||function(e){for(var t=this;t.matches&&!t.matches(e);)t=t.parentNode;return t.matches?t:null}}(Element.prototype)),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.UUID").createUUID=function(){let e=[],t="0123456789abcdef";for(let i=0;i<36;i++)e[i]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("")},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").throttle=function(e,t){let i=null,n=Date.now();return null==t&&(t=30),function(){let o=Date.now(),s=t-(o-n);const r=this,a=arguments;clearTimeout(i),s<=0?(e.apply(r,a),n=Date.now()):i=setTimeout(e,s)}};const h=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");h.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;ei=i[e])),i}},limitTransformationDecimal(e){for(let t=0;t11&&t<=14&&(e[t]=Number(e[t].toFixed(3)));return e}};var c=h.DataUtil;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Utils").Transformation={getTranslation(e){const t=this._getDecompose(e);return{x:t.position.x,y:t.position.y,z:t.position.z}},getQuaternion(e){const t=this._getDecompose(e);return{x:t.quaternion._x,y:t.quaternion._y,z:t.quaternion._z,w:t.quaternion._w}},getScaling(e){const t=this._getDecompose(e);return{x:t.scale.x,y:t.scale.y,z:t.scale.z}},quaternionToEulerAngles(e,t){const i=new THREE.Euler,n=new THREE.Quaternion(e.x,e.y,e.z,e.w),o=i.setFromQuaternion(n,t||"XYZ");return{x:o._x,y:o._y,z:o._z,order:o._order}},eulerAnglesToQuaternion(e){const t=new THREE.Quaternion,i=new THREE.Euler(e.x,e.y,e.z,e.order),n=t.setFromEuler(i);return{x:n._x,y:n._y,z:n._z,w:n._w}},_getDecompose(e){const t=new THREE.Matrix4,i=new THREE.Vector3,n=new THREE.Quaternion,o=new THREE.Vector3;return t.fromArray(e),t.decompose(i,n,o),{position:i,quaternion:n,scale:o}}};const d=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");d.performance={throttleAndDebounce(e,t=300){let i=null,n=null;return function(...o){n&&(clearTimeout(n),n=null),n=setTimeout((()=>{clearTimeout(i),i=null,e(...o)}),t),i||(i=setTimeout((()=>{e(...o),clearTimeout(i),i=null}),t))}},throttle(e,t=300){let i=null;return function(...n){i||(i=setTimeout((()=>{e(...n),clearTimeout(i),i=null}),t))}},debounce(e,t=300){let i=null;return function(...n){i&&(clearTimeout(i),i=null),i=setTimeout((()=>{e(...n)}),t)}}},d.performance,function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang");let i=function(){this.container={}};i.prototype.addEvent=function(e,t,i){return"string"==typeof e&&"function"==typeof t&&(void 0===this.container[e]?this.container[e]=[t]:!0===i?this.container[e].unshift(t):this.container[e].push(t)),this},i.prototype.fireEvent=function(e){if(e&&this.container[e]){var t=Array.prototype.slice.call(arguments);t.shift();for(var i=[...this.container[e]],n=i.length,o=0;of)return null;let w=(r-a)/c,v=(l-a)/c;if(gv)return null;let y=(u-m)/(f-m),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;pg)continue;if(e.ym)continue;let f=(e.x-u)/(g-u),w=(e.y-p)/(m-p),v=c.viewport[3]-c.viewport[0],y=c.viewport[4]-c.viewport[1];i(n*((c.viewport[0]+v*f-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},g(Array.prototype,"getObjectByAttribute",(function(e,t){for(var i=this,n=i.length,o=0;o=0;i--)t[i]==e&&t.splice(i,1);return t})),g(Array.prototype,"insert",(function(e,t){return this.splice(e,0,t),this})),g(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}})),g(Array.prototype,"unique",(function(e){for(var t=[],i=0;i{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 m).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:u.APIHost,resourceHost:u.resourceHost,viewToken:null,modelId:null,modelType:"singleModel",dataEnvType:u.dataEnvType||"BIMFACE"}};var f=window.CLOUD=window.CLOUD||{};const w=function(e){return e.map((e=>{const t={positions:[]},i=e.end.x-e.start.x,n=e.end.y-e.start.y,o=e.end.z-e.start.z,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2)+Math.pow(o,2)),r=i/s,a=n/s,l=o/s,h={x:e.start.x-r,y:e.start.y-a,z:e.start.z-l},c={x:e.end.x+r,y:e.end.y+a,z:e.end.z+l};t.positions.push(h,c);const d=[{startPoint:e.start,endPoint:e.end,lineType:"Line"}];return{id:e.id,name:e.name,label:t,geometry:d}}))};var v,y,b,x,E,P,M,C,T,I;function S(e){c.assertType(e,"obj")&&(Object.defineProperty(e,"_isVue",{enumerable:!1,value:"ForSkipVueObserver"}),Object.defineProperty(e,"__v_skip",{enumerable:!1,value:"ForSkipVueObserver"}))}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data");var i=e.Web.Lang.Utility.HttpRequest.promiseJSONRequest,n=e.Web.Lang.Utility.HttpRequest.ajax,o={getFamilyTypes:function(e){const t=`${e.resourcePath}${e.databagId}/metadata/familyInfo.json`;return i(t)},getFamilyData:function(e){const t=`${e.relativeUrl}/metadata/assetProperties.json`;return i(t)},getAreas:function(e){var t=`${e.relativeUrl}/data/spaces.json`;return i(t)},getMepSystem:function(e,t){if("integrateModel"==t.modelType)var n=`${t.relativeUrl}/metadata/${e}/mepsystem.json`;else n=`${t.relativeUrl}/metadata/mepsystem.json`;return i(n,"noCode")},getTreeOldData:function(e){if("singleModel"==e.modelType)var t=`${e.relativeUrl}/data/tree.json`;else t=`${e.relativeUrl}/data/specialtyTree.json`;return i(t)},getTreeNewData:function(e){var t=`${e.relativeUrl}/data/tree.json`;return i(t)},getSectionData:function(e){var t=`${e.relativeUrl}/metadata/sectionCut.json`;return i(t)},getObjectData:function(t,i){return new Promise((function(n,o){if(i._objectData)n(i._objectData);else{let o=new e.Bimface.Data.ObjectPropertyManager(`${t.relativeUrl}/property`);o.load((function(){i._objectData=o,n(i._objectData)}))}}))},getMaterialProperty:function(e,t){var n=t.split(".");if("singleModel"==e.modelType)var o=`${e.relativeUrl}/metadata/materialmap.json`;else o=`${e.relativeUrl}/metadata/${n[0]}/materialmap.json`;return i(o,"noCode")},getMaterialPropertyItem:function(e,t,n){var o=t.split("."),s="singleModel"==e.modelType?`${e.relativeUrl}/metadata/materials/${n}.json`:`${e.relativeUrl}/metadata/${o[0]}/materials/${n}.json`;return i(s,"noCode")},getAreaProperty:function(e,t){var n=e.split("_");if("singleModel"==t.modelType)var o=`${t.relativeUrl}/metadata/areas.json`;else o=`${t.relativeUrl}/metadata/${n[0]}/areas.json`;return i(o,"noCode")},getRoomProperty:function(e,t){var n=e.split("_");if("singleModel"==t.modelType)var o=`${t.relativeUrl}/metadata/rooms.json`;else o=`${t.relativeUrl}/metadata/${n[0]}/rooms.json`;return i(o,"noCode")},getFiles:function(e){var t=`${e.relativeUrl}/data/files.json`;return i(t)},getDrawingsheets:function(e,t){var n=`${e.relativeUrl}/metadata/drawings.json`;return i(n,"noCode")},getMapInfo:function(e,t){this._opt;var i={},o=[];this._helper;2===t||"integrateModel"!==e.modelType?n({url:`${e.relativeUrl}/metadata/axisgrids/grids.json.gz`,async:!1,success:function(e){var t=f.AxisGridManager.adaptGridData(JSON.parse(e));i.Grids=t.grids}}):n({url:`${e.relativeUrl}/metadata/grids.json`,async:!1,success:function(e){var t=JSON.parse(e);i.Grids=w(t.grids)}}),n({async:!1,url:`${e.relativeUrl}/metadata/levels.json`,success:function(e){i.Levels=JSON.parse(e).levels}}),n({async:!1,url:`${e.relativeUrl}/resource/v3/maps/output.json`,dataType:"text",success:function(t){var i=JSON.parse(t);for(var n in i){var s=i[n];null==s.id&&(s.id=n),s.path=`${e.relativeUrl}/resource/v3/maps/${s.id}.png`,s.name=n,o.push(s)}}});let s=i.Levels;if(s){let e=e=>{let t=!1;return o.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t{let s={Grids:[]},r=[];const a="integrateModel"===e.modelType&&2!==t,l=`${e.relativeUrl}/metadata/${a?"grids.json":"axisgrids/grids.json.gz"}`;Promise.allSettled([i(l,"noCode"),i(`${e.relativeUrl}/metadata/levels.json`,"noCode"),i(`${e.relativeUrl}/resource/v3/maps/output.json`,"noCode")]).then((t=>{let[i,o,l]=t;if(i.value)if(a)s.Grids=w(i.value.grids);else{var h=f.AxisGridManager.adaptGridData(i.value);s.Grids=h.grids}s.Levels=o.value.levels,(t=>{for(var i in t){var o=t[i];null==o.id&&(o.id=i),o.path=`${e.relativeUrl}/resource/v3/maps/${o.id}.png`,o.name=i,r.push(o)}let a=s.Levels;if(a){let e=e=>{let t=!1;return r.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t1||n({async:!1,url:`${e.relativeUrl}/resource/v3/maps/output.json`,dataType:"text",success:function(e){const i=JSON.parse(e);t.floors=i}}),t},getLinksJson:function(e){var t=`${e.relativeUrl}/metadata/links.json`;return"singleModel"==e.modelType&&(t=`${e.relativeUrl}/metadata/rvtLinks.json`),i(t,"noCode")},getFloors:function(e){let t=`${e.relativeUrl}/data/spaces.json`;return i(t,"noCode")},getViews:function(e){var t={data:null,resourceHost:"./"};return n({url:`${e.relativeUrl}/metadata/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewsById:function(e){var t={data:null,resourceHost:"./"};return n({url:`${e.relativeUrl}/metadata/${e.fileId}/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewData:function(e){let t=`${e.relativeUrl}/metadata/viewStates/${e.viewId}.json`;return i(t,"noCode")},getRooms:function(e){let t=`${e.resourceHost}/${e.databagId}/metadata/rooms.json`;return i(t,"noCode")},getRoomBoundary:function(e,t){let n=`${t.resourceHost}/${t.databagId}/metadata/roomsboundary/${e}.json`;return i(n,"noCode")},getAllDrawingsheets:function(e){var t=`${e.relativeUrl}/metadata/drawings.json`;return i(t,"noCode")},decodeElementId:function(e,t){if(/^[0-9]*\.*[0-9]*$/.test(t))return Promise.resolve(t);var i=t.split("."),n=i[0];return this.getFiles(e).then((function(e){for(let t of e)for(let e of t.linkedBy)if(e==n)return t.fileId+"."+i[1]})).then((function(e){return e}))},getCategoryVisibility:function(e){var t=`${e.relativeUrl}/metadata/categoryVisibility.json`;return i(t,"noCode")},getText:function(e){var t=`${e.relativeUrl}/metadata/text.json`;return i(t,"noCode")},getSegmentGroups:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups?view_token=${e.viewToken}`;return i(t,"noCode")},getSegmentFromGroups:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups/${t}/segments?view_token=${e.viewToken}`;return i(n,"noCode")},getSegmentTree:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentTree?view_token=${e.viewToken}`;return i(t,"noCode")},getSegmentById:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}?view_token=${e.viewToken}`;return i(n,"noCode")},getSegmentElementIds:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}/elementIds?view_token=${e.viewToken}`;return i(n,"noCode")},getPartialElementsMetadata:function(e,t){var n=`${e.relativeUrlWithoutDatabagId}/${t}/metadata/partial_elements_metadata.json`;return i(n,"noCode")},getPartialElementsMetadataFile:function(e,t){return`${e.relativeUrlWithoutDatabagId}/${t}/metadata/partial_elements_metadata.json`},getDatabagResource:function(e,t){return`${e.relativeUrlWithoutDatabagId}/${t}/resource/v3/model`},getModelGroup:function(e,t){var n=`${e.relativeUrl}/metadata/modelSetsTree.json`;return i(n,"noCode")},getManifest:function(e){var t=`${e.relativeUrl}/manifest.json`;return i(t,"noCode")},getNestedComponents:function(e){var t=`${e.relativeUrl}/metadata/nestedComponents.json`;return i(t,"noCode")},getObjectMap:function(e){var t=`${e.relativeUrl}/metadata/objectMap.json.gz`;return i(t,"noCode")},getWalkthrough:function(e){var t=`${e.relativeUrl}/data_ext/walkthrough.json`;return i(t,"noCode")},getProjectInfo:function(e){var t=`${e.relativeUrl}/metadata/project.json`;return i(t,"noCode")},getModelInfo:function(e){var t=`${e.relativeUrl}/resource/v3/model/config.json`;return i(t,"noCode")},getBimtileInfo:function(e,t){return i(`${e}/resource/v3/model/${t}`,"noCode")},getFeatureStyle:function(e){var t=`${e.relativeUrl}/resource/v3/model/featureStyle.json`;return i(t,"noCode")},getDimensions:function(e,t){let n=`${t.relativeUrl}/metadata/ModelDimensions.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/ModelDimensions.json`),i(n,"noCode")},getLevelmapping:function(e){var t=`${e.relativeUrl}/metadata/levelmapping.json`;return i(t,"noCode")},getDrawingTree:function(e,t){var n=`${t.relativeUrl}/metadata/drawingsTree.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/drawingsTree.json`),i(n,"noCode")},getViewsTree:function(e,t){var n=`${t.relativeUrl}/metadata/viewsTree.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/viewsTree.json`),i(n,"noCode")}};t.OfflineDataProdiver=o}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data.OfflineDataProdiver");function n(e){this._config=e}n.prototype={getFamilyTypes:function(e,t){i.getFamilyTypes(this._config).then((function(t){var i=JSON.parse(t),n=i.Types||i.types;for(let e=0,t=n.length;e{t&&t(e)}))}else n&&n(s)}))}))},getAreas:function(e,t){i.getAreas(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getMepSystem:function(e,t,n){var o=this;i.getMepSystem(e,o._config).then((function(e){t&&t(e,o._config.modelType)})).catch((function(e){n&&n(e)}))},getTreeOldData:function(e,t){var n=this;i.getTreeOldData(n._config).then((function(t){e&&e(t,n._config.modelType,"old")})).catch((function(e){t&&t(e)}))},getTreeNewData:function(e,t){var n=this;i.getTreeNewData(n._config).then((function(t){var i=!0,o=e=>{"familyType"===e.type?e.items&&0!==e.items.length||(i=!1):e.items&&e.items.length>0&&o(e.items[0])};t&&t.length>0&&o(t[0]),e&&e(t,n._config.modelType,i?void 0:"old")})).catch((function(e){t&&t(e)}))},getSectionData:function(e,t){i.getSectionData(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomProperty:function(e,t,n){var o=this;i.getRoomProperty(e,this._config).then((function(n){var s="singleModel"==o._config.modelType?e:e.split("_")[1];for(var r of n)if(r.id==s)return void i.getObjectData(o._config,o).then((function(i){e="singleModel"==o._config.modelType?e:`${e.split("_")[0]}.${e.split("_")[1]}`;var n=i.getElementProperties(e);n.splice(0,1),r.properties=n,t&&t(r)}))}))},getAreaProperty:function(e,t,n){var o=this;i.getAreaProperty(e,this._config).then((function(n){var s="singleModel"==o._config.modelType?e:e.split("_")[1];for(var r of n.areas)r.id==s&&i.getObjectData(o._config,o).then((function(i){e="singleModel"==o._config.modelType?e:`${e.split("_")[0]}.${e.split("_")[1]}`;var n=i.getElementProperties(e);n.splice(0,1),r.properties=n,t&&t(r)}))}))},getModelGroup:function(e,t){i.getModelGroup(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getFiles:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getLinkGraph:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingsheets(e,t,n,o){var s=this;i.getDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType,s._config.dataEnvType)}))},getLinksJson(e,t,n,o){var s=this;e=e||s._config.modelId,i.getLinksJson(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getFloors:function(e,t){var n=this;i.getFloors(this._config).then((function(t){for(let e of t.data)e.miniMap=`${n._config.databagId}/resource/v3/maps/${e.name}.png`;e&&e(t.data)}))},getElementByConditions:function(e,t,n){var o=this;i.getObjectData(this._config,o).then((function(i){n&&n(i.getElementByConditions(e,t,o._config))}))},getMapInfo:function(e,t){var n=i.getMapInfo(this._config,t);e&&e(n)},getMapInfoAsync:function(e,t,n){i.getMapInfoAsync(this._config,n).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getExplosionFloorsInfo:function(e,t){const n=i.getExplosionFloorsInfo(this._config);e&&e(n)},getLevels:function(e,t,n){i.getLevels(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getViews:function(e){var t=i.getViews(this._config);e&&e(t)},getViewsById:function(e,t){var n=this._config;n.fileId=e;var o=i.getViewsById(n);t&&t(o)},getViewData:function(e,t){var n=Object.assign({},this._config);n.viewId=e,i.getViewData(n).then((function(e){"[object Function]"===Object.prototype.toString.call(t)&&t(e)})).catch((function(e){"[object Function]"===Object.prototype.toString.call(failure)&&failure(e)}))},getRooms:function(e,t){i.getRooms(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomBoundary:function(e,t,n){i.getRoomBoundary(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getAllDrawingsheets:function(e,t,n,o){var s=this;i.getAllDrawingsheets(this._config).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){n&&n({drawingList:[]},s._config.modelType)}))},getCategoryVisibility:function(e,t){i.getCategoryVisibility(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getText:function(e,t){i.getText(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentGroups:function(e,t){i.getSegmentGroups(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentFromGroups:function(e,t,n){i.getSegmentFromGroups(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentTree:function(e,t){i.getSegmentTree(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentById:function(e,t,n){i.getSegmentById(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentElementIds:function(e,t,n){i.getSegmentElementIds(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadata:function(e,t,n){i.getPartialElementsMetadata(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadataFile:function(e){return i.getPartialElementsMetadataFile(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getManifest:function(e,t){i.getManifest(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getNestedComponents:function(e,t){i.getNestedComponents(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getObjectMap:function(e,t){i.getObjectMap(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getWalkthrough:function(e,t){i.getWalkthrough(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getProjectInfo:function(e,t){var n=this;i.getProjectInfo(n._config).then((function(t){e&&e(t,n._config.modelType)})).catch((function(e){t&&t(e)}))},getModelInfo:function(e,t){i.getModelInfo(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getBimtileInfo:function(e,t,n,o){const s=`${this._config.relativeUrlWithoutDatabagId}/${e}`;i.getBimtileInfo(s,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getFeatureStyle:function(e,t){i.getFeatureStyle(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDimensions:function(e,t,n){i.getDimensions(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getLevelmapping:function(e,t){i.getLevelmapping(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingTree:function(e,t){i.getDrawingTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))},getViewsTree:function(e,t){i.getViewsTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))}},t.OfflineDataManager=n}(),v=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),y=(t,i)=>e.Web.Lang.Utility.HttpRequest.promiseJSONRequest(t,i,f.EnableStorage),b=t=>e.Web.Lang.Utility.HttpRequest.promiseJsonFunction(t),x=t=>e.Web.Lang.Utility.HttpRequest.getUrl(t),E=e.Web.Lang.Utility.HttpRequest.ajax,P={getMepSystem:function(e,t){if("integrateModel"==t.modelType)var i=`${t.resourceHost}/${t.databagId}/metadata/${e}/mepsystem.json`;else i=`${t.resourceHost}/${t.databagId}/metadata/mepsystem.json`;let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/mepsystem.json`:"metadata/mepsystem.json",status:"noCode",...t.httpDefaultParams};return b(n)},getTreeNewData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/data/tree.json`,path:"data/tree.json",status:"noCode",...e.httpDefaultParams};return b(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 y(t)},getSectionData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/sectionCut.json`,path:"metadata/sectionCut.json",status:"noCode",...e.httpDefaultParams};return b(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 y(n)},fromIntegrateModel:function(t,i,n){var o=`${e.APIHost}/data/v2/integrations/${t}/drawingsheets?fileIdHash=${i}&elementId=${n}&view_token=${e.viewToken}`;return y(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 y(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 y(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 y(i)},getObjectData:function(e,t){if("singleModel"==e.modelType)var i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`;else if("integrateModel"==e.modelType){var n=t.split(".");i=1==n.length?e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?view_token=${e.viewToken}`}else i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/sections/${e.modelId}/elements/${t}?view_token=${e.viewToken}`;return y(i)},getFamilyData:function(e,t){let i=`${e.APIHost}/data/v2/rfaFiles/${e.modelId}/familyTypes/${t}?view_token=${e.viewToken}`;return y(i)},getEditedObjectData:function(e,t){if("singleModel"==e.modelType)var i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/files/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`;else{var n=t.split(".");i=1==n.length?e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?includeOverrides=true&view_token=${e.viewToken}`}return y(i)},getFiles:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/files?includeDrawingSheet=true&view_token=${e.viewToken}`;return y(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 y(n)},getLinkGraph:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/linkGraph?view_token=${e.viewToken}`;return y(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 y(n)}failure&&failure({})},getDrawingsheets:function(e,t){var i=`${e.APIHost}/data/v2/files/${t}/drawingsheets?fileId=${t}&view_token=${e.viewToken}`;return y(i)},getAllDrawingsheets:function(e,t){let i={url:`${e.resourceHost}/${e.integrateDrawings&&e.integrateDrawings.databagId||e.databagId}/metadata/drawings.json`,path:"metadata/drawings.json",status:"noCode",...e.httpDefaultParams};return b(i)},getLinksJson:function(e,t){var i=`${e.resourceHost}/${e.databagId}/metadata/links.json`;"singleModel"==e.modelType&&(i=`${e.resourceHost}/${e.databagId}/metadata/rvtLinks.json`);let n={url:i,path:"metadata/links.json",status:"noCode",...e.httpDefaultParams};return b(n)},getFloors:function(e){if("singleModel"==e.modelType)var t=`${e.APIHost}/data/v2/files/${e.modelId}/floors?view_token=${e.viewToken}`;else t=`${e.APIHost}/data/v2/integrations/${e.modelId}/floors?view_token=${e.viewToken}`;return y(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 y(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{let t=!1;return n.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t{let o={Grids:[]},s=[];const r="integrateModel"===e.modelType&&2!==t,a=`${e.resourceHost}/${e.databagId}/metadata/${r?"grids.json":"axisgrids/grids.json.gz"}`,l="metadata/"+(r?"grids.json":"axisgrids/grids.json.gz");Promise.allSettled([b({url:a,path:l,status:"noCode",...e.httpDefaultParams}),b({url:`${e.resourceHost}/${e.databagId}/metadata/levels.json`,path:"metadata/levels.json",status:"noCode",...e.httpDefaultParams}),b({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,path:"resource/model/maps/output.json",status:"noCode",...e.httpDefaultParams})]).then((t=>{let[n,a,l]=t;if(n.value)if(r)o.Grids=w(n.value.grids);else{var h=f.AxisGridManager.adaptGridData(n.value);o.Grids=h.grids}o.Levels=a.value.levels,(t=>{for(var n in t){var r=t[n];null==r.id&&(r.id=n),r.path=x({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/${r.id}.png`,path:`resource/model/maps/${r.id}.png`,...e.httpDefaultParams}),r.name=n,s.push(r)}let a=o.Levels;if(a){let e=e=>{let t=!1;return s.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t1||E({async:!1,url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,dataType:"text",success:function(e){const i=JSON.parse(e);t.floors=i}}),t},getExplosionFloorsInfoAsync:function(e){let t={};return new Promise(((i,n)=>{const o=`${e.resourceHost}/${e.databagId}/metadata/levels.json`;y(o,"noCode").then((o=>{t.levels=o.levels,t.levels.length>0&&t.levels[0].boundingBox?i(t):y(`${e.resourceHost}/${e.databagId}/resource/v3/maps/output.json`,"noCode").then((e=>{t.floors=e,i(t)})).catch(n)})).catch(n)}))},getLevels:function(e,t){let i=`${t.resourceHost}/${t.databagId}/metadata/levels.json`,n="metadata/levels.json";e&&(i=`${t.resourceHost}/${t.databagId}/metadata/${e}/levels.json`,n=`metadata/${e}/levels.json`);let o={url:i,path:n,status:"noCode",...t.httpDefaultParams};return b(o)},getViews:function(e){var t={data:null,resourceHost:e.resourceHost};return E({url:x({url:`${e.resourceHost}/${e.databagId}/metadata/views.json`,path:"metadata/views.json",...e.httpDefaultParams}),async:!1,success:function(e){t.data=e}}),t},getViewsById:function(e){var t={data:null,resourceHost:e.resourceHost};return E({url:x({url:`${e.resourceHost}/${e.databagId}/metadata/${e.fileId}/views.json`,path:`metadata/${e.fileId}/views.json`,...e.httpDefaultParams}),async:!1,success:function(e){t.data=e}}),t},getViewData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/viewStates/${e.viewId}.json`,path:`metadata/viewStates/${e.viewId}.json`,status:"noCode",...e.httpDefaultParams};return b(t)},getRooms:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/rooms.json`,path:"metadata/rooms.json",status:"noCode",...e.httpDefaultParams};return b(t)},getRoomBoundary:function(e,t){let i={url:`${t.resourceHost}/${t.databagId}/metadata/roomsboundary/${e}.json`,path:`metadata/roomsboundary/${e}.json`,status:"noCode",...t.httpDefaultParams};return b(i)},getCategoryVisibility:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/categoryVisibility.json`,path:"metadata/categoryVisibility.json",status:"noCode",...e.httpDefaultParams};return b(t)},getText:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/text.json`,path:"metadata/text.json",status:"noCode",...e.httpDefaultParams};return b(t)},getScheduleList:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/schedule.json`,path:"metadata/schedule.json",status:"noCode",...e.httpDefaultParams};return b(t)},getScheduleById:function(e,t){let i={url:`${t.resourceHost}/${t.databagId}/metadata/schedule/${e}.txt`,path:`metadata/schedule/${e}.txt`,status:"noCode",...t.httpDefaultParams};return b(i)},getSegmentGroups:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups?view_token=${e.viewToken}`;return y(t,"noCode")},getSegmentFromGroups:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups/${t}/segments?view_token=${e.viewToken}`;return y(i,"noCode")},getSegmentTree:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentTree?view_token=${e.viewToken}`;return y(t,"noCode")},getSegmentById:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}?view_token=${e.viewToken}`;return y(i,"noCode")},getSegmentElementIds:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}/elementIds?view_token=${e.viewToken}`;return y(i,"noCode")},getPartialElementsMetadata:function(e,t){let i={url:`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`,path:"metadata/partial_elements_metadata.json",status:"noCode",...e.httpDefaultParams};return b(i)},getPartialElementsMetadataFile:function(e,t){return x({url:`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`,path:"metadata/partial_elements_metadata.json",...e.httpDefaultParams})},getDatabagResource:function(e,t){return x({url:`${e.resourceHost}/${t}/resource/v3/model`,path:"resource/v3/model",...e.httpDefaultParams})},getModelGroup:function(e,t){let i={url:`${e.resourceHost}/${e.databagId}/metadata/modelSetsTree.json`,path:"metadata/modelSetsTree.json",status:"noCode",...e.httpDefaultParams};return b(i)},getManifest:function(e){let t={url:`${e.resourceHost}/${e.databagId}/manifest.json`,path:"manifest.json",status:"noCode",...e.httpDefaultParams};return b(t)},getNestedComponents:function(e){let t={url:`${e.relativeUrl}/metadata/nestedComponents.json`,path:"metadata/nestedComponents.json",status:"noCode",...e.httpDefaultParams};return b(t)},getObjectMap:function(e){let t={url:`${e.relativeUrl}/metadata/objectMap.json.gz`,path:"metadata/objectMap.json.gz",status:"noCode",...e.httpDefaultParams};return b(t)},getWalkthrough:function(e){let t={url:`${e.relativeUrl}/data_ext/walkthrough.json`,path:"data_ext/walkthrough.json",status:"noCode",...e.httpDefaultParams};return b(t)},getProjectInfo:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/project.json`,path:"metadata/project.json",status:"noCode",...e.httpDefaultParams};return b(t)},getModelInfo:function(e){let t={url:`${e.relativeUrl}/resource/v3/model/config.json`,path:"resource/v3/model/config.json",status:"noCode",...e.httpDefaultParams};return b(t)},getBimtileInfo:function(e,t,i){let n={url:`${e}/resource/v3/model/${t}`,path:`resource/v3/model/${t}`,status:"noCode",...i.httpDefaultParams};return b(n)},getFeatureStyle:function(e){let t={url:`${e.relativeUrl}/resource/v3/model/featureStyle.json`,path:"resource/v3/model/featureStyle.json",status:"noCode",...e.httpDefaultParams};return b(t)},getDimensions:function(e,t){let i=`${t.relativeUrl}/metadata/ModelDimensions.json`;return"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/ModelDimensions.json`),i=x({url:i,path:"integrateModel"==t.modelType?"metadata/ModelDimensions.json":`metadata/${e}/ModelDimensions.json`,...t.httpDefaultParams}),y(i,"noCode")},getLevelmapping:function(e){let t={url:`${e.relativeUrl}/metadata/levelmapping.json`,path:"metadata/levelmapping.json",status:"noCode",...e.httpDefaultParams};return b(t)},getDrawingTree:function(e,t){var i=`${t.relativeUrl}/metadata/drawingsTree.json`;"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/drawingsTree.json`);let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/drawingsTree.json`:"metadata/drawingsTree.json",status:"noCode",...t.httpDefaultParams};return b(n)},getViewsTree:function(e,t){var i=`${t.relativeUrl}/metadata/viewsTree.json`;"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/viewsTree.json`);let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/viewsTree.json`:"metadata/viewsTree.json",status:"noCode",...t.httpDefaultParams};return b(n)}},v.OnlineDataProdiver=P,function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data.OnlineDataProdiver");function n(e){this._config=e,this._config.httpDefaultParams={APIHost:e.APIHost,loadMode:e.loadMode,fileId:e.modelId,viewToken:e.viewToken,modelType:e.modelType}}n.prototype={getOfflineDataManager(){return this._offlineDatamanager=this._offlineDatamanager||new t.OfflineDataManager(this._config),this._offlineDatamanager},getComponentProperty:function(e,t,n){const o=this;if(!e)return console.warn("elementId must not be empty!."),void(n&&n());i.getObjectData(this._config,e).then((function(e){t&&t(e)})).catch((function(i){f.EnableStorage&&!o._config.isGlobeScene?o.getOfflineDataManager().getComponentProperty(e,t,n):n&&n(i)}))},getFamilyProperty:function(e,t,n){if(!e)return console.warn("familyTypeId must not be empty!."),void(n&&n());i.getFamilyData(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getComponentOverriddenProperty:function(e,t,n){if(!e)return console.warn("elementId must not be empty!."),void(n&&n());i.getEditedObjectData(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getMaterialProperty:function(e,t,n){var o=this;i.getMaterialProperty(this._config,e).then((function(e){t&&t(e)})).catch((function(i){f.EnableStorage?o.getOfflineDataManager().getMaterialProperty(e,t,n):n&&n(i)}))},getTreeOldData:function(e,t){var n=this;i.getTreeOldData(n._config).then((function(t){e&&e(t,n._config.modelType,"old")})).catch((function(e){t&&t(e)}))},getTreeNewData:function(e,t,n=!0){var o=this;i.getTreeNewData(o._config).then((function(t){e&&(!n&&e(t,o._config.modelType),n&&e(t.data,o._config.modelType))})).catch((function(e){t&&t(e)}))},getSectionData:function(e,t,n=!0){var o=this;i.getSectionData(o._config).then((function(t){e&&(!n&&e(t,o._config.modelType),n&&e(t.data,o._config.modelType))})).catch((function(e){t&&t(e)}))},getMepSystem:function(e,t,n){var o=this;i.getMepSystem(e,o._config).then((function(e){t&&t(e,o._config.modelType)})).catch((function(e){n&&n(e)}))},getAreas:function(e,t){i.getAreas(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomProperty:function(e,t,n){i.getRoomProperty(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getDrawingList:function(e,t,n,o){var s=this._config.modelType;if("integrateModel"==s){var r=t.split(".")[0],a=t.split(".")[1];i.getDrawingList(this._config).fromIntegrateModel(e,r,a).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))}else"singleModel"==s&&i.getDrawingList(this._config).fromSingleModel(e,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getModelGroup:function(e,t){i.getModelGroup(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getAreaProperty:function(e,t,n){i.getAreaProperty(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getFiles:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getMaterialOverride:function(e,t,n,o){i.getMaterialOverride(e,t,this._config).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getLinkGraph:function(e,t){i.getLinkGraph(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingsheets(e,t,n,o){var s=this;e=e||s._config.modelId,i.getDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getAllDrawingsheets(e,t,n,o){var s=this;e=e||s._config.modelId,i.getAllDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getLinksJson(e,t,n,o){var s=this;e=e||s._config.modelId,i.getLinksJson(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getFloors(e,t){i.getFloors(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getElementByConditions(e,t,n,o){i.getElementByConditions(this._config,e,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getComponentsByConditions(e,t,n,o){i.getComponentsByConditions(this._config,e,t).then((function(e){n&&n(e&&e[0].elementIds)})).catch((function(e){o&&o(e)}))},getMaterialJson(e,t,n,o,s){i.getMaterialJson(e,t,n).then((function(e){o&&o(e)})).catch((function(e){s&&s(e)}))},getTextureJson:function(e,t,n,o,s){i.getTextureJson(e,t,n).then((function(e){o&&o(e)})).catch((function(e){s&&s(e)}))},getMapInfo:function(e,t){var n=i.getMapInfo(this._config,t);e&&e(n)},getMapInfoAsync:function(e,t,n){i.getMapInfoAsync(this._config,n).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getExplosionFloorsInfo:function(e,t){const n=i.getExplosionFloorsInfo(this._config);e&&e(n)},getLevels:function(e,t,n){i.getLevels(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getViews:function(e){var t=i.getViews(this._config);e&&e(t)},getViewsById:function(e,t){var n=this._config;n.fileId=e;var o=i.getViewsById(n);t&&t(o)},getViewData:function(e,t,n){var o=Object.assign({},this._config);o.viewId=e,i.getViewData(o).then((function(e){"[object Function]"===Object.prototype.toString.call(t)&&t(e)})).catch((function(e){"[object Function]"===Object.prototype.toString.call(n)&&n(e)}))},getRooms:function(e,t){i.getRooms(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomBoundary:function(e,t,n){i.getRoomBoundary(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getCategoryVisibility:function(e,t){i.getCategoryVisibility(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getText:function(e,t){i.getText(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getScheduleList:function(e,t){i.getScheduleList(this._config).then((function(t){e&&e(t.scheduleList)})).catch((function(e){t&&t(e)}))},getScheduleById:function(e,t,n){i.getScheduleById(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentGroups:function(e,t){i.getSegmentGroups(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentFromGroups:function(e,t,n){i.getSegmentFromGroups(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentTree:function(e,t){i.getSegmentTree(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentById:function(e,t,n){i.getSegmentById(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentElementIds:function(e,t,n){i.getSegmentElementIds(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadata:function(e,t,n){i.getPartialElementsMetadata(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadataFile:function(e){return i.getPartialElementsMetadataFile(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getManifest:function(e,t){i.getManifest(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getNestedComponents:function(e,t){i.getNestedComponents(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getObjectMap:function(e,t){i.getObjectMap(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getWalkthrough:function(e,t){i.getWalkthrough(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getProjectInfo:function(e,t){var n=this;i.getProjectInfo(n._config).then((function(t){e&&e(t,n._config.modelType)})).catch((function(e){t&&t(e)}))},getModelInfo:function(e,t){i.getModelInfo(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getBimtileInfo:function(e,t,n,o){const s=`${this._config.relativeUrlWithoutDatabagId}/${e}`;i.getBimtileInfo(s,t,this._config).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getFeatureStyle:function(e,t){i.getFeatureStyle(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDimensions:function(e,t,n){i.getDimensions(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getLevelmapping:function(e,t){i.getLevelmapping(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingTree:function(e,t){i.getDrawingTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))},getViewsTree:function(e,t){i.getViewsTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))}},t.OnlineDataManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=function(e){if(this._config=e,this._objectData=null,this._cache={},"Local"==e.dataEnvType?this.dataManager=new t.OfflineDataManager(e):this.dataManager=new t.OnlineDataManager(e),!e.viewToken)return!1};i.prototype={getFamilyTypes:function(e,t){this.dataManager.getFamilyTypes(e,t)},getComponentProperty:function(e,t,i){this.dataManager.getComponentProperty(e,t,i)},getFamilyProperty:function(e,t,i){this.dataManager.getFamilyProperty(e,t,i)},getComponentOverriddenProperty:function(e,t,i){this.dataManager.getComponentOverriddenProperty(e,t,i)},getDrawingList:function(e,t,i,n){this.dataManager.getDrawingList(e,t,i,n)},getTreeOldData:function(e,t){this.dataManager.getTreeOldData(e,t)},getTreeNewData:function(e,t,i=!1){this.dataManager.getTreeNewData(e,t,i)},getSectionData:function(e,t,i=!1){this.dataManager.getSectionData(e,t,i)},getMepSystem:function(e,t,i){this.dataManager.getMepSystem(e,t,i)},getModeTree:function(e,t){console.warn("This function is deprecated. Please use getTreeOldData instead."),this.getTreeOldData(e,t)},getFloors:function(e,t){this.dataManager.getFloors(e,t)},getAreas:function(e,t){this.dataManager.getAreas(e,t)},getAreaProperty:function(e,t,i){this.dataManager.getAreaProperty(e,t,i)},getModelGroup:function(e,t){this.dataManager.getModelGroup(e,t)},getMaterialProperty:function(e,t,i){this.dataManager.getMaterialProperty(e,t,i)},getRoomProperty:function(e,t,i){this.dataManager.getRoomProperty(e,t,i)},getFiles:function(e,t){this.dataManager.getFiles(e,t)},getMaterialOverride:function(e,t,i,n){this.dataManager.getMaterialOverride(e,t,i,n)},getLinkGraph:function(e,t){this.dataManager.getLinkGraph(e,t)},getDrawingsheets:function(e,t,i,n){this.dataManager.getDrawingsheets(e,t,i,n)},getElementByConditions:function(e,t,i,n){this.dataManager.getElementByConditions(e,t,i,n)},getComponentsByConditions:function(e,t,i,n){this.dataManager.getComponentsByConditions(e,t,i,n)},getMaterialJson(e,t,i,n,o){this.dataManager.getMaterialJson(e,t,i,n,o)},getTextureJson:function(e,t,i,n,o){this.dataManager.getTextureJson(e,t,i,n,o)},getAllDrawingsheets:function(e,t,i,n){this.dataManager.getAllDrawingsheets(e,t,i,n)},getLinksJson:function(e,t,i,n){this.dataManager.getLinksJson(e,t,i,n)},getMapInfo:function(e,t){this.dataManager.getMapInfo(e,t)},getMapInfoAsync:function(e,t,i){this.dataManager.getMapInfoAsync(e,t,i)},getExplosionFloorsInfo:function(e,t){this.dataManager.getExplosionFloorsInfo(e,t)},getCategoryVisibility:function(e,t){this.dataManager.getCategoryVisibility(e,t)},getText:function(e,t){this.dataManager.getText(e,t)},getScheduleList:function(e,t){this.dataManager.getScheduleList(e,t)},getScheduleById:function(e,t,i){this.dataManager.getScheduleById(e,t,i)},getSegmentGroups:function(e,t){this.dataManager.getSegmentGroups(e,t)},getSegmentFromGroups:function(e,t,i){this.dataManager.getSegmentFromGroups(e,t,i)},getSegmentTree:function(e,t){this.dataManager.getSegmentTree(e,t)},getSegmentById:function(e,t,i){this.dataManager.getSegmentById(e,t,i)},getSegmentElementIds:function(e,t,i){this.dataManager.getSegmentElementIds(e,t,i)},getPartialElementsMetadata:function(e,t,i){this.dataManager.getPartialElementsMetadata(e,t,i)},getPartialElementsMetadataFile:function(e){return this.dataManager.getPartialElementsMetadataFile(e)},getDatabagResource:function(e){return this.dataManager.getDatabagResource(e)},getManifest:function(e,t){return this.dataManager.getManifest(e,t)},getNestedComponents:function(e){return this.dataManager.getNestedComponents(e)},getObjectMap:function(e){return this.dataManager.getObjectMap(e)},getWalkthrough:function(e){return this.dataManager.getWalkthrough(e)},getViews:function(e){return this.dataManager.getViews(e)},getViewData:function(e,t,i){return this.dataManager.getViewData(e,t,i)},getProjectInfo:function(e,t){this.dataManager.getProjectInfo(e,t)},getModelInfo:function(e,t){return this.dataManager.getModelInfo(e,t)},getBimtileInfo:function(e,t,i,n){return this.dataManager.getBimtileInfo(e,t,i,n)},getFeatureStyle:function(e,t){return this.dataManager.getFeatureStyle(e,t)},getDimensions:function(e,t,i){return this.dataManager.getDimensions(e,t,i)},getLevelmapping:function(e){return this.dataManager.getLevelmapping(e)},getDrawingTree:function(e,t){return this.dataManager.getDrawingTree(e,t)},getViewsTree:function(e,t){return this.dataManager.getViewsTree(e,t)}},t.MetaDataManager=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").FamilyDataManagerConfig=function(){return{resourceHost:u.resourceHost,databagId:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.HttpRequest,n=function(e){if(!e.databagId)return!1;this.__config=e};n.prototype.getFamilyTypes=function(e,t){let n,o=this.__config;"Local"==o.dataEnvType?(n=`./${o.databagId}/metadata/familyInfo.json`,o.resourcePath&&(n=`${o.resourcePath}/${o.databagId}/metadata/familyInfo.json`)):n=i.getUrl({url:`${o.resourceHost}/${o.databagId}/metadata/familyInfo.json`,path:"metadata/familyInfo.json",...this.__config.httpDefaultParams}),i.ajax({url:n,success:function(t){var i=(t=JSON.parse(t)).Types||t.types;for(let e=0,t=i.length;e{var i=JSON.parse(e);t&&t(i)}})},t.FamilyDataManager=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").IBLManagerConfig=function(){return{resourceHost:u.staticHost}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.HttpRequest,n=function(e){this.__config=e};n.prototype.getIBLConfig=function(e,t){let n,o=this.__config;if("Local"==o.dataEnvType)return!1;n=`${o.resourceHost}/resources/IBL/IBLConfig.json`,i.ajax({url:n,success:function(t){var i=JSON.parse(t);e&&e(i)},failure:e=>{var i=JSON.parse(e);t&&t(i)}})},t.IBLManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i={version:1,EnumObjectTableIndex:{OTI_OBJECTS_VALUES:0,OTI_PROPERTY_SCHEMAS:1,OTI_ELEMENT_PROPERTIES:2,OTI_FAMILY_PROPERTIES:3,OTI_FAMILIES:4,OTI_ELEMENTS:5,OTI_BOUNDING_BOX:6,OTI_ELEMENTS_CLASS:7}},n=function(e){this.url=e,this.objectsDB=[]};n.prototype={load:function(e){var t=this,i=["Values.json","Schemas.json","ElementProperties.json","FamilyTypeProperties.json","Families.json","Elements.json","BoundingBox.json"],n=i.length;i.forEach(((i,o)=>{const s=t.url+"/"+i+CLOUD.GlobalData.ZipResourcePostfix;CLOUD.Storage.IndexedDBHelper.loadWithStorage("InfoData",s,(()=>new Promise(((e,t)=>{(new THREE.FileLoader).load(s,e,void 0,t)}))),(t=>{this.objectsDB[o]=JSON.parse(t),0==(n-=1)&&e()}))}))},getFamilyTypeProperties:function(e){var t=this.objectsDB[i.EnumObjectTableIndex.OTI_FAMILIES][e];if(void 0===t)return null;for(var n=this.objectsDB[i.EnumObjectTableIndex.OTI_OBJECTS_VALUES],o=this.objectsDB[i.EnumObjectTableIndex.OTI_FAMILY_PROPERTIES],s=this.objectsDB[i.EnumObjectTableIndex.OTI_PROPERTY_SCHEMAS],r=0,a=0,l=0,h={},c=[],d=0,u=0,g=t[2],p=t[1];uu[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{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,i=!0){if(!this._enable)return;const n=e=>(")"!==(e=e.toString())[e.length-1]&&(e+="()"),e);i&&(e=n(e),t=n(t));const o=`${e} is obsolete, please use ${t} instead.`;this.setConsoleType("warn"),this.warn(o)}updateDataSource(e){this._enable&&console.error(`[BIMFACE ERROR]:${e} is not compatible with the data source. Please upgrade the data source and try again.`)}open(){this._enable=!0,this.info("Console opened")}close(){this.info("Console closed"),this._enable=!1}}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable(),o=(Object.freeze({TranslucentOthers:"",HideOthers:""}),function(){let t=new e.Web.Lang.EventManager;this.viewerType="Viewer",this.isFullScreen=!1,this._defaultUnit=void 0,S(this),this.getEventManager=function(){return t}});o.prototype.destroy=function(){this.getEventManager=null,this.authenticate=null},o.prototype.init=function(){},o.prototype.getViewerType=function(e){return this.viewerType},o.prototype.addView=function(t,i,o){if(!n)return;this.loadTime||(this.loadTime=(new Date).getTime());let s=this,r=e.Bimface.Authentication.AuthenticationManager,a=(s._opt,new e.Bimface.Authentication.AuthenticationConfig);a.viewToken=t,a.APIHost=this._opt.APIHost,a.enableStorage=this.enableStorage,a.securityApi=this._opt.securityApi,(this.authenticate=new r(a)).authenticate((function(e){"bimView"==e.renderType&&("pdf-transfer"!==e.workerType?e.renderType="3DView":e.renderType="pdfView"),s.loadViewCore(e,i,o)}),(function(t){var i=e.Bimface.Viewer.Viewer3DEvent;s.getEventManager().fireEvent(i.Error,t)}))},o.prototype.loadViewCore=function(){},o.prototype.addEventListener=function(e,t,i){this.getEventManager().addEvent(e,t,i)},o.prototype.removeEventListener=function(e,t){this.getEventManager().removeEvent(e,t)},o.prototype.enableFullScreen=function(t){var i=this._opt.domElement,n=this;this.isFullScreen=t,t?e.Web.Lang.Utility.FullScreen.fullScreen(i):e.Web.Lang.Utility.FullScreen.exitFullScreen(),setTimeout((function(){n.resize()}),200)},o.prototype._loadNotSuportPromptPage=function(e){let t=i.create("div","bf-waring-container"),n=i.create("div","bf-waring"),o=i.create("span","bf-waring-icon"),s=i.create("span","bf-waring-text");s.innerText=BimfaceLanguage.bf_browser_notSupported,n.appendChild(o),n.appendChild(s),t.appendChild(n);let r=i.create("div","bf-suggestion");r.innerText=BimfaceLanguage.bf_browser_suggestion,t.appendChild(r);let a=i.create("div","bf-logo");t.appendChild(a),e.appendChild(t)},o.prototype.getUnit=function(){return"m"===this._defaultUnit?e.Bimface.Common.Units.LengthUnits.Meter:e.Bimface.Common.Units.LengthUnits.Millimeter},o.prototype.getNetwork=function(){const e=window.performance;if(!e)return function(){console.log("您的浏览器不支持performance属性")};const t=[];function i(e,t){const i=e.timing,n={timing:e.timing};return n.redirectTime=i.redirectEnd-i.redirectStart,n.lookupDomainTime=i.domainLookupEnd-i.domainLookupStart,n.connectTime=i.connectEnd-i.connectStart,n.requestTime=i.responseEnd-i.responseStart,n.domReadyTime=i.domComplete-i.domInteractive,n.whiteTime=i.responseStart-i.navigationStart,n.domLoadTime=i.domContentLoadedEventEnd-i.navigationStart,n.loadTime=i.loadEventEnd-i.navigationStart,n.resourceTiming=function(e){const t={entries:e.length,transferSize:0,encodedBodySize:0,decodedBodySize:0};let i=1/0,n=-1/0;return e.forEach((e=>{void 0!==e.duration&&void 0!==e.startTime&&(i=Math.min(i,e.startTime),n=Math.max(n,e.startTime+e.duration)),e.transferSize&&(t.transferSize+=e.transferSize),e.encodedBodySize&&(t.encodedBodySize+=e.encodedBodySize),e.decodedBodySize&&(t.decodedBodySize+=e.decodedBodySize)})),t.transferSize&&(t.transferSize=t.transferSize/1048576),t.encodedBodySize&&(t.encodedBodySize=t.encodedBodySize/1048576),t.decodedBodySize&&(t.decodedBodySize=t.decodedBodySize/1048576),t.finishTime=8*Math.ceil((n-i)/8),t}(t),n.requests=n.resourceTiming.entries,n.transferred=n.resourceTiming.transferSize,n.resourcesSize=n.resourceTiming.decodedBodySize,n.finishTime=n.resourceTiming.finishTime,n}return new PerformanceObserver((e=>{for(let i of e.getEntries())t.push(i)})).observe({entryTypes:["resource","navigation","longtask"]}),function(){return i(e,t)}}(),t.Viewer=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingConfig=function(){return{domElement:null,resourceHost:u.resourceHost,staticHost:u.staticHost+"/api/Glodon",APIHost:u.APIHost,securityApi:u.securityApi,useCustomResources:u.useCustomResources,sdkUrl:null,staticPath:"/api/Glodon",enableLineWidth:!1,displayMode:0,enableHover:!0,enableViewport:!1,enableContextMenu:!0,enableCrossingSelection:!0}},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",DrawingTransformed:"DrawingTransformed",ViewMoving:"ViewMoving",ViewMoved:"ViewMoved",ViewZooming:"ViewZooming",ViewZoomed:"ViewZoomed",Hover:"Hover",ZoomFactorChanged:"ZoomFactorChanged",ButtonOnToolbarClicked:"ButtonOnToolbarClicked",RectSelection:"RectSelection",BoxSelected:"BoxSelected",ZoomEnd:"ZoomEnd",Tap:"Tap",LongTap:"LongTap",Resized:"Resized"});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=[],this.snapCondition={}}setSnap2DList(e){this.snapList=e}getSnap2DList(){return this.snapList}setSnap3DList(e){this.snapList=e}getSnap3DList(){return this.snapList}setSnapConditions(e){this.snapConditions=e,this.snapCondition.objectData=e}getSnapConditions(){return this.snapConditions}setSnapList(e){this.snapList=e}setSnapCondition(e){this.snapCondition=e}getSnapCondition(){return this.snapCondition}}}(),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"),l=e.Bimface.Viewer.ViewerDrawingEvent,h=e.Web.Lang.Utility.DataUtil;o.isInitialized=o.isInitialized||!1;const c={Window:1,Crossing:2};let d=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable(),g=["rgb(50,50,55)","rgb(255,255,255)","rgb(255,255,255)","rgb(50,50,55)"];class p extends e.Bimface.Viewer.Viewer{constructor(t){super(t),n.Viewer.call(this);e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(d){this.viewerType="ViewerDrawing";let n=t;this._opt=t,this.isInitialized=!1,this.hasBindEvents=!1,this.inputDelayTimeInterval=600,this.grids=null,this.snapIsEnabled=!1,this.drawingConsole=new e.Web.Common.Console,this._cache={};var i=t.rootElement||r.create("div","bf-drawing-container"),o=t.domElement;this.drawingIndex=-1,this.isAlignment=!1,this.fileName=t.fileName,this.modelId=t.modelId,this.wrapElement=o,this.visible=!0,this.eventManager=t.eventManager,this.selfEventManager=new e.Web.Lang.EventManager,this.viewToken=t.viewToken,this.movedDistance={x:0,y:0};var s=t.domElement;this._domElement=s,this._viewConfig=n,this.rootElement=i,this.getDomElement=function(){return o},this.getRootElement=function(){return i},this.getViewer=function(){return this._drawingViewer},this.getEventManager=function(){return this.eventManager},this.getSelfEventManager=function(){return this.selfEventManager},this._pressAlt=!1,this._pressCtrl=!1}else this._loadNotSuportPromptPage(t.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");this._opt.useCustomResources&&(t.style.backgroundImage=`url(${u.staticHost}/resources/custom/loading.gif)`),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)}})}enableViewport(e){this._drawingViewer.enableViewport&&this._drawingViewer.enableViewport(e)}showViewById(e){i.send(t,"showViewById"),this._drawingViewer.activeLayoutById(e||0),this.getEventManager().fireEvent(l.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=g[e],this._drawingViewer.setSelectWireframeColor&&this._drawingViewer.enableReplaceElementColor&&this._drawingViewer.replaceElementColor&&(0==e?this._drawingViewer.setSelectWireframeColor(1,1,1,1):3!=e&&this._drawingViewer.setSelectWireframeColor(.733,.733,.733,1),1==e||2==e?(this._drawingViewer.enableReplaceElementColor(!0),this._drawingViewer.replaceElementColor(1,1,1,0,0,0)):this._drawingViewer.enableReplaceElementColor(!1)),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");this.isOfflineMode()||(s=i.getUrl({url:s,path:"manifest.json",APIHost:this._opt.APIHost,loadMode:this._viewMetaData.loadMode,fileId:n.modelId,viewToken:n.viewToken})),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,a){var h,c=this;this.grids=null,n&&(i=i+(s?"/"+s:"")+"/"+n),c._drawingViewer?h=c._drawingViewer:c._drawingViewer=h=t._drawingViewer,h.viewer.SetPreLoad(!0),h.update(),e.Bimface.WebglDrawingSheet.addModel(i,h,(function(i,s,d){if(r){let e=null;for(let t=0;te.id==r));if(i){e=i;break}}e&&(c.currentFrameBoundingBox=e.bbox)}c.drawingIndex=s;for(var u=document.querySelectorAll(".bf-drawing-container .bf-loading"),g=u.length,p=0;p1)c._drawingViewer.activeLayoutById(m[1].id);else if(n){var f=null;for(p=0;p{c.revitInteropReady=!0}}c._drawingViewer.mouseEditorMgr.activeEditorByName("pick"),c._drawingViewer.onViewChanges=function(){c.getEventManager()&&c.getEventManager().fireEvent(l.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,a=!1,h=!1;i&&(s=i.HasLayout,r=i.HasMiniMap,a=i.HasText),(o.split&&o.split.databagId||o.config&&o.config.split)&&(h=!0),n=Object.assign(n,{HasLayout:s,HasMiniMap:r,HasText:a,HasSplitDrawing:h}),c._manifest=Object.assign(e,{Features:n}),t._manifest=Object.assign(e,{Features:n}),c.getSelfEventManager().fireEvent(l.Loaded,c.modelId,c._drawingViewer.mouseEditorMgr,c)})),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(t){let n=t.integrateDrawings&&t.integrateDrawings.databagId||t.databagId;t.drawingUrl=e.Web.Lang.Utility.HttpRequest.getUrl({url:`${o._viewConfig.resourceHost}/${n}/resource/drawing`,path:"resource/drawing",APIHost:o.authenticate.config.APIHost,loadMode:t.loadMode,fileId:t.modelId,viewToken:t.viewToken,modelType:t.modelType}),i(t)}))}getViewScale(){return this._drawingViewer.getViewScale()}getObjectViews(){let e=this.getViews(),t={};for(let i=0;i0){const t=RegExp.$1.split(",");this.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}this.overrideObjectsColorCalled&&this.overrideObjectsColor(this.overrideObjectsColorCalled.option,this.overrideObjectsColorCalled.color),delete this.getViewer().oldBackgoundColorBeforeMoving,this.getEventManager().fireEvent(l.DrawingTransformed),this.updateBoundingBox()}getInformation(){return{modelId:this.modelId,wrap:this.wrapElement,drawing:this,visible:this.visible,fileName:this.fileName}}setDrawingTransformation(e){this.getViewer().setModelTransformation(e,this.drawingIndex),this.getEventManager().fireEvent(l.DrawingTransformed),this.updateBoundingBox()}updateBoundingBox(){0==this.getCurrentViewId()&&this._drawingViewer.viewer.UpdateModelBoxOfDrawingSet&&this._drawingViewer.viewer.UpdateModelBoxOfDrawingSet(),0!=this.getCurrentViewId()&&this._drawingViewer.viewer.UpdateLayoutBoxOfDrawingSet&&this._drawingViewer.viewer.UpdateLayoutBoxOfDrawingSet(this.getCurrentViewId())}getDrawingTransformation(){var e=new Array;const t=this._drawingViewer.viewer.GetAlignMatrixCol(0,this.drawingIndex);e.push(t.get_x()),e.push(t.get_y()),e.push(t.get_z()),e.push(t.get_w());const i=this._drawingViewer.viewer.GetAlignMatrixCol(1,this.drawingIndex);e.push(i.get_x()),e.push(i.get_y()),e.push(i.get_z()),e.push(i.get_w());const n=this._drawingViewer.viewer.GetAlignMatrixCol(2,this.drawingIndex);e.push(n.get_x()),e.push(n.get_y()),e.push(n.get_z()),e.push(n.get_w());const o=this._drawingViewer.viewer.GetAlignMatrixCol(3,this.drawingIndex);return e.push(o.get_x()),e.push(o.get_y()),e.push(o.get_z()),e.push(o.get_w()),h.limitTransformationDecimal(e)}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(l.ComponentsSelectionChanged,e),this.getEventManager().fireEvent(l.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;tn?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;tt?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,n){e.Web.Lang.Utility.HttpRequest.ajax({url:t,success:function(e){var t=JSON.parse(e);t&&i(t)},failure:function(e){n&&n(e)}})}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,c[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{let o;const{references:s}=n;if(Array.isArray(s)){const t=s.reduce(((e,t)=>(Array.isArray(t.items)&&e.push(...t.items),e)),[]);if(Array.isArray(t)){const i=t.find((t=>t.id===e));o=i&&i.name}}const r=this.getLayers();void 0!==o&&Array.isArray(r)&&(i=r.filter((e=>e.name.startsWith(`${o}|`))).map((e=>e.id))),t&&t(i)}),(()=>t&&t(i)))}getExternalReferencesList(e){let t=`${this.url}/externalBlocks.json`;this._ajaxGet(t,e)}fromLinkRevitId(n,o){i.send(t,"fromLinkRevitId");const s=this;if(!s.revitInterop){const t=new e.Bimface.RevitInterop;t.initialize(this._drawingViewer,this._drawingViewer.model.Url),s.revitInterop=t,s.revitInteropReady=!1,t.callback=()=>{s.revitInteropReady=!0}}return s.revitInterop.fromLinkRevitId(n,o)}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){var o=e.Web.Lang.Utility.HttpRequest,s=n.split&&n.split.databagId||n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,r=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||i._viewConfig.resourceHost)+"/"+s+"/resource/drawing/Frames");!i.isOfflineMode()&&(r=o.getUrl({url:r,path:"resource/drawing/Frames",APIHost:i._opt.APIHost,loadMode:i._viewMetaData.loadMode,fileId:n.modelId,viewToken:n.viewToken,workerType:"drawing-split"})),i.getIndexJson(r,t)}}getLayerIdsByObjects(e){let t=[];for(let i=0;i{const t=e.portsAndViews[0],i=t.elevation||0,n=t.viewPoint.upDirection;if(this._isPlan(t.viewPoint.viewDirection)){let e=l;const t=a.GetActiveLayoutId();if(t){const i=a.GetIntersectViewportIdList(t,l.x,l.y);i.size()&&(e=a.LayoutToModel(l.x,l.y,i.at(0)))}e=this._getRotatePoint([n[0],n[1]],[0,1],e),s&&s({x:e.x,y:e.y,z:i})}else s&&s(null)}),this.intergratedFileId,c)}_getRotatePoint(e,t,i){return function(e,t){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),s=i/o,r=n/o,a=Math.cos(t),l=Math.sin(t),h=r*a+s*l;return{x:(o*(s*a-r*l)).toFixed(4)-0,y:(o*h).toFixed(4)-0}}(i,((i,n)=>{let o=Math.sqrt(i.reduce(((e,t)=>e+Math.pow(t,2)),0)),s=Math.sqrt(n.reduce(((e,t)=>e+Math.pow(t,2)),0)),r=Math.acos(i.reduce(((e,t,i)=>e+t*n[i]),0)/(o*s));return r=e[0]*t[1]-e[1]*t[0]<0?r:2*Math.PI-r,r})(e,t))}_isPlan(e){return 0===e[0]&&0===e[1]&&1===e[2]}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");!i.isOfflineMode()&&(s=e.Web.Lang.Utility.HttpRequest.getUrl({url:s,path:"resource/drawing/drawingFeatures.json.gz",APIHost:i._opt.APIHost,loadMode:i._viewMetaData.loadMode,fileId:n.modelId,viewToken:n.viewToken})),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-1||e.layerIds.indexOf(n[t].id.toString())>-1)&&(n[t].visible=!1);this.changeLayers(n)}highlight(e){if(e.objectIds&&(Array.isArray(e.objectIds)||(e.objectIds=[e.objectIds]),e.viewportId?this._drawingViewer.highlightIdsWithViewport(e.objectIds,this.drawingIndex,e.viewportId):this._drawingViewer.highlightByIds2(e.objectIds,this.drawingIndex)),e.layerIds){let t=[];e.layerIds.map((e=>{const i=this.getObjectsByLayerId(e);t=[...new Set([...t,...i])]})),this._drawingViewer.highlightByIds2(t,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.overrideObjectsColorCalled={option:e,color:t},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;let r=this;this.getDrawingFeatures((function(e){if(e){let a,l=[];if(0==i)a=e.text.model.data;else{const t=n.find((e=>e.id==i));a=e.text.layouts.find((e=>e.name==t.name)).data}for(let e=0;eo.x&&s.x>a.max.x&&o.ya.max.y&&l.push({content:t,boundingBox:a})}}let h=l;if(l.length>0){l.sort(((e,t)=>t.boundingBox.min.y-e.boundingBox.min.y));const e=l[Math.ceil(l.length/2)-1],t=e.boundingBox.max.y-e.boundingBox.min.y;h=[];const i=e=>{let n=e[0],o=[n];for(let s=1;se.boundingBox.min.x-t.boundingBox.min.x)),h=h.concat(o),i(e.slice(s));o.push(r),n=r}o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),h=h.concat(o)};i(l)}t(h)}else t(null)}))}setMovedDistance(e){this.movedDistance.x+=e[0],this.movedDistance.y+=e[1]}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),this.getEventManager().fireEvent(l.DrawingTransformed),this.updateBoundingBox()}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-1){let e=[];for(let i=0;ir[0]||n.currentFrameBoundingBox[1]>r[1]||n.currentFrameBoundingBox[2]0&&s.push({viewId:r[a],content:o[t].content,modelId:n.modelId,data:e})}}t(s)}else i(null)}))}select(e){if(e.objectIds){Array.isArray(e.objectIds)||(e.objectIds=[e.objectIds]);let t=[],i=[];e.objectIds.map((e=>{e.toString().indexOf(".")>-1?t.push(e):i.push(e)})),e.viewportId?this._drawingViewer.selectIdsWithViewport(i,this.drawingIndex,e.viewportId):this._drawingViewer.selectByIds2(i,this.drawingIndex),t.length>0&&t.map((e=>{const t=e.toString().split(".");this._drawingViewer.selectIdWithBlock(t[0],t[1])}))}if(e.layerIds){let t=[];e.layerIds.map((e=>{const i=this.getObjectsByLayerId(e);t=[...new Set([...t,...i])]})),this._drawingViewer.selectByIds2(t,this.drawingIndex)}this.update(!0)}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){this.getViewer().layerStartTime=(new Date).getTime();const n=this.getLayers();i.send(t,"showLayers");for(let t=0;t-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),e.viewportId?this._zoomToViewportObject(e,n):(this._drawingViewer.zoomToObject(e.objectId,n,this.drawingIndex),this.selectByIds(e.objectId),this.getEventManager().fireEvent(l.DrawingTransformed))}_zoomToViewportObject(e,t){const i=e.objectId,n=e.viewportId,o=this._drawingViewer.viewer.GetLayoutIdByViewportId(n,this.drawingIndex);if(-1==o)return;this.showViewById(o);const s=this._drawingViewer.getObjectBoundingBox(i,this.drawingIndex);if(this._drawingViewer.viewer.IsModelElementIdInViewportId(i,n,this.drawingIndex)){const e=this._drawingViewer.viewer.ToViewportBoxMinMax(s[0][0],s[0][1],s[0][2],s[1][0],s[1][1],s[1][2],n,this.drawingIndex),i=e.GetMinPt(),o=e.GetMaxPt();this._zoomToBoundingBox([[i.x,i.y,i.z],[o.x,o.y,o.z]],t)}else this._zoomToBoundingBox([s[0],s[1]],t);this._drawingViewer.viewer.SelectIdWithViewport(i,this.drawingIndex,n),this.getEventManager().fireEvent(l.DrawingTransformed)}_zoomToBoundingBox(e,t=.5){if("2"!==this.version)return void this.drawingConsole.info("Drawing of old version doesn't support zoomToBoundingBox.");if(!e)return void this.drawingConsole.info("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()}toModelId(e){i.send(t,"toModelId");const n=e&&e.toString().indexOf(".")>0;let o;n&&(o=e.split("."));let s=this.revitInterop.toRevitId(o&&o[0]||e);if(n){var r=this.getViewer().revitInterop.toLinkRevitId(o[0],o[1]);if(r instanceof Object){s=r.fileId+"."+r.revitId}}return s}toDrawingId(e,t){const i=(e,t)=>e&&(0==e.blockId||e.blockId)?e.ids?`${e.blockId}.${e.ids[0]}`:this.revitInterop.fromRevitId(t.toString().split(".")[1]):e;if(!t)return i(e&&e.indexOf(".")>-1?this.revitInterop.fromLinkRevitId(e.split(".")[0],e.split(".")[1]):this.revitInterop.fromRevitId(e),e);{const n=()=>{const n=e&&e.indexOf(".")>-1?this.revitInterop.fromLinkRevitId(e.split(".")[0],e.split(".")[1]):this.revitInterop.fromRevitId(e);t(i(n,e))};this.revitInteropReady?n():this.revitInterop.callback=()=>{this.revitInteropReady=!0,n()}}}_ajaxPost(t,i={}){return(0,e.Web.Lang.Utility.HttpRequest.promiseJSONRequest)({type:"post",url:t+`?view_token=${this._opt.viewToken}`,headers:{"Content-Type":"application/json"},data:JSON.stringify(i)})}getExplodeElementsProperties(n,o,s){i.send(t,"getExplodeElementsProperties");const r=e.Web.Lang.Utility.ClientHelper.formatURL(this._viewConfig.APIHost+`/data/v1/files/${this._viewMetaData.modelId}/explode-drawing-elements/properties`);this._ajaxPost(r,{explodeElementIds:n}).then(o,s)}getElementsProperties(n,o,s){i.send(t,"getElementsProperties");const r=e.Web.Lang.Utility.ClientHelper.formatURL(this._viewConfig.APIHost+`/data/v1/files/${this._viewMetaData.modelId}/drawing-elements/properties`);this._ajaxPost(r,{elementIds:n}).then(o,s)}destroy(){this.getViewer()&&this.getViewer().releaseModel(this.drawingIndex),this._opt=null,this.drawingConsole=null,this._cache=null,this.wrapElement=null,this.eventManager=null,this.selfEventManager=null,this.movedDistance=null,this._domElement=null,this._viewConfig=null,this.rootElement=null,this.loading=null,this._drawingViewer=null,this.authenticate=null,this.modelBBox=null,this.grids=null,this._timeHandle&&(clearTimeout(this._timeHandle),this._timeHandle=null),this.tempSnapPoint=null,this.overrideObjectsColorCalled=null,this._selectionChangedInfo=null,this._drawingFeatures=null,this.revitInterop=null}}n.Drawing=p}(),function(e){if("undefined"!=typeof module&&module.exports)return function(e){module.exports=e()};if("function"==typeof define&&define.amd)return define;if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")}()((function(){function e(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function t(e,t){var i,n,o=e.length;if(!o||!t)return!1;for(i=t.toLowerCase(),n=0;n=0&&(n=n.substring(0,h)+"([\\w._\\+]+)"+n.substring(h+5)),t[a]=new RegExp(n,"i");c.props[e]=t}i(c.oss),i(c.phones),i(c.tablets),i(c.uas),i(c.utils),c.oss0={WindowsPhoneOS:c.oss.WindowsPhoneOS,WindowsMobileOS:c.oss.WindowsMobileOS}}(),s.findMatch=function(e,t){for(var i in e)if(r.call(e,i)&&e[i].test(t))return i;return null},s.findMatches=function(e,t){var i=[];for(var n in e)r.call(e,n)&&e[n].test(t)&&i.push(n);return i},s.getVersionStr=function(e,t){var i,n,o,a,l=s.mobileDetectRules.props;if(r.call(l,e))for(o=(i=l[e]).length,n=0;n1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},s.isMobileFallback=function(e){return s.detectMobileBrowsers.fullPattern.test(e)||s.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},s.isTabletFallback=function(e){return s.detectMobileBrowsers.tabletPattern.test(e)},s.prepareDetectionCache=function(e,t,i){var o,r,a;if(e.mobile===M)return(r=s.findMatch(s.mobileDetectRules.tablets,t))?(e.mobile=e.tablet=r,void(e.phone=null)):(o=s.findMatch(s.mobileDetectRules.phones,t))?(e.mobile=e.phone=o,void(e.tablet=null)):void(s.isMobileFallback(t)?(a=n.isPhoneSized(i),a===M?(e.mobile=s.FALLBACK_MOBILE,e.tablet=e.phone=null):a?(e.mobile=e.phone=s.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=s.FALLBACK_TABLET,e.phone=null)):s.isTabletFallback(t)?(e.mobile=e.tablet=s.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null)},s.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},s.detectOS=function(e){return s.findMatch(s.mobileDetectRules.oss0,e)||s.findMatch(s.mobileDetectRules.oss,e)},s.getDeviceSmallerSide=function(){return window.screen.width=0){w=v[e].substring(0,v[e].indexOf("Build/"));break}}r.trackObj.osVersion=f,r.trackObj.modelName=w}if(this._elementEventListeners=[],this._addElementEventListener=({element:e,type:t,listener:i,useCapture:n})=>{e&&t&&i&&e.addEventListener(t,i,n),this._elementEventListeners.push({element:e,type:t,listener:i,useCapture:n})},this._removeAllElementEventListener=()=>{this._elementEventListeners.forEach((({element:e,type:t,listener:i,useCapture:n})=>{e&&t&&i&&e.removeEventListener(t,i,n)})),this._elementEventListeners=[]},s)h=a.create("div","bf-drawing-wrap");else{let t="bf-drawing-wrap bf-mobile";if(o.MobileToolbars&&o.MobileToolbars instanceof Array||o.MobileButtons&&o.MobileButtons instanceof Array){o.Toolbars=o.MobileToolbars=o.MobileToolbars?o.MobileToolbars:o.DefaultMobileToolbars,o.MobileButtons=o.MobileButtons?o.MobileButtons:o.DefaultMobileButtons;const i=o.MobileButtonsMap;o.Buttons=[],o.MobileButtons.forEach((e=>i[e]&&o.Buttons.push(i[e]))),t=e.Web.Lang.Utility.ClientHelper.getIsTablet()?"bf-drawing-wrap bf-mobile bf-mobile-new bf-tablet":"bf-drawing-wrap bf-mobile bf-mobile-new",this.isMobileNew=!0,this._addElementEventListener({element:document,type:"touchstart",listener:e=>{e.touches.length>1&&e.preventDefault()}}),this._addElementEventListener({element:document,type:"gesturestart",listener:e=>{e.preventDefault()}})}if(h=a.create("div",t),this.isMobileNew)h.style.fontSize=l.getFontSize();else{var y=o.domElement.offsetWidth,b=o.domElement.offsetHeight;h.style.fontSize=90*Math.min(y,b,414)/750+"px"}}h.id=e.Web.Lang.Utility.UUID.createUUID(),o.Toolbars=[...new Set(o.Toolbars)];let P=[];o.Buttons&&o.Buttons.forEach((e=>{"DividerLine"!=e&&-1!=P.indexOf(e)||P.push(e)})),o.Buttons=P,delete o.DefaultMobileToolbars,delete o.DefaultMobileButtons,delete o.MobileButtonsMap;var x,E=o.domElement;E.addClass("viewerDrawingWrap"),E.id?x=E.id:(x=e.Web.Lang.Utility.UUID.createUUID(),E.id=x),u.id="Drawing"+h.id,u.setCss({width:"100%",height:"100%",position:"relative",zIndex:1,background:0==this._opt.displayMode?"rgb(50, 50, 55)":""}),h.setCss({width:"100%",height:"100%",position:"relative",overflow:"hidden"}),h.appendChild(u),E.appendChild(h),n.domElement=u,this._domElement=E,this._viewConfig=n,this.rootElement=u,this.getIsMobileNew=function(){return this.isMobileNew},this.getDomElement=function(){return h},this.getRootElement=function(){return u},this.getViewer=function(){return this._drawingViewer},this._destroyCursor=e.Web.Lang.Utility.MouseMotion.setCursor(this),this.customHomeview=null,this.defaultHomeview=null,this.isBoxSelection=!1,this._pressAlt=!1,this._pressCtrl=!1;let M=null,C=null;s?(this._addElementEventListener({element:document,type:"keydown",listener:e=>{var t=e.keyCode||e.which||e.charCode;18==t?this._pressAlt=!0:17==t&&(this._pressCtrl=!0)}}),this._addElementEventListener({element:document,type:"keyup",listener:e=>{var t=e.keyCode||e.which||e.charCode;18==t?this._pressAlt=!1:17==t&&(this._pressCtrl=!1)}}),this._addElementEventListener({element:h,type:"mouseleave",listener:()=>{this._pressAlt=!1,this._pressCtrl=!1}}),this._addElementEventListener({element:h,type:"mousedown",listener:function(e){h.oldMouseX=e.clientX,h.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.isBoxSelection||r._pressCtrl||r._pressAlt)&&(e.stopPropagation(),M=i),r.mouseHasBeenClicked=!0}}),this._addElementEventListener({element:h,type:"mousemove",listener:function(e){if(r._drawingViewer){if(M&&(r.isBoxSelection||r._pressCtrl||r._pressAlt)){e.stopPropagation();let t=r.getDomElement().getBoundingClientRect();C={x:e.clientX-t.left,y:e.clientY-t.top},r.getEventManager().fireEvent(c.RectSelection,{rectSelectStart:M,rectSelectEnd:C,finish:!1}),r._drawingViewer.rectStartTime=(new Date).getTime()}else r.dragIsEnable&&r.mouseHasBeenClicked&&r._drawingViewer.zoomOrMoveObj&&(r._drawingViewer.zoomOrMoveObj.isEnd=!1,r._drawingViewer.zoomOrMoveObj.debounceCountZoomOrMoveFn(),r._drawingViewer.zoomOrMoveObj.iterationStart||r._drawingViewer.zoomOrMoveObj.isZooming||(r._drawingViewer.zoomOrMoveObj.frameCount=0,r._drawingViewer.zoomOrMoveObj.countFps(),r._drawingViewer.zoomOrMoveObj.moving=!0));if(r._drawingViewer&&r.loadedDrawings.length>0&&r.authenticate&&r.authenticate.data.config&&"true"==r.authenticate.data.config["integrate-with-links"]){const t=r.getDomElement().getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;r.getViewer().disableSelectInBlock(),r._drawingViewer.preSelect(i,n,!1,!1);const o=r._drawingViewer.getHighlightIds(r.loadedDrawings[0].drawing.drawingIndex);o[0]&&r._drawingViewer.linkedIds&&r._drawingViewer.linkedIds.indexOf(o[0].toString())>-1?r.enableSelectInBlock():r.getViewer().disableSelectInBlock()}}},useCapture:!0}),this._addElementEventListener({element:h,type:"mouseup",listener:function(e){if(!r._drawingViewer)return;r.mouseHasBeenClicked=!1;const t=Math.abs(this.oldMouseX-e.clientX)<=1&&Math.abs(this.oldMouseY-e.clientY)<=1;let i,n,o,s=this.getBoundingClientRect(),a={};function l(){var t,s=[],l=[],h=[];if(t=r._drawingViewer.toWorldPoint([i,n]),r._opt.enableHover&&(r._drawingViewer.preSelect(i,n,!1,!1),r.loadedDrawings.length>0?r.loadedDrawings.map((e=>{const t=r._drawingViewer.getHighlightIds(e.drawing.drawingIndex);t.length>0&&(s=[...s,...t],l.push(e.drawing.modelId),h.push(e.drawing.drawingIndex))})):s=r._drawingViewer.getHighlightIds()),a={worldPosition:{x:t[0],y:t[1]},clientPosition:o,objectId:s[0]||null,clientX:e.clientX,clientY:e.clientY,event:e,eventType:0===e.button?"Click":"RightClick"},a.objectId){let e=r.getLayerIdFromElementId(a.objectId,r.loadedDrawings.length>0&&h[0]||0),t=r.loadedDrawings.length>0?r.getDrawing(l[0]).getLayerById(e):r.getLayerById(e);a.layerId=e||null,a.layerName=t&&t.name||null,r.loadedDrawings.length>0?a.modelId=l[0]:r._viewMetaData&&r._viewMetaData.modelId&&(a.modelId=r._viewMetaData.modelId)}else a.layer=null;if(r.grids&&(a.grid=r.getNearestGrid({x:i,y:n})),r.snapIsEnabled){var d=r._drawingViewer.snapToPoint(i,n);if(d.GetPoint().length>0){var u,g=d.GetSnapType(),p={x:d.GetPoint()[0],y:d.GetPoint()[1]},m=d.GetViewPortId&&d.GetViewPortId();if(!d.GetID()){let e=r._drawingViewer.toScreenPoint(d.GetPoint()),t=r._drawingViewer.toModelWorld(e);p={x:t[0],y:t[1]},m=t[2]}u=m&&m>0?r._drawingViewer.toViewportScreenPoint([p.x,p.y],m,d.GetDrawingIndex()):r._drawingViewer.toScreenPoint(d.GetPoint()),o={x:u[0],y:u[1]};var f=r._drawingViewer.toWorldPoint([o.x,o.y]);a.snapPoint={type:g,clientPosition:o,worldPosition:{x:f[0],y:f[1]}},m&&m>0&&(a.snapPoint.viewportPosition=p)}}a.selfDrawing=r,a.objectId&&r._drawingViewer.viewer.IsViewportElement&&r._drawingViewer.viewer.IsViewportElement(a.objectId)&&(a.objectType="Viewport"),r.getEventManager().fireEvent(c.MouseClicked,a)}if(i=e.clientX-s.left,n=e.clientY-s.top,o={x:i,y:n},t){if(!e.target.hasClass("bf-drawable-context")&&"canvas"!=e.target.tagName.toLocaleLowerCase()&&!e.target.hasClass("bf-rect-selcetion")&&!e.target.hasClass("bf-measure-svg"))return;if(2!==e.button||r.isMeasuring||r._drawingViewer.isDrawingMoving){if(0===e.button){if(M&&(I&&r.getViewer().dom.removeChild(T),M=null,I=!1),l(),"2"!=(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version)return;const t=r.getSelectedElements();r._pressCtrl&&(e.stopPropagation(),t.indexOf(a.objectId)>-1?r.removeSelectId(a.objectId):r.selectByIds(a.objectId,r.loadedDrawings.length>0?a.modelId?r.getDrawing(a.modelId).drawingIndex:r.loadedDrawings[0].drawing.drawingIndex:0,!0)),r._pressAlt&&console.log(a)}}else{if((e.path?e.path:e.composedPath()).some((e=>e.hasClass&&e.hasClass("bf-drawingFrame-panel")))&&!h.hasClass("drawingFrameMark"))return;if(e.stopPropagation(),l(),"2"!=(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version||!r._opt.enableContextMenu)return;let t=r.getDomElement().getBoundingClientRect(),i={x:e.clientX-t.left,y:e.clientY-t.top},n={width:t.width,height:t.height};var d={};d.clientPosition=i,d.containerBox=n,r.getEventManager().fireEvent(c.ContextMenu,d)}}else if(0===e.button){if(r._pressCtrl||r._pressAlt||r.isBoxSelection){if("2"!=(r.loadedDrawings.length>0?r.loadedDrawings[0].drawing:r).version||!r._opt.enableCrossingSelection)return;e.stopPropagation(),r.getEventManager().fireEvent(c.RectSelection,{rectSelectStart:M,rectSelectEnd:C,finish:!0})}else r._drawingViewer.zoomOrMoveObj&&r._drawingViewer.zoomOrMoveObj.stopCount(),M&&(I&&r.getViewer().dom.removeChild(T),M=null,I=!1);!r.isBoxSelection&&r.getEventManager().fireEvent(c.MouseDragged,{clientPosition:o})}},useCapture:!0})):(this._addElementEventListener({element:u,type:"touchstart",listener:function(e){if(e.target.hasClass("bf-drawable-context")||"canvas"==e.target.tagName.toLocaleLowerCase()){var t=e.targetTouches[0];r.startTime=(new Date).getTime(),u.oldTouchX=t.clientX,u.oldTouchY=t.clientY,r._drawingViewer.zoomOrMoveObj&&(r._drawingViewer.zoomOrMoveObj.isEnd=!1,r._drawingViewer.zoomOrMoveObj.iterationStart||r._drawingViewer.zoomOrMoveObj.isZooming||(r._drawingViewer.zoomOrMoveObj.frameCount=0,r._drawingViewer.zoomOrMoveObj.countFps(),r._drawingViewer.zoomOrMoveObj.moving=!0))}}}),this._addElementEventListener({element:u,type:"touchend",listener:function(e){var t,i,n,o=e.changedTouches[0],s=this.oldTouchX==o.clientX&&this.oldTouchY==o.clientY,a=this.getBoundingClientRect(),l={};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 h,d;if(d=r._drawingViewer.toWorldPoint([t,i]),r._drawingViewer.preSelect(t,i,!1,!1),h=r._drawingViewer.getHighlightIds(),(l={worldPosition:{x:d[0],y:d[1]},clientPosition:n,objectId:h[0]||null,clientX:o.clientX,clientY:o.clientY,event:e}).objectId){let e=r.getLayerIdFromElementId(l.objectId,r.loadedDrawings.length>0&&r.loadedDrawings[0].drawingIndex||0),t=r.getLayerById(e);l.layerId=e||null,l.layerName=t&&t.name||null}else l.layer=null;r.grids&&(l.grid=r.getNearestGrid({x:t,y:i})),l.selfDrawing=r,l.objectId&&r._drawingViewer.viewer.IsViewportElement&&r._drawingViewer.viewer.IsViewportElement(l.objectId)&&(l.objectType="Viewport"),r.isMobileNew&&(r.endTime=(new Date).getTime(),(new Date).getTime()-r.startTime>=1e3?r.getEventManager().fireEvent(c.LongTap,l):r.getEventManager().fireEvent(c.Tap,l)),r.getEventManager().fireEvent(c.MouseClicked,l)}else l={clientPosition:n},r.getEventManager().fireEvent(c.MouseDragged,l),r._drawingViewer.zoomOrMoveObj&&(r._drawingViewer.zoomOrMoveObj.debounceCountZoomOrMoveFn(),r._drawingViewer.zoomOrMoveObj.stopCount())}}));const T=a.create("div","bf-rect-selcetion");let I=!1;r.addEventListener(c.RectSelection,(function(e){const{finish:n}=e;if(M&&C){const e={x:Math.min(M.x,C.x),y:Math.min(M.y,C.y)},t={x:Math.max(M.x,C.x),y:Math.max(M.y,C.y)};let i=M.x0?r.loadedDrawings.map((e=>{const t=e.drawing.getObjectsByBoundingBox(r.getCurrentViewId(!0),s,d[i]);a=[...a,...t]})):a=r.getElementsByBoundingBox(r.getCurrentViewId(!0),s,d[i]),a.length&&a.length>0){let e="selectElementsByBoundingBox";r._pressAlt&&(e="removeSelectElementIdsByBoundingBox"),r.loadedDrawings.length>0?r.loadedDrawings.map((t=>{r._drawingViewer[e](r.getCurrentViewId(!0),s,d[i],t.drawing.drawingIndex)})):r._drawingViewer[e](r.getCurrentViewId(!0),s,d[i]),r.update();const t=r.getSelectedElements();r.getEventManager().fireEvent(c.SelectionChanged,t)}}}else{const t=Math.abs(M.x-C.x),n=Math.abs(M.y-C.y);T.setCss({left:`${e.x}px`,top:`${e.y}px`,width:`${t}px`,height:`${n}px`,zIndex:1,background:"rgba(185,255,235,0.3)",border:`2px ${"Window"===i?"solid":"dashed"} rgba(0,130,94,1)`}),r._opt.enableCrossingSelection&&r.getViewer().dom.appendChild(T)&&(I=!0)}}if(n&&(function(e,t){if(e&&t){let i={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)},n={x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)},o=e.xe+=t)),r.trackObj.boxSelection=Math.round(e/r._drawingViewer.rectSelectionTime.length),r.trackObj.eventId="图纸加载",i.send(t,"RectSelection",r.trackObj),i.intervalAction()}})),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(c.Loaded,(function(){r.defaultHomeview=r.getState(),window.bimfaceSdkVersion&&(i.send(t,"sdkVersion"),delete window.bimfaceSdkVersion)}))}else this._loadNotSuportPromptPage(o.domElement)};s.Type.inheritPrototype(f,n.Viewer),f.prototype=Object.assign({},n.Viewer.prototype,{addModel:function(n,s,r,a){if(i.send(t,"addModel"),!g||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,c,d=this,u=(d.getViewer(),d._opt,n.dataPath,n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId),p=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||this._viewConfig.resourceHost)+"/"+u+"/resource/drawing");if(n.drawingUrl=p,d._data=n,null!=a){c=!0;let t=n.split&&n.split.databagId;h=t?e.Web.Lang.Utility.ClientHelper.formatURL((n.path||d._viewConfig.resourceHost)+"/"+t+"/resource/drawing/Frames"):p+"/Frames"}else h=p,c=!1;c&&this.getDomElement().addClass("drawingFrame");d.isInitialized||o.isInitialized?d.loadIndexJson(n,s,r,(function(){"1"==d.version||"1"==d.prevVersion?d.destroy(!0,!0):d.destroy(),"1"==d.version&&(d._drawingViewer=d.createDrawingViewer(d.rootElement.id)),d._drawingViewer&&d._drawingViewer.clearAll(),"2"==d.version?d.loadWebGL(h,s,r,a):d.loadModel(h,s,r),d._viewMetaData=n})):d.loadIndexJson(n,s,r,(function(){"1"==d.version||"1"==d.prevVersion?d.destroy(!0,!0):d.destroy();var t=n.sdkPath?n.sdkPath+"/bimface":n.sdkPath;if("bimView"==n.renderType&&n.subRenders&&0!=n.subRenders.length)for(var i=0;i0&&(this.loadedDrawings.forEach((e=>{e.drawing.destroy(),e.drawing=null})),this.loadedDrawings=null),this._drawingViewer&&(this._drawingViewer.destroy&&this._drawingViewer.destroy(),this._drawingViewer=null);for(var n=document.querySelectorAll("#"+this.rootElement.id+" canvas"),o=0;o0&&(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){var o=e.Web.Lang.Utility.HttpRequest,s=n.split&&n.split.databagId||n.integrateDrawings&&n.integrateDrawings.databagId||n.databagId,r=e.Web.Lang.Utility.ClientHelper.formatURL((n.path||i._viewConfig.resourceHost)+"/"+s+"/resource/drawing/Frames");i.authenticate&&(r=o.getUrl({url:r,path:"resource/drawing/Frames",APIHost:i.authenticate.config.APIHost,loadMode:i.authenticate.data.loadMode,fileId:n.modelId,viewToken:n.viewToken,workerType:"drawing-split"})),i.getIndexJson(r,t)}},loadFrame(t,i){let n=this;this.destroy(),this.showLoading();var o=this.getDomElement();o.addClass("drawingFrame"),o.addClass("drawingFrameMark"),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;r?(s=e.Web.Lang.Utility.ClientHelper.formatURL((t.path||n._viewConfig.resourceHost)+"/"+r+"/resource/drawing/Frames"),s=h.getUrl({url:s,path:"resource/drawing/Frames",APIHost:n.authenticate.config.APIHost,loadMode:n.authenticate.data.loadMode,fileId:t.modelId,viewToken:t.viewToken,workerType:"drawing-split"})):s=t.drawingUrl+"/Frames",n._drawingViewer&&n._drawingViewer.clearAll(),n.loadWebGL(s,null,null,i,!0),n._viewMetaData=t}))}))},load:function(e,t,i){this.loadDrawing({viewToken:e,sheetId:t,fileId:i})},loadIndexJson:function(t,i,n,s){let r=this,a=t.drawingUrl;i&&(a=a+(n?"/"+n:"")+"/"+i),this.url=a,this.getIndexJson(a,(function(i){var n=document.querySelector(".bf-drawing-container .bf-loading-text");if(r.version&&(r.prevVersion=r.version),"2"==i.metadata.version||"2"==i.metadata["version:"])r.version="2",n&&(n.innerText="0%"),s(i);else{if(r.version="1",n&&(n.innerText=BimfaceLanguage.bf_load),o.isInitialized)return void s(i);if("bimView"==t.renderType&&t.subRenders&&0!=t.subRenders.length)for(var a=0;a0?this.loadedDrawings[0].drawing.drawingIndex:0)},getModelPosition:function(n,o,s){i.send(t,"getModelPosition"),this.obsoleteOld("ViewerDrawing.getModelPosition","ViewerDrawing.getDrawing(modelId).getModelPosition");const r=this.getViewer().viewer;let a,l;a=this.loadedDrawings.length<1?this.authenticate.data.databagId:this.loadedDrawings[0].drawing._viewMetaData.databagId,l=o&&void 0!==o.x&&void 0!==o.y?o:Array.isArray(o)?{x:o[0],y:o[1]}:{x:0,y:0},this.loadedDrawings.length>0&&(this._viewMetaData=this.loadedDrawings[0].drawing._viewMetaData);let h=this._viewMetaData||this._data,c=this.authenticate?{APIHost:this.authenticate.config.APIHost,loadMode:this.authenticate.data.loadMode,fileId:h.modelId,viewToken:h.viewToken}:{};e.Web.Graphics.Utility.Relation.getDrawingSheets(a,n,(e=>{const t=e.portsAndViews[0],i=t.elevation||0,n=t.viewPoint.upDirection;if(this._isPlan(t.viewPoint.viewDirection)){let e=l;const t=r.GetActiveLayoutId();if(t){const i=r.GetIntersectViewportIdList(t,l.x,l.y);i.size()&&(e=r.LayoutToModel(l.x,l.y,i.at(0)))}e=this._getRotatePoint([n[0],n[1]],[0,1],e),s&&s({x:e.x,y:e.y,z:i})}else s&&s(null)}),null,c)},_getRotatePoint:function(e,t,i){return function(e,t){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),s=i/o,r=n/o,a=Math.cos(t),l=Math.sin(t),h=r*a+s*l;return{x:(o*(s*a-r*l)).toFixed(4)-0,y:(o*h).toFixed(4)-0}}(i,((i,n)=>{let o=Math.sqrt(i.reduce(((e,t)=>e+Math.pow(t,2)),0)),s=Math.sqrt(n.reduce(((e,t)=>e+Math.pow(t,2)),0)),r=Math.acos(i.reduce(((e,t,i)=>e+t*n[i]),0)/(o*s));return r=e[0]*t[1]-e[1]*t[0]<0?r:2*Math.PI-r,r})(e,t))},_isPlan:function(e){return 0===e[0]&&0===e[1]&&1===e[2]},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(),this._drawingViewer.trackShowOrHideLayers&&this._drawingViewer.trackShowOrHideLayers()},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),this.getViewer().layerStartTime=(new Date).getTime(),i.send(t,"hideLayer");for(var o=this.getLayers(!0),s=0,r=o.length;s1)l._drawingViewer.activeLayoutById(d[1].id);else if(i){var u,g=null;for(h=0;h0?u.initialize(a,l.loadedDrawings[0].drawing.model.Url):u.initialize(a),a.revitInterop=u,l.revitInteropReady=!1,u.callback=()=>{l.revitInteropReady=!0}}let p=e.Web.Lang.Utility.ClientHelper.getIsDesktop();const{name:m}=e.Web.Lang.Utility.ClientHelper.getDesktopType(),f=m.indexOf("win")>=0;l._drawingViewer.mouseEditorMgr=f?e.Bimface.WebglDrawingSheet.createMouseAndTouchEditorManager(a):p?e.Bimface.WebglDrawingSheet.createMouseEditorManager(a):e.Bimface.WebglDrawingSheet.createTouchEditorManager(a),l._drawingViewer.mouseEditorMgr.bindEvents(),l.observer(l._drawingViewer.mouseEditorMgr),l._drawingViewer.mouseEditorMgr.activeEditorByName("pick"),l._drawingViewer.mouseEditorMgr.zoomStart=function(){this._timeHandle&&(clearTimeout(this._timeHandle),this._timeHandle=null)},l._drawingViewer.mouseEditorMgr.zoomEnd=function(){this._timeHandle=setTimeout((()=>{l.getEventManager().fireEvent(c.ZoomEnd)}),l.inputDelayTimeInterval)},l._drawingViewer.onViewChanges=function(){l.getEventManager()&&l.getEventManager().fireEvent(c.Rendered,l._drawingViewer)},l.setDisplayMode(l._opt.displayMode),!l._opt.enableViewport&&l.home(),l.getManifest((function(e){let t=(e=e||{}).Features,i=Object.assign({},t||{}),n=l._viewMetaData||l._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}),l._manifest=Object.assign(e,{Features:i}),l.getEventManager().fireEvent(c.Loaded,l._drawingViewer.mouseEditorMgr)})),l.enableHover(l._opt.enableHover)}),s)},observer(t){let i=null,n=this;t.observer=function(t,o,s,r,a,l){if("zoom"==t&&"exit"==o&&(n.getEventManager().fireEvent(c.ViewZoomed),n._opt.enableZoomRect=!1),"zoomFactorChanged"==o&&n.getEventManager().fireEvent(c.ZoomFactorChanged,s),("DistanceMeasure"==t||"AngleMeasure"==t||"AreaMeasure"==t||"PolylineDistanceMeasure"==t)&&"change"==o){var h=n.getViewScale(),d=null;s&&"Distance"===s.type?d="measured"===s.status?{type:s.type,distance:s.distance*h,points:s.points,start:[s.start[0]*h,s.start[1]*h],end:[s.end[0]*h,s.end[1]*h],viewPortId:s.viewPortId,isOnLayout:s.isOnLayout,drawingIndex:s.drawingIndex,drawingIndexes:s.drawingIndexes,layoutId:s.layoutId,isOnBorder:s.isOnBorder}:{type:s.type,points:s.points}:s&&"Area"===s.type?d={type:"Area",points:s.points,viewPortId:s.viewPortId,area:"measured"===s.status&&s.area*h*h||null,drawingIndex:s.drawingIndex,drawingIndexes:s.drawingIndexes,layoutId:s.layoutId,isOnBorder:s.isOnBorder}:(s&&"Angle"===s.type||s&&"PolylineDistance"===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(c.ComponentsSelectionChanged,s),n.getEventManager().fireEvent(c.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(c.Hover,{objectId:s[0],clientPosition:{x:r,y:a},worldPosition:{x:e[0],y:e[1]},event:l}),i=s[0]}else i=null}},createDrawingViewer:function(t,i,n=!1){if(this._drawingViewer)return this._drawingViewer;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=t&&o.createDrawing(t,i);this._addElementEventListener({element:window,type:"resize",listener:()=>r&&r.onResize&&r.onResize()}),r.onViewChanges=()=>{this.getEventManager()&&this.getEventManager().fireEvent(c.Rendered,r)};const{name:a}=e.Web.Lang.Utility.ClientHelper.getDesktopType(),l=a.indexOf("Windows")>=0;return r.mouseEditorMgr=l?o.createMouseAndTouchEditorManager(r):s?o.createMouseEditorManager(r):o.createTouchEditorManager(r),r.mouseEditorMgr.bindEvents(),this.observer(r.mouseEditorMgr),r.mouseEditorMgr.zoomStart=()=>{r.zoomOrMoveObj&&(r.zoomOrMoveObj.isEnd=!1,r.zoomOrMoveObj.debounceCountZoomOrMoveFn(),r.zoomOrMoveObj.iterationStart||r.zoomOrMoveObj.moving||(r.zoomOrMoveObj.countFps(),r.zoomOrMoveObj.isZooming=!0)),this._timeHandle&&(clearTimeout(this._timeHandle),this._timeHandle=null)},r.mouseEditorMgr.zoomEnd=()=>{r.zoomOrMoveObj&&r.zoomOrMoveObj.debounceCountFinishFn(),this._timeHandle=setTimeout((()=>{this.getEventManager().fireEvent(c.ZoomEnd)}),this.inputDelayTimeInterval)},this._drawingViewer=r,r},zoomToBoundingBox:function(e,t=.5){let i=!1;if("2"!==this.version&&this.loadedDrawings.length<1&&(console.log("Drawing of old version doesn't support zoomToBoundingBox."),i=!0),e||(console.log("Parameter boundingBox is required."),i=!0),!i){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;tt?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;tn?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.getDrawing()&&this.getDrawing().fromLinkRevitId(e,n)},toModelId:function(e){return this.obsoleteOld("ViewerDrawing.toModelId","ViewerDrawing.getDrawing(modelId).toModelId"),i.send(t,"toModelId"),this.loadedDrawings.length>0?this.getDrawing().toModelId(e):this._drawingViewer.revitInterop.toRevitId(e)},toDrawingId:function(e,n){if(this.obsoleteOld("ViewerDrawing.toDrawingId","ViewerDrawing.getDrawing(modelId).toDrawingId"),i.send(t,"toDrawingId"),this.loadedDrawings.length>0)this.getDrawing().toDrawingId(e,n);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));if(t)return o=t.drawing.drawingIndex,e.ratio=n,void t.drawing.zoomToObject(e)}e.viewportId?this._zoomToViewportObject(e,n):(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))},_zoomToViewportObject(e,t){const i=e.objectId,n=e.viewportId,o=this._drawingViewer.viewer.GetLayoutIdByViewportId(n);if(-1==o)return;this.showViewById(o);const s=this._drawingViewer.getObjectBoundingBox(i);if(this._drawingViewer.viewer.IsModelElementIdInViewportId(i,n)){const e=this._drawingViewer.viewer.ToViewportBoxMinMax(s[0][0],s[0][1],s[0][2],s[1][0],s[1][1],s[1][2],n),i=e.GetMinPt(),o=e.GetMaxPt();this.zoomToBoundingBox([[i.x,i.y,i.z],[o.x,o.y,o.z]],t)}else this.zoomToBoundingBox([s[0],s[1]],t),this._drawingViewer.selectByIds([i])},zoomToObjectWithBlock:function(e,t,i){if(i=i||.5,this.clearSelection(),this.authenticate&&this.authenticate.data&&this.authenticate.data.config&&"true"==this.authenticate.data.config["integrate-with-links"])this._drawingViewer.zoomToElementsWithBlock(e,t,i);else{this._drawingViewer.zoomToObjectWithBlock(e,t[0],i);for(var n=0;n=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(c.ComponentsSelectionChanged,e),this.getEventManager().fireEvent(c.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(){this.obsoleteOld("ViewerDrawing.getSelectedObjects","ViewerDrawing.getDrawing(modelId).getSelectedObjects");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,l=r.getLayouts(),h=null;for(g=0;g0?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;gr&&r.onResize&&r.onResize()}),r.onViewChanges=function(){s.getEventManager()&&s.getEventManager().fireEvent(c.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,l=!1;t&&(o=t.HasLayout,r=t.HasMiniMap,a=t.HasText),(n.split&&n.split.databagId||n.config&&n.config.split)&&(l=!0),i=Object.assign(i,{HasLayout:o,HasMiniMap:r,HasText:a,HasSplitDrawing:l}),s._manifest=Object.assign(e,{Features:i}),s.getEventManager().fireEvent(c.Loaded,s._drawingViewer.mouseEditorMgr)})),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;g0?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&&(m[3]=e.getRGBA())},restoreBackgroundColor:function(){3===this._opt.displayMode&&(m[3]=m[0]),this.rootElement.style.background=m[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=m[e],this._drawingViewer.setSelectWireframeColor&&this._drawingViewer.enableReplaceElementColor&&this._drawingViewer.replaceElementColor&&(0==e?this._drawingViewer.setSelectWireframeColor(1,1,1,1):3!=e&&this._drawingViewer.setSelectWireframeColor(.733,.733,.733,1),1==e||2==e?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.loadedDrawings.length>0?this.loadedDrawings.map((e=>this._drawingViewer.enableReplaceElementColor(!1,e.drawing.drawingIndex))):this._drawingViewer.enableReplaceElementColor(!1)),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){t=parseInt(t)||0;let i=this.obsoleteOld("","",!1);return this._drawingViewer.toViewportBoundingBox(e[0],e[1],t,i)},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;i0?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),this.updateSceneBoundingBox()},getScaleFactor(){const e=this.obsoleteOld("ViewerDrawing.getScaleFactor","ViewerDrawing.getDrawing(modelId).getScaleFactor");return this._drawingViewer.getAlignScale(e)},getExternalReferencesList(e){let 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;t0?(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");this.authenticate&&(s=i.getUrl({url:s,path:"manifest.json",APIHost:this.authenticate.config.APIHost,loadMode:this.authenticate.data.loadMode,fileId:n.modelId,viewToken:n.viewToken})),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;ie.id==i));n=e.text.layouts.find((e=>e.name==t.name)).data}for(let e=0;e0&&a.movedDistance?{min:{x:n[0]+a.movedDistance[0],y:n[1]+a.movedDistance[1]},max:{x:n[2]+a.movedDistance[0],y:n[3]+a.movedDistance[1]}}:{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.yo.max.y&&l.push({content:t,boundingBox:o})}}let h=l;if(l.length>0){l.sort(((e,t)=>t.boundingBox.min.y-e.boundingBox.min.y));const e=l[Math.ceil(l.length/2)-1],t=e.boundingBox.max.y-e.boundingBox.min.y;h=[];const i=e=>{let n=e[0],o=[n];for(let s=1;se.boundingBox.min.x-t.boundingBox.min.x)),h=h.concat(o),i(e.slice(s));o.push(r),n=r}o.sort(((e,t)=>e.boundingBox.min.x-t.boundingBox.min.x)),h=h.concat(o)};i(l)}t(h)}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;t0&&(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");n.authenticate&&(s=e.Web.Lang.Utility.HttpRequest.getUrl({url:s,path:"resource/drawing/drawingFeatures.json.gz",APIHost:n.authenticate.config.APIHost,loadMode:n.authenticate.data.loadMode,fileId:i.modelId,viewToken:i.viewToken})),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-1){let e=[];for(let n=0;n0){let o=[],s=0;function r(e){o=[...o,...e],s+=1}this.loadedDrawings.map((t=>{t.drawing.search(e,r,i)}));const a=setInterval((function(){s==n.loadedDrawings.length&&(t(o),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-1){let e=[];for(let i=0;ie.drawing.drawingIndex==t)).drawing.setMovedDistance(e),this.loadedDrawings.length>0&&this.loadedDrawings[0].drawing.drawingIndex==t&&(this.movedDistance=this.movedDistance?[this.movedDistance[0]+e[0],this.movedDistance[1]+e[1]]:e),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;l0&&this.loadedDrawings.find((e=>{e.drawing.isAlignment&&(t=e.drawing.drawingIndex)})),t>-1){const i=this.getCurrentViewId(!0);let n;n=0==i?this.getViewer().toModelWorld([e.clientPosition.x,e.clientPosition.y]):this.getViewer().toWorldPoint([e.clientPosition.x,e.clientPosition.y]),this._drawingViewer.alignmentPoints.push({x:n[0],y:n[1]});let o=this._drawingViewer.alignmentPoints;if(1==o.length){let t=this.getViewer(),n=t.snapToPoint(e.clientPosition.x,e.clientPosition.y),s=n.GetPoint(),r=n.GetLayoutPoint();if(0!=n.GetID())o[0]=0==i?{x:s[0],y:s[1]}:{x:r[0],y:r[1]};else{let n=[e.clientPosition.x,e.clientPosition.y];if(n){let e=t.toModelWorld(n).slice(0,2),s=t.toWorldPoint(n)&&t.toWorldPoint(n).slice(0,2);o[0]=0==i?{x:e[0],y:e[1]}:{x:s[0],y:s[1]}}}}else if(2==o.length){let n=this.getViewer();"capture"!=n.mouseEditorMgr.editors[0].name&&this.setNavigationMode("capture");let s=this.verify([e.clientPosition.x,e.clientPosition.y],t);if(s){let e=n.toModelWorld(s).slice(0,2),t=n.toWorldPoint(s)&&n.toWorldPoint(s).slice(0,2);o[1]=0==i?{x:e[0],y:e[1]}:{x:t[0],y:t[1]}}this.moveDrawing([o[1].x-o[0].x,o[1].y-o[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=>{const t=e.selfDrawing;t&&t.onMouseClick&&t.onMouseClick(e)},enableSelectInBlock:function(){this._drawingViewer.enableSelectInBlock()},updateBoundingBox(){0==this.getCurrentViewId(!0)&&this._drawingViewer.viewer.UpdateModelBoxOfDrawingSet&&this._drawingViewer.viewer.UpdateModelBoxOfDrawingSet(),0!=this.getCurrentViewId(!0)&&this._drawingViewer.viewer.UpdateLayoutBoxOfDrawingSet&&this._drawingViewer.viewer.UpdateLayoutBoxOfDrawingSet(this.getCurrentViewId(!0))},isDrawingIndexNotExist(e){return!this.loadedDrawings.find((t=>t.drawing.drawingIndex==e))},loadDrawing:function(n,s){i.send(t,"loadDrawing");let r=(new Date).getTime();if("object"==typeof n){const a=this,l=n.modelId,h=n.frameId,c=n.fileId||null,d=n.viewToken,u=n.viewMetaData,g=n.sheetId||n.drawingSheetId;let m;if(u&&(a._data=u),this.loadedDrawings.length>0&&(this.oldState=this._drawingViewer&&this.getCurrentState()),null!=l&&(m=this.loadedDrawings.find((e=>e.modelId==l)),m))return this.console.error(`Failed to load drawing with ID ${l}, a drawing with the same ID already exists`),!1;if(d)this.getViewMetaData(d,f);else if(u){if(!u.drawingUrl){let w=u.integrateDrawings&&u.integrateDrawings.databagId||u.databagId,v=e.Web.Lang.Utility.ClientHelper.formatURL((u.path||this._viewConfig.resourceHost)+"/"+w+"/resource/drawing");u.drawingUrl=v}f(u)}function f(n){a.loadIndexJson(n,g,c,(function(u){const m="2"==u.metadata.version||"2"==u.metadata["version:"]?"2":"1";if(a.version&&a.version!=m)return void a.console.error(`Failed to load drawing with ID ${l}, version diffrent with former drawing`);a.version=m,a.createDrawingViewer(a.getRootElement().id,null);let f=new e.Bimface.Viewer.ViewerDrawingConfig;f.resourceHost=a._opt.resourceHost,f.staticHost=a._opt.staticHost,f.APIHost=a._opt.APIHost,f.drawingUrl=n.drawingUrl,f.viewToken=d,f.enableViewport=a._viewConfig.enableViewport,f._drawingViewer=a._drawingViewer,f.rootElement=a.getRootElement(),f.domElement=a.getDomElement(),f.fileName=n.name,f.modelId=l,f.eventManager=a.getEventManager();const w=e.Bimface.Viewer.ViewerDrawingEvent;let v;v=new e.Bimface.Viewer.Drawing(f),g?v.load(d,g,c,a,n,a.version):h?v.loadFrame(d,h,a,n,a.version):v.load(d,null,null,a,n,a.version);const y={modelId:l,wrap:a.getDomElement(),drawing:v,fileName:n.name};a.loadedDrawings.push(y);const b=a.getEventManager().container;let x=!0;if(b[w.MouseClicked]&&b[w.MouseClicked].length>0){b[w.MouseClicked].find((e=>e==a._handleDrawingMouseClick))&&(x=!1)}return x&&(a.addEventListener(w.MouseClicked,a._handleDrawingMouseClick),a.addEventListener(w.Tap,a._handleDrawingMouseClick)),v.getSelfEventManager().addEvent(w.Loaded,(function(n,l,h){if(h.trackObj=a.trackObj,a.trackObj.id=e.Web.Lang.Utility.UUID.createUUID(),a.trackObj.primaryViewLoadTime=(new Date).getTime()-r,a.trackObj.eventId="图纸加载",a.trackObj.fileSuffix=h._viewMetaData.name.split(".")[h._viewMetaData.name.split(".").length-1],h._manifest.Statics&&(a.trackObj.numberOfBlocks=h._manifest.Statics.numberOfBlocks,a.trackObj.maximumElementsInBlock=h._manifest.Statics.maximumElementsInBlock,a.trackObj.numberOfViewports=h._manifest.Statics.numberOfViewports,a.trackObj.numberOfElements=h._manifest.Statics.numberOfElements),i.send(t,"Loaded",a.trackObj),i.intervalAction(),!a._drawingViewer&&(a._drawingViewer=y.drawing.getViewer()),"boolean"!=typeof a._drawingViewer.trackFunsInited&&(a._drawingViewer.trackFunsInited=!1),a._drawingViewer.mouseEditorMgr.enableDrag&&a._drawingViewer.mouseEditorMgr.enableDrag(a.dragIsEnable),a._drawingViewer.mouseEditorMgr.enableScale&&a._drawingViewer.mouseEditorMgr.enableScale(a.scaleIsEnable),a.loadedDrawings.length>1&&a.oldState&&a.setState(a.oldState),!a._drawingViewer.trackFunsInited){a._drawingViewer.trackFunsInited=!0,!a._drawingViewer.zoomOrMoveObj&&(a._drawingViewer.zoomOrMoveObj={startTime:"",endTime:"",isStart:!0,isEnd:!1,isZooming:!1,frameCount:0,iterationStart:!1});const e=()=>{if(0==a.getCurrentViewId(!0)){if(a._drawingViewer.zoomOrMoveModelTimes?a._drawingViewer.zoomOrMoveModelTimes+=1:a._drawingViewer.zoomOrMoveModelTimes=1,3==a._drawingViewer.zoomOrMoveModelTimes&&a._drawingViewer.zoomOrMoveModelFrames){let e=0;a._drawingViewer.zoomOrMoveModelFrames.map((t=>e+=t)),a.trackObj.averageModelFPS=Math.round(e/a._drawingViewer.zoomOrMoveModelFrames.length),a.trackObj.minimumModelFPS=Math.min(...a._drawingViewer.zoomOrMoveModelFrames),a.trackObj.eventId="图纸加载",i.send(t,"ZoomOrMoveModel",a.trackObj),i.intervalAction(),++a._drawingViewer.zoomOrMoveModelTimes}}else if(a._drawingViewer.zoomOrMoveLayoutTimes?a._drawingViewer.zoomOrMoveLayoutTimes+=1:a._drawingViewer.zoomOrMoveLayoutTimes=1,3==a._drawingViewer.zoomOrMoveLayoutTimes){let e=0;a._drawingViewer.zoomOrMoveLayoutFrames.map((t=>e+=t)),a.trackObj.averageLayoutFPS=Math.round(e/a._drawingViewer.zoomOrMoveLayoutFrames.length),a.trackObj.minimumLayoutFPS=Math.min(...a._drawingViewer.zoomOrMoveLayoutFrames),a.trackObj.eventId="图纸加载",i.send(t,"ZoomOrMoveLayout",a.trackObj),i.intervalAction(),++a._drawingViewer.zoomOrMoveLayoutTimes}};a._drawingViewer.zoomOrMoveObj.countFps=()=>{if(a._drawingViewer.zoomOrMoveObj.isStart?(a._drawingViewer.zoomOrMoveObj.startTime=(new Date).getTime(),a._drawingViewer.zoomOrMoveObj.frameCount=0,a._drawingViewer.zoomOrMoveObj.isStart=!1,a._drawingViewer.zoomOrMoveObj.iterationStart=!0):++a._drawingViewer.zoomOrMoveObj.frameCount,a._drawingViewer.zoomOrMoveObj.isEnd){a._drawingViewer.zoomOrMoveObj.endTime=(new Date).getTime();const e=Math.round(+a._drawingViewer.zoomOrMoveObj.frameCount/(+a._drawingViewer.zoomOrMoveObj.endTime-a._drawingViewer.zoomOrMoveObj.startTime)*1e3);return 0==a.getCurrentViewId(!0)?(a._drawingViewer.zoomOrMoveModelFrames||(a._drawingViewer.zoomOrMoveModelFrames=[]),!Number.isNaN(e)&&Number.isFinite(e)&&e>0&&a._drawingViewer.zoomOrMoveModelFrames.push(e)):(a._drawingViewer.zoomOrMoveLayoutFrames||(a._drawingViewer.zoomOrMoveLayoutFrames=[]),!Number.isNaN(e)&&Number.isFinite(e)&&e>0&&a._drawingViewer.zoomOrMoveLayoutFrames.push(e)),a._drawingViewer.zoomOrMoveObj.isZooming&&(a._drawingViewer.zoomOrMoveObj.isZooming=!1),void(a._drawingViewer.zoomOrMoveObj.moving&&(a._drawingViewer.zoomOrMoveObj.moving=!1))}requestAnimationFrame((()=>{a._drawingViewer&&a._drawingViewer.zoomOrMoveObj.countFps()}))},a._drawingViewer.zoomOrMoveObj.debounceCountZoomOrMoveFn=p.debounce(e,500),a._drawingViewer.zoomOrMoveObj.stopCount=()=>{a._drawingViewer.zoomOrMoveObj.isEnd=!0,requestAnimationFrame((()=>{a._drawingViewer&&(a._drawingViewer.zoomOrMoveObj.startTime="",a._drawingViewer.zoomOrMoveObj.endTime="",a._drawingViewer.zoomOrMoveObj.iterationStart=!1,a._drawingViewer.zoomOrMoveObj.isStart=!0)}))},a._drawingViewer.zoomOrMoveObj.debounceCountFinishFn=p.debounce(a._drawingViewer.zoomOrMoveObj.stopCount,500),a._drawingViewer.trackShowOrHideLayers=()=>{a.getViewer().layerEndTime=(new Date).getTime(),a.getViewer().layerTimes||(a.getViewer().layerTimes=[]),a.getViewer().layerStartTime&&a.getViewer().layerTimes.length<=3&&(a.getViewer().layerTimes.push(a.getViewer().layerEndTime-a.getViewer().layerStartTime),delete a.getViewer().layerStartTime,delete a.getViewer().layerEndTime,3==a.getViewer().layerTimes.length&&(a.trackObj.layerDisplayState=(a.getViewer().layerTimes[0]+a.getViewer().layerTimes[1]+a.getViewer().layerTimes[2])/3,a.trackObj.eventId="图纸加载",i.send(t,"LayerShowOrHide",a.trackObj),i.intervalAction()))}}const c=a.getRootElement().style.backgroundColor;a.setDisplayMode(a.getDisplayMode());if((c?c.match(/\((.+?)\)/g):[]).length>0&&1!=a.loadedDrawings.length){const t=RegExp.$1.split(",");a.setBackgroundColor(new e.Web.Graphics.Color(t[0],t[1],t[2],4==t.length?t[3]:1))}const d=a.loadedDrawings.find((e=>e.drawing.drawingIndex==h.drawingIndex));d&&null==d.modelId&&(d.modelId=h.modelId),a.snapIsEnabled&&a.enableSnap(a.snapIsEnabled),a.getEventManager().fireEvent(w.Loaded,n,l,h),a.getEventManager().fireEvent(w.LoadDrawing,a),a.getEventManager().fireEvent(w.ViewChanged,a),s&&s(l),a.update(!0),void 0===o.isFirstLoaded?o.isFirstLoaded=!1:!1===o.isFirstLoaded&&a._drawingViewer&&a.updateBoundingBox(),a._opt.enableViewport||1!=a.loadedDrawings.length||requestAnimationFrame((()=>a.home()))})),v.getEventManager().addEvent(w.DrawingTransformed,(()=>{a.snapIsEnabled&&a.enableSnap(a.snapIsEnabled)})),!0}))}}"string"==typeof n&&(1==arguments.length&&this.load(arguments[0]),2==arguments.length&&this.loadFrame(arguments[0],arguments[1]))},loadDrawings:function(e,t){const i=[];let n=0;e.map((o=>{if(i.includes(o.modelId))return this.console.error(`Failed to load drawing with ID ${o.modelId}, a drawing with the same ID already exists`),!1;i.push(o.modelId),this.loadDrawing(o,(()=>{n++,n===e.length&&t&&t()}))}))},getDrawing:function(e,t=!1){if(null!=e){const i=this.loadedDrawings.find((t=>t.modelId==e));return i?i.drawing:void(!t&&this.console.error("modelId is not exist!"))}return this.loadedDrawings[0].drawing},removeDrawing:function(e,t=!1){if(null==e)return this.console.error("modelId is necessary!"),!1;const i=this.getDrawing(e,t);i&&(i.destroy(),this.loadedDrawings.removeObjectByAttribute("modelId",e),this.update(),this.getEventManager().fireEvent(c.ViewChanged,self),this.updateSceneBoundingBox(),0==this.loadedDrawings.length&&(this.getEventManager().fireEvent("RemovedAllDrawing"),this._drawingViewer&&(this._drawingViewer.mouseEditorMgr&&this._drawingViewer.mouseEditorMgr.unbindAllEvent(),this._drawingViewer.destroy&&this._drawingViewer.destroy(),this._drawingViewer=null,this._domElement.querySelectorAll("#"+this.rootElement.id+" canvas").forEach((e=>e.remove())))))},removeAllDrawings:function(){for(var e=this.loadedDrawings.length-1;e>-1;e--)this.removeDrawing(this.loadedDrawings[e].drawing.modelId,!0)},clearBoundingBox:function(){this._drawingViewer.clearElementBox(),this._drawingViewer.update(!0)},getSceneBoundingBox(){const e=this._drawingViewer.getModelBBox().GetMinPt(),t=this._drawingViewer.getModelBBox().GetMaxPt();return{min:{x:e[0],y:e[1]},max:{x:t[0],y:t[1]}}},updateSceneBoundingBox(){this._drawingViewer&&this._drawingViewer.viewer&&this.updateBoundingBox()},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},enableDrag(e){this._drawingViewer.mouseEditorMgr.enableDrag(e),this.dragIsEnable=e},isDragEnabled(){return this.dragIsEnable},enableScale(e){this._drawingViewer.mouseEditorMgr.enableScale(e),this.scaleIsEnable=e},isScaleEnabled(){return this.scaleIsEnable},enableContextMenu(e){"boolean"==typeof e&&(this._opt.enableContextMenu=e),void 0===e&&(this._opt.enableContextMenu=!0)},isEnableContextMenu(){return this._opt.enableContextMenu},enableCrossingSelection(e){"boolean"==typeof e&&(this._opt.enableCrossingSelection=e),void 0===e&&(this._opt.enableCrossingSelection=!0)},isEnableCrossingSelection(){return this._opt.enableCrossingSelection},setBoxSelectionMode(e){i.send(t,"setBoxSelectionMode"),this.boxSelectedMode="Default"==e?null:e},getBoxSelectionMode(){return i.send(t,"getBoxSelectionMode"),this.boxSelectedMode?this.boxSelectedMode:"Default"},startBoxSelection(){i.send(t,"startBoxSelection"),this.isBoxSelection=!0},endBoxSelection(){i.send(t,"endBoxSelection"),this.isBoxSelection=!1}}),n.ViewerDrawing=f}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerDrawingSetConfig=function(){return{domElement:null,resourceHost:u.resourceHost,staticHost:u.staticHost+"/api/Glodon",APIHost:u.APIHost,securityApi:u.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)"];e.Bimface.Data.StatisticsDataManager.getInstance();const a=new e.Web.Common.Console;let l=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 s,r=o.create("div","bf-drawingSet-container "),a=i.domElement;a.id?s=a.id:(s=e.Web.Lang.Utility.UUID.createUUID(),a.id=s),r.id="DrawingSet"+s,r.setCss({width:"100%",height:"100%",position:"relative"}),a.appendChild(r),n.domElement=r,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=a,this._viewConfig=n,this.rootElement=r,this.haveActiveDrawing=!1,this.getRootElement=function(){return r}};n.Type.inheritPrototype(l,t.Viewer),l.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?(a.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{n.getActiveDrawing().viewerDrawing.resize()}),500)},getCurrentState:function(){let e=[],t=this.sets;for(var i=0;i0){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{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(t){t.drawingUrl=e.Web.Lang.Utility.HttpRequest.getUrl({url:`${n._viewConfig.resourceHost}/${t.databagId}/resource/drawing`,path:"resource/drawing",APIHost:n.authenticate.config.APIHost,loadMode:t.loadMode,fileId:t.modelId,viewToken:t.viewToken,modelType:t.modelType}),i(t)}))},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;let a=`${this._viewConfig.resourceHost}/${r}/resource/drawing/reference.json`;s.viewerDrawing.authenticate&&(a=o.getUrl({url:a,path:"resource/drawing/reference.json",APIHost:s.viewerDrawing.authenticate.config.APIHost,loadMode:s.viewerDrawing.authenticate.data.loadMode,fileId:s.viewerDrawing.authenticate.data.modelId,viewToken:s.viewerDrawing.authenticate.data.viewToken})),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`;this.authenticate&&(n=i.getUrl({url:n,path:"manifest.json",APIHost:this.authenticate.config.APIHost,loadMode:this.authenticate.data.loadMode,fileId:this.authenticate.data.modelId,viewToken:this.authenticate.data.viewToken})),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()},destroy:function(){this.sets.forEach((e=>{e.viewerDrawing.destroy(!0)})),this.sets=null,this.rootElement.remove()}}),t.ViewerDrawingSet=l}(),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:u.resourceHost,onCameraChanged:null,inMoveOnAxisGrid:null}},C=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),T=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),(I=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 f.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,T.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;o0&&(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})}},C.MiniMap=I,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:u.resourceHost,loadAsync:!1}},function(){let t=Object.freeze({ViewerCameraChanged:"ViewerCameraChanged",MouseClicked:"MouseClicked",MouseHoveredGrid:"MouseHoveredGrid",SelectionChanged:"SelectionChanged",SelectionMoved:"SelectionMoved",SelectionEditor:"SelectionEditor",FloorPlaneChanged:"FloorPlaneChanged",Zoom:"Zoom"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map").MapEvents=t}(),function(){let t=Object.freeze({Default:"Default",Static:"Static"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map").MapNavigationMode=t}();var D=function(e,t){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},D(e,t)};function B(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}D(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var _,A=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}(),k=function(){function e(){this._boxSize=new THREE.Vector2,this._boxCenter=new THREE.Vector2,this._intersect=new THREE.Vector3}return e.prototype.cross=function(e,t,i,n){return(t.x-e.x)*(n.y-i.y)-(t.y-e.y)*(n.x-i.x)},e.prototype.getArea=function(e,t,i){return this.cross(e,t,e,i)},e.prototype.getAbsArea=function(e,t,i){return Math.abs(this.getArea(e,t,i))},e.prototype.getInterPoint=function(e,t,i,n){var o=this.getAbsArea(e,t,i),s=this.getAbsArea(e,t,n);return new THREE.Vector2((n.x*o+i.x*s)/(o+s),(n.y*o+i.y*s)/(o+s))},e.prototype.isAngleGreaterThanPi=function(e,t,i){var n=new THREE.Vector3;return n.crossVectors(e,t),!(n.dot(i)>=0)},e.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},e.prototype.screenToNormalizedPoint=function(e,t){e.x=e.x/t.width,e.y=-e.y/t.height},e.prototype.normalizedPointToWorld=function(e,t){t.getSize(this._boxSize),e.x=.5*(e.x+1)*this._boxSize.x+t.min.x,e.y=.5*(e.y+1)*this._boxSize.y+t.min.y},e.prototype.worldToNormalizedPoint=function(e,t){t.getSize(this._boxSize),e.x=(e.x-t.min.x)/this._boxSize.x*2-1,e.y=(e.y-t.min.y)/this._boxSize.y*2-1},e.prototype.toWorldPoint=function(e,t,i,n){e.x<0&&(e.x=0),e.x>t&&(e.x=t),e.y<0&&(e.y=0),e.y>i&&(e.y=i),e.x=e.x/t*2-1,e.y=-e.y/i*2+1,this.normalizedPointToWorld(e,n)},e.prototype.getCuttingBoxOnCanvas=function(e,t,i,n){var o=new THREE.Box3,s=new THREE.Vector2(e.x,e.y),r=new THREE.Vector2(t.x,t.y);this.toWorldPoint(s,i[0],i[1],n),this.toWorldPoint(r,i[0],i[1],n);var a=[];return a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,s.y)),a.push(new THREE.Vector3(r.x,s.y)),o.setFromPoints(a),{min:{x:o.min.x,y:o.min.y,z:0},max:{x:o.max.x,y:o.max.y,z:0}}},e.prototype.canvasPointToClient=function(e,t){var i=t.mapContainer;if(!i||!t.floorPlaneBox)return null;var n=this.getContainerOffsetToClient(i);if(0===n.width||0===n.height)return null;var o=new THREE.Vector2;return o.x=e.x+n.left,o.y=e.y+n.top,o},e.prototype.getMainSceneMatrix=function(e){return e.getScene().getMatrixGlobal()},e.prototype.transformWorldPoint=function(e,t){var i=this.getMainSceneMatrix(e);e.miniMapTransform&&t.applyMatrix4((new THREE.Matrix4).fromArray(e.miniMapTransform)),t.applyMatrix4(i)},e.prototype.expandBbox=function(e,t){var i=e.getCenter(this._boxCenter);e.getSize(this._boxSize);var n=new THREE.Vector2,o=t,s=this._boxSize.x/this._boxSize.y,r=this._boxSize.x,a=this._boxSize.y;s>o?a=r/o:s0&&o.x0&&o.y0&&s.x0&&s.ya&&(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;ni)},e}(),L=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 B(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}(A),V=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 B(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}(A),R=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 B(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}(A),H=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return B(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new R(t,e.name))}))},t.prototype.abtainRenderables=function(e){for(var t=0;t=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 V(c,o,i))}}));var a=r.positions.map(n);e.add(new H(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=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;t0&&(this.currentIdx--,i=this.zoomFactors[this.currentIdx]),!(i<0||this.lastZoomFactor==i)){this.lastZoomFactor=i,1==i&&X.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]}X.panOffsetX+=r,X.panOffsetY+=a,X.panOffsetXForCamera+=r,X.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:G.ZOOM_MOUSE_WHEEL,data:{offsetX:X.panOffsetX,offsetY:X.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++),cm[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","RT");hf[1]&&0==g&&(l[1]+=f[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 h0)(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");j.offsetXForZoomAndPan=e[0]-t[0],j.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(z),Y=function(e){function t(){var t=e.call(this)||this;return t.cameraCircleNode=null,t.cameraArrowNode=null,t.rotateAngle=0,t.panelSize=[298,198],t.cameraPositionToTarget=2e3,t.build(),t}return B(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),X.panOffsetXForCamera=0,X.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),eo&&(t=o),t1e-6){t[1]=this.elevations[o],t[1]-=this.offsetForPlane;break}return t},e.prototype.getElevation=function(e,t){for(var i=this.resourceLevels,n=0;ne){o=r;break}}for(s=t.length-1;s>=0;s--){var r;if((r=t[s])=n&&ir?h=l/r:a0;){var t=e.children[0];e.removeChild(t)}this.mapContainer.removeChild(e);var i=this.getData().getTipNode();i&&null!=i.getSvgNode().parentNode&&this.mapContainer.removeChild(i.getSvgNode())},e.prototype.updateCameraNode=function(e){var t=this.viewer,i=t.camera,n=t.cameraControl;if(i&&n){var o=i.position,s=i.target,r=this.algorithm.getMainSceneMatrix(t),a=new THREE.Matrix4;a.copy(r).invert();var l=this.viewerFloorData.getFloorPlaneBox();l.getCenter(this.bBoxCenter);var h=new THREE.Vector3(l.min.x,l.min.y,this.bBoxCenter.z).applyMatrix4(r),c=new THREE.Vector3(l.min.x,l.max.y,this.bBoxCenter.z).applyMatrix4(r),d=new THREE.Vector3(l.max.x,l.min.y,this.bBoxCenter.z).applyMatrix4(r),u=new THREE.Plane;u.setFromCoplanarPoints(h,c,d),u.projectPoint(o,this.projectedCameraPosition),this.projectedCameraPosition.applyMatrix4(a),t.miniMapTransform&&this.projectedCameraPosition.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert()),u.projectPoint(s,this.projectedTargetPosition),this.projectedTargetPosition.applyMatrix4(a),t.miniMapTransform&&this.projectedTargetPosition.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert());var g=this.projectedTargetPosition.clone().sub(this.projectedCameraPosition);g.z=0,g.normalize();var p=o.clone();p.applyMatrix4(a),t.miniMapTransform&&p.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert()),e&&(p=e.globalUnitUtil.revertVector(p));var m=p.clone(),f=this.viewerFloorData.getSize(),w={width:f[0]/2,height:f[1]/2},v=this.viewerFloorData.getAxisGridBox2D();this.algorithm.worldToNormalizedPoint(m,v),this.algorithm.normalizedPointToScreen(m,w);var y=this.viewerFloorData.getCameraNode();if(y.setOpacity("1.0"),g.length()<1e-5)y.setCameraArrowOpacity("0.0"),y.setOffsetAndRotate(m.x+X.panOffsetX,m.y+X.panOffsetY,0);else{var b=new THREE.Vector3(0,0,1),x=new THREE.Vector3(1,0,0),E=this.algorithm.isAngleGreaterThanPi(x,g,b),P=THREE.Math.radToDeg(x.angleTo(g));E||(P*=-1),y.setBigCamera(),y.setOffsetAndRotate(m.x+X.panOffsetX,m.y+X.panOffsetY,P),y.setCameraArrowOpacity("1.0")}}},e.prototype.update=function(e){for(var t=this.viewerFloorData.getDrawableItems(),i=0;ii.width||t>i.height)&&(e=this.pointOnBorder[0],t=this.pointOnBorder[1]),e=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=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]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}(),oe=function(e){function t(t,i){var n=e.call(this)||this;return n.name=_.RECTPICK_Editor,n.eventManager=i,n.viewerFloorData=t.getData(),n.naviAction=new ne(t),n.vfViewer=t,n.algorithm=new k,n}return B(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:G.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]+j.offsetXForZoomAndPan,y:e[1]+j.offsetYForZoomAndPan},i={x:e[2]+j.offsetXForZoomAndPan,y:e[3]+j.offsetYForZoomAndPan},n=this.algorithm.getCuttingBoxOnCanvas(t,i,this.viewerFloorData.getSize(),this.viewerFloorData.getAxisGridBox2D()),o=this.viewerFloorData.getFloorPlaneBox();if(n.min.z=o.min.z,n.max.z=o.max.z,this.vfViewer.getViewer().miniMapTransform){var s=new THREE.Vector3(n.max.x,n.max.y,n.max.z);s.applyMatrix4((new THREE.Matrix4).fromArray(this.vfViewer.getViewer().miniMapTransform));var r=new THREE.Vector3(n.min.x,n.min.y,n.min.z);r.applyMatrix4((new THREE.Matrix4).fromArray(this.vfViewer.getViewer().miniMapTransform)),n.max=s,n.min=r}return n},t.prototype.getIntersectionByNormalizedPoint=function(e,t){var i=this.vfViewer.getData().getIntersections(),n=new THREE.Vector2(e.x,e.y);return this.algorithm.normalizedPointToScreen(n,{width:t[0]/2,height:t[1]/2}),k.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+=j.offsetXForZoomAndPan,i.y+=j.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-j.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+a.left,t.clientY=r.intersectionPoint.y-j.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+a.top}return t},t}(z),se=function(){function e(e,t,i){this.eventManager=new W,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(_.PICK_Editor),this.enableEditor(_.PAN_Editor),this.enableEditor(_.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{this._axisGrids={Grids:r,Levels:a},this._floors=s,(this._axisGrids.Grids||this._axisGrids.Levels)&&this.viewerFloor.setAxisGridData(this._axisGrids),this.viewerFloor.setPlanes(this._floors);var t=new e.Bimface.UI.Select.SelectConfig;t.className="bf-select bf-select-map";var i=this.getDefaultFloorPlane(),n=this._floors.getObjectByAttribute("name",i);0!=n&&(t.default=n.id),t.options=this._floors,t.element=this._mapHeader,t.prefix=BimfaceLanguage.bf_panel_map_level;var o=this,l=new e.Bimface.UI.Select.Select(t);l.addEventListener("Change",(function(e){o.showFloorById(e.id,e.modelId)})),this.addEventListener(this._mapEvents.FloorPlaneChanged,(function(e){l._currentElement.innerText=BimfaceLanguage.bf_panel_map_level+e})),this.createMap()};let i=0;const o=n.getModels().length;n.getModels().forEach((e=>{e["getMapInfo"+(this._opt.loadAsync?"Async":"")]((n=>{n.floors.map((t=>t.modelId=e.modelId)),s=[...n.floors,...s],r=n.axisGrid.Grids?[...n.axisGrid.Grids,...r]:r,n.axisGrid.Levels&&n.axisGrid.Levels.map((t=>t.modelId=e.modelId)),a=n.axisGrid.Levels?[...n.axisGrid.Levels,...a]:a,i++,i===o&&t()}),(()=>{i++,i===o&&t()}))}))}else{var l=o.create("div","bf-map-header-title");this._mapHeader.appendChild(l),this.addEventListener(this._mapEvents.FloorPlaneChanged,(function(t){void 0===t&&(t=0),n.getUnit()===e.Bimface.Common.Units.LengthUnits.Millimeter&&(t/=1e3),l.innerHTML=BimfaceLanguage.bf_panel_map_height+t+"m"})),this.createMap()}},createMap:function(){i.send(t,"createMap");var n=(h=this).getEventManager(),o=e.Bimface.Plugins.Map.MapEvents,s=h._opt;let r=this.EventType;!h._modelId&&h._floors[0]&&(h._modelId=h._floors[0].modelId);const a=h._opt.viewer.getModel(h._modelId)._getModelTransformation();if(h._opt.viewer.getViewer().miniMapTransform=a,this.viewerFloor.addEventListener(r.PICK_MOUSE_UP,(function(e){!h._modelId&&h._floors[0]&&(h._modelId=h._floors[0].modelId);const t=h._opt.viewer.getModel(h._modelId)._getModelTransformation();h._opt.viewer.getViewer().miniMapTransform=t,h._opt.viewer.globalUnitUtil.translate(e,["x","y","z"],!1),n.fireEvent(o.MouseClicked,e.data,t),window.requestAnimationFrame((()=>h._opt.viewer.fireEvent("MiniMapOperate")))})),this.viewerFloor.setMapClickMode(s.navigationMode.toLocaleLowerCase()),this.viewerFloor.addEventListener(r.Minimap_Rect_Changed,(function(e){n.fireEvent("MinimapRectChanged",e.rectInfo)})),this.viewerFloor.addEventListener(r.Minimap_Rect_Destroyed,(function(e){n.fireEvent("MinimapRectDestroyed",e)})),this.viewerFloor.addEventListener(r.Camera_Height_Changed,(function(e){h.viewerFloor.enableFloorPlaneChangedEvent(!1),h.showFloorById(e.id),h.viewerFloor.enableFloorPlaneChangedEvent(!0)})),this.viewerFloor.addEventListener(r.Floor_Plane_Changed_For_Panel,(function(e){n.fireEvent("FloorPlaneChanged",e.name)})),this.viewerFloor.addEventListener(r.ZOOM_MOUSE_WHEEL,(function(e){n.fireEvent(o.Zoom,e.data)})),this.viewerFloor.addEventListener(r.Floor_Plane_Changed,(function(e){if(null!=e.elevation){"string"==typeof e.elevation&&(e.elevation=parseFloat(e.elevation));var t=s.viewer.getViewer(),i=t.camera,n=e.elevation;window.requestAnimationFrame((()=>{var e=s.viewer.sceneToWorld(i.position.clone()),o=new THREE.Vector3(e.x,e.y,n+h._manHeight);const r=t.getBoundingBoxWorld();o.z=Math.min(o.z,s.viewer.globalUnitUtil.revertTranslate(r.max.z));var a=s.viewer.worldToScene(o);t.cameraControl.flyToPointWithParallelEye(new THREE.Vector3(a.x,a.y,a.z)),window.requestAnimationFrame((()=>h._opt.viewer.fireEvent("MiniMapOperate")))}))}})),h.viewerFloor.enableFloorPlaneChangedEvent(!1),h._hasFloor)if(this._useEngineMap){let t=this;t.viewerFloor.setFlip(!0);let i=s.viewer.getViewer();t.mapManager=new e.Bimface.Plugins.Map.MapManager({viewer:s.viewer});const n=this._axisGrids,o=this._floors;let r={};r.maxPixel=t._opt.maxPixel,r.height=[],r.boundingbox=[],r.useBorder=!1;const a=n.Levels;for(let e=0;et==o[e].id));if(n){const a=t.viewerFloor.vfData.getDataFloorPlanes().getFloorPlaneBox(o[e].id);let l=s.viewer.globalUnitUtil.translateBBox(new THREE.Box3(new THREE.Vector3(a.Min.X,a.Min.Y,a.Min.Z),new THREE.Vector3(a.Max.X,a.Max.Y,a.Max.Z)));l.applyMatrix4((new THREE.Matrix4).fromArray(t._opt.viewer.getModel(o[e].modelId)._getModelTransformation())),l.applyMatrix4(i.getScene().getMatrixGlobal()),r.boundingbox.push(l);let h=new THREE.Vector3(0,0,n.elevation);h.applyMatrix4((new THREE.Matrix4).fromArray(t._opt.viewer.getModel(o[e].modelId)._getModelTransformation())),r.height.push(s.viewer.globalUnitUtil.translate(h.z))}}let l=e=>{for(let t=0;t0){var i=o.getObjectByAttribute("name",this.defaultFloorPlane);0==i?this.showFloorById(o[0].id):this.showFloorById(i.id)}t.viewerFloor.enableFloorPlaneChangedEvent(!0),t._inited=!0};r.successCallback=l,t.mapManager.removeCreateMapEvent(),t.mapManager.createMapByHeight(r)}else{const e=this._floors;if(e.length>0){var l=e.getObjectByAttribute("name",this.defaultFloorPlane);0==l?this.showFloorById(e[0].id):this.showFloorById(l.id)}h.viewerFloor.enableFloorPlaneChangedEvent(!0),h._inited=!0}else{var h;(h=this).viewerFloor.setFlip(!0);const t=s.viewer,i=t.globalUnitUtil.revertBBox(t.getViewer().getBoundingBoxWorld()),n={Min:i.min,Max:i.max};h.mapManager=new e.Bimface.Plugins.Map.MapManager({viewer:t});let o=t.getCamera().getStatus().position.z;o=Math.floor(Math.min(Math.max(o,i.min.z),i.max.z));let r=e=>{let o=t.getCamera().getStatus().position.z;o=Math.floor(Math.min(Math.max(o,i.min.z),i.max.z));let s=[];s.push({id:o,name:"top",elevation:o}),s.push({id:i.min.z,name:o.toString(),elevation:i.min.z});let r={Grids:[],Levels:s};h.viewerFloor.setAxisGridData(r);let a=[];a.push({id:o,name:o,path:e,BoundingBox:n}),h._floors=a,h.viewerFloor.setPlanes(a),h.showFloorById(o),h._inited=!0},a={};a.maxPixel=h._opt.maxPixel,a.spacing=h._refreshHeight,a.successCallback=r,h.mapManager.removeCreateMapEvent(),h.mapManager.createMapByCamera(a),t.getViewer().getModelManager().dispatchEvent({type:f.EVENTS.ON_CAMERA_CHANGED_AND_RENDERED})}},setDefaultFloorPlane:function(e){for(var t=this._floors,i=0;i=0)},e.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},e.prototype.screenToNormalizedPoint=function(e,t){e.x=e.x/t.width,e.y=-e.y/t.height},e.prototype.normalizedPointToWorld=function(e,t){t.getSize(this._boxSize),e.x=.5*(e.x+1)*this._boxSize.x+t.min.x,e.y=.5*(e.y+1)*this._boxSize.y+t.min.y},e.prototype.worldToNormalizedPoint=function(e,t){t.getSize(this._boxSize),e.x=(e.x-t.min.x)/this._boxSize.x*2-1,e.y=(e.y-t.min.y)/this._boxSize.y*2-1},e.prototype.toWorldPoint=function(e,t,i,n){e.x<0&&(e.x=0),e.x>t&&(e.x=t),e.y<0&&(e.y=0),e.y>i&&(e.y=i),e.x=e.x/t*2-1,e.y=-e.y/i*2+1,this.normalizedPointToWorld(e,n)},e.prototype.getCuttingBoxOnCanvas=function(e,t,i,n){var o=new THREE.Box3,s=new THREE.Vector2(e.x,e.y),r=new THREE.Vector2(t.x,t.y);this.toWorldPoint(s,i[0],i[1],n),this.toWorldPoint(r,i[0],i[1],n);var a=[];return a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,s.y)),a.push(new THREE.Vector3(r.x,s.y)),o.setFromPoints(a),{min:{x:o.min.x,y:o.min.y,z:0},max:{x:o.max.x,y:o.max.y,z:0}}},e.prototype.canvasPointToClient=function(e,t){var i=t.mapContainer;if(!i||!t.floorPlaneBox)return null;var n=this.getContainerOffsetToClient(i);if(0===n.width||0===n.height)return null;var o=new THREE.Vector2;return o.x=e.x+n.left,o.y=e.y+n.top,o},e.prototype.getMainSceneMatrix=function(e){return e.getScene().getMatrixGlobal()},e.prototype.transformWorldPoint=function(e,t){var i=this.getMainSceneMatrix(e);e.miniMapTransform&&t.applyMatrix4((new THREE.Matrix4).fromArray(e.miniMapTransform)),t.applyMatrix4(i)},e.prototype.expandBbox=function(e,t){var i=e.getCenter(this._boxCenter);e.getSize(this._boxSize);var n=new THREE.Vector2,o=t,s=this._boxSize.x/this._boxSize.y,r=this._boxSize.x,a=this._boxSize.y;s>o?a=r/o:s0&&o.x0&&o.y0&&s.x0&&s.ya&&(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;ni)},e}(),ue=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 le(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}(ce),ge=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 le(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}(ce),pe=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 le(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}(ce),me=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return le(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new pe(t,e.name))}))},t.prototype.abtainRenderables=function(e){for(var t=0;t=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 ge(c,o,i))}}));var a=r.positions.map(n);e.add(new me(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=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;t0&&(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:ve.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++),cm[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","RT");hf[1]&&0==g&&(l[1]+=f[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 h0)(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");Pe.offsetXForZoomAndPan=e[0]-t[0],Pe.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(xe),Ce=function(e){function t(){var t=e.call(this)||this;return t.cameraCircleNode=null,t.cameraArrowNode=null,t.rotateAngle=0,t.panelSize=[298,198],t.cameraPositionToTarget=2e3,t.build(),t}return le(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),eo&&(t=o),tt&&(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.x0&&r.ye,o=-1;if(n?this.currentIdx0&&(this.currentIdx--,o=this.zoomFactors[this.currentIdx]),!(o<0||this.lastZoomFactor==o)){this.lastZoomFactor=o,1==o&&Re.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],m=this.boundsChecking(a,p,r);l=m[0],h+=m[1]}Re.panOffsetX+=l,Re.panOffsetY+=h,Re.panOffsetXForCamera+=l,Re.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:Be.ZOOM_MOUSE_WHEEL,data:{offsetX:Re.panOffsetX,offsetY:Re.panOffsetY,zoomFactor:o}})}},t.prototype.onMouseWheel=function(e){var t=(e.deltaY||-e.wheelDelta||e.detail)<0,i=-1;if(t?this.currentIdx0&&(this.currentIdx--,i=this.zoomFactors[this.currentIdx]),!(i<0||this.lastZoomFactor==i)){this.lastZoomFactor=i,1==i&&Re.clear();var n=this.nmData.getOriginSize(),o=new THREE.Vector2(e.offsetX-n[0]/2,e.offsetY-n[1]/2),s=this.zoomFactors[this.currentIdx],r=0,a=0;if(this.nmData.isZooming=!0,t){var l=s/(u=this.zoomFactors[this.currentIdx-1]),h=[],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]}Re.panOffsetX+=r,Re.panOffsetY+=a,Re.panOffsetXForCamera+=r,Re.panOffsetYForCamera+=a,this.nmData.setZoomFactor(i),this.nmViewer.destroy(),this.nmData.destroy(),this.nmData.build(),this.nmViewer.update(),this.nmData.updateMovement(),this.updateZoomAndPan();var p=this;1==s&&requestAnimationFrame((function(){delete p.nmData.isZooming})),this.eventManager.dispatchEvent({type:Be.ZOOM_MOUSE_WHEEL,data:{offsetX:Re.panOffsetX,offsetY:Re.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++),cm[0]&&0==u&&(l[0]+=m[0]-h,u++),c>m[1]&&0==g&&(l[1]+=m[1]-c,g++),h=(r[0]-i.x)*n+i.x,c=(r[1]-i.y)*n+i.y;var f=this.nmData.getCorner("Origin","RT");hf[1]&&0==g&&(l[1]+=f[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 h0)(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");Ve.offsetXForZoomAndPan=e[0]-t[0],Ve.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(Ae),He=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 Ie,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 Te(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 Se(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 fe(!1,this.getSize(),this.bIsShowAxisGrid,this.getZoomFactor()),this.buildFloorPlane(),this.bIsShowCameraNode){this.cameraNode=new Ce;var e=this.getOriginSize();this.cameraNode.setPanelSize(e),this.drawableItems.push(this.cameraNode)}this.intersectPoint=new De(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 we(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:r0;){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(),m=this.navigationMapData.getCameraNode();if(m){var f=this.navigationMapData.getImageSize(),w={width:f[0]/2,height:f[1]/2};if(this.navigationMapData.getAxisGridBox2D(),this.getData().worldToNormalizedPoint(p),this.algorithm.normalizedPointToScreen(p,w),m.setOpacity("1.0"),u.length()<1e-5)m.setCameraArrowOpacity("0.0"),m.setOffsetAndRotate(p.x+Re.panOffsetX,p.y+Re.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),m.setBigCamera(),m.setOffsetAndRotate(p.x+Re.panOffsetX,p.y+Re.panOffsetY,x),m.setCameraArrowOpacity("1.0")}}}},e.prototype.update=function(e){for(var t=this.navigationMapData.getDrawableItems(),i=0;ii.width||t>i.height)&&(e=this.pointOnBorder[0],t=this.pointOnBorder[1]),e=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=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]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}(),Ue=function(e){function t(t,i){var n=e.call(this)||this;return n.name=Ee.RECTPICK_Editor,n.eventManager=i,n.nmData=t.getData(),n.naviAction=new Ge(t),n.nmViewer=t,n.algorithm=new Ie,n}return le(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:Be.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]+Ve.offsetXForZoomAndPan,y:e[1]+Ve.offsetYForZoomAndPan},i={x:e[2]+Ve.offsetXForZoomAndPan,y:e[3]+Ve.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}),Ie.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+=Ve.offsetXForZoomAndPan,i.y+=Ve.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-Ve.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+l.left,t.clientY=a.intersectionPoint.y-Ve.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+l.top}return t},t}(Ae),ze=function(){function e(e,t,i){this.eventManager=new Le,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(Ee.PICK_Editor),this.enableEditor(Ee.Zoom_Editor),this.enableEditor(Ee.PAN_Editor),this.enableEditor(Ee.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;i8&&(this.onScale(t,i,n),this.touches=o))},e.prototype.onTouchEnd=function(e){for(var t=e.changedTouches[0],i=[],n=0;n{this._initialized&&this.navigationMap.renderCameraNode()},i.addCallbacks("render",this.renderCB),this.maxHeight=i.getBoundingBoxWorld().max.z,this.onClickCallback=t.onClickCallback,this.initConfig=null,this.cloudMapManager=new e.Bimface.Plugins.Map.MapManager({viewer:t.viewer}),t.type){case"Relevance":default:this.associateModel(t);break;case"SetProfile":t.isProfile=!0,this.initConfig=t,this.setProfileHeight(t);break;case"AutoProfile":t.isProfile=!0,this.setProfileAutoHeight(t)}}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}init(){t.send("Bimface.Plugins.NavigationMap.NavigationMap","init");const i=this.getEventManager(),n=e.Bimface.Plugins.NavigationMap.NavigationMapEvent;let o=this.EventType;this.navigationMap.addEventListener(o.PICK_MOUSE_UP,(e=>{const t=e.data;this.onClickCallback&&this.onClickCallback(e.data),i.fireEvent(n.MouseClicked,t)})),this._initialized=!0,this._opt.successCallback&&this._opt.successCallback(),this.navigationMap.setSize(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight),this.initConfig&&(this.setProfileHeight(this.initConfig),this.initConfig=null),this.navigationMap.addEventListener(this.EventType.NavigationMap_Rect_Changed,(e=>{this.getEventManager().fireEvent("NavigationMapRectChanged",e.rectInfo)})),this.navigationMap.addEventListener(this.EventType.NavigationMap_Rect_Destroyed,(e=>{this.getEventManager().fireEvent("NavigationMapRectDestroyed",e)})),this.addEventListener("NavigationMapRectChanged",(e=>{this._updateToolBarByMinmapRect(e)})),this.addEventListener("NavigationMapRectDestroyed",(e=>{this.toolbar&&this.toolbar.hide()}))}associateModel(e){let{mapAnchors:t,modelAnchors:i,url:n,domElement:o}=e;o&&(this.mapContainer=o),i.point1=this._viewer.globalUnitUtil.translateVector(i.point1),i.point2=this._viewer.globalUnitUtil.translateVector(i.point2);const s=Math.min(i.point1.z,i.point2.z);this.getImageSize(n,(o=>{const r=[new THREE.Vector2(i.point1.x,i.point1.y),new THREE.Vector2(i.point2.x,i.point2.y)],a=[new THREE.Vector2(t.point1.x,t.point1.y),new THREE.Vector2(t.point2.x,t.point2.y)],l=this.maxHeight,h={modelAnchor:r,mapAnchor:a,zHeight:s,maxHeight:l};this._initialized?(this.navigationMap.clearZoomAndPan(),this.navigationMap.setAnchor(h)):(this.navigationMap=new Fe(this.viewer,this.mapContainer,h),this.navigationMap.registerCameraHeightChanged(f.EVENTS.ON_CAMERA_HEIGHT_CHANGED),this.init()),this.navigationMap.saveImageSize(o),this.update(n,e.isProfile)}))}setProfileHeight(e,t,i){let n={maxPixel:800};n.height=void 0===e.height?0:e.height,void 0===e.isProfile&&(e.isProfile=!0);let o=i=>{const o=this._viewer.globalUnitUtil.revertBBox(this.viewer.getBoundingBoxWorld());let s=o.min,r=o.max;s.z=r.z=n.height;const a={point1:s,point2:r};let l=new THREE.Vector3;o.getSize(l);const h=l.x/l.y;let c=n.maxPixel,d=n.maxPixel;const u=e.domElement||this._opt.domElement,g=e.isProfile,p=u&&u.getBoundingClientRect();if(p&&p.width&&p.height){const e=p.width/p.height,n=new Image;return n.onload=()=>{const i=n.width/n.height,o=document.createElement("canvas");let l=o.getContext("2d");if(e>i){o.height=n.height,o.width=n.height*e;const t=(o.width-n.width)/2,i=t*(r.x-s.x)/n.width;a.point1.x-=i,a.point2.x+=i,l.drawImage(n,t,0,n.width,n.height)}else{o.width=n.width,o.height=n.width/e;const t=(o.height-n.height)/2,i=t*(r.y-s.y)/n.height;a.point1.y-=i,a.point2.y+=i,l.drawImage(n,0,t,n.width,n.height)}const h=o.toDataURL("image/png");let c=new THREE.Vector2(0,o.height),d=new THREE.Vector2(o.width,0);const p={modelAnchors:a,mapAnchors:{point1:c,point2:d},url:h,domElement:u,isProfile:g};this.associateModel(p),t&&t()},void(n.src=i)}h>1?d/=h:c*=h;let m=new THREE.Vector2(0,d),f=new THREE.Vector2(c,0);const w={modelAnchors:a,mapAnchors:{point1:m,point2:f},url:i,domElement:u,isProfile:g};this.associateModel(w),t&&t()};n.successCallback=o,this.cloudMapManager.removeCreateMapEvent();let s=JSON.parse(JSON.stringify(n));s.height=this._viewer.globalUnitUtil.translate(s.height),s.successCallback=o,this.cloudMapManager.createMapByHeight(s)}setProfileAutoHeight(e,t,i){let n={maxPixel:800};n.height=void 0===e.height?0:e.height;let o=i=>{const o=this._viewer.globalUnitUtil.revertBBox(this.viewer.getBoundingBoxWorld());let s=o.min,r=o.max;s.z=r.z=n.height;const a={point1:s,point2:r};let l=new THREE.Vector3;o.getSize(l);const h=l.x/l.y;let 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()};n.successCallback=o;let s=JSON.parse(JSON.stringify(n));s.height=this._viewer.globalUnitUtil.translate(s.height),s.successCallback=o,this.cloudMapManager.createMapByCamera(n),this.viewer.modelManager.dispatchEvent({type:f.EVENTS.ON_CAMERA_CHANGED_AND_RENDERED})}getImageSize(e,t){let i=document.createElement("img");i.onload=()=>{t({width:i.width,height:i.height})},i.onerror=()=>{this._opt.failureCallback&&this._opt.failureCallback()},i.src=e}update(e,t){this.navigationMap.updateUrl(e,t),this.navigationMap.destroy(),this.navigationMap.rebuildData(),this.navigationMap.render()}destroy(){this._opt.viewer.getViewer().removeCallbacks("render",this.renderCB),this.cloudMapManager.destroy(),this.navigationMap.destroy(),this.navigationMap.destroyEditor(),this.mapContainer.innerHTML=""}resize(e,t){var i=this._opt.domElement;i.style.width=e+"px",i.style.height=t+"px",this.navigationMap.resize(e,t),this.getEventManager().fireEvent("Resize",{width:e,height:t})}_clearState(){let e=this._opt.viewer,t=e._sectionBox;t&&t.exit(),e.restoreDefault()}_clearSectionBox(){let e=this._opt.viewer._sectionBox;e&&e.reset()}_updateSectionBox(t){let i=this._opt.viewer,n=i._sectionBox;if(!n){let t=new e.Bimface.Plugins.Section.SectionBoxConfig;t.viewer=i,t.id="SectionBox",n=new e.Bimface.Plugins.Section.SectionBox(t)}n.setBox(t),i.zoomToBoundingBox(t),i.render()}_updateToolBarByMinmapRect(t){const i=this._opt.domElement;let n=this._opt.viewer;if(this.toolbar)this.toolbar.show();else{let t=new e.Bimface.UI.Button.ButtonConfig;t.id="mapIsolate",t.title=BimfaceLanguage.bf_panel_map_isolation,t.className="bf-map-button bf-map-isolate";let o=new e.Bimface.UI.Button.Button(t);o.setHtml(BimfaceLanguage.bf_panel_map_isolation),o.setStyle({cursor:"default"}),o.addEventListener("Click",(()=>{this._clearState();let t=this.navigationMap.getBoundingBox();t=this._viewer.globalUnitUtil.revertBBox(t),n.isolateByBox(t,e.Bimface.Viewer.IsolateOption.HideOthers),n.zoomToBoundingBox(t),this.navigationMap.clearRectPick(),this.toolbar.hide(),n.render()}));let s=new e.Bimface.UI.Button.ButtonConfig;s.id="mapSection",s.title=BimfaceLanguage.bf_panel_map_section,s.className="bf-map-button bf-map-section";let r=new e.Bimface.UI.Button.Button(s);r.setHtml(BimfaceLanguage.bf_panel_map_section),r.setStyle({cursor:"default"}),r.addEventListener("Click",(()=>{this._clearState();let e=this.navigationMap.getBoundingBox();e=this._viewer.globalUnitUtil.revertBBox(e),this._clearSectionBox(),this._updateSectionBox(e),this.navigationMap.clearRectPick(),this.toolbar.hide(),n.render()}));let a=new e.Bimface.UI.Button.ButtonConfig;a.id="mapCancel",a.title=BimfaceLanguage.bf_general_cancel,a.className="bf-map-button bf-map-cancel";let l=new e.Bimface.UI.Button.Button(a);l.setHtml(BimfaceLanguage.bf_general_cancel),l.setStyle({cursor:"default"}),l.addEventListener("Click",(e=>{this.navigationMap.clearRectPick(),this.toolbar.hide()})),l.addEventListener("mousedown",(e=>{e.preventDefault(),e.stopPropagation()}));let h=new e.Bimface.UI.Toolbar.ToolbarConfig;h.className="bf-map-toolbar",this.toolbar=new e.Bimface.UI.Toolbar.Toolbar(h),this.toolbar.addControls([o,r,l]),this.toolbar.element.style.zIndex=11,i.appendChild(this.toolbar.element)}i.offsetWidth;const o=i.offsetHeight,s=this.toolbar.element.offsetWidth,r=this.toolbar.element.offsetHeight;t.x+t.widththis._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,S(this)}destroy(){}addEventListener(e,t){this.eventManager.addEvent(e,t)}removeEventListener(e,t){this.eventManager.getEventManager().removeEvent(e,t)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap").MapViewerConfig=class{constructor(){this.console=new e.Web.Common.Console,this.console.obsolete("The Class 'Glodon.Bimface.Plugins.NavigationMap.MapViewer'","Glodon.Bimface.Plugins.NavigationMapConfig.domElement",!1),this.map=null,this.domElement=[]}};var We=function(e,t){return We=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},We(e,t)};function je(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}We(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Xe,Ye,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;for(var r=new THREE.MeshBasicMaterial({color:this.faceDefaultColor,side:THREE.DoubleSide}),a=new Float32Array(3*e.length),l=0;l0?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;i0?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;t0?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]);var p=i.clone().add(a.clone().multiplyScalar("Z"==this.componentId?125:120));this.createTextWireframe(p),this.hide()},t.prototype.createWireframe=function(e){for(var t=new THREE.LineGeometry,i=[],n=0;n=2){var s=n[1].object.componentId;4==o.length&&2==s.length&&n[1].distance0)for(var t=this._opt.viewer.getZoomScale(),i=0,n=e.length;ii[0]+o)return!1;var s=.5*n[1];return!(ti[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 st(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=t.markupManager.getMarkupCenter(e,o);r||(r=[0,0]),i.save(),i.translate(r[0],r[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(r[0],r[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath(),n.ctx.strokeStyle="rgba("+(2*o+2)+",60,60,1)",n.ctx.fillStyle="rgba("+(2*o+2)+",60,255,1)",n.ctx.lineWidth=Wt.isMobile?18:this.lineWidth+n.lineWidth;for(var a=1,l=this.drawPoints.length;a-1)return;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.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 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.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]]);Et.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}(lt),Tt=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 st(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=this.getCenter(e),h=a[1]-r[1],c=a[0]-r[0],d=Math.abs(c),u=Math.abs(h),g=d/this.baseUnit,p=u/this.baseUnit,m=parseInt(g),f=parseInt(p),w=0==m?d:d/m,v=0==f?u:u/f;i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(l[0],l[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath();var y=[-d/2,-u/2],b=[d/2,u/2];n.ctx.strokeStyle="rgba("+(2*o+2)+",40,40,1)",n.ctx.lineWidth=Wt.isMobile?18:this.lineWidth+n.lineWidth,i.lineJoin="round",this.drawSide("orientation",w,d,y[0],y[1],i,null,o,n,!0),this.drawSide("portrait",v,u,b[0],y[1],i,null,o,n),this.drawSide("orientation",w,d,b[0],b[1],i,!0,o,n),this.drawSide("portrait",v,u,y[0],b[1],i,!0,o,n),this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var x=this.getHoverColor(t);x&&s?(i.shadowColor=x,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.fillStyle&&i.fill(),i.stroke(),i.restore(),n.ctx.stroke(),n.ctx.restore()}},t.prototype.drawSide=function(e,t,i,n,o,s,r,a,l,h){var c,d=0,u=0,g=i/t,p=n,m=o;"orientation"==e?d=t:u=t;for(var f=0;fi?c[0]=r?p-i:p+i:u&&Math.abs(c[1]-m)>i&&(c[1]=r?m-i:m+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*Et.distanceByArr(e,t),s=[t[1]-e[1],e[0]-t[0]];return s=Et.normalize(s),[n[0]+s[0]*o,n[1]+s[1]*o]},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]),o=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=[];return s.push(i[0],i[1]),s.push(i[0],o[1]),s.push(i[0],n[1]),s.push(o[0],n[1]),s.push(n[0],n[1]),s.push(n[0],o[1]),s.push(n[0],i[1]),s.push(o[0],i[1]),s},t}(ht),It=rt,St=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return st(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new 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,this.redraw(e),It.FINISHED)},t}(lt),Dt=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 st(t,e),t.prototype.draw=function(e,t,i,n,o,s){var r=e.worldToClientPoint(this.drawPoints[0]),a=this.getTextBbox(e),l=[(a[2]+a[0])/2,(a[3]+a[1])/2];this.center&&(l=e.worldToClientPoint(this.center)),i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),n.init(l,this.rotation),i.fillStyle=i.strokeStyle,i.font=this.fontSize+"px "+this.fontFamily,i.zIndex=120,n.ctx.font="bold "+this.fontSize+"px "+this.fontFamily,n.ctx.strokeStyle="rgba("+(2*o+2)+",80,80,1)",n.ctx.fillStyle="rgba("+(2*o+2)+",80,80,1)";var h=this.userText.split(/\n/);this.highlightColor?i.fillStyle=this.getHighlightFillColor():i.fillStyle=this.strokeStyle;var c=this.getHoverColor(t);c&&s?(i.shadowColor=c,i.shadowBlur=1):(i.shadowColor="",i.shadowBlur=0);for(var d=0;di&&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;ni&&(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;ne&&(e=t.width);return[e,i.length*this.fontSize]},t.prototype.getEndPt=function(e){var t=this.getTextBbox(e);return[t[2],t[3]]},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]);if(this.drawPoints[1]){s=e.worldToClientPoint(this.drawPoints[1]);var n=[(i[0]+s[0])/2,(i[1]+s[1])/2]}else var o=this.getTextBbox(e),s=(n=[(o[2]+o[0])/2,(o[3]+o[1])/2],[o[2],o[3]]);var r=[];return r.push(i[0],i[1]),r.push(i[0],n[1]),r.push(i[0],s[1]),r.push(n[0],s[1]),r.push(s[0],s[1]),r.push(s[0],n[1]),r.push(s[0],i[1]),r.push(n[0],i[1]),r},t}(ht),Bt=rt,_t=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 st(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 Bt.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=this.markupManager.getFontSize(),d=i.style.fontFamily,u=new Dt(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(e){e.stopImmediatePropagation()})),i.addEventListener("mouseup",(function(e){e.stopImmediatePropagation()})),i.addEventListener("mousemove",(function(e){e.stopImmediatePropagation()})),i.setAttribute("id",t.divId),i.style.position="absolute",i.style.left="0",i.style.top="0",this.markupManager.viewer.wrapDom.appendChild(i);var n=document.createElement("span");n.id="box",n.style.visibility="hidden",i.appendChild(n);var o=document.createElement("span");n.id="boxEdit",n.style.visibility="hidden",n.style.wordBreak="break-all",n.style.display="inline-block",i.appendChild(o)}},t.prototype.setEditBox=function(e){this.size=e},t.prototype.hideTextArea=function(e){var t=document.getElementById(e);t.blur(),t.style.display="none"},t.prototype.showTextArea=function(e){document.getElementById(e).style.display="block"},t.prototype.setUserText=function(e){this.userText=e},t.prototype.setPureText=function(e){this.pureText=e},t.prototype.addKeyDownListener=function(e){var t=this,i=document.getElementById(this.textAreaId);i&&i.addEventListener("keydown",(function(i){return t.keyDownFunction(e,i)}),!0)},t.prototype.addInputListener=function(e){var t=this,i=document.getElementById(this.textAreaId);i&&(i.addEventListener("input",(function(n){t.resize(i,e)})),i.addEventListener("blur",(function(e){})))},t.prototype.resize=function(e,i){var n=e.value.split(/\n/),o=document.querySelectorAll("#"+t.divId+" span")[0];o.innerText=e.value,o.style.fontSize=this.markupManager.getFontSize()+"px",e.style.width=o.offsetWidth+20+"px",e.rows=n.length},t.prototype.keyDownFunction=function(e,t){var i=document.getElementById(this.textAreaId);13==t.keyCode&&(i.rows=i.rows+1,console.log("Key enter pressed."))},t.prototype.addMouseDownListener=function(){var e=document.getElementById(this.textAreaId);e&&e.addEventListener("click",(function(e){console.log("Mouse click textarea now.")}))},t.prototype.createTextArea=function(e){var t=[this.startX,this.startY];this.worldPoint=e.clientToWorldPoint(t);var i=document.createElement("textArea");i.setAttribute("id",this.textAreaId),i.setAttribute("maxlength",999),i.value=null==this.userText?"":this.userText,i.style.color=this.markupManager.getColor(),i.style.position="fixed",i.style.lineHeight="100%",this.editorMode,i.style.width="10px",i.style.paddingLeft="6px",i.style.overflow="hidden",i.style.webkitUserSelect="auto",i.style.webkitAppearance="none",i.style.borderRadius=0,null!=this.userText?this.resize(i,e):i.rows="1";var n=e.wrapDom.getBoundingClientRect();return i.style.left=t[0]+n.left+"px",i.style.top=t[1]+n.top+"px",i.style.fontFamily=this.markupManager.getFontFamily(),i.style.fontSize=this.markupManager.getFontSize()+"px",i.style.border="1px solid red",i.style.background="transparent",i.style.outline="none",i.style.resize="none",i.style.zIndex=100,i.style.display="block",i},t.prototype.insertTextArea2Dom=function(e){var i=document.getElementById(t.divId),n=i.childElementCount+1;this.textAreaId="textArea_"+n;var o=this.createTextArea(e);this.textArea=o,i.appendChild(o),o.focus(),t.lastTextareaId=this.textAreaId},t.prototype.reposition=function(e){var t=e.worldToClientPoint(this.worldPoint),i=e.wrapDom.getBoundingClientRect();this.textArea.style.left=t[0]+i.left+"px",this.textArea.style.top=t[1]+i.top+"px"},t.prototype.removeTextAreaInDom=function(e){var i=document.getElementById(t.divId),n=document.getElementById(e);try{i.removeChild(n)}catch(e){}},t.lastTextareaId="",t.divId="bf-drawing-textEditor",t}(lt),At=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 st(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=t.markupManager.getMarkupCenter(e,o);r||(r=[0,0]),i.save(),i.translate(r[0],r[1]),i.rotate(this.rotation),i.beginPath(),i.lineJoin="round",n.init(r,this.rotation),n.ctx.lineWidth=Wt.isMobile?18:this.lineWidth+n.lineWidth;for(var a=1,l=this.drawPoints.length;a-1)return;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new At([],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 kt.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}(lt),Vt=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.markupType="Handdrawing",s.drawPoints=t,s.strokeStyle=i,s.lineWidth=n,s.rotation=o||0,s.bNeedHitByBbox=!1,s}return st(t,e),t.prototype.draw=function(e,t,i,n,o){if(!(this.drawPoints.length<2)){i.lineJoin="round",n.ctx.lineWidth=Wt.isMobile?18:this.lineWidth+n.lineWidth;var s=t.markupManager.getMarkupCenter(e,o);s||(s=[0,0]),i.save(),i.translate(s[0],s[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(s[0],s[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath(),n.ctx.strokeStyle="rgba("+(2*o+2)+",90,90,1)";var r=this.drawPoints.length,a=this.drawPoints;if(r<3)for(var l=1;l=0&&(this.canvas.style.cursor="",this.highLightId=-1),this.curIndex>=0){if(!(o=this.markupManager.get(this.curIndex)))return;i&&this.markupManager.hitTest(e,i[0],i[1])==this.curIndex&&this.markupManager.viewer.isEnableAnnotationPick&&(this.canvas.style.cursor="pointer",this.highLightId=this.curIndex,this.device.isPc&&(t.lineWidth=o.lineWidth,this.markupManager.viewer.alwaysMode&&o.draw(e,this.markupManager.viewer,t,this.MarkupVirtualPad,this.curIndex,!0)))}if(this.editIndex>=0){if(this.markupManager.viewer.alwaysMode)return;if(0==this.markupManager.markups.length)return this.editIndex,!1;var n=this.markupManager.getMarkupBbox(e,this.editIndex);if(!n)return;var o,s=[n[0],n[1]],r=[n[2],n[3]],a=(o=this.markupManager.get(this.editIndex)).getGrips(e,this.markupManager,this.editIndex),l=this.markupManager.getMarkupCenter(e,this.editIndex);if(!l)return;t.save(),t.translate(l[0],l[1]),"Arrow"!=o.markupType&&t.rotate(o.rotation),t.beginPath(),t.lineWidth="1",t.strokeStyle="red",t.fillStyle="#ffffff";var h=(o.lineWidth||0)/2;4!=a.length&&(this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Move")&&(t.strokeStyle="#999999"),t.strokeRect(-.5*(r[0]-s[0])-h,-.5*(r[1]-s[1])-h,r[0]-s[0]+2*h,r[1]-s[1]+2*h),t.strokeStyle="red",this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Rotate")&&(t.strokeStyle="#ffffff",t.fillStyle="#999999"),t.arc(0,s[1]-l[1]-20,6,0,2*Math.PI,!1),t.fill(),t.stroke(),t.closePath(),t.beginPath(),t.arc(0,s[1]-l[1]-20,3,.5*Math.PI,1.8*Math.PI,!1),t.moveTo(3,s[1]-l[1]-21),t.lineTo(.5,s[1]-l[1]-19.5),t.moveTo(3,s[1]-l[1]-21),t.lineTo(3,s[1]-l[1]-24.5),t.stroke()),t.closePath(),t.strokeStyle="red",t.fillStyle="#ffffff";var c=void 0,d=void 0;if("Arrow"==o.markupType){this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Stretch")&&(t.strokeStyle="#999999");var u=this.markupManager.getMarkupSize(e,this.editIndex),g=Math.sqrt(u[0]*u[0]+u[1]*u[1]),p=u[0]/g*4,m=u[1]/g*4;t.beginPath(),t.arc(a[0]-l[0]+(a[0]-1)return this.editIndex=-1,void this.redraw(e);if(n==Ot.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==Ot.RightButton&&this.tool.begin(e,t,i,n)}this.bFirstClick=!0;var a=this.editIndex;if(this.preEdit=a,this.curIndex>=0){var l=this.markupManager.get(this.curIndex),h=null==l?void 0:l.markupType;if(Wt.isMobile&&("Cloud"===h||"Polyline"===h))return;if(this.markupManager.viewer.hasOwnProperty("isEnableAnnotationPick")&&!this.markupManager.viewer.isEnableAnnotationPick)return;this.editIndex=this.curIndex,this.inEditMode=!0,this.redraw(e)}else this.editIndex=-1,this.redraw(e);this.editIndex!=a&&this.markupManager.viewer.functions.onSelectChange(this.editIndex)},e.prototype.onEditing=function(e,t,i,n){if(this.start?-1!=this.curIndex&&this.editIndex==this.curIndex||this.tool.onEditing(e,t,i,n):this.tool.onMouseMove(e,t,i,n),this.inEditMode){var o=this.markupManager.hitGrip(e,[t,i],this.editIndex);if(this.bFirstClick){this.firstPos=[t,i],this.bFirstClick=!1,this.currentGrip=o>=0?o:-1;var s=this.markupManager.get(this.editIndex);if(!s)return;return s.originPoints=s.getPoints(),s.originRotation=s.rotation,"Text"==s.markupType&&(this.editIndex==this.preEdit&&s.userText&&s.originUserText&&this.currentGrip<9?s.userText=s.originUserText:-1!=this.currentGrip&&this.currentGrip<9&&(s.originUserText=s.userText)),s.controlPt&&(s.originControlPt=s.controlPt),void(s.editPt&&(s.originEditPt=s.editPt))}var r=[t,i];9==this.currentGrip?this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Rotate")&&(this.markupManager.gripRotate(e,this.editIndex,this.firstPos,r),this.redraw(e,r)):this.currentGrip>=0&&this.currentGrip<9?this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Stretch")&&(this.markupManager.gripDragging(e,this.editIndex,this.currentGrip,this.firstPos,r),this.redraw(e,r)):this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Move")&&(this.markupManager.translatePos(e,this.editIndex,this.firstPos,r),this.redraw(e,r))}else this.bFirstClick=!0,this.currentGrip=-1},e.prototype.end=function(e,t,i,n){if(this.modelViewer&&"ViewerDrawing"===this.modelViewer.viewerType&&this.modelViewer.snapIsEnabled){var o=this.modelViewer._drawingViewer.snapToPoint(t,i),s=this.modelViewer._drawingViewer.toScreenPoint([o.GetPoint()[0],o.GetPoint()[1]]);t=s[0],i=s[1]}else this.modelViewer&&"Viewer3D"===this.modelViewer.viewerType&&this.modelViewer.snap&&(t=this.modelViewer.snap.context.hoverPosition.x,i=this.modelViewer.snap.context.hoverPosition.y);this.start&&(-1!=this.curIndex&&this.editIndex==this.curIndex||Ot.FINISHED==this.tool.end(e,t,i,n)&&(this.start=!1)),this.onEditing(e,t,i,n),this.inEditMode&&(this.inEditMode=!1),this.start=!1},e.prototype.onExit=function(e){this.tool.onExit(e)},e.prototype.onMouseWheel=function(e,t){this.start},e.prototype.onKeyDown=function(e,t){this.editIndex>=0&&("Delete"==t.code||"Backspace"==t.code)&&this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Delete")&&(this.markupManager.remove(this.editIndex),this.curIndex=-1,this.editIndex=-1,this.redraw(e))},e.prototype.onClick=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n);if(0==t.button||2==t.button&&this.isEndDrawingForRightClick){var s={click:0==t.button?0:1,clientPosition:{x:t.clientX,y:t.clientY},screenPosition:{x:t.screenX,y:t.screenY},eventType:0==t.button?"Click":"RightClick"};this.markupManager.viewer.functions.onClick(at(at({},s),o))}}this.isEndDrawingForRightClick=!0},e.prototype.onTouch=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={click:2,clientPosition:{x:t.touches[0].pageX,y:t.touches[0].pageY},screenPosition:{x:t.touches[0].screenX,y:t.touches[0].screenY},eventType:"touch"};this.markupManager.viewer.functions.onTouch(at(at({},s),o))}this.isEndDrawingForRightClick=!0},e.prototype.onLongPress=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={click:2,clientPosition:{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY},screenPosition:{x:t.changedTouches[0].screenX,y:t.changedTouches[0].screenY},eventType:"longPress"};this.markupManager.viewer.functions.onLongPress(at(at({},s),o))}},e.prototype.onDoubleClick=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={clientPosition:{x:t.clientX,y:t.clientY},screenPosition:{x:t.screenX,y:t.screenY}};this.markupManager.viewer.functions.onDoubleClick(at(at({},s),o))}this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Edit")&&(this.tool.onDoubleClick&&this.tool.onDoubleClick(e,t),this.editText(e))},e.prototype.onDoubleTouch=function(e,t){this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Edit")&&(this.tool.onDoubleTouch&&this.tool.onDoubleTouch(e,t),this.editText(e))},e.prototype.editText=function(e){if(!(this.curIndex<0||null==this.curIndex)){var t=this.markupManager.get(this.curIndex);if(t){var i=t.getPoints();if("Text"==t.markupType){""!=_t.lastTextareaId&&(this.textMarkupTool?this.textMarkupTool.initDom(e):this.tool.initDom(e));var n=new _t(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],Ot.LelftButton),n.setEditBox(t.getTextSize()),this.device.isMobileApple||this.device.isPc||setTimeout((function(){n.reposition(e)}),500),this.markupManager.remove(this.curIndex),this.highLightId=-1,this.curIndex=-1,this.editIndex=-1,this.textMarkupTool=n,this.redraw(e)}}}},e.prototype.onMouseDown=function(e,t){2==t.button?(e.startX=null,e.startY=null,this.isEndDrawingForRightClick=!0,(this.tool instanceof Lt||this.tool instanceof Ct)&&(this.isEndDrawingForRightClick=this.tool.getIsEndDrawing()),this.tool.onMouseRightClick&&this.tool.onMouseRightClick(e,t)):this.begin(e,t.offsetX,t.offsetY,t.buttons)},e.prototype.onMouseMove=function(e,t){var i=this.formatEventOffset(e,t);this.onEditing(e,i.x,i.y,t.buttons)},e.prototype.onMouseUp=function(e,t,i){var n=this.formatEventOffset(e,t);this.markupManager.viewer.alwaysMode&&2==t.button&&(this.markupManager.hitTest(e,n.x,n.y,!0)>-1&&(t.preventDefault(),t.stopPropagation()));if(this.curIndex>=0&&this.markupManager.viewer.alwaysMode){if(!this.device.isPc)return;var o=this.markupManager.get(this.curIndex),s=this.markupManager.getHighlightConfig()||{highlightColor:""};o&&(o.highlightColor=o.highlightColor?"":s.highlightColor,this.redraw(e))}return this.end(e,n.x,n.y,t.buttons)},e.prototype.onTouchstart=function(e,t){var i=this.formatEventOffset(e,t);this.touchPos=[i.x,i.y],this.begin(e,i.x,i.y,1)},e.prototype.onTouchmove=function(e,t){var i=this.formatEventOffset(e,t);this.touchPos=[i.x,i.y],this.onEditing(e,i.x,i.y,1)},e.prototype.onTouchend=function(e,t){var i=this.formatEventOffset(e,t);return this.end(e,this.touchPos.length>0?this.touchPos[0]:i.x,this.touchPos.length>0?this.touchPos[1]:i.y,1)},e.prototype.isPanMode=function(e){return e==Ot.MiddleButton||e==Ot.RightButton},e.prototype.formatEventOffset=function(e,t){var i,n,o=this.canvas.getBoundingClientRect();if(Wt.isMobile){var s=t.touches.length>0?t.touches:t.changedTouches;i=s[0].pageX-(o.x||o.left),n=s[0].pageY-(o.y||o.top)}else i=t.clientX-(o.x||o.left),n=t.clientY-(o.y||o.top);return{x:i,y:n}},e.prototype.redraw=function(e,t){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.fillStyle="rgba(0,0,0,0)",this.MarkupVirtualPad.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.markupManager.draw(e,this.ctx),this.onDrawing(e,this.ctx,t),this.markupManager.viewer.redrawOtherMarkups()},e.prototype.setCurIndex=function(e){this.curIndex=e},e.prototype.redrawOnlySelf=function(e,t){this.MarkupVirtualPad.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.fillStyle="rgba(0,0,0,0)",this.MarkupVirtualPad.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.markupManager.draw(e,this.ctx),this.onDrawing(e,this.ctx,t)},e.prototype.getStart=function(){return this.start},e}(),Gt=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=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=Et.rotateAround([t,i],l,-r.rotation);if(1==!(h[0]a[2]||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;ro[0]&&(o[0]=a[0]),a[1]>o[1]&&(o[1]=a[1])}return n.concat(o)}},e.prototype.getMarkupCenter=function(e,t){var i=this.getMarkupBbox(e,t);if(i)return[(i[0]+i[2])/2,(i[1]+i[3])/2]},e.prototype.setFontSize=function(e){this.fontSize=e},e.prototype.getMarkupSize=function(e,t){var i=this.getMarkupBbox(e,t);return[Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1])]},e.prototype.getFontFamily=function(){return this.fontFamily},e.prototype.setFontFamily=function(e){this.fontFamily=e},e.prototype.translatePos=function(e,t,i,n){var o=this.markups[t];if(o&&(o.setPoints(o.originPoints),o.editPt&&(o.editPt=o.originEditPt),o.controlPt&&(o.controlPt=o.originControlPt),this.getMarkupCenter(e,t))){for(var s=n[0]-i[0],r=n[1]-i[1],a=o.originPoints,l=[],h=[],c=0;cs[0]&&i[1]s[0]&&i[1]>s[1]?n[0]>g&&n[1]s[1]?n[0]>g&&n[1]>u&&(c=2*Math.PI-c):i[0]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,this,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]),m=e.worldToClientPoint(r[1]);switch(i){case 0:p[0]+=u,p[1]+=g;break;case 4:m[0]+=u,m[1]+=g;break;default:console.log("default grip id."+i)}return p=e.clientToWorldPoint(p),m=e.clientToWorldPoint(m),void s.setPoints([p,m])}var f=this.rotateTransform(n[0],n[1],s.rotation,o[0],o[1]),w=f[0]-n[0],v=f[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&&"Handdrawing"!==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,m=d[0]-h[0]/2,f=d[1]-h[1]/2,w=function(t){for(var i=0;i=2&&255==r},e.prototype.hitTest=function(e,t){var i=this.ctx.getImageData(e,t,1,1).data,n=i[0],o=i[1],s=i[2],r=i[3];return n+o+s<3?-1:s==o&&o<100&&s%10==0&&n>=2&&255==r||255==s&&o>99?(n-2)/2:void 0},e.prototype.hitGrip=function(e,t){var i=this.ctx.getImageData(e,t,1,1).data,n=i[0],o=i[1],s=i[2];if(n+o+s+i[3]<3)return-1;if(255==s){if(100==o)return 9;if(255==o)return 10;if(o>=110)return(o-110)/10}return-1},e}(),Ft=rt,Wt=function(){function e(t,i,n){var o=this;this.getDevice=function(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),i=/(?:SymbianOS)/.test(e)||t,n=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e);/(?:Chrome|CriOS)/.test(e);var s=/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),r=/(?:iPhone)/.test(e)&&!s,a=/(?:iPhone|iPad)/.test(e);return{isPc:!(this.isMobileAgent||r||n||i||s),isMobileApple:a}},this.work=!1,this.alwaysMode=!1,this.restoreState=!1,this.firstTouch=0,this.longPressTime=0,this.longPressTimer=null,this.modelViewer=t,this.canvas=this.modelViewer._markupCanvas||document.createElement("canvas"),this.canvas.id="markup",this.canvas.style.zIndex=10,this.canvas.width=i.clientWidth,this.canvas.height=i.clientHeight,this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0",!this.modelViewer._markupCanvas&&(this.modelViewer._markupCanvas=this.canvas),this.ctx=this.canvas.getContext("2d"),this.wrapDom=i,this.canvas.style.display="none",this.isShow=!1,this.functions={},this.isMobileAgent=n,e.isMobile=n||!this.getDevice().isPc,i.appendChild(this.canvas),this.modelViewer._markupViewers||(this.modelViewer._markupViewers=[]),this.modelViewer._markupViewers.push(this),this.bindEvent();var s=this;this.viewer=t.getViewer?t.getViewer():t,this.viewer.wrapDom=i,this.MarkupVirtualPad=new zt(this.viewer,i,e.isMobile),this.viewer.markupManager=this.markupManager=new Ut(this.MarkupVirtualPad,this),this.editor=this.viewer.markupEditor=new Nt(this.canvas,this.markupManager,this.MarkupVirtualPad,this.getDevice(),this.modelViewer),this.editor.markupManager=this.viewer.markupManager,this.functions.onSelectChange=function(e){},this.functions.onClick=function(e){},this.functions.onTouch=function(e){},this.functions.onLongPress=function(e){},this.functions.itemCompleted=function(e){},this.functions.onDoubleClick=function(e){},this.isEnableAnnotationPick=!0,this.operationTypes=["Delete","Edit","Move","Rotate","Stretch"];this.modelViewer.addEventListener("Resized",(function(){s.canvas.width=i.clientWidth,s.canvas.height=i.clientHeight,s.MarkupVirtualPad.canvas.width=i.clientWidth,s.MarkupVirtualPad.canvas.height=i.clientHeight,s.update()})),e.isMobile&&(this.offsetHeight=this.wrapDom.offsetHeight,setInterval((function(){var e=o.wrapDom.offsetHeight;o.offsetHeight!=e&&(o.offsetHeight=e,o.resize())}),500))}return e.prototype.resize=function(){this.editor.tool.reposition&&this.editor.tool.reposition(this.viewer)},e.prototype.getContainerSize=function(){return this.wrapDom.getBoundingClientRect()},e.prototype.setOperationTypes=function(e){this.operationTypes=e},e.prototype.setIsEnableAnnotationPick=function(e){this.isEnableAnnotationPick=e},e.prototype.hideCanvas=function(){this.isShow=!1,this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.update()}));var e=!0;this.modelViewer._markupViewers.map((function(t){t.isShow&&(e=!1)})),e&&(this.canvas.style.display="none")},e.prototype.showCanvas=function(){this.isShow=!0,this.canvas.style.display="block",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.update()}))},e.prototype.redrawOtherMarkups=function(){var e=this;this.modelViewer._markupViewers.map((function(t){t.isShow&&t!==e&&t.updateOnlySelf()}))},e.prototype.startDrawing=function(){var e=this;this.work=!0,this.alwaysMode=!1,this.modelViewer._markupViewers.map((function(t){t!==e&&(t.editor.setCurIndex(-1),t.alwaysMode=!0)})),this.showCanvas()},e.prototype.switchMode=function(){},e.prototype.initStyle=function(){var e=this.viewer.markupManager;e.markups=[],e.strokeStyle="red",e.lineWidth=3,e.fontSize=14,e.fontFamily="Arial",e.fillStyle="white",e.enableFillStyle=!1},e.prototype.update=function(){this.editor.redraw(this.viewer)},e.prototype.updateOnlySelf=function(){this.editor.redrawOnlySelf(this.viewer)},e.prototype.onlyShowSelf=function(){var e=this;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(t){t===e&&t.updateOnlySelf()}))},e.prototype.recoverAllMarkupState=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.updateOnlySelf()}))},e.prototype.bindEvent=function(){this.getDevice().isPc?(this.wrapDom.addEventListener("dblclick",this.onDoubleClick.bind(this),!1),this.wrapDom.addEventListener("mousedown",this.onMouseDown.bind(this),!0),"ViewerDrawing"===this.modelViewer.getViewerType()?this.wrapDom.parentElement.parentElement.addEventListener("mouseup",this.onMouseUp.bind(this),!0):this.wrapDom.addEventListener("mouseup",this.onMouseUp.bind(this),!1),this.wrapDom.addEventListener("mousemove",this.onMouseMove.bind(this),!1),this.wrapDom.addEventListener("mousewheel",this.onMouseWheel.bind(this),!1),this.wrapDom.addEventListener("DOMMouseScroll",this.onMouseWheel.bind(this),!1),this.wrapDom.addEventListener("contextmenu",this.oncontextmenu.bind(this),!1)):(this.wrapDom.addEventListener("touchstart",this.onTouchstart.bind(this),!0),this.wrapDom.addEventListener("touchend",this.onTouchend.bind(this),!0),this.wrapDom.addEventListener("touchmove",this.onTouchmove.bind(this),!0)),document.addEventListener("keydown",this.onKeyDown.bind(this)),document.addEventListener("keyup",this.onKeyUp.bind(this))},e.prototype.endDrawing=function(){this.work=!1,this.clearAnnotations(),this.editor.redraw(this.viewer),this.hideCanvas(),this.switchMode(),this.restoreState=!1;var e=document.querySelector("#bf-drawing-textEditor");if(e){var t=e.querySelectorAll("textarea");t.length&&(t[t.length-1].style.display="none",t[t.length-1].value="")}},e.prototype.clearAnnotations=function(){this.markupManager.clear(),this.update()},e.prototype.removeSelectedAnnotation=function(){-1!=this.editor.editIndex&&(this.markupManager.remove(this.editor.editIndex),this.editor.editIndex=-1,this.update())},e.prototype.createSnapshot=function(e){},e.prototype.showAnnotation=function(){},e.prototype.setAnnotationType=function(e){this.editor.setMarkupType(e),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)},e.prototype.setAnnotationStyle=function(e){e["stroke-color"]&&this.markupManager.setColor(e["stroke-color"]),e["font-size"]&&this.markupManager.setFontSize(e["font-size"]),e["stroke-width"]&&this.markupManager.setLineWidth(e["stroke-width"]),e["fill-color"]&&this.markupManager.setFillColor(e["fill-color"]),e["font-family"]&&this.markupManager.setFontFamily(e["font-family"])},e.prototype.getAnnotationList=function(){return this.markupManager.markups.slice()},e.prototype.setAnnotationList=function(e){var t=e[0];if(!t)return this.clearAnnotations();if(t.drawPoints&&"number"==typeof t.drawPoints[0])for(var i=0;in&&t.pageXo&&t.pageYn&&t.pageXo&&t.pageYn&&t.pageXo&&t.pageY{this.onSelectChange(e)},this._helper.functions.itemCompleted=e=>{this.itemCompleted(e)},window.addEventListener("resize",(()=>{this._helper.update()})),this.init()});o.prototype={init:function(){var e=this._opt;e.lineWidth&&this.setLineWidth(e.lineWidth),e.lineColor&&this.setLineColor(e.lineColor),e.fillColor&&this.setFillColor(e.fillColor),e.fontFamily&&this.setFontFamily(e.fontFamily),e.fontSize&&this.setFontSize(e.fontSize)},exit:function(){this.endDrawing()},onSelectChange(e){},onClick(e){this._helper.functions.onClick=e},onTouch(e){this._helper.functions.onTouch=e},onLongPress(e,n){i.send(t,"onLongPress"),0==arguments.length||1==arguments.length&&"number"!=typeof arguments[0]?this.console.warn("Parameter pressTime is required"):2!=arguments.length||"number"==typeof arguments[0]?(this._helper.setLongPressTime(e),this._helper.functions.onLongPress=n):this.console.warn("Incorrect parameter type of pressTime")},itemCompleted(e){this._helper.functions.itemCompleted=e},onDoubleClick(e){this._helper.functions.onDoubleClick=e},enablePick(e){this._helper.setIsEnableAnnotationPick(e)},setOperationMode(e){"[object Array]"===Object.prototype.toString.call(e)&&this._helper.setOperationTypes(e)},restoreOperationMode(){this._helper.setOperationTypes(["Delete","Edit","Move","Rotate","Stretch"])},getAnnotationList:function(){if(this._helper.viewer&&this._helper.viewer.getActiveLayoutId){const e=this._helper.viewer.getActiveLayoutId();0!=e&&(this._helper.currentLayoutId=e)}else this._helper.currentLayoutId&&delete this._helper.currentLayoutId;return this._helper.getAnnotationList()},setAnnotationList:function(e){e.length>0&&e[0].id&&(e=this._helper.transform(e)),this._helper.setAnnotationList(e),this._helper.update()},setState:function(e){this._opt.viewer&&"ViewerDrawing"==this._opt.viewer.viewerType&&void 0!==e.state.viewId&&this._opt.viewer.showViewById(e.state.viewId),this._helper.setState(e)},createSnapshot:function(e){this._helper.createSnapshot(e)},startDrawing:function(){this._helper.startDrawing();var e=document.querySelector(".bf-toolbar-select");e&&(e.style.display="none")},endDrawing:function(){i.send(t,"endDrawing"),this._helper.editAnnotationEnd(),this.isShowAnnotation=!1;var e=document.querySelector(".bf-toolbar-select");e&&(e.style.display="block")},clear:function(){i.send(t,"clear"),this._helper.clearAnnotations()},resize:function(){},setAnnotationType:function(e){i.send(t,"setAnnotationType"),this.restoreAnnotationAction(),this._helper.setAnnotationType(e.toLocaleLowerCase())},setLineWidth:function(e){i.send(t,"setLineWidth"),this._helper.setAnnotationStyle({"stroke-width":e})},setLineColor:function(e){i.send(t,"setLineColor"),this._helper.setAnnotationStyle({"stroke-color":`${e.getRGBA()}`})},setFillColor:function(e){i.send(t,"setFillColor"),this._helper.setAnnotationStyle({"fill-color":`${e.getRGBA()}`})},setFontFamily:function(e){i.send(t,"setFontFamily"),this._helper.setAnnotationStyle({"font-family":e})},setFontSize:function(e){i.send(t,"setFontSize"),this._helper.setAnnotationStyle({"font-size":e})},removeSelectedAnnotation:function(){this._helper.removeSelectedAnnotation()},showAnnotation:function(){this._helper.viewer&&this._helper.viewer.getActiveLayoutId&&this._helper.currentLayoutId&&this._helper.viewer.getActiveLayoutId()!=this._helper.currentLayoutId||this._helper.showAnnotation()},hideAnnotation:function(){this._helper.hideAnnotation()},setStyle:function(e){this._helper.setAnnotationStyle(e)},destroy:function(){this.endDrawing()},getCurrentState:function(){if(this.isViewer2D)var e=this._helper.getCurrentState();else{var t=this._opt.viewer.getViewer();this._opt.windowAdaption&&t.setCameraStateWithFrustum&&t.setCameraStateWithFrustum(!0);e=this._helper.getCurrentState();t.setCameraStateWithFrustum&&t.setCameraStateWithFrustum(!1)}return e},getWorldPosition:function(e){var t=this._opt.viewer,i=t.screenWidth/2,n=t.screenHeight/2,o={x:i+e.position.x,y:n-e.position.y};return t.clientToWorld(o)},inherit:function(e){for(var t in e)this[t]=e[t]},stringifyAnnotationList(e){return this._helper.markupManager.toString(e)},jsonifyAnnotationList(e){return this._helper.markupManager.fromString(e)},lockAnnotationAction(){this._helper.lockAnnotationAction&&this._helper.lockAnnotationAction()},restoreAnnotationAction(){this._helper.restoreAnnotationAction&&this._helper.restoreAnnotationAction()},highlightAnnotationByIds(e){this._helper.highlightAnnotationByIds&&this._helper.highlightAnnotationByIds(e)},clearHighlight(){this._helper.clearHighlight&&this._helper.clearHighlight()},setHighlightConfig(e){this._helper.setHighlightConfig&&this._helper.setHighlightConfig(e)}},n.AnnotationManager=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationToolbarConfig=function(){return{viewer:null,windowAdaption:!1,enableWebHanddrawing:!1}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation");let i=Object.freeze({Saved:"Saved",Cancelled:"Cancelled"});t.AnnotationToolbarEvent=i}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Bimface.Plugins.Annotation.AnnotationToolbarEvent,o=function(t){return S(this),t.viewer.getIsMobileNew&&t.viewer.getIsMobileNew()?function(t,o){var s=o._eventManager=new e.Web.Lang.EventManager;let r=e.Bimface.UI.Control.ControlEvent;var a=t.viewer,l=e.Bimface.Viewer.ViewerDrawing&&a instanceof e.Bimface.Viewer.ViewerDrawing;o.isDrawing=l;var h=e.Bimface.Viewer.ViewerPDF&&a instanceof e.Bimface.Viewer.ViewerPDF;o.isPDF=h;var c=a.getDomElement();l||(c=a.getDomElement().parentElement);var d=i.create("div","bf-annotation bf-hide");o.domElement=d;var u=e.Bimface.Plugins.Annotation.AnnotationTypeOption,g=new e.Bimface.Plugins.Annotation.AnnotationManagerConfig;g.viewer=a,g.windowAdaption=t.windowAdaption,g.annotationCallback=t.annotationCallback;var p=new e.Bimface.UI.Toolbar.ToolbarConfig;p.element=d,p.className="bf-toolbar bf-toolbar-annotation";var m=o.annotationToolbar=new e.Bimface.UI.Toolbar.Toolbar(p);o.annotationToolbar=m,l&&(g.annotationToolbar=m);var f=o._annotationManager=new e.Bimface.Plugins.Annotation.AnnotationManager(g);d.addEventListener("mousedown",(function(e){e.stopPropagation()})),d.addEventListener("touchstart",(function(e){e.stopPropagation()})),d.addEventListener("touchmove",(function(e){e.stopPropagation()}));var w=new e.Bimface.UI.Toolbar.ToolbarConfig;w.element=c,w.className="bf-toolbar bf-annotation-control";var v=o.controlToolbar=new e.Bimface.UI.Toolbar.Toolbar(w);o.controlToolbar.hide();var y=new e.Bimface.UI.Button.ButtonConfig;y.className="bf-save cancel",y.id="annotationCancel_id",y.title=BimfaceLanguage.bf_general_cancel;var b=new e.Bimface.UI.Button.SingleButton(y);b.setHtml(`${BimfaceLanguage.bf_general_cancel}`),b.addEventListener("Click",(function(){f.endDrawing(),s.fireEvent(n.Cancelled),d.addClass("bf-hide"),o.controlToolbar.hide(),P||(P=app.getToolbar("MainToolbar")),P&&P.show(),ae&&ae.hide(),W&&W.hide(),we&&we.hide(),o.restoreDomState(o.domElement.parentElement)})),v.addControl(b);var x=new e.Bimface.UI.Button.ButtonConfig;x.className="bf-save",x.id="annotatioSave_id",x.title=BimfaceLanguage.bf_general_save;var E=new e.Bimface.UI.Button.SingleButton(x);E.setHtml(`${BimfaceLanguage.bf_general_save}`),E.addEventListener("Click",(function(){l||h?s.fireEvent(n.Saved,{annotationList:f.getAnnotationList()}):s.fireEvent(n.Saved,{annotationList:f.getAnnotationList(),state:f.getCurrentState()}),f.endDrawing(),v.hide(),d.addClass("bf-hide"),ae&&ae.hide(),W&&W.hide(),we&&we.hide(),o.restoreDomState(o.domElement.parentElement)})),v.addControl(E);let P=null;c.appendChild(d);let M="Annotation_"+e.Web.Lang.Utility.UUID.createUUID();if(l){var C=new e.Bimface.UI.Button.ButtonConfig;C.className="bf-button gld-bf-drag",C.title="平移",C.id="annotationHand_id",C.groupName=M,C.needTitle=!0;var T=new e.Bimface.UI.Button.SingleButton(C);T.addEventListener("Click",(function(){f.lockAnnotationAction(),se.show(),me.hide()})),m.addControl(T)}var I=new e.Bimface.UI.Button.ButtonConfig;I.className="bf-button gld-bf-narrow ",I.title="箭头",I.id="annotationArrow_id",I.groupName=M,I.needTitle=!0;var S=new e.Bimface.UI.Button.SingleButton(I);S.addEventListener("Click",(function(){f.setAnnotationType(u.Arrow),se.show(),me.setCheckedState(!1),me.hide()})),S.setChecked(),m.addControl(S);var D=new e.Bimface.UI.Button.ButtonConfig;D.className="bf-button gld-bf-n-cloud",D.title="云线框",D.groupName=M,D.id="annotationCloudrect_id",D.needTitle=!0;var B=new e.Bimface.UI.Button.SingleButton(D);B.addEventListener("Click",(function(){f.setAnnotationType(u.CloudRect),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(B);var _=new e.Bimface.UI.Button.ButtonConfig;_.className="bf-button gld-bf-nrectangle",_.title="矩形",_.groupName=M,_.id="annotationRectangle_id",_.needTitle=!0;var A=new e.Bimface.UI.Button.SingleButton(_);A.addEventListener("Click",(function(){f.setAnnotationType(u.Rectangle),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(A);var k=new e.Bimface.UI.Button.ButtonConfig;k.className="bf-button gld-bf-noval",k.title="椭圆",k.groupName=M,k.id="annotationCircle_id",k.needTitle=!0;var L=new e.Bimface.UI.Button.SingleButton(k);L.addEventListener("Click",(function(){f.setAnnotationType(u.Ellips),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(L);var V=new e.Bimface.UI.Button.ButtonConfig;V.className="bf-button gld-bf-mark",V.title="标记",V.groupName=M,V.id="annotationCross_id",V.needTitle=!0;var R=new e.Bimface.UI.Button.SingleButton(V);if(R.addEventListener("Click",(function(){f.setAnnotationType(u.Cross),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(R),a.getIsMobileNew()){var H=new e.Bimface.UI.Button.ButtonConfig;H.className="bf-button gld-bf-n-handdrawing",H.title="手绘线",H.groupName=M,H.id="annotationHanddrawing_id";var O=new e.Bimface.UI.Button.SingleButton(H);O.addEventListener("Click",(function(){f.setAnnotationType(u.Handdrawing),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(O)}var N=new e.Bimface.UI.Button.ButtonConfig;N.className="bf-button gld-bf-ntext",N.title="文字",N.groupName=M,N.id="annotationText_id",N.needTitle=!0;var G=new e.Bimface.UI.Button.SingleButton(N);G.addEventListener("Click",(function(){f.setAnnotationType(u.Text),se.setCheckedState(!1),se.hide(),me.show()})),m.addControl(G);var U=new e.Bimface.UI.Button.ButtonConfig;U.className="bf-button bf-color",U.title="颜色",U.id="annotationColor_id",U.needTitle=!0;var z=new e.Bimface.UI.Button.ToggleButton(U);z.setHtml(''),z.addEventListener(r.StateChange,(function(e){e?(se.setCheckedState(!1),me.setCheckedState(!1),W.show(),ae.hide()):W.hide()})),m.addControl(z);var F=new e.Bimface.UI.Toolbar.ToolbarConfig;F.element=c,F.className="bf-toolbar bf-color-control";var W=o.colorToolbar=new e.Bimface.UI.Toolbar.Toolbar(F),j=new e.Bimface.UI.Button.ButtonConfig;j.className="bf-button bf-pl-15",j.title="红",j.groupName="GroupColor",j.id="annotationLineThin_id";var X=new e.Bimface.UI.Button.SingleButton(j);X.setHtml('');const Y=new e.Web.Graphics.Color(208,2,27,1);X.addEventListener("Click",(function(){z.setHtml(''),ne("color-red"),f.setLineColor(Y),W.hide(),d.removeClass("bf-hide"),z.setCheckedState(!1)})),W.addControl(X);var Z=new e.Bimface.UI.Button.ButtonConfig;Z.className="bf-button",Z.title="黄",Z.groupName="GroupColor",Z.id="annotationLineMiddle_id";var $=new e.Bimface.UI.Button.SingleButton(Z);const q=new e.Web.Graphics.Color(245,166,35,1);$.setHtml(''),$.addEventListener("Click",(function(){z.setHtml(''),ne("color-yellow"),f.setLineColor(q),W.hide(),d.removeClass("bf-hide"),z.setCheckedState(!1)})),W.addControl($);var K=new e.Bimface.UI.Button.ButtonConfig;K.className="bf-button",K.title="蓝",K.groupName="GroupColor",K.id="annotationLineThick_id";var J=new e.Bimface.UI.Button.SingleButton(K);J.setHtml('');const Q=new e.Web.Graphics.Color(74,144,226,1);J.addEventListener("Click",(function(){z.setHtml(''),ne("color-blue"),f.setLineColor(Q),W.hide(),d.removeClass("bf-hide"),z.setCheckedState(!1)})),W.addControl(J);var ee=new e.Bimface.UI.Button.ButtonConfig;ee.className="bf-button",ee.title="绿",ee.groupName="GroupColor",ee.id="annotationLineThick_id";var te=new e.Bimface.UI.Button.SingleButton(ee);te.setHtml('');const ie=new e.Web.Graphics.Color(126,211,33,1);function ne(e){se.element.removeClass("color-red").removeClass("color-yellow").removeClass("color-blue").removeClass("color-green").addClass(e),ae.element.removeClass("color-red").removeClass("color-yellow").removeClass("color-blue").removeClass("color-green").addClass(e)}te.addEventListener("Click",(function(){z.setHtml(''),ne("color-green"),f.setLineColor(ie),W.hide(),d.removeClass("bf-hide"),z.setCheckedState(!1)})),W.addControl(te),W.hide();var oe=new e.Bimface.UI.Button.ButtonConfig;oe.className="bf-button bf-line color-red",oe.title="粗细",oe.id="annotationLine_id",oe.needTitle=!0;var se=new e.Bimface.UI.Button.ToggleButton(oe);se.setHtml(''),se.addEventListener(r.StateChange,(function(e){e?(z.setCheckedState(!1),me.setCheckedState(!1),me.hide(),ae.show(),W.hide(),we.hide()):ae.hide()})),m.addControl(se);var re=new e.Bimface.UI.Toolbar.ToolbarConfig;re.element=c,re.className="bf-toolbar bf-line-control color-red";var ae=o.lineToolbar=new e.Bimface.UI.Toolbar.Toolbar(re),le=new e.Bimface.UI.Button.ButtonConfig;le.className="bf-button bf-line-button bf-pl-15",le.title="细",le.groupName="GroupLine",le.id="annotationLineThin_id";var he=new e.Bimface.UI.Button.SingleButton(le);he.setHtml(''),he.addEventListener("Click",(function(){se.setHtml(''),f.setLineWidth(3),ae.hide(),d.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(he);var ce=new e.Bimface.UI.Button.ButtonConfig;ce.className="bf-button bf-line-button",ce.title="中",ce.groupName="GroupLine",ce.id="annotationLineMiddle_id";var de=new e.Bimface.UI.Button.SingleButton(ce);de.setHtml(''),de.addEventListener("Click",(function(){se.setHtml(''),f.setLineWidth(6),ae.hide(),d.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(de);var ue=new e.Bimface.UI.Button.ButtonConfig;ue.className="bf-button bf-line-button",ue.title="粗",ue.groupName="GroupLine",ue.id="annotationLineThick_id";var ge=new e.Bimface.UI.Button.SingleButton(ue);ge.setHtml(''),ge.addEventListener("Click",(function(){se.setHtml(''),f.setLineWidth(10),ae.hide(),d.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(ge),ae.hide();var pe=new e.Bimface.UI.Button.ButtonConfig;pe.className="bf-button bf-font",pe.title="字号",pe.id="annotationFont_id",pe.needTitle=!0;var me=new e.Bimface.UI.Button.ToggleButton(pe);me.setHtml('14'),me.addEventListener(r.StateChange,(function(e){e?(z.setCheckedState(!1),se.setCheckedState(!1),we.show(),ae.hide(),W.hide()):we.hide()})),m.addControl(me),me.hide();var fe=new e.Bimface.UI.Toolbar.ToolbarConfig;fe.element=c,fe.className="bf-toolbar bf-font-control";var we=o.fontToolbar=new e.Bimface.UI.Toolbar.Toolbar(fe),ve=new e.Bimface.UI.Button.ButtonConfig;ve.className="bf-button bf-font-button bf-pl-15",ve.title="字号",ve.groupName="GroupFont",ve.id="annotationSizeSmall_id";var ye=new e.Bimface.UI.Button.SingleButton(ve);ye.setHtml("14"),ye.addEventListener("Click",(function(){me.setHtml('14'),f.setFontSize(14),we.hide(),d.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(ye);var be=new e.Bimface.UI.Button.ButtonConfig;be.className="bf-button bf-font-button",be.title="字号",be.groupName="GroupFont",be.id="annotationSizeSmall_id";var xe=new e.Bimface.UI.Button.SingleButton(be);xe.setHtml("18"),xe.addEventListener("Click",(function(){me.setHtml('18'),f.setFontSize(18),we.hide(),d.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(xe);var Ee=new e.Bimface.UI.Button.ButtonConfig;Ee.className="bf-button bf-font-button",Ee.title="字号",Ee.groupName="GroupFont",Ee.id="annotationSizeSmall_id";var Pe=new e.Bimface.UI.Button.SingleButton(Ee);Pe.setHtml("24"),Pe.addEventListener("Click",(function(){me.setHtml('24'),f.setFontSize(24),we.hide(),d.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(Pe),we.hide()}(t,this):function(t,o){var s=o._eventManager=new e.Web.Lang.EventManager,r=t.viewer,a=e.Bimface.Viewer.ViewerDrawing&&r instanceof e.Bimface.Viewer.ViewerDrawing;o.isDrawing=a;var l=e.Bimface.Viewer.ViewerPDF&&r instanceof e.Bimface.Viewer.ViewerPDF;o.isPDF=l;var h=i.create("div","bf-annotation bf-hide");o.domElement=h;var c=e.Bimface.Plugins.Annotation.AnnotationTypeOption,d=new e.Bimface.Plugins.Annotation.AnnotationManagerConfig,u=d.lineColor;d.viewer=r,d.windowAdaption=t.windowAdaption,d.annotationCallback=t.annotationCallback;var g=new e.Bimface.UI.Toolbar.ToolbarConfig;g.element=h,g.className="bf-toolbar bf-toolbar-annotation";var p=o.annotationToolbar=new e.Bimface.UI.Toolbar.Toolbar(g);o.annotationToolbar=p,a&&(d.annotationToolbar=p);var m=o._annotationManager=new e.Bimface.Plugins.Annotation.AnnotationManager(d);r.getDomElement().appendChild(h),h.addEventListener("mousedown",(function(e){e.stopPropagation()})),h.addEventListener("touchstart",(function(e){e.stopPropagation()})),h.addEventListener("touchmove",(function(e){e.stopPropagation()}));var f=new e.Bimface.UI.Toolbar.ToolbarConfig;f.element=h,f.className="bf-toolbar bf-toolbar-control";var w=new e.Bimface.UI.Toolbar.Toolbar(f);let v="Annotation_"+e.Web.Lang.Utility.UUID.createUUID();if(a){var y=new e.Bimface.UI.Button.ButtonConfig;y.className="bf-button gld-bf-drag",y.title="视图交互",y.id="annotationHand_id",y.groupName=v;var b=new e.Bimface.UI.Button.SingleButton(y);b.addEventListener("Click",(function(){m.lockAnnotationAction(),ee.show(),he.hide()})),p.addControl(b)}var x=new e.Bimface.UI.Button.ButtonConfig;x.className="bf-button gld-bf-narrow ",x.title="箭头",x.id="annotationArrow_id",x.groupName=v;var E=new e.Bimface.UI.Button.SingleButton(x);E.addEventListener("Click",(function(){m.setAnnotationType(c.Arrow),ee.show(),he.hide()})),E.setChecked(),p.addControl(E);var P=new e.Bimface.UI.Button.ButtonConfig;P.className="bf-button gld-bf-n-cloud",P.title="云线框",P.groupName=v,P.id="annotationCloudrect_id";var M=new e.Bimface.UI.Button.SingleButton(P);M.addEventListener("Click",(function(){m.setAnnotationType(c.CloudRect),ee.show(),he.hide()})),p.addControl(M);var C=new e.Bimface.UI.Button.ButtonConfig;C.className="bf-button gld-bf-ncloud",C.title="云线",C.groupName=v,C.id="annotationCloud_id";var T=new e.Bimface.UI.Button.SingleButton(C);T.addEventListener("Click",(function(){m.setAnnotationType(c.Cloud),ee.show(),he.hide()})),p.addControl(T);var I=new e.Bimface.UI.Button.ButtonConfig;I.className="bf-button gld-bf-n-ployline",I.title="折线",I.groupName=v,I.id="annotationPolyline_id";var S=new e.Bimface.UI.Button.SingleButton(I);S.addEventListener("Click",(function(){m.setAnnotationType(c.Polyline),ee.show(),he.hide()})),p.addControl(S);var D=new e.Bimface.UI.Button.ButtonConfig;D.className="bf-button gld-bf-nrectangle",D.title="矩形",D.groupName=v,D.id="annotationRectangle_id";var B=new e.Bimface.UI.Button.SingleButton(D);B.addEventListener("Click",(function(){m.setAnnotationType(c.Rectangle),ee.show(),he.hide()})),p.addControl(B);var _=new e.Bimface.UI.Button.ButtonConfig;_.className="bf-button gld-bf-noval",_.title="椭圆",_.groupName=v,_.id="annotationCircle_id";var A=new e.Bimface.UI.Button.SingleButton(_);A.addEventListener("Click",(function(){m.setAnnotationType(c.Ellips),ee.show(),he.hide()})),p.addControl(A);var k=new e.Bimface.UI.Button.ButtonConfig;k.className="bf-button gld-bf-mark",k.title="X",k.groupName=v,k.id="annotationCross_id";var L=new e.Bimface.UI.Button.SingleButton(k);if(L.addEventListener("Click",(function(){m.setAnnotationType(c.Cross),ee.show(),he.hide()})),p.addControl(L),t.enableWebHanddrawing){var V=new e.Bimface.UI.Button.ButtonConfig;V.className="bf-button gld-bf-n-handdrawing",V.title="手绘线",V.groupName=v,V.id="annotationHanddrawing_id";var R=new e.Bimface.UI.Button.SingleButton(V);R.addEventListener("Click",(function(){m.setAnnotationType(c.Handdrawing),ee.show(),he.hide()})),p.addControl(R)}var H=new e.Bimface.UI.Button.ButtonConfig;H.className="bf-button gld-bf-ntext",H.title="文字",H.groupName=v,H.id="annotationText_id";var O=new e.Bimface.UI.Button.SingleButton(H);O.addEventListener("Click",(function(){m.setAnnotationType(c.Text),ee.hide(),he.show()})),p.addControl(O);var N=new e.Bimface.UI.Button.ButtonConfig;N.className="bf-combobox bf-color",N.title="颜色",N.id="annotationColor_id";var G=new e.Bimface.UI.Button.ComboBox(N),U=new e.Bimface.UI.Button.ButtonConfig;U.className="bf-button bf-color",U.title="红",U.id="annotationColorRed_id";var z=new e.Bimface.UI.Button.ComboBoxOptionButton(U);z.color=new e.Web.Graphics.Color(208,2,27,1);var F=i.create("div","bf-color-button");F.setCss({backgroundColor:`#${z.color.getHEX()}`}),z.setHtml(F.outerHTML),G.addControl(z);var W=new e.Bimface.UI.Button.ButtonConfig;W.className="bf-button bf-color",W.title="黄",W.id="annotationColorYellow_id";var j=new e.Bimface.UI.Button.ComboBoxOptionButton(W);j.color=new e.Web.Graphics.Color(245,166,35,1);var X=i.create("div","bf-color-button");X.setCss({backgroundColor:`#${j.color.getHEX()}`}),j.setHtml(X.outerHTML),G.addControl(j);var Y=new e.Bimface.UI.Button.ButtonConfig;Y.className="bf-button bf-color",Y.title="蓝",Y.id="annotationColorBlue_id";var Z=new e.Bimface.UI.Button.ComboBoxOptionButton(Y);Z.color=new e.Web.Graphics.Color(74,144,226,1);var $=i.create("div","bf-color-button");$.setCss({backgroundColor:`#${Z.color.getHEX()}`}),Z.setHtml($.outerHTML),G.addControl(Z);var q=new e.Bimface.UI.Button.ButtonConfig;q.className="bf-button bf-color",q.title="绿",q.id="annotationColorGreen_id";var K=new e.Bimface.UI.Button.ComboBoxOptionButton(q);K.color=new e.Web.Graphics.Color(126,211,33,1);var J=i.create("div","bf-color-button");J.setCss({backgroundColor:`#${K.color.getHEX()}`}),K.setHtml(J.outerHTML),G.addControl(K),p.addControl(G);var Q=new e.Bimface.UI.Button.ButtonConfig;Q.className="bf-combobox",Q.title="粗细",Q.id="annotationLine_id";var ee=new e.Bimface.UI.Button.ComboBox(Q),te=new e.Bimface.UI.Button.ButtonConfig;te.className="bf-button bf-line",te.title="细",te.id="annotationLineThin_id";var ie=new e.Bimface.UI.Button.ComboBoxOptionButton(te);ie.lineWidth=3;var ne=i.create("div","bf-line-button");ne.setCss({height:`${ie.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-ie.lineWidth)/2+"px 4px"}),ie.element.appendChild(ne),ee.addControl(ie),te.title="中";var oe=new e.Bimface.UI.Button.ComboBoxOptionButton(te);oe.lineWidth=6,oe.id="annotationLineMiddle_id";var se=i.create("div","bf-line-button");se.setCss({height:`${oe.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-oe.lineWidth)/2+"px 4px"}),oe.element.appendChild(se),ee.addControl(oe),te.title="粗";var re=new e.Bimface.UI.Button.ComboBoxOptionButton(te);re.lineWidth=10,re.id="annotationLineThick_id";var ae=i.create("div","bf-line-button");ae.setCss({height:`${re.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-re.lineWidth)/2+"px 4px"}),re.element.appendChild(ae),ee.addControl(re),G.addEventListener("Change",(function(e){m.setLineColor(e.color),(u=e.color).getHEX(),ne.setCss({height:`${ie.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-ie.lineWidth)/2+"px 4px"}),se.setCss({height:`${oe.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-oe.lineWidth)/2+"px 4px"}),ae.setCss({height:`${re.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-re.lineWidth)/2+"px 4px"});var t=ee.getCurrentControl();ee.setSelectedControlById(t.getId())})),ee.addEventListener("Change",(function(e){m.setLineWidth(e.lineWidth)})),p.addControl(ee);var le=new e.Bimface.UI.Button.ButtonConfig;le.className="bf-combobox bf-font-button",le.title="字号",le.id="annotationFont_id";var he=new e.Bimface.UI.Button.ComboBox(le),ce=new e.Bimface.UI.Button.ButtonConfig;ce.className="bf-button bf-size",ce.title="14";var de=new e.Bimface.UI.Button.ComboBoxOptionButton(ce);de.fontSize=14,de.id="annotationSizeSmall_id",de.setHtml("14"),he.addControl(de),ce.title="18";var ue=new e.Bimface.UI.Button.ComboBoxOptionButton(ce);ue.fontSize=18,ue.id="annotationSizeMiddle_id",ue.setHtml("18"),he.addControl(ue),ce.title="24";var ge=new e.Bimface.UI.Button.ComboBoxOptionButton(ce);ge.fontSize=24,ge.id="annotationSizeLarge_id",ge.setHtml("24"),he.addControl(ge),he.addEventListener("Change",(function(e){m.setFontSize(e.fontSize)})),he.hide(),p.addControl(he);var pe=new e.Bimface.UI.Button.ButtonConfig;pe.className="bf-save",pe.title=BimfaceLanguage.bf_general_save;var me=new e.Bimface.UI.Button.SingleButton(pe);me.setHtml(BimfaceLanguage.bf_general_save),me.addEventListener("Click",(function(){a||l?s.fireEvent(n.Saved,{annotationList:m.getAnnotationList()}):s.fireEvent(n.Saved,{annotationList:m.getAnnotationList(),state:m.getCurrentState()}),m.endDrawing(),h.addClass("bf-hide"),o.restoreDomState(o.domElement.parentElement)})),w.addControl(me);var fe=new e.Bimface.UI.Button.ButtonConfig;fe.className="bf-cancel",fe.title=BimfaceLanguage.bf_general_cancel;var we=new e.Bimface.UI.Button.SingleButton(fe);we.setHtml(BimfaceLanguage.bf_general_cancel),we.addEventListener("Click",(function(){m.endDrawing(),s.fireEvent(n.Cancelled),h.addClass("bf-hide"),o.restoreDomState(o.domElement.parentElement)})),w.addControl(we)}(t,this)};o.prototype={getEventManager:function(){return this._eventManager},addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},show:function(e,t){this.isDrawing||this.isPDF||this._annotationManager.clear(),this._annotationManager.startDrawing(),this.controlToolbar&&this.controlToolbar.show(),this.domElement.removeClass("bf-hide"),this.hideDomState(this.domElement.parentElement)},hideDomState(e){let t=e.querySelector(".bf-toolbar.bf-toolbar-search");t&&(t.style.display="none");let i=e.querySelector(".bf-toolbar.bf-layout-btn-wrapper");i&&(i.style.display="none");let n=e.querySelector(".bf-toolbar.bf-tree-toolbar");n&&(n.style.display="none")},restoreDomState(e){let t=e.querySelector(".bf-toolbar.bf-toolbar-search");t&&(t.style.display="block");let i=e.querySelector(".bf-toolbar.bf-layout-btn-wrapper");i&&(i.style.display="block");let n=e.querySelector(".bf-toolbar.bf-tree-toolbar");n&&(n.style.display="block")},getAnnotationManager:function(){return this._annotationManager},exit:function(){this.annotationToolbar.hide(),this.getAnnotationManager().exit()}},t.AnnotationToolbar=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").TagConfig=function(){return{viewer:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(e){var t=this,i=this._viewer=e.viewer.getViewer();if(this._opt=e,this._renderCallback=function(){t.resize()},e.minimap){this.mapHelper=e.minimap;var n=new f.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 f.View3dAdapter(i);i.addCallbacks("render",this._renderCallback)}this._tagHelper=new f.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{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),this.hitTest(t)?(this.domContainer.style.cursor="pointer",e.preventDefault(),e.stopPropagation()):this.domContainer.style.cursor=""}),!1),this.domContainer.addEventListener("mousedown",(e=>{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top);let i=this.hitTest(t);i?(i.getIsSelected()?(this.setSelectedItem(null),i.unselect()):(this.setSelectedItem(i),i.select()),i&&e.altKey&&console.info(Object.assign({},i.content,{id:i.id})),e.preventDefault(),e.stopPropagation()):this.setSelectedItem(null)}),!1),this.domContainer.addEventListener("dblclick",(e=>{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),this.hitTest(t)&&(e.preventDefault(),e.stopPropagation())}),!1)}hitTest(e){for(var t=this.dimensionItems.length-1;t>=0;t--){let i=this.dimensionItems[t];if(i.getNotation().hitTest(e))return i}for(t=this.dimensionItems.length-1;t>=0;t--){let i=this.dimensionItems[t];if(i.hitTest(e))return i}return null}setSelectedItem(e){this.selectedItem&&(this.selectedItem.actionWhenUnselected(),this.selectedItem.unselect()),this.selectedItem=e,e&&e.actionWhenSelected()}getSelectedItem(){return this.selectedItem}hasSelected(){return null!==this.selectedItem}setIsEnableSelection(e){this.isEnableSelection=e}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension").DimensionContainerConfig=class{constructor(){this.viewer=null,this.contents=[]}};class Kt{}Kt.xmlns="http://www.w3.org/2000/svg",Kt.makeCircle=function(e){var t=document.createElementNS(Kt.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},Kt.makeConcentricCircle=function(e){var t=document.createElementNS(Kt.xmlns,"g"),i=document.createElementNS(Kt.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},Kt.makeLine=function(e){var t=document.createElementNS(Kt.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},Kt.makeRectangle=function(e){var t=document.createElementNS(Kt.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},Kt.makeText=function(e){var t=document.createElementNS(Kt.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{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=>Kt.distanceToSegment(e,i.start,i.end)<=t))}}{constructor(e){super(e),this.defaultColor="#F99D0B",this.defaultOpacity=1,this.initialize()}initialize(){super.initialize(),this.annotationStyle={height:21,radius:4},this.hitTestEpsilon=this.annotationStyle.height/2}drawAnnotation(e,t,i,o,s){var r=this.calcAnnotationStyle(t,e),a=Kt.makeRectangle({x:r.offsetRect.x,y:r.offsetRect.y,width:r.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:o||this.defaultColor,fillOpacity:s||this.defaultOpacity});this.notationUnselected.push(a);let l=Kt.makeRectangle({x:r.offsetRect.x-2,y:r.offsetRect.y-2,width:r.width+4,height:this.annotationStyle.height+4,radius:this.annotationStyle.radius,strokeColor:"#FFFFFF",fillColor:o||this.defaultColor,fillOpacity:s||this.defaultOpacity});this.notationSelected.push(l);let h=new n(r.offsetRect.x,r.offsetRect.y+this.annotationStyle.height/2),c=new n(r.offsetRect.x+r.width,h.y);this.notationSegmentRects.push({start:h,end:c});var d=Kt.makeText({x:r.offsetText.x,y:r.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});return this.svgGroup=[],this.svgGroup.push(a),this.svgGroup.push(l),this.svgGroup.push(d),this.unselect(),this.svgGroup}calcAnnotationStyle(e,t){var i=0,o=new n(t.x,t.y),s=new n(t.x,t.y);return i=Kt.measureText(e),o.x-=i/2,o.y-=this.annotationStyle.height/2,s.x=o.x+5,s.y=o.y+19-3.5,{offsetRect:o,offsetText:s,width:i+=10}}}!function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension");t.DrawableItem=class{constructor(t){this.viewer=t.viewer,this.id=e.Web.Lang.Utility.UUID.createUUID(),t.color&&(t.color instanceof e.Web.Graphics.Color||(console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),t.color=null)),this.defaultColor=t.color?"#"+t.color.getHEX():"#F99D0B",this.defaultOpacity=t.color?t.color.getAlpha():1,this.isShow=!0,this.svgGroup=[],this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.hitTestEpsilon=10,this.hitTestSegments=[],this.selectElements=[],this.unSelectElements=[],this.isSelected=!0,this.notation=new Jt(this.type),this.unitObj={Kilometer:"km",Meter:"m",Centimeter:"cm",Millimeter:"mm"}}getSvgGroup(){return this.svgGroup}getId(){return this.id}getType(){return this.type}clear(){this.detach(),this.notation.clear(),this.svgGroup=[],this.hitTestSegments=[]}detach(){for(const t of this.svgGroup){var e=t.parentNode;e&&e.removeChild(t)}}attach(e){for(const t of this.svgGroup)e.appendChild(t)}calcLine(e,t){let i=[];this.viewer.getViewer();var o=this.viewer.getDomElement().getBoundingClientRect(),s=this.viewer.viewerAdapter.worldPointsToClient(e,t);if(s){e=new n(s.start.x-o.left,s.start.y-o.top),t=new n(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i}calcTerminalLines(e,t,i){if(0===e.length)return[];let n=[],o=e[0],s=e[1],r=o.clone().sub(s).normalize(),a=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),t),l=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),-t);n.push({start:a,end:l}),r=r.multiplyScalar(-1);let h=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),t),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)}show(){for(const e of this.svgGroup)e.style.display="block";this.isSelected?this.select():this.unselect(),this.isShow=!0}hide(){for(const e of this.svgGroup)e.style.display="none";this.isShow=!1}getNotation(){return this.notation}hitTest(e){let t=this.hitTestEpsilon;for(let i=0;i0?(t=o.getDomElement().getElementsByClassName("bf-drawable-context")[0]).getElementsByClassName("bf-drawable-svg").length>0?n=t.getElementsByClassName("bf-drawable-svg")[0]:(n=i.createNS("svg","bf-drawable-svg"),t.appendChild(n)):(t=i.create("div","bf-drawable-context"),n=i.createNS("svg","bf-drawable-svg"),o.getDomElement().appendChild(t),t.appendChild(n)),this.eventControl=new qt(o,n,this._items),this.context={rootDomElement:t,dimensionContainer:n},this.dimensionContainer=n,this.id="Dimension",this.viewer.addEventListener("Rendered",(()=>{this.update()})),this.viewer.render(),e.contents&&e.contents.length>0&&this.initDimensions(e.contents))}initDimensions(t){t.map((t=>{if("Distance"==t.dimension.type){let i=new e.Bimface.Plugins.Dimension.LinearConfig;i.viewer=this.viewer;let n=new e.Bimface.Plugins.Dimension.Linear(i);n.setContent(t),this.addItem(n)}}))}addItem(e){this._items.push(e),e.attach(this.dimensionContainer)}addItems(e){e.map((e=>this.addItem(e)))}getAllItems(){return this._items}getItemById(e){let t=null;return this._items.map((i=>{i.id!=e||(t=i)})),t}hideAllItems(){this._items.map((e=>e.hide()))}showAllItems(){this._items.map((e=>e.show()))}update(){this.remove();for(const e of this._items)e.initialize(),e.attach(this.dimensionContainer),!e.isShow&&e.hide();this.eventControl.hasSelected()&&(this.eventControl.getSelectedItem().select(),!this.eventControl.getSelectedItem().isShow&&this.eventControl.getSelectedItem().hide())}clear(){this.remove(),this._items=[]}remove(){for(const e of this._items)e.clear()}}}();class Qt{constructor(){}}Qt.ifExploded=function(e,t,i){let n="ViewerDrawing"===e.getViewerType(),o="ViewerDrawingSet"===e.getViewerType();if(n||o||t instanceof Glodon.Bimface.Plugins.Drawable.ClusterTag)return t;const s=e.getViewer();if(!s.modelManager)return t;const r=s.modelManager.explosionManager;let a=t.modelId;if(i&&t.layerId){const i=e.getLayerManager().getLayer(t.layerId);if(!i)return t;if("TileLayer"===i.typeName||"TilesetLayer"===i.typeName)return t;a=i.getModelId().toString()}else{if(i&&!t.layerId)return t;a||(a=e._defaultModel.modelId.toString())}t.modelId=a;const l=e.getModel(a).getFloorExplosionDirection(),h=r.getFloorInfos(a),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()},Qt.getExplodedOffsetByLevelName=function(e,t){for(const i of e)if(i.name===t)return i.explodedHeight-i.elevation;return 0},Qt.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-es.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}}},Qt.attachExplosionOffset=function(e,t,i){let n=e.getViewer();if(!i.worldPosition&&!i.position)return;const o=i._config.objectId;let s=null;if(o){s=n.modelManager.getModel(i.modelId).modelExplosion.getExplosionTranslationByObjId(o),i.explosionOffset.x+=s.x,i.explosionOffset.y+=s.y,i.explosionOffset.z+=s.z}else s=this.getCenterExplosionOffset(n,t,i),i.explosionOffset.x=s.x,i.explosionOffset.y=s.y,i.explosionOffset.z=s.z;i.explosionOffset=t?e.globalUnitUtil.revertTranslate(i.explosionOffset,["x","y","z"]):{x:0,y:0,z:0}},Qt.getCenterExplosionOffset=function(e,t,i,n){this.scratchVector=new THREE.Vector3,e.getScene().getOriginalBoundingBoxWorld().getCenter(this.scratchVector);const o=(new THREE.Box3).expandByPoint(i.worldPosition||i.getOriginalPosition());return!0===n?CLOUD.Utils.computeAfterExplodeTranslation(this.scratchVector,o,t):CLOUD.Utils.computeExplodeTranslation(this.scratchVector,o,t)},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable").DrawableContainerConfig=function(){return{viewer:null,maxNum:20,affectedBySection:!0,enableRender:!0}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable").DrawableItemConfig=function(){return{id:null,objectId:null,modelId:null,tooltip:"",tooltipStyle:{},draggable:!1,worldPosition:new e.Web.Geometry.Point3d(0,0,0),angle:0,layerId:void 0}},function(){var n="Bimface.Plugins.Drawable.DrawableItem",o=e.Bimface.Data.StatisticsDataManager.getInstance();let s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),r=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Common.MouseButton,function(i){this.id=i.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=i.layerId,this.modelId=i.modelId,this.objectId=i.objectId,i.worldPosition?this.worldPosition=i.worldPosition:console.log("worldPosition must not be empty."),null!=i.viewerDrawingId&&(this.viewerDrawingId=i.viewerDrawingId),this.config=i,this.angle=i.angle,this.explosionOffset=new t,this.explosionExtent=0,this._enableDepthTest=i.enableDepthTest,this._isCover=!1,this._enableDepthTestCallback=null,S(this)});r.prototype={draw:function(e){},onClick:function(e){o.send(n,"onClick"),this._onclick=e},onDoubleClick:function(e){o.send(n,"onClick"),this._doubleClick=e},onRightClick:function(e){o.send(n,"onRightClick"),this._onrightclick=e},onEndDrag:function(e){o.send(n,"onEndDrag"),this._onenddrag=e},setTooltip:function(e){o.send(n,"setTooltip"),this.tipElement.querySelector("span").innerText=e},setTooltipStyle:function(e){for(var t in o.send(n,"setTooltipStyle"),e)this.tipElement.style[t]=e[t],"backgroundColor"===t&&(this.tipElement.childNodes[0].childNodes[0].style.borderTopColor=e[t])},getTooltip:function(){return this.tipElement.querySelector("span").innerText},getTooltipStyle:function(){return this.tipElement.style},getWorldPosition:function(){return this.worldPosition},setWorldPosition:function(e){o.send(n,"setWorldPosition"),this.worldPosition=e},getSize:function(){return{width:this.config.width,height:this.config.height}},hide:function(){o.send(n,"hide"),this._domElement.style.display="none",this.notControlByCameraPosition=!0,this.forceHide=!0},hideByCameraPosition:function(){this.notControlByCameraPosition||(this._domElement.style.display="none",this.forceHide=!0)},show:function(){o.send(n,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this._domElement.style.display="",this.forceHide=!1)},showByCameraPosition:function(){this.forceHide&&(this.notControlByCameraPosition||(this._domElement.style.display="",this.forceHide=!1))},updateVisibility:function(){this.isHideByClustering||this.forceHide?this._domElement.style.display="none":this._domElement.style.display="block"},attachExplosionOffset:function(e,n){if(!this.worldPosition)return;let o=this._config.objectId;if(o){let i=e.modelManager.getBoundingBoxByIds([o]),s=this.assoiatedComponentBbox,r=i;if(s){let e=r.getCenter().clone();e.sub(s.getCenter().clone()),this.explosionOffset=e,this.explosionExtent>0&&0===n&&(this.worldPosition.x+=e.x,this.worldPosition.y+=e.y,this.worldPosition.z+=e.z,this.explosionExtent=0,this.explosionOffset=new t,this.assoiatedComponentBbox=r.clone())}}else{let t=e.getScene().getOriginalBoundingBoxWorld().getCenter(),o=(new i).expandByPoint(this.worldPosition),s=CLOUD.Utils.computeExplodeTranslation(t,o,n);this.explosionOffset=s}},setInitialExplosionInfo:function(e){if("Viewer3D"!==e.getViewerType()&&"ViewerGIS"!==e.getViewerType())return;let t=null;"Viewer3D"===e.getViewerType()?t=this.modelId?e.getModel(this.modelId):e.getDefaultModel():"ViewerGIS"===e.getViewerType()&&(t=e.getLayerManager().getLayer(this.layerId)||null),this.explosionExtent=null===t?0:t.getExplosionExtent();const i=this._config.objectId;if(!i)return;e.getViewer().modelManager.getBoundingBoxByIds([i]).isEmpty()&&(this._config.objectId=null,console.log("Cannot find component with Id "+i))},clearExplosionOffset:function(){this.explosionOffset=new t},getCurrentPosition:function(){return{x:this.worldPosition.x+this.explosionOffset.x,y:this.worldPosition.y+this.explosionOffset.y,z:this.worldPosition.z+this.explosionOffset.z}},getId:function(){return this.id},handleEnableDepthTest(t){if(!this._enableDepthTest||!this.viewer)return;if("Viewer3D"!==this.viewer.getViewerType()&&"ViewerGIS"!==this.viewer.getViewerType())return;if("LeadLabel"==this.name&&this._modelId&&this._objectId&&"Viewer3D"==this.viewer.getViewerType()){this.update&&this.update();let e=this.viewer.getModel(this._modelId).getComponentStatus(this._objectId);if("hidden"==e||"translucent"==e)return void(this._isCover=!1)}!t&&(t=this.viewer.getCameraStatus().position);let i=new THREE.Vector3(...Object.values(t)),n=new THREE.Vector3(...Object.values(this.worldPosition));const o=n.clone().sub(i).normalize(),s=this.viewer.getComponentsByRaycaster(i,o,[]);let r=s.length>0?s[0].distance:n.clone().sub(i).length(),a=1;switch(this.viewer.getUnit()){case e.Bimface.Common.Units.LengthUnits.Kilometer:a=1e-6;break;case e.Bimface.Common.Units.LengthUnits.Meter:a=.001;break;case e.Bimface.Common.Units.LengthUnits.Centimeter:a=.1;break;case e.Bimface.Common.Units.LengthUnits.Millimeter:a=1}let l=n.clone().sub(i).length()>=r+a;this._isCover!=l&&this._enableDepthTestCallback&&this._enableDepthTestCallback(l),this._isCover=l},enableDepthTest:function(e){this._enableDepthTest=e,this.handleEnableDepthTest()},isDepthTestEnabled:function(){return this._enableDepthTest},onObstructionChanged:function(e){this._enableDepthTestCallback=e,this._enableDepthTest&&(this.handleEnableDepthTest(),e(this._isCover))}},s.DrawableItem=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(){this.rootDomElement=i.create("div","bf-drawable-context"),this.clientPosition=null};n.prototype.destroy=function(){this.rootDomElement.parentNode&&this.rootDomElement.parentNode.removeChild(this.rootDomElement)},t.DrawableContext=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.ImageConfig=function(){let e={width:32,height:32,viewer:null,opacity:.75,src:null,offsetX:0,offsetY:0,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1};return Object.assign({},i,e)}}(),function(){var t="Bimface.Plugins.Drawable.Image",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Bimface.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),r=function(e){o.call(this,e);let t=this;this._isDragging=!1;let i=s.create("div","bf-drawable-text"),n=s.create("img","bf-drawable-image");i.draggable=!1,n.src=e.src,n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,n.style.opacity=`${e.opacity}`,n.style.transform=`rotate(${e.angle}deg)`,i.appendChild(n),this._config=e,this._domElement=i,this._imgElement=n;let r=s.create("div","bf-tooltip tooltipTop");r.style.display="none",r.innerHTML=`
${e.tooltip}
`,r.style.left=`${e.tooltipStyle.left}`,r.style.top=`${e.tooltipStyle.top}`;var a,l=e.tooltipStyle;this.tipElement=r,this.setTooltipStyle(l),i.appendChild(r),this.clientPosition={},this.visibleDistance=e.visibleDistance;e.draggable&&s.drag({element:i,cursor:"pointer",end:function(e){t._isDragging=!1;var i,n=t.viewer,o="Viewer3D"===n.getViewerType(),s="ViewerGIS"===n.getViewerType(),r={x:e.x-a.x+t.clientPosition.x,y:e.y-a.y+t.clientPosition.y};if(o){var l=n.pickByPoint(r);if(!l||!l.objectId)return void t.update();if(l.objectId){t._config.objectId=l.objectId;let e=n.getViewer().getComponentInfoByUserId(l.objectId);t.levelName=e&&e.userData&&e.userData.levelName,t.setInitialExplosionInfo(n),t.clearExplosionOffset(),t.needForceUpdate=!0}i=l.worldPosition}else if(s){let e=n.getDomElement().getBoundingClientRect(),o=n.getViewer().pickByPoint({x:r.x+e.left,y:r.y+e.top});if(!o||!o.meshId)return void t.update();o.meshId&&(t._config.objectId=o.meshId),i=o.worldPosition}else i=n.clientToWorld(r);i?(t.worldPosition=i,t.update(),t._onenddrag&&t._onenddrag(t)):t.update()},start:function(e){a=e},move:function(){t._isDragging=!0}}),i.addEventListener("mouseup",(function(e){var i=e||window.event;"0"==i.button&&t._onclick&&(!t._isDragging||a.x==i.clientX&&a.y==i.clientY)&&(t.clickTimerId&&clearTimeout(t.clickTimerId),t.clickTimerId=setTimeout((()=>{t.event=i,t._onclick(t),delete t.event}),500))})),i.addEventListener("mousedown",(function(e){var i=e||window.event;i.stopPropagation(),"2"==i.button&&t._onrightclick?t._onrightclick(t):"1"==i.button&&t._onmiddleclick&&t._onmiddleclick(t)})),i.addEventListener("mouseover",(function(e){r&&r.querySelector("span").innerText.length>0&&(r.style.display="block")})),i.addEventListener("mouseout",(function(e){t.tipElement&&(t.tipElement.style.display="none")})),i.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),t._doubleClick&&t._doubleClick(t),t.clickTimerId&&clearTimeout(t.clickTimerId)}))};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(r,o);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._imgElement.style.opacity=e},getSrc:function(){return this._config.src},setSrc:function(e){i.send(t,"setSrc"),this._config.src=e,this._imgElement.src=e},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getAngle:function(){return this.angle},setAngle:function(e){i.send(t,"setAngle"),this.angle=e,this._imgElement.style.transform=`rotate(${e}deg)`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)}},r),n.Image=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.CustomItemConfig=function(){let e={width:0,height:0,opacity:.75,content:"",offsetX:0,offsetY:0,viewer:null,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1};return Object.assign({},i,e)}}(),function(){var t="Bimface.Plugins.Drawable.CustomItem",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),s=e.Bimface.Plugins.Drawable.DrawableItem,r=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),a=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");o.IE11Store={};let l=function(t){s.call(this,t),this._isDragging=!1;let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),o=r.create("div","bf-drawable-text");o.style.width=`${t.width}px`,o.style.height=`${t.height}px`;let a=r.create("div","bf-drawable-contentwrap");var l;o.appendChild(a),this._domElement=o,this.name="customItem",this._contentElement=a,this._config=t,this.clientPosition={},this.visibleDistance=t.visibleDistance,this.setContent(t.content);let h=r.create("div","bf-tooltip");h.style.display="none",h.innerHTML=`
${t.tooltip}
`,h.style.left=`${t.width}px`,h.style.top=`-${t.height}px`;var c=t.tooltipStyle;this.tipElement=h,this.setTooltipStyle(c),o.appendChild(h);t.draggable&&r.drag({element:o,cursor:"pointer",end:function(t){i._isDragging=!1;var n=i.viewer,o=e.Bimface.Viewer.Viewer3D&&"Viewer3D"===n.viewerType,s=e.Bimface.Viewer.ViewerGIS&&n instanceof e.Bimface.Viewer.ViewerGIS;const r=e.Bimface.Viewer.ViewerDrawing&&n instanceof e.Bimface.Viewer.ViewerDrawing;var a,h={x:t.x-l.x+i.clientPosition.x,y:t.y-l.y+i.clientPosition.y};if(o){let e=n.getDomElement().getBoundingClientRect(),t=n.pickByPoint({x:h.x+e.left,y:h.y+e.top});if(!t||!t.objectId)return void i.update();if(t.objectId){i._config.objectId=t.objectId;let e=n.getViewer().getComponentInfoByUserId(t.objectId);i.levelName=e&&e.userData&&e.userData.levelName,i.setInitialExplosionInfo(n),i.clearExplosionOffset(),i.needForceUpdate=!0}a=t.worldPosition}else if(s){let e=n.getDomElement().getBoundingClientRect(),t=n.getViewer().pickByPoint({x:h.x+e.left,y:h.y+e.top});if(!t||!t.meshId)return void i.update();t.meshId&&(i._config.objectId=t.meshId),a=t.worldPosition}else if(r){var c=n.getViewer().toWorldPoint([h.x,h.y]);a={x:c[0],y:c[1]}}else a=n.clientToWorld(h);a?(i.worldPosition=a,i.update(),i._onenddrag&&i._onenddrag(i)):i.update()},start:function(e){l=e},move:function(){i._isDragging=!0}}),o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.style.opacity=`${t.opacity}`,o.addEventListener("mouseover",(function(e){i.tipElement&&i.tipElement.querySelector("span").innerText.length>0&&(i.tipElement.style.display="block")})),o.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),o.addEventListener("keydown",(function(e){e.stopPropagation()})),n&&o.addEventListener("mouseup",(function(e){var t=e||window.event;"0"==t.button&&i._onclick&&(!i._isDragging||l.x==t.clientX&&l.y==t.clientY)&&(i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i.event=t,i._onclick(i),delete i.event}),500))})),o.addEventListener("mousedown",(function(e){var t=e||window.event;t.stopPropagation(),"2"==t.button&&i._onrightclick?i._onrightclick(i):"1"==t.button&&i._onmiddleclick&&i._onmiddleclick(i)})),o.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),o.addEventListener("touchstart",(function(e){(e||window.event).stopPropagation()})),o.addEventListener("touchmove",(function(e){(e||window.event).stopPropagation()})),!n&&o.addEventListener("touchend",(function(e){var n=e||window.event;n.stopPropagation(),i._onclick&&(!t.draggable||l.x==n.changedTouches[0].clientX&&l.y==n.changedTouches[0].clientY)&&i._onclick(i)}))};a.Type.inheritPrototype(l,s);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",""==t.innerHTML&&(this.dom&&this.domId?t.appendChild(o.IE11Store[this.domId].cloneNode(!0)):this.text&&(t.innerText=this.text)),e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._domElement.style.opacity=e},getContent:function(){return this._config.content||this.text},setContent:function(n){i.send(t,"setContent"),this._contentElement.innerHTML="",n instanceof HTMLElement?(n.draggable=!1,this._config.content=n,this._domElement.content=n,this.dom=n,this.domId||(this.domId=e.Web.Lang.Utility.UUID.createUUID()),o.IE11Store[this.domId]=n.cloneNode(!0),this._contentElement.appendChild(n)):(this._contentElement.innerHTML=n,this.text=n,this._config.content="")},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){s.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return s.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){s.prototype.onObstructionChanged.call(this,e)},resetClientPosition:function(e){const t=this._domElement,i=this._config;"Viewer3D"!==this.viewer.viewerType&&"ViewerGIS"!==this.viewer.viewerType||(e=this.viewer.worldToClient(e)),t.style.left=e.x+i.offsetX-i.width/2+"px",t.style.top=e.y+i.offsetY-i.height/2+"px"},getContainer:function(){return this._domElement},setContainerVisible(e){this._domElement.style.display=!0===e?"block":"none"}},l),n.CustomItem=l}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.LeadLabelConfig=function(){let t={text:null,viewer:null,containerCss:{boxSizing:"border-box",fontSize:"12px",lineHeight:1.5,borderWidth:"2px",borderStyle:"solid",padding:"5px",borderColor:"#1f93ff",backgroundColor:"#eeeeee",padding:"2px 8px",opacity:.9},lineCss:{width:"2px",color:"#1f93ff"},pointCss:{radius:4,backgroundColor:"#1f93ff",borderColor:"#ffffff",borderStyle:"solid",borderWidth:"1px"},offset:{x:27,y:-47},height:26,width:140,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1,style:{lineColor:new e.Web.Graphics.Color(31,147,255,1),lineWidth:2,backgroundColor:new e.Web.Graphics.Color(238,238,238,1),fontSize:12}};return Object.assign({},i,t)}}(),function(){var t="Bimface.Plugins.Drawable.LeadLabel",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Bimface.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var r=function(t){o.call(this,t);let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),r=s.create("div","bf-drawable-lead-label"),a=s.create("div","bf-drawable-lead-label-textarea");r.appendChild(a);let l=s.createNS("line","bf-drawable-lead-line"),h=s.createNS("line","bf-drawable-lead-line"),c=s.createNS("circle","bf-drawable-lead-point"),d=s.createNS("g","bf-drawable-group");i._text=t.text,this.name="LeadLabel",this.isAssociateComponentHide=!1,this.visibleDistance=t.visibleDistance,r.setCss(t.containerCss),a.innerText=i._text.replace(/\n/g," ");let u=[r,l,h,c];this._labelCombination=u;let g=s.create("div","bf-tooltip");g.style.display="none",g.innerHTML=`
${t.tooltip}
`,g.style.left="0px",g.style.top="0px",this.tipElement=g,this.setTooltipStyle(t.tooltipStyle),r.appendChild(g),r.style.width=parseFloat(t.width)+"px",r.style.minHeight=parseFloat(t.height)+"px";let p=Math.trunc((t.height-8)/18);var m;a.style.webkitLineClamp=p||1,h.setAttribute("stroke-width",t.lineCss.width),h.style.stroke=t.lineCss.color,l.setAttribute("stroke-width",t.lineCss.width),l.style.stroke=t.lineCss.color,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.setStyle(t.style),this._isDragging=!1;t.draggable&&s.drag({element:r,cursor:"pointer",start:function(e){m=e},move:function(e){i._isDragging=!0;var n=e.x-m.x+i.clientPosition.x,o=e.y-m.y+i.clientPosition.y;d.setAttribute("transform",`translate(${n},${o+t.offset.y-18})`)},end:function(n){i._isDragging=!1;const o=t.viewer||i.viewer;var s="Viewer3D"===o.viewerType;this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&o instanceof e.Bimface.Viewer.ViewerGIS;var r=o.getDomElement().getBoundingClientRect(),a={x:n.x-m.x+i.clientPosition.x+r.left,y:n.y-m.y+i.clientPosition.y+r.top};if(s){var l=o.pickByPoint(a);if(l){if(i.setWorldPosition(l.worldPosition),i.bindComponentById(l.objectId,l.modelId),l.objectId){i._config.objectId=l.objectId,i._config.modelId=l.modelId;let e=o.getViewer().getComponentInfoByUserId(l.objectId,l.modelId);i.levelName=e&&e.userData&&e.userData.levelName,i.needForceUpdate=!0}i.setInitialExplosionInfo(o),i.clearExplosionOffset()}o.render()}else if(this._isViewerGIS){let e=o.getViewer().pickByPoint({x:a.x,y:a.y});if(!e||!e.meshId)return void i.update();e.meshId&&(i._config.objectId=e.meshId),i.worldPosition=e.worldPosition,i.setWorldPosition(e.worldPosition),i.update()}else{var h=o.clientToWorld(a);h&&i.setWorldPosition(h),o.update()}i._dragEnd&&i._dragEnd(i)}}),r.addEventListener("mousedown",(function(e){(e=e||event).stopPropagation()})),r.addEventListener("mouseover",(function(e){g&&g.querySelector("span").innerText.length>0&&(g.style.display="block")})),r.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),n&&r.addEventListener("click",(function(e){(e=e||event).stopPropagation(),i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i._click&&(i.event=e,i._click(i),delete i.event)}),500)})),r.addEventListener("touchstart",(function(){(event||window.event).stopPropagation(),!n&&i._click&&i._click(i)})),r.addEventListener("contextmenu",(function(e){i._rightClick&&i._rightClick(i)})),r.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),r.addEventListener("mouseenter",(function(e){a.innerText=i._text;let t=r.offsetHeight;r.addClass("bf-drawable-show"),a.addClass("bf-drawable-show"),t>r.offsetHeight&&(r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show"))})),r.addEventListener("mouseleave",(function(e){a.innerText=i._text.replace(/\n/g," "),r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show")})),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(t,i){if(!this._isDragging){this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&this.viewer instanceof e.Bimface.Viewer.ViewerGIS;var n=this._container,o=this._svgGroup,r=this._offset,a=this._config.viewer||this.viewer,l=this._objectId,h=this._modelId;if(a&&l&&!this._isViewerGIS){var c=a.getModel(h).getComponentStatus(l);if("hidden"==c||"translucent"==c)return this.hide(),void(this.isAssociateComponentHide=!0);this.isAssociateComponentHide&&(this.show(),this.isAssociateComponentHide=!1)}!0!==this.isHideByClustering?(this.clientPosition=t.clientPosition,n.style.left=`${t.clientPosition.x+r.x+23}px`,n.style.top=t.clientPosition.y+r.y-18+"px",o.setAttribute("transform",`translate(${t.clientPosition.x},${t.clientPosition.y+r.y-18})`),t.domContainer||(t.domContainer=s.create("div","bf-drawable-container"),t.rootDomElement.appendChild(t.domContainer)),t.svgContainer||(t.rootDomElement.getElementsByClassName("bf-drawable-svg").length>0?t.svgContainer=t.rootDomElement.getElementsByClassName("bf-drawable-svg")[0]:(t.svgContainer=s.createNS("svg","bf-drawable-svg"),t.rootDomElement.appendChild(t.svgContainer))),this.isShow("default"==i),t.rootDomElement.contains&&t.domContainer.contains(n)||(t.domContainer.appendChild(n),t.svgContainer.appendChild(o))):this.hide()}},setDisplayMode:function(e){this.show(),this.displayMode=e,this.isShow()},hide:function(){i.send(t,"hide"),this.forceHide=!0,this.notControlByCameraPosition=!0,this._container.style.display="none",this._svgGroup.style.display="none"},show:function(){i.send(t,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},hideByCameraPosition:function(){this.notControlByCameraPosition||(this.forceHide=!0,this._container.style.display="none",this._svgGroup.style.display="none")},showByCameraPosition:function(){!this.notControlByCameraPosition&&this.forceHide&&(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},onClick:function(e){i.send(t,"onClick"),e&&(this._click=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClick=e)},onDoubleClick:function(e){e&&(this._doubleClick=e)},onEndDrag:function(e){i.send(t,"onEndDrag"),e&&(this._dragEnd=e)},getText:function(){return this._text},setText:function(e){i.send(t,"setText"),this._domTextArea.innerText=e,this._text=e},getOpacity:function(){return this._container.style.opacity},setOpacity:function(e,n){i.send(t,"setOpacity"),this._container.style.opacity=e},getHeight:function(){return parseFloat(this._container.style.height)},setHeight:function(e){i.send(t,"setHeight"),this._container.style.height=parseFloat(e)+"px";let n=Math.trunc((e-8)/18);this._domTextArea.style.webkitLineClamp=n||1},getWidth:function(){return parseFloat(this._container.style.width)},setWidth:function(e){i.send(t,"setWidth"),this._container.style.width=parseFloat(e)+"px"},getObjectId:function(){return this._objectId},associateComponentById:function(e,t){console.log("[BIMFACE WARN]: LeadLabel.associateComponentById() is obsolete, please use LeadLabel.bindComponentById() instead."),this.bindComponentById(e,t)},bindComponentById:function(e,t){let i=(this._config.viewer||this.viewer).getViewer().getComponentInfoByUserId(e);i?(this.levelName=i.userData&&i.userData.levelName,this._objectId=e,this._config.objectId=e,this._modelId=t):console.warn("invalid component id")},clearAssociation:function(){console.log("LeadLabel.clearAssociation() is obsolete, please use LeadLabel.unbind() instead."),this.unbind()},unbind:function(){this._objectId=null,this._modelId=null},isShow:function(e){var t=this._container,i=this._svgGroup;null!=this.displayMode&&(e=1!==this.displayMode),e?(t.removeClass("bf-drawable-mini"),i.removeClass("bf-drawable-mini-svg")):(t.addClass("bf-drawable-mini"),i.addClass("bf-drawable-mini-svg"))},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)},resetClientPosition:function(e){const t=this._container,i=this._config,n=i.viewer||this.viewer;"Viewer3D"!==n.viewerType&&"ViewerGIS"!==n.viewerType||(e=n.worldToClient(e)),t.style.left=`${e.x+i.offset.x+23}px`,t.style.top=e.y+i.offset.y-18+"px",this._svgGroup.setAttribute("transform",`translate(${e.x},${e.y+i.offset.y-18})`)},setContainerVisible:function(e){!0!==e?this.hide():this.show()},setStyle:function(e){if(e&&null!==e){const[t,i,n,o]=this._labelCombination,s=e.lineColor&&e.lineColor.getRGBA();e.lineColor&&(this.config.style.lineColor=e.lineColor,i.style.stroke=s,n.style.stroke=s,t.style.borderColor=s,o.style.fill=s),e.lineWidth&&(this.config.style.lineWidth=e.lineWidth,t.style.borderWidth=e.lineWidth+"px",i.style.strokeWidth=e.lineWidth+"px",n.style.strokeWidth=e.lineWidth+"px",o.style.strokeWidth=e.lineWidth+"px"),e.backgroundColor&&(this.config.style.backgroundColor=e.backgroundColor,t.style.backgroundColor=e.backgroundColor.getRGBA()),e.fontSize&&(this.config.style.fontSize=e.fontSize,t.style.fontSize=e.fontSize+"px")}null!==this.config.style&&null!==e||(this.config.style=new Object),i.send(t,"setStyle")},getStyle:function(){return this.config.style}}),n.LeadLabel=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.MiniTagConfig=function(){return Object.assign({},i,{minimap:null,floorList:[],height:20,width:20,objectId:"",src:"",worldPosition:null,viewer:null})}}();var ei=function(e,t){return ei=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},ei(e,t)};function ti(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}ei(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var ii=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=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;i1?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}(ni);window.Glodon.Bimface.Marker.View3dAdapter=oi;var si=function(e){function t(t,i){var n=e.call(this)||this;n.name="VIEW2D",n.minimap=t,n.domContainer=t.getMapContainer(),n.cameraControl=i.cameraControl,n.scene=i.getScene();var o=t.viewerFloor?t.viewerFloor.vfData:t.nmEditor.navigationMapData,s=o.width||298,r=o.height||198;return n.initialDomSize={width:s,height:r},n.currentDomSize={width:s,height:r},n._boxSize=new THREE.Vector2,n}return ti(t,e),t.prototype.getInitialDomSize=function(){return this.initialDomSize},t.prototype.resize=function(e){this.currentDomSize=e},t.prototype.getDomContainerBounds=function(){return this.currentDomSize},t.prototype.getMinimap=function(){return this.minimap},t.prototype.calculateBoundary=function(e,t,i,n){var o=(e[1].x-e[0].x)/(t[1].x-t[0].x),s=e[1].x-o*t[1].x;n.x=o*i.x+s;var r=(e[1].y-e[0].y)/(t[1].y-t[0].y),a=e[1].y-r*t[1].y;n.y=r*i.y+a},t.prototype.worldToClient=function(e){var t=this.minimap.nmView?this.minimap.nmView.viewer.globalUnitUtil.translateVector(e):new window.THREE.Vector3(e.x,e.y,e.z);if(this.minimap.nmView&&!this.minimap.nmData.isProfile&&this.minimap.nmData.modelAnchor&&this.minimap.nmData.mapAnchor)return this.calculateBoundary(this.minimap.nmData.mapAnchor,this.minimap.nmData.modelAnchor,t,t),t;var i=this.minimap.nmView?this.scene.boundingBoxWorldWithoutDEM.clone():this.minimap.getAxisGridBox2D();this.worldToNormalizedPoint(t,i);var n=this.getDomContainerBounds(),o={width:n.width/2,height:n.height/2};if(this.normalizedPointToScreen(t,o),t.x+=o.width,t.y+=o.height,this.minimap.nmView){var s=this.domContainer.getElementsByTagName("image")[0].width.baseVal.value,r=this.domContainer.getElementsByTagName("image")[0].height.baseVal.value,a=n.width-s,l=n.height-r;s=s/n.height?(l=i.min.x-t[0].x*Math.abs(i.max.x-i.min.x),d+=((a=o/n.width*n.height)-(d-c))/2):(d=i.max.y+t[0].y*Math.abs(i.max.y-i.min.y),l-=((r=s/n.height*n.width)-(h-l))/2);var u=(e.x-l)/r,g=(d-e.y)/a,p=this.viewer.drawableContainer._items.find((function(e){return e instanceof window.Glodon.Bimface.Plugins.Drawable.MiniTag}));p&&p.config.width;var m=p&&p.config.height||20;return{x:n.width*u,y:n.height*g-m/2}},t}(ni);window.Glodon.Bimface.Marker.DrawingdAdapter=ri;var ai=function(){function e(t,i){this.canUseThree=!!window.THREE,this.id=t,this.editor=i,this.position=this.canUseThree&&new window.THREE.Vector3||{x:0,y:0},this.boundingBox=this.canUseThree&&new window.THREE.Box3||{min:{x:1/0,y:1/0,z:1/0},max:{x:-1/0,y:-1/0,z:-1/0}},this.shape=null,this.style=e.getDefaultStyle(),this.selected=!1,this.highlighted=!1,this.highlightColor="#000088",this.isDisableInteractions=!1,this.ratioW=1,this.ratioH=1,this.keys={BACKSPACE:8,ALT:18,ESC:27,LEFT:37,UP:38,RIGHT:39,BOTTOM:40,DELETE:46,ZERO:48,A:65,D:68,E:69,Q:81,S:83,W:87,PLUS:187,SUB:189},this.onMouseDownBinded=this.onMouseDown.bind(this),this.onClickBinded=this.onClick.bind(this),this.onDoubleClickBinded=this.onDoubleClick.bind(this),this.onKeyUpBinded=this.onKeyUp.bind(this)}return e.prototype.addDomEventListeners=function(){this.shape.addEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.addEventListener("click",this.onClickBinded,!0),this.shape.addEventListener("dblclick",this.onDoubleClickBinded,!0),this.shape.addEventListener("touchstart",this.onClickBinded,!0),window.addEventListener("keyup",this.onKeyUpBinded)},e.prototype.removeDomEventListeners=function(){this.shape.removeEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.removeEventListener("click",this.onClickBinded,!0),this.shape.removeEventListener("dblclick",this.onDoubleClickBinded,!0),this.shape.removeEventListener("touchstart",this.onClickBinded,!0),window.removeEventListener("keyup",this.onKeyUpBinded)},e.prototype.onMouseDown=function(e){e.preventDefault(),e.stopPropagation(),2==e.button&&this.select(e.button)},e.prototype.onClick=function(e){var t=this;e.preventDefault(),e.stopPropagation(),this.clickTimerId&&clearTimeout(this.clickTimerId),this.clickTimerId=setTimeout((function(){t.select(e.button)}),500)},e.prototype.onDoubleClick=function(e){e.preventDefault(),e.stopPropagation(),this.editor.doubleClickMarker(this),this.clickTimerId&&clearTimeout(this.clickTimerId)},e.prototype.onKeyUp=function(e){if(e.keyCode===this.keys.DELETE)this.editor.deselectMarker(),this.delete()},e.prototype.createShape=function(){},e.prototype.destroy=function(){this.removeDomEventListeners(),this.deselect(),this.setParent(null)},e.prototype.set=function(e,t,i,n){this.userId=e,this.canUseThree&&this.position.set(t.x,t.y,t.z)||(this.position=t),i&&(this.boundingBox=this.canUseThree?i.clone():i),n&&(this.style=ii.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=ii.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}(),li=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=ai.shapeTypes.BUBBLE,n.createShape(),n.addDomEventListeners(),n}return ti(t,e),t}(ai),hi=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}(),ci=function(e){function t(t,i,n,o){var s=e.call(this,t,i)||this;return s.shapeType=ai.shapeTypes.COMMON,s.pictureSize=o||{width:20,height:20},s.createShape(n),s.addDomEventListeners(),s}return ti(t,e),t.prototype.createShape=function(e){this.shape=hi.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}(ai),di=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=ai.shapeTypes.COMMON,n.createShape(),n.addDomEventListeners(),n}return ti(t,e),t.prototype.createShape=function(){this.shape=hi.makeFlag()},t}(ai),ui=function(){function e(e){this.disableInteractions=function(e){this.isDisableInteractions=e},this.adapter=e,this.markers=[],this.mapGroupMarkers={},this.groups=null,this.selectedMarker=null,this.flagColors={red:"#ff2129",green:"#85af03",yellow:"#fe9829"},this.bubbleColors={red:"#f92a24",green:"#86b507",gray:"#ff9326"},this.nextMarkerId=0,this.initialized=!1,this.markerClickCallback=null,this.markerDoubleClickCallback=null,this.markerRightClickCallback=null,this.markersRatioH=1,this.markersRatioW=1}return e.prototype.getAdapter=function(){return this.adapter},e.prototype.updateDomContainer=function(){var e=this.adapter.getDomContainer();this.adapter.setDomContainer(e)},e.prototype.getMarkers=function(){return this.markers},e.prototype.getMarkersByGroupName=function(e){return this.mapGroupMarkers.hasOwnProperty(e)?this.mapGroupMarkers[e]:[]},e.prototype.addMarkerToGroup=function(e,t){this.mapGroupMarkers.hasOwnProperty(t)||(this.mapGroupMarkers[t]=[]),this.mapGroupMarkers[t].push(e)},e.prototype.setMarkerGroups=function(e){this.groups=e},e.prototype.removeMarkerInGroup=function(e,t){for(var i=this.mapGroupMarkers[t],n=0,o=i.length;n0)for(;n.childNodes.length;)n.removeChild(n.childNodes[0])},e.prototype.addMarker=function(e){var t=this.adapter.getName();if("VIEW3D"!=t&&"DRAWING"!=t&&"VIEW2D"!=t||e.setParent(this.svgGroup),this.markers.push(e),this.groups)for(var i=0,n=this.groups.length;i1&&(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=ai.getDefaultStyle();t["fill-color"]=this.getMarkerColor(e.shapeType,e.state);var i,n=e.id||this.generateMarkerId(),o=ai.shapeTypes;switch(e.shapeType){case o.BUBBLE:i=new li(n,this);break;case o.COMMON:(i=new ci(n,this,e.state,e.size)).setRatio(this.markersRatioW,this.markersRatioH),i.reset();break;case o.FLAG:default:i=new di(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{switch(e[0]){case"setMarkerClickCallback":r._tagHelper.setMarkerClickCallback(e[1]);break;case"setMarkerDoubleClickCallback":r._tagHelper.setMarkerDoubleClickCallback(e[1]);break;case"setMarkerRightClickCallback":r._tagHelper.setMarkerRightClickCallback(e[1])}})),delete this.notExecutedFns},onClick:function(e){i.send(t,"onClick"),r._tagHelper?r._tagHelper.setMarkerClickCallback(e):this.notExecutedFns.push(["setMarkerClickCallback",e])},onDoubleClick:function(e){i.send(t,"onDoubleClick"),r._tagHelper?r._tagHelper.setMarkerDoubleClickCallback(e):this.notExecutedFns.push(["setMarkerDoubleClickCallback",e])},onRightClick:function(e){i.send(t,"onRightClick"),r._tagHelper?r._tagHelper.setMarkerRightClickCallback(e):this.notExecutedFns.push(["setMarkerRightClickCallback",e])},onEndDrag:function(e){i.send(t,"onEndDrag")},zoomAndPan:function(e,t,i){r._tagHelper&&r._tagHelper.zoomAndPanMarkerById(this.id,e,t,i)}}),n.MiniTag=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.ClusterTagConfig=function(){return Object.assign({},i,{width:52,height:57,content:"",src:null,offsetX:0,offsetY:0})}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=e.Bimface.Plugins.Drawable.DrawableItem,n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){i.call(this,t),this.includedTags=[],this.clusterBbox=null,this.attachFilter=t.attachFilter;let o=n.create("div","bf-drawable-cluster");o.style.position="absolute",o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.innerHTML=this.getClusterTagHtml();let s=n.create("div","bf-drawable-cluster-textarea");s.innerText=t.content,o.appendChild(s),this.clusterStyle=e.Bimface.Plugins.Cluster.ClusterStyle.Success,this.forceHide=!1,this._config=t,this._domTextArea=s,this._container=o,this.hookEvents()};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(o,i);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({hookEvents:function(){let e=this._container,t=this;this.isMouseDown=!1,e.addEventListener("mouseup",(function(e){t.isMouseDown=!1})),e.addEventListener("mousemove",(function(e){t.isMouseDown||t.onHoverCallback&&t.onHoverCallback({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox})})),e.addEventListener("mousedown",(function(e){(e||window.event).stopPropagation(),t.isMouseDown=!0})),e.addEventListener("click",(function(e){(e||window.event).stopPropagation(),t.clickTimerId&&clearTimeout(t.clickTimerId),t.clickTimerId=setTimeout((()=>{t.onClickCallback&&t.onClickCallback({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox})}),500)})),e.addEventListener("dblclick",(function(e){(e||window.event).stopPropagation(),t._doubleClick&&t._doubleClick({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox}),t.clickTimerId&&clearTimeout(t.clickTimerId)}))},draw:function(e){var t=this._container,i=this._config;t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",e.rootDomElement.appendChild(t)},getClusterTagHtml(){let e=' ';this.attachFilter||(e="");let t=''+e;return t+=` `,t},setScale:function(e){this._container.style.transform=`scale(${e})`},getText:function(){return this._domTextArea.innerText},setText:function(e){this._domTextArea.innerText=e},updateText:function(){let e=this.getIncluded().length;this.showDetails||e<=99?(e>999&&(this._container.children[0].style.scale=1.5),e>99999?this.setText("99999"):this.setText(e.toString())):this.setText("99+")},show:function(){this._container.style.display="block",this.forceHide=!1},hide:function(){this._container.style.display="none",this.forceHide=!0},onClick:function(e){this.onClickCallback=e},onHover:function(e){this.onHoverCallback=e},include:function(e){this.includedTags.push(e)},isInclude:function(e){for(const t of this.includedTags)if(t.getId()===e)return!0;return!1},setBoundingBox:function(e){this.clusterBbox=e},getIncluded:function(){return this.includedTags},getContainer:function(){return this._container},hideIncludedTags:function(){for(const e of this.includedTags)e.isHideByClustering=!0},showIncludedTags:function(){for(const e of this.includedTags)e.isHideByClustering=!1},getCurrentPosition:function(){return{x:this.worldPosition.x,y:this.worldPosition.y,z:this.worldPosition.z}},setStyle:function(e){this.clusterStyle=e;let t=document.getElementById(this.getId());t&&(t.style.fill=e),this._domTextArea.style.color=e},getStyle:function(){return this.clusterStyle},getOpacity:function(){return""===this._container.style.opacity?1:this._container.style.opacity},setOpacity:function(e){this._container.style.opacity=e},resetClientPosition:function(e){const t=this._container,i=this._config;"Viewer3D"!==this.viewer.viewerType&&"ViewerGIS"!==this.viewer.viewerType||(e=this.viewer.worldToClient(e)),t.style.left=e.x+i.offsetX-i.width/2+"px",t.style.top=e.y+i.offsetY-i.height/2+"px"},setContainerVisible(e){this._container.style.display=!0===e?"block":"none"},play:function(e){if(!(this.clusterBbox&&this.clusterBbox.center&&this.includedTags.length>0))return void console.log("clusterBbox");const t=this.clusterBbox.center,i=this.includedTags,n=i.length;for(let e=0;e{this.animationId=requestAnimationFrame(r),this.progress>=1&&(this.curvePos=1,e&&e(),cancelAnimationFrame(this.animationId),this.progress=0),(e=>{for(let o=0;o{i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position),o=null}),500)),t&&(clearTimeout(t),t=null),t=setTimeout((()=>{clearTimeout(o),o=null,i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position)}),200)}))}a&&(n.addEventListener(e.Bimface.Viewer.ViewerGISEvent.ViewChanged,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.ViewerGISEvent.LayerVisibleChanged,(function(){i.handleEnableDepthTest()}))),s&&(n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewLoaded,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelVisibleChanged,(function(){i.handleEnableDepthTest()})));let c=()=>{n.getViewer().registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(t=>{let i=this.getAllItems();for(let o=0,s=i.length;o{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{this.calculateViewerGISExplosionOffset(e)})),c()):(n.getDomElement().getElementsByClassName("bf-drawable-context").length>0?h.rootDomElement=n.getDomElement().getElementsByClassName("bf-drawable-context")[0]:n.getDomElement().appendChild(h.rootDomElement),t.affectedBySection&&(n.addEventListener(e.Bimface.Plugins.Section.SectionBoxEvent.SectionBoxUpdate,(function(e){i.section=e,i.update()})),n.addEventListener(e.Bimface.Plugins.Section.SectionPlaneEvent.SectionPlaneUpdate,(function(e){i.section=e,i.update()}))),this.calculateViewer3dExplosionOffset=e=>{const t=e.modelId,o=e.floorInfos.length,s=n.getDefaultModel().modelId.toString(),r=n.getModel(t).getFloorExplosionExtent(),a=n.getModel(t).getFloorExplosionDirection();if(0===r)for(const e of i.getAllItems())e.setInitialExplosionInfo(n);let l=[];i.floorInfos=e;var h=function(){let e=i._items;for(let n=0,o=e.length;no.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{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}}showOrHideLabelForCamearPosition(e,t){if(this._isViewer3D||this._isViewerGIS){!e&&(e=this._viewer.getCameraStatus().position),t=t||this._items;for(let i=0;it[i].visibleDistance?t[i].hideByCameraPosition():t[i].showByCameraPosition()}this.bIsEnableMinitagUpdate=!1,this.update(),this.bIsEnableMinitagUpdate=!0}}handleEnableDepthTest(e){(this._isViewer3D||this._isViewerGIS)&&this._items&&this._items.length>0&&this._items.map((t=>{this._viewer.getViewer().camera.frustum.containsPoint(this._viewer.worldToScene(t.worldPosition))&&t.handleEnableDepthTest(e)}))}addItem(n){i.send(t,"addItem");const o=this._items,s=this._viewer;if(n.viewer=s,n.update=this.update.bind(this),!n.worldPosition)return;if(n instanceof e.Bimface.Plugins.Drawable.MiniTag)n.init(),o.push(n),this.update();else{let e=Qt.ifExploded(s,n,this._isViewerGIS);e&&("Viewer3D"===this._viewer.getViewerType()&&e.setInitialExplosionInfo(this._viewer),o.push(e),this._enableRender&&this.update())}this.showOrHideLabelForCamearPosition(),n.handleEnableDepthTest&&n.handleEnableDepthTest()}getLevelNameById(t,i){if(!this._spatialRelation){let t=new e.Bimface.Plugins.SpatialRelation.RoomConfig;t.viewer=this._viewer;let i=new e.Bimface.Plugins.SpatialRelation.Room(t);this._spatialRelation=i}let n=this._spatialRelation.getBoundaryByRoomId(t);if(n){if(this._levelsInfo)return levelName=function(e,t){let i=e[0][2];for(let e=0;e{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{let t=e._domElement||e._container;e&&this._context.rootDomElement.contains(t)&&t.remove(),e._svgGroup&&this._context.svgContainer.contains(e._svgGroup)&&this._context.svgContainer.removeChild(e._svgGroup)})),this._items=[],this.update()}update(){let t=this._items,i=this._viewer,n=this._context,o=this._maxNum;var s=document.body.getBoundingClientRect(),r=e.Bimface.Plugins.Drawable.MiniTag;if(this.bIsEnableMinitagUpdate&&r.clear(),this._isDrawingView&&(i=i.getViewer()),this._isDrawingView)for(let o=0,r=t.length;os.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=t.clientPosition.z?1:-1}));for(let i=0;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)}}}isHideFromSection(e){if(!this.section)return!1;if("SectionBox"===this.section.id){let t=this._viewer.getViewer().editorManager.getToolByName("clipByBox").isReverse,i=this.section.isIncluded(e);return t?i:!i}return!this.section.isIncluded(e)}exit(){i.send(t,"exit"),this.clear(),this._context.destroy()}hideItemsById(e){i.send(t,"hideItemsById");let n=this;if(e&&e.length>0)for(let t=0;t0)for(let t=0;t0)for(let t=0;t0)for(let t=0;t=0;){let n=t[i];if(n instanceof o&&n.clusterItemId===e){t.splice(i--,1);let e=n.getContainer();this._context.rootDomElement.contains(e)&&e.remove()}else i--}}showItemsByLayerId(e){i.send(t,"showItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;t--){let i=n[t];i.layerId==e&&i.show()}}hideItemsByLayerId(e){i.send(t,"hideItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;t--){let i=n[t];i.layerId==e&&i.hide()}}removeItemsByLayerId(e){i.send(t,"removeItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;){let i=n[t];if(i.layerId==e){let e=i._domElement||i._container;i&&this._context.rootDomElement.contains(e)&&e.remove(),i._svgGroup&&i._svgGroup.parentElement.removeChild(i._svgGroup),n.splice(t--,1)}else t--}}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster").ClusterContainerConfig=function(){return{viewer:null,enableAnimation:!0}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster")),n=e.Web.Lang.Utility.performance;i.ClusterContainer=class{constructor(e){t.send("Bimface.Plugins.Cluster","ClusterContainer"),this.viewer=e.viewer,this.isViewer3D="Viewer3D"===e.viewer.getViewerType()||"ViewerGIS"===e.viewer.getViewerType(),this.clusterItems=[],this._lastZoomFactorData=null,this.hookEvents(e.viewer),this.enableAnimation=!1!==e.enableAnimation,S(this)}hookEvents(e){let t=e.getViewerType();this.isViewer3D?this.hookViewer3DEvents():"ViewerDrawing"===t?this.hookViewerDrawingEvents():this.hookViewerDrawingSetEvents()}hookViewer3DEvents(){var t=this.viewer.getViewer();let i=[];i.push(CLOUD.EVENTS.ON_EDITOR_ZOOM),i.push(CLOUD.EVENTS.ON_EDITOR_PANING),i.push(CLOUD.EVENTS.ON_EDITOR_ROTATING),i.push(CLOUD.EVENTS.ON_EDITOR_WALKING),i.push(CLOUD.EVENTS.ON_CAMERA_ANIMATION_UPDATE);for(const e of i)t.registerEventListener(e,(()=>{this.update()}));t.registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(()=>{this.update(!0)})),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,(()=>{for(const e of this.clusterItems)e.meanShift=null;this.update(!0)}))}hookViewerDrawingEvents(){let t=e.Bimface.Viewer.ViewerDrawingEvent;this.viewer.addEventListener(t.ZoomFactorChanged,(e=>{let t=!1;(null===this._lastZoomFactorData||e>=this._lastZoomFactorData)&&(t=!0),this.update(!1,t),this._lastZoomFactorData=e}))}hookViewerDrawingSetEvents(){let t=e.Bimface.Viewer.ViewerDrawingSetEvent;this.viewer.addEventListener(t.ZoomFactorChanged,(e=>{let t=!1;(null===this._lastZoomFactorData||e>=this._lastZoomFactorData)&&(t=!0),this.update(!1,t),this._lastZoomFactorData=e}))}addCluster(e){e.viewer=this.viewer,e.init(),this.clusterItems.push(e),e.setIsNeedMakingClusterTag(!0)}addClusters(e){for(const t of e)this.addCluster(t)}getClusterById(e){for(const t of this.clusterItems)if(t.getId()===e)return t;return null}getClusters(){return this.clusterItems}removeClustersById(e){let t=this.clusterItems;for(let i=t.length-1;i>=0;){let n=t[i];e.indexOf(n.id)>=0?(n.clearClusterTags(),t.splice(i--,1)):i--}}clear(){for(const e of this.clusterItems)e.clearClusterTags();this.clusterItems=[]}update(e,t){let i=(e,t)=>{for(const i of this.clusterItems){if(this.isViewer3D){if(0===i.calcClusterLevel()){i.clearClusterTags();continue}}(e||i.isNeedClustering())&&i.clustering(t),i.updateClusterTags(this.enableAnimation)}};this.throttleAndDebounceFun||(this.throttleAndDebounceFun=n.throttleAndDebounce(i)),this.isViewer3D?this.throttleAndDebounceFun(e,t):i(e,t)}enableClusterAnimation(e){this.enableAnimation=e}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster").ClusterItemConfig=function(){return{scale:1,tags:[],distance:50,maxLevel:4,style:e.Bimface.Plugins.Cluster.ClusterStyle.Success,minClusterSize:2,viewer:null,showDetails:!1}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster");let i=Object.freeze({Danger:"#FF001F",Information:"#1A82FC",Success:"#32D3A6",Warning:"#FF9D0B"});t.ClusterStyle=i}();class gi{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=1;e--)if(o>=.5*s**(e-1)){r=e;break}return-1===r&&(r=0),0===t[1]&&(r=1),r}getLength(e){let n=this.prepareTagPositions(e),o=this.viewer3d.getCameraStatus().position;o=new t(o.x,o.y,o.z);let s=(new i).setFromPoints(n).getSize().length(),r=o.distanceTo(n[0]);n.forEach((e=>{const t=o.distanceTo(e);r=Math.min(r,t)}));let a=.995*this.getCameraMaxRange(),l=[];return l.push(r),l.push(s),l.push(a),l}getCameraMaxRange(){var e=this.viewer3d.getViewer(),t=e.camera;e.getBoundingBoxWorld().getSize(this._sceneSize);const i=.5*this.viewer3d.globalUnitUtil.revertTranslate(this._sceneSize.length())/Math.tan(THREE.Math.degToRad(.5*t.fov));return e.cameraControl.getMaximalRangeofCamera()*i}setMaxLevel(e){this._maxLevel=e}getMaxLevel(){return this._maxLevel}getMinClusterSize(){return this._minClusterSize}setMinClusterSize(e){this._minClusterSize=e}isLevelChanged(e){return this.calcClusterLevel(e)!==this.currentLevel}cullingByFrustum(e){for(const t of e){this.viewer3d.isInViewFrustum(t.worldPosition)?t.show():t.hide()}}getBoundingbox(e){return e.min=e.bbox.min,e.max=e.bbox.max,e}getCenter(e){return e.center}setDistance(){console.log("ClusterItem3D doesn't support setDistance.")}getDistance(){console.log("ClusterItem3D doesn't support getDistance.")}clustering(e,t){e.clustering(t,!0)}}class pi{constructor(e){this.viewerDrawing=e.viewer,this.searchRange=e.distance,this._minClusterSize=e.minClusterSize}prepareTagPositions(e){let i=[];for(let n=0;n{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 mi{constructor(){}}mi.time=300,mi.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{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()},mi.ZoomOutPlay=function(e,t,i,n,o,s){for(const r of i){const i=r.children;if(0===i.length)continue;const a=mi.getClusterTag(e,r.id);if(a)for(const e of i){const i=mi.getClusterTag(t,e),l=r.center;let h=null;if(i){h=i.clusterBbox.center,mi.CreateZoomOutAnimation(i,a,h,l,s);continue}const c=mi.getCluster(n,e),d=mi.getIndices(c);for(const e of d){let t=o[e];t&&(h=mi.getEndClientPosition(t),h&&mi.CreateItemZoomOutAnimation(t,a,h,l,s))}}}},mi.CreateZoomOutAnimation=function(e,t,i,n,o){const s=e.getContainer();o._context.rootDomElement.appendChild(s),mi.CreateZoomAnimation(e,t,i,n,!1,(()=>{t.show(),s.remove()}))},mi.CreateItemZoomOutAnimation=function(e,t,i,n,o){e.setContainerVisible(!0),e.isInAnimation=!0,mi.CreateZoomAnimation(e,t,i,n,!1,(()=>{t.show(),e.isInAnimation=null,e.setContainerVisible(!1)}))},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster"));class n{constructor(i){t.send("Bimface.Plugins.Cluster","ClusterItem"),this.config=i,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.setTags(i.tags),this._isVisible=!0,this.clusterTags=[],this._mapTagIsExist={},this._mapClusterTags={},this.mapDrawableStyle={},this.mapClusterException={},this.onClusterChanged=null,this.clusterStyle=i.style,this.scale=i.scale,this._isNeedClustering=!0,this._isNeedMakingClusterTag=!0,this.meanShift=null,this._lastSearchRange=null,this._lastClusters=null,this._lastClusterTags=null,S(this)}init(){this.isViewer3D="Viewer3D"===this.viewer.getViewerType()||"ViewerGIS"===this.viewer.getViewerType(),this.config.viewer=this.viewer,this.impl=this.isViewer3D?new gi(this.config):new pi(this.config)}setScale(e){this.scale=e,this.makeClusterTags()}getScale(){return this.scale}getId(){return this.id}getTags(){return this._tags}addTags(t){for(let i=0;i0?(this.impl.setMinClusterSize(e),this._isNeedClustering=!0):console.log("Invalid param, please input valid param.")}setTags(e){if(0!==e.length){if(this._tags)for(const e of this._tags)e.isHideByClustering=!1;this._tags=[],this._mapTagIsExist={},this.addTags(e)}}removeTagsByIds(e){for(let t=this._tags.length-1;t>=0;){let i=this._tags[t];e.indexOf(i.id)>=0?(this._tags.splice(t--,1),delete this._mapTagIsExist[i.id],i.isHideByClustering=!1):t--}this._isNeedClustering=!0,this.meanShift=null}setDistance(e){this.impl.setDistance(e)}getDistance(){return this.impl.getDistance()}getMaxLevel(){return this.impl.getMaxLevel()}setMaxLevel(e){this.impl.setMaxLevel(e),this._isNeedClustering=!0}onClick(e){this.onClickCallback=e;for(const e of this.clusterTags)e.onClick(this.onClickCallback)}onDoubleClick(e){this.onDoubleClickCallback=e;for(const e of this.clusterTags)e.onClick(this.onDoubleClickCallback)}onHover(e){this.onHoverCallback=e;for(const e of this.clusterTags)e.onClick(this.onHoverCallback)}hide(){for(const e of this.clusterTags)e.hide();for(let e=0;e{this.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._lastSearchRange1)for(let o=0;o=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},fi.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},fi.calcSpatialArea=function(e){if(e.length<3)return 0;let t=0,i=fi.getAllTriangle(e);for(let e=0;e3){s(o);let i=JSON.parse(JSON.stringify(e));if(i.splice(1,o.length-2),2===i.length)return;t(i)}else{l(e[0],e[1],e[2]);let i=JSON.parse(JSON.stringify(e));i.splice(1,1),t(i)}},i=function(e,t){let i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Triangle;o.set(e[0],e[1],e[2]);let s=new THREE.Triangle;s.set(e[0],e[2],t);let r=o.getNormal(i),a=s.getNormal(n),l=r.angleTo(a);return Math.abs(l-3.1415)<2e-4||Math.abs(l)<2e-4},n=function(e){for(let t=0;t{let i=e.clone();i.z=0,t.push(i)})),this.calcSpatialArea(t)},fi.cutFillAnalysis=null,fi.calcSurfaceArea=function(e,t,i){let n=0;if(e.length<3||!t)return this.console.warn("Parameter points or viewer is invalid."),n;let o=t.getViewer(),s=e.map((e=>o.worldToDrawing(e))),r=null;if("TilesetLayer"===i){let e=t.getLayerManager().getLayerByType("TilesetLayer");r=[],e.map((e=>r.push(e.id)))}return fi.cutFillAnalysis?fi.cutFillAnalysis.effectOpt({boundary:s,layerIds:r}):fi.cutFillAnalysis=new CLOUD.CutFillMeasure({boundary:s,viewer:t,layerIds:r}),n=fi.cutFillAnalysis.getTotalSuperficialArea(),n},fi.cutFillAnalysisEarth=null,fi.calcSurfaceAreaEarth=function(e,t,i){let n=0;if(e.length<3||!t)return this.console.warn("Parameter points or viewer is invalid."),n;let o=t.getViewer(),s=e.map((e=>o.worldToDrawing(e))),r=null;if("TilesetLayer"===i){let e=t.getLayerManager().getLayerByType("TilesetLayer");r=[],e.map((e=>r.push(e.id)))}return fi.cutFillAnalysisEarth?fi.cutFillAnalysisEarth.effectOpt({boundary:s,layerIds:r}):fi.cutFillAnalysisEarth=new CLOUD.SphereCutFillMeasure({boundary:s,viewer:t,layerIds:r}),n=fi.cutFillAnalysisEarth.getTotalSuperficialArea(),n};class wi{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=>fi.distanceToSegment(e,i.start,i.end)<=t))}}class vi extends wi{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=fi.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=fi.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=fi.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=fi.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=fi.measureText(e)),"SpatialArea"==this.type&&(o.x+=i/2+20,s.x+=i/2+20,o.y-=3,s.y-=3),{offsetRect:o,offsetText:s,width:i+=10}}}class yi extends wi{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=fi.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=fi.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});this.notationSelected.push(h);let c=fi.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=fi.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=fi.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=fi.measureText(e),!0===i?r.x+=15:r.x-=o/2,r.y-=this.annotationStyle.height/2,a.x=r.x+5,a.y=r.y+19-3.5;return l.y-=22.5,{offsetRect:r,offsetText:a,offsetArrow:l,width:o+=10}}calcAnnotationHeight(){let e=21;return"Position"==this.type&&(e=100),e}calcAnnotationRadius(){let e=4;return"Position"==this.type&&(e=0),e}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=new e.Web.Graphics.Color(17,218,183,.2),o=new e.Web.Graphics.Color(17,218,183,1),s=function(t){this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.nextMeasurePoint=null,this.measurePoints=[],this.maxPointsNum=2,this.measureResult=null,this.measureParams={precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit},this.measureItemConfig=t,this.viewer=t.viewer;t.color.getRGBA();let s=i.createNS("circle","bf-measure-handle");s.setAttribute("stroke-width",0),s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();let r=i.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=n.getRGB();let a=i.createNS("polygon","bf-measure-rect");a.setAttribute("fill",n.getRGBA()),a.setAttribute("stroke",n.getRGB()),a.setAttribute("stroke-width",1);var l=i.createNS("path","bf-measure-foot");l.setAttribute("fill","none"),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("rect","bf-snap-handle");h.setAttribute("width",14),h.setAttribute("height",14),h.setAttribute("fill","none"),h.setAttribute("stroke",o.getRGB()),h.setAttribute("stroke-width",2);const c=i.createNS("path","bf-snap-handle");c.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),c.setAttribute("fill","none"),c.setAttribute("stroke",o.getRGB()),c.setAttribute("stroke-width",2);const d=i.createNS("line","bf-snap-handle");d.setAttribute("x1",0),d.setAttribute("y1",0),d.setAttribute("x2",14),d.setAttribute("y2",14),d.setAttribute("stroke",n.getRGB()),d.setAttribute("stroke-width",2);const u=i.createNS("line","bf-snap-handle");u.setAttribute("x1",14),u.setAttribute("y1",0),u.setAttribute("x2",0),u.setAttribute("y2",14),u.setAttribute("stroke",n.getRGB()),u.setAttribute("stroke-width",2),this.hoverFoot=l,this.hoverPoint=s,this.hoverLine=r,this.hoverPanel=a,this.hoverEndPoint=h,this.hoverMidPoint=c,this.hoverIntersectionPointA=d,this.hoverIntersectionPointB=u,this.hoverPanelSize={width:20,height:20},this.defaultColor=`#${t.color.getHEX()}`||"#F99D0B",this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.measureType=t.measureType,this.notation="ViewerGIS"===this.viewer.getViewerType()?new yi(this.measureType):new vi(this.measureType),this.isReserverd=!1,this.hoverPositionUpdated=!1};s.prototype={stretchOnDirection:function(e,t,i){let n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){},drawLine(e){if(0===e.length)return;let t=fi.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this._svg.appendChild(t)},drawTerminalPoint(e){let t=fi.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)},drawNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this._svg.appendChild(e)},drawCaptureItem:function(e){let t=this.hoverPoint,i=this.hoverLine,n=this.hoverPanel,o=this.hoverEndPoint,s=this.hoverMidPoint,r=this.hoverIntersectionPointA,a=this.hoverIntersectionPointB,l=e.hoverPosition&&e.hoverPosition.x,h=e.hoverPosition&&e.hoverPosition.y,c=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",l),t.setAttribute("cy",h),e.svg.appendChild(t);break;case"EndPoint":o.setAttribute("x",l-7),o.setAttribute("y",h-7),e.svg.appendChild(o);break;case"MidPoint":s.setAttribute("d",`M ${l} ${h-7} L ${l+8} ${h+8} L ${l-8} ${h+8} L ${l} ${h-7}`),e.svg.appendChild(s);break;case"IntersectionPoint":r.setAttribute("x1",l-7),r.setAttribute("y1",h-7),r.setAttribute("x2",l+7),r.setAttribute("y2",h+7),e.svg.appendChild(r),a.setAttribute("x1",l+7),a.setAttribute("y1",h-7),a.setAttribute("x2",l-7),a.setAttribute("y2",h+7),e.svg.appendChild(a);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-14} v 14 h 14 M ${t},${i-9} h 9 v 9`),e.svg.appendChild(this.hoverFoot)}else i.setAttribute("x1",e.lineStartPoint.x),i.setAttribute("y1",e.lineStartPoint.y),i.setAttribute("x2",e.lineEndPoint.x),i.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(i);break;case"Panel":let d=e.clientPts,u=d[0].distanceTo(d[1]),g=d[0].distanceTo(d[3]),p=u/c.width,m=g/c.height;if(1!=p){let e=this.stretchOnDirection(d[0],d[1],c.width),t=this.stretchOnDirection(d[2],d[3],c.width);d=e.concat(t)}if(1!=m){let e=this.stretchOnDirection(d[0],d[3],c.height),t=this.stretchOnDirection(d[1],d[2],c.height);d=[e[0],t[0],t[1],e[1]]}let f="";for(let e=0;e-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(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(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 xi=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),Ei=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class Pi extends xi.MeasureItem{constructor(t){super(t),this.opt=t,this.maxPointsNum=1;const i=new e.Web.Graphics.Color(17,218,183,.2),n=Ei.createNS("circle","bf-measure-handle");n.setAttribute("r",t.width),n.setAttribute("fill",i.getRGB()),n.style.fill=i.getRGB();const o=Ei.createNS("line","bf-measure-line");o.style.strokeWidth=2,o.style.stroke=i.getRGB();const s=Ei.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 \n \n \n \n \n \n \n \n \n \n \n \n \n ',a.className="bf-measure-dragbutton",a.style.display="none";let e=this.dragEvents={touchmove:e=>{let{top:t,left:i}=r.getBoundingClientRect(),{clientX:n,clientY:o}=e.touches[0];this.setButtonPosition(a,n-i,o-t);const s=new Touch({identifier:Date.now(),target:r,clientX:n,clientY:o,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5}),l=new TouchEvent("touchstart",{touches:[s]});r.dispatchEvent(l);const h=new TouchEvent("touchend");r.dispatchEvent(h),e.stopPropagation(),e.preventDefault()}};for(let t in e)a.addEventListener(t,e[t]);r.appendChild(a)}this.dragButton=a,this.dragButtonPoint=null,this.dragButtonVisible=!1,this._result={};const l=this.nextButtons={},h=document.createElement("div");this.nextButtonContainer=h,r.appendChild(h),["positive_X","negative_X","positive_Y","negative_Y","positive_Z"].forEach((e=>{const t=document.createElement("div");t.addEventListener("touchstart",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchmove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchend",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.addEventListener("mousedown",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mousemove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mouseup",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.className=`bf-measure-nextbutton ${e}`;const i={button:t};let n;Object.defineProperty(i,"position",{set:e=>{if(e){t.style.display="block";let{x:i,y:n}=this.viewer.worldToClient(e);i&&n&&this.setButtonPosition(t,i,n)}else t.style.display="none";n=e},get:()=>n}),h.appendChild(t),l[e]=i})),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,(()=>{if(this.dragButtonVisible&&this.dragButtonPoint){this.dragButton.style.display=this.viewer.isInViewFrustum(this.dragButtonPoint)?"block":"none";let{x:e,y:t}=this.viewer.worldToClient(this.dragButtonPoint);e&&t&&this.setButtonPosition(this.dragButton,e,t)}Object.values(l).forEach((e=>{e.position=e.position?e.position.clone():void 0,e.position&&!this.viewer.isInViewFrustum(e.position)&&(e.button.style.display="none")}))}))}computeMeasureResult(t){let i=this.getPoints();if(0===i.length)return;i[0].point=new THREE.Vector3(...Object.values(this.viewer.globalUnitUtil.revertTranslate(i[0].point,["x","y","z"])));let{point:n}=i[0];this._result.pointInfo=i[0];const o=n.clone().add(t.clone().multiplyScalar(1)),s=(e,t)=>{const i=this.viewer.getComponentsByRaycaster(o,t),n=this.viewer.getComponentsByRaycaster(o,t.clone().negate());return this._result[e]=i.length>0&&n.length>0?{enable:!0,direction:t,positiveIntersects:i,negativeIntersects:n,positiveIndex:0,negativeIndex:0}:{enable:!1},this.nextButtons[`positive_${e}`].position=i.length>1&&n.length>0?i[0].position:void 0,"Z"!==e&&(this.nextButtons[`negative_${e}`].position=n.length>1&&i.length>0?n[0].position:void 0),s};let r,a,l;return Math.abs(1-Math.abs(t.z))<.001?(r=new THREE.Vector3(1,0,0),a=new THREE.Vector3(0,1,0),l=new THREE.Vector3(0,0,1)):(r=t.clone().cross(new THREE.Vector3(0,0,1)),r.x<0&&r.negate(),a=t.clone().cross(r),a.y<0&&a.negate(),l=t),s("X",r)("Y",a)("Z",l),!e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.showDragButton(n),this.getMeasureResult()}getMeasureResult(){let e={},{componentId:t,modelId:i,point:n}=this._result.pointInfo;e.pointSelected={x:n.x,y:n.y,z:n.z},e.componentSelected={componentId:t,modelId:i},e.type=this.measureType;const o=t=>{if(this._result[t].enable){let{direction:i,positiveIntersects:n,negativeIntersects:o,positiveIndex:s,negativeIndex:r}=this._result[t],a=n[s],l=o[r];e[`Laser${t}`]={vector:{x:i.x,y:i.y,z:i.z},distance:a.distance+l.distance,endPoints:[{x:a.position.x,y:a.position.y,z:a.position.z,direction:"positive"},{x:l.position.x,y:l.position.y,z:l.position.z,direction:"negative"}],endComponents:[{componentId:a.id,modelId:a.modelId,direction:"positive"},{componentId:l.id,modelId:l.modelId,direction:"negative"}]}}return o};return o("X")("Y")("Z"),e}getNextResult(t){let[i,n]=t.split("_");if(!this._result[n]||!this._result[n].enable)return;let o=this._result[n][`${i}Intersects`],s=++this._result[n][`${i}Index`];o.length<=s&&(this._result[n][`${i}Index`]=s=0),this.opt.measure.measureByInfo({...this.getMeasureResult(),id:e.Web.Lang.Utility.UUID.createUUID()}),this.nextButtons[t].position=o[s].position}draw(e){this.drawCaptureItem(e)}showDragButton(e){this.reset(),this.viewer.render(),this.dragButtonPoint=e,this.dragButtonVisible=!0;let{x:t,y:i}=this.viewer.worldToClient(e);this.dragButton.style.display="block",t&&i&&this.setButtonPosition(this.dragButton,t,i)}hideDragButton(){this.dragButtonVisible=!1,this.dragButton.style.display="none",Object.values(this.nextButtons).forEach((e=>e.position=void 0))}showNextButton(){this.nextButtonContainer.style.display="block"}hideNextButton(){this.nextButtonContainer.style.display="none"}clearNextButton(){Object.values(this.nextButtons).forEach((e=>e.position=void 0))}setButtonPosition(e,t,i){e.style.top=`${i}px`,e.style.left=`${t}px`}}xi.MeasureLaserClearDistanceItem=Pi;class Mi{constructor(e,t,i,n){this.viewer=e,this.id=t,this.type=i,this.isShow=!0,this.xmlns="http://www.w3.org/2000/svg",this.defaultColor=n.defaultColor||"#F99D0B",this.svgGroup=[],this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.hitTestEpsilon=10,this.hitTestSegments=[],this.selectElements=[],this.unSelectElements=[],this.elementsOnTop=[],this.isSelected=!0,this.mask=null,this.notation="ViewerGIS"===this.viewer.getViewerType()?new yi(i):new vi(i),this.measureParams={precision:0,scale:1,unit:"None"}}getSvgGroup(){return this.svgGroup}getId(){return this.id}getType(){return this.type}clear(e){this.detach(e),this.notation.clear(e),this.svgGroup=[],this.hitTestSegments=[]}detach(e){for(const e of this.svgGroup){(t=e.parentNode)&&t.removeChild(e)}for(const e of this.elementsOnTop){var t;(t=e.parentNode)&&t.removeChild(e)}}attach(e){for(const t of this.svgGroup)e.appendChild(t)}calcLine(e,t){let i=[];this.viewer.getViewer();var o=this.viewer.getDomElement().getBoundingClientRect(),s=this.viewer.viewerAdapter.worldPointsToClient(e,t);if(s){e=new n(s.start.x-o.left,s.start.y-o.top),t=new n(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i}calcTerminalLines(e,t,i){if(0===e.length)return[];let n=[],o=e[0],s=e[1],r=o.clone().sub(s).normalize(),a=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),t),l=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),-t);n.push({start:a,end:l}),r=r.multiplyScalar(-1);let h=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),t),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)}ifMaskDraw(e,t,i,n,o,s){if("ViewerDrawing"==this.viewer.viewerType){const r=this.viewer.getViewer().getLayoutViewportBoundingBox(t,i,n),a=this.viewer.getViewer().toScreenPoint(r.min),l=this.viewer.getViewer().toScreenPoint(r.max),h=e[0].start?e[0].start:e[0],c=e[1].end?e[1].end:e[1];if(h.xl[0]||h.ya[1]||c.xl[0]||c.ya[1])this.drawMask(r,!0);else if(-1==n&&-1!=o){const e=this.viewer.getViewer().getLayoutViewportBoundingBox(t,o,s);this.drawMask(e,!isFinite(e.max[0]))}else this.removeMask()}}drawMask(e,t=!0){const i=this.viewer.getViewer().toScreenPoint(e.min),n=this.viewer.getViewer().toScreenPoint(e.max);let o=this.mask=fi.makeRectangle({x:t?0:i[0],y:t?0:n[1],width:t?this.viewer.getDomElement().clientWidth:n[0]-i[0],height:t?this.viewer.getDomElement().clientHeight:i[1]-n[1],radius:0,fillColor:0==this.viewer.getViewer().dc.printMode?"#444444":"#DDDDDD",fillOpacity:.7});this.svgGroup.push(o)}removeMask(){this.mask&&(this.mask.style.display="none"),this.mask=null}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}show(){for(const e of this.svgGroup)e.style.display="block";for(const e of this.elementsOnTop)e.style.display="block";this.isShow=!0}hide(){for(const e of this.svgGroup)e.style.display="none";for(const e of this.elementsOnTop)e.style.display="none";this.isShow=!1}getNotation(){return this.notation}hitTest(e){let t=this.hitTestEpsilon;for(let i=0;i0&&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 bi.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}}class Ii extends Mi{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.elevationPoint=t.points[0],this.elevation="number"==typeof t.elevation?t.elevation:t.points[0].z,this.initialElevation=t.initialElevation,this.setMeasureParams({precision:t.precision,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(this.viewer.isInViewFrustum&&!this.viewer.isInViewFrustum(this.elevationPoint))return;var e=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);e=this.viewer.worldToClient(e);for(var t=[58,-12,-12,-12,0,0,12,-12],i="",n=0;n{(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=bi.formatDistance(t,this.measureParams);return i+=bi.getPostFix(e,!1),i.split(",").join("")}}class Di extends Mi{constructor(e,i,n,o){super(e,n,i.type,o),this.filterUrl=i.filterUrl,this.worldPositions=i.points,this.measureResult=i.area,this.viewPortId=i.viewPortId,this.drawingIndex=i.drawingIndex,this.drawingIndexes=i.drawingIndexes,this.layoutId=i.layoutId||0,this.isOnBorder=i.isOnBorder,this.boundaryPoints=[],this.scratchVector=new t,this.setMeasureParams({precision:i.precision,scale:i.scale,unit:i.unit})}initialize(e=!1,t,i){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;let s=new o,r=this.worldPositions;var a="";this.boundaryPoints=[],!this.previousNormalPoints&&(this.previousNormalPoints=[]);const l=r.length;for(var h=0;h<=l;h++){if(r[h%r.length].viewId&&!r[h%r.length].isActiveLayoutElement&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;let o=this.drawingIndexes?this.worldToClient(r[h%r.length],this.drawingIndexes[h%r.length]):this.worldToClient(r[h%r.length]);e&&h+10&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.isOnLayoutMeasure&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;const n=()=>{let e=this.calAuxLines(),t=[];return t.push(e[0].start,e[1].end),this.hitTestSegments=t,{auxLines:e,linePoints:t,terminalLines:this.calcTerminalLines(t,Math.PI/2,6.5)}};let{auxLines:o,linePoints:s,terminalLines:r}=n();if(e&&this.ifMaskDraw(r,this.layoutId,this.viewPortId,this.drawingIndex,i,t),this.mask||(this.previousNormalPoints=[this.startPoint.clone(),this.endPoint.clone()]),this.mask){this.startPoint=this.previousNormalPoints[0],this.endPoint=this.previousNormalPoints[1];const e=n();o=e.auxLines,s=e.linePoints,r=e.terminalLines}this.attachSingleLine(s),this.attachTerminalLines(r);this.attachAuxLines(o,["#7CCF21","#CC021B"]),this.attachTerminalPoints(s),this.attachNotation(s),this.notation.dropShadow(this.filterUrl),this.unselect(),!this.viewer.loadedDrawings&&!this.isShow&&this.hide()}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.getMeasureResult(),this.id);for(const e of t)this.svgGroup.push(e)}calAuxLines(){let e=[],t=this.startPoint.clone(),i=this.endPoint.clone(),o={x:i.x,y:t.y};e.push(t,o,i);let s=[];for(let t=0;t0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;let e=[];for(let t=0;t{o+=t;let i=t.toString();i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=bi.formatDistance(o,this.measureParams),o+=bi.getPostFix(e,!1),{distance:n,totalDistance:o}}}class ki extends Mi{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.groundInfos=t.groundInfos,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit}),this.borderColor=n.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=n.width||3}initialize(){let e=this.worldPositions.length;if(!(e<2)){for(let t=1;t{o+=t;let i=t.toString();i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=bi.formatDistance(o,this.measureParams),o+=bi.getPostFix(e,!1),{distance:n,totalDistance:o}}}class Li extends Mi{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=fi.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=fi.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 fi.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=bi.formatPrecision(i.latitude.toString(),o),a=bi.formatPrecision(i.longitude.toString(),o),l=bi.formatDistance(t.toString(),s);return l+=bi.getPostFix(e,!1),`经度:${a} ° \n纬度:${r} ° \n高程:${l}`}}class Vi extends Mi{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].ze[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=fi.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=fi.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=fi.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=bi.formatDistance(t,this.measureParams),t+=bi.getPostFix(e,!1),i=i.toString(),i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n=n.toString(),n=bi.formatDistance(n,this.measureParams),n+=bi.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}}class Ri extends Mi{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{let i=this.viewer.worldToClient(e);t+=i.x+","+i.y+" "}));let i=fi.makePolygon({points:t,width:this.lineWidth,color:this.defaultColor,fillColor:this.fillColor.getRGBA()});this.svgGroup.push(i)}attachUnselectedTerminalPoints(e){let t=fi.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;t2){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{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=fi.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;ei.x>0&&i.y>0&&i.xthis.svgGroup.push(e))),this.unselect()}getMeasureResult(e){let t=this.measureParams.unit,i=e.toString(),n=bi.formatDistance(i,this.measureParams);return n+=bi.getPostFix(t,!1),n.split(",").join("")}select(){super.select()}unselect(){super.unselect()}}class Ui extends Mi{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=bi.formatCubic(t,this.measureParams);return i=i+bi.getPostFix(e,!1)+"³",i.split(",").join("")}}class zi extends Mi{constructor(e,t,i,o){super(e,i,t.type,o),this.filterUrl=t.filterUrl,this.isOnLayoutMeasure=t.isOnLayout,this.viewPortId=t.viewPortId,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId||0,this.isOnBorder=t.isOnBorder,this.worldPositions=t.points?t.points:[];for(let e=0;e0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.isOnLayoutMeasure&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;let o=this.worldPositions.length;if(!(o<2)){this.previousNormalPoints||(this.previousNormalPoints=[]);for(let s=1;s{o+=t;let i=t.toString();i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=bi.formatDistance(o,this.measureParams),o+=bi.getPostFix(e,!1),{distance:n,totalDistance:o}}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class Fi{constructor(e){this.viewer=e}make(e,t,i,n){let o=null,s="ViewerDrawing"===this.viewer.getViewerType(),r={defaultColor:`#${n._opt.color.getHEX()}`,enableAuxiliaryValue:n._opt.enableAuxiliaryValue};switch(e){case"Distance":o=s?new Bi(this.viewer,t,i,r):new Ci(this.viewer,t,i,r);break;case"Angle":o=s?new _i(this.viewer,t,i,r):new Ti(this.viewer,t,i,r);break;case"MinimumDistance":o=new Si(this.viewer,t,i,r);break;case"Elevation":o=new Ii(this.viewer,t,i,r);break;case"Area":o=new Di(this.viewer,t,i,r);break;case"GroundlineDistance":o=new ki(this.viewer,t,i,r);break;case"PolylineDistance":o=s?new zi(this.viewer,t,i,r):new Ai(this.viewer,t,i,r);break;case"Position":o=new Li(this.viewer,t,i,r);break;case"TriangleDistance":o=new Vi(this.viewer,t,i,r);break;case"SpatialArea":o=new Ri(this.viewer,t,i,r);break;case"ProjectedArea":o=new Hi(this.viewer,t,i,r);break;case"SurfaceArea":o=new Ni(this.viewer,t,i,r);break;case"LaserClearDistance":o=new Gi(this.viewer,t,i,r),o.measure=n;break;case"Volume":o=new Ui(this.viewer,t,i,r)}return o.initialize(),o}}class Wi extends Ci{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e,this.distanceX=Math.abs(this.worldPositions[1].x-this.worldPositions[0].x),this.distanceY=Math.abs(this.worldPositions[1].y-this.worldPositions[0].y),this.distanceZ=Math.abs(this.worldPositions[1].z-this.worldPositions[0].z),this.measureResult=Math.sqrt(Math.pow(this.distanceX,2)+Math.pow(this.distanceY,2)+Math.pow(this.distanceZ,2))}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult,distanceX:this.distanceX,distanceY:this.distanceY,distanceZ:this.distanceZ,points:this.worldPositions,type:this.type}}}class ji extends Ti{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureAngle=t.measureAngle,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e;var t=new THREE.Vector3(this.worldPositions[0].x-this.worldPositions[1].x,this.worldPositions[0].y-this.worldPositions[1].y,this.worldPositions[0].z-this.worldPositions[1].z),i=new THREE.Vector3(this.worldPositions[2].x-this.worldPositions[1].x,this.worldPositions[2].y-this.worldPositions[1].y,this.worldPositions[2].z-this.worldPositions[1].z),n=t.angleTo(i);this.measureAngle=180*n/Math.PI}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),angle:this.measureAngle,points:this.worldPositions,type:this.type}}}class Xi extends Bi{constructor(e,t){t.start=t.startPoint,t.end=t.endPoint,super(e,t,t.id,{defaultColor:t.defaultColor}),this.startPoint=new n(t.worldPositions[0][0],t.worldPositions[0][1]),this.endPoint=new n(t.worldPositions[1][0],t.worldPositions[1][1]),this.viewPortId=t.viewPortId,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.isOnLayoutMeasure=t.isOnLayoutMeasure,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewPortId&&t!=this.viewPortId)return;0===this.updateIndex?this.startPoint=new n(e[0],e[1]):this.endPoint=new n(e[0],e[1]);let i=this.endPoint.x-this.startPoint.x,o=this.endPoint.y-this.startPoint.y;this.measureResult=Math.sqrt(i*i+o*o)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),start:[this.startPoint.x,this.startPoint.y],end:[this.endPoint.x,this.endPoint.y],points:[[this.startPoint.x,this.startPoint.y],[this.endPoint.x,this.endPoint.y]],viewPortId:this.viewPortId,distance:this.measureResult,isOnLayout:this.isOnLayoutMeasure,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}}class Yi extends ji{constructor(e,t){super(e,t),this.isOnLayoutMeasure=t.isOnLayoutMeasure,this.viewPortId=t.viewPortId,this.drawingIndex=t.drawingIndex,this.layoutId=t.layoutId,this.drawingIndex=t.drawingIndex,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.viewPortId&&t!=this.viewPortId)return;this.worldPositions[this.updateIndex]=e;let i=this.getClientPoints();this.measureAngle=this.angleByArr([i[0].x,i[0].y],[i[1].x,i[1].y],[i[2].x,i[2].y])}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),angle:this.measureAngle,points:this.worldPositions,isOnLayout:this.isOnLayoutMeasure,viewPortId:this.viewPortId,drawingIndex:this.drawingIndex,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}angleByArr(e,t,i){let n=Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)),o=Math.sqrt(Math.pow(t[0]-i[0],2)+Math.pow(t[1]-i[1],2)),s=Math.sqrt(Math.pow(e[0]-i[0],2)+Math.pow(e[1]-i[1],2)),r=(Math.pow(n,2)+Math.pow(o,2)-Math.pow(s,2))/(2*n*o);return r=r.toFixed(12),180*Math.acos(r)/Math.PI}getClientPoints(){let e=[];for(let t=0;tthis.worldPositions[1].z&&(t.set(this.worldPositions[1].x,this.worldPositions[1].y,this.worldPositions[0].z),i=t.distanceTo(this.worldPositions[0]),n=t.distanceTo(this.worldPositions[1])),this.measureResult.horizontalDistance=i,this.measureResult.verticalDistance=n}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,horizontalDistance:this.measureResult.horizontalDistance,verticalDistance:this.measureResult.verticalDistance,points:this.worldPositions,type:this.type}}}class Ji extends Ri{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.selectElements=[],this.unSelectElements=[]}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=fi.calcSpatialArea(this.worldPositions)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type}}}class Qi extends Ji{constructor(e,t){super(e,t)}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=fi.calcProjectedArea(this.worldPositions)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class en extends Ji{constructor(e,t){super(e,t),this.measureSurfaceMesh=null,this.layerType=t.layerType}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=fi.calcSurfaceArea(this.worldPositions,this.viewer,this.layerType)}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new Oi({fillColor:new Glodon.Web.Graphics.Color(255,157,11,.2),color:new Glodon.Web.Graphics.Color(255,157,11,1),width:this.lineWidth})),super.initialize()}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type,layerType:this.layerType}}attachArea(e){this.measureSurfaceMesh.setMeasurePoints(e),this.viewer.render()}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_surface_area}clear(){super.clear(),this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)}}class tn extends ki{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.groundInfos=t.groundInfos,this.isFirst=!0,this.lastGroundLineMes={},this.borderColor=t.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3}init(){this.updateGroundLine(this.worldPositions)}debounce(e,t=300){let i=null;return function(...n){i&&(clearTimeout(i),i=null),i=setTimeout((()=>{e(...n)}),t)}}calculate(e){this.isFirst&&(this.init(),this.isFirst=!1),this.worldPositions[this.updateIndex]=e;let t=()=>{this.isEnd||this.handle()};this.debounceFun||(this.debounceFun=this.debounce(t)),this.debounceFun(),this.updateGroundLine(this.worldPositions)}handle(){this.groundInfos.length!==this.measureResult.distance.length&&this.groundInfos.pop(),this.updateIndex>0&&(this.groundInfos[this.updateIndex-1]=this.calculateGroundlineDistance(this.worldPositions[this.updateIndex-1],this.worldPositions[this.updateIndex])),this.updateIndex{l.copy(e),(l=i.worldToScene(e)).y=1e4,a.set(l,new THREE.Vector3(0,-1,0));let t=c.getObjectsByRaycaster(h,a,!0);if(t.length>0){let e;e=i.sceneToWorld(t[0].point),d.push(e)}else d.push(e)})),s=null;let u=new Glodon.Bimface.Plugins.Geometry.SplineCurve(d);return u.projectToGround(!0),this.lastPoint0=n,this.lastPoint1=o,this.lastGroundInfo={length:u.length,midPoint:u.getPointByParameter(.5),endPoint:u.getPointByParameter(1),status:"finished"},this.lastGroundInfo}}class nn{constructor(e,t,i){this.domContainer=e,this.viewer=t,this.measure=i,this.drawable=null,this.isDrawed=!1,this.lastMeasureType="",this.currentMeasureType=""}createDrawable(e){this.lastMeasureType=this.measure.type,this.currentMeasureType=e.type;let t="ViewerDrawing"===this.viewer.getViewerType();switch(e.type){case"Distance":this.drawable=t?new Xi(this.viewer,e):new Wi(this.viewer,e);break;case"Angle":this.drawable=t?new Yi(this.viewer,e):new ji(this.viewer,e);break;case"PolylineDistance":this.drawable=t?new $i(this.viewer,e):new qi(this.viewer,e);break;case"Area":this.drawable=new Zi(this.viewer,e);break;case"TriangleDistance":this.drawable=new Ki(this.viewer,e);break;case"SpatialArea":this.drawable=new Ji(this.viewer,e);break;case"ProjectedArea":this.drawable=new Qi(this.viewer,e);break;case"SurfaceArea":this.drawable=new en(this.viewer,e);break;case"GroundlineDistance":this.drawable=new tn(this.viewer,e);break;default:this.drawable=null}}draw(e,t){if(!this.drawable)return;this.isDrawed||this.measure.setMeasureType(this.currentMeasureType),this.isDrawed=!0;let i="ViewerDrawing"===this.viewer.getViewerType(),n={x:i&&!this.viewer.isFullScreen?e.clientX-t.left:e.clientX,y:i&&!this.viewer.isFullScreen?e.clientY-t.top:e.clientY},o={};if(i){var s=[],r=this.viewer._drawingViewer.snapToPoint(n.x,n.y),a=r.GetViewPortId&&r.GetViewPortId();if(r.GetPoint().length>0&&(s=[r.GetPoint()[0],r.GetPoint()[1],a]),!r.GetID()){let e=this.viewer._drawingViewer.toScreenPoint(r.GetPoint()),t=this.viewer._drawingViewer.toModelWorld(e);s=t,a=t[2]}o=s,this.drawable.calculate(o,a)}else{let e=this.viewer.getViewer().pickToPoint(n,5);e&&e.pickPoint&&(o=this.viewer.sceneToWorld(e.pickPoint),this.drawable.calculate(o))}let l=this.drawable.getInfo();this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,l),this.drawable.clear(),this.drawable.initialize(!0,i&&r&&r.GetDrawingIndex(),i&&r&&r.GetViewPortId()),this.drawable.select(),this.drawable.attach(this.domContainer)}end(){if(!this.drawable||!this.isDrawed)return;this.drawable.end&&this.drawable.end();let e=this.drawable.getInfo();this.measure.drawableManager.addItem(e),this.drawable.clear(),this.drawable=null,this.isDrawed=!1,this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdated,e)}update(){this.drawable&&this.isDrawed&&(this.drawable.clear(),this.drawable.initialize(),this.drawable.select(),this.drawable.attach(this.domContainer))}}class on{constructor(t,i,n){this.domContainer=t,this.measureItems=i,this.manage=n,this.measureUpdateManage=new nn(t,n.viewer,n.measure),this.selectedItem=null,this.selectionChanged=null,this.hoverChanged=null,this.isEnableSelection=!0,this.mousedownHitItem=null,this.offset=t.getBoundingClientRect(),e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hookEvents()}hookEvents(){this.domContainer.addEventListener("mousemove",(e=>{if(this.manage.measure.isSelectItem=!1,!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);if(this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),!this.isMoveed&&this.mouseDownPoint&&(Math.abs(this.mouseDownPoint.x-e.clientX)>=1||Math.abs(this.mouseDownPoint.y-e.clientY)>=1)&&(this.isMoveed=!0),this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type){let t={x:e.clientX,y:e.clientY},i=this.manage.viewer.getViewer().pickToPoint(t,5);if(i&&i.pickPoint){let e=this.manage.viewer.sceneToWorld(i.pickPoint);this.mouseDownHelperHitItem.update(e)}return void(this.isMouseDownHelperHitItemMove=!0)}if(!this.isMouseDownMove&&this.mousedownPoint&&Math.abs(this.mousedownPoint.x-t.x)>=1&&Math.abs(this.mousedownPoint.y-t.y)>=1&&(this.isMouseDownMove=!0,this.mousedownPoint=null),this.isMouseDownMove&&(this.selectPointItemId&&(this.manage.removeItemById(this.selectPointItemId),this.selectPointItemId=null),this.measureUpdateManage.draw(e,this.offset)),this.isMouseDown)return;let i=this.hitTest(t);if("Viewer3D"===this.manage.viewer.viewerType){i=this.manage.measure.measureHelper.hitTest(new n(e.clientX,e.clientY),new n(t.x,t.y))||i}this.hoverChanged(i),i?(this.domContainer.style.cursor="default",e.preventDefault(),e.stopPropagation()):this.domContainer.style.cursor=""}),!1),this.domContainer.addEventListener("mousedown",(e=>{if(this.mousedownHitItem=null,this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!0,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint={x:e.clientX,y:e.clientY},!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);if(this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),"Viewer3D"===this.manage.viewer.viewerType){let i=this.manage.measure.measureHelper.hitTestPoint(new n(e.clientX,e.clientY),new n(t.x,t.y));i&&(this.mouseDownHelperHitItem=i);let o=this.manage.measure.measureHelper.hitTest(new n(e.clientX,e.clientY),new n(t.x,t.y));if(o)return this.manage.measure.isSelectItem=!0,o.getIsSelected()?(this.selectionChanged(null),this.setSelectedItem(null),o.unselect()):(this.selectionChanged(o),this.setSelectedItem(o),o.select()),e.preventDefault(),void e.stopPropagation()}let i=this.hitTest(t);if(this.mousedownHitItem=i,i){this.manage.measure.isSelectItem=!0;for(let e=0;e{this.manage.measure.isSelectItem=!1,this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type&&this.isMouseDownHelperHitItemMove&&(this.mouseDownHelperHitItem.endUpdate(this.manage.mapMeasureInfo),this.setSelectedItem(this.mouseDownHelperHitItem),this.mouseDownHelperHitItem.select(),this.mouseDownHelperHitItem=null),this.measureUpdateManage.end(),this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!1,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint=null,this.mousedownHitItem&&(e.preventDefault(),e.stopPropagation())}),!1),this.domContainer.addEventListener("dblclick",(()=>{event.preventDefault(),event.stopPropagation()}),!1)}hitTest(e){for(var t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.getNotation().hitTest(e))return i}for(t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.hitTest(e))return i}return null}setSelectedItem(e){this.selectedItem&&(this.selectedItem.actionWhenUnselected(),this.selectedItem.unselect()),this.selectedItem=e,e&&e.actionWhenSelected()}getSelectedItem(){return this.selectedItem}hasSelected(){return null!==this.selectedItem}setIsEnableSelection(e){this.isEnableSelection=e}}class sn{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+")"}}let rn=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),an=new e.Web.Graphics.Color(17,218,183,.2),ln=new e.Web.Graphics.Color(17,218,183,1);class hn{constructor(t){this.object3D=new THREE.Object3D,this.children=[],this.id=t&&t.id||e.Web.Lang.Utility.UUID.createUUID(),this.measure=t.measure,this.nextMeasurePoint=null,this.measurePoints=[],this.maxPointsNum=2,this.measureResult=null,this.measureParams={precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit},this.measureItemConfig=t,this.linewidth="number"==typeof t.width?t.width>10||t.width<1?3:t.width:3,this.viewer=t.viewer,this.selectChild=null,this.isEndDrawing=!1,this._config=t,this.helper=t.helper,this.hoveredObject=null,this.selectedObject=null,this.object3D.visible=!0,this.isSelected=!0,this.helperEvents={},this.color=t.color instanceof e.Web.Graphics.Color?"#"+t.color.getHEX():"#ff9d0b",this.svgContainer=this.helper.svgContainer,this.notationGroup=[],this.notation=new vi(t.measureType);let i=rn.createNS("circle","bf-measure-handle");i.setAttribute("stroke-width",0),i.setAttribute("r",6),i.setAttribute("fill",an.getRGB()),i.style.fill=an.getRGB();let n=rn.createNS("line","bf-measure-line");n.style.strokeWidth=2,n.style.stroke=an.getRGB();let o=rn.createNS("polygon","bf-measure-rect");o.setAttribute("fill",an.getRGBA()),o.setAttribute("stroke",an.getRGB()),o.setAttribute("stroke-width",1);var s=rn.createNS("path","bf-measure-foot");s.setAttribute("fill","none"),s.setAttribute("stroke",an.getRGB()),s.setAttribute("stroke-width",2);const r=rn.createNS("rect","bf-snap-handle");r.setAttribute("width",14),r.setAttribute("height",14),r.setAttribute("fill","none"),r.setAttribute("stroke",ln.getRGB()),r.setAttribute("stroke-width",2);const a=rn.createNS("path","bf-snap-handle");a.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),a.setAttribute("fill","none"),a.setAttribute("stroke",ln.getRGB()),a.setAttribute("stroke-width",2);const l=rn.createNS("line","bf-snap-handle");l.setAttribute("x1",0),l.setAttribute("y1",0),l.setAttribute("x2",14),l.setAttribute("y2",14),l.setAttribute("stroke",an.getRGB()),l.setAttribute("stroke-width",2);const h=rn.createNS("line","bf-snap-handle");h.setAttribute("x1",14),h.setAttribute("y1",0),h.setAttribute("x2",0),h.setAttribute("y2",14),h.setAttribute("stroke",an.getRGB()),h.setAttribute("stroke-width",2),this.hoverFoot=s,this.hoverPoint=i,this.hoverLine=n,this.hoverPanel=o,this.hoverEndPoint=r,this.hoverMidPoint=a,this.hoverIntersectionPointA=l,this.hoverIntersectionPointB=h,this.hoverPanelSize={width:20,height:20},this.isReserverd=!1,this.hoverPositionUpdated=!1}init(){}getConfig(){return this._config}getCloudViewer(){return this.helper.viewer}draw(){}endDraw(){}update(){}endUpdate(){}select(){this.isSelected=!0}unselect(){this.isSelected=!1}getIsSelected(){return this.isSelected}actionWhenSelected(){}actionWhenUnselected(){}updateResult(){}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.getMeasureResult(),this.id);for(const e of t)this.notationGroup.push(e);this.attach(this.notationGroup)}attach(e){if(0!=e.length)for(const t of e)this.svgContainer.appendChild(t)}detach(e){if(0!=e.length)for(const i of e){var t=i.parentNode;t&&t.removeChild(i)}}updateNotationPositionFun(e,t){let i=this.viewer.worldToScene({x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2,z:(t[0].z+t[1].z)/2});i=new THREE.Vector3(i.x,i.y,i.z);let o,s=i.applyMatrix4(this.viewer.getViewer().camera.matrixWorldInverse.clone()).applyMatrix4(this.viewer.getViewer().camera.projectionMatrix);o=Math.abs(s.x)>1||Math.abs(s.y)>1||Math.abs(s.z)>1?{x:-100,y:-100}:this.viewer.worldToClient({x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2,z:(t[0].z+t[1].z)/2});let r=this.notation.calcAnnotationStyle(this.getMeasureResult(),o);e[0].setAttribute("x",r.offsetRect.x),e[0].setAttribute("y",r.offsetRect.y),e[1].setAttribute("x",r.offsetRect.x-2),e[1].setAttribute("y",r.offsetRect.y-2),e[2].setAttribute("x",r.offsetText.x),e[2].setAttribute("y",r.offsetText.y);let a=new n(r.offsetRect.x,r.offsetRect.y+this.notation.annotationStyle.height/2),l=new n(r.offsetRect.x+r.width,a.y);this.notation.notationSegmentRects.push({start:a,end:l})}hitTest(e,t){let i=null;return this.children.some((n=>{const o=n.hitTest(e,t);return o&&(i=n),o})),this.hoveredObject=i,this.hoveredObject?!!this.hoveredObject:this.notation.hitTest(t)}hitTestPoint(e,t){let i=null;return this.children.some((n=>{const o="Point"==n.type&&n.hitTest(e,t);return o&&(i=n),o})),this.selectChild=i,!!this.selectChild}add(e){this.children.push(e),this.object3D.add(e.object3D)}remove(e){for(let t=0;t{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}destroy(){for(this._destroyed=!0,Object.entries(this.helperEvents).forEach((([e,t])=>{this.helper.group.removeEventListener(e,t)}));this.children.length>0;)this.children[0].destroy(),this.object3D.remove(this.children[0].object3D),this.children.splice(0,1);this.helper.viewer.render(),this.removeAllSvg()}removeAllSvg(){this.detach(this.notationGroup),this.notationGroup=[]}stretchOnDirection(e,t,i){let n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]}drawCaptureItem(e){let t=this.hoverPoint,i=this.hoverLine,n=this.hoverPanel,o=this.hoverEndPoint,s=this.hoverMidPoint,r=this.hoverIntersectionPointA,a=this.hoverIntersectionPointB,l=e.hoverPosition&&e.hoverPosition.x,h=e.hoverPosition&&e.hoverPosition.y,c=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",l),t.setAttribute("cy",h),e.svg.appendChild(t);break;case"EndPoint":o.setAttribute("x",l-7),o.setAttribute("y",h-7),e.svg.appendChild(o);break;case"MidPoint":s.setAttribute("d",`M ${l} ${h-7} L ${l+8} ${h+8} L ${l-8} ${h+8} L ${l} ${h-7}`),e.svg.appendChild(s);break;case"IntersectionPoint":r.setAttribute("x1",l-7),r.setAttribute("y1",h-7),r.setAttribute("x2",l+7),r.setAttribute("y2",h+7),e.svg.appendChild(r),a.setAttribute("x1",l+7),a.setAttribute("y1",h-7),a.setAttribute("x2",l-7),a.setAttribute("y2",h+7),e.svg.appendChild(a);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-14} v 14 h 14 M ${t},${i-9} h 9 v 9`),e.svg.appendChild(this.hoverFoot)}else i.setAttribute("x1",e.lineStartPoint.x),i.setAttribute("y1",e.lineStartPoint.y),i.setAttribute("x2",e.lineEndPoint.x),i.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(i);break;case"Panel":let d=e.clientPts,u=d[0].distanceTo(d[1]),g=d[0].distanceTo(d[3]),p=u/c.width,m=g/c.height;if(1!=p){let e=this.stretchOnDirection(d[0],d[1],c.width),t=this.stretchOnDirection(d[2],d[3],c.width);d=e.concat(t)}if(1!=m){let e=this.stretchOnDirection(d[0],d[3],c.height),t=this.stretchOnDirection(d[1],d[2],c.height);d=[e[0],t[0],t[1],e[1]]}let f="";for(let e=0;e-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}}addPoint(e){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}redo(){this.measurePoints.length>0&&this.measurePoints.length{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}getOrthogonalityCameraScaleValue(){return 1/(this.getCloudViewer().camera.zoom/this.getCloudViewer().camera.position.clone().sub(this.getCloudViewer().camera.target.clone()).length())}destroy(){this.object3D.children.forEach((e=>{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&e.material.dispose&&e.material.dispose()}))}}class dn extends cn{constructor(e){super(e),this.type="Point",this.isSelected=!1}init(){const{point:e,showText:t,noBorder:i}=this.getConfig();this.bgColor=this.getConfig().bgColor||"#ff9d0b",this.borderColor=this.getConfig().borderColor||"#FFFFFF",this.noBorder=i,this.object3D.position.set(e.x,e.y,e.z),this.showText=0!=t||t,this.object3D.updateMatrixWorld(),this.addPoint(),this.addRigidBody(),super.init()}update(e){this.object3D.position.set(e.x,e.y,e.z),this.object3D.updateMatrixWorld()}addPoint(){this.updateScaleFactor(),this.defaultTexture=this.getTexture();const e=new CLOUD.SpriteShaderMaterial({map:this.defaultTexture,depthTest:!1}),t=this.point=new THREE.Sprite(e);t.renderOrder=CLOUD.EnumRenderOrder.Effect+200,this.object3D.add(t)}getTexture(e){const t=document.createElement("canvas");t.width=16,t.height=16;const i=t.getContext("2d");this.noBorder||(i.beginPath(),i.arc(8,8,8,0,2*Math.PI),i.fillStyle="#"+this.getLinearColor(this.borderColor).getHexString(),i.fill()),i.beginPath(),i.arc(8,8,5.5,0,2*Math.PI),i.fillStyle="#"+this.getLinearColor(this.bgColor).getHexString(),i.fill();return new THREE.CanvasTexture(t)}addRigidBody(){const e=new THREE.BoxGeometry(1,1,1),t=new THREE.MeshBasicMaterial,i=this.rigidBody=new THREE.Mesh(e,t);i.visible=!1,this.object3D.add(i)}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=10*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.object3D.updateMatrixWorld()}hitTest(e){const t=[];return this.rigidBody.raycast(e,t),t.length>0}}class un extends cn{constructor(e){super(e)}init(){const{points:e,color:t,dashSize:i,gapSize:n}=this.getConfig();this.isNotHitTest=this.getConfig().isNotHitTest||!1,this.points=e,this.linewidth=this.getConfig().linewidth||3,this.dashSize=i,this.gapSize=n;const o=[];e.forEach((e=>o.push(e.x,e.y,e.z))),this.addLine(o,{color:this.getLinearColor(t)}),super.init()}addLine(e,t){const i=new THREE.LineGeometry;if(i.setPositions(e),!this.lineMaterial){let e;!0===this.getConfig().dashed?(e=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!0,dashSize:this.dashSize||1,gapSize:this.gapSize||1,dashScale:.1,depthTest:!1,...t}),e.defines.USE_DASH=""):e=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!1,depthTest:!1,...t}),e.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=e}const n=new THREE.Line2(i,this.lineMaterial);n.computeLineDistances(),n.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.object3D.add(n),this.line=n}update(e){this.points=e,this.object3D.remove(this.line),this.line.geometry.dispose();const t=[];e.forEach((e=>t.push(e.x,e.y,e.z))),this.addLine(t),this.object3D.updateMatrixWorld()}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}updateScaleFactor(e,t){if(!0===this.getConfig().dashed){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.points[0].clone().add(this.points[1]).multiplyScalar(.5),n=e.clone().sub(i.clone()).length(),o=t.angleTo(i.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=n/this.getCloudViewer().domElement.offsetHeight*.8;s<.2?s*=1.8:s<.5?s*=1.4:s<1&&(s*=1.2),this.line.material.dashSize=s,this.line.material.gapSize=s,this.line.computeLineDistances()}}hitTest(e,t){if(this.isNotHitTest)return!1;if(2!=this.points.length)return!1;let i=this.viewer.worldToClient(this.viewer.sceneToWorld(this.points[0])),o=this.viewer.worldToClient(this.viewer.sceneToWorld(this.points[1]));var s=new n(i.x,i.y),r=new n(o.x,o.y);return fi.distanceToSegment(t,s,r)<=10}}class gn extends cn{constructor(e){super(e)}init(){const{point:e,color:t}=this.getConfig();this.point=e,this.anotherPoint=this.getConfig().anotherPoint;this.object3D.position.set(e.x,e.y,e.z),this.addLine([10,0,0,-10,0,0],{color:this.getLinearColor(t)}),super.init(),this.updateScaleFactor()}addLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:2,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.object3D.add(o),this.line=o}update(e){this.point=e,this.object3D.position.set(e.x,e.y,e.z),this.object3D.updateMatrixWorld()}updateAnotherPoint(e){this.anotherPoint=e,this.updateDirection(),this.object3D.updateMatrixWorld()}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}updateScaleFactor(e,t,i){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var n=this.object3D.position,o=e.clone().sub(n.clone()).length(),s=t.angleTo(this.object3D.position.clone().sub(e.clone()));o=Math.sin(Math.PI/2-s)*o,this.getCloudViewer().camera.isPerspective||(o=this.getOrthogonalityCameraScaleValue());var r=.4*o/this.getCloudViewer().domElement.offsetHeight;if(this.object3D.scale.set(r,r,r),this.updateDirection(),i){let e=this.point.clone().sub(this.anotherPoint.clone()).normalize();var a=this.point.clone().add(e.clone().multiplyScalar(r*i));this.object3D.position.set(a.x,a.y,a.z)}this.object3D.updateMatrixWorld()}updateDirection(){var e=this.viewer.getDomElement().getBoundingClientRect(),t=this.viewer.worldToClient(this.viewer.sceneToWorld(this.anotherPoint)),i=this.getCloudViewer().cameraControl.getRaycaster(t.x+e.left,t.y+e.top);let n=i.ray.origin.clone(),o=i.ray.direction.clone(),s=(new THREE.Plane).setFromNormalAndCoplanarPoint(o,this.point),r=new THREE.Vector3,a=s.projectPoint(n,r),l=this.point.clone().sub(a).normalize().clone().normalize().cross(o.clone().normalize()).normalize();var h=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),l);this.line.quaternion.set(h.x,h.y,h.z,h.w)}hitTest(e){return!1}}class pn extends hn{constructor(e){super(e),this.name="distance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Distance,this.maxPointsNum=2,this.measurePoints=[],this.points=[],this.auxLines=[],this.auxLinesNotationGroup=[],this.selectedArr=[],this.canEdit=!0,this.firstUpdate=!0,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}stretchOnDirection(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]}initByData(e){this.id=e.id,this.setData(e),this.point1=new dn({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[0]),bgColor:this.color}),this.points.push(this.point1),this.add(this.point1),this.point2=new dn({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[1]),bgColor:this.color}),this.points.push(this.point2),this.add(this.point2),this.line=new un({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line),this.endDraw(),this.unselect()}draw(e){if(!this.getIsReserverd())switch(this._svg=e.svg,this.drawCaptureItem(e),e.clientPoints.length){case 2:let t=new dn({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.add(t),this.point2=t,this.points.push(t),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 1:if(!this.point1){let t=new dn({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t)}this.line?this.line.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line=new un({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line)),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.addAuxLines(),this.measureParams.enableAuxiliaryValue&&this.calAuxLinesNotation();let e=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([e,e]),this.line.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.linePoint1=new gn({control:this,name:"linePoint1",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[0]),anotherPoint:this.viewer.worldToScene(this.measurePoints[1]),color:this.color}),this.add(this.linePoint1),this.linePoint2=new gn({control:this,name:"linePoint2",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[1]),anotherPoint:this.viewer.worldToScene(this.measurePoints[0]),color:this.color}),this.add(this.linePoint2)}update(e){this.firstUpdate&&(this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.select(),this.firstUpdate=!1),"point1"==this.selectChild.name?this.measurePoints[0]=e:this.measurePoints[1]=e,this.selectChild.update(this.viewer.worldToScene(e)),this.line.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.updateAuxLines(),this.calculate(),this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let t=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([t,t]),this.notation.select(),this.linePoint1.update(this.viewer.worldToScene(this.measurePoints[0])),this.linePoint2.update(this.viewer.worldToScene(this.measurePoints[1])),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render(),this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,this.getInfo())}endUpdate(){this.firstUpdate=!0,this.measureParams.enableAuxiliaryValue&&(this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.calAuxLinesNotation()),this.linePoint1.updateAnotherPoint(this.viewer.worldToScene(this.measurePoints[1])),this.linePoint2.updateAnotherPoint(this.viewer.worldToScene(this.measurePoints[0])),this.info.distance=this.measureResult,this.info.distanceX=this.distanceX,this.info.distanceY=this.distanceY,this.info.distanceZ=this.distanceZ,this.info.points=this.measurePoints}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([e,e]),this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.measureParams.enableAuxiliaryValue&&this.calAuxLinesNotation(),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}getInfo(){return{id:this.id,distance:this.measureResult,distanceX:this.distanceX,distanceY:this.distanceY,distanceZ:this.distanceZ,points:this.measurePoints,type:this.type}}calculate(){this.distanceX=Math.abs(this.measurePoints[1].x-this.measurePoints[0].x),this.distanceY=Math.abs(this.measurePoints[1].y-this.measurePoints[0].y),this.distanceZ=Math.abs(this.measurePoints[1].z-this.measurePoints[0].z),this.auxLinesResult=[this.distanceX,this.distanceY,this.distanceZ],this.measureResult=Math.sqrt(Math.pow(this.distanceX,2)+Math.pow(this.distanceY,2)+Math.pow(this.distanceZ,2))}addAuxLines(){let e=["#CC021B","#7CCF21","#4A90E2"];for(var t={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},i={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},n=[this.measurePoints[0],t,i,this.measurePoints[1]],o=0;o{e.object3D.visible=!0})),this.notation.select(),this.point1.object3D.visible=!0,this.point2.object3D.visible=!0,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.selectedArr.map((e=>{e.object3D.visible=!1})),this.notation.unselect(),this.point1.object3D.visible=!1,this.point2.object3D.visible=!1,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.points.forEach((e=>e.updateScaleFactor(t,i))),this.updateNotationPosition(),this.linePoint1&&this.linePoint1.updateScaleFactor(t,i,this.linewidth),this.linePoint2&&this.linePoint2.updateScaleFactor(t,i,this.linewidth),this.auxLines.forEach((e=>e.updateScaleFactor(t,i)))}updateNotationPosition(){if(this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,this.measurePoints),this.auxLinesNotationGroup.length>0)){var e={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},t={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},i=[this.measurePoints[0],e,t,this.measurePoints[1]];for(let e=0,t=i.length-1;e0&&(this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[])}reset(){this.children=[],this.measurePoints=[],this.points=[],this.auxLines=[],this.notationGroup=[],this.auxLinesNotationGroup=[],this.selectedArr=[],this.line=null,this.point1=null,this.point2=null,this.text=null,this.textUnselect=null,this.linePoint1=null,this.linePoint2=null,this.object3D.clear()}redo(){1==this.measurePoints.length&&(this.remove(this.point1),this.remove(this.line),this.point1=null,this.line=null,this.points.pop()),super.redo()}}class mn extends cn{constructor(e){super(e)}init(){const{point:e,color:t,direction:i}=this.getConfig();this.dir=i,this.point=e;this.line1=this.getLine([0,0,0,3,0,-3],{color:this.getLinearColor(t)}),this.object3D.add(this.line1);this.line2=this.getLine([0,0,0,-3,0,-3],{color:this.getLinearColor(t)}),this.object3D.add(this.line2),this.addRigidBody(),this.object3D.position.set(e.x,e.y,e.z),super.init(),this.updateScaleFactor()}getLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:2,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);return o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,o}addRigidBody(){const e=new THREE.BoxGeometry(8,8,8),t=new THREE.MeshBasicMaterial,i=this.rigidBody=new THREE.Mesh(e,t);i.visible=!1,this.object3D.add(i)}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1.6*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.updateDirection(),this.object3D.updateMatrixWorld()}updateDirection(){let e=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();this.directionQuaternion=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,-1),this.dir.clone().normalize());const t=this.control.object3D.quaternion.clone().invert(),i=new THREE.Vector3(0,1,0).applyQuaternion(this.directionQuaternion),n=new THREE.Plane(new THREE.Vector3(...Object.values(this.dir)).normalize()),o=new THREE.Vector3;n.projectPoint(e.clone().applyQuaternion(t),o);const s=(new THREE.Quaternion).setFromUnitVectors(i,o.normalize()).multiply(this.directionQuaternion.clone());this.object3D.quaternion.set(s.x,s.y,s.z,s.w),this.object3D.updateMatrixWorld(!0)}updateMaterialResolution(){this.line1.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.line2.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}hitTest(e){const t=[];return this.rigidBody.raycast(e,t),t.length>0}}class fn extends hn{constructor(e){super(e),this.name="minimumDistance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance,this.maxPointsNum=2,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){this.isEndDrawing=!0,this.line=new un({helper:this.helper,control:this,name:"Line",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[0]),this.viewer.worldToScene(this.worldPositions[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line);let e=this.viewer.worldToClient({x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2});this.attachNotation([e,e]),this.lineTriangle1=new mn({control:this,name:"lineTriangle1",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[0]),direction:this.viewer.worldToScene(this.worldPositions[0]).sub(this.viewer.worldToScene(this.worldPositions[1])),color:this.color}),this.add(this.lineTriangle1),this.lineTriangle2=new mn({control:this,name:"lineTriangle2",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[1]),direction:this.viewer.worldToScene(this.worldPositions[1]).sub(this.viewer.worldToScene(this.worldPositions[0])),color:this.color}),this.add(this.lineTriangle2)}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient({x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2});this.attachNotation([e,e]),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}setMinDistanceLine(e){this.minDistanceLine=e}clearMinDistanceLine(){}addPoint(e){var t=this.viewer;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())}reset(e){var t=this.viewer;!1!==e&&this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])})),this.measurePoints=[],this.clearMinDistanceLine(),this.minDistanceLine=null,t.render()}redo(){var e=this.viewer;if(this.measurePoints.length>0&&this.measurePoints.length{(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=bi.formatDistance(t,this.measureParams);return i+=bi.getPostFix(e,!1),i.split(",").join("")}select(){super.select(),this.notation.select()}unselect(){super.unselect(),this.notation.unselect()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.updateNotationPosition(),this.lineTriangle1&&this.lineTriangle1.updateScaleFactor(t,i),this.lineTriangle2&&this.lineTriangle2.updateScaleFactor(t,i)}updateNotationPosition(){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,this.worldPositions))}}class wn extends cn{constructor(e){super(e)}init(){const{center:e,radius:t,thetaStart:i,thetaLength:n,material:o,quaternion:s}=this.getConfig();this.addArc(e,t,i,n,o,s),super.init()}addArc(e,t,i,n,o,s){const r=new THREE.EllipseCurve(0,0,t,t,i,i+n,!1,0).getPoints(128),a=[];r.forEach((e=>a.push(e.x||0,e.y||0,e.z||0)));const l=new THREE.LineGeometry;l.setPositions(a);let h=new THREE.LineMaterial({linewidth:o.linewidth||2,dashed:!1,depthTest:!1,transparent:!0,color:this.getLinearColor(o.color)});h.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const c=new THREE.Line2(l,h);c.position.set(e.x,e.y,e.z),s&&c.quaternion.set(s.x,s.y,s.z,s.w),c.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.line=c,this.object3D.add(c)}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}}class vn extends hn{constructor(e){super(e),this.name="angle",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Angle,this.maxPointsNum=3,this.measurePoints=[],this.points=[],this.canEdit=!0,this.firstUpdate=!0,this.normalLength=70,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e);var t=new dn({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[0]),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t),t=new dn({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[1]),bgColor:this.color}),this.point2=t,this.points.push(t),this.add(t),t=new dn({control:this,name:"point3",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[2]),bgColor:this.color}),this.add(t),this.point3=t,this.points.push(t),this.line1=new un({control:this,name:"line1",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[0]),this.viewer.worldToScene(this.worldPositions[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line1),this.line2=new un({control:this,name:"line2",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[1]),this.viewer.worldToScene(this.worldPositions[2])],color:this.color,linewidth:this.linewidth}),this.add(this.line2),this.endDraw(),this.unselect()}draw(e){if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 3:let t=new dn({control:this,name:"point3",viewer:this.viewer,point:this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[2],["x","y","z"])),bgColor:this.color});this.add(t),this.point3=t,this.points.push(t),this.line2.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[2],["x","y","z"]))]),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 2:if(!this.point2){let e=new dn({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),bgColor:this.color});this.point2=e,this.points.push(e),this.add(e)}this.line2?this.line2.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line2=new un({control:this,name:"line2",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line2)),this.line1.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"]))]),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 1:if(!this.point1){let t=new dn({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t)}this.line1?this.line1.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line1=new un({control:this,name:"line1",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line1)),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.line1.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.line2.update([this.viewer.worldToScene(this.measurePoints[1]),this.viewer.worldToScene(this.measurePoints[2])]),this.addText(),this.addCurve(),this.updateScaleFactor(),this.viewer.getViewer().render()}addText(){this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());var e=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),t=this.viewer.worldToScene(this.measurePoints[2]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone());let i=e.normalize().clone().add(t.normalize().clone()).normalize();var n=this.viewer.worldToScene(this.measurePoints[1]).clone().add(i.clone().multiplyScalar(this.normalLength));let o=this.viewer.worldToClient(this.viewer.sceneToWorld(n));this.attachNotation([o,o])}addCurve(){let e=(new THREE.Plane).setFromCoplanarPoints(this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1]),this.viewer.worldToScene(this.measurePoints[2])),t=e.normal.z<0?e.normal:new THREE.Vector3(-e.normal.x,-e.normal.y,-e.normal.z),i=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),t);var n=new THREE.Vector3(1,0,0).clone().applyQuaternion(i),o=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),s=n.angleTo(o);n.clone().cross(o).angleTo(t)e.updateScaleFactor(t,i))),this.updateCurveScaleFactor(t,i)}updateCurveScaleFactor(e,t){if(!this.isEndDrawing)return;var i=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),n=this.viewer.worldToScene(this.measurePoints[2]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone());let o=.9*i.length(),s=.9*n.length();e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var r=this.curve.line.position,a=e.clone().sub(r.clone()).length(),l=t.angleTo(this.curve.line.position.clone().sub(e.clone()));a=Math.sin(Math.PI/2-l)*a,this.getCloudViewer().camera.isPerspective||(a=this.getOrthogonalityCameraScaleValue());var h=.4*a/this.getCloudViewer().domElement.offsetHeight;h=Math.min(h*this.normalLength,o,s)/this.normalLength,this.curve.line.scale.set(h,h,h),this.curve.object3D.updateMatrixWorld();let c=i.normalize().clone().add(n.normalize().clone()).normalize();var d=this.viewer.worldToScene(this.measurePoints[1]).clone().add(c.clone().multiplyScalar(this.normalLength*h));let u=this.viewer.sceneToWorld(d);this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[u,u])}reset(){this.children=[],this.measurePoints=[],this.points=[],this.line1=null,this.line2=null,this.point1=null,this.point2=null,this.point3=null,this.object3D.clear()}redo(){1==this.measurePoints.length?(this.remove(this.point1),this.remove(this.line1),this.point1=null,this.line1=null,this.points.pop()):2==this.measurePoints.length&&(this.remove(this.point2),this.remove(this.line2),this.point2=null,this.line2=null,this.points.pop()),super.redo()}}class yn extends hn{constructor(e){super(e),this.name="elevation",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Elevation,this.maxPointsNum=1,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){this.isEndDrawing=!0;let e=this.viewer.worldToClient(this.elevationPoint);this.attachNotation([e,e]),this.addPolyline()}addPolyline(){var e=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);e=this.viewer.worldToClient(e);for(var t=[58,-12,-12,-12,0,0,12,-12],i="",n=0;nthis.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){if(this.isEndDrawing=!0,!this.measureResult)return;let e=this.viewer.worldToClient(this.worldPosition);this.attachNotation([e,e])}updateResult(){if(!this.measureResult)return;this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient(this.worldPosition);this.attachNotation([e,e]),this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,volumeResult:this.measureResult,points:this.selectedComponentsId,volumePosition:this.viewer.worldToScene(this.worldPosition),type:this.type}}setData(e){this.info=e,this.id=e.id,this.selectedComponentsId=e.points,this.worldPosition=this.viewer.sceneToWorld(e.volumePosition),this.measureResult=e.volumeResult,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}addPoint(e){var t=this._config.viewer;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())}reset(e){var t=this._config.viewer;!1!==e&&this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])})),this.measurePoints=[],t.render()}actionWhenSelected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).addSelectedComponentsById([e.userId])})),this.viewer.render()}actionWhenUnselected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).removeSelectedId([e.userId])})),this.viewer.render()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=bi.formatCubic(t,this.measureParams);return i=i+bi.getPostFix(e,!1)+"³",i.split(",").join("")}select(){super.select(),this.notation.select()}unselect(){super.unselect(),this.notation.unselect()}updateScaleFactor(e){this.updateNotationPosition()}updateNotationPosition(){this.isEndDrawing&&this.measureResult&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[this.worldPosition,this.worldPosition]))}}class xn extends cn{constructor(e){super(e)}init(){const{point:e,color:t,direction:i}=this.getConfig();this.dir=i,this.point=e,this.linewidth=this.getConfig().linewidth||1;this.line1=this.getLine([0,0,0,2,0,-4],{color:this.getLinearColor(t)}),this.object3D.add(this.line1);this.line2=this.getLine([0,0,0,-2,0,-4],{color:this.getLinearColor(t)}),this.object3D.add(this.line2),this.object3D.position.set(e.x,e.y,e.z),super.init(),this.updateScaleFactor()}getLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);return o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,o}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1.6*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.updateDirection(),this.object3D.updateMatrixWorld()}updateDirection(){let e=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();this.directionQuaternion=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,-1),this.dir.clone().normalize());const t=this.control.object3D.quaternion.clone().invert(),i=new THREE.Vector3(0,1,0).applyQuaternion(this.directionQuaternion),n=new THREE.Plane(new THREE.Vector3(...Object.values(this.dir)).normalize()),o=new THREE.Vector3;n.projectPoint(e.clone().applyQuaternion(t),o);const s=(new THREE.Quaternion).setFromUnitVectors(i,o.normalize()).multiply(this.directionQuaternion.clone());this.object3D.quaternion.set(s.x,s.y,s.z,s.w),this.object3D.updateMatrixWorld(!0)}updateMaterialResolution(){this.line1.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.line2.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}}class En extends hn{constructor(e){super(e),this.name="laserClearDistance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance,this.maxPointsNum=1,this.lineArrowGroup={},this.lineGroup={},this.allNotationGroup={},this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)));const t=this.viewer.getDomElement();let i=document.getElementsByClassName("bf-measure-dragbutton")[0];if(!i){i=document.createElement("div"),i.innerHTML='\n \n \n \n \n \n \n \n \n \n \n \n \n \n ',i.className="bf-measure-dragbutton",i.style.display="none";let e=this.dragEvents={touchmove:e=>{let{top:n,left:o}=t.getBoundingClientRect(),{clientX:s,clientY:r}=e.touches[0];this.setButtonPosition(i,s-o,r-n);const a=new Touch({identifier:Date.now(),target:t,clientX:s,clientY:r,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5}),l=new TouchEvent("touchstart",{touches:[a]});t.dispatchEvent(l);const h=new TouchEvent("touchend");t.dispatchEvent(h),e.stopPropagation(),e.preventDefault()}};for(let t in e)i.addEventListener(t,e[t]);t.appendChild(i)}this.dragButton=i,this.dragButtonPoint=null,this.dragButtonVisible=!1,this._result={};const n=this.nextButtons={},o=document.createElement("div");this.nextButtonContainer=o,t.appendChild(o),["positive_X","negative_X","positive_Y","negative_Y","positive_Z"].forEach((e=>{const t=document.createElement("div");t.addEventListener("touchstart",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchmove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchend",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.addEventListener("mousedown",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mousemove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mouseup",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.className=`bf-measure-nextbutton ${e}`;const i={button:t};let s;Object.defineProperty(i,"position",{set:e=>{if(e){t.style.display="block";let{x:i,y:n}=this.viewer.worldToClient(e);i&&n&&this.setButtonPosition(t,i,n)}else t.style.display="none";s=e},get:()=>s}),o.appendChild(t),n[e]=i})),this.fun=()=>{if(this.dragButtonVisible&&this.dragButtonPoint){this.dragButton.style.display=this.viewer.isInViewFrustum(this.dragButtonPoint)?"block":"none";let{x:e,y:t}=this.viewer.worldToClient(this.dragButtonPoint);e&&t&&this.setButtonPosition(this.dragButton,e,t)}Object.values(n).forEach((e=>{e.position=e.position?e.position.clone():void 0,e.position&&!this.viewer.isInViewFrustum(e.position)&&(e.button.style.display="none")}))},this.viewer.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,this.fun)}initByData(e){this.id=e.id,this.setData(e),this.measurePoints.push({componentId:e.componentSelected.componentId,modelId:e.componentSelected.modelId,point:this.viewer.globalUnitUtil.translate(e.pointSelected,["x","y","z"])}),this.computeMeasureResult(e.intersectNormal),this.endDraw(),this.unselect()}draw(e){this.drawCaptureItem(e)}endDraw(){this.isEndDrawing=!0;const e=this.measure.getMeasureParams().laserXYZ,t={X:"#CC021B",Y:"#7CCF21",Z:"#4A90E2"},i=n=>{const o=this.data[`Laser${n}`];if(o&&-1!==e.indexOf(n)){const e=t[n],[i,s]=o.endPoints,r=new THREE.Vector3(i.x,i.y,i.z),a=new THREE.Vector3(s.x,s.y,s.z),l=o.distance;this.lineGroup[n]=new un({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(r),this.viewer.worldToScene(a)],linewidth:this.lineWidth,isNotHitTest:!0,color:e}),this.add(this.lineGroup[n]),this.lineArrowGroup[n+"start"]=new xn({control:this,name:n+"start",viewer:this.viewer,point:this.viewer.worldToScene(r),direction:this.viewer.worldToScene(a).sub(this.viewer.worldToScene(r)),linewidth:this.lineWidth,color:e}),this.add(this.lineArrowGroup[n+"start"]),this.lineArrowGroup[n+"end"]=new xn({control:this,name:n+"end",viewer:this.viewer,point:this.viewer.worldToScene(a),direction:this.viewer.worldToScene(r).sub(this.viewer.worldToScene(a)),linewidth:this.lineWidth,color:e}),this.add(this.lineArrowGroup[n+"end"]);let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2,z:(r.z+a.z)/2},c=this.viewer.worldToClient(h);if(!this.viewer.isInViewFrustum(h)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x{const o=this.data[`Laser${n}`];if(o&&-1!==t.indexOf(n)){const t=e[n],[i,s]=o.endPoints,r=new THREE.Vector3(i.x,i.y,i.z),a=new THREE.Vector3(s.x,s.y,s.z),l=o.distance;let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2,z:(r.z+a.z)/2},c=this.viewer.worldToClient(h);if(!this.viewer.isInViewFrustum(h)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x{const n=this.viewer.getComponentsByRaycaster(s,t),o=this.viewer.getComponentsByRaycaster(s,t.clone().negate());return this._result[e]=n.length>0&&o.length>0?{enable:!0,direction:t,positiveIntersects:n,negativeIntersects:o,positiveIndex:0,negativeIndex:0}:{enable:!1},this.nextButtons[`positive_${e}`].position=n.length>1&&o.length>0&&-1!==i.indexOf(e)?n[0].position:void 0,"Z"!==e&&(this.nextButtons[`negative_${e}`].position=o.length>1&&n.length>0&&-1!==i.indexOf(e)?o[0].position:void 0),r};let a,l,h;return Math.abs(1-Math.abs(e.z))<.001?(a=new THREE.Vector3(1,0,0),l=new THREE.Vector3(0,1,0),h=new THREE.Vector3(0,0,1)):(a=e.clone().cross(new THREE.Vector3(0,0,1)),a.x<0&&a.negate(),l=e.clone().cross(a),l.y<0&&l.negate(),h=e),r("X",a)("Y",l)("Z",h),!Glodon.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.showDragButton(n),this.getMeasureResult()}getMeasureResult(){let e={},{componentId:t,modelId:i,point:n}=this._result.pointInfo;const o=this.measure.getMeasureParams().laserXYZ;e.pointSelected={x:n.x,y:n.y,z:n.z},e.componentSelected={componentId:t,modelId:i},e.type=this.type;const s=t=>{if(this._result[t].enable&&-1!==o.indexOf(t)){let{direction:i,positiveIntersects:n,negativeIntersects:o,positiveIndex:s,negativeIndex:r}=this._result[t],a=n[s],l=o[r];e[`Laser${t}`]={vector:{x:i.x,y:i.y,z:i.z},distance:a.distance+l.distance,endPoints:[{x:a.position.x,y:a.position.y,z:a.position.z,direction:"positive"},{x:l.position.x,y:l.position.y,z:l.position.z,direction:"negative"}],endComponents:[{componentId:a.id,modelId:a.modelId,direction:"positive"},{componentId:l.id,modelId:l.modelId,direction:"negative"}]}}return s};return s("X")("Y")("Z"),e.intersectNormal=this.intersectNormal,e}getNextResult(e){let[t,i]=e.split("_");if(!this._result[i]||!this._result[i].enable)return;let n=this._result[i][`${t}Intersects`],o=++this._result[i][`${t}Index`];n.length<=o&&(this._result[i][`${t}Index`]=o=0),this.data=this.getMeasureResult(),this.nextButtons[e].position=n[o].position,this.updateLinesPosition(),this.updateResult(),this.updateScaleFactor()}updateLinesPosition(){const e=this.measure.getMeasureParams().laserXYZ,t=i=>{const n=this.data[`Laser${i}`];if(n&&-1!==e.indexOf(i)){const[e,t]=n.endPoints,o=new THREE.Vector3(e.x,e.y,e.z),s=new THREE.Vector3(t.x,t.y,t.z);this.lineGroup[i].update([this.viewer.worldToScene(o),this.viewer.worldToScene(s)]),this.lineArrowGroup[i+"start"].object3D.position.copy(this.viewer.worldToScene(o)),this.lineArrowGroup[i+"end"].object3D.position.copy(this.viewer.worldToScene(s))}return t};t("X")("Y")("Z"),this.object3D.updateMatrixWorld(),this.viewer.render()}showDragButton(e){this.reset(),this.viewer.render(),this.dragButtonPoint=e,this.dragButtonVisible=!0;let{x:t,y:i}=this.viewer.worldToClient(e);this.dragButton.style.display="block",t&&i&&this.setButtonPosition(this.dragButton,t,i)}hideDragButton(){this.dragButtonVisible=!1,this.dragButton.style.display="none",Object.values(this.nextButtons).forEach((e=>e.position=void 0))}showNextButton(){this.nextButtonContainer.style.display="block"}hideNextButton(){this.nextButtonContainer.style.display="none"}clearNextButton(){Object.values(this.nextButtons).forEach((e=>e.position=void 0))}setButtonPosition(e,t,i){e.style.top=`${i}px`,e.style.left=`${t}px`}select(){super.select(),this.notation.select(),this.showNextButton()}unselect(){super.unselect(),this.notation.unselect(),Glodon.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hideNextButton()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize());for(let e in this.lineArrowGroup)this.lineArrowGroup[e]&&this.lineArrowGroup[e].updateScaleFactor(t,i);this.updateNotationPosition()}updateNotationPosition(){if(!this.isEndDrawing)return;this.notation.notationSegmentRects=[];const e=this.measure.getMeasureParams().laserXYZ,t=i=>{const o=this.data[`Laser${i}`];if(o&&-1!==e.indexOf(i)){const[e,t]=o.endPoints,s=new THREE.Vector3(e.x,e.y,e.z),r=new THREE.Vector3(t.x,t.y,t.z),a=o.distance;let l={x:(s.x+r.x)/2,y:(s.y+r.y)/2,z:(s.z+r.z)/2},h=this.viewer.worldToClient(l);if(!this.viewer.isInViewFrustum(l)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x\n #include \n\n gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n #include \n #include \n #include \n\n }\n ",clipping:!1});return Object.defineProperties(t,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}}}),t.setValues(e),t}}class Cn extends hn{constructor(e){super(e),this.name="slope",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Slope,this.maxPointsNum=1,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect(),this.updateScaleFactor()}draw(e){this.drawCaptureItem(e)}drawCaptureItem(e){let t=this.hoverPanel,i=this.hoverPanelSize;if("Panel"===e.hoverObjectType){let n=e.clientPts,o=n[0].distanceTo(n[1]),s=n[0].distanceTo(n[3]),r=o/i.width,a=s/i.height;if(1!=r){let e=this.stretchOnDirection(n[0],n[1],i.width),t=this.stretchOnDirection(n[2],n[3],i.width);n=e.concat(t)}if(1!=a){let e=this.stretchOnDirection(n[0],n[3],i.height),t=this.stretchOnDirection(n[1],n[2],i.height);n=[e[0],t[0],t[1],e[1]]}let l="";for(let e=0;e.01&&(this.dashLine=new un({control:this,name:"Line",viewer:this.viewer,isNotHitTest:!0,points:[new THREE.Vector3(0,0,0),s],color:"#7CCF21",linewidth:2,dashed:!0,dashSize:.4,gapSize:.4}),e.add(this.dashLine.object3D)),s.length()>20&&o.angleTo(s)>.01&&this.addCurve([o,new THREE.Vector3(0,0,0),s]);let r=this.viewer.worldToClient(this.slopePoint);this.attachNotation([r,r]),this.updateScaleFactor()}addCurve(e){let t=(new THREE.Plane).setFromCoplanarPoints(e[0],e[1],e[2]),i=t.normal.z<0?t.normal:new THREE.Vector3(-t.normal.x,-t.normal.y,-t.normal.z),n=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),i);var o=new THREE.Vector3(1,0,0).clone().applyQuaternion(n),s=e[0].clone().sub(e[1].clone()),r=o.angleTo(s);o.clone().cross(s).z>=0&&(r=2*Math.PI-r);var a,l=e[2].clone().sub(e[1].clone()),h=o.angleTo(l);(o.clone().cross(l).z>0&&(h=2*Math.PI-h),r>h)?a=l.clone().cross(s).z>=0?r:h:a=s.clone().cross(l).z>0?h:r;this.curve&&this.remove(this.curve);let c=e[1].clone().sub(e[0].clone()).angleTo(e[1].clone().sub(e[2].clone()));this.curve=new wn({control:this,name:"arc",viewer:this.viewer,center:e[1],radius:18,thetaStart:a,thetaLength:c,material:{color:this.color},quaternion:n}),this.obj3d.add(this.curve.object3D)}updateResult(){this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,slope:this.slope,point:this.slopePoint,normal:this.slopeNormal,type:this.type}}setData(e){this.info=e,this.id=e.id,this.slope=e.slope,this.slopePoint=e.point,this.slopeNormal=e.normal,this.slopeDir=e.slopeDir}getMeasureResult(){return this.slope+" %"}select(){super.select(),this.point.object3D.visible=!0,this.pointUnselect.object3D.visible=!1,this.notation.select(),this.dashLine&&(this.dashLine.object3D.visible=!0),this.curve&&(this.curve.object3D.visible=!0),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.point.object3D.visible=!1,this.pointUnselect.object3D.visible=!0,this.notation.unselect(),this.dashLine&&(this.dashLine.object3D.visible=!1),this.curve&&(this.curve.object3D.visible=!1),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}hitTest(e,t){let i=null;this.children.some((n=>{const o=n.hitTest(e,t);return o&&(i=n),o})),this.hoveredObject=i;let n=this.hitTestArrow(e,t);return this.hoveredObject?!!this.hoveredObject:n||this.notation.hitTest(t)}hitTestArrow(e,t){if(!this.slopePoint||!this.worldPoint2)return!1;let i=this.viewer.worldToClient(this.slopePoint),o=this.viewer.worldToClient(this.worldPoint2);var s=new n(i.x,i.y),r=new n(o.x,o.y);return fi.distanceToSegment(t,s,r)<=10}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.point&&this.point.updateScaleFactor(t,i),this.pointUnselect&&this.pointUnselect.updateScaleFactor(t,i),this.arrow&&this.arrow.updateDirection(i),this.obj3d&&this.updateScaleFactorArrow(t,i)}updateScaleFactorArrow(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.viewer.worldToScene(this.slopePoint),n=e.clone().sub(i.clone()).length(),o=t.angleTo(i.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1*n/this.getCloudViewer().domElement.offsetHeight;this.obj3d.scale.set(s,s,s),this.obj3d.updateMatrixWorld();let r=this.viewer.worldToScene(this.slopePoint),a=this.viewer.worldToScene(this.slopeDir),l=r.clone().add(a.normalize().clone().multiplyScalar(90*s)),h=this.viewer.sceneToWorld(l);this.worldPoint2=h,this.updateNotationPosition({x:(this.slopePoint.x+h.x)/2,y:(this.slopePoint.y+h.y)/2,z:(this.slopePoint.z+h.z)/2})}updateNotationPosition(e){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[e,e]))}}class Tn extends cn{constructor(e){super(e)}init(){const{points:e,color:t,opacity:i}=this.getConfig();this.color=t,this.opacity=i||1,this.trangles=[],this.trangleArr=fi.getAllTriangle(e);for(let e=0;e0&&(this.trangles.forEach((e=>{this.object3D.remove(e),e.geometry.dispose()})),this.trangles=[]),this.getConfig().points=e,this.trangleArr=fi.getAllTriangle(e);for(let e=0;ethis.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e);for(let e=0;e=2){let t=[],i=[];if(this.measurePoints.map((e=>i.push(this.viewer.globalUnitUtil.revertTranslate(e,["x","y","z"])))),i.push(e.worldPosition),i.map((e=>t.push(this.viewer.worldToScene(e)))),this.spaceShape)this.spaceShape.update(t);else{let e=this.spaceShape=new Tn({control:this,name:"spaceShape",viewer:this.viewer,points:t,color:this.color,linewidth:this.linewidth,opacity:.3});this.add(e)}let n=this.spaceShape.getArea();this.measureResult=n,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let o=this.viewer.worldToClient(e.worldPosition);this.attachNotation([o,o]),this.notation.select()}this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.lastLine&&this.remove(this.lastLine),this.lines[this.lines.length-1].update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[this.measurePoints.length-1])]);let e=[];if(this.measurePoints.map((t=>e.push(this.viewer.worldToScene(t)))),this.spaceShape)this.spaceShape.update(e);else{let t=this.spaceShape=new Tn({control:this,name:"spaceShape",viewer:this.viewer,points:e,color:this.color,linewidth:this.linewidth,opacity:.3});this.add(t)}this.measurePoints.map((e=>{let t=new dn({control:this,name:"pointUnselect",viewer:this.viewer,point:this.viewer.worldToScene(e),noBorder:!0,bgColor:this.color,borderColor:this.color});t.object3D.visible=!1,t.hitTest=()=>!1,this.add(t),this.unselectPoints.push(t)})),this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let t=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([t,t]),this.notation.select()}update(e){this.firstUpdate&&(this.select(),this.firstUpdate=!1);let t=+this.selectChild.name.split("-")[1];this.measurePoints[t]=e,this.selectChild.update(this.viewer.worldToScene(e)),this.unselectPoints[t].update(this.viewer.worldToScene(e));for(let e=0;ei.push(this.viewer.worldToScene(e)))),this.spaceShape.update(i);let n=this.spaceShape.getArea();this.measureResult=n,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let o=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([o,o]),this.notation.select(),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render(),this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,this.getInfo())}endUpdate(){this.firstUpdate=!0,this.info.area=this.measureResult,this.info.points=this.measurePoints}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([e,e]),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}getInfo(){return{id:this.id,area:this.measureResult,points:this.measurePoints,type:this.type}}setData(e){this.info=e,this.id=e.id,this.measureResult=e.area,this.measurePoints=e.points,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=bi.formatArea(t,this.measureParams),t+=bi.getPostFix(e,!0),`${BimfaceLanguage.bf_panel_measure_spatial_area}:`+t}select(){super.select(),this.notation.select(),this.points.forEach((e=>{e.object3D.visible=!0})),this.unselectPoints.forEach((e=>{e.object3D.visible=!1})),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.notation.unselect(),this.points.forEach((e=>{e.object3D.visible=!1})),this.unselectPoints.forEach((e=>{e.object3D.visible=!0})),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.points.forEach((e=>e.updateScaleFactor(t,i))),this.unselectPoints.forEach((e=>e.updateScaleFactor(t,i))),this.updateNotationPosition()}updateNotationPosition(){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[this.measurePoints[this.measurePoints.length-1],this.measurePoints[this.measurePoints.length-1]]))}reset(){this.children=[],this.measurePoints=[],this.points=[],this.unselectPoints=[],this.lines=[],this.lastLine=null,this.spaceShape=null,this.triangles=[],this.lastTriangles=null,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear()),this.notationGroup=[],this.object3D.clear()}redo(){this.measurePoints.length>0&&(this.measurePoints.length<=1&&this.reset(),this.remove(this.points[this.points.length-1]),this.remove(this.lines[this.lines.length-1]),this.lines.pop(),this.points.pop(),1===this.points.length&&(this.remove(this.lastLine),this.remove(this.spaceShape),this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear(),this.spaceShape=null,this.lastLine=null)),super.redo()}}class Sn{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 Fi(t,i),this.hookViewer3DEvents(),this.controlObj={[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Distance]:pn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance]:fn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Angle]:vn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Elevation]:yn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Volume]:bn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance]:En,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Slope]:Cn,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea]:In}}hookViewer3DEvents(){this.selectionControl=new on(this.domContainer,this.itemList,this),this.selectionControl.selectionChanged=e=>{if(e){let t=this.mapMeasureInfo[e.getId()];if(t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t),this.bringToFront(e),this.itemClickCallback){let t=this.mapMeasureInfo[e.getId()];this.itemClickCallback(t)}}else this.eventListener.fireEvent("MeasureUnselected",{})},this.selectionControl.hoverChanged=e=>{e?(this.measure.disableMeasureCursor(),this.measure.setIsEnableSnap(!1)):e&&!this.measure.isMeasureOpen()||(this.measure.enableMeasureCursor(),this.measure.setIsEnableSnap(!0))},this.viewer.addEventListener("Rendered",(()=>{this.update(),this.selectionControl&&this.selectionControl.measureUpdateManage.update()})),document.addEventListener("keyup",(e=>{if(46===e.keyCode){let e=this.selectionControl.getSelectedItem();e&&(this.eventListener.fireEvent("MeasureSelected",{type:e.getType(),isDataEmpty:!0}),this.removeItemById(e.getId()),this.selectionControl.setSelectedItem(null))}})),(!this.isViewer3D()||this.measure._opt.isCreateByUI)&&this.viewer.addEventListener("ButtonOnToolbarClicked",(e=>{if("LeftSubToolbar"===e.id&&(this.selectionControl.setSelectedItem(null),this.showExclusiveByViewId(e.viewId),this.viewId=e.viewId),"Measure"===e.id){let t=this.selectionControl.getSelectedItem();if(e.isChecked){if(this.showAll(),t){let e=this.mapMeasureInfo[t.getId()];e.type=t.getType(),t&&t.actionWhenSelected(),this.eventListener.fireEvent("MeasureSelected",e)}}else this.hideAll(),t&&t.actionWhenUnselected()}}))}addItem(e){let t=e.type,i=e.id;if(this.mapMeasureInfo[i])return;this.mapMeasureInfo[i]=e,e.filterUrl=this.dropShadowManager.getFilterUrl();const n=this.measure.getMeasureParams();for(let t in n)e.hasOwnProperty(t)||(e[t]=n[t]);if(this.isViewer3D())return this.measure.measureItem.setData(e),this.measure.measureItem.endDraw(),this.measure.measureItem.select(),this.selectionControl.setSelectedItem(this.measure.measureItem),void(n.minimumDistanceZoom&&"MinimumDistance"===t&&this.viewer.getCamera().zoomToBoundingBox(e.boundingBox));let o=this.drawableFactory.make(t,e,i,this.measure);"ViewerDrawing"===this.viewer.getViewerType()&&o.setViewId&&o.setViewId(this.viewId),o.attach(this.domContainer),o.select(),this.selectionControl.setSelectedItem(o),this.itemList.push(o)}removeItemById(e){this.mapMeasureInfo[e]&&(this.isViewer3D()&&this.measure.measureHelper.removeById(e),delete this.mapMeasureInfo[e]);for(var t=0;t{t.type==e&&delete this.mapMeasureInfo[t.id]})),void this.measure.measureHelper.removeByType(e);for(var t=0;t{this.selectionControl.setSelectedItem(null),this.setIsEnableSelection(!1)})),this.eventListener.addEvent("Measured",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("Reset",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("MeasureParamsUpdated",(()=>{this.measure.measureItem&&this.measure.measureItem.setMeasureParams(this.measure.getMeasureParams());for(const e of this.itemList){let t=this.measure.getMeasureParams(e.type);e.setMeasureParams(t),this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit,this.mapMeasureInfo[e.id].enableAuxiliaryValue=t.enableAuxiliaryValue||!1,this.mapMeasureInfo[e.id].laserXYZ=t.laserXYZ,this.mapMeasureInfo[e.id].minimumDistanceZoom=t.minimumDistanceZoom}if(this.isViewer3D()&&this.measure.measureHelper.children.map((e=>{if(e.isEndDrawing){let t=this.measure.getMeasureParams(e.type);e.setMeasureParams(t),this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit,this.mapMeasureInfo[e.id].enableAuxiliaryValue=t.enableAuxiliaryValue||!1,this.mapMeasureInfo[e.id].laserXYZ=t.laserXYZ,this.mapMeasureInfo[e.id].minimumDistanceZoom=t.minimumDistanceZoom,e.updateResult()}})),this.update(),this.selectionControl.hasSelected()){let e=this.selectionControl.getSelectedItem(),t=this.mapMeasureInfo[e.getId()];t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t)}}))}bringToFront(e){if(!this.isViewer3D()){for(var t=0;t{e.isEndDrawing&&"LaserClearDistance"==e.type&&e.showNextButton()}))}hideAll(){this.group.visible=!1,this.viewer.render(),this.hideLaserClearDistance()}hideLaserClearDistance(){this.children.map((e=>{e.isEndDrawing&&"LaserClearDistance"==e.type&&e.hideNextButton()}))}hitTest(e,t){var i=new THREE.Vector2(e.x,e.y),n=this.viewer.cameraControl.getRaycaster(i.x,i.y);let o=n.ray.origin.clone(),s=n.ray.direction.clone();return n.set(o,s),this.children.find((e=>e.hitTest(n,t)))}hitTestPoint(e,t){var i=new THREE.Vector2(e.x,e.y),n=this.viewer.cameraControl.getRaycaster(i.x,i.y);let o=n.ray.origin.clone(),s=n.ray.direction.clone();return n.set(o,s),this.children.find((e=>e.hitTestPoint(n,t)))}unselctedAll(){this.children.map((e=>e.isEndDrawing&&e.unselect()))}updateMaterialResolution(){this.children.map((e=>{e.isEndDrawing&&e.children.map((e=>{e.updateMaterialResolution()}))}))}destroy(){for(;this.children.length>0;)this.children[0].destroy(),this.group.remove(this.children[0].object3D),this.children.splice(0,1);this.viewer.render(),window.removeEventListener("resize",this.updateFun)}}!function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=null,s=[],a=null,l=null,h=[],c=function(t){var n=t.viewer,o=this,s=new e.Web.Lang.EventManager,r=i.create("div","bf-measure-conext");o.isOpen=!1,this.initialElevation=t.initialElevation,n.addEventListener("Rendered",(function(){o.isOpen&&o.update()})),this.measureHelper=new Dn(n.getViewer()),n.getViewer().getInteractionScene().add(this.measureHelper.group),n.addEventListener("MiniMapOperate",(()=>{this.measureHelper.cameraChangedUpdate()})),this.controlObj={[e.Bimface.Plugins.Measure.MeasureTypeOption.Distance]:pn,[e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance]:fn,[e.Bimface.Plugins.Measure.MeasureTypeOption.Angle]:vn,[e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation]:yn,[e.Bimface.Plugins.Measure.MeasureTypeOption.Volume]:bn,[e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance]:En,[e.Bimface.Plugins.Measure.MeasureTypeOption.Slope]:Cn,[e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea]:In},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(f.EVENTS.ON_MEASURE_PICK,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(f.EVENTS.ON_VOLUME_MEASURE_END,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(f.EVENTS.ON_MEASURE_RESET,(function(t){if(o.isOpen){if(o.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea&&o.measureItem&&o.measureItem.getPoints().length>2)return void o.measureByInfo(o.getInfo());o.measureItem.reset(),o.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset)}}))};c.prototype={init:function(){var e=this.context,t=this._opt.viewer;t.getDomElement().appendChild(e.rootDomElement);var n=i.createNS("svg","bf-measure-svg"),o=i.createNS("svg","bf-measure-svg");this.measureHelper.svgContainer=o;var s=i.create("div","bf-measure-text");e.rootDomElement.innerHTML="",e.rootDomElement.appendChild(n),e.rootDomElement.appendChild(o),this.drawableManager=new Sn(o,t,this),this.drawableManager.setEventListener(this.getEventManager()),this.switchOn(),e.svg=n,e.text=s,t.render()},enableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=`url(${r}),auto`},disableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=""},hideDragButton(){!e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.measureItem&&this.measureItem.hideDragButton&&this.measureItem.hideDragButton()},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),this.enableMeasureCursor();let t=this._opt.viewer.getViewer();if(this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.Volume?(t.editorManager.disableTool(f.EditToolMode.PICK_BY_MEASURE),t.editorManager.enableTool(t,f.EditToolMode.VOLUME_MEASURE)):(t.editorManager.disableTool(f.EditToolMode.VOLUME_MEASURE),t.editorManager.enableTool(t,f.EditToolMode.PICK_BY_MEASURE)),this._measureItemMap[this.type])this.measureItem=this._measureItemMap[this.type];else{let t=new e.Bimface.Plugins.Measure.MeasureItemConfig;t=Object.assign(t,this._opt,this.getMeasureParams()),t.measure=this,t.measureType=this.type,t.helper=this.measureHelper,this.measureItem=new this.controlObj[this.type](t),this.measureHelper.removeNotDrawingFinished(),this.measureHelper.add(this.measureItem)}},switchOn:function(){this.isOpen||(this.activeByMeasureType(),this.isOpen=!0,this.drawableManager.setIsEnableSelection(!0),this.context.rootDomElement.setAttribute("style","display: block"),this.context.rootDomElement.addClass("bf-measure-conext-open"),this.measureHelper.showAll())},switchOff:function(){if(this.isOpen){this.hideDragButton();var e=this,t=e._opt.viewer.getViewer();this.disableMeasureCursor(),t.editorManager.disableTool(f.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(f.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(),c=i.measureItem;if(t){n=t.pickPoint?t.pickPoint:null,t.pointType?a=t.pointType:t.pickPlane?(a="Panel",l=t.normal):t.pickLine?(a="Line",s=t.pickLine):a=t.pickPoint?"Point":null;var d=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume;if(t.pick&&t.pickPoint||d){var u=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation,g=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance;const n=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance;if(u)c.redo(),c.addPoint(t.pickPoint),c.draw(this.context);else if(g&&t.userId&&t.modelId){const e=this.drawableManager.selectionControl.selectedItem;e&&e.name!==this.type&&this.drawableManager.selectionControl.setSelectedItem(null),c.addPoint({userId:t.userId,modelId:t.modelId})}else{if(!(!g||t.userId&&t.modelId))return void i.update();if(d&&t.objectId){for(let i in this.drawableManager.mapMeasureInfo){if(this.drawableManager.mapMeasureInfo[i].type!==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume)continue;let n=this.drawableManager.mapMeasureInfo[i].points[0];if(n.modelId===t.modelId&&n.userId===t.objectId){this.drawableManager.removeItemById(i);break}}this.volumeResult=t.volume,this.volumePosition=t.position,c.addPoint({userId:t.objectId,modelId:t.modelId})}else if(n)t.userId&&c.addPoint({componentId:t.userId,modelId:t.modelId,point:t.pickPoint});else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Slope){if(!t.pickPlane)return void i.update();c.addPoint({normal:t.normal,point:t.pickPoint})}else this.type,e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea,c.addPoint(this.context.footPoint?o:t.pickPoint),i.update()}var p=c.getPoints();h=c.getPoints(),p.length==c.maxPointsNum?this.measureByInfo(this.getInfo()):(r||(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,i.getInfo()))}else this.isEnableSnap&&i.update()}},measureByInfo(t){const i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();i?t.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance&&this.drawableManager.removeItemsByType(e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance):(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),this.drawableManager.addItem(t),i||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,t);let n=new e.Bimface.Plugins.Measure.MeasureItemConfig;n=Object.assign(n,this._opt,this.getMeasureParams()),n.measure=this,n.measureType=this.type,n.helper=this.measureHelper,this.measureItem=new this.controlObj[this.type](n),this.measureHelper.removeNotDrawingFinished(),this.measureHelper.add(this.measureItem)},measureMinimum:function(){},reset:function(){this.isOpen&&(this.measureItem.reset(),this.context.svg.innerHTML="",this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset))},measuringRedo(){this.redo(),this.getInfo().points&&!this.getInfo().points.length&&this.drawableManager.setIsEnableSelection(!0)},measuredRedo(t){if(this.isOpen){const i=this._opt.viewer,n=i.getSelectedComponents();if(this.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance||this.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume){const e=h.map((e=>e.userId)),o=n.reduce(((t,i)=>(e.includes(i)||t.push(i),t)),[]);o.length?(i.removeSelectedId(o),i.render()):(i.clearSelectedComponents(),t&&t())}else n.length?(i.clearSelectedComponents(),i.render()):t&&t()}},setIsEnableSnap:function(e){e||(this.context.svg.innerHTML=""),this.isEnableSnap=e},update:function(){var t=this.measureItem,i=this.context,r=this._opt.viewer,h=r.getDomElement(),c=h.getBoundingClientRect(),d=r.getViewer(),u=t.getPoints(),g=[],p=[];if(i.svg.innerHTML="",i.footPoint=null,n?(i.worldPosition=r.globalUnitUtil.revertTranslate(n,["x","y","z"]),i.hoverPosition=d.worldToCanvas(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=d.worldToCanvas(s[0]),i.lineEndPoint=d.worldToCanvas(s[1]);var m=new THREE.Vector2(i.lineStartPoint.x,i.lineStartPoint.y),w=new THREE.Vector2(i.lineEndPoint.x,i.lineEndPoint.y),v=new THREE.Box2;v.min.set(h.clientLeft,h.clientTop),v.max.set(v.min.x+h.clientWidth,v.min.y+h.clientHeight);var y=!v.containsPoint(m),b=!v.containsPoint(w),x={start:m,end:w},E=f.CameraUtil.lineIntersectWithRect(x,v);if(y&&b)2==E.length&&(i.lineStartPoint=E[0],i.lineEndPoint=E[1]);else if(y||b)for(var P=new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y),M=y?w.clone():m.clone(),C=M.clone().sub(P).normalize(),T=0;T0){i.lineStartPoint=M,i.lineEndPoint=E[T];break}}let e=u[u.length-1];if(e){const{x:t,y:n}=d.worldToCanvas(e),a=new THREE.Vector2(t,n),l=new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y);if(a.distanceTo(l)>5){let t=s[0].clone(),n=s[1].clone();const a=t.x-n.x,h=t.y-n.y,c=t.z-n.z;let d=(e.x-t.x)*(t.x-n.x)+(e.y-t.y)*(t.y-n.y)+(e.z-t.z)*(t.z-n.z);d/=Math.pow(a,2)+Math.pow(h,2)+Math.pow(c,2);let u=new THREE.Vector3(t.x+d*a,t.y+d*h,t.z+d*c),g=r.worldToClient(u);l.distanceTo(g)<=5&&(i.footPoint=g,i.hoverPosition=g,o=u)}}}if("Panel"==i.hoverObjectType){i.normal=d.getScene().worldToDrawing(l),i.normal.normalize();var I=d.cameraControl,S=new THREE.Plane;S.setFromNormalAndCoplanarPoint(i.normal,i.hoverPositionDS);var D=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,A=I.getRaycaster(D.x,D.y);if(this._p1=A.ray.intersectPlane(S,this._p1),A=I.getRaycaster(B.x,B.y),this._p2=A.ray.intersectPlane(S,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var k=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(k))<=.0025,H=Math.abs(i.normal.clone().dot(V))<=.0025;if(R&&H)var O=k.clone(),N=V.clone();else O=L.clone().cross(i.normal).normalize(),N=i.normal.clone().cross(O).normalize();var G=this._p1.distanceTo(this._p2)/2,U=O.clone().multiplyScalar(G),z=N.clone().multiplyScalar(G),F=_.clone().sub(U).add(z),W=_.clone().add(U).add(z),j=_.clone().sub(U).sub(z),X=_.clone().add(U).sub(z),Y=[];Y.push(F,W,X,j);for(var Z=[],$=I.getContainerDimensions(),q=0;q0&&(t.elevation=t.points[0].z-n.globalUnitUtil.excute(this.initialElevation,"m",this.getDefaultUnit())),t.initialElevation=this.initialElevation;else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Slope)if(o[0]){let e;if(0===o[0].normal.x&&0===o[0].normal.y)e=new THREE.Vector3(0,-1,0);else{let t=n.globalUnitUtil.revertVector(o[0].normal,["x","y","z"]).normalize(),i=n.globalUnitUtil.revertVector(o[0].point,["x","y","z"]),s=i.clone().add(t.clone().multiplyScalar(10)),r=i.clone().add(new THREE.Vector3(0,0,-1).clone().multiplyScalar(10));e=(new THREE.Plane).setFromCoplanarPoints(i,s,r).normal.clone().cross(t)}var r=e.angleTo(new THREE.Vector3(0,0,-1));r=r>Math.PI/2?Math.PI/2-(Math.PI-r):Math.PI/2-r;let i=Math.tan(r);i=i>10?9.9999:i,t.point=n.globalUnitUtil.revertVector(o[0].point,["x","y","z"]),t.normal=o[0].normal,t.slopeDir=e,t.slope=(100*i).toFixed(2)}else t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]);else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea){t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]);let e=fi.calcSpatialArea(t.points);t.area=e}else if(t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]),this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance)o&&2==o.length&&(t.distanceX=Math.abs(t.points[1].x-t.points[0].x),t.distanceY=Math.abs(t.points[1].y-t.points[0].y),t.distanceZ=Math.abs(t.points[1].z-t.points[0].z),t.distance=Math.sqrt(Math.pow(t.distanceX,2)+Math.pow(t.distanceY,2)+Math.pow(t.distanceZ,2)));else if(3==o.length){var a=new THREE.Vector3(t.points[0].x-t.points[1].x,t.points[0].y-t.points[1].y,t.points[0].z-t.points[1].z),h=new THREE.Vector3(t.points[2].x-t.points[1].x,t.points[2].y-t.points[1].y,t.points[2].z-t.points[1].z),c=a.angleTo(h);t.angle=180*c/Math.PI}return t},redo:function(){this.measureItem.redo(),this.update(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,this.getInfo())},exit:function(){this.switchOff(),this.context.rootDomElement.setAttribute("style","display: none"),this.context.rootDomElement.removeClass("bf-measure-conext-open"),this.measureHelper.hideAll()},setInitialElevation(e){"number"==typeof e?this.initialElevation=e:this._opt.viewer.console.warn("The data type of initialElevation is wrong")},getInitialElevation(){return this.initialElevation},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return this._opt.viewer._defaultUnit},getEngineUnit:function(){return this._opt.viewer.globalUnitUtil.isBimtilesAsset()?"m":this._opt.viewer.globalUnitUtil.getDefaultUnit()}},t.MeasureViewer3D=c}(),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 Sn(l,n,this),this.drawableManager.setEventListener(r),n.addEventListener("Measured",(t=>{if(!t)return;i||this.drawableManager.clear(!0),t.id=e.Web.Lang.Utility.UUID.createUUID(),this.drawableManager.addItem(t),i||this.drawableManager.unselctedAll();let o=t.type,{type:s,id:r,points:l}=t,h={type:s,id:r,points:l};h[o.toLowerCase()]=t[o.toLowerCase()],h.type=o,a.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,h),delete n.isMeasuring})),n.addEventListener("Measuring",(t=>{i||this.drawableManager.clear(!0),t.id=e.Web.Lang.Utility.UUID.createUUID(),a.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,t),n.isMeasuring=!0})),n.addEventListener("Reset",(()=>{this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset),delete n.isMeasuring}))};s.prototype={init:function(e){i.send(t,"init");e&&(this._callback=e),this.switchOn()},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||this.drawableManager.clear(!0);let t=this.viewerDrawing.mouseEditorMgr,i={color:`#${this._opt.color.getHEX()}`};this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance&&(i.measureResultFormat=bi,i.measure=this,i.totalLengthText=BimfaceLanguage.bf_panel_measure_total_distance),t.activeEditorByName(`${this.type}Measure`,i)},switchOn:function(){i.send(t,"switchOn"),this.isOpen||(this.isOpen=!0,this.enableMeasureCursor(),this.activeByMeasureType(),this.drawableManager.setIsEnableSelection(!0))},enableMeasureCursor:function(){this.domElement.firstElementChild.style.cursor=`url(${r}),auto`},enableOcclusionCursor:function(){this.domElement.firstElementChild.style.cursor=`url(${l}),auto`},disableMeasureCursor:function(){this.domElement.firstElementChild.style.cursor=""},switchOff:function(){i.send(t,"switchOff"),this.isOpen&&(this.isOpen=!1,this.disableMeasureCursor(),this.measureItem=null,this.viewerDrawing.mouseEditorMgr.editors.forEach((e=>{e.auxMobileMeasureTool&&(e.auxMobileMeasureTool.center=null)})),this.viewerDrawing.mouseEditorMgr.activeEditorByName("pick"),this.drawableManager.setIsEnableSelection(!1))},reset:function(){i.send(t,"reset");var n=this.viewerDrawing.mouseEditorMgr.getEditor();n.reset&&n.reset(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset),this.viewerDrawing.update()},update:function(){i.send(t,"update")},exit:function(){i.send(t,"exit"),this.switchOff()},isMeasureOpen:function(){return this.isOpen},setIsEnableSnap:function(e){let t=this.viewerDrawing.mouseEditorMgr.getEditor();t.setIsEnableSnap&&t.setIsEnableSnap(e)},getDefaultUnit:function(){return null}},n.MeasureDrawing=s}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0!==this.measureEnd||this.measurePoints.length==this.maxPointsNum){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}else this.maxPointsNum=this.measurePoints.length},draw:function(e,t){if(this.measureResult=t,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.getMeasureResult();this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.drawLine([e.clientPoints[0],e.hoverPosition]),this.drawNotations();break;default:for(let t=1;t{o+=t;let i=t.toString();i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=bi.formatDistance(o,this.measureParams),o+=bi.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].ze[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=bi.formatDistance(t,this.measureParams),t+=bi.getPostFix(e,!1),i=i.toString(),i=bi.formatDistance(i,this.measureParams),i+=bi.getPostFix(e,!1),n=n.toString(),n=bi.formatDistance(n,this.measureParams),n+=bi.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=fi.makeLine({start:e.clientPoints[0],end:e.hoverPosition,color:this.measureItemConfig.color.getRGBA(),lineWidth:this.measureItemConfig.width});e.svg.appendChild(t)}let t=fi.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=fi.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=fi.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=bi.formatArea(t,this.measureParams),t+=bi.getPostFix(e,!0),t}};n.prototype=Object.assign(n.prototype,o),i.MeasureSpatialAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e)});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_projected_area};n.prototype=Object.assign(n.prototype,o),i.MeasureProjectedAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e),this.defaultColor=e.color,this.fillColor=e.fillColor,this.borderWidth=e.width,this.measureSurfaceMesh=null});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)},draw:function(e,t){if(this.measureResult=t.area,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(this.measurePoints.length){case 0:this.measureSurfaceMesh&&this.measureSurfaceMesh.dispose();break;case 1:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition);break;default:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition),this.drawNotation(e.hoverPosition,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}},drawArea(t,i){const n=this.viewer.getDomElement().getBoundingClientRect&&this.viewer.getDomElement().getBoundingClientRect(),o=n?n.x:0,s=n?n.y:0,r={x:i.x+o,y:i.y+s,z:i.z};let a=this.viewer.clientToWorld(r),l=[...t];l.push(a),this.measureSurfaceMesh||(this.measureSurfaceMesh=new Oi({fillColor:new e.Web.Graphics.Color(255,157,11,.2),color:new e.Web.Graphics.Color(255,157,11,1),width:this.borderWidth})),this.measureSurfaceMesh.setMeasurePoints(l),this.viewer.render()},drawTerminals(e,t){t&&e.concat(t);e.forEach((e=>{let t=fi.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)}))},getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_surface_area};n.prototype=Object.assign(n.prototype,o),i.MeasureSurfaceAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(t){i.MeasureItem.call(this,t),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2,this.groundInfos=[],this.mesh=null,this.borderColor=t.color||new e.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3,this.groundLineInfos=[],this.lastGroundLineMes={}});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},redo(){this.measurePoints.length>0&&this.measurePoints.length-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0===this.measureEnd&&this.measurePoints.length!=this.maxPointsNum)return this.maxPointsNum=this.measurePoints.length,this.groundInfos.length==this.measurePoints.length&&this.groundInfos.pop(),void this.clearGroundLine();if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1),this.measurePoints.length>1&&this.groundLineInfos.push(this.calculateGroundlineDistance(this.measurePoints[this.measurePoints.length-2],this.measurePoints[this.measurePoints.length-1]))},updateGroundLine(e){this.groundLine?this.groundLine.geometry.updateGeometry({points:e}):(this.groundLine=f.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundLine.onAdded()),this.viewer.render()},clearGroundLine(){this.groundLine&&(this.groundLine.onRemoved(),this.groundLine.dispose(),this.groundLine=null)},calculateGroundlineDistance(t,i){if(!t||!i)return null;let n=this.viewer,o=new THREE.Vector3(t.x,t.y,t.z),s=new THREE.Vector3(i.x,i.y,i.z);if(o.equals(s))return null;if(this.lastPoint0&&this.lastPoint1&&o.equals(this.lastPoint0)&&s.equals(this.lastPoint1))return this.lastGroundInfo;let r,a=[];a.push(o),a.push(s),r=new THREE.CatmullRomCurve3(a),r.tension=0,r.type="catmullrom";var l=new f.Raycaster,h=new THREE.Vector3,c=n.getViewer().cameraControl.getIntersectContext(null),d=new f.IntersectHelper(n.getViewer());l.camera=c.camera,l.viewportSize=c.viewportSize;var u=[];r.getPoints(100).forEach((e=>{h.copy(e),(h=n.worldToScene(e)).y=1e4,l.set(h,new THREE.Vector3(0,-1,0));let t=d.getObjectsByRaycaster(c,l,!0);if(t.length>0){let e;e=n.sceneToWorld(t[0].point),u.push(e)}else u.push(e)})),r=null;let g=new e.Bimface.Plugins.Geometry.SplineCurve(u);return g.projectToGround(!0),this.lastPoint0=o,this.lastPoint1=s,this.lastGroundInfo={length:g.length,midPoint:g.getPointByParameter(.5),endPoint:g.getPointByParameter(1),status:"finished"},this.lastGroundInfo},draw:function(e,t){if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.nextMeasurePoint&&this.updateGroundLine([...this.measurePoints,this.nextMeasurePoint]),this.drawNotations();break;default:for(let t=1;t0){t.lineStartPoint=E,t.lineEndPoint=b[M];break}}let e=c[c.length-1];if(e){const{x:n,y:s}=i.worldToClient(e),r=new THREE.Vector2(n,s),a=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y);if(r.distanceTo(a)>5){let n=o[0].clone(),s=o[1].clone();const r=n.x-s.x,l=n.y-s.y,h=n.z-s.z;let c=(e.x-n.x)*(n.x-s.x)+(e.y-n.y)*(n.y-s.y)+(e.z-n.z)*(n.z-s.z);c/=Math.pow(r,2)+Math.pow(l,2)+Math.pow(h,2);let d=new THREE.Vector3(n.x+c*r,n.y+c*l,n.z+c*h),u=i.worldToClient(d);a.distanceTo(u)<=5&&(t.footPoint=u,t.hoverPosition=u)}}}if("Panel"==t.hoverObjectType){t.normal=h.getScene().worldToDrawing(a),t.normal.normalize();var C=h.cameraControl,T=new THREE.Plane;T.setFromNormalAndCoplanarPoint(t.normal,t.hoverPositionDS);var I=new THREE.Vector2(t.hoverPosition.x-10,t.hoverPosition.y-10),S=new THREE.Vector2(t.hoverPosition.x+10,t.hoverPosition.y-10),D=t.hoverPositionDS,B=C.getRaycaster(I.x,I.y);if(this._p1=B.ray.intersectPlane(T,this._p1),B=C.getRaycaster(S.x,S.y),this._p2=B.ray.intersectPlane(T,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),A=new THREE.Vector3(0,1,0),k=new THREE.Vector3(0,0,1),L=Math.abs(t.normal.clone().dot(_))<=.0025,V=Math.abs(t.normal.clone().dot(k))<=.0025;if(L&&V)var R=_.clone(),H=k.clone();else R=A.clone().cross(t.normal).normalize(),H=t.normal.clone().cross(R).normalize();var O=this._p1.distanceTo(this._p2)/2,N=R.clone().multiplyScalar(O),G=H.clone().multiplyScalar(O),U=D.clone().sub(N).add(G),z=D.clone().add(N).add(G),F=D.clone().sub(N).sub(G),W=D.clone().add(N).sub(G),j=[];j.push(U,z,W,F);for(var X=[],Y=C.getContainerDimensions(),Z=0;Z=2){let e=i.length;o.distance=[],o.totalDistance=0;for(let t=1;t=2){o.distance=[],o.totalDistance=0,o.positions=[],o.groundInfos=s.groundInfos,s.lastGroundLineMes.point&&(s.lastGroundLineMes.point.x==s.nextMeasurePoint.x&&s.lastGroundLineMes.point.y==s.nextMeasurePoint.y&&s.lastGroundLineMes.point.z==s.nextMeasurePoint.z?(new Date).getTime()-s.lastGroundLineMes.time>300&&(this.groundLineInfo=s.calculateGroundlineDistance(s.measurePoints[s.measurePoints.length-1],s.nextMeasurePoint)):s.lastGroundLineMes.time=(new Date).getTime()),s.lastGroundLineMes.point=s.nextMeasurePoint,s.groundInfos=this.groundLineInfo&&!s.measureEnd?[...s.groundLineInfos,this.groundLineInfo]:s.groundLineInfos;for(let e=0;ei[1].z&&(e.set(i[1].x,i[1].y,i[0].z),t=e.distanceTo(i[0]),n=e.distanceTo(i[1])),Object.assign(o,{horizontalDistance:t,verticalDistance:n})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:if(i.length>=3&&t){let e=fi.calcSpatialArea(i);Object.assign(o,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:if(i.length>=3&&t){let e=fi.calcProjectedArea(i);Object.assign(o,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:i.length>=3&&t&&(void 0===this.surfaceAreaValue||n?this.surfaceAreaValue=fi.calcSurfaceArea(i,r,this.layerType):(this.surfaceAreaLastTime||(this.surfaceAreaLastTime=(new Date).getTime()),(new Date).getTime()-this.surfaceAreaLastTime>=300&&(this.surfaceAreaValue=fi.calcSurfaceArea(i,r,this.layerType),this.surfaceAreaLastTime=(new Date).getTime())),Object.assign(o,{area:this.surfaceAreaValue,layerType:this.layerType}))}return o},redo:function(){this.measureItem.redo(),this.update(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,this.getInfo())},exit:function(){this.switchOff(),this._unhookEvents()},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return"m"},getEngineUnit:function(){return this._opt.viewer.globalUnitUtil.isBimtilesAsset()?"m":this._opt.viewer.globalUnitUtil.getDefaultUnit()}},t.MeasureViewerGIS=l}(),function(){var t="Bimface.Plugins.Measure.Measure",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t.viewer;if(i){S(this);var s=new e.Web.Lang.EventManager,r=o.create("div","bf-measure-conext");this.context={rootDomElement:r},this.id="Measure","ViewerGIS"===i.getViewerType()&&t.measureType==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance&&(t.measureType=e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance),this._opt=t,this.type=t.measureType,this.layerType=t.layerType,this.getEventManager=function(){return s},"Viewer3D"===i.getViewerType()?(n.MeasureViewer3D.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewer3D.prototype)):"ViewerGIS"===i.getViewerType()?(n.MeasureViewerGIS.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewerGIS.prototype)):(n.MeasureDrawing.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureDrawing.prototype)),this._setDefaultUnits(t),this._setDefaultPrecisions(t),this.init()}};s.prototype={inherit:function(e){for(var t in e)this[t]=e[t]},addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},_setDefaultUnits:function(t){const i=t.viewer.getViewerType();if(null!=t.lengthUnits&&null==t.units){switch(i){case"Viewer3D":case"ViewerGIS":t.units={distance:t.lengthUnits,elevation:t.lengthUnits,area:t.lengthUnits};break;case"ViewerDrawing":t.units={distance:t.lengthUnits,area:t.lengthUnits}}return}const n=this.getDefaultUnit();"m"===n?t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Meter:"mm"===n&&(t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Millimeter);const o=t.units&&t.units.distance||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.Millimeter,s=t.units&&t.units.distance||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.None,r=t.units&&t.units.elevation||e.Bimface.Common.Units.LengthUnits.Meter,a=t.units&&t.units.area||e.Bimface.Common.Units.LengthUnits.Meter,l=t.units&&t.units.area||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.Millimeter,h=t.units&&t.units.area||e.Bimface.Common.Units.LengthUnits.None;switch(i){case"Viewer3D":t.units={distance:o,elevation:r,area:l};break;case"ViewerGIS":t.units={distance:o,elevation:r,area:a};break;case"ViewerDrawing":t.units={distance:s,area:h}}},_setDefaultPrecisions:function(e){if("number"==typeof e.precision)e.obsoletePrecision=e.precision,e.precision={distance:e.obsoletePrecision,elevation:e.obsoletePrecision,area:e.obsoletePrecision,angle:e.obsoletePrecision,latLon:e.obsoletePrecision};else{let{distance:t=3,elevation:i=3,area:n=3,angle:o=2,latLon:s=9}=e.precision;e.precision={distance:t,elevation:i,area:n,angle:o,latLon:s}}},getMeasureType:function(){return this.type},setMeasureType:function(e){i.send(t,"setMeasureType"),this.hideDragButton&&this.hideDragButton(),this.type=e,this.reset(),this.activeByMeasureType(),this.getEventManager().fireEvent("typeChange",e)},setPrecision:function(e){"number"==typeof e||"string"==typeof e?(this._opt.obsoletePrecision=e,this._opt.precision={distance:e,elevation:e,area:e,angle:e,latLon:e}):this._opt.precision=Object.assign(this._opt.precision,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getPrecision:function(){return void 0!==this._opt.obsoletePrecision?this._opt.obsoletePrecision:this._opt.precision},setScale:function(e){this._opt.scale=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getScale:function(){return this._opt.scale},setLengthUnits:function(e){this._opt.lengthUnits=e;for(const t in this._opt.units)this._opt.units[t]=e;this.getEventManager().fireEvent("MeasureParamsUpdated")},getLengthUnits:function(){return this._opt.lengthUnits},setUnits:function(e){this._opt.units=Object.assign(this._opt.units,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getUnits:function(){return this._opt.units},getAllItems:function(){return this.drawableManager.save()},setItems:function(e){this.clear(),this.drawableManager.load(e)},clear:function(){this.drawableManager.clear(!0),this.hideDragButton&&this.hideDragButton()},hideAllItems:function(){this.drawableManager.hideAll()},showAllItems:function(){this.drawableManager.showAll()},onClick:function(e){this.drawableManager.onClick(e)},removeSelectedItem:function(){this.drawableManager.unselctedAll()},getSelectedItem:function(){return this.drawableManager.getSelectedItem()},setLayerType:function(e){this.layerType=e},getMeasureParams:function(t){let i={scale:this.getScale(),defaultUnit:this.getDefaultUnit(),laserXYZ:this.getLaserXYZ()};switch(t||this.type){case e.Bimface.Plugins.Measure.MeasureTypeOption.Angle:i=Object.assign(i,{precision:this._opt.precision.angle,unit:"°"});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation:i=Object.assign(i,{precision:this._opt.precision.elevation,unit:this.getUnits().elevation});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Area:case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:i=Object.assign(i,{precision:this._opt.precision.area,unit:this.getUnits().area});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Position:i=Object.assign(i,{precision:{elevation:this._opt.precision.elevation,latLon:this._opt.precision.latLon},unit:this.getUnits().elevation});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Slope:i=Object.assign(i,{unit:"%"});break;default:i=Object.assign(i,{precision:this._opt.precision.distance,unit:this.getUnits().distance,enableAuxiliaryValue:this._opt.enableAuxiliaryValue||!1,minimumDistanceZoom:this.getMinimumDistanceZoom()})}return i},enableAuxiliaryValue(e){i.send(t,"enableAuxiliaryValue"),this._opt.enableAuxiliaryValue=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},isEnableAuxiliaryValue(){return i.send(t,"isEnableAuxiliaryValue"),this._opt.enableAuxiliaryValue},setLaserXYZ(e){i.send(t,"setLaserXYZ"),this._opt.laserXYZ=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getLaserXYZ(){return this._opt.laserXYZ},setMinimumDistanceZoom(e){i.send(t,"setMinimumDistanceZoom"),this._opt.minimumDistanceZoom=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getMinimumDistanceZoom(){return this._opt.minimumDistanceZoom}},n.Measure=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureRayConfig=function(){return{viewer:null,targetsHintColor:new e.Web.Graphics.Color(245,127,35,.6)}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureRayItemConfig=function(){return{id:null,color:new e.Web.Graphics.Color(245,127,35,1),width:2,startPoint:new e.Web.Geometry.Point3d(0,0,0),endPoint:new e.Web.Geometry.Point3d(0,0,0),startObjectId:null,endObjectId:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){this.id=t.id||e.Web.Lang.Utility.UUID.createUUID();this.startPoint=t.startPoint,this.endPoint=t.endPoint;this.startComponentId=t.startComponentId,this.endComponentId=t.endComponentId;var n=i.createNS("defs","bf-defs");n.innerHTML=`\n \n \n `;var o=i.create("i","bf-measure-handle");o.style.width=12*t.width+"px",o.style.height=12*t.width+"px",o.style.backgroundColor=t.color.getRGBA(),o.style.lineHeight=12*t.width+"px";var s=i.createNS("line","bf-measure-line");s.style.stroke=t.color.getRGBA(),s.setAttribute("stroke-width",t.width);var r=i.create("span","bf-measure-number");r.style.backgroundColor=t.color.getRGBA(),this.domElement=n,this.line=s,this.circle=o,this.text=r};n.prototype={draw:function(e){var t=this.domElement,i=this.line,n=this.circle,o=this.text,s=Math.abs(e.endPoint.x-e.startPoint.x),r=Math.abs(e.endPoint.y-e.startPoint.y),a=Math.abs(e.endPoint.z-e.startPoint.z),l=Math.sqrt(Math.pow(s,2)+Math.pow(r,2)+Math.pow(a,2));i.setAttribute("x1",e.startPoint.x),i.setAttribute("y1",e.startPoint.y),i.setAttribute("x2",e.endPoint.x),i.setAttribute("y2",e.endPoint.y),n.style.left=`${e.startPoint.x}px`,n.style.top=`${e.startPoint.y}px`,e.isMove&&(n.style.border="2px solid #fff"),l<15?i.removeAttribute("marker-end"):i.setAttribute("marker-end","url(#end)"),o.innerText=e.distance,e.svg.appendChild(t),e.svg.appendChild(i),e.text.appendChild(n),0==e.distance?n.innerText="0":(o.style.left=(e.startPoint.x+e.endPoint.x)/2+"px",o.style.top=(e.startPoint.y+e.endPoint.y)/2+"px",o.style.transform="translate(-50%, 0)",o.style.marginTop="2px",e.text.appendChild(o))}},t.MeasureRayItem=n}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure");let i=Object.freeze({Measured:"Measured",Clear:"Clear"});t.MeasureRayEvent=i}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){var n=t.viewer;if(n)if("Viewer3D"===n.viewerType){var o=this,s=new e.Web.Lang.EventManager,r=i.create("div","bf-measure-conext");n.addEventListener("Rendered",(function(){o.measureItem&&o.update()})),this.context={rootDomElement:r},this._opt=t,this._enableMove=!1,this._events={mousedown:function(){this._startTime=(new Date).getTime()},mouseup:function(e){if(0==e.button||1==e.button)if(o._enableMove)o._enableMove=!1,o.measureByPoint(e);else{var t=this._startTime;(new Date).getTime()-t<300&&o.measureByPoint(e)}},mousemove:function(e){o._enableMove&&(e.stopPropagation(),o.measureByPoint(e))}},this.getEventManager=function(){return s}}else console.log("Viewer2D is not supported.")};n.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},switchOn:function(e){var t=this.context,n=this;n._opt.viewer.getDomElement().appendChild(t.rootDomElement),e&&(n._callback=e),n._opt.viewer.getModels().forEach((e=>{e.setSelectedComponentsById()}));var o=i.createNS("svg","bf-measure-svg"),s=i.create("div","bf-measure-text");t.rootDomElement.appendChild(o),t.rootDomElement.appendChild(s),t.svg=o,t.text=s,t.rootDomElement.addEventListener("mousedown",n._events.mousedown),t.rootDomElement.addEventListener("mouseup",n._events.mouseup),t.rootDomElement.addEventListener("mousemove",n._events.mousemove)},switchOff:function(){var e=this.context.rootDomElement,t=this,i=t._opt.viewer;t.measureItem&&(i.restoreComponentsColorById([t.measureItem.startComponentId,t.measureItem.endComponentId]),i.render()),e.removeEventListener("mousedown",t._events.mousedown),e.removeEventListener("mouseup",t._events.mouseup),e.removeEventListener("mousemove",t._events.mousemove),e.innerHTML="",e.remove(),t.measureItem=null},reset:function(){this.clear()},clear:function(){var t=this.context,i=this,n=i._opt.viewer;i.measureItem&&(n.restoreComponentsColorById([i.measureItem.startComponentId,i.measureItem.endComponentId]),n.render()),t.svg.innerHTML="",t.text.innerHTML="",i.measureItem=null,i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureRayEvent.Clear,data)},measureByPoint:function(t){var i=this,n=i._opt.viewer,o=n.getViewer().pickByPointWithNormal(t);if(o){i.measureItem&&n.restoreComponentsColorById([i.measureItem.startComponentId,i.measureItem.endComponentId]);e.Bimface.Viewer.Viewer3DEvent;var s=i._getContextData(o),r=new e.Bimface.Plugins.Measure.MeasureRayItemConfig;r.startComponentId=s.startComponentId,r.endComponentId=s.endComponentId,r.startPoint=s.startPoint,r.endPoint=s.endPoint;var a=new e.Bimface.Plugins.Measure.MeasureRayItem(r);a.circle.addEventListener("mousedown",(function(e){2!=e.button&&(i._enableMove=!0)})),i.context.distance=s.distance,n.overrideComponentsColorById([s.startComponentId,s.endComponentId],i._opt.targetsHintColor),setTimeout((function(){i.update(),n.render()}),100),i.measureItem=a,i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureRayEvent.Measured,s)}},update:function(){var t=this.measureItem,i=this.context,n=this._opt.viewer;i.svg.innerHTML="",i.text.innerHTML="",i.isMove=this._enableMove;var o=n.worldToClient(t.startPoint),s=n.worldToClient(t.endPoint);o&&s&&(i.startPoint=new e.Web.Geometry.Point3d(o.x,o.y,o.z),i.endPoint=new e.Web.Geometry.Point3d(s.x,s.y,s.z),t.draw(i))},exit:function(){this.switchOff()},_getContextData:function(e){var t,i,n={};return t=i=e[0],e.length>1&&(i=e[1]),n.startComponentId=t.userId,n.startPoint=t.worldPosition,n.endComponentId=i.userId,n.endPoint=i.worldPosition,n.distanceX=Math.round(Math.abs(n.endPoint.x-n.startPoint.x)),n.distanceY=Math.round(Math.abs(n.endPoint.y-n.startPoint.y)),n.distanceZ=Math.round(Math.abs(n.endPoint.z-n.startPoint.z)),n.distance=Math.round(Math.sqrt(Math.pow(n.distanceX,2)+Math.pow(n.distanceY,2)+Math.pow(n.distanceZ,2))),n}},t.MeasureRay=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D").Marker3DContainerConfig=function(){return{viewer:null,type:null,layerId:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D").Marker3DConfig=function(){return{id:null,objectId:null,size:30,tooltip:"",tooltipStyle:{color:"#333",fontSize:"14px",borderWidth:"1px",borderColor:"#666",borderStyle:"solid",backgroundColor:"#fff"},src:null,canvas:null,worldPosition:new e.Web.Geometry.Point3d(0,0,0),modelId:void 0,layerId:void 0,hoverAnimation:!0}},function(){var t="Bimface.Plugins.Marker3D.Marker3D",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=this;this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=t.layerId,this.modelId=t.modelId,this.objectId=t.objectId,this.size=t.size,this.iconUrl=t.canvas?t.canvas.toDataURL():t.src,this.position={x:t.worldPosition.x,y:t.worldPosition.y,z:t.worldPosition.z},this.hoverAnimation=t.hoverAnimation,this.originalPosition=new THREE.Vector3(this.position.x,this.position.y,this.position.z),this.explosionOffset=new THREE.Vector3,this.tooltip=t.tooltip,this.tooltipElement=o.create("div","bf-tooltip"),this.tooltipElement.innerHTML=t.tooltip,this.tooltipElement.setCss(t.tooltipStyle),this.isHideByClustering=!1,this._tooltipCallback=function(e,t,n){var o=i.tooltipElement;n.appendChild(o);var s=o.offsetWidth,r=o.offsetHeight;o.style.left=t.x-s/2+"px",o.style.top=t.y-r-i.size+"px",i._hoverCallback&&i._hoverCallback(e)},this._config=t,this.scratchVector=new THREE.Vector3,this.scratchVector_2=new THREE.Vector3,S(this)};s.prototype={getId:function(){return this.id},getWorldPosition:function(){return this.container?this.container._viewer.globalUnitUtil.revertVector(this.position):this.position},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.position={x:e.x,y:e.y,z:e.z},this.originalPosition=new THREE.Vector3(this.position.x,this.position.y,this.position.z),this.update()},getSize:function(){return this.size},setSize:function(e){i.send(t,"setSize"),this.size=e,this.update()},getSrc:function(){return this.iconUrl},setSrc:function(e){i.send(t,"setSrc"),this.iconUrl=e,this.update()},getTooltip:function(){return this.tooltip},setTooltip:function(e){i.send(t,"setTooltip"),this.tooltip=e,this.tooltipElement.innerHTML=e},onClick:function(e){i.send(t,"onClick"),e&&(this._clickCallback=e)},onHover:function(e){i.send(t,"onHover"),e&&(this._hoverCallback=e)},onDoubleClick:function(e){i.send(t,"onDoubleClick"),e&&(this._doubleClickCallback=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClickCallback=e)},update:function(){i.send(t,"update"),this.container&&this.container.update()},isHideByClustering:function(){return this.isHideByClustering},hideByClustering:function(e){this.isHideByClustering=!!e},attachExplosionOffset:function(e,t){if(!this.getWorldPosition())return;let i=this._config.objectId;if(i){let n=e.modelManager.getBoundingBoxByIds([i]),o=this.assoiatedComponentBbox,s=n;if(o){let e=s.getCenter(this.scratchVector).clone();e.sub(o.getCenter(this.scratchVector_2).clone()),this.explosionOffset=e,this.explosionExtent>0&&0===t&&(this.originalPosition.x+=this.explosionDirection*e.x,this.originalPosition.y+=this.explosionDirection*e.y,this.originalPosition.z+=this.explosionDirection*e.z,this.explosionExtent=0,this.explosionOffset=new THREE.Vector3,this.assoiatedComponentBbox=s.clone())}}else{let i=e.getScene().getOriginalBoundingBoxWorld().getCenter(this.scratchVector),n=(new THREE.Box3).expandByPoint(this.getWorldPosition()),o=CLOUD.Utils.computeExplodeTranslation(i,n,t);this.explosionOffset=o}},updatePosition:function(){this.container?(this.position.x=this.container._viewer.globalUnitUtil.translate(this.originalPosition.x+this.explosionOffset.x),this.position.y=this.container._viewer.globalUnitUtil.translate(this.originalPosition.y+this.explosionOffset.y),this.position.z=this.container._viewer.globalUnitUtil.translate(this.originalPosition.z+this.explosionOffset.z)):(this.position.x=this.originalPosition.x+this.explosionOffset.x,this.position.y=this.originalPosition.y+this.explosionOffset.y,this.position.z=this.originalPosition.z+this.explosionOffset.z)},getOriginalPosition:function(){return this.originalPosition},setInitialExplosionInfo:function(e){if("Viewer3D"!==e.getViewerType()&&"ViewerGIS"!==e.getViewerType())return;let t=null;"Viewer3D"===e.getViewerType()?t=this.modelId?e.getModel(this.modelId):e.getDefaultModel():"ViewerGIS"===e.getViewerType()&&(t=e.getLayerManager().getLayer(this.layerId)),this.explosionExtent=null===t?t.getExplosionExtent():0;let i=this._config.objectId;if(i){let t=e.getViewer().modelManager.getBoundingBoxByIds([i]);t.isEmpty()?(this._config.objectId=null,console.log("Cannot find component with Id "+i)):this.assoiatedComponentBbox=t.clone()}},getCurrentPosition:function(){return this.container?this.container._viewer.globalUnitUtil.revertVector(this.position):this.position},getHoverAnimation:function(){return this.hoverAnimation},setHoverAnimation:function(e){null!=e&&(this.hoverAnimation=e,this.update())},setContainerVisible:function(e){this.hideByClustering(!e),this.update()},getOpacity:function(){return 1},setOpacity:function(e){},resetClientPosition:function(e){this.setWorldPosition(e)}},n.Marker3D=s}(),function(){var t="Bimface.Plugins.Marker3D.Marker3DContainer",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");n.Marker3DContainer=class{constructor(t){e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(!t.viewer)return void console.log("viewer must not be empty.");this.isMarker3DContainer=!0;const i="Viewer3D"===t.viewer.viewerType,n=e.Bimface.Viewer.ViewerGIS&&t.viewer instanceof e.Bimface.Viewer.ViewerGIS;var o=t.viewer.getDomElement(),s=t.viewer.getViewer();if(!i&&!n)return void console.log("Viewer2D is not supported.");if(S(this),"ViewerGIS"===t.viewer.getViewerType()&&"ShpPoint"===t.type)this._helper=new f.ShpPointMarker(s,t.layerId);else{if(t.viewer.marker3DContainer)return t.viewer.marker3DContainer;t.viewer.marker3DContainer=this,this._helper=new f.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===f.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===f.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===f.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===f.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(f.EVENTS.ON_CLICK_MARKER3D_PICK,r._pick),s.registerEventListener(f.EVENTS.ON_CLICK_MARKER3D_PICK,r._rightPick),s.registerEventListener(f.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;tn.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{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{this.calculateViewerGISExplosionOffset(e)}))),t.viewer.getViewer().registerEventListener(f.EVENTS.ON_EXPLOSION,(e=>{let i=this.getAllItems();for(const n of i)Qt.attachExplosionOffset(t.viewer,e.extent,n);this.update()}))}addItem(e){i.send(t,"addItem"),e.container=this;let n=Qt.ifExploded(this._viewer,e,this._isViewerGIS);n&&(n.setInitialExplosionInfo(this._viewer),n.updatePosition(),this._items.push(n),this._helper.add([n],(()=>{this._viewer.render()}))),this.addTipsHoverListener()}addTipsHoverListener(){if(!this.hoverListenerAdded){const i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();var t=this._viewer.getViewer();i&&t.registerEventListener(f.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{this._levelsInfo=e.axisGrid.Levels,this.addItem(i)}))}}addItems(e){i.send(t,"addItems");for(const t of e){let e=Qt.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer),t.updatePosition()}this._helper.add(e),this.addTipsHoverListener()}removeItemById(e){i.send(t,"removeItemById"),this._items.removeObjectByAttribute("id",e),this._helper.removeById(e)}getItemById(e){return this._items.getObjectByAttribute("id",e)}getAllItems(){return[...this._items]}clear(){i.send(t,"clear");var n=this._viewer.getViewer();let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();n.unregisterEventListener(f.EVENTS.ON_CLICK_PICK,this._pick),o&&n.unregisterEventListener(f.EVENTS.ON_HOVER_PICK,this._hover),this.hoverListenerAdded=!1,this._items=[],this._helper.clear(!0),this._viewer.render()}update(){this._helper.clear();let e=this._items.slice();for(let t=0,i=e.length;t{this._opt.viewer.getEventManager().fireEvent("SectionBoxVisibleChanged",e)}))},setBox:function(e){o.send(n,"setBox");var t=this._sectionBox.getEditor();e=this._viewer.globalUnitUtil.translate(e,["x","y","z"]),t.calculateOffsetByBox(e.min,e.max),f.GlobalData.ClippingCapsType==f.EnumClippingCapsTypes.ClipBox&&this._sectionBox&&this._sectionBox.getEditor().clipPlanes.reCalculateClippingIds()},getBox:function(){},hideBox:function(){o.send(n,"hideBox"),this._sectionBox&&this._sectionBox.setVisible(!1),this._viewer.render()},showBox:function(){o.send(n,"showBox"),this._sectionBox&&this._sectionBox.setVisible(!0),this._viewer.render()},setProgress:function(e,t){var i={x:["Left","Right"],y:["Back","Front"],z:["Bottom","Top"]};t&&(this._sectionBox.setProcess(i[e][0],t[0]/100),2==t.length&&this._sectionBox.setProcess(i[e][1],1-t[1]/100))},getProgress:function(e){var t=[],i={x:["Left","Right"],y:["Back","Front"],z:["Bottom","Top"]};return t.push(100*this._sectionBox.getProcess(i[e][0])),t.push(100-100*this._sectionBox.getProcess(i[e][1])),t},reCalculateClippingIds(e){this._sectionBox.reCalculateClippingIds(e)},reset:function(){o.send(n,"reset"),this._sectionBox&&this._sectionBox.toggle(!0,!0),this._sectionBox&&this._sectionBox.reset("Rotate"),this.showBox()},enable:function(e){o.send(n,"enable");var t=this._opt.viewer,i=t.getViewer().getScene();f.ClipPlaneManager.getInstance(i).enable(e,e),t.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionBoxVisibleChangedEvent(e)},fitToModel:function(){o.send(n,"fitToModel"),this.reset();var e=this._sectionBox.recalculate().clone();e.isEmpty()&&e.expandByPoint(new THREE.Vector3),e=this._viewer.globalUnitUtil.revertTranslate(e,["x","y","z"]),this.setBox(e),this._sectionBox.getEditor()._isVisible()&&this.showBox(),this.eventManager.fireEvent(this.sectionBoxEvent.SectionBoxChanged)},isIncluded:function(e){var t=this._opt.viewer,i=t.getViewer().getScene(),n=f.ClipPlaneManager.getInstance(i).getClipBoundingBox(),o=t.worldToScene(e);return n.containsPoint(o)},exit:function(){o.send(n,"exit");var e=this._opt.viewer.getViewer(),i=this._viewer.getDomElement();this.clearFilter(),this.reset(),e.getModelManager().updatePickingMaterial(),e.editorManager.disableTool(f.EditToolMode.CLIP_BY_BOX),e.getClipCapsManager().resetClippingCapsStatus(),i.style.removeProperty("cursor"),this._sectionBox=null,this._opt.viewer._sectionBox=null,t=null,this.eventManager.fireEvent(this.sectionBoxEvent.SectionBoxUpdate,null),e.unregisterEventListener(f.EVENTS.ON_CLIP_HOVER,(function(e){e.onClipBox?i.style.cursor=`url(${a}),auto`:i.style.removeProperty("cursor")})),f.GlobalData.SnapClippingLine=!1,f.GlobalData.CalculateClippingLine=!0,this.fireSectionBoxVisibleChangedEvent(!1)},lockBox:function(e){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").lockBoxFaces(e)},unlockBox:function(){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").unlockBox()},getState:function(){var e=this._opt.viewer,t=this._sectionBox.saveState(),i=t.boundingBox;return i.min=e.sceneToWorld(i.min),i.max=e.sceneToWorld(i.max),t.center=e.globalUnitUtil.revertVector(t.center),t.position=e.globalUnitUtil.revertVector(t.position),t},setState:function(e){var t=this._opt.viewer,i=Object.assign({},e.boundingBox),n=Object.assign({},e);n.cneter=Object.assign({},e.center),n.position=Object.assign({},e.position);var o=n.boundingBox;o.min=t.worldToScene(o.min),o.max=t.worldToScene(o.max),n.center=t.globalUnitUtil.translateVector(n.center),n.position=t.globalUnitUtil.translateVector(n.position),n.quaternion&&n.quaternion instanceof Array&&(n.quaternion=new THREE.Quaternion(...n.quaternion)),this._sectionBox.loadState(n),e.boundingBox=i},restore:function(){var e=this._sectionBox.getEditor()._isVisible();this._sectionBox.toggle(!0,e),this._sectionBox.reset("Rotate")},getSectionBox:function(){o.send(n,"getSectionBox");var e=this._opt.viewer,t=this._sectionBox.saveState().boundingBox,i=e.getViewer().getScene().getMatrixGlobal();return i.invert(),t=e.globalUnitUtil.revertTranslate(t,["x","y","z"]),(t=new THREE.Box3(new THREE.Vector3(t.min.x,t.min.y,t.min.z),new THREE.Vector3(t.max.x,t.max.y,t.max.z))).applyMatrix4(i),t},setSectionBox:function(e){o.send(n,"setSectionBox");var t=this._opt.viewer,i=t.getViewer().getScene(),s=f.ClipPlaneManager.getInstance(i);e=t.globalUnitUtil.translate(e,["x","y","z"]);var r=(i=t.getViewer().getScene()).getMatrixGlobal(),a=new THREE.Box3(new THREE.Vector3(e.min.x,e.min.y,e.min.z),new THREE.Vector3(e.max.x,e.max.y,e.max.z));a.isEmpty()?console.warn("The x,y,z of box.min must be smaller than box.max"):(a.applyMatrix4(r),s.setSectionBox(a.min,a.max))},update:function(){this._sectionBox.update()},setObjectsById(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsById(e)})),this._sectionBox.update(),this._opt.viewer.render()},setObjectsByObjectData(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsByObjectData(e)})),this._sectionBox.update(),this._opt.viewer.render()},restoreObjects(){this._opt.viewer.getModels().forEach((e=>{e.clearLocalClipping()})),this._sectionBox.update(),this._opt.viewer.render()},setFilter(e){if(!(e&&e instanceof Array))return void console.log("conditions should be Array.");const t=this._opt.viewer,i=t.getViewer();for(const i of e){if(i.layerId){const e=t.getLayerManager().getLayer(i.layerId);if(!e)continue;i.modelId=e.getModelId()}let e;if(i.modelId)e=t.getModel(i.modelId);else if(e=t.getModel(),void 0===e)continue;i.objectIds?e.localClippingComponentsById(i.objectIds):i.objectData?e.localClippingComponentsByObjectData(i.objectData):e.localClippingComponentsByObjectData([])}this._sectionBox.update(),i.getModelManager().updatePickingMaterial(),this.fireSectionBoxVisibleChangedEvent(!1),this._opt.viewer.render()},clearFilter(){this.restoreObjects(),this.fireSectionBoxVisibleChangedEvent(!0)},changeClipDirection(e){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").changeDirection(e),this.fireSectionBoxVisibleChangedEvent(!e)},rotateByAxis(e,t){if(o.send(n,"rotateByAxis"),"XAxis"!==e&&"YAxis"!==e&&"ZAxis"!==e)return void console.warn("Rotate axis must be XAxis,YAxis or ZAxis.");if(isNaN(t))return void console.warn("the degree input is not a number");let i,s=THREE.Math.degToRad(t);switch(e){case"XAxis":i="x";break;case"YAxis":i="z",s=-s;break;case"ZAxis":i="y"}const r=this._opt.viewer;r.getViewer().editorManager.getToolByName("clipByBox").rotateSectionBox(i,s),r.render()},setBoxByVectors(e,t,i,s){o.send(n,"setBoxByVectors"),this.reset();let r=e=>void 0!==e.x&&void 0!==e.y&&void 0!==e.z;if(!(r(e)&&r(t)&&r(i)&&r(s)))return void console.warn("the object input is invalid.");const a=new THREE.Vector3(t.x,t.y,0),l=new THREE.Vector3(i.x,i.y,0),h=new THREE.Vector3(0,0,s.z),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 m=THREE.Math.radToDeg(Math.acos(a.clone().normalize().dot(new THREE.Vector3(1,0,0))));this.rotateByAxis("ZAxis",m)},enableHatch(e){this._opt.viewer._sectionPlane||f.GlobalData.ClippingCapsType!=e&&f.GlobalData.ClippingCapsType!=f.EnumClippingCapsTypes.ClipPlane&&(f.GlobalData.ClippingCapsType=e?f.EnumClippingCapsTypes.ClipBox:f.EnumClippingCapsTypes.None,this._sectionBox&&this._sectionBox.visibleCapsWireframe(e),e&&this._sectionBox&&this._sectionBox.getEditor().clipPlanes.reCalculateClippingIds(),this._opt.viewer.render())},isHatchEnabled:()=>f.GlobalData.ClippingCapsType==f.EnumClippingCapsTypes.ClipBox,enableSnap(e){f.GlobalData.SnapClippingLine=!!e},enableOutline(e){f.GlobalData.CalculateClippingLine!==e&&(f.GlobalData.CalculateClippingLine=!!e,this._sectionBox.reCalculateClippingIds())}},s.SectionBox=r}(),function(){let t=Object.freeze({Forward:"Forward",Reverse:"Reverse"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlaneDirection=t}(),function(){let t=Object.freeze({X:"X",Y:"Y",Z:"Z"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlanePlane=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlaneConfig=function(){return{viewer:null,progress:50,plane:e.Bimface.Plugins.Section.SectionPlanePlane.X,direction:e.Bimface.Plugins.Section.SectionPlaneDirection.Forward,isHatchEnabled:!0,hatchByMaterial:!1,enableSnap:!0,isOutlineEnabled:!0,filter:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CoordinateDrawer=class{constructor(e,t){this.coordinateSystem=e,this.viewer=t,this.container=this.viewer.domElement,this.mapDrawables={},this.initialize()}initialize(){this.xmlns="http://www.w3.org/2000/svg";var e=i.create("div","bf-coordinate-drawer");e.style.left="0px",e.style.top="0px",e.style.width=this.container.offsetWidth+"px",e.style.height=this.container.offsetHeight+"px",e.style.position="absolute",e.style.zIndex=5,this.group=document.createElementNS(this.xmlns,"svg"),this.group.setAttribute("width",this.container.offsetWidth+""),this.group.setAttribute("height",this.container.offsetHeight+""),e.appendChild(this.group),this.container.appendChild(e)}makeCircle(e,t){var i=this.mapDrawables;null==i[e]&&(i[e]=document.createElementNS(this.xmlns,"circle"),this.group.appendChild(i[e]));var n=i[e];n.style.fill=t.color||"#FF0000",n.setAttribute("r",t.radius+""),n.setAttribute("transform","translate("+t.center.x+","+t.center.y+")")}show(e,t){var i=this.getDrawable(e);i&&(i.style.display=t?"block":"none")}fill(e,t){this.getDrawable(e).style.fill=t?"block":"none"}makeLine(e,t){var i=this.mapDrawables;null==i[e]&&(i[e]=document.createElementNS(this.xmlns,"line"),this.group.appendChild(i[e]));var n=i[e];n.setAttribute("stroke",t.color||"#000000"),n.setAttribute("stroke-width",t.width||3),n.setAttribute("x1",t.start.x+""),n.setAttribute("y1",t.start.y+""),n.setAttribute("x2",t.end.x+""),n.setAttribute("y2",t.end.y+"")}makeDashLine(e,t){this.makeLine(e,t),this.mapDrawables[e].setAttribute("stroke-dasharray",t.dashArray)}makePolyline(e,t){var i=null,n=this.mapDrawables;null==n[e]&&(n[e]=document.createElementNS(this.xmlns,"polyline"),this.group.appendChild(n[e])),(i=n[e]).setAttribute("stroke",t.color||"#A9A9A9"),i.setAttribute("stroke-width",t.width||3),i.style.fill="none",i.setAttribute("points",t.points)}makeDefs(e){var t=this.mapDrawables;null==t[e]&&(t[e]=document.createElementNS(this.xmlns,"defs"),null==t.marker&&(t.marker=this.makeMarker(),t[e].appendChild(t.marker)),this.group.appendChild(t[e]))}makeMarker(){var e=document.createElementNS(this.xmlns,"marker");e.setAttribute("id","arrow"),e.setAttribute("viewBox","0 0 10 10"),e.setAttribute("refX","5"),e.setAttribute("refY","5"),e.setAttribute("markerWidth","6"),e.setAttribute("markerHeight","6"),e.setAttribute("orient","auto-start-reverse");var t=document.createElementNS(this.xmlns,"path");return t.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),t.style.fill="#11DAB7",this.mapDrawables.arrow=t,e.appendChild(t),e}getDrawable(e){return this.mapDrawables[e]}attach(){this.getDrawable("axisZ").setAttribute("marker-end","url(#arrow)")}setColor(e,t){this.getDrawable(e).setAttribute("stroke",t)}fill(e,t){this.getDrawable(e).style.fill=t}hideAll(e){let t=1==e?"none":"block";this.group.parentNode.style.display=t}destroy(){for(var e=this.group.children,t=0;t3||"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(),f.GlobalData.ClippingCaps=!1,e.viewer.modelManager.dispatchEvent({type:f.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0});var n=e.fillClipPlane.normalIndex,o=e.viewportOffset,s=new THREE.Vector2(i.clientX-o.left,i.clientY-o.top),r=e.calcRotateAngleIndex(s,e.coordinateSystem.discretePointsY);1==e.firstClickDown&&(e.lastIndex=r);var a=2*(r-e.lastIndex);n>3&&(a=-a,"Reverse"==e.coordinateSystem.planeDirection&&(a=-a)),e.drawingImpl.show("tipArcX",!1),e.coordinateSystem.updateAxisZ();var l=e.fillClipPlane.renderClipPlane.normal.clone(),h=e.coordinateSystem.getCoordinateAxis(),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\n #include \n\n gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n #include \n #include \n #include \n\n }\n ",clipping:!1});return Object.defineProperties(t,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}}}),t.setValues(e),t}}t.CoordinateControl=class{constructor(t){this.object3D=new THREE.Object3D,this.name="SectionPlaneControl",this._config=t,this.viewer=t.viewer,this.system=t.system,this.cameraControl=this.viewer.getViewer().cameraControl,this.fillClipPlane=f.FillClipPlaneManager.getInstance(this.viewer.getViewer().getScene()),this.eventManager=this.system.viewer.getEventManager(),this.sectionPlaneEvent=e.Bimface.Plugins.Section.SectionPlaneEvent,this.viewportOffset=this.viewer.getViewer().domElement.getBoundingClientRect(),this.defaultDistance=1500,this.firstClickDown=!0,this.arrowMouseDown=!1,this.circleXMouseDown=!1,this.circleYMouseDown=!1,this.centerPosition=null,this.projectCenterPosition=new THREE.Vector3,this.planeMouseDown=!1,this.translateStartPt=new THREE.Vector2,this.object3D.visible=!1,this._destroyed=!1,this.raycaster=new THREE.Raycaster;let i=this;this.domElementEvents=[{element:this.viewer.getViewer().domElement,type:"mousemove",event:e=>{if(this.arrowMouseDown){if(i.fillClipPlane.clearCapsWireframe(),f.GlobalData.ClippingCaps=!1,this.viewer.getViewer().modelManager.dispatchEvent({type:f.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0}),!(e.clientX==i.translateStartPt.x&&e.clientY==i.translateStartPt.y)){var t=i.fillClipPlane.renderClipPlane,n=t.normal.clone();n.w=t.constant;var o=i.cameraControl.movePlane(n,e,i.translateStartPt,!1,i.fillClipPlane.state.position.clone());null!=o&&i.fillClipPlane.offset(o),i.translateStartPt.set(e.clientX,e.clientY),i.cameraControl.setCameraChanging(!0),i.cameraControl.update(!0)}this.centerPosition&&(this.centerPosition=this.fillClipPlane.state.position.clone().add(this.dirCenter.clone().multiplyScalar(this.lengthCenter||0)),this.fillClipPlane.updateBasePoint(this.centerPosition),this.fillClipPlane.update());let s=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;return this.object3D.position.set(s.x,s.y,s.z),i.update(),i.fireSectionPlaneChangedEvent(),e.preventDefault(),void e.stopPropagation()}if(this.circleYMouseDown){i.fillClipPlane.clearCapsWireframe(),f.GlobalData.ClippingCaps=!1;let t=this.system.getCoordinateAxisForPoint(this.centerPosition);var s=i.fillClipPlane.normalIndex;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},this.intersectPlane);this.oldDir||(this.oldDir=n.clone().sub(t.start.clone()).normalize());let o=n.clone().sub(t.start.clone()).normalize();const r=this.oldDir.clone().cross(o);let a=o.angleTo(this.oldDir);r.angleTo(this.intersectPlane.normal)0){const e=h[0].point;i.centerPosition=e,i.fillClipPlane.updateBasePoint(i.centerPosition)}let t=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;return this.object3D.position.set(t.x,t.y,t.z),i.update(),i.viewer.render(),e.preventDefault(),void e.stopPropagation()}a=new THREE.Vector2(e.clientX,e.clientY);let c=(l=this.viewer.getViewer().cameraControl.getRaycaster(a.x,a.y)).ray.origin.clone(),d=l.ray.direction.clone();this.raycaster.set(c,d),this.hitTest(this.raycaster)}},{element:this.viewer.getViewer().domElement,type:"mousedown",event:e=>{if(this.picked){if(this.centerPosition||(this.centerPosition=this.system.getCoordinateAxisForPoint().start),this.fillClipPlane.setBasePoint(this.centerPosition),"arrowRigidBody"==this.picked.name)this.arrowMouseDown=!0,i.translateStartPt.set(e.clientX,e.clientY),this.centerPosition&&(this.dirCenter=this.centerPosition.clone().sub(this.fillClipPlane.state.position.clone()).normalize(),this.lengthCenter=this.centerPosition.clone().sub(this.fillClipPlane.state.position.clone()).length());else if("circleEdgeRigidBodyX"==this.picked.name){this.circleXMouseDown=!0;var t=this.system.getCoordinateAxisForPoint(this.centerPosition);this.mouseDownQuaternion=this.object3D.quaternion.clone();let i=new THREE.Plane;i.setFromCoplanarPoints(t.start,t.endZ,t.endX),this.intersectPlane=i;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},i);this.oldDir=n.clone().sub(t.start.clone()).normalize()}else if("circleEdgeRigidBodyY"==this.picked.name){this.circleYMouseDown=!0;t=this.system.getCoordinateAxisForPoint(this.centerPosition);this.mouseDownQuaternion=this.object3D.quaternion.clone();let i=new THREE.Plane;i.setFromCoplanarPoints(t.start,t.endZ,t.endY),this.intersectPlane=i;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},i);this.oldDir=n.clone().sub(t.start.clone()).normalize()}else if("plane"==this.picked.name){this.planeMouseDown=!0;t=this.system.getCoordinateAxisForPoint(this.centerPosition);let i=this.viewer.worldToClient(this.viewer.sceneToWorld(t.start));this.offsetCenterPoint={x:e.clientX-i.x,y:e.clientY-i.y}}e.preventDefault(),e.stopPropagation()}}},{element:this.viewer.getViewer().domElement,type:"mouseup",event:e=>{if(i.update(),this.arrowMouseDown||this.circleXMouseDown||this.circleYMouseDown){f.GlobalData.ClippingCaps=!0,i.fillClipPlane.calculateClippingIds(),this.viewer.getViewer().modelManager.dispatchEvent({type:f.EVENTS.ON_CLIP_MOUSE_MOVE_END,onClipPlane:!0})}this.arrowMouseDown=!1,this.circleXMouseDown=!1,this.circleYMouseDown=!1,this.planeMouseDown=!1,this.firstClickDown=!0,this.oldDir=null,i.viewer.render()}}],this.addDomElementEvents()}addDomElementEvents(){this.domElementEvents.forEach((({element:e,type:t,useCapture:i,event:n})=>{e.addEventListener(t,n,i)}))}getIntersectPosition(e,t){const i=this.viewer.getViewer().cameraControl.getRaycaster(e.x,e.y).ray.direction.clone().normalize(),n=this.viewer.getViewer().camera.position.clone(),o=new THREE.Ray(n,i),s=new THREE.Vector3;return o.intersectPlane(t,s),s}hitTest(e){if(this.picked=null,this.object3D.visible){if(this.object3D.children.some((t=>{const i=[];return t.canRaycast&&t.raycast(e,i),i.length>0&&(this.picked=t),i.length>0})),this.arrowHover=!1,this.planeHover=!1,this.circleEdgeXHover=!1,this.circleEdgeYHover=!1,this.picked)switch(this.lastPickedName&&this.lastPickedName==this.picked.name||this.highlightActionList.forEach((e=>e.stop())),this.lastPickedName=this.picked.name,this.picked.name){case"plane":this.planeHover=!0,this.handlePlaneHoverEvent();break;case"arrowRigidBody":this.arrowHover=!0,this.handleArrowHoverEvent();break;case"circleEdgeRigidBodyX":this.circleEdgeXHover=!0,this.handleCircleEdgeXHoverEvent();break;case"circleEdgeRigidBodyY":this.circleEdgeYHover=!0,this.handleCircleEdgeYHoverEvent()}else this.lastPickedName=null,this.handleNormaleEvent();this.viewer.render()}}handlePlaneHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeXGray,this.actionCircleEdgeYGray,this.actionPlaneHightlight])}handlePlaneMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!0,this.axisDashedY.visible=!0,this.axisDashedZ.visible=!0,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!0,this.circleEdgeGrayY.visible=!0,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!0,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!0,this.object3D.updateMatrixWorld()}handleArrowHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZHightlight,this.actionSphereZHightlight,this.actionArrowHightlight,this.actionCircleEdgeXGray,this.actionCircleEdgeYGray,this.actionPlaneGray])}handleArrowMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!0,this.axisDashedY.visible=!0,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!0,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!0,this.arrowGray.visible=!1,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleCircleEdgeXHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!0,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeYGray,this.actionPlaneGray,this.actionCircleEdgeHoverX])}handleCircleEdgeXMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!0,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!1,this.sphereY.visible=!1,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!0,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleCircleEdgeYHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!0,this.plane.visible=!1,this.planeGray.visible=!0,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeXGray,this.actionPlaneGray,this.actionCircleEdgeHoverY])}handleCircleEdgeYMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!0,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!0,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!1,this.sphereY.visible=!1,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!0,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleNormaleEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!0,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.cancelHighlight()}highlightHandle(e){this.highlightActionList=[],this.animationList=[],e.map((e=>{this.highlightActionList.push(e.action),this.addAnimation(e)})),this.setHighlight()}getLinearColor(e){const t=new THREE.Color(e),i=e=>{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}createLine(e,t,n={}){const o=new THREE.LineGeometry;let s;o.setPositions(t),n.isDashed?(s=new THREE.LineMaterial({color:this.getLinearColor(n.color||i),linewidth:n.linewidth||2,dashed:!0,dashSize:1,gapSize:1,dashScale:.1,depthTest:!1}),s.defines.USE_DASH=""):s=new THREE.LineMaterial({color:this.getLinearColor(n.color||i),linewidth:n.linewidth||2,dashed:!1,depthTest:!1}),s.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const r=new THREE.Line2(o,s);return r.computeLineDistances(),r.renderOrder=f.EnumRenderOrder.Effect+1e3,r.name=e,r}createArrow(e,t,i,n){const o=new THREE.BufferGeometry,s=new Float32Array([-7,0,0,7,0,0,0,0,14]);o.setAttribute("position",new THREE.BufferAttribute(s,3));const r=new l({depthTest:!1,color:this.getLinearColor(n)}),a=new THREE.Mesh(o,r),h=new THREE.Vector3(...Object.values(i)).normalize(),c=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),h);a.applyQuaternion(c);const d=new THREE.Vector3(...Object.values(t));return a.position.set(d.x,d.y,d.z),a.name=e,a.renderOrder=f.EnumRenderOrder.Effect+1e3,a.updateMatrixWorld(!0),a}createArrowRigidBody(e,t,i,n){const o=i.length(),s=new THREE.CylinderGeometry(5,5,o,3),r=f.MaterialUtil.createStandardMaterial(n);var a=new THREE.Mesh(s,r);a.name=e;const l=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),i.clone().normalize());return a.applyQuaternion(l),a.position.set(t.x,t.y,t.z),a.canRaycast=!0,a.updateMatrixWorld(),a.visible=!1,a}createCircleEdge(e,t,i,n,o,s,r){const a=new THREE.EllipseCurve(0,0,i,i,n,n+o,!1,0).getPoints(128),l=[];a.forEach((e=>l.push(e.x||0,e.y||0,e.z||0)));const h=new THREE.LineGeometry;h.setPositions(l);let c=new THREE.LineMaterial({linewidth:s.linewidth||2,dashed:!1,depthTest:!1,transparent:!0,color:this.getLinearColor(s.color)});c.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const d=new THREE.Line2(h,c);return d.name=e,d.position.set(t.x,t.y,t.z),r&&d.quaternion.set(r.x,r.y,r.z,r.w),d.renderOrder=f.EnumRenderOrder.Effect+100,d}createCircleEdgeRigidBody(e,t,n,o){const s=new THREE.TorusGeometry(n,3,5,16,Math.PI/2);let r=new THREE.MeshBasicMaterial({color:i});const a=new THREE.Mesh(s,r);return a.canRaycast=!0,a.name=e,a.position.set(t.x,t.y,t.z),o&&a.quaternion.set(o.x,o.y,o.z,o.w),a.visible=!1,a}createPlane(e,t,i,n){const o=new THREE.BufferGeometry,s=new Float32Array([-10,0,-10,10,0,-10,10,0,10,10,0,10,-10,0,10,-10,0,-10]);o.setAttribute("position",new THREE.BufferAttribute(s,3));const r=new l({depthTest:!1,side:2,transparent:!0,color:this.getLinearColor(n)}),a=new THREE.Mesh(o,r);i=new THREE.Vector3(...Object.values(i)).normalize();const h=new THREE.Vector3(...Object.values(t));a.position.set(h.x,h.y,h.z);let c=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),new THREE.Vector3(1,0,0));return a.quaternion.set(c.x,c.y,c.z,c.w),a.name=e,a.canRaycast=!0,a.renderOrder=f.EnumRenderOrder.Effect+1e3,a.updateMatrixWorld(!0),a}createSphere(e,t,n={}){var o=new THREE.SphereGeometry(6,200,200);const s=new l({depthTest:!1,transparent:!0,color:this.getLinearColor(n.color||i)});var r=new THREE.Mesh(o,s);return r.name=e,r.renderOrder=f.EnumRenderOrder.Effect+100,r.position.set(t.x,t.y,t.z),r}createBasicMaterial(e,t){let i=new THREE.Color(t);return new THREE.ShaderMaterial({fragmentShader:`void main() {\n\tgl_FragColor = vec4( ${i.r}, ${i.g}, ${i.b}, 1 );\n}`,...e})}getPointFormDir(e,t){var i=this.system.config.styles;return e.clone().add(t.clone().multiplyScalar(i.axisXLength))}changeVisible(e){this.object3D.visible=e,this.object3D.updateMatrixWorld()}resetCenterPosition(){this.centerPosition=null,this.fillClipPlane.updateBasePoint(this.fillClipPlane.state.position),this.update()}centerPositionProjectionToClipPlane(){if(this.centerPosition){var e=this.system.getCoordinateAxisForPoint();let t=new THREE.Plane;t.setFromCoplanarPoints(e.start,e.endY,e.endX),t.projectPoint(this.centerPosition,this.projectCenterPosition),this.centerPosition.copy(this.projectCenterPosition),this.update()}}getCoordinateAxis(){var e=new THREE.Vector3(1,0,0),t=new THREE.Vector3(0,1,0),i=new THREE.Vector3(0,0,1),n=this.system.config.styles,o=new THREE.Vector3(0,0,0),s=o.clone().add(i.clone().multiplyScalar(n.axisXLength)),r=o.clone().add(t.clone().multiplyScalar(n.axisYLength)),a=o.clone().add(e.clone().multiplyScalar(n.axisZLength)),l=o.clone().add(e.clone().multiplyScalar(n.axisXLength)),h=o.clone().add(i.clone().multiplyScalar(n.axisXLength/5)),c=o.clone().add(t.clone().multiplyScalar(n.axisYLength/5));return{start:o,endX:s,endY:r,endZ:a,endZPoint:l,endPlaneX:h,endPlaneY:c}}init(){this.addItems(),this.update(),this.animationTimeScale=4,this.highlightActionList=[],this.animationList=[],this.clock=new THREE.Clock;const e=()=>{if(this._destroyed)return;const t=this.clock.getDelta();let i=!1;this.animationList.forEach((({mixer:e,action:n,object:o})=>{n.isRunning()&&(i=!0,e.update(t),o.updateMatrixWorld(!0))})),i&&this.viewer.getViewer().render(),requestAnimationFrame(e)};e(),this.initHighlightAnimation()}setCenterPosition(e){this.centerPosition=e,this.update()}update(){let e=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;this.object3D.position.set(e.x,e.y,e.z);var t=this.system.cameraControl.camera,i=this.centerPosition||this.fillClipPlane.state.position,o=t.position.clone().sub(i.clone()).length();this.viewer.getViewer().camera.isPerspective||(o=1/(this.viewer.getViewer().camera.zoom/this.viewer.getViewer().camera.position.clone().sub(this.viewer.getViewer().camera.target.clone()).length()));var s=o/this.defaultDistance;this.object3D.scale.set(s,s,s);let r,a=this.fillClipPlane.state.quaternion;if(0===this.fillClipPlane.normalIndex?r=null:1===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(-1,0,0)):2===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,-1)):3===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,1)):4===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(-1,0,0)).multiply((new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0))):5===this.fillClipPlane.normalIndex&&(r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(0,-1,0)).multiply((new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,1)))),r&&(a=a.clone().multiply(r)),this.object3D.quaternion.set(a.x,a.y,a.z,a.w),this.planeHover&&this.handlePlaneHoverEvent(),this.planeMouseDown&&this.handlePlaneMoveEvent(),this.arrowHover&&this.handleArrowHoverEvent(),this.arrowMouseDown&&this.handleArrowMoveEvent(),this.circleEdgeXHover&&this.handleCircleEdgeXHoverEvent(),this.circleXMouseDown&&this.handleCircleEdgeXMoveEvent(),this.circleEdgeYHover&&this.handleCircleEdgeYHoverEvent(),this.circleYMouseDown&&this.handleCircleEdgeYMoveEvent(),this.axisStartDir&&this.object3D.remove(this.axisStartDir),this.circleXMouseDown||this.circleYMouseDown){let e=new THREE.Vector3(0,0,0),t=this.getPointFormDir(e,new THREE.Vector3(1,0,0));this.axisStartDir=this.createLine("axisStartDir",[...Object.values(e),...Object.values(t)],{linewidth:1,color:n});let i=this.object3D.quaternion.clone().invert();i=i.clone().multiply(this.mouseDownQuaternion.clone()),this.axisStartDir.quaternion.multiply(i),this.object3D.add(this.axisStartDir)}this.updateArrowDirection(this.arrow),this.updateArrowDirection(this.arrowHighlight),this.updateArrowDirection(this.arrowGray),this.object3D.updateMatrixWorld()}updateArrowDirection(e){const t=this.object3D.quaternion.clone().invert();let i=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(1,0,0));const n=new THREE.Vector3(0,1,0).applyQuaternion(i),o=new THREE.Plane(new THREE.Vector3(...Object.values(new THREE.Vector3(1,0,0))).normalize()),s=new THREE.Vector3;let r=this.viewer.getViewer().camera.target.clone().sub(this.viewer.getViewer().camera.position).normalize();o.projectPoint(r.clone().applyQuaternion(t),s);const a=(new THREE.Quaternion).setFromUnitVectors(n,s.normalize()).multiply(i.clone());e.quaternion.set(a.x,a.y,a.z,a.w),e.updateMatrixWorld(!0)}addItems(){var e=this.getCoordinateAxis();this.axisX&&this.object3D.remove(this.axisX),this.axisY&&this.object3D.remove(this.axisY),this.axisZ&&this.object3D.remove(this.axisZ),this.axisX=this.createLine("axisX",[...Object.values(e.start),...Object.values(e.endX)]),this.axisY=this.createLine("axisY",[...Object.values(e.start),...Object.values(e.endY)]),this.axisZ=this.createLine("axisZ",[...Object.values(e.start),...Object.values(e.endZ)],{color:o}),this.object3D.add(this.axisX),this.object3D.add(this.axisY),this.object3D.add(this.axisZ),this.axisDashedX&&this.object3D.remove(this.axisDashedX),this.axisDashedX=this.createLine("axisDashedX",[...Object.values(e.start),...Object.values(e.endX)],{isDashed:!0}),this.object3D.add(this.axisDashedX),this.axisDashedX.visible=!1,this.axisDashedY&&this.object3D.remove(this.axisDashedY),this.axisDashedY=this.createLine("axisDashedX",[...Object.values(e.start),...Object.values(e.endY)],{isDashed:!0}),this.object3D.add(this.axisDashedY),this.axisDashedY.visible=!1,this.axisDashedZ&&this.object3D.remove(this.axisDashedZ),this.axisDashedZ=this.createLine("axisDashedZ",[...Object.values(e.start),...Object.values(e.endZPoint)],{isDashed:!0}),this.object3D.add(this.axisDashedZ),this.axisDashedZ.visible=!1,this.axisZArrow&&this.object3D.remove(this.axisZArrow),this.axisZArrow=this.createLine("axisZArrow",[...Object.values(e.endZPoint),...Object.values(e.endZ)]),this.object3D.add(this.axisZArrow),this.axisZArrow.visible=!1,this.axisHighlightZ&&this.object3D.remove(this.axisHighlightZ),this.axisHighlightZ=this.createLine("axisHighlightZ",[...Object.values(e.start),...Object.values(e.endZ)],{color:n}),this.object3D.add(this.axisHighlightZ),this.axisHighlightZ.visible=!1,this.axisHighlightZPoint&&this.object3D.remove(this.axisHighlightZPoint),this.axisHighlightZPoint=this.createLine("axisHighlightZPoint",[...Object.values(e.start),...Object.values(e.endZPoint)],{color:n}),this.object3D.add(this.axisHighlightZPoint),this.axisHighlightZPoint.visible=!1,this.axisGrayZ&&this.object3D.remove(this.axisGrayZ),this.axisGrayZ=this.createLine("axisGrayZ",[...Object.values(e.start),...Object.values(e.endZ)]),this.object3D.add(this.axisGrayZ),this.axisGrayZ.visible=!1,this.arrow&&this.object3D.remove(this.arrow),this.arrow=this.createArrow("arrow",e.endZ,e.endZ.clone().sub(e.start),o),this.object3D.add(this.arrow),this.arrowHighlight&&this.object3D.remove(this.arrowHighlight),this.arrowHighlight=this.createArrow("arrowHighlight",e.endZ,e.endZ.clone().sub(e.start),n),this.object3D.add(this.arrowHighlight),this.arrowHighlight.visible=!1,this.arrowGray&&this.object3D.remove(this.arrowGray),this.arrowGray=this.createArrow("arrowGray",e.endZ,e.endZ.clone().sub(e.start),i),this.object3D.add(this.arrowGray),this.arrowGray.visible=!1;let t=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1)),l=e.start.clone().sub(e.endX.clone()).length();this.circleEdgeX&&this.object3D.remove(this.circleEdgeX),this.circleEdgeX=this.createCircleEdge("circleEdgeX",e.start,l,.015*Math.PI,.47*Math.PI,{color:r},t),this.object3D.add(this.circleEdgeX),this.circleEdgeY&&this.object3D.remove(this.circleEdgeY),this.circleEdgeY=this.createCircleEdge("circleEdgeY",e.start,l,.015*Math.PI,.47*Math.PI,{color:a}),this.object3D.add(this.circleEdgeY),this.circleEdgeGrayX&&this.object3D.remove(this.circleEdgeGrayX),this.circleEdgeGrayX=this.createCircleEdge("circleEdgeGrayX",e.start,l,.015*Math.PI,.47*Math.PI,{color:i},t),this.object3D.add(this.circleEdgeGrayX),this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY&&this.object3D.remove(this.circleEdgeGrayY),this.circleEdgeGrayY=this.createCircleEdge("circleEdgeGrayY",e.start,l,.015*Math.PI,.47*Math.PI,{color:i}),this.object3D.add(this.circleEdgeGrayY),this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX&&this.object3D.remove(this.circleEdgeHoverX),this.circleEdgeHoverX=this.createCircleEdge("circleEdgeHoverX",e.start,l,0,2*Math.PI,{color:n,linewidth:1},t),this.object3D.add(this.circleEdgeHoverX),this.circleEdgeHoverX.material.opacity=0,this.circleEdgeHoverY&&this.object3D.remove(this.circleEdgeHoverY),this.circleEdgeHoverY=this.createCircleEdge("circleEdgeHoverY",e.start,l,0,2*Math.PI,{color:n,linewidth:1}),this.object3D.add(this.circleEdgeHoverY),this.circleEdgeHoverY.material.opacity=0,this.circleEdgeRigidBodyX&&this.object3D.remove(this.circleEdgeRigidBodyX),this.circleEdgeRigidBodyX=this.createCircleEdgeRigidBody("circleEdgeRigidBodyX",e.start,l,t),this.object3D.add(this.circleEdgeRigidBodyX),this.circleEdgeRigidBodyY&&this.object3D.remove(this.circleEdgeRigidBodyY),this.circleEdgeRigidBodyY=this.createCircleEdgeRigidBody("circleEdgeRigidBodyY",e.start,l),this.object3D.add(this.circleEdgeRigidBodyY),this.plane&&this.object3D.remove(this.plane);let h=e.endPlaneX.clone().sub(e.start.clone()),c=e.endPlaneY.clone().sub(e.start.clone()),d=h.clone().add(c);this.plane=this.createPlane("plane",e.start.clone().add(d),e.start.clone().sub(e.endZ.clone()).normalize(),s),this.object3D.add(this.plane),this.planeGray&&this.object3D.remove(this.planeGray),this.planeGray=this.createPlane("planeGray",e.start.clone().add(d),e.start.clone().sub(e.endZ.clone()).normalize(),i),this.object3D.add(this.planeGray),this.planeGray.visible=!1,this.planeHighlight&&this.object3D.remove(this.planeHighlight),this.planeHighlight=this.createPlane("planeHighlight",e.start.clone().add(d),e.start.clone().sub(e.endZ.clone()).normalize(),n),this.object3D.add(this.planeHighlight),this.planeHighlight.visible=!1,this.sphereX&&this.object3D.remove(this.sphereX),this.sphereX=this.createSphere("sphereX",e.endX),this.object3D.add(this.sphereX),this.sphereY&&this.object3D.remove(this.sphereY),this.sphereY=this.createSphere("sphereY",e.endY),this.object3D.add(this.sphereY),this.sphereZ&&this.object3D.remove(this.sphereZ),this.sphereZ=this.createSphere("sphereZ",e.endZPoint,{color:o}),this.object3D.add(this.sphereZ),this.sphereHighlightZ&&this.object3D.remove(this.sphereHighlightZ),this.sphereHighlightZ=this.createSphere("sphereHighlightZ",e.endZPoint,{color:n}),this.object3D.add(this.sphereHighlightZ),this.sphereHighlightZ.visible=!1,this.sphereGrayZ&&this.object3D.remove(this.sphereGrayZ),this.sphereGrayZ=this.createSphere("sphereGrayZ",e.endZPoint,{color:i}),this.object3D.add(this.sphereGrayZ),this.sphereGrayZ.visible=!1,this.arrowRigidBody&&this.object3D.remove(this.arrowRigidBody);let u=new THREE.Vector3((e.start.x+e.endZ.x)/2,(e.start.y+e.endZ.y)/2,(e.start.z+e.endZ.z)/2);this.arrowRigidBody=this.createArrowRigidBody("arrowRigidBody",u,e.endZ.clone().sub(e.start),{color:o}),this.object3D.add(this.arrowRigidBody),this.object3D.updateMatrixWorld()}setHighlight(){this.highlightActionList.forEach((e=>{e.timeScale=this.animationTimeScale,e.paused=!1,e.play()}))}cancelHighlight(){this.highlightActionList.forEach((e=>{e.timeScale=-this.animationTimeScale,e.paused=!1,e.play()}))}initHighlightAnimation(){this.actionAxisZGray=this.getActionHightlight(this.axisZ,this.axisZ.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionSphereZGray=this.getActionHightlight(this.sphereZ,this.sphereZ.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionArrowGray=this.getActionHightlight(this.arrow,this.arrow.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionAxisZHightlight=this.getActionHightlight(this.axisZ,this.axisZ.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionSphereZHightlight=this.getActionHightlight(this.sphereZ,this.sphereZ.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionArrowHightlight=this.getActionHightlight(this.arrow,this.arrow.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionCircleEdgeXGray=this.getActionHightlight(this.circleEdgeX,this.circleEdgeX.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionCircleEdgeYGray=this.getActionHightlight(this.circleEdgeY,this.circleEdgeY.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionPlaneGray=this.getActionHightlight(this.plane,this.plane.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionPlaneHightlight=this.getActionHightlight(this.plane,this.plane.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionCircleEdgeHoverX=this.getActionHightlight(this.circleEdgeHoverX,[0],[1],"opacity"),this.actionCircleEdgeHoverY=this.getActionHightlight(this.circleEdgeHoverY,[0],[1],"opacity")}getActionHightlight(e,t,i,n){const o=new THREE.ColorKeyframeTrack(".material.color",[0,1],[...t,...i]),s=new THREE.NumberKeyframeTrack(".material.opacity",[0,1],[...t,...i]),r=new THREE.AnimationClip("Action",1,["opacity"==n?s:o]);let a=new THREE.AnimationMixer(e),l=a.clipAction(r);return l.setLoop(THREE.LoopOnce),l.timeScale=this.animationTimeScale,l.clampWhenFinished=!0,{mixer:a,action:l,object:e}}addAnimation({mixer:e,action:t,object:i}){this.animationList.push({mixer:e,action:t,object:i})}fireSectionPlaneChangedEvent(){const e=this.system.viewer._sectionPlane;this.eventManager.fireEvent(this.sectionPlaneEvent.SectionPlaneChanged,e.getSectionPlane())}destroy(){this.object3D.clear(),this._destroyed=!0,this.centerPosition=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CoordinateSystem=class{constructor(t){this.viewer=t;let i=this.viewer.getViewer();this.cameraControl=i.cameraControl,this.fillClipPlane=f.FillClipPlaneManager.getInstance(i.getScene()),this.container=i.domElement,this.config=new e.Bimface.Plugins.Section.CoordinateSystemConfig,this.updateBinded=this.update.bind(this),this.initialize(),this.coordinateControl=new e.Bimface.Plugins.Section.CoordinateControl({viewer:t,system:this}),i.getInteractionScene().add(this.coordinateControl.object3D)}initialize(){this.enable=!0,this.boundingBox=new THREE.Box2}setDirection(e){this.planeDirection=e}saveTransform(e){this.savedCamera=e.clone()}getCoordinateAxisForPoint(e){var t=this.fillClipPlane.renderClipPlane.normal.clone(),i=this.fillClipPlane.getCoordinate(),n=i.axisY.clone(),o=t.clone().cross(n.clone());this.fillClipPlane.normalIndex>3&&(n=(o=i.axisX.clone()).clone().cross(t.clone()));var s=this.cameraControl.camera;this.defaultDistance=1500;var r=this.config.styles,a=e||this.fillClipPlane.state.position.clone(),l=s.position.clone().sub(a.clone()).length(),h=a.clone().add(o.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength)),c=a.clone().add(n.clone().multiplyScalar(l/this.defaultDistance*r.axisYLength)),d=a.clone().add(t.clone().multiplyScalar(l/this.defaultDistance*r.axisZLength)),u=a.clone().add(t.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength)),g=a.clone().add(o.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength/5)),p=a.clone().add(n.clone().multiplyScalar(l/this.defaultDistance*r.axisYLength/5));return this.dirX=o,this.dirY=n,{start:a,endX:h,endY:c,endZ:d,endZPoint:u,endPlaneX:g,endPlaneY:p}}update(e){1!=e&&1==this.bIsCoordinateHided||(this.coordinateControl.update(),this.updateBbox())}hide(e){this.bIsCoordinateHided=e,this.coordinateControl.changeVisible(!e)}destroy(){this.coordinateControl.destroy()}updateBbox(){let e=this.getCoordinateAxisForPoint(this.coordinateControl.centerPosition),t=this.viewer.worldToClient(this.viewer.sceneToWorld(e.start.clone())),i=[this.viewer.worldToClient(this.viewer.sceneToWorld(e.endX.clone())),this.viewer.worldToClient(this.viewer.sceneToWorld(e.endY.clone())),this.viewer.worldToClient(this.viewer.sceneToWorld(e.endZ.clone()))],n=t.x,o=t.y,s=t.x,r=t.y;for(let e=0;es&&(s=i[e].x),i[e].yr&&(r=i[e].y);this.boundingBox=new THREE.Box2,this.boundingBox.min=new THREE.Vector2(n,o),this.boundingBox.max=new THREE.Vector2(s,r),this.boundingBox.expandByScalar(10)}insideBoundingBox(e){return this.boundingBox.containsPoint(e.clone())}backwardCoordinate(){var e=this.cameraControl.camera.position,t=this.cameraControl.camera.target.clone().sub(e.clone()).normalize(),i=this.fillClipPlane.renderClipPlane.normal.clone();t.angleTo(i);Math.PI}}}(),function(){var t="Bimface.Plugins.Section.SectionPlane",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");let o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");var s={Forward:0,Reverse:1},r={X:0,Y:2,Z:4},a=function(t){var i=this,n=t.viewer;if(n)if("Viewer3D"===n.viewerType||n instanceof e.Bimface.Viewer.ViewerGIS){if(S(this),n._sectionBox&&(n._sectionBox.hideBox(),!1!==t.exitSectionBox&&n._sectionBox.exit()),t.hatchByMaterial&&n.getViewer().getClipCapsManager().enableHatchByMaterial(t.hatchByMaterial,!1),f.GlobalData.CalculateClippingLine=!!t.isOutlineEnabled,f.GlobalData.SnapClippingLine=!!t.enableSnap,n._sectionPlane)return n._sectionPlane.showPlane(),n._sectionPlane;n._sectionPlane=this,i.id=t.id,i._opt=t,i.mode=t.mode,i._plane=t.plane,i._direction=t.direction,i._progress=-1,this.onFloorExplosionBinded=this.onFloorExplosion.bind(this),this.onClipMouseHoverBinded=this.onClipMouseHover.bind(this),this.onClipMouseMoveBinded=this.onClipMouseMove.bind(this),this.onEditorEndBinded=this.onEditorEnd.bind(this),i.init(),i.setPlane(t.plane),this._boxSize=new THREE.Vector3,t.filter&&i.setFilter(t.filter),i.enableHatch(t.isHatchEnabled)}else console.log("viewer should be Viewer3D or ViewerGIS.");else console.log("domElement must not be empty.")};a.prototype={init:function(){i.send(t,"init"),this.enableCoordinate=!0;var n=this._opt.viewer,o=n.getViewer(),s=this;this.coordinateSystem=new e.Bimface.Plugins.Section.CoordinateSystem(n),this.coordinateSystem.setDirection(this._direction),f.GlobalData.ClippingCaps=!0,o.editorManager.enableTool(o,f.EditToolMode.CLIP_FILL),this._sectionTool=f.FillClipPlaneManager.getInstance(o.getScene()),this._sectionTool.observer=function(){var t=e.Bimface.Plugins.Section.SectionPlaneEvent;n.getEventManager().fireEvent(t.SectionPlaneUpdate,s)},this._sectionTool.enable(!0,!0),o.getModelManager().updatePickingMaterial(),this.hookEvens(),this.coordinateSystem.coordinateControl.init(),this.fireSectionPlaneVisibleChangedEvent(!0)},hookEvens:function(){var t=this.coordinateSystem,i=this._opt.viewer.getViewer(),n=o.throttle;i.registerEventListener(f.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),i.registerEventListener(f.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),i.registerEventListener(f.EVENTS.ON_EDITOR_ZOOM,n(t.updateBinded,50)),i.registerEventListener(f.EVENTS.ON_CAMERA_ANIMATION_UPDATE,n(t.updateBinded,50)),i.registerEventListener(f.EVENTS.ON_EDITOR_END,this.onEditorEndBinded),this._opt.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,this.onFloorExplosionBinded)},onFloorExplosion:function(){this.resetSectionTool(),this._opt.viewer.render()},onClipMouseHover:function(e){var t=this.coordinateSystem,i=this._opt.viewer.getDomElement();if(0!=this.enableCoordinate)if(t.update(!0),e.onClipPlane)t.hide(!1);else{i.style.cursor="";var n=new THREE.Vector2(e.event.offsetX,e.event.offsetY);t.insideBoundingBox(n)?t.hide(!1):t.hide(!0)}},onClipMouseMove:function(){this.coordinateSystem.update()},onEditorEnd:function(){this.coordinateSystem.update(!0)},fireSectionPlaneMobileChangedEvent:function(){this._opt.viewer.getEventManager().fireEvent("SectionPlaneMobileChanged",this.getSectionPlane())},fireSectionPlaneStateChangedEvent:function(){this._opt.viewer.getEventManager().fireEvent("SectionPlaneStateChanged",this.getSectionPlane())},fireSectionPlaneVisibleChangedEvent:function(e){requestAnimationFrame((()=>{this._opt.viewer.getEventManager().fireEvent("SectionPlaneVisibleChanged",e)}))},exit:function(){var t=this._opt.viewer.getViewer(),i=f.FillClipPlaneManager.getInstance(t.getScene());this.borderParamWidth&&this.borderParamHeight&&this.setBorder(this.borderParamWidth,this.borderParamHeight,!1),this.clearFilter(),t.getModelManager().updatePickingMaterial(),t.editorManager.disableTool(f.EditToolMode.CLIP_FILL),i.clearCapsWireframe(),f.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(f.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),t.unregisterEventListener(f.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),t.unregisterEventListener(f.EVENTS.ON_EDITOR_END,this.onEditorEndBinded),this._opt.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,this.onFloorExplosionBinded),f.GlobalData.SnapClippingLine=!1,f.GlobalData.CalculateClippingLine=!0,this.fireSectionPlaneVisibleChangedEvent(!1)},setProgress:function(e){if(i.send(t,"setProgress"),!1!==this._sectionTool.isEnabled()){var n=1-e/50;this._progress=e,this._sectionTool.setProcess(n),this.coordinateSystem.coordinateControl.update(),this._sectionTool.calculateClippingIds(),this.coordinateSystem.coordinateControl.centerPositionProjectionToClipPlane(),this.fireSectionPlaneStateChangedEvent()}},setOriginProgress:function(e){var t=e/100;this._progress=e,this._sectionTool.setProcess(t),this.coordinateSystem.coordinateControl.update(),this._sectionTool.calculateClippingIds(),this.coordinateSystem.coordinateControl.centerPositionProjectionToClipPlane()},getOriginProgress:function(){return 100*this._sectionTool.getProcess()},setDistanceProgress:function(e){if(!e.start||0==Math.abs(e.end.x-e.start.x)&&0==Math.abs(e.end.y-e.start.y))return;let t,i,n,o,s=1;n=this._sectionTool.renderClipPlane.normal.clone().normalize(),o=n.clone().negate();const r=this._opt.viewer;if(r.getCamera()._cloudCamera.position.clone().sub(r.getCamera()._cloudCamera.target.clone()).normalize().angleTo(n)<.2)return;const a=e=>{const t=r.getViewer().cameraControl.getRaycaster(e.x,e.y),i=t.ray.direction.clone().cross(t.ray.direction.clone().cross(n.clone())).normalize(),a=new THREE.Plane(i),l=-a.distanceToPoint(r.getCamera()._cloudCamera.position);a.set(i,l),s*=1;let h=new THREE.Vector3;if(new THREE.Ray(this._sectionTool.center,n).intersectPlane(a,h),0==h.x&&0==h.y&&0==h.z){let e=n.clone();n=o.clone(),o=e,s*=-1,new THREE.Ray(this._sectionTool.center,n).intersectPlane(a,h)}return h},l=r.getViewer().getBoundingBoxWorld(),h=r.getViewer().worldToDrawing(l.max),c=r.getViewer().worldToDrawing(l.min),d=a(e.start),u=a(e.end);t=h.clone().projectOnVector(n).distanceTo(c.clone().projectOnVector(n)),i=u.clone().projectOnVector(n).distanceTo(d.clone().projectOnVector(n));const g=e.progress/100*t,p=u.clone().sub(d.clone()).angleTo(n)<.001?1:-1;this._sectionTool.setProcess((g+s*p*i)/t),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneMobileChangedEvent()},getProgress:function(){return 50*(1-this._sectionTool.getProcess())},changeClipDirection(){let e=this.getSectionPlane();e.normal.x=-1*e.normal.x,e.normal.y=-1*e.normal.y,e.normal.z=-1*e.normal.z;let t=this.coordinateSystem.coordinateControl.centerPosition;this.setSectionPlane(e),t&&(this.coordinateSystem.coordinateControl.centerPosition=t),this.coordinateSystem.updateBinded()},setPlane:function(e){i.send(t,"setPlane");var n=s[this._direction]+r[e];if(this._plane=e,!1===this._sectionTool.isEnabled())return;this._sectionTool.changeNormal(n),this.setProgress(this._opt.progress),this.coordinateSystem.coordinateControl.resetCenterPosition();this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionPlaneStateChangedEvent()},getPlane:function(){return this._plane},setDirection:function(e){i.send(t,"setDirection");var n=s[e]+r[this._plane];this._direction=e,this._sectionTool.changeNormal(n),this.setProgress(this._opt.progress);this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionPlaneStateChangedEvent()},getDirection:function(){return this._direction},setRotateAngle:function(e,t){this._sectionTool.setRotateAngle(e,t)},getRotateAngle:function(){return this._sectionTool.getRotateAngle()},hidePlane:function(){i.send(t,"hidePlane"),this._sectionTool&&(this._sectionTool.visible=!1),this.enableCoordinate=!1,this.coordinateSystem.hide(!0);this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass()},showPlane:function(){if(i.send(t,"showPlane"),this._sectionTool&&!1===this._sectionTool.isEnabled())return;this._sectionTool&&(this._sectionTool.visible=!0),this.enableCoordinate=!0;this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass()},rotateByAxis:function(e,n,o=!0){if(i.send(t,"rotateByAxis"),"YAxis"===e||"ZAxis"===e){var a="",l=0,h=s[this.getDirection()]+r[this._plane];0==h||1==h?(l="YAxis"===e?-n:n,a="YAxis"===e?"y":"z"):2==h||3==h?(l="YAxis"===e?-n:n,a="YAxis"===e?"x":"z"):4!=h&&5!=h||(l="YAxis"===e?n:-n,a="YAxis"===e?"x":"y"),l="Reverse"===this._direction?n:l,this._sectionTool&&(this._sectionTool.rotateAngleOffset(l,a),o&&this._sectionTool.calculateClippingIds()),this.fireSectionPlaneStateChangedEvent()}else console.log("Rotate axis must be YAxis or ZAxis.")},reset:function(){i.send(t,"reset");var e=this;e.setPlane(e._opt.plane),e.setDirection(e._opt.direction),e.setProgress(e._opt.progress)},enable:function(e){i.send(t,"enable"),!e&&this._sectionTool.clearCapsWireframe(),this.borderParamWidth&&this.borderParamHeight&&this.setBorder(this.borderParamWidth,this.borderParamHeight,e),this._sectionTool.enable(e,e),e&&this._sectionTool.reCalculateClippingIds(),e?this.showPlane():this.hidePlane(),this._opt.viewer.render(),this.fireSectionPlaneVisibleChangedEvent(e)},getState:function(){return this._sectionTool.store()},isIncluded:function(e){var t=this._opt.viewer,i=t.getViewer().getScene(),n=f.FillClipPlaneManager.getInstance(i),o=n.renderClipPlane.normal.clone().normalize(),s=n.state.position,r=t.worldToScene(e),a=new THREE.Vector3;return a.subVectors(r,s).normalize(),o.angleTo(a)>Math.PI/2},setPositionByPlane:function(e,t,i){if(!1===this._sectionTool.isEnabled())return;var o=this._opt.viewer;e=o.worldToScene(e),t=o.getViewer().worldToDrawing(t),i=o.globalUnitUtil.translate(i);var s=new THREE.Vector3(e.x,e.y,e.z),r=new THREE.Vector3(t.x,t.y,t.z),a=s.clone().add(r.clone().multiplyScalar(i));this._opt.plane=n.SectionPlanePlane.X,this._opt.direction=n.SectionPlaneDirection.Forward,this.reset(),this._sectionTool.update();var l=new THREE.Vector3(1,0,0),h=new THREE.Vector3(0,1,0);let c=1,d=r.clone().projectOnPlane(h);if(d.length()>1e-6){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,!1)}let u=d.clone().angleTo(r.clone());if(c=r.y<0?1:-1,this.rotateByAxis("YAxis",u*THREE.Math.RAD2DEG*c,!1),"ViewerGIS"===o.viewerType)this._sectionTool.state.position.copy(a),this._sectionTool.state.planeMeshCenter.copy(a),this._sectionTool.updateBasePoint(a);else{const e=a.clone().sub(this._sectionTool.center).projectOnVector(r);let t=e.length();Math.abs(e.angleTo(r))>Math.PI/2&&(t*=-1);t+=.1,this._sectionTool.setOffset(t),this.coordinateSystem.coordinateControl.update()}this._sectionTool.update(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},setState:function(e){i.send(t,"setState");let n=e.quaternion;e.quaternion&&e.quaternion instanceof Array&&(n=new THREE.Quaternion(...e.quaternion)),this._sectionTool.restore({...e,quaternion:n}),this.coordinateSystem.coordinateControl.centerPosition=e.basePoint?new THREE.Vector3(e.basePoint.x,e.basePoint.y,e.basePoint.z):new THREE.Vector3(e.position.x,e.position.y,e.position.z),this.fireSectionPlaneStateChangedEvent()},restoreRotation:function(){this._sectionTool.restoreRotation(),this._sectionTool.update(),this.coordinateSystem.coordinateControl.setCenterPosition(this._sectionTool.state.position),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},getSectionPlane:function(){var e=this._opt.viewer,t=this._sectionTool.state.position.clone(),i=this._sectionTool.renderClipPlane.normal.clone();return t=e.sceneToWorld(t),i=e.sceneToWorld(i),(i=new THREE.Vector3(i.x,i.y,i.z)).normalize(),{position:t,normal:i}},setSectionPlane:function(e){var t=this._opt.viewer;this.coordinateSystem.coordinateControl.centerPosition;this.reset();var i=t.worldToScene(e.position),n=t.worldToScene(e.normal);(n=new THREE.Vector3(n.x,n.y,n.z)).normalize();var o=new THREE.Vector3(1,0,0),s=new THREE.Quaternion;s.setFromUnitVectors(o,n);var r=new THREE.Euler;r.setFromQuaternion(s),r.x=0,s.setFromEuler(r),s.x=-s.x;var a=this._sectionTool.uniforms.vClipPlane.value[0].clone(),l=new THREE.Vector3(a.x,a.y,a.z);l.normalize();var h=new THREE.Vector3(i.x,i.y,i.z).sub(this._sectionTool.center);this._sectionTool.planeOffset=h.x/l.x,this._sectionTool.state.quaternion.copy(s),this._sectionTool.state.position.copy(i),this._sectionTool.updateBasePoint(i),this._sectionTool.update(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},resetSectionTool:function(){var e=this._opt.viewer.getViewer().getScene(),t=e.getBoundingBox();t.getSize(this._boxSize),this._sectionTool.resize(this._boxSize.multiplyScalar(e.expandScalar)),t.getCenter(this._sectionTool.center),t.getCenter(this._sectionTool.state.position),this.coordinateSystem.coordinateControl.centerPosition=this._sectionTool.state.position.clone(),this._sectionTool.setBasePoint(this._sectionTool.state.position),this._sectionTool.update(),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},setObjectsById(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsById(e)})),this._sectionTool.update(),this._opt.viewer.render()},setObjectsByObjectData(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsByObjectData(e)})),this._sectionTool.update(),this._opt.viewer.render()},restoreObjects(){this._opt.viewer.getModels().forEach((e=>{e.clearLocalClipping()})),this._sectionTool.update(),this._opt.viewer.render()},setFilter(t){if(t&&t instanceof Array){var i=this._opt.viewer,n=i.getViewer();if("Viewer3D"===i.viewerType)for(var o=0;o{e.getViewer().modelManager.getModel(t.modelId).enableLocalClippingMode(!1)})),this.restoreObjects(),this.fireSectionPlaneVisibleChangedEvent(!0)},setBorder(t,i,n){this.borderParamWidth=t,this.borderParamHeight=i;var o=20,s=20;"Viewer3D"===this._opt.viewer.viewerType?(o=this._opt.viewer.worldToScene({x:t,y:0,z:0}).x,s=this._opt.viewer.worldToScene({x:i,y:0,z:0}).x):this._opt.viewer instanceof e.Bimface.Viewer.ViewerGIS&&(o=t?this._opt.viewer.globalUnitUtil.translate(t):o,s=i?this._opt.viewer.globalUnitUtil.translate(i):s),o=Math.max(1,o),s=Math.max(1,s),this._sectionTool.setBorder(o,s,n),this.coordinateSystem.coordinateControl.setCenterPosition(this._sectionTool.state.position),this._sectionTool.calculateClippingIds()},drawComponentContours(){let e=this._opt.viewer.getViewer().getScene().getOrCreateObjectGroup(f.ObjectGroupType.CAPSWIREFRAME,{globalSpace:!0});const t=this._sectionTool.capsIntersectContour;for(const i in t){const n=t[i],o=this._opt.viewer.getModel(i).getModelTransformationAdaptedUnit();(new THREE.Matrix4).fromArray(o);for(const t in n){n[t].clippingContours.map((t=>{t.map((t=>{const i=new THREE.BufferGeometry;i.setFromPoints(t),i.computeBoundingSphere();let n=new THREE.Line(i,new THREE.LineBasicMaterial({color:16711680,depthTest:!1}));e.add(n),n.updateMatrixWorld(!0)}))}))}}},getComponentContours(t,i){if(!this._sectionTool)return void console.warn("The SectionPlane is unavailable");const n=this._opt.viewer;let o=t;if(n instanceof e.Bimface.Viewer.ViewerGIS){const e=n.getLayerManager().getLayer(t);if(!e)return void console.warn("Parameter layerId is invalid.");o=e.getModelId()}const s=n.getModel(o);if(!s)return void console.warn("Parameter modelId is invalid.");let r=s.getComponentContours(i);if(n instanceof e.Bimface.Viewer.ViewerGIS){const e=r.length;for(let i=0;if.GlobalData.ClippingCapsType==f.EnumClippingCapsTypes.ClipPlane,enableSnap(e){f.GlobalData.SnapClippingLine=!!e},enableOutline(e){f.GlobalData.CalculateClippingLine!==e&&(f.GlobalData.CalculateClippingLine=!!e,this._sectionTool.calculateClippingIds())}},n.SectionPlane=a}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionRegionConfig=class{constructor(){const e={viewer:null,boundary:null,height:0,enableSnap:!0,filter:null,isOutlineEnabled:!0};for(let t in e)this[t]=e[t]}};class Bn{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(S(this),f.GlobalData.CalculateClippingLine=!!t.isOutlineEnabled,f.GlobalData.SnapClippingLine=!!t.enableSnap,i._sectionPlane&&(i._sectionPlane.hidePlane(),i._sectionPlane.exit()),i._sectionBox&&(i._sectionBox.hideBox(),i._sectionBox.exit()),i._sectionRegion)return i._sectionRegion;i._sectionRegion=this,this.eventManager=i.getEventManager(),this._opt=t,this._viewer=i,this.cloudViewer=this._viewer.getViewer(),this._disableFilter=!0,this.reset(),t.filter&&this.setFilter(t.filter)}else console.log("Viewer2D is not supported.")}init(){const e=this.cloudViewer.getScene().getMatrixGlobal();let t=this.boundary[0].z;this.height<0&&(t+=this.height);let i=this.boundary.map((e=>new THREE.Vector3(e.x,e.y,t)));i.push(i[0]),Bn.isClockwiseBoundary(i)||i.reverse(),f.ClipRegionManager.setEnableFilter(!1),i=this._viewer.globalUnitUtil.translate(i,["x","y","z"]);for(let t=0;t{e.clearLocalClipping()})),f.ClipRegionManager.setEnableFilter(!1),this._disableFilter=!0,f.ClipRegionManager.setUpdateOnce(),this._opt.viewer.render()}enableSnap(e){f.GlobalData.SnapClippingLine=!!e}enableOutline(e){f.GlobalData.CalculateClippingLine!==e&&(f.GlobalData.CalculateClippingLine=!!e)}static isClockwiseBoundary(e){let t=0;const i=e.length;for(let n=0;n0)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionRegion=Bn,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough").WalkthroughConfig=function(){return{viewer:null,time:10,stopCallback:null,camera:null}},function(){var t="Bimface.Plugins.Walkthrough",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");n.Walkthrough=class{constructor(t){var i=t.viewer,n=i.getViewer();i?"Viewer3D"===i.getViewerType()||"ViewerGIS"===i.getViewerType()?(S(this),this._viewer=i,this.bPause=!1,this.cameraStatus=null,this._walkthrough=new f.Walkthrough,this._player=new f.WalkthroughPlayer(n),this._player.setWalkthrough(this._walkthrough),t.stopCallback&&this._player.addStopPlayCallback(t.stopCallback),this.setWalkthroughTime(t.time),this.console=new e.Web.Common.Console,this.camera=t.camera,this.nearPoint=null,this.farPoint=null):console.log("ViewerType is not supported."):console.log("viewer must not be empty.")}addKeyFrame(n){i.send(t,"addKeyFrame");var o=this._viewer,s=o.getViewer().camera,r={id:e.Web.Lang.Utility.UUID.createUUID(),position:s.position.clone(),target:s.target.clone(),name:n};if(this._walkthrough.addKeyFrame(r),this._walkthrough.checkFrameTimeMode()){const e=this._walkthrough.getKeyFrames();e.length>1&&void 0===e[e.length-2].timeBetweenFrames&&(e[e.length-2].timeBetweenFrames=5)}var a=Object.assign({},r);return a.position=o.sceneToWorld(r.position),a.target=o.sceneToWorld(r.target),a.coordinateSystem="world",a}setKeyFrameCallback(e){i.send(t,"setKeyFrameCallback"),this._player.setKeyFrameCallback(e)}removeKeyFrame(e){i.send(t,"removeKeyFrame"),this._walkthrough.removeKeyFrame(e)}clearKeyFrames(){i.send(t,"clearKeyFrames"),this._walkthrough.clearFrames()}setKeyFrames(e){i.send(t,"setKeyFrames"),"string"==typeof e&&(e=JSON.parse(e));var n=[];e.forEach((e=>{var t=Object.assign({},e);"world"===t.coordinateSystem&&(t.position=this._viewer.worldToScene(e.position),t.target=this._viewer.worldToScene(e.target)),n.push(t)})),this._walkthrough.setKeyFrameList(n)}getKeyFrames(){var e=this._walkthrough.getKeyFrames(),t=[];return e.forEach((e=>{var i=Object.assign({},e);i.position=this._viewer.sceneToWorld(e.position),i.target=this._viewer.sceneToWorld(e.target),i.coordinateSystem="world",t.push(i)})),t}setWalkthroughTime(e){i.send(t,"setWalkthroughTime"),c.assertType(e,"obj")?e.frameTime?this._walkthrough.setWalkthroughTime(e.frameTime):this._walkthrough.setWalkthroughTime(e.totalTime):this._walkthrough.setWalkthroughTime(e)}setCamera(e){if(!e||!e.near&&!e.far)return;this.camera=e,this.cameraStatus=this._viewer.getCameraStatus();const t=this.cameraStatus.position,i=this.cameraStatus.target,n=new THREE.Vector3(i.x-t.x,i.y-t.y,i.z-t.z).normalize(),o=this._viewer.getViewer(),s=this._viewer.globalUnitUtil;if(this.camera.near){const e=this.camera.near;this.nearPoint={x:t.x+e*n.x,y:t.y+e*n.y,z:t.z+e*n.z},this.nearPoint=s.translateVector(this.nearPoint),this.nearPoint=o.worldToDrawing(this.nearPoint)}if(this.camera.far){const e=this.camera.far;this.farPoint={x:t.x+e*n.x,y:t.y+e*n.y,z:t.z+e*n.z},this.farPoint=s.translateVector(this.farPoint),this.farPoint=o.worldToDrawing(this.farPoint)}}getCamera(){return this.camera}setDisableAnimation(e){this.disableAnimation=e}play(e){if(!this.disableAnimation){i.send(t,"play");var n=this._viewer.getViewer();this.setCamera(this.camera),(this.nearPoint||this.farPoint)&&(n.calculateNearFar(void 0,this.nearPoint,this.farPoint),n.enableCameraNearFar=!1);var o=this._player,s=this.cameraStatus;if((r=n.cameraControl.camera).up.set(0,1,0),r.realUp.set(0,1,0),e&&o.startFrom(e),o.stop(!1),!0===this.bPause){var r=n.getCamera();s&&function(e){var t=(e=JSON.parse(e)).position,i=e.target,n={position:new THREE.Vector3(t.x,t.y,t.z),target:new THREE.Vector3(i.x,i.y,i.z)},o=s,r=n.position.clone().sub(o.position),a=n.target.clone().sub(o.target);return r.length()>0||a.length()>0}(r)&&(this._player.camera.position.copy(this._viewer.worldToScene(s.position)),this._player.camera.target.copy(this._viewer.worldToScene(s.target)))}o.walkthrough.keyFrameList&&o.walkthrough.keyFrameList.length>0?(o.play(),this.bPause=!1):this.console.warn("The parameter[keyFrames] cannot be null")}}pause(){this.disableAnimation||(i.send(t,"pause"),this.bPause=!0,this.cameraStatus=this._viewer.getCameraStatus(),this._player.pause())}setProgress(e){this.disableAnimation||"number"==typeof e&&(e<0||e>1||(this._player.setProgress(e),this.cameraStatus=this._viewer.getCameraStatus()))}stop(){this.disableAnimation||(i.send(t,"stop"),this._player.stop(!0),this.bPause=!1)}stopCallback(e){i.send(t,"stopCallback"),e&&(this._stopCallback=e,this._player.addStopPlayCallback(e))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment").SegmentConfig=function(){return{viewer:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment").IsolateOption=Object.freeze({Hidden:"Hidden",Translucent:"Translucent",PartlyTranslucent:"PartlyTranslucent"}),function(){var t="Bimface.Plugins.Segment",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment");n.Segment=class{constructor(e){this._viewer=e.viewer,this._segmentInfoMap=null,this._segmentInfoArray=null,this._segmentIdArray=null,this._elementIdMap={},this._loading=!1,this._segmentInfoAcquired=!1,this._segmentIdMapFromComponentId={},this._traversedSegmentIdMap={},this._fullElementIdsLoadEnabled=!0,S(this)}destroy(){this._viewer=null,this._segmentInfoMap=null,this._segmentInfoArray=null,this._segmentIdArray=null,this._elementIdMap=null,this._segmentIdMapFromComponentId=null,this._traversedSegmentIdMap=null}_hasSegmentInfo(e){return!(!this._segmentInfoMap||!this._segmentInfoMap[e])}_getSegmentInfoById(e){return this._segmentInfoMap?this._segmentInfoMap[e]:null}_removeDuplication(e){for(var t={},i=0,n=e.length;i0?requestAnimationFrame(function e(o,s){var r=s;return function(){n._getSegmentElementIdsByIdx(o,r,(function(){r{t._elementIdMap[e.segmentId]=e.elementIds,t.segmentFileInfoMap[e.segmentId].elementIds=e.elementIds})),e&&e()}),(function(){e&&e()}))}_getSegmentMetadataByIdx(e,t,i){var n=this._viewer,o=e[t],s=this.segmentFilePathMap[o].metadata,r=this.segmentFilePathMap[o].databag;n.getSegmentManager().getSegmentMetadata(o,r,s,(function(){i&&i()}),(function(){i&&i()}))}_getSegmentMetadata(e){var t=Object.keys(this.segmentFilePathMap),i=t.length,n=this;i>0?requestAnimationFrame(function t(o,s){var r=s;return function(){n._getSegmentMetadataByIdx(o,r,(function(){r{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{let s=o.modelId;var r=CLOUD.AxisGridManager.getInstance(n,s);if(e&&"mousewheel"==e.type){var l=n.getMatrixGlobal(),h=new THREE.Vector2(e.clientX,e.clientY),c=t.cameraControl.getRaycaster(h.x,h.y),d=r.getIntersectPoints(c,l),u=r.snapOnFloors(d);if(u&&0==u.length)return i.highlightLine.hide(),void i.highlightIntersectLines.hide();for(const e of u){if(a(e))break}}})),i.highlightLine.update(),i.highlightIntersectLines.update()}))}distance(e,t){var i=e.x-t.x,n=e.y-t.y,o=e.z-t.z;return Math.sqrt(i*i+n*n+o*o)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid").AxisGridManagerConfig=function(){return{viewer:null}},function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.EditPoint=class{constructor(e,t,i){this.viewer3D=e,this.worldPosition=!0===i?null:t,this.clientPosition=!0===i?t:null,this.svgElement=null,this.xmlns="http://www.w3.org/2000/svg",this.glodonColor="#11DAB7",this.gridHighlightColor="#FF7F00",this.observer=function(){},this.uuid=-1,this.initialize()}initialize(){this.worldPosition?this.clientPosition=this.viewer3D.worldToClient(this.worldPosition):this.worldPosition=this.viewer3D.clientToWorld(this.clientPosition);let e=document.createElementNS(this.xmlns,"circle");e.setAttribute("r",3),e.setAttribute("style","stroke: "+this.glodonColor+"; stroke-width: 1; fill: #ffffff"),e.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")"),this.svgElement=e}setObserver(e){this.observer=e}hightlight(){this.svgElement.style.stroke=this.gridHighlightColor}cancelHightlight(){this.svgElement.style.stroke=this.glodonColor}distanceTo(e){let t=e.x-this.clientPosition.x,i=e.y-this.clientPosition.y;return Math.sqrt(t*t+i*i)}detach(){this.svgElement.parentNode.removeChild(this.svgElement)}update(e){1==e?this.worldPosition=this.viewer3D.clientToWorld(this.clientPosition):this.clientPosition=this.viewer3D.worldToClient(this.worldPosition),this.svgElement.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")")}isEqualWith(e){return e.uuid==this.uuid}getWorldPosition(){let e=this.worldPosition;return[e.x,e.y,e.z]}getClientPosition(){return new THREE.Vector2(this.clientPosition.x,this.clientPosition.y)}setClientPosition(e){this.clientPosition.x=e.x,this.clientPosition.y=e.y}getSvgElement(){return this.svgElement}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.EditEdge=class{constructor(e){this.svgElement=null,this.xmlns="http://www.w3.org/2000/svg",this.gridHighlightColor="#FF7F00",this.editPoints=e,this.initialize(),this.hide()}initialize(){let e=this.editPoints[0],t=this.editPoints[1],i=document.createElementNS(this.xmlns,"line");i.setAttribute("stroke",this.gridHighlightColor),i.setAttribute("stroke-width",3),i.setAttribute("x1",e.getClientPosition().x+""),i.setAttribute("y1",e.getClientPosition().y+""),i.setAttribute("x2",t.getClientPosition().x+""),i.setAttribute("y2",t.getClientPosition().y+""),this.svgElement=i}show(){this.update(),this.svgElement.style.display="block"}hide(){this.svgElement.style.display="none"}update(){let e=this.editPoints[0],t=this.editPoints[1];this.svgElement.setAttribute("x1",e.getClientPosition().x+""),this.svgElement.setAttribute("y1",e.getClientPosition().y+""),this.svgElement.setAttribute("x2",t.getClientPosition().x+""),this.svgElement.setAttribute("y2",t.getClientPosition().y+"")}detach(){this.svgElement.parentNode.removeChild(this.svgElement)}startWithNull(){return null==this.editPoints[0]}endWith(e){return this.editPoints[1].isEqualWith(e)}distanceTo(e){let t=e.x-this.clientPosition.x,i=e.y-this.clientPosition.y;return Math.sqrt(t*t+i*i)}getSvgElement(){return this.svgElement}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.Boundary=class{constructor(e){this.editPoints=e,this.polyline=null,this.xmlns="http://www.w3.org/2000/svg",this.glodonColor="#11DAB7",this.boundaryHighlightColor="#FF7F00",this.initialize()}initialize(){this.setObserver();let e=this.formatPolyline(this.editPoints),t=document.createElementNS(this.xmlns,"polyline");t.setAttribute("stroke",this.glodonColor),t.setAttribute("stroke-width",2),t.style.fill=this.glodonColor,t.style.fillOpacity="0.4",t.setAttribute("points",e),this.polyline=t}setObserver(){this.updateBinded=this.update.bind(this);for(const e of this.editPoints)e.setObserver(this.updateBinded)}formatPolyline(e){let t="";for(let i of e){let e=i.getClientPosition();t+=e.x+","+e.y,t+=" "}let i=e[0].getClientPosition();return t+=i.x+","+i.y,t+=" ",t}update(){let e=this.formatPolyline(this.editPoints);this.polyline.setAttribute("points",e)}rebuild(e){this.editPoints=e,this.initialize()}getSvgElement(){return this.polyline}}}();class _n{constructor(){}}_n.distanceToSegment=function(e,t,i){let n=this.nearestPointOnSegment(e,t,i);return e.distanceTo(n)},_n.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 An{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 An)for(const i of t.getDrawables())e.appendChild(i);else e.appendChild(t)}))}detach(){for(const t of this.drawables){if(t instanceof An)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 kn extends An{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=fi.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=fi.makeLine(n);o.setAttribute("marker-end","url(#"+this.id+")"),this.drawables.push(o)}setDefault(){this.drawables[1].style.stroke=this.color;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.color)}setGray(){this.drawables[1].style.stroke=this.grayColor;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.grayColor)}select(){this.drawables[1].style.stroke=this.highlightColor;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.highlightColor)}hitTest(e){let t=this.hitTestEpsilon;const i=new THREE.Vector3(e.x,e.y,0),n=new THREE.Line3(new THREE.Vector3(this.start.x,this.start.y,0),new THREE.Vector3(this.target.x,this.target.y,0)),o=new THREE.Vector3;return n.closestPointToPoint(i,!0,o),o.distanceTo(i)<=t?this:null}hide(){let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.display="none"),this.drawables[1].style.display="none"}show(){this.drawables[1].style.display="block";let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.display="block")}getDirection(){let e=this.target.clone().sub(this.start).normalize();return new THREE.Vector3(e.x,e.y,0)}magnify(){let e=document.getElementById(this.id);e.setAttribute("markerWidth",6),e.setAttribute("markerHeight",6)}resetSize(){let e=document.getElementById(this.id);e.setAttribute("markerWidth",4),e.setAttribute("markerHeight",4)}isArrow(){return!0}}class Ln{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{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=_n.distanceToSegment(t,r[0],r[1]);return l<=this.hitTestEpsilon?"up-segment":(l=_n.distanceToSegment(t,a[0],a[1]),l<=this.hitTestEpsilon?"down-segment":null)}detach(){for(const t of this.drawables){var e=t.parentNode;e&&e.removeChild(t),this.drawables=[]}}getDrawables(){return this.drawables}highlight(e){let t="up-segment"==e?this.upSegment:this.downSegment;for(const e of[0,2,4])t[e].style.stroke=this.highlightColor;let i="up-segment"==e?["1","2"]:["3","4"];for(const e of i){document.getElementById(e).children[0].style.fill=this.highlightColor}}cancelHighlight(){for(const e of[0,2,4])this.upSegment[e].style.stroke=this.glodonColor,this.downSegment[e].style.stroke=this.glodonColor;for(const e of["1","2","3","4"]){document.getElementById(e).children[0].style.fill=this.glodonColor}}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing"));i.RoomData=class{constructor(e,i){t.send("Bimface.Plugins.RoomEditing","RoomData"),this.viewer=e,this.roomBoundary=i,this.editHeight=null,this.editPoints=[],this.editEdges=[],this.boundary=null,this.editPointUuid=0,this.onEditPointDeletion=null,this.onEditPointAddition=null,this.isEditHeightEnabled=!1,this.roomHeightOffset={from:0,to:0}}build(){if(this.isEditHeightEnabled)!this.editHeight&&this.makeHeight();else{let t;this.makeEditPoints(),this.makeEditEdges(),this.makeBoundary();let i=this.viewer.roomManager;if(i&&i.getRoomById(this.editRoomId)){t=i.getRoomById(this.editRoomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId)}this.roomHeightOffset.from=t.min.z,this.roomHeightOffset.to=t.max.z}}makeHeight(){let t;this.editHeight=new Ln;let i=this.viewer.roomManager;if(i&&i.getRoomById(this.editRoomId)){t=i.getRoomById(this.editRoomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId)}this.roomHeightOffset.from=t.min.z,this.roomHeightOffset.to=t.max.z}makeEditPoints(){for(let e=0;ee.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;ethis.roomHeightOffset.to-o&&(this.roomHeightOffset.from=this.roomHeightOffset.to-o))}getRoomHeightOffset(){return[this.roomHeightOffset.from,this.roomHeightOffset.to]}updateRoomBoundary(e){const t=this.roomBoundary;let i=new THREE.Vector3;for(let n=0;n0;){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,_n.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=_n.distanceToSegment(e,o,s);r{n.viewHouseVisibility=n.viewer._getViewHouseVisibility(),n.viewHouseVisibility&&n.viewer.hideViewHouse(),n.viewer._enableCursor(!1),t.getFilter().deactivateAll(),n.viewer._enableSelectionChanged(!1),n.viewer.setCameraAnimation(!1),n.viewer.setCameraType("OrthographicCamera"),n.viewer.enableOrbit(!1),n.viewer.hideRoomsById([this.roomId]),n.roomData.build(),n.roomView.attachDrawables(),n.roomView.addCloudViewerEvents(t),n.roomEditorToolBar.show(),n.viewer.render()}),i)}recordUIVisibility(){let e=Object.keys(this.mapUIVisibility);for(const t of e){let e=document.getElementsByClassName(t);e.length>0&&(this.mapUIVisibility[t]=e[0].style.display)}}save(){let e=this.roomInfo.boundary.offsetZ||0,t=[],i=[];const n=this.getBindedModelTransformInv(),o=new THREE.Vector3;let s=this.roomData.getRoomHeightOffset(),r=new THREE.Vector3(0,0,s[0]).applyMatrix4(this.viewer.getViewer().getModelManager().getModel(this.getBindedModelId()).transformMatrix.clone().invert()).z;for(const s of this.roomData.getEditPoints()){let a=s.getWorldPosition();o.fromArray(a).applyMatrix4(n),a=o.toArray();let l=a;l[2]=e,t.push(l),i.push({x:l[0],y:l[1],z:r})}return{boundary:this.viewer.createBoundary(t),outerBoundary:i,height:s[1]-s[0],id:this.roomId}}checkIntersect(){let t=new THREE.Vector3,i=new THREE.Vector3(10,10),n=[];n.push(t,new THREE.Vector3(10,0),i,new THREE.Vector3(0,10));new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(n);let o=[];for(const e of this.roomData.getEditPoints()){let t=e.getWorldPosition(),i=new THREE.Vector2(t[0],t[1]);o.push(i)}return e.Bimface.Plugins.Geometry.PlaneBufferGeometry.checkIntersect(o)}onExit(t){let i=this.viewer.getViewer();if(this.roomView.removeCloudViewerEvents(i),this.removeDomEventListeners(),this.roomView.detachDrawables(),this.bIsOnEditing=!1,this.viewHouseVisibility&&this.viewer.showViewHouse(),this.viewer._enableCursor(!0),this.viewer.setCameraAnimation(this.lastAnimationState),i.getFilter().activateAll(),this.viewer._enableSelectionChanged(!0),this.viewer.enableOrbit(!0),!0!==t){let t=this.save(),i=this.roomInfo.faceColor,n=this.roomInfo.frameColor;const o=this.getBindedModelId();let s=this.viewer.roomManager;if(s&&s.getRoomById(t.id)){let e=s.getRoomById(t.id),i=this.roomData.getRoomHeightOffset(),n=this.viewer.getViewer().getModelManager().getModel(o).transformMatrix.clone(),r=new THREE.Vector3,a=new THREE.Quaternion,l=new THREE.Vector3;n.decompose(r,a,l),r=this.viewer.globalUnitUtil.revertVector(r),n.compose(r,a,l),i[0]=new THREE.Vector3(0,0,i[0]).applyMatrix4(n.clone().invert()).z,i[1]=new THREE.Vector3(0,0,i[1]).applyMatrix4(n.clone().invert()).z;let h=t.boundary,c=[];for(let e=0;erequestAnimationFrame((()=>{let t=this.viewer._sectionPlane;t&&(t.setPlane("Z"),t.setDirection("Forward"),t.setProgress(this.restoreSectionPlaneProgress)),this.roomView.detachDrawables(),this.roomView.attachDrawables(),this.viewer.render(),this.viewer.setCameraAnimation(e),this.roomView.update()})))),this.isInHeightEditor=!1}_activateHeightEditor(){this.isInHeightEditor=!0,this.restoreCameraStatus2=this.viewer.getCameraStatus(),this.viewer._sectionPlane&&(this.restoreSectionPlaneProgress=this.viewer._sectionPlane.getProgress()),this.makeSectionPlane();let t=this.viewer,i=this.roomView,n=this.viewer.getCameraAnimation();this.viewer.setCameraAnimation(!1),t.setView(e.Bimface.Viewer.ViewOption.South,(()=>{let o,s=this.viewer.roomManager;if(s&&s.getRoomById(this.roomId)){o=s.getRoomById(this.roomId).getRoomBoundingBox()}else{o=new e.Bimface.Plugins.SpatialRelation.Room({viewer:t}).getRoomBoundingBoxById(this.roomId)}o=this.viewer.globalUnitUtil.translateBBox(o),t.getViewer().zoomToBBox(o,.5,void 0,void 0,1e3),t.setCameraType("OrthographicCamera"),i.getData().build(),i.update(),this.viewer.setCameraAnimation(n)}))}activateByRoomId(t){let i;this.isInHeightEditor=!1,this.roomId=t;let o=this.viewer.roomManager;if(o&&o.getRoomById(this.roomId)){let e=o.getRoomById(this.roomId);this.roomInfo=e.roomInfo,i=e.getOldBoundary()}else{this.roomInfo=this.viewer.mapCustomizedRoom[t],i=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer,hasInitialized:!0}).getBoundaryByRoomId(t)}this.roomData=new n.RoomData(this.viewer,i),this.roomData.setEditRoomId(t),this.roomView=new n.RoomView(this.roomData,this.svgContainer),this.roomView.setEventManager(this.viewer.getEventManager()),this.viewer.enableOrbit(!1),this.viewer._enableCursor(!1),this.activateEditor("Pick"),this.addDomEventListeners()}onMouseDown(e){if(e.button===THREE.MOUSE.LEFT){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.begin(t)}}onMouseMove(e){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.onEditing(t)}onMouseUp(e){if(e.button===THREE.MOUSE.LEFT){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.end(t),e.preventDefault(),e.stopPropagation()}}onMouseDoubleClick(e){e.preventDefault(),e.stopPropagation()}onWindowResize(){this.roomView.update()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing").RoomEidtorConfig=function(){return{viewer:null,roomId:null}},function(){let t="Bimface.Plugins.RevitHelpers",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers"));n.DrawingHelper=class{constructor(e){i.send(t,"DrawingHelper"),S(this),this.viewer3D=e.viewer,this.databagId=e.viewer._data.databagId,this.modelId=e.modelId,this.modelId&&!this.viewer3D._models[this.modelId]&&(this.modelId=null,this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")),this.dataViews=null,this.integrateDataViews={},this.drawingViews=[],this.drawingIds=[],this.drawingList=[],this.integrateDrawingList={},this._config=e,this.mapDrawingVisibility={},this.mapDrawingObject={},this.supportViewTypeMap={FloorPlan:!0,Elevation:!0,Section:!0};let n=e.viewer.getViewer().getScene();this.customPlaneManager=CLOUD.CustomPlaneManager.getInstance(n),this.initialize()}initialize(){let e=this;"integrateModel"==this.viewer3D.getModel(this.modelId||null)._data.modelType&&null!=this.viewer3D.getModel(this.modelId||null)._data.integrateDrawings?e._config.viewer.getLinksJson((function(t){t&&e.formatLinksData(t)})):"singleModel"==this.viewer3D.getModel(this.modelId||null)._data.modelType&&this.getViews((function(t){let i=JSON.parse(t).viewList;for(let t=0;t{for(let s=0;s0?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;t0?n(r,a,l):new THREE.Matrix4,h.length>0&&i(h,o)}this.transforms=t}getViews(e){if(this.dataViews)return void(e&&e(this.dataViews));let t=this;(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViews((function(i){t.dataViews=i,e&&e(i.data)}))}getViewsById(e,t){if(this.integrateDrawingList[e])return void(t&&t(this.integrateDrawingList[e]));let i=this;(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViewsById(e,(function(o){if(!o.data)return t&&t([]);i.integrateDataViews[e]=o,i.integrateDataViews.resourceHost=o.resourceHost;let s=JSON.parse(o.data).viewList,r=[];for(let e=0;e=0}getDrawingList(e,t){if(!e){let e=JSON.parse(JSON.stringify(this.drawingList));return e.forEach((e=>{e.viewPort&&e.viewPort.origin&&(e.viewPort.origin=this.viewer3D.globalUnitUtil.revertTranslate(e.viewPort.origin,["x","y","z"]))})),t&&t(e),e}{if("integrateModel"==this.viewer3D.getModel(this.modelId)._data.modelType){let t=!1,i=this.viewer3D.getModel(this.modelId)._data.integratedFileIds;for(let n in i){if(i[n].indexOf(e)>-1){t=!0;break}}if(!t)return void this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")}let i=this;this.getViewsById(e,(function(e){return e.forEach((e=>{e.viewPort&&e.viewPort.origin&&(e.viewPort.origin=i.viewer3D.globalUnitUtil.revertTranslate(e.viewPort.origin,["x","y","z"]))})),t&&t(e),e}))}}addDrawingsById(e,t,i){let n=this,o=0;for(let s=0;s0){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-1){t=!0;break}}if(!t)return void this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")}(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViewsTree(e,(e=>n(this.viewer3D.globalUnitUtil.excute(e,"mm",this.viewer3D.globalUnitUtil.getGlobalUnit(),["cropBox","outline","elevation"]))))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers").DrawingHelperConfig=function(){return{viewer:null,modelId:""}};class Rn{constructor(e,t,i){this.viewer3D=e,this.objectType=t,this.name="Translation",this._eventManager=i,this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1,"ExternalObject"===t&&(this.externalObjectManager=new Glodon.Bimface.Plugins.ExternalObject.ExternalObjectManager(e))}setEditedObjectId(e){if(this.handleEditedObjectId(e),e=this.editedObjectId,this.viewer3D instanceof Glodon.Bimface.Viewer.ViewerGIS){const t=this.viewer3D.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i1}init(){if(!this.initialized&&this.isEditedMulti()){const e=this.editedObjectId[0];this.singleModelMatrixInvert=this.getModelTransformMatrix(e).invert();const t=this.editedObjectId.reduce(((e,t)=>{const{min:i,max:n}=this.getSingleBoundingBoxWorld(t);return e.push(i,n),e}),[]),{min:i,max:n}=(new THREE.Box3).setFromPoints(t);this.initialCenter=(new THREE.Vector3).addVectors(i,n).multiplyScalar(.5),this.initialBoundingBoxPoints=[new THREE.Vector3(i.x,i.y,i.z),new THREE.Vector3(n.x,i.y,i.z),new THREE.Vector3(n.x,n.y,i.z),new THREE.Vector3(i.x,n.y,i.z),new THREE.Vector3(i.x,i.y,n.z),new THREE.Vector3(n.x,i.y,n.z),new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(i.x,n.y,n.z)],this.initialized=!0}}resetInitialValues(){this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1}getBoundingBoxWorld(){const e=this.objectType;if(this.isEditedMulti()){return(new THREE.Box3).setFromPoints(this.initialBoundingBoxPoints.map((e=>e.clone().applyMatrix4(this.transformMatrix))))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundingBoxWorld()}getTransformMatrix(){return this.isEditedMulti()?this.transformMatrix:this.getModelTransformMatrix(this.editedObjectId)}getSingleBoundingBoxWorld(e){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(e);return this.viewer3D.getViewer().getModelManager().getModel(e).getBoundingBoxWorld()}getModelTransformMatrix(e){if("ExternalObject"===this.objectType){let t=this.viewer3D.getExternalComponentManager().getGroupTransform(e);return(new THREE.Matrix4).compose(t.position,t.rotate,t.scale)}return this.viewer3D.getViewer().getModelManager().getModel(e).getTransformMatrix().clone()}getBoundaryPoints(){const e=this.objectType;if(this.isEditedMulti()){const e=this.transformMatrix;return this.initialBoundingBoxPoints.map((t=>t.clone().applyMatrix4(e)))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundaryPoints(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundaryPoints()}getBoundingBox(){let e=this.getBoundaryPoints(),t=this.getRotationMatrix().invert(),i=[];return e.map((e=>i.push(e.clone().applyMatrix4(t)))),(new THREE.Box3).setFromPoints(i)}getRotationMatrix(){let e=new THREE.Matrix4,t=this.getTransformMatrix();return e.extractRotation(t),e}_fireModelEvent(e){const t=this._eventManager,i=Array.isArray(this.editedObjectId)?this.editedObjectId:[this.editedObjectId],n={};i.map((e=>{n[e]=this.viewer3D.getModel(e).getModelTransformationAdaptedUnit()})),t.fireEvent(e,{modelId:i,transformation:n})}updateController(e){}updateTransformMatrix(){const e=this.editedObjectId[0],t=this.getModelTransformMatrix(e);this.transformMatrix=t.multiply(this.singleModelMatrixInvert)}_scaleOnBasePoint(e,t,i){const n=new THREE.Vector3,o=new THREE.Quaternion,s=new THREE.Vector3;e.decompose(n,o,s),s.multiply(i);const r=i.clone().sub(new THREE.Vector3(1,1,1)),a=o.clone(),l=a.clone().invert(),h=n.clone(),c=t.clone().sub(h).applyQuaternion(l).multiply(r).applyQuaternion(a);n.sub(c);return(new THREE.Matrix4).compose(n,o,s)}_rotateOnBasePoint(e,t,i,n){const o=new THREE.Vector3,s=new THREE.Quaternion,r=new THREE.Vector3;e.decompose(o,s,r);const a=s.clone().invert(),l=(new THREE.Quaternion).setFromAxisAngle(i,n);s.multiply(l);const h=o.clone(),c=t.clone().sub(h).applyQuaternion(a).applyQuaternion(s);o.sub(c).add(t.clone().sub(h));return(new THREE.Matrix4).compose(o,s,r)}getExternalObjectTransform(e){const t=this.externalObjectManager.getTransformation(e);return(new THREE.Matrix4).fromArray(t)}setRotation(e,t){const i=this.objectType,n=t;if(this.isEditedMulti()){const t=this.editedObjectId.length,i=this.viewer3D.globalUnitUtil.revertVector(this.initialCenter.clone().applyMatrix4(this.transformMatrix)),o=this.transformMatrix.clone();let s;switch(n){case"xy":s=new THREE.Vector3(0,0,1);break;case"xz":s=new THREE.Vector3(0,1,0);break;case"yz":s=new THREE.Vector3(1,0,0)}const r=this._rotateOnBasePoint(this.transformMatrix.clone(),i,s,e),a=o.clone().invert();for(let e=0;e{if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}));else{const i=this.editedObjectId;if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}this.isEditedMulti()&&this.updateTransformMatrix(),"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}setName(e){this.name=e}}Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Web.Lang.Utility.Dom");let Hn=Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Bimface.Plugins.ObjectEditor");class On{constructor(e,t){this.viewer=e,this.editObjectType=t,S(this),this.activeEditors=[],this.rotationController={X:!0,Y:!0,Z:!0},this.translationController={X:!0,Y:!0,Z:!0},this.scaleController={Uniform:!0,X:!0,Y:!0,Z:!0},this.initilize()}initilize(){this.initHelperAndEvent();let e=new Glodon.Web.Lang.EventManager;this.getEventManager=function(){return e},this.activeEditor=new Rn(this.viewer,this.editObjectType,e)}initHelperAndEvent(){this.helper=CLOUD.Interaction.InteractionHelper.getInstance(this.viewer.getViewer()),this.helperEvents={},this.addHelperEvent("TransformStarted",(e=>{"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformStart")})),this.addHelperEvent("TransformChanged",(e=>{if("Translation"===e.id){let t=e.control.position.clone(),i={x:t.x-this.objectPositon.x,y:t.y-this.objectPositon.y,z:t.z-this.objectPositon.z};this.activeEditor.setObjectTranslation(this.viewer.globalUnitUtil.revertTranslate(i,["x","y","z"])),this.objectPositon=t}else if("Scale"===e.id){let t=e.control.scaleInfo,i={};if(t){let n=this.activeEditor.getBoundaryPoints(),o=null;const s=(e,t,i,o)=>{let s=n[e],r=n[t],a=n[i],l=n[o];return(new THREE.Vector3).add(s).add(r).add(a).add(l).multiplyScalar(.25)};switch(t.type){case"AxisX":o=s(0,3,7,4),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisXN":o=s(1,2,6,5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisY":o=s(0,1,5,4),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisYN":o=s(2,3,7,6),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisZ":o=s(0,1,2,3),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;case"AxisZN":o=s(4,5,6,7),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;default:o=s(0,1,2,3).add(s(4,5,6,7)).multiplyScalar(.5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,t.scaleFactor/this.objectScale.y,t.scaleFactor/this.objectScale.z)}o=this.viewer.globalUnitUtil.revertVector(o),this.activeEditor.setObjectScale(o,i),e.control.update(this.activeEditor.getBoundingBox());let r=new THREE.Vector3;this.activeEditor.getBoundingBoxWorld().getCenter(r),e.control.setPosition(r),this.objectScale={x:t.scaleFactor,y:t.scaleFactor,z:t.scaleFactor}}}else if("Rotate"===e.id){let t=e.control.rotateInfo,i="";if(t){switch(t.type){case"ringX":default:i="yz";break;case"ringY":i="xz";break;case"ringZ":i="xy"}switch(this.activeEditor.setRotation(t.angle,i),t.type){case"ringX":e.control.rotateX(t.angle);break;case"ringY":e.control.rotateY(t.angle);break;default:e.control.rotateZ(t.angle)}}}})),this.addHelperEvent("TransformFinished",(e=>{"Scale"===e.id&&(this.objectScale={x:1,y:1,z:1}),"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformEnd")}))}addHelperEvent(e,t){this.helperEvents[e]=t,this.helper.addEventListener(e,t)}setEditedObjectId(e){this.editedObjectId=e,Array.isArray(e)&&this.activeEditor.resetInitialValues(),this.activeEditor.setEditedObjectId(e),this.dispose();let t=new THREE.Vector3;switch(this.activeEditor.name){case"Translation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.updateController()}attachInitDrawables(){}getEditedObjectId(){return this.editedObjectId}activateEditor(e){this.dispose();let t=new THREE.Vector3;switch(e){case"Translation":this.activeEditor.setName("Translation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.setName("Scaling"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.setName("Rotation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.activeEditor.setEditedObjectId(this.editedObjectId),this.updateController()}changeControlArrowDirection(){const e=this.viewer.getViewer().camera._direction&&this.viewer.getViewer().camera._direction.clone().applyMatrix4(this.helper.invertMatrix).normalize(),t=this.viewer.getViewer().camera.position.clone().applyMatrix4(this.helper.invertMatrix),i=this.viewer.getViewer().camera.fov;this.helper.dispatchEvent({type:"CameraChanged",cameraDirection:e,cameraPosition:t,cameraFov:i})}dispose(){this.helper.removeControl("Translation"),this.helper.removeControl("Scale"),this.helper.removeControl("Rotate")}hide(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!1),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!1),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!1),this.viewer.render()}show(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!0),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!0),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!0),this.viewer.render()}onExit(){this.dispose(),this.isExitNow=!0,Object.entries(this.helperEvents).forEach((([e,t])=>{this.helper.removeEventListener(e,t)})),this.viewer.render()}updateController(e,t){switch(t){case"Translation":null!=e.X&&(this.translationController.X=e.X),null!=e.Y&&(this.translationController.Y=e.Y),null!=e.Z&&(this.translationController.Z=e.Z);break;case"Rotation":null!=e.X&&(this.rotationController.X=e.X),null!=e.Y&&(this.rotationController.Y=e.Y),null!=e.Z&&(this.rotationController.Z=e.Z);break;case"Scaling":null!=e.X&&(this.scaleController.X=e.X),null!=e.Y&&(this.scaleController.Y=e.Y),null!=e.Z&&(this.scaleController.Z=e.Z),null!=e.Uniform&&(this.scaleController.Uniform=e.Uniform)}const i={...this.scaleController};this.activeEditor&&this.activeEditor.isEditedMulti()&&(i.X=i.Y=i.Z=!1),this.helper.getControl("Translation")&&this.helper.getControl("Translation").updateAxisVisible(this.translationController),this.helper.getControl("Rotate")&&this.helper.getControl("Rotate").updateAxisVisible(this.rotationController),this.helper.getControl("Scale")&&this.helper.getControl("Scale").updateAxisVisible(i)}}Hn.ObjectEditorManager=On;const Nn="Exit",Gn="EditingModeChanged",Un=e.Bimface.Data.StatisticsDataManager.getInstance(),zn="bf_interaction.sceneEditor";let Fn=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class Wn{constructor(e){this.viewer=e.viewer,this.objectId=e.objectId,S(this),this.viewer._objectEditorToolbar&&this.viewer._objectEditorToolbar.exit(),this.mode=null,this.toolBarButtons={translate:!e.buttonVisibility.hasOwnProperty("translate")||e.buttonVisibility.translate,rotate:!e.buttonVisibility.hasOwnProperty("rotate")||e.buttonVisibility.rotate,scale:!e.buttonVisibility.hasOwnProperty("scale")||e.buttonVisibility.scale},this.viewer._objectEditorToolbar=this,this.rotationController={X:!e.rotationController.hasOwnProperty("X")||e.rotationController.X,Y:!e.rotationController.hasOwnProperty("Y")||e.rotationController.Y,Z:!e.rotationController.hasOwnProperty("Z")||e.rotationController.Z},this.translationController={X:!e.translationController.hasOwnProperty("X")||e.translationController.X,Y:!e.translationController.hasOwnProperty("Y")||e.translationController.Y,Z:!e.translationController.hasOwnProperty("Z")||e.translationController.Z},Array.isArray(this.objectId)&&this.objectId.length>1?this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!!e.scaleController.hasOwnProperty("X")&&e.scaleController.X,Y:!!e.scaleController.hasOwnProperty("Y")&&e.scaleController.Y,Z:!!e.scaleController.hasOwnProperty("Z")&&e.scaleController.Z}:this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!e.scaleController.hasOwnProperty("X")||e.scaleController.X,Y:!e.scaleController.hasOwnProperty("Y")||e.scaleController.Y,Z:!e.scaleController.hasOwnProperty("Z")||e.scaleController.Z}}setRotationController(e){e&&(this.rotationController=e),this.objectEditorManager.updateController(this.rotationController,"Rotation")}getRotationController(){let e={};return e.X=!this.rotationController.hasOwnProperty("X")||this.rotationController.X,e.Y=!this.rotationController.hasOwnProperty("Y")||this.rotationController.Y,e.Z=!this.rotationController.hasOwnProperty("Z")||this.rotationController.Z,e}setTranslationController(e){e&&(this.translationController=e),this.objectEditorManager.updateController(this.translationController,"Translation")}getTranslationController(){let e={};return e.X=!this.translationController.hasOwnProperty("X")||this.translationController.X,e.Y=!this.translationController.hasOwnProperty("Y")||this.translationController.Y,e.Z=!this.translationController.hasOwnProperty("Z")||this.translationController.Z,e}setScaleController(e){e&&(this.scaleController=e),this.objectEditorManager.updateController(this.scaleController,"Scaling")}getScaleController(){let e={};return e.X=!this.scaleController.hasOwnProperty("X")||this.scaleController.X,e.Y=!this.scaleController.hasOwnProperty("Y")||this.scaleController.Y,e.Z=!this.scaleController.hasOwnProperty("Z")||this.scaleController.Z,e.Uniform=!this.scaleController.hasOwnProperty("Uniform")||this.scaleController.Uniform,e}setButtonVisibility(e){e&&(this.toolBarButtons=e,this._updateButtonsVisibility())}getButtonVisibility(){let e={};return e.translate=!this.toolBarButtons.hasOwnProperty("translate")||this.toolBarButtons.translate,e.rotate=!this.toolBarButtons.hasOwnProperty("rotate")||this.toolBarButtons.rotate,e.scale=!this.toolBarButtons.hasOwnProperty("scale")||this.toolBarButtons.scale,e}_updateButtonsVisibility(){this.toolBarButtons.scale||this.toolBarButtons.rotate||this.toolBarButtons.translate?(this.switchToolbarAllHide=!1,this.show()):(this.setBimfaceUIVisibility(!1),this.switchToolbar.hide(),this.switchToolbarAllHide=!0);let e=this.switchToolbar.getControls(),t=this.getButton("Translation",e),i=this.getButton("Rotation",e),n=this.getButton("Scaling",e);this.toolBarButtons.translate?t.show():t.hide(),this.toolBarButtons.rotate?i.show():i.hide(),this.toolBarButtons.scale?n.show():n.hide()}_updateController(){this.objectEditorManager&&(this.objectEditorManager.updateController(this.translationController,"Translation"),this.objectEditorManager.updateController(this.rotationController,"Rotation"),this.objectEditorManager.updateController(this.scaleController,"Scaling"))}setEditingMode(e){if(this.objectEditorManager){switch(e){case"rotation":this.mode="rotation",this.objectEditorManager.activateEditor("Rotation");break;case"translation":this.mode="translation",this.objectEditorManager.activateEditor("Translation");break;case"scale":this.mode="scale",this.objectEditorManager.activateEditor("Scaling")}this.objectEditorManager.show()}}getEditingMode(){return this.mode}setEditedObjectId(e){this.objectEditorManager.setEditedObjectId(e)}getEditedObjectId(){return this.objectEditorManager.getEditedObjectId()}show(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!1),this.modelEditor.show(),this.switchToolbarAllHide||this.switchToolbar.show(),this.objectEditorManager.show())}hide(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!0),this.modelEditor.hide(),this.switchToolbar.hide(),this.objectEditorManager.hide())}exit(){this._destroyed||(this.hide(),this._getEventManager().fireEvent(Nn),this.objectEditorManager.onExit(),delete this.viewer._objectEditorToolbar,this.destroy())}destroy(){this.domElement&&this.domElement.remove(),this.domElement=null,this.viewer=null,this.objectId=null,this.objectEditorManager=null,this._destroyed=!0}update(){}updateManagerController(e,t){this.objectEditorManager.updateController(e,type)}initialize(){this.mapUIVisibility={"bf-tree-toolbar":"none","bf-modelTree-panel":"none","bf-toolbar-bottom":"none","bf-property-panel":"none","bf-measurement-panel":"none","bf-sectionPlane-panel":"none","bf-pickSectionPlane-panel":"none","bf-sectionBox-panel":"none","bf-settings-panel":"none","bf-basicInfo-panel":"none","bf-map-panel":"none"},this.recordUIVisibility()}toolBarDom(t=!1){const i=this;let n=[];const o=Fn.create("div",t?"bf-effectToolbar":"bf-roomEditorToolbar");if(i.domElement=o,o.style.zIndex=1,o.addEventListener("mousedown",(e=>(e.stopPropagation(),!1))),t){const t=new e.Bimface.UI.Toolbar.ToolbarConfig;t.element=o,t.className="bf-toolbar bf-toolbar-effectToolbar switch-btn";let s=this.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(t);i.modelEditor=s,n.push(s);const r=new e.Bimface.UI.Button.ButtonConfig;r.className="bf-button bimface-icon gld-bf-edit-24",r.title="点击隐藏编辑控件",r.checkedState=!0;const a=new e.Bimface.UI.Button.ToggleButton(r);a.addEventListener("StateChange",(e=>{e?(a.element.title="点击隐藏编辑控件",Un.send(zn,"editorStatusOn"),this.objectEditorManager.show(),this.objectEditorManager.activateEditor("Translation")):(a.element.title="点击显示编辑控件",Un.send(zn,"editorStatusOff"),this._getEventManager().fireEvent(Nn),this.objectEditorManager.dispose(),this.objectEditorManager.hide()),this.toggleOtherButtons(e)})),s.addControl(a)}if(void 0===this.switchToolbar){var s=e.Bimface.UI.Toolbar.ToolbarConfig();s.className=t?"bf-toolbar bf-toolbar-effectToolbar":"bf-toolbar bf-toolbar-roomEditor",s.element=o,s.buttons=["ModelEditingTranslate","ModelEditingRotate","ModelEditingScale"],this.viewer.getDomElement().appendChild(o),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(s),n.push(this.switchToolbar)}let r=e.Bimface.UI.Control.ControlEvent,a=this.switchToolbar.getControls();this.uncheckOthers("Translation",a);let l=["Translation","Rotation","Scaling"];i._editingMode="Translation";for(let e=0;e{this.exit()})),s.addControl(a)}this.viewer.getDomElement().appendChild(o),this._updateButtonsVisibility(),this._updateController()}recordUIVisibility(){let e=Object.keys(this.mapUIVisibility);for(const t of e){let e=document.getElementsByClassName(t);e.length>0&&(this.mapUIVisibility[t]=e[0].style.display)}}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getButton(e,t){for(let i=0;i0)return"ViewerGIS"===e.viewer.getViewerType()?e.ids.reduce(((t,i)=>{const n=e.viewer.getLayerManager().getLayer(i);return n&&t.push(n.getModelId()),t}),[]):e.ids;if("ViewerGIS"===e.viewer.getViewerType()&&e.layerId){const i=e.viewer.getLayerManager().getLayer(e.layerId);i&&(t=i.getModelId())}return t}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor").ModelEditorToolbarConfig=function(){return{viewer:null,modelId:null,layerId:null,app:null,buttonVisibility:{},translationController:{},rotationController:{},scaleController:{},ids:null}},function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor"));i.ModelEditorToolbar=class extends Wn{constructor(e){t.send("Bimface.Plugins.ModelEditor","ModelEditorToolbar"),e.objectId=jn(e),super(e),this.name="ModelEditorToolbar",this.editedId=e.objectId,this.initialize(),this.toolBarDom(e.isGisEdit)}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedModelId(e){super.setEditedObjectId(e)}getEditedModelId(){return super.getEditedObjectId()}setEditedModel(e){const t=jn({viewer:this.viewer,modelId:e,layerId:e});super.setEditedObjectId(t),this.editedId=e}getEditedModel(){return this.editedId}setEditedModels(e){const t=jn({viewer:this.viewer,ids:e,layerIds:e});super.setEditedObjectId(t),this.editedId=e}getEditedModels(){return this.editedId}show(){super.show()}hide(){super.hide()}exit(){super.exit(),CLOUD.GlobalData.GTAO=this.enableGTAO}setRotationController(e){super.setRotationController(e)}getRotationController(){return super.getRotationController()}setTranslationController(e){super.setTranslationController(e)}getTranslationController(){return super.getTranslationController()}setScaleController(e){super.setScaleController(e)}getScaleController(){return super.getScaleController()}setEditingMode(e){super.setEditingMode(e)}getEditingMode(){return super.getEditingMode()}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}initialize(){super.initialize(),this.objectEditorManager=new On(this.viewer,"Model"),this.objectEditorManager.setEditedObjectId(this.objectId),this.enableGTAO=CLOUD.GlobalData.GTAO,!0===this.enableGTAO&&(CLOUD.GlobalData.GTAO=!1)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor");let i=Object.freeze({ModelTransformStart:"ModelTransformStart",ModelTransforming:"ModelTransforming",ModelTransformEnd:"ModelTransformEnd",Exit:"Exit",EditingModeChanged:"EditingModeChanged"});t.ModelEditorToolbarEvent=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").loadersConfig=function(){return{"3DS":{loaderName:"TDSLoader",loaderFiles:["TDSLoader.js"]},FBX:{loaderName:"FBXLoader",loaderFiles:["fflate.min.js","FBXLoader.js"]},OBJ:{loaderName:"OBJLoader",loaderFiles:["OBJLoader.js"]},MTL:{loaderName:"MTLLoader",loaderFiles:["MTLLoader.js"]}}},function(){var t="Bimface.Plugins.ExternalObject.ExternalObjectManager",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.HttpRequest,o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject");o.ExternalObjectManager=class{constructor(n){if(i.send(t,"bf_c_extObjMng_new"),n._plugins&&n._plugins.externalObjectManager)return n._plugins.externalObjectManager;n._plugins&&(n._plugins.externalObjectManager=this),this._viewer=n,n.externalComponentManager&&!n.externalComponentManager.isDestroyed()||(n.externalComponentManager=new CLOUD.ExternalComponentManager(n.getViewer()),n.externalComponentManager._objects={}),this._manager=n.externalComponentManager,this._objects=this._manager._objects,this.modelId="ExternalComponent";let o=new e.Web.Lang.EventManager;return this.getEventManager=function(){return o},this._sceneScale=n.globalUnitUtil.translateVector(new THREE.Vector3(1,1,1)),this._scaledIdMap={},this.urlMap={},n.externalObjectManager=this,this.enableLight=!1,this.console=new e.Web.Common.Console,S(this),this}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}addObject(e,n,o){return i.send(t,"bf_c_extObjMng_addObj"),console.warn("[BIMFACE WARN]: ExternalObjectManager.addObject(name, object, modelId) is obsolete, please use ExternalObjectManager.loadObject(option, successCallback, failureCallback) instead."),this._addObject(e,n,o)}_isBuildInGeometry(t){return t instanceof e.Bimface.Plugins.Geometry.SplineCurve||t instanceof e.Bimface.Plugins.Geometry.SpatialPlane||t instanceof e.Bimface.Plugins.Geometry.Plane||t instanceof e.Bimface.Plugins.Geometry.Pipe||t instanceof e.Bimface.Plugins.Geometry.Band||t instanceof e.Bimface.Plugins.Geometry.PlaneBufferGeometry}_addObject(t,i,n,o){if(i.viewer||(i.viewer=this._viewer),!this.getObjectIdByName(t)){if(!this.enableLight){let e=i.children.filter((e=>"AmbientLight"!==e.type));i.children=e}this._isBuildInGeometry(i)&&(i=i._rebuild?i._rebuild(this._viewer):i);var s=e.Web.Lang.Utility.UUID.createUUID();return this._manager.addNode(s,i),this._objects[s]=t,this._viewer.getViewer().render(),"Viewer3D"===this._viewer.getViewerType()&&this._manager.bindModel(s,n||i._modelId||this._viewer.getDefaultModel().modelId,o),this._isBuildInGeometry(i)||!1===i._externalNeedScale?this._scaledIdMap[s]=!1:(this.scale(s,this._sceneScale),this._scaledIdMap[s]=!0),s}console.warn(`[ExternalObjectManager.addObject] 已有名为 "${t}" 的ExternalObject,请更换名称后再执行ExternalObjectManager.addObject()`)}_isNameRepeated(e,t){const i=this.urlMap[e].optionList;for(const e of i)if(e.name===t)return!0;return!1}addObjectByUrl(e,t,i,n,o){console.warn("[BIMFACE WARN]: ExternalObjectManager.addObjectByUrl(name, objectUrl, callback, modelId) is obsolete, please use ExternalObjectManager.loadObject(option, successCallback, failureCallback) instead."),this.loadObject({name:e,url:{objectUrl:t.url,mtlUrl:t.mtlUrl},association:{modelId:n}},i,o)}loadObject(t,i,o){const s=t.name,r=t.url,a=r&&r.objectUrl;if(!s||!a&&!t.object)return console.warn("[BIMFACE WARN]: option.name and (option.url.objectUrl or option.object) must not be undefined"),void(o&&o());void 0!==t.enableLight&&(this.enableLight=t.enableLight);const l=t.association&&t.association.modelId,h=t.association&&t.association.objectId;let 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,1==this._scaledIdMap[t]?(this.scale(n,this._sceneScale),this._scaledIdMap[n]=!0):this._scaledIdMap[n]=!1,n}getObjectIdByName(e){for(var t in this._objects)if(this._objects[t]===e)return t}overrideColor(e,n){i.send(t,"overrideColor");const o=this._viewer.getViewer().getFilter(),s={color:parseInt(n.getHEX(),16),opacity:n.getAlpha()};e.all?o.addToOverrideListByConditions([],s,this.modelId):(e.ids&&o.addToOverrideListByColor(e.ids,s,this.modelId),e.objectData&&o.addToOverrideListByConditions(e.objectData,s,this.modelId))}restoreColor(e){i.send(t,"restoreColor"),e.all?this._viewer.getViewer().getFilter().addToOverrideListByConditions([],null,this.modelId):(e.ids&&this._viewer.getViewer().getFilter().addToOverrideListByColor(e.ids,null,this.modelId),e.objectData&&this._viewer.getViewer().getFilter().addToOverrideListByConditions(e.objectData,null,this.modelId))}getAllObjectIds(){return Object.keys(this._objects)}removeById(e){if(this._objects[e]){this.clearRelationshipById(e),this.removeGlowEffectById([e]),this._manager.removeNodeById(e),delete this._objects[e];const t=this._getCloneOriginUrlById(e);void 0!==t&&delete this.urlMap[t],this._viewer.getViewer().render()}}removeByIds(e){this.removeGlowEffectById(e);for(var t=0;t0&&this.removeGlowEffectById(e),this._manager.clearNodes(),this._objects={},this._manager._objects={},this.urlMap={},this.relationshipsMap=null,this._viewer.getViewer().render()}hide(e){if(!CLOUD.Utils.isDefined(e))return;const t=this._manager.getFilter();if(!CLOUD.Utils.isDefined(t))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return void t.hideAll();let i=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(t.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0!==i.length&&t.hideByIds(i)}show(e){if(!CLOUD.Utils.isDefined(e))return;const t=this._manager.getFilter();if(!CLOUD.Utils.isDefined(t))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return void t.showAll();let i=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(t.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0!==i.length&&t.showByIds(i)}select(e){let t=this._viewer.getViewer();if(!CLOUD.Utils.isDefined(e))return;const i=this._manager.getFilter();if(!CLOUD.Utils.isDefined(i))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return t.addToSelection(this.getAllObjectIds(),this.modelId),void t.render();let n=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),n=n.concat(i.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(n=n.concat(e.ids)),n=Array.from(new Set(n)),0!==n.length&&(t.addToSelection(n,this.modelId),t.render())}removeSelection(e){let t=this._viewer.getViewer();if(!CLOUD.Utils.isDefined(e))return;const i=this._manager.getFilter();if(!CLOUD.Utils.isDefined(i))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return t.clearSelection(),void t.render();let n=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),n=n.concat(i.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(n=n.concat(e.ids)),n=Array.from(new Set(n)),0!==n.length&&(t.removeFromSelection(n,this.modelId),t.render())}convert(e,t){!1!==t&&(t=!0);const i=c.assertType(e,"obj")&&e.modelId?`${e.modelId}_${e.objectId}`:e;let n=this._viewer.getExternalObjectConverter().convertToExternalObject(i,e,t);return n._externalNeedScale=!1,n}_fireTransformedEvent(t){this.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ExternalObjectTransformed,t,this.getPosition(t)),this._viewer.getViewer().updateGlowEffect(this.modelId,t),this._viewer.updateSceneBoundingBox(!1)}translate(e,t){let i=new THREE.Vector3(t.x,t.y,t.z);i.multiply(new THREE.Vector3(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z));let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateTransform(e,i))),this._manager.setAccumulateTransform(e,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}_getMatrixWorld(e){return(new THREE.Matrix4).fromArray(this.getTransformation(e))}rotateOnBasePoint(e,t,i,n){t=this._viewer.globalUnitUtil.translateVector(t),i=new THREE.Vector3(i.x,i.y,i.z);const o=this.relationshipsMap&&this.relationshipsMap.get(e);let s,r,a;o&&o.father&&(s=this._getMatrixWorld(o.father),r=s.clone().invert());const l=this._getMatrixWorld(e);if(a=l.clone().invert(),s){this._manager.applyTransformMatrix(e,l.clone().multiply(r),!0);const n=this._getMatrixWorld(e).clone().invert();t.applyMatrix4(n),i=new THREE.Vector4(i.x,i.y,i.z,0).applyMatrix4(n),i=new THREE.Vector3(i.x,i.y,i.z).normalize()}if(this._manager.rotateOnBasePoint(e,t,i,n),s){const t=this._getMatrixWorld(e);this._manager.applyTransformMatrix(e,t.clone().multiply(s),!0)}((e,t,i)=>{let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>{const n=this._getMatrixWorld(e),o=i.clone().multiply(t.clone().multiply(n));this._manager.applyTransformMatrix(e,o,!0)}))})(e,a,this._getMatrixWorld(e)),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}scaleOnBasePoint(e,t,i){t=this._viewer.globalUnitUtil.translateVector(t),this._manager.scaleOnBasePoint(e,t,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}getBoundingBoxById(e){return this._viewer.globalUnitUtil.revertBBox(this._manager.getBoundingBoxById(e))}_getValid3dParam(e){if("[object Object]"===Object.prototype.toString.call(e)&&e.hasOwnProperty("x")&&e.hasOwnProperty("y")&&e.hasOwnProperty("z"))return new THREE.Vector3(e.x,e.y,e.z)}setPosition(e,t){var i=this._getValid3dParam(t);i&&(i.applyMatrix4((new THREE.Matrix4).makeScale(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z)),this._manager.setTransform(e,i,void 0,void 0,void 0,!0),this._viewer.getViewer().render(),this._fireTransformedEvent(e))}getPosition(e){var t=this._manager.getGroupTransform(e);if(t&&t.position){var i=t.position;return this._viewer.globalUnitUtil.revertTranslate({x:i.x,y:i.y,z:i.z},["x","y","z"])}}offset(e,t){var i=this._getValid3dParam(this._viewer.globalUnitUtil.translate(t,["x","y","z"]));if(!i)return;let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateOffset(e,i))),this._manager.setAccumulateOffset(e,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}offsetX(e,t){this.offset(e,{x:t,y:0,z:0})}offsetY(e,t){this.offset(e,{x:0,y:t,z:0})}offsetZ(e,t){this.offset(e,{x:0,y:0,z:t})}rotate(e,t){var i=this._getValid3dParam(t);if(!i)return;let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateTransform(e,void 0,void 0,i))),this._manager.setAccumulateTransform(e,void 0,void 0,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}rotateX(e,t){this.rotate(e,{x:t,y:0,z:0})}rotateY(e,t){this.rotate(e,{x:0,y:t,z:0})}rotateZ(e,t){this.rotate(e,{x:0,y:0,z:t})}setRotationX(e,t,i){let n=new THREE.Vector3(1,0,0);this.rotateOnBasePoint(e,t,n,i)}setRotationY(e,t,i){let n=new THREE.Vector3(0,1,0);this.rotateOnBasePoint(e,t,n,i)}setRotationZ(e,t,i){let n=new THREE.Vector3(0,0,1);this.rotateOnBasePoint(e,t,n,i)}scale(e,t){var i=this._getValid3dParam(t);i&&0!==i.x&&0!==i.y&&0!==i.z&&(this._manager.setAccumulateTransform(e,void 0,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e))}scaleX(e,t){this.scale(e,{x:t,y:1,z:1})}scaleY(e,t){this.scale(e,{x:1,y:t,z:1})}scaleZ(e,t){this.scale(e,{x:1,y:1,z:t})}getTransformation(e){if(!this._manager._hasObjectId(e))return;const[t]=this._manager.meshes[e];if(t){const i=t.matrix.clone();return 1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(1/this._sceneScale.x,1/this._sceneScale.y,1/this._sceneScale.z)),i.elements[12]*=1/this._sceneScale.x,i.elements[13]*=1/this._sceneScale.y,i.elements[14]*=1/this._sceneScale.z,c.limitTransformationDecimal(i.elements)}}setTransformation(e,t){if(!this._manager._hasObjectId(e))return;if(["[object Float32Array]","[object Array]"].indexOf(Object.prototype.toString.call(t))<0)return;const i=new THREE.Matrix4;i.fromArray(t),1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z)),i.elements[12]*=this._sceneScale.x,i.elements[13]*=this._sceneScale.y,i.elements[14]*=this._sceneScale.z,this._manager.applyTransformMatrix(e,i,!0),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}setGlowEffectById(n,o){i.send(t,"setGlowEffectById");var s=new THREE.Color("#11DAB7"),r="body",a=.3,l=3,h=!1;null!=o&&(null!=o.type&&(r=o.type),null!=o.color&&o.color instanceof e.Web.Graphics.Color&&(s=new THREE.Color(o.color.red/255,o.color.green/255,o.color.blue/255)),null!=o.intensity&&(a=o.intensity),null!=o.spread&&(l=o.spread),null!=o.isGis&&(h=o.isGis)),this._viewer.getViewer().setGlowEffectById(this.modelId,n,{color:s,type:r,intensity:a,spread:l,isGis:h}),this._viewer.render()}removeGlowEffectById(e){if(i.send(t,"removeGlowEffectById"),null==e||0==e.length)return void console.warn("没有发光效果被删除。");this._viewer.getViewer().removeGlowEffectById(this.modelId,e),this._viewer.render()}clearGlowEffect(){i.send(t,"clearGlowEffect"),this._viewer.getViewer().removeGlowEffectById(this.modelId),this._viewer.render()}getAnimations(e){return this._manager.getAnimations(e)}play(e,t){if(!this.isAnimatable(e))return void console.warn("there is no animation in the mesh");if(!c.assertType(t,"obj")){t={index:t||0}}const i=!1===t.loop?THREE.LoopOnce:THREE.LoopRepeat;this._manager.play(e,{...t,loop:i})}pause(e){this._manager.pause(e)}stop(e){this._manager.stop(e)}isAnimatable(e){return this._manager.isAnimation(e)}getObjectByName(e){const t=this.getAllObjects(),i=this.getObjectIdByName(e);return t.find((e=>e.name===i))}removeByName(e){let t=this.getObjectIdByName(e);this.removeById(t)}getAllObjects(){return this._manager.getAllMeshes()}setObjectData(e,t){if(Array.isArray(t)){let i={};t.forEach((e=>{i=Object.assign({},i,e)})),this._manager.setObjectData(e,i)}else this._manager.setObjectData(e,t)}getObjectData(e){return this._manager.getObjectData(e)}_getCloneOriginUrlById(e){for(const t in this.urlMap)if(this.urlMap[t].originId===e)return t}toLocalPosition(e,t){if(3===arguments.length){console.warn("[BIMFACE WARN]: ExternalObjectManager.toLocalPosition(id, worldPosition, worldVector) is obsolete, please use ExternalObjectManager.toLocalPosition(id, option) instead.");const t=arguments[1]&&this._viewer.globalUnitUtil.translate(arguments[1],["x","y","z"]),i=arguments[2]&&this._viewer.globalUnitUtil.translate(arguments[2],["x","y","z"]);if(!this._manager._hasObjectId(e))return;const n=this._manager.getTransform(e),o=(new THREE.Matrix4).compose(n.position,n.rotate,n.scale).clone().invert();let s,r;if(t){s=new THREE.Vector3(t.x,t.y,t.z).applyMatrix4(o).toArray()}if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(o),r=r.normalize().toArray()}return{localPosition:s,localVector:r}}let{worldPosition:i,worldVector:n}=t;if(i&&(i=this._viewer.globalUnitUtil.translate(i,["x","y","z"])),n&&(n=this._viewer.globalUnitUtil.translate(n,["x","y","z"])),!this._manager._hasObjectId(e))return;const o=this._manager.getTransform(e),s=(new THREE.Matrix4).compose(o.position,o.rotate,o.scale).clone().invert();let r,a;if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(s),r={x:r.x,y:r.y,z:r.z}}if(n){a=new THREE.Vector4(n.x,n.y,n.z,0).applyMatrix4(s),a.normalize(),a={x:a.x,y:a.y,z:a.z}}return{localPosition:r,localVector:a}}toWorldPosition(e,t){if(3===arguments.length){console.warn("[BIMFACE WARN]: ExternalObjectManager.toWorldPosition(id, localPosition, localVector) is obsolete, please use ExternalObjectManager.toWorldPosition(id, option) instead.");const t=arguments[1],i=arguments[2];if(!this._manager._hasObjectId(e))return;const n=this._manager.getTransform(e),o=(new THREE.Matrix4).compose(n.position,n.rotate,n.scale);let s,r;if(t){const e=new THREE.Vector3(t.x,t.y,t.z);s=this._viewer.globalUnitUtil.revertTranslate(e.applyMatrix4(o).toArray())}if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(o),r=r.normalize().toArray()}return{worldPosition:s,worldVector:r}}const{localPosition:i,localVector:n}=t;if(!this._manager._hasObjectId(e))return;const o=this._manager.getTransform(e),s=(new THREE.Matrix4).compose(o.position,o.rotate,o.scale);let r,a;if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(s),r=this._viewer.globalUnitUtil.revertTranslate({x:r.x,y:r.y,z:r.z},["x","y","z"])}if(n){a=new THREE.Vector4(n.x,n.y,n.z,0).applyMatrix4(s),a.normalize(),a={x:a.x,y:a.y,z:a.z}}return{worldPosition:r,worldVector:a}}setHierarchy(e){return this.temporaryMap=new Map,this.isCorrectRelationships=!0,this.getTemporaryMap(null,e.id,e.children),this.isCorrectRelationships?this.relationshipsMap?this.checkLegal()?(this.combineMap(),!0):(this.console.warn("The hierarchical structure was wrong due to the duplication of objects in different hierarchies."),!1):(this.relationshipsMap=this.temporaryMap,!0):(this.console.warn("The hierarchical structure was wrong due to the duplication of objects in different hierarchies."),!1)}getTemporaryMap(e,t,i){if(!this.isCorrectRelationships)return;let n=[];for(let e=0;e0)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-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-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;e0&&(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:{},ids:null}};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").ExternalObjectEditorToolbarEvent={Exit:"Exit",EditingModeChanged:"EditingModeChanged"};var Xn,Yn,Zn,$n,qn;!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 Wn{constructor(e){t.send("Bimface.Plugins.ExternalObject","ExternalObjectEditorToolbar"),e.objectId=e.id||e.ids,super(e),this.name="ExternalObjectEditorToolbar",this.initialize(),this.toolBarDom(),S(this)}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedExternalObjectId(e){super.setEditedObjectId(e)}getEditedExternalObjectId(){return super.getEditedObjectId()}setEditedExternalObjectIds(e){super.setEditedObjectId(e)}getEditedExternalObjectIds(){return super.getEditedObjectId()}show(){super.show()}hide(){super.hide()}exit(){super.exit()}setRotationController(e){super.setRotationController(e)}getRotationController(){return super.getRotationController()}setTranslationController(e){super.setTranslationController(e)}getTranslationController(){return super.getTranslationController()}setScaleController(e){super.setScaleController(e)}getScaleController(){return super.getScaleController()}setEditingMode(e){super.setEditingMode(e)}getEditingMode(){return super.getEditingMode()}initialize(){super.initialize(),this.objectEditorManager=new On(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,S(this),!0!==e.hasInitialized&&this.initialize()}initialize(){let e=this;"singleMode"===this.viewer3D._data.modelType&&this.getRooms((function(t){let i=JSON.parse(t);for(const t of i)e.mapRoomId[t.id]=!0,e.mapRoomBbox[t.id]=(new THREE.Box3).setFromPoints([t.bboxMin,t.bboxMax])}))}getRooms(e){const t=this;this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager.getRooms((function(i){if(e)if(i&&i.length&&i[0].annotationPosition){const n=JSON.parse(JSON.stringify(i));i=t.viewer3D.globalUnitUtil.revertTranslate(t.viewer3D.globalUnitUtil.revertTranslate(i,["x","y","z","perimeter","area"]),["area"]);for(let e=0;e0))return;i=this.viewer3D.createBoundary(1==t.length&&t[0]||t)}else i=t;if(!i)return void console.warn("The custom room data is not standard");o.offset=this.viewer3D.globalUnitUtil.revertTranslate(o.offset),i.offsetZ-=o.offset[0],this.viewer3D.createRoomByOffset(i,o.offset,e,o.faceColor,o.frameColor,!1),this.viewer3D.render();let s={id:e,unit:"m2",value:null},r=this._getRoomBoundaryById(e);"m"===this.viewer3D.getDefaultUnit()?s.value=Math.abs(THREE.ShapeUtils.area(r)):s.value=Math.abs(THREE.ShapeUtils.area(r))/1e6}else console.warn(`Input room id ${e} is not exist.`)}enableDepthTest(e,t){const i=this.viewer3D.getViewer();CLOUD.ExtrudeBodyManager.getInstance(i).enableDepthTest(e,t)}getModelComponentIds(){if(this.allComponentIds&&"ViewerGIS"!==this.viewer3D.viewerType)return this.allComponentIds;let e=this.viewer3D.getViewer();return this.allComponentIds=e.getAllModelUserIds(),this.allComponentIds}getComponentsByRoomId(e,t,i,n){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let o=this;this.getRoomBoundary(e,(function(t){let i=JSON.parse(t);i.hasOwnProperty("loops")&&(i=i.loops[0]);let n=[];for(const e of i)n.push({x:e[0].x,y:e[0].y});o.mapRoomBoundary[e]=n}));let s=[],r=this.getModelComponentIds();for(const n in r)for(const o of r[n]){let r=this.viewer3D.getViewer().getComponentInfoByUserId(o,n).boundingBox;this.roomContains(e,r,t,i)&&s.push(o)}n&&n(s)}getRoomsByComponentId(e,t,i,n){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let o=[],s=this.viewer3D.getCustomizedRoom(),r=Object.keys(s);for(let n=0;n2&&i.push(s)}let o=this.viewer3D.createBoundary(e,i);return o.offset=[...t.offset],o}return t.boundary.offset=t.offset,t.boundary}_getRoomBoundaryById(e){return this.viewer3D.getCustomizedRoom()[e]?this.getCustomizedRoom(e).roomBoundary:this.mapRoomBoundary[e]}isRoomContainBoundingBoxByZ(e,t,i){let n=this.getRoomBoundingBoxById(e),o=n.min.z,s=n.max.z,r=t.max.z,a=t.min.z,l=this.tolerence;if(i==this.toleranceType.STRICT)return a>=o-l&&r<=s+l;if(i==this.toleranceType.ORDINARY){let e=(a+r)/2;return this.isBetween(e,o,s)&&(this.isBetween(a,o,s)||this.isBetween(r,o,s))}return i==this.toleranceType.LENIENT?a<=s+l&&r>=o-l:void 0}setTopHeightByRoomId(e,t){let i=this.getCustomizedRoom(e);if(i){let n=this.viewer3D.getCustomizedRoom()[e];this.viewer3D.clearRoomsById([e],!1);let o=[];for(let e=0;e=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);o=this.viewer3D.globalUnitUtil.revertTranslate(o,["x","y","z"]);let s=[],r=CLOUD.ExtrudeBodyManager.getInstance(this.viewer3D.getViewer()).getBindedModelId(e);for(let e=0;e=3:i==this.toleranceType.LENIENT&&(l=a>=1),l}isBetween(e,t,i){let n=this.tolerence;return e<=i+n&&e>=t-n}toFivePos(e){let t=[];return t.push(new THREE.Vector2(e.min.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.max.y)),t.push(new THREE.Vector2(e.min.x,e.max.y)),t.push(new THREE.Vector2((e.min.x+e.max.x)/2,(e.min.y+e.max.y)/2)),t}containsInBoundary(e,t,i){let n=!1;for(let i=0;is!=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.xMath.max(t.y,i.y)||e.y0){let e=[];for(let t=0;tthis.containsInBoundary(e,t,i))))return!1;let a=Number(e.z.toFixed(10)),l=this.getRoomBoundingBoxById(t),h=Number(l.min.z.toFixed(10)),c=Number(l.max.z.toFixed(10));return i?a>h&&a=h&&a<=c}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation").RoomConfig=function(){return{viewer:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");let n=Object.freeze({Saved:"Saved",Cancelled:"Cancelled"});t.RoomEditorToolbarEvent=n,i.RoomEditorToolbarEvent=n}(),function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation");var o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Application.UI.Button");let s=e.Bimface.Plugins.SpatialRelation.RoomEditorToolbarEvent;class r{constructor(i){t.send("Bimface.Plugins.SpatialRelation","RoomEditorToolbar"),this.id="RoomEditorToolbar",this.viewer=i.viewer,this.roomId=i.roomId,this.databagId=i.viewer._data.databagId,this.eventManager=new e.Web.Lang.EventManager,S(this),this.initialize(),this.toolBarDom()}initialize(){const t=e.Bimface.Plugins.RoomEditing,i=new t.RoomEidtorConfig;i.viewer=this.viewer,i.roomId=this.roomId,i.roomEditorToolBar=this,this.roomEditor=new t.RoomEditor(i),this.roomEditor.onEnter(),this.registerRoomEditorEvents()}toolBarDom(){const t=this;let n=[];const o=i.create("div","bf-roomEditorToolbar");if(t.domElement=o,void 0===this.switchToolbar){var r=e.Bimface.UI.Toolbar.ToolbarConfig();r.className="bf-toolbar bf-toolbar-roomEditor",r.element=o,r.buttons=["RoomEditingDrag","RoomEditingAdd","RoomEditingDelete","RoomEditingHeight"],this.viewer.getDomElement().appendChild(o),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(r),n.push(this.switchToolbar)}let a=e.Bimface.UI.Control.ControlEvent,l=this.switchToolbar.getControls();this.uncheckOthers("Drag",l);let h=["Pick","Add","Delete","Height"];for(let e=0;e${BimfaceLanguage.bf_panel_roomEdit_insufficientNode}`,t.deletionErrorTips=new e.Bimface.UI.Tips.Tips(i)}t.deletionErrorTips.show()}));let i=this.viewer.getDomElement();this.viewer.addEventListener("RoomEditorAddEnter",(function(){i.addClass("roomEditor-addtion")})),this.viewer.addEventListener("RoomEditorAddExit",(function(){i.removeClass("roomEditor-addtion")})),this.viewer.addEventListener("RoomEditorDeleteEnter",(function(){i.addClass("roomEditor-deletion")})),this.viewer.addEventListener("RoomEditorDeleteExit",(function(){i.removeClass("roomEditor-deletion")}))}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}show(){this.roomToolbar.show(),this.switchToolbar.show()}hide(){this.roomEditor.setBimfaceUIVisibility(!0),this.roomToolbar.hide(),this.switchToolbar.hide()}update(){if(!0!==this.roomEditor.checkIntersect())this.hide(),this.roomEditor.onExit();else{if(!this.intersectTips){const t=new e.Bimface.UI.Tips.TipsConfig;t.element=this.viewer.getDomElement(),t.className="bf-tips bf-roomEditor-tips",t.timeOut=3e3,t.html=`
${BimfaceLanguage.bf_panel_roomEdit_selfIntersection}
`,this.intersectTips=new e.Bimface.UI.Tips.Tips(t)}this.intersectTips.show()}}exit(){this.hide(),this.roomEditor.onExit(!0)}}n.RoomEditorToolbar=r,o.RoomEditorToolbar=r}(),Xn=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation"),Yn=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms"),Zn=function(){return{viewer:null,roomId:null,app:null}},Xn.RoomEditorToolbarConfig=Zn,Yn.RoomEditorToolbarConfig=Zn;class Kn{}Kn.loadThirdPartyByName=function(e,t){const i=Glodon.Web.Lang.Utility.HttpRequest,n=window.BimfaceLoaderConfig.fullStaticHost,o=Kn.libraryConfig(),s=[],r=o[e]&&o[e].loaderFiles;void 0!==r?(r.map((e=>{s.push(`${n}/lib/${e}`)})),i.getScripts(s,(()=>{t&&t()}))):console.warn("The thirdParty not found")},Kn.libraryConfig=function(){return{Video:{loaderName:"Video",loaderFiles:["video.min.js"]},clipper:{loaderName:"clipper",loaderFiles:["clipper.js"]},interactions:{loaderName:"interactions",loaderFiles:["interactions.js"]},html2canvas:{loaderName:"html2canvas",loaderFiles:["html2canvas.min.js"]}}},function(){e.Bimface.Data.StatisticsDataManager.getInstance();const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids");class n{constructor(t){this.console=new e.Web.Common.Console,this.validConfig(t)?(this.id="SolidToolbar",t.roomId=t.sectionId,t.floor=t.floorId,this._config=t,this._viewer=t.viewer,this._modelId=t.modelId,this._floorId=t.floorId,this._height=t.height,this._unit=t.unit,this._roomId=t.sectionId,this._controlId=t.controlId,this.eventManager=new e.Web.Lang.EventManager,this._defaultContextMenuDisplay=t.viewer._opt.enableToggleContextMenuDisplay,this.eventManager.addEvent(i.SolidToolbarEvent.Saved,(()=>requestAnimationFrame((()=>this._viewer.toggleContextMenuDisplay(this._defaultContextMenuDisplay))))),S(this)):this.console.warn("初始化参数错误")}validConfig(e){return!!e.viewer&&(!!e.floorId&&(!!e.name&&(!!e.sectionId&&!!e.conditions)))}setCamera(){this._viewer.getViewer().setHomeView(0),this._viewer.getViewer().setHomeView(1),this._viewer.setCameraType("OrthographicCamera"),this._viewer.getModels().map((e=>e.isolateComponentsById([void 0],"MakeOthersTranslucent"))),this._viewer.enableSnap(!0)}initialize(){if(this._initialized)return;const n=this;this.setCamera();const o=document.createElement("div","bf-solidToolbar");n.domElement=o;const s=e.Bimface.UI.Toolbar.ToolbarConfig();s.id="SolidToolbar",s.className="bf-toolbar bf-solidToolbar",s.element=o;this._viewer.getDomElement().appendChild(o),this.drawToolbar=new e.Bimface.UI.Toolbar.Toolbar(s),[].push(this.drawToolbar),this._viewer.getModel(this._modelId).getAreas((o=>{const s=o.find((e=>e.id==n._floorId));s&&(null==n._config.height&&(s.height?n._config.height=s.height:n._config.height="Millimeter"==n._viewer.getGlobalUnit()?3e3:3),n._config.elevation="Millimeter"==n._viewer.getGlobalUnit()?s.elevation/1e3:s.elevation),n.loadScripts().then((()=>{n.solidDrawTool=new e.Bimface.Interactions.Separation(n._config),n.solidDrawTool.addEventListener("DrawFinished",(()=>{n.destroyToolbar(),n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().solidToolbar=n,n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)})),n.solidDrawTool.addEventListener("EditCompleted",(()=>{n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)})),n._initialized=!0,n.getEventManager().fireEvent(i.SolidToolbarEvent.Initialized),n._viewer.toggleContextMenuDisplay(!1)}));const r=e.Bimface.UI.Button.ButtonConfig();r.className="bf-draw-rectangle gld-bimface gld-bf-nrectangle",r.title="绘制矩形";const a=new e.Bimface.UI.Button.ToggleButton(r);a.addEventListener("Click",(function(){a.isChecked()&&(n.solidDrawTool.type=0,h.setCheckedState(!1),n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.drawPolyLineTool&&n.solidDrawTool.drawPolyLineTool.exit(),n.solidDrawTool.drawRectangle())})),n.drawToolbar.addControl(a);const l=e.Bimface.UI.Button.ButtonConfig();l.className="bf-draw-polyline gld-bimface gld-bf-polygon",l.title="绘制多段线";const h=new e.Bimface.UI.Button.ToggleButton(l);h.addEventListener("Click",(function(){h.isChecked()&&(n.solidDrawTool.type=0,a.setCheckedState(!1),n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.drawRectangleTool&&(n.solidDrawTool.drawRectangleTool.exit(),delete n.solidDrawTool.drawRectangleTool),n.solidDrawTool.drawPolyLine())})),n.drawToolbar.addControl(h);const c=new e.Bimface.Application.UI.Button.DividerLine;n.drawToolbar.addControl(c);const d=t.create("label","bf-grid-container"),u=document.createElement("input");u.type="checkbox",u.className="bf-checkbox-input",u.checked="checked",d.appendChild(u);const g=document.createElement("span");g.className="grid-text",g.innerText="轴网",d.appendChild(g),d.addEventListener("change",(function(){u.checked?n._viewer.getModel(n._modelId).showAxisGridsByFloor(n._config.fileId,n._floorId):n._viewer.getModel(n._modelId).removeAllAxisGrids()})),n.drawToolbar.element.appendChild(d)}))}loadScripts(){if(n._scriptsLoaded)return Promise.resolve();const e=new Promise((e=>{Kn.loadThirdPartyByName("interactions",e)})),t=new Promise((e=>{Kn.loadThirdPartyByName("clipper",e)}));return new Promise((i=>{Promise.all([e,t]).then((()=>{n._scriptsLoaded=!0,i()}))}))}cancelDraw(){this.solidDrawTool.drawPolyLineTool&&this.solidDrawTool.drawPolyLineTool.exit(),this.solidDrawTool.drawRectangleTool&&this.solidDrawTool.drawRectangleTool.exit(),this._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),this._viewer.enableSnap(!1)}getToolbar(){return this}getSolidSeparation(){return this.solidDrawTool}edit(){if(this.setCamera(),!this.drawToolbar){const t=this._viewer.getModel(this._modelId).getRoomManager().getRoomById(this._roomId);if(!this.solidDrawTool){const n=this;return void this.loadScripts().then((()=>{n.solidDrawTool=new e.Bimface.Interactions.Separation(n._config),n.solidDrawTool.room=t,t.solidToolbar=n,n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.edit(),n._initialized=!0,n.getEventManager().fireEvent(i.SolidToolbarEvent.Initialized),n._viewer.toggleContextMenuDisplay(!1),n.solidDrawTool.addEventListener("EditCompleted",(()=>{n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)}))}))}this.solidDrawTool.room=t,t.solidToolbar=this}this._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),this.solidDrawTool.edit()}cancelEdit(){const t=this._viewer.getModel(this._modelId).getRoomManager();t&&t.showRoomsById([this._roomId]),this._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),this.solidDrawTool.editPolygon&&this.solidDrawTool.editPolygon.exit(),this._viewer.enableSnap(!1)}hide(){this.drawToolbar.hide()}show(){this.drawToolbar.show()}destroyToolbar(){this.drawToolbar.destroy()}hideContent(){this.drawToolbar.hide(),this.solidDrawTool.hide()}showContent(){this.drawToolbar.show(),this.solidDrawTool.show()}exitSection(){this._viewer._sectionPlane&&this._viewer._sectionPlane.exit(),this.cancelDraw(),this.cancelEdit(),this._viewer.toggleContextMenuDisplay(this._defaultContextMenuDisplay)}getSolid(){return this.solidDrawTool.getRoom()}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}destroy(){this.exitSection(),this.drawToolbar=null,this.console=null,this._config=null,this._viewer=null,this.eventManager=null,this.domElement&&this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement)}}i.SolidToolbar=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids").SolidToolbarConfig=function(){return{controlId:null,viewer:null,modelId:null,floor:null,height:null,name:null,sectionId:null,fileId:null,unit:null,roomColor:null,frameColor:null,enableAxisGrids:!0,overlapType:"plus"}},$n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids"),qn=Object.freeze({Saved:"Saved",Deleted:"Deleted",Initialized:"Initialized"}),$n.SolidToolbarEvent=qn,function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers"));i.MEPTopologyHelper=class{constructor(e){t.send("Bimface.Plugins.RevitHelpers","MEPTopologyHelper"),this.databagId=e.viewer._data.databagId,this.modelType=e.viewer._data.modelType,this.viewer=e.viewer,S(this)}_findNetworkById(t,i){var n,o,s=this;s._FILEID_CACHE!=s.fileId&&(s._API_CACHE=null),"integrateModel"==s.modelType?(n=`${u.resourceHost}/${s.databagId}/metadata/${s.fileId}/mepsystem.json`,o=`metadata/${s.fileId}/mepsystem.json`,s._FILEID_CACHE=s.fileId):(n=`${u.resourceHost}/${s.databagId}/metadata/mepsystem.json`,o="metadata/mepsystem.json"),s._API_CACHE?s._getNetwork(t,s._API_CACHE,(function(e){i(e)})):e.Web.Lang.Utility.HttpRequest.ajax({url:"Local"!=s.viewer._data.dataEnvType?e.Web.Lang.Utility.HttpRequest.getUrl({url:n,path:o,APIHost:s.viewer._opt.APIHost,loadMode:s.viewer._data.loadMode,fileId:s.viewer._data.modelId,viewToken:s.viewer._data.viewToken,modelType:s.viewer._data.modelType}):n,success:function(e){var n=JSON.parse(e);s._API_CACHE=n,s._getNetwork(t,n,(function(e){i(e)}))}})}_getNetwork(e,t,i){var n=this;n._NETWORK_LENGTH=0,t.systems.map((function(o,s){o.network[e]&&(n._NETWORK_LENGTH++,i(o.network)),s==t.systems.length-1&&0==n._NETWORK_LENGTH&&console.log("此ID不存在于Network中")}))}_transform(e){let t=[];for(let i in e)/^__STEP/.test(i)||(t[t.length]={type:i,id:e[i]});return t}_walk(e,t,i,n){let o="up"===i?"flowFrom":"flowInto",s=[t];for(;s.length;){let t=s.pop(),i=e[t];if(!i)continue;i.id=t,n(i,e);let r=i[o];r&&[].push.apply(s,[...r].reverse())}}_BFSwalk(e,t,i,n){let o="up"===i?"flowFrom":"flowInto",s=[t];for(;0!==s.length;){let t=s.shift(),i=e[t];i&&(i.id=t,n(i,i[o],e),[].push.apply(s,i[o]))}}_deduplicate(e){return e.map((function(e){return e.reduce((function(e,t,i){return i%2==0?-1===e.indexOf(t)&&e.push(t):/\d+/.test(e[e.length-1])||e.push(t),e}),[])}))}_formatToObj(e){var t,i=this,n={};return e.forEach((function(e){e.forEach((function(e,o){if(o%2==0)t=e,n[e]||(n[e]=[]);else{let o;o="integrateModel"==i.modelType?`${i.fileId}.${e}`:e,-1===n[t].indexOf(o)&&n[t].push(o)}}))})),n}_formatNewData(e,t){let i;for(let t in e){if(-1!=Object.keys(e[t]).indexOf("flowFrom")){i=e;break}{let n=[],o=[];e[t].neighbours.map((e=>{"bidirectional"!==e.direction&&("in"===e.direction?n.push(e.id):o.push(e.id))})),Object.assign(e[t],{flowFrom:n},{flowInto:o}),i=e}}return i}getDownstreamComponentsById(e,t){const i=this;"integrateModel"==i.modelType&&(i.fileId=e.split(".")[0],e=e.split(".")[1]),i._findNetworkById(e,(n=>{if(!n)return t();let o=i._formatNewData(n),s={};i._BFSwalk(o,e,"down",(function(t){t.id!==e&&("integrateModel"==i.modelType&&(t.id=`${i.fileId}.${t.id}`),s[t.type]?s[t.type].push(t.id):s[t.type]=[t.id])})),t(i._transform(s))}))}getConnectedComponentsById(e,t){var i=this;"integrateModel"==i.modelType&&(i.fileId=e.split(".")[0],e=e.split(".")[1]),i._findNetworkById(e,(n=>{if(!n)return t();let o=i._formatNewData(n),s={up:{routes:[[]]},down:{routes:[[]]}};["up","down"].forEach((t=>this._walk(o,e,t,(function(i,n){let o=s[t].routes,r=o.length-1;if("末端"===o[r].slice(-2,-1)[0]){if("末端"===i.type)return o[o.length]=o[r].slice(0,-1).concat(i.id);{let e=i["up"===t?"flowInto":"flowFrom"][0];o[o.length]=o[r].slice(0,o[r].indexOf(e)+1),r++}}e!=i.id&&(o[r].push(i.type),o[r].push(i.id))}))));let r=i._deduplicate(s.up.routes),a=i._deduplicate(s.down.routes),l=this._transform(i._formatToObj(r)),h=this._transform(i._formatToObj(a));t({up:l,down:h})}))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers").MEPTopologyHelperConfig=function(){return{viewer:null}},function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers");class n{constructor(e,i){t.send("Bimface.Plugins.RevitHelpers","DrawingView"),this.viewer3D=e,this.drawingViews=i,this.activeViewId=null,this.activeDrawingView=null,this.viewPoint=null,this.planTranslation=null,this.linkFileTranslation=new THREE.Vector3}activeViewById(e){this.activeViewId=e;for(const e of this.drawingViews)if(e.id==this.activeViewId){this.activeDrawingView=e;let t=e.viewPoint.origin;this.coordViewPoint=new THREE.Vector3(t[0],t[1],t[2])}}formatViewMatrix(e){let t=this.activeDrawingView.viewPoint.rightDirection,i=this.activeDrawingView.viewPoint.upDirection,n=new THREE.Vector3(t[0],t[1],t[2]),o=new THREE.Vector3(i[0],i[1],i[2]);e=null==e?new THREE.Vector3:e;let s=new THREE.Matrix4;return s.makeBasis(n,o,e),s}update(e,t){this.makeTranslation(e,t),"FloorPlan"==this.activeDrawingView.viewType?this.rotateFloorPlan(e):this.rotateElevation(e)}makeTranslation(e,t){let i=this.activeDrawingView.viewPoint.viewDirection,n=new THREE.Vector3(i[0],i[1],i[2]).multiplyScalar(t),o=this.planTranslation,s=this.linkFileTranslation;e.translateX(o.x+s.x+n.x),e.translateY(o.y+s.y+n.y),e.translateZ(o.z+s.z+n.z)}rotateFloorPlan(e){let t=this.activeDrawingView.viewPoint.upDirection,i=new THREE.Vector3(t[0],t[1],t[2]),n=new THREE.Vector3(0,1,0).angleTo(i);new THREE.Vector3(0,1,0).cross(i).length()>0&&(n=-n),e.rotateZ(n),e.updateMatrixWorld()}rotateElevation(e){let t=this.activeDrawingView.viewPoint.viewDirection,i=new THREE.Vector3(t[0],t[1],t[2]),n=i.angleTo(new THREE.Vector3(0,-1,0));i.cross(new THREE.Vector3(0,-1,0)).z>0&&(n=-n),e.rotateX(Math.PI/2),e.rotateY(n),e.updateMatrixWorld()}getOutline3D(){let e=this.activeDrawingView.outline,t=this.activeDrawingView.viewPoint.scale,i=this.activeDrawingView.elevation,n=new THREE.Vector3(e[0]*t,e[1]*t,0),o=new THREE.Vector3(e[0]*t,e[3]*t,0),s=new THREE.Vector3(e[2]*t,e[3]*t,0),r=new THREE.Vector3(e[2]*t,e[1]*t,0),a=this.formatViewMatrix(),l=n.applyMatrix4(a),h=o.applyMatrix4(a),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),m=new THREE.Vector3(g/2,u/2,i);return new THREE.Box3(p,m)}setLinkFileTranslation(e){this.linkFileTranslation.x=e.elements[12],this.linkFileTranslation.y=e.elements[13],this.linkFileTranslation.z=e.elements[14]}}n.toObject=function(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n instanceof Array&&(t[i]={x:n[0],y:n[1],z:n[2]})}return t},i.DrawingView=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Snap").SnapConfig=function(){return{id:null,color:new e.Web.Graphics.Color(249,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),objectColor:new e.Web.Graphics.Color(17,218,183,.9),width:3,radius:25,viewer:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Snap"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){this.viewer=t.viewer,this.maxPointsNum=1;var n=new e.Web.Graphics.Color(17,218,183,.2);let o=new e.Web.Graphics.Color(17,218,183,1);var s=i.createNS("circle","bf-snap-handle");s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();const r=i.createNS("rect","bf-snap-handle");r.setAttribute("width",14),r.setAttribute("height",14),r.setAttribute("fill","none"),r.setAttribute("stroke",o.getRGB()),r.setAttribute("stroke-width",2);const a=i.createNS("path","bf-snap-handle");a.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),a.setAttribute("fill","none"),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",2);const l=i.createNS("line","bf-snap-handle");l.setAttribute("x1",0),l.setAttribute("y1",0),l.setAttribute("x2",14),l.setAttribute("y2",14),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("line","bf-snap-handle");h.setAttribute("x1",14),h.setAttribute("y1",0),h.setAttribute("x2",0),h.setAttribute("y2",14),h.setAttribute("stroke",n.getRGB()),h.setAttribute("stroke-width",2);var c=i.createNS("line","bf-snap-line");c.style.strokeWidth=2,c.style.stroke=n.getRGB();var d=i.createNS("polygon","bf-snap-rect");d.setAttribute("fill",n.getRGBA()),d.setAttribute("stroke",n.getRGB()),d.setAttribute("stroke-width",1),this.hoverLine=c,this.hoverPoint=s,this.hoverEndPoint=r,this.hoverMidPoint=a,this.hoverIntersectionPointA=l,this.hoverIntersectionPointB=h,this.hoverPanel=d,this.hoverPanelSize={width:20,height:20}};n.prototype=Object.assign(n.prototype,{stretchOnDirection:function(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){var t=this.hoverLine,i=this.hoverPoint;const n=this.hoverEndPoint,o=this.hoverMidPoint,s=this.hoverIntersectionPointA,r=this.hoverIntersectionPointB,a=e.hoverPosition&&e.hoverPosition.x,l=e.hoverPosition&&e.hoverPosition.y;var h=this.hoverPanel,c=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":i.setAttribute("cx",e.hoverPosition.x),i.setAttribute("cy",e.hoverPosition.y),e.svg.appendChild(i);break;case"EndPoint":n.setAttribute("x",a-7),n.setAttribute("y",l-7),e.svg.appendChild(n);break;case"MidPoint":o.setAttribute("d",`M ${a} ${l-7} L ${a+8} ${l+8} L ${a-8} ${l+8} L ${a} ${l-7}`),e.svg.appendChild(o);break;case"IntersectionPoint":s.setAttribute("x1",a-7),s.setAttribute("y1",l-7),s.setAttribute("x2",a+7),s.setAttribute("y2",l+7),e.svg.appendChild(s),r.setAttribute("x1",a+7),r.setAttribute("y1",l-7),r.setAttribute("x2",a-7),r.setAttribute("y2",l+7),e.svg.appendChild(r);break;case"Line":t.setAttribute("x1",e.lineStartPoint.x),t.setAttribute("y1",e.lineStartPoint.y),t.setAttribute("x2",e.lineEndPoint.x),t.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(t);break;case"Panel":var d=e.clientPts,u=d[0].distanceTo(d[1]),g=d[0].distanceTo(d[3]),p=u/c.width,m=g/c.height;if(1!=p){var f=this.stretchOnDirection(d[0],d[1],c.width),w=this.stretchOnDirection(d[2],d[3],c.width);d=f.concat(w)}if(1!=m){f=this.stretchOnDirection(d[0],d[3],c.height),w=this.stretchOnDirection(d[1],d[2],c.height);d=[f[0],w[0],w[1],f[1]]}for(var v="",y=0;y{e.setSelectedComponentsById()}));var r=i.createNS("svg","bf-snap-svg");o.rootDomElement.innerHTML="",o.rootDomElement.appendChild(r),o.svg=r;var a=new e.Bimface.Plugins.Snap.SnapItem(t);n.snapItem=a,s.render()},snapByPoint:function(e){n=e.pickPoint?e.pickPoint:null;let t=this.snapMode?this.snapMode.getSnap3DList():["line","face","endpoint","midpoint","intersection"];if(e.pointType&&t.includes({EndPoint:"endpoint",MidPoint:"midpoint",IntersectionPoint:"intersection"}[e.pointType])?s=e.pointType:e.pickPlane&&t.includes("face")?(s="Panel",r=e.normal):e.pickLine&&t.includes("line")?(s="Line",o=e.pickLine):s=null,!this.isNeedSnap(e))return this.context.pickPoint=n,this.context.hoverPosition=n,void(this.context.hoverObjectType=s);this.update()},isNeedSnap:function(e){if(!this.snapMode)return!0;let t=this.snapMode.getSnap3DList(),i="face",n="line",o="endpoint",s="midpoint",r="intersection",a=!1,l=!1,h=!1,c=!1;e.pointType&&(l=t.includes(o)||t.includes(s)||t.includes(r)),e.pickPlane&&(h=t.includes(i)),e.pickLine&&(c=t.includes(n)),a=l||h||c;let d=this.snapMode.getSnapCondition(),u=this._opt.viewer.getViewer().getUserdataByUserId(e.userId),g=this.isMatchConditions(u,d.objectData),p=!0,m=!0;if("ViewerGIS"==this._opt.viewer.getViewerType())if(e.modelId){let t=this._opt.viewer.getModel(e.modelId)._layer.id;d.layerIds&&d.layerIds.length>0&&d.layerIds.indexOf(t)<0&&(p=!1)}else p=!1;"Viewer3D"==this._opt.viewer.getViewerType()&&d.modelIds&&d.modelIds.length>0&&d.modelIds.indexOf(e.modelId)<0&&(m=!1);let f=a&&g&&p&&m;return f||this.reset(),f},isMatchConditions:function(e,t){if(!e||!t)return!0;for(var i=!0,n=0,o=t.length;n0){e.lineStartPoint=b,e.lineEndPoint=v[E];break}}}if("Panel"==e.hoverObjectType){e.normal=l.getScene().worldToDrawing(r),e.normal.normalize();var P=l.cameraControl,M=new THREE.Plane;M.setFromNormalAndCoplanarPoint(e.normal,e.hoverPositionDS);var C=new THREE.Vector2(e.hoverPosition.x-10,e.hoverPosition.y-10),T=new THREE.Vector2(e.hoverPosition.x+10,e.hoverPosition.y-10),I=e.hoverPositionDS,S=P.getRaycaster(C.x,C.y);if(this._p1=S.ray.intersectPlane(M,this._p1),S=P.getRaycaster(T.x,T.y),this._p2=S.ray.intersectPlane(M,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var D=new THREE.Vector3(1,0,0),B=new THREE.Vector3(0,1,0),_=new THREE.Vector3(0,0,1),A=Math.abs(e.normal.clone().dot(D))<=.0025,k=Math.abs(e.normal.clone().dot(_))<=.0025;if(A&&k)var L=D.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,H=L.clone().multiplyScalar(R),O=V.clone().multiplyScalar(R),N=I.clone().sub(H).add(O),G=I.clone().add(H).add(O),U=I.clone().sub(H).sub(O),z=I.clone().add(H).sub(O),F=[];F.push(N,G,z,U);for(var W=[],j=P.getContainerDimensions(),X=0;X{delete this._walkthroughMap[e]}))}setWalkthroughList(t){if("[object Object]"===Object.prototype.toString.call(t)){var i=t.coordinate;t.data.forEach((t=>{var n=new e.Bimface.Plugins.Walkthrough.WalkthroughConfig;n.viewer=this._viewer;var o=new e.Bimface.Plugins.Walkthrough.Walkthrough(n),s=t.coordinateSystem||i;"world"===s&&t.keyFrames.forEach((e=>{e.coordinateSystem=s})),o.setKeyFrames(t.keyFrames),o.setWalkthroughTime(t.time),o._walkthrough.setName(t.name),this._walkthroughMap[t.id]={id:t.id,walkthrough:o}}))}}getWalkthroughList(){var e={data:[],version:1};for(var t in this._walkthroughMap){var i={id:t},n=this._walkthroughMap[t].walkthrough;i.keyFrames=n.getKeyFrames(),i.keyFrames.forEach((e=>{delete e.coordinateSystem})),i.name=n._walkthrough.getName(),i.time=n._walkthrough.walkthroughTime,i.coordinateSystem="world",e.data.push(i)}return e}exportVideo(e,i){t.send("Bimface.Plugins.Walkthrough.WalkthroughManager","exportVideo");const n=this,o=this._walkthroughMap[e],s=this._viewer.getViewer().getRenderer().domElement;let r=document.createElement("canvas");r.width=s.width,r.height=s.height;let a=r.getContext("2d"),l=null==this._viewer._opt.backgroundColor.direction?this._viewer._opt.backgroundColorDirection:this._viewer._opt.backgroundColor.direction;0==l&&(l=2*Math.PI);const h=(e,t,i)=>{let n=2*Math.PI,o=i;for(;o<-Math.PI;)o+=n;for(;o>Math.PI;)o-=n;let s,r=Math.atan2(t,e),a=Math.tan(o);s=o>-r&&o<=r?1:o>r&&o<=Math.PI-r?2:o>Math.PI-r||o<=-(Math.PI-r)?3:4;let l={x:e/2,y:t/2},h=e/2,c=t/2;switch(s){case 1:l.x=e,l.y=c-e/2*a;break;case 2:l.x=h+t/(2*a),l.y=0;break;case 3:l.x=0,l.y=c+e/2*a;break;case 4:l.x=h-t/(2*a),l.y=t}return{x:l.x,y:l.y,region:s}},c=(e=>{const t=1.5*Math.PI-e;return{theta:t,revTheta:t+Math.PI}})(l);let d=h(r.width,r.height,c.theta),u=h(r.width,r.height,c.revTheta);Math.abs(d.x-u.x)<.01&&(d.x=0,u.x=0),Math.abs(d.xy-u.y)<.01&&(d.y=0,u.y=0);const g=a.createLinearGradient(d.x,d.y,u.x,u.y);o.walkthrough.stop(),o.walkthrough.play(),o.walkthrough.setDisableAnimation(!0);const p=this._viewer._opt.backgroundColor.colors||this._viewer._opt.backgroundColor,m=()=>{a&&(a.clearRect(0,0,r.width,r.height),p.map((e=>{const t=`#${(e.color||e).red.toString(16).padStart(2,"0")}${(e.color||e).green.toString(16).padStart(2,"0")}${(e.color||e).blue.toString(16).padStart(2,"0")}`,i=e.stop?parseInt(e.stop.split("%")[0])/100:0;g.addColorStop(i,t)})),a.fillStyle=g,a.fillRect(0,0,r.width,r.height),a.drawImage(s,0,0),requestAnimationFrame(m))};requestAnimationFrame(m);const f=r.captureStream();this.mediaRecorder=new MediaRecorder(f,{videoBitsPerSecond:85e5,mimeType:"video/webm; codecs=h264"});const w=[];this.mediaRecorder.ondataavailable=e=>{w.push(e.data)},this.mediaRecorder.onstop=()=>{const e=new Blob(w,{type:"video/webm"});i&&i(e),r=null,a=null,n._viewer.render()},this.mediaRecorder.start();const v=o.walkthrough._stopCallback;o.walkthrough.stopCallback((()=>{n.mediaRecorder&&"inactive"!=n.mediaRecorder.state&&(n.mediaRecorder.stop(),delete n.mediaRecorder),v&&v(),o.walkthrough.setDisableAnimation(!1)}))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").NorthArrowConfig=function(){return{domElement:null,viewer:null,right:10,top:10}};class Jn{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 Qn{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),tn.minPitch&&t-a>n.minPitch&&"bf-northarrow-pitchdown"===this.className.baseVal)t-=a,s=!0;else{if(!(t{o=!1},mouseover:function(){this.firstElementChild.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.firstElementChild.setAttribute("filter",""),o=!1},dblclick:function(){if("bf-northarrow-pitchup"===this.className.baseVal){let o=e.getYawPitch();i=o.yaw,t=o.pitch;let r=Math.PI/200;const a=()=>{t=-t,t>n.maxPitch&&(t=n.maxPitch),t{switch(/bf-northarrow-pan(.*)/.exec(this.className.baseVal)[1]){case"up":e.panInDirection(!0);break;case"down":e.panInDirection(!1);break;case"left":e.panInHorizontal(!0);break;case"right":e.panInHorizontal(!1)}t&&requestAnimationFrame(i)};i()},mouseup:()=>{t=!1},mouseover:function(){this.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.setAttribute("filter",""),t=!1}};for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}class to{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(),S(this)}init(){this.drawElements((()=>{this.addDomElementEvents(),this.northArrowYaw=new Jn(this.elements.yaw,this.domElement,this._camera),this.northArrowPitch=new Qn({pitchUp:this.elements.pitchUp,pitchDown:this.elements.pitchDown},this._camera),this.northArrowZoom=new to({zoomIn:this.elements.zoomIn,zoomOut:this.elements.zoomOut},this._camera),this.northArrowPan=new eo({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 \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n N\n \n \n\n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',this.elements={},["pitchUp","pitchDown","yaw","panUp","panDown","panLeft","panRight","zoomIn","zoomOut"].forEach((e=>{const t=this.domElement.querySelector(`.bf-northarrow-${e.toLowerCase()}`);this.elements[e]=t})),e()}addDomElementEvents(){this.domElementEvents={mouseover:()=>{this.elements.pitchUp.style.opacity=1,this.elements.pitchDown.style.opacity=1},mouseout:()=>{this.elements.pitchUp.style.opacity=0,this.elements.pitchDown.style.opacity=0},mousedown:e=>(e.stopPropagation(),!1)},this.domElementEvents.mousemove=this.domElementEvents.mouseup=this.domElementEvents.mousedown,this.domElementEvents.mouseout();for(let e in this.domElementEvents)this.domElement.addEventListener(e,this.domElementEvents[e])}addRenderCallback(){this.renderCallback=()=>{this.northArrowYaw&&this.northArrowYaw.update()},this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){if(this.domElement&&this.domElementEvents)for(let e in this.domElementEvents)this.domElement.removeEventListener(e,this.domElementEvents[e]);this.northArrowYaw&&this.northArrowYaw.destroy(),this.northArrowPitch&&this.northArrowPitch.destroy(),this.northArrowPan&&this.northArrowPan.destroy(),this.northArrowZoom&&this.northArrowZoom.destroy(),this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}setLimitPitch(e=null,t=null){this.northArrowPitch.minPitch=null!=e?e:-Math.PI/2,this.northArrowPitch.maxPitch=null!=t?t:Math.PI/2}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").ScaleBarConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.performance,o=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7];t.ScaleBar=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-scale");n.style.bottom=`${e.bottom}px`,n.style.right=`${e.right}px`,t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,this.lastUpdateTime=Date.now(),this.enableScale=!0,this._value=void 0,S(this),this.init()}init(){this.drawElements((()=>{this.addRenderCallback()}))}drawElements(e){this.domElement.innerHTML='\n \n \n \n \n \n ',this.barElement=this.domElement.querySelector(".bf-scale-bar"),this.labelElement=this.domElement.querySelector(".bf-scale-label"),this.domElement.style.display="none",e()}addRenderCallback(){this.renderCallback=n.throttleAndDebounce((()=>{if(this.enableScale&&!this._opt.viewer._isDestroyed){var e=this._opt.viewer.getViewer().camera,t=this._opt.viewer.getViewer().getViewportSize();if(e.position.y<0)this.domElement.style.display="none";else{var i=new THREE.Vector3(t.width/2,t.height-1),n=new THREE.Vector3(t.width/2+1,t.height-1),s=this._opt.viewer.getViewer().pickByPoint(i,!0,!1),r=this._opt.viewer.getViewer().pickByPoint(n,!0,!1);if(s&&r&&s.worldPosition&&r.worldPosition){var a=s.worldPosition.distanceTo(r.worldPosition);if(this._pixelDistance=a,a<0)this.domElement.style.display="none";else{for(var l,h=o.length-1;!l&&h>=0;--h)o[h]/a<=120&&(l=o[h]);if(l){var c;this._value=l,c=l>=1e3?(l/1e3).toString()+"km":l.toString()+"m",this.labelElement.textContent=c;var d=this.labelElement.getBoundingClientRect().width||43;this.labelElement.setAttribute("x",70-d/2),this.labelElement.setAttribute("y",23);var u=l/a,g="M"+(70-u/2).toString()+" 20 L"+(70-u/2).toString()+" 28 L"+(70+u/2).toString()+" 28 L"+(70+u/2).toString()+" 20";this.barElement.setAttribute("d",g),this.domElement.style.display="block"}else this._value=void 0,this._pixelDistance=void 0,this.domElement.style.display="none"}}else this.domElement.style.display="none"}}}),500),this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enableScale=!0}hide(){this.domElement.style.display="none",this.enableScale=!1}isVisible(){return this.enableScale}getValue(){return this._pixelDistance}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").InfoBarConfig=function(){return{domElement:null,viewer:null,right:0,bottom:0}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.performance;t.InfoBar=class{constructor(e){this._opt=e;const t=e.domElement,o=i.create("div","bf-infobar");o.style.bottom=`${e.bottom}px`,o.style.right=`${e.right}px`,o.style.display="none",t.appendChild(o),this.domElement=o,this.enable=!0,this._info={},this._inited=!1,this.isMouseClicked=!1,S(this);this._mousemoveCallback=n.throttleAndDebounce((e=>{if(!this.enable)return;if(this.isMouseClicked)return;let t=this._opt.viewer.getViewer().pickByPoint(e,!1,!1);if(!t)return;let i=t.worldPosition,n=i.z,{lat:o,lon:s}=this._opt.viewer.worldToLatLon(i);this._info={latitude:o,longtitude:s,altitude:n};let r=`${o.toFixed(6)}${o>=0?"N":"S"}  ${s.toFixed(6)}${s>=0?"E":"W"}  ${"-0.000"===n.toFixed(3)?"0.000":n.toFixed(3)}m`;this.domElement.innerHTML=r,this._inited||(this.domElement.style.display="block",this._inited=!0)}),250),this._mousedownCallback=()=>{this.isMouseClicked=!0},this._mouseupCallback=()=>{this.isMouseClicked=!1},this.init()}init(){this._opt.domElement.addEventListener("mousedown",this._mousedownCallback),this._opt.domElement.addEventListener("mouseup",this._mouseupCallback),this._opt.domElement.addEventListener("mousemove",this._mousemoveCallback)}destroy(){this._opt.domElement.removeEventListener("mousemove",this._mousemoveCallback),this._opt.domElement.removeEventListener("mousedown",this._mousedownCallback),this._opt.domElement.removeEventListener("mouseup",this._mouseupCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enable=!0}hide(){this.domElement.style.display="none",this.enable=!1}isVisible(){return this.enable}getValue(){return this._info}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").CreditConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.Credit=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div",`bf-credit ${e.class||""}`);t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,S(this)}drawElements(){const{credit:t,text:i,link:n,copyright:o}=this._opt;if(t===e.Bimface.Common.Credit.None)this.domElement.innerHTML="";else this.domElement.innerHTML=`\n \n `}destroy(){this._opt.domElement.removeChild(this.domElement)}update(e){this._opt=Object.assign({},this._opt,e),this.drawElements()}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search").SearchConfig=function(){return{wrapElement:null,viewer:null}},function(){var t="Bimface.Plugins.Search",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t;if(this._opt=i,this.clear(),!i.viewer)return console.log("viewer is not defined."),!1;let n=new e.Web.Lang.EventManager;this.getEventManager=function(){return n},this.buttonIcon=o.create("div","bf-button gld-bf-search bf-search-btn"),this.element=o.create("div","bf-search-toolbar bf-hide"),i.wrapElement.appendChild(this.buttonIcon),i.wrapElement.appendChild(this.element),this.init()};s.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},clickSearch(e){const t=this._opt.viewer,i=this.element.querySelector("input").value;return""==i?(this.clear(),void this.update(e)):i===this._data.text?this.clickArrow(!0,e):void t.search({text:i},(t=>{this._data.index=t.length>0?1:0;let n=this.formatResult(t);this._data.all=n.length,this._data.result=n,this._data.text=i,this.hasData=!!this._data.result.length,this._opt.UI.getPanel("MobileLayoutListPanel")&&n.length>0&&this._opt.UI.getPanel("MobileLayoutListPanel").updateStatusByDataType(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(e),this._data.index&&this.zoomToBbox(n[this._data.index-1])}))},clickArrow(e,t){const i=e?this._data.index+1:this._data.index-1,n=this._data.result;this._opt.UI;n.length>0&&(this._data.index=e?i>n.length?1:i:i>0&&i||n.length,this._opt.UI.getPanel("MobileLayoutListPanel")&&n.length>0&&this._opt.UI.getPanel("MobileLayoutListPanel").updateStatusByDataType(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(t),this.zoomToBbox(n[this._data.index-1]))},init:function(){i.send(t,"init"),document.addEventListener("keyup",(e=>{e&&13==e.keyCode&&this.element.querySelector("input")==document.activeElement&&this.clickSearch(!0)})),this.element.addEventListener("click",(e=>{let t=e.target;t.hasClass("bf-search")?this.clickSearch():t.hasClass("gld-bf-arrowup")?this.clickArrow():t.hasClass("gld-bf-arrowdown")&&this.clickArrow(!0)})),this.buttonIcon.addEventListener("click",(e=>{this.buttonIcon.addClass("bf-hide"),this.element.removeClass("bf-hide"),this.update(!0);let t=this._opt.UI.getToolbar("LeftSubToolbar");t&&(t.getControl("MobileLayoutList").setCheckedState(!1),t.getControl("MobileLayoutList").hide())})),this.update()},formatResult(e){let t=[];for(let i=0;i\n \n \n
\n \n
\n \n
\n \n
\n ${this._data.index}/${this._data.all}\n
\n
\n
\n `;const n=this.element.querySelector(".bf-search-back");n&&n.addEventListener("click",(e=>{this.element.querySelector("input").value="",this.buttonIcon.removeClass("bf-hide"),this.element.addClass("bf-hide"),this.clear();let t=this._opt.UI.getToolbar("LeftSubToolbar");t&&t.getControl("MobileLayoutList").show()}));let o=this.element.querySelector("input");if(e){o.focus();const e=this._data.text;o.value="",o.value=e}o.addEventListener("input",(e=>{this.updateClearBtn(o.value)}));this.element.querySelector(".bf-right-btns .bf-clear").addEventListener("click",(()=>{o.value="",this.clear(),this.updateClearBtn(),this.updateCountRow()})),this.updateCountRow()},clear:function(){this._data={index:0,all:0,text:"",result:[]},this.hasData=!!this._data.result.length},updateClearBtn(e){const t=this.element.querySelector(".bf-right-btns .bf-clear"),i=this.element.querySelector(".bf-right-btns .bf-line");e?(t.removeClass("bf-hidden"),i.removeClass("bf-hidden")):(t.addClass("bf-hidden"),i.addClass("bf-hidden"))},updateCountRow(){const e=this.element.querySelector(".count-wrapper");this.hasData?e.removeClass("bf-hide"):e.addClass("bf-hide")},zoomToBbox(e){const t=this._opt.viewer;t.showViewById(e.viewId),t.zoomToBoundingBox(e.boundingBox)},destroy(){this._opt=null,this.element=null,this._data=null}},n.MobileSearch=s}(),function(){var t="Bimface.Plugins.Search",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t;if(this._opt=i,this.clear(),!i.viewer)return console.log("viewer is not defined."),!1;let n=new e.Web.Lang.EventManager;this.getEventManager=function(){return n},this.element=o.create("div","bf-search-toolbar"),this.searchPanel=o.create("ul","bf-search-panel"),this.searchPanel.id="bf-search-panel",i.wrapElement.appendChild(this.element),i.wrapElement.appendChild(this.searchPanel),this.init()};s.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},clickSearch(e){const t=this._opt.viewer,i=this.element.querySelector("input").value;return""==i?(this.clear(),this.searchPanel.innerHTML="",void this.update(e)):i===this._data.text?this.clickArrow(!0,e):void t.search({text:i},(t=>{this._data.index=t.length>0?1:0;let n=this.formatResult(t);this._data.all=n.length,this._data.result=n,this._data.text=i,this._opt.UI.getToolbar("LeftSubToolbar")&&n.length>0&&this._opt.UI.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(e),this._data.index&&this.zoomToBbox(n[this._data.index-1])}))},clickArrow(e,t){this.searchPanel.getElementsByClassName("bf-search-result-content").length>0&&(this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#ccc");const i=e?this._data.index+1:this._data.index-1,n=this._data.result,o=this._opt.UI;n.length>0&&(this._data.index=e?i>n.length?1:i:i>0&&i||n.length,o.getToolbar("LeftSubToolbar")&&o.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(t),this.zoomToBbox(n[this._data.index-1]))},clickSearchPanel(e){if(void 0!==e){this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#ccc",this._data.index=e;let t=this._data.result;this._opt.UI.getToolbar("LeftSubToolbar")&&t.length>0&&this._opt.UI.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==t[this._data.index-1].viewId?"Model":t[this._data.index-1].viewId),this.update(!0),this._data.index&&this.zoomToBbox(t[this._data.index-1])}},init:function(){i.send(t,"init"),this.onKeyup=e=>{e&&13==e.keyCode&&this.element.querySelector("input")==document.activeElement&&this.clickSearch(!0)},document.addEventListener("keyup",this.onKeyup),this.onClick=e=>{let t=e.target;t.hasClass("gld-bf-search")?this.clickSearch():t.hasClass("gld-bf-arrowup")?this.clickArrow():t.hasClass("gld-bf-arrowdown")&&this.clickArrow(!0)},this.element.addEventListener("click",this.onClick),this.onSearchPanelClick=e=>{this.clickSearchPanel(e.target.index)},this.searchPanel.addEventListener("click",this.onSearchPanelClick),this.update()},formatResult(e){let t=[],i=0;this.searchPanel.innerHTML="";for(let n=0;n
${this._data.index}/${this._data.all}
`,this.searchPanel.getElementsByClassName("bf-search-result-content").length>0&&(this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#32D3A6",this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].scrollIntoViewIfNeeded(!0)),e){let e=this.element.querySelector("input");e.focus();const t=this._data.text;e.value="",e.value=t}},clear:function(){this._data={index:0,all:0,text:"",text:"",result:[]}},zoomToBbox(e){const t=this._opt.viewer;t.showViewById(e.viewId),t.zoomToBoundingBox(e.boundingBox)},destroy:function(){document.removeEventListener("keyup",this.onKeyup),this.element&&this.element.removeEventListener("click",this.onClick),this.searchPanel&&this.searchPanel.removeEventListener("click",this.onSearchPanelClick),this._opt=null,this._data=null,this.element=null,this.searchPanel=null}},n.Search=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox").SkyBoxStyle=Object.freeze({BlueSky:"BlueSky",CloudySky:"CloudySky",DarkNight:"DarkNight",Galaxy:"Galaxy",Cosmos:"Cosmos",MoonrisePureskyDark:"MoonrisePureskyDark",MountainGround:"MountainGround",CloudPuresky:"CloudPuresky",MistyMorning:"MistyMorning",Puresky:"Puresky",SunsetPuresky:"SunsetPuresky",GreyPuresky:"GreyPuresky",OvercastPuresky:"OvercastPuresky",Customized:"Customized"}),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox");t.SkyBoxManagerConfig=class{constructor(){this.customizedImage=null,this.style=null,this.viewer=null,this.initializeVisible=!0}}}(),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=0){if(this._viewer.visualization&&this._viewer.visualization.active&&this._viewer.getModel().isBimtilesModel()&&!e.Web.Lang.Utility.ClientHelper.getIsMac()){var s=(n.dataEnvType==oo.Local?n.sdkPath:u.staticHost)+"/resources/Setting/SkyBox/"+i+".exr";this._viewer.getViewer().skyBoxMapManager.loadEquirectangularMap(s,(e=>{this._viewer.getViewer().setDeferBackground(e),this._viewer.getViewer().setRenderStateChanged(!0),this._viewer.getViewer().setDefferBackgroundRotation(new THREE.Euler(0,0,0)),this._viewer.getViewer().render()}))}return}i=this._style}if(0==o.length&&i){s=(n.dataEnvType==oo.Local?n.sdkPath:u.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),S(this)}destroy(){this._viewer.getViewer().removeGround(),this._ground=null}setElevation(e){this._ground.setElevation(this._viewer.globalUnitUtil.translate(e))}getElevation(){return this._viewer.globalUnitUtil.revertTranslate(this._ground.getElevation())}show(){console.log("This function is not available now")}hide(){console.log("This function is not available now")}update(){console.log("This function is not available now")}setColor(){console.log("This function is not available now")}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AuxMobile").AuxMobileConfig=function(){return{editor:null,width:3,viewer:null}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AuxMobile"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.AuxMobile=class{constructor(e){this.viewer=e.viewer,this.touchEndCounts=0,this.editor=e.editor,this.showAuxBall=!1,this.outerCircleRadius=40,this.outerCircleFillStyle="rgba(0, 0, 0, 0.65)",this.outerCircleBorderWidth=4,this.outerCircleBorderColor="#999999",this.innerCircleRadius=20,this.innerCircleFillStyle="rgba(255, 255, 255, 0.8)",this.innerCircleBorderWidth=2,this.ballOuterCircleRadius=40,this.ballOuterCircleFillStyle="rgba(255, 255, 255, 0.3)",this.ballOuterCircleBorderWidth=1,this.ballOuterCircleBorderColor="#999999",this.ballInnerCircleRadius=20,this.ballInnerCircleFillStyle="rgba(255, 255, 255, 0.8)",this.ballInnerCircleBorderWidth=2,this.ballDirectionCircleRadius=4,this.ballDirectionCircleFillStyle="rgba(50, 211, 166, 1)",this.ballDirectionCircleBorderWidth=1,this.triangleWidth=12,this.triangleFillStyle="rgba(0, 0, 0, 0.65)",this.triangleBorderWidth=1,this.triangleBorderColor="#999999";let t=this.canvas=i.create("canvas","bf-aux-mobile"),n=this.viewer.getDomElement();t.width=n.offsetWidth,t.height=n.offsetHeight,this.ctx=t.getContext("2d"),n.append(t),this.initPos()}initPos(){let e={x:this.canvas.width/2,y:this.canvas.height/2};this.draw(this.updateAux(e))}setEditor(e){this.editor=e}updateAux(e){this.center=e;let t={outerCircle:{}};if(t.outerCircle.center=e,this.showAuxBall)t.outerCircle.radius=this.ballOuterCircleRadius,t.innerCircle={},t.innerCircle.center=e,t.innerCircle.radius=this.ballInnerCircleRadius;else{t.outerCircle.radius=this.outerCircleRadius,t.innerCircle={},t.innerCircle.center=e,t.innerCircle.radius=this.innerCircleRadius,t.triangle=[];let i={x:e.x-this.outerCircleRadius,y:e.y-this.outerCircleRadius};t.triangle.push({x:i.x,y:i.y}),t.triangle.push({x:i.x+this.triangleWidth,y:i.y}),t.triangle.push({x:i.x,y:i.y+this.triangleWidth})}return t}draw(e){let t=this.ctx;t.clearRect(0,0,this.canvas.width,this.canvas.height);let i=e.outerCircle;t.strokeStyle=this.outerCircleBorderColor,t.lineWidth=this.outerCircleBorderWidth,t.fillStyle=this.outerCircleFillStyle,t.beginPath(),t.arc(i.center.x,i.center.y,i.radius,0,2*Math.PI,!0),t.fill(),t.stroke();let n=e.innerCircle;t.fillStyle=this.innerCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,n.radius,0,2*Math.PI,!0),t.fill();let o=e.triangle;t.lineWidth=this.triangleBorderWidth,t.fillStyle=this.triangleFillStyle,t.beginPath(),t.moveTo(o[0].x,o[0].y),t.lineTo(o[1].x,o[1].y),t.lineTo(o[2].x,o[2].y),t.closePath(),t.fill(),t.stroke()}drawBall(e){let t=this.ctx;t.clearRect(0,0,this.canvas.width,this.canvas.height);let i=e.outerCircle;t.strokeStyle=this.ballOuterCircleBorderColor,t.lineWidth=this.ballOuterCircleBorderWidth,t.fillStyle=this.ballOuterCircleFillStyle,t.beginPath(),t.arc(i.center.x,i.center.y,i.radius,0,2*Math.PI,!0),t.fill(),t.stroke();let n=e.innerCircle;t.fillStyle=this.ballInnerCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,n.radius,0,2*Math.PI,!0),t.fill(),t.lineWidth=this.ballDirectionCircleBorderWidth,t.fillStyle=this.ballDirectionCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,this.ballDirectionCircleRadius,0,2*Math.PI,!0),t.fill(),t.moveTo(n.center.x-this.ballDirectionCircleRadius-3,n.center.y-this.ballDirectionCircleRadius-2),t.lineTo(n.center.x-this.ballDirectionCircleRadius-13,n.center.y),t.lineTo(n.center.x-this.ballDirectionCircleRadius-3,n.center.y+this.ballDirectionCircleRadius+2),t.closePath(),t.fill(),t.beginPath(),t.moveTo(n.center.x+this.ballDirectionCircleRadius+3,n.center.y-this.ballDirectionCircleRadius-2),t.lineTo(n.center.x+this.ballDirectionCircleRadius+13,n.center.y),t.lineTo(n.center.x+this.ballDirectionCircleRadius+3,n.center.y+this.ballDirectionCircleRadius+2),t.closePath(),t.fill()}getRealPoint(e){let t=this.canvas.getBoundingClientRect(),i=this.outerCircleRadius,n=this.outerCircleRadius;return{x:e.x-i+t.left,y:e.y-n+t.top}}getBallRealPoint(e){let t=this.outerCircleRadius,i=this.outerCircleRadius;return{x:e.x-t,y:e.y-i}}showBall(){let e=this.getBallRealPoint(this.center);this.showAuxBall=!0,this.drawBall(this.updateAux(e))}showCanvas(){this.canvas.style.display="block"}hideCanvas(){this.canvas.style.display="none"}formatPoint(e){let t=this.canvas.getBoundingClientRect();return{x:e.x-t.left,y:e.y-t.top}}onTouchStart(e,t){if(t=this.formatPoint(t),!this.touchOnAux(t))return;this.startPoint=t,e.stopImmediatePropagation(),e.preventDefault(),this.editor.touchStartCallback(t)}onTouchMove(e,t){if(t=this.formatPoint(t),!this.touchOnAux(t))return;e.stopImmediatePropagation(),e.preventDefault();let i=this.editor,n=this.updateAux({x:t.x,y:t.y});if(this.showAuxBall){this.drawBall(n);let e=this.startPoint;i.touchMoveCallback({start:e,end:t})}else{this.draw(n);let e=this.getRealPoint(t);i.touchMoveCallback(e)}}onTouchEnd(e,t,i){if(this.startPoint=null,!t)return;if(t=this.formatPoint(t),!this.touchOnAux(t))return;e.stopImmediatePropagation(),e.preventDefault();let n=this.editor;if(this.showAuxBall)n.touchEndCallback(this.center);else{let e=this.getRealPoint(t);n.touchEndCallback(e)}}vectorAngle(e,t){let i=Math.sqrt(e.reduce(((e,t)=>e+Math.pow(t,2)),0)),n=Math.sqrt(t.reduce(((e,t)=>e+Math.pow(t,2)),0));return Math.acos(e.reduce(((e,i,n)=>e+i*t[n]),0)/(i*n))}getNormal(){let e=this.viewer.getViewer().getScene();return CLOUD.FillClipPlaneManager.getInstance(e).renderClipPlane.normal}getCoordinate(){let e=this.viewer._sectionPlane.coordinateSystem,t=e.getCoordinateAxis();return{start:e.drawingToCanvas(t.start.clone()),endZ:e.drawingToCanvas(t.endZ.clone())}}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="",this.showAuxBall=!1,this.initPos()}destroy(){this.canvas.remove()}redraw(){if(this.center){let e=this.updateAux(this.center);this.draw(e)}}touchOnAux(e){const{center:t,outerCircleRadius:i,ballOuterCircleRadius:n,showAuxBall:o}=this,s=e;let r=t.x-s.x,a=t.y-s.y;return Math.sqrt(r*r+a*a)<=(o&&n||i)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClashDetective").ClashDetectivePanelConfig=class{constructor(){this.viewer=null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClashDetective"),i=e.Bimface.Data.StatisticsDataManager.getInstance();t.ClashDetectivePanel=class{constructor(t){i.send("Bimface.Plugins.ClashDetective.ClashDetectivePanel","bf_c_clashDetectivePanel_new");let n=this;if(this._console=new e.Web.Common.Console,S(this),!t)return void this._console.error("clashDetectivePanelConfig must not be empty.");if(!t.viewer||"Viewer3D"===!t.viewer.viewerType)return void this._console.error("viewer must not be empty or viewer3d.");this.clashDetectivePanelConfig=t,this.viewer=t.viewer,this.unitType=this.viewer.getUnit(),this.modelUnit=this.unitType;const o=n.viewer.getModels();o.length&&(this.modelUnit="m"===o[0]._manifest.Metadata.Unit?"Meter":"Millimeter"),this.clashResult={},this.currentIndex=0,this.hasModelA=!1,this.hasModelB=!1,this.isIntegrateA=!1,this.isIntegrateB=!1,this.transMultiplyingMap={"Millimeter-Millimeter":1,"Millimeter-Centimeter":.1,"Millimeter-Meter":.001,"Millimeter-Kilometer":1e-7,"Meter-Millimeter":1e3,"Meter-Centimeter":100,"Meter-Meter":1,"Meter-Kilometer":.001},this.bBoxBorderMap={Millimeter:2e3,Centimeter:200,Meter:2,Kilometer:.002};var s=new e.Bimface.UI.Panel.PanelConfig;s.title=BimfaceLanguage.bf_panel_clashDetective_clashDetective,s.className="bf-panel clash-detective-panel-wrapper",s.id="clashDetective";let r=e.Web.Lang.Utility.ClientHelper.getIsDesktop();s.css=r?{right:"10px",top:"10px",width:"300px",height:"416px"}:{left:0,top:0,width:"100%",height:"100%"};var a=new e.Bimface.UI.Panel.Panel(s);let l,h;a.addEventListener("Hide",(()=>{this.clearIsolation();let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item"),this.currentIndex=0})),this.clashDetectivePanel=a,this.viewer.clashDetectivePanel=a,this.makeOthersTranslucent=e.Bimface.Viewer.IsolateOption.MakeOthersTranslucent,n._updateModelName=function(e){h=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdA)),!h||e!=n.modelIdA&&e!=h.modelId||(n.modelUnit="m"===h._manifest.Metadata.Unit?"Meter":"Millimeter",n.hasModelA=!0,l=document.getElementById("cdModelAName"),l&&(l.setAttribute("class","active"),l.removeAttribute("title"),l.innerText=`${h._data.name}${n.isIntegrateA?"(集成模型)":""}`)),h=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdB)),!h||e!=n.modelIdB&&e!=h.modelId||(n.modelUnit="m"===h._manifest.Metadata.Unit?"Meter":"Millimeter",n.hasModelB=!0,l&&(l=document.getElementById("cdModelBName"),l.setAttribute("class","active"),l.removeAttribute("title"),l.innerText=`${h._data.name}${n.isIntegrateB?"(集成模型)":""}`))},this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,this._updateModelName)}setActiveItem(e,t=!1){if(e<=0||this.clashResult&&this.clashResult.results.length&&e>this.clashResult.results.length)return;if(!t){let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item")}let i=this.clashResult.results[e-1],n=document.querySelector(`#itemId_${e}`);n&&n.setAttribute("class","cd-r-list-item active"),this.currentIndex=e,(this.hasModelA||this.hasModelB)&&(this.isolateComponentsById(i),this.zoomToBoundingBox(i.position,this.unitType,this.modelUnit))}zoomToBoundingBox(e,t,i){let n=this.transformToBoundingBox(e,t,i);this.viewer.zoomToBoundingBox(n)}transformToBoundingBox(e,t,i){const n=this.viewer.getGlobalUnit()?1:this.transMultiplyingMap[`${i}-${t}`],o=this.bBoxBorderMap[t];return{max:{x:e.x*n+o,y:e.y*n+o,z:e.z*n+o},min:{x:e.x*n-o,y:e.y*n-o,z:e.z*n-o}}}destroy(){this.clashDetectivePanel.close(),this.clearIsolation(),this.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,this._updateModelName)}show(){this.clashDetectivePanel.show()}hide(){this.clashDetectivePanel.hide(),this.clearIsolation();let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item"),this.currentIndex=0}setData(e){let t=this;this.clashDetectivePanel.clear(),this.clashResult=e,this.modelIdA=e.selectionA.fileId||e.selectionA.integrateId,this.modelIdB=e.selectionB.fileId||e.selectionB.integrateId,e.selectionA.integrateId&&(this.isIntegrateA=!0),e.selectionB.integrateId&&(this.isIntegrateB=!0);let i=[],n="";e.results.forEach(((e,t)=>{n=`\n
  • \n ${BimfaceLanguage.bf_panel_clashDetective_clash_num}${t+1}:\n
    \n

    ${BimfaceLanguage.bf_panel_clashDetective_componentA}:${e.objectIdA}

    \n

    ${BimfaceLanguage.bf_panel_clashDetective_componentB}:${e.objectIdB}

    \n
    \n
  • `,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
    \n
    \n ${BimfaceLanguage.bf_panel_clashDetective_modelA}:\n \n ${o}${this.isIntegrateA?"(集成模型)":""}\n \n
    \n
    \n ${BimfaceLanguage.bf_panel_clashDetective_modelB}:\n \n ${s}${this.isIntegrateB?"(集成模型)":""}\n \n
    \n
    \n
      \n ${i.join("")}\n
    \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,S(this)}loadClashDetectiveResult(e,t){let i=this;function o(e){i._console.error(e.message)}n.ajax({url:`${i.viewer._opt.APIHost}/inside/databag?viewToken=${e}`,async:!0,success:function(s){const r=JSON.parse(s);if("success"==r.code){let s=r.data&&r.data.modelId;s&&n.ajax({url:`${i.viewer._opt.APIHost}/data/clashDetective/${s}/result?view_token=${e}`,async:!0,success:function(e){var n=JSON.parse(e);"success"==n.code?t&&t(i.viewer.globalUnitUtil.revertTranslate(n.data,["x","y","z"])):o(n)},failure:e=>{o(JSON.parse(e))}})}else o(r)},failure:e=>{o(JSON.parse(e))}})}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClearanceHeightCheck");t.ClearanceHeightCheckPanelConfig=class{constructor(){this.clearanceHeightCheckResult=null,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();let i=e.Web.Lang.Utility.HttpRequest;var n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClearanceHeightCheck");n.ClearanceHeightCheckPanel=class{constructor(i){if(t.send("Bimface.Plugins.ClearanceHeightCheck.ClearanceHeightCheckPanel","bf_clearanceHeightCheckPanel_new"),this._console=new e.Web.Common.Console,S(this),!i)return void this._console.error("clearanceHeightCheckPanelConfig must not be empty.");if(!i.viewer||"Viewer3D"===!i.viewer.viewerType)return void this._console.error("viewer must not be empty or viewer3d.");this.clearanceHeightCheckPanelConfig=i,this.viewer=i.viewer,this.checkResultData=i.clearanceHeightCheckResult,this.unitType=this.viewer.getUnit(),this.model=this.viewer.getModel(),this.clearanceComponentsList=[],this.clearanceHeightId="",this.nodeData=null;var n=new e.Bimface.UI.Panel.PanelConfig;n.title="净空分析",n.className="bf-panel clearance-heightcheck-panel-wrapper",n.id="ClearanceHeightCheck";let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();n.css=o?{right:"10px",top:"10px",width:"440px",height:"530px"}:{left:0,top:0,width:"100%",height:"100%"};var s=new e.Bimface.UI.Panel.Panel(n);s.addEventListener("Hide",(()=>{let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item"),this.nodeData&&this.nodeData.deselect(),this.clearAllRooms(),this.clearAll(),this.clearSection()})),this.clearanceHeightCheckPanel=s,this.viewer.clearanceHeightCheckPanel=s,this.checkResultData&&this.setData(this.checkResultData),this.defaultComponentsDisplayMode={mode:"default",option:{unqualifiedObjectColor:new e.Web.Graphics.Color(255,96,88,.6),qualifiedObjectColor:new e.Web.Graphics.Color(75,217,82,.6)}},this.currentComponentsDisplayMode=this.defaultComponentsDisplayMode,this.defaultRoomDisplayMode={mode:"default",option:{qualifiedRoomColor:new e.Web.Graphics.Color(255,184,0,.6),qualifiedRoomFrameColor:new e.Web.Graphics.Color(255,184,0,1),unqualifiedRoomColor:new e.Web.Graphics.Color(88,135,255,.6),unqualifiedRoomFrameColor:new e.Web.Graphics.Color(88,135,255,1)}},this.currentRoomDisplayMode=this.defaultRoomDisplayMode,this.roomManager=this.viewer.getRoomManager(),this.componentsUnit="mm"}clearSection(){this._sectionPlane&&this._sectionPlane.exit(),this._sectionPlane=null}zoomToBoundingBox(e){this.viewer.getViewer().zoomToBBox(e,.5,void 0,void 0,1e3)}zoomToArea(t,i,n,o=!1,s){this.clearSection();let r=new THREE.Vector3,a=new THREE.Vector3,l=this.viewer;if(i){let i;var h=1600,c=10;"m"===l.globalUnitUtil.getDefaultUnit()&&(h/=1e3,c/=1e3);const u=(()=>"mm"===l.globalUnitUtil.getDefaultUnit()&&!0===l.getViewer().hasBimtilesModel()?.001:"m"!==l.globalUnitUtil.getDefaultUnit()||l.getViewer().hasBimtilesModel()?1:1e3)();i=n/u+h+c,h*=u;var d=l.getCameraAnimation();l.setCameraAnimation(!1),l.setView(e.Bimface.Viewer.ViewOption.Top);let g=l.getViewer().getBoundingBoxWorld();o?this.zoomToBoundingBox(g):this.zoomToBoundingBox(t),l.setCameraAnimation(d);let p=this._sectionPlane=this.makeSectionPlane(l),m=l.getViewer().getScene().getExpandScalar(),f=(new THREE.Box3).setFromCenterAndSize(g.getCenter(r),g.getSize(a).multiplyScalar(m)),w=f.min.z,v=f.max.z;const y=l.getDefaultModel().modelId;let b=100-(i-w)/(v-w)*100;if(s){let e=CLOUD.ExtrudeBodyManager.getInstance(l.getViewer()).getNode(s);if(e){b=100-(i+e.geometry.boundingBox.clone().applyMatrix4(l.getViewer().getModelManager().getModel(y).transformMatrix).min.z-w)/(v-w)*100}}p.setPlane("Z"),p.setDirection("Forward"),p.setProgress(b),p.hidePlane(),CLOUD.GlobalData.ClippingCaps=!0,l.render()}else this.roomManager.hideAllRooms(),l.getModels().forEach((e=>{e.clearIsolation()})),this.clearSection(),l.render()}makeSectionPlane(t){let i=new e.Bimface.Plugins.Section.SectionPlaneConfig;return i.viewer=t,i.id="SectionPlane",i.plane=e.Bimface.Plugins.Section.SectionPlanePlane.Z,i.direction=e.Bimface.Plugins.Section.SectionPlaneDirection.Forward,i.exitSectionBox=!1,new e.Bimface.Plugins.Section.SectionPlane(i)}setComponentsDisplayMode(e,t){this.currentComponentsDisplayMode={mode:e,option:t}}getComponentsDisplayMode(){return this.currentComponentsDisplayMode}setRoomsDisplayMode(e,t){this.currentRoomDisplayMode={mode:e,option:t}}getRoomsDisplayMode(){return this.currentRoomDisplayMode}setActiveItem(e,t){if(e<0||this.clearanceComponentsList&&this.clearanceComponentsList.length&&e>this.clearanceComponentsList.length)return;if(this.currentIndex!==e){let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item")}let i=this.getElement().querySelector(`#clrhcItemId_${e}`);i&&i.setAttribute("class","bf-clrhc-list-item active"),this.currentIndex=e,this.zoomToObjectById(t)}zoomToObjectById(e){this.viewer.clearSelectedComponents(),this.viewer.setSelectedComponentsById([e]),this.viewer.zoomToSelectedComponents(),this.viewer.render()}isolateComponentsById(t){this.model.isolateComponentsById(t,e.Bimface.Viewer.IsolateOption.MakeOthersTranslucent),this.viewer.render()}clearIsolateComponents(){this.model.clearOverrideColorComponents(),this.model.restoreComponentsFrameColor({all:!0}),this.model.clearIsolation(),this.viewer.render()}getElement(){return this.clearanceHeightCheckPanel.element}destroy(){this.clearAll(),this.clearAllRooms(),this.clearanceHeightCheckPanel.close(),this.clearSection()}show(){this.clearanceHeightCheckPanel.show()}hide(){this.clearanceHeightCheckPanel.hide();let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item"),this.currentIndex=0}buildSpaceList(e){const t=[];return e.forEach((e=>t.push(...e.space))),t}getSpaceInfoBySpaceId(e){return this.spaceList.find((t=>t.spaceId===e))}setData(e){let t=[];this.clearanceHeightCheckPanel.clear(),this.checkResultData=e,this.clearanceHeightId=e.clearanceHeightId,e.results&&e.results.length&&(t=e.results,this.spaceList=this.buildSpaceList(t));this.clearanceHeightCheckPanel.setHtml('\n \n
    \n
    \n
    \n
    \n
    \n '),this.viewer._opt.domElement.appendChild(this.getElement()),this.viewer.getFloors((e=>{let i=this.mergeData(t,e),n=this.createTree(i);this.getElement().querySelector("#cleanranceTreeId").appendChild(n.element)})),this.clearAll()}mergeData(e,t){return e.forEach((e=>{let i=t.find((t=>e.levelId===t.id));e.name=i&&i.name||"其它",e.elevation=i.elevation})),e}getDataByPath(e,t,n,o=(()=>{})){i.ajax({url:`${this.viewer._opt.APIHost}/${e}`,type:"POST",data:JSON.stringify(t||{}),headers:{"Content-Type":"application/json"},async:!0,success:e=>{var t=JSON.parse(e);"success"==t.code||"bimfaceservice-0000"===t.code?n&&n(t.data):o(t)},failure:e=>{var t=JSON.parse(e);o(t)}})}setCleanranceRoomData(e){let t=this.viewer._data.viewToken;const i=this.model.getMetaData();let n={fileId:this.viewer._data.modelId};"integrateModel"===i.modelType&&(n={integrateId:this.viewer._data.modelId}),this.getDataByPath(`data/v1/feature-management/spaces/${e.id}/properties?view_token=${t}`,n,(i=>{this.clearAllRooms(),i&&(this.createRoomBySpacesProperties(i),this.viewer.render(),this.zoomToBoundingBox({max:i.bboxMax,min:i.bboxMin})),n={clearanceHeightId:this.clearanceHeightId,spaceId:e.id},this.getDataByPath(`data/v1/feature-management/spaces/clearance-height-check/components-results?view_token=${t}`,n,(e=>{e&&e.object&&e.object.length?(this.clearanceComponentsList=e.object,this.componentsUnit=e.unit||"mm"):this.clearanceComponentsList=[],this.showComponentsByOption(1)}))}))}showComponentsByOption(e){let t=[],i="",n="",o=this.clearanceComponentsList;e&&(o=this.clearanceComponentsList.filter((t=>2===e?t.isQualified:!t.isQualified))),this.overrideColorForComponents(o),o.forEach(((e,n)=>{i=`\n
  • \n
    \n

    构件ID${e.objectId}

    \n

    净高${e.clearanceHeight} ${this.nodeData.extData.unit}

    \n
    \n \n ${e.isQualified?"符合":"不符合"}\n \n
  • \n `,t.push(i)})),this.currentComponentsList=o;let s=0,r=0;this.nodeData.extData.clearanceHeight&&(s=this.nodeData.extData.clearanceHeight.toFixed&&this.nodeData.extData.clearanceHeight.toFixed(3)-0),this.nodeData.extData.targetHeight&&(r=this.nodeData.extData.targetHeight.toFixed&&this.nodeData.extData.targetHeight.toFixed(3)-0),n=`\n
    \n ${this.nodeData.extData.name}\n
    \n
    \n 实际净高 (${this.nodeData.extData.unit})\n ${s}\n
    \n
    \n 目标净高 (${this.nodeData.extData.unit})\n ${r}\n
    \n
    \n
    \n
    \n 净高结果\n
    \n
    \n
      \n ${t.join("")}\n
    \n `,this.getElement().querySelector("#cleanranceRoomId").innerHTML=n,this.createSelect(0===this.currentSelectOption?0:this.currentSelectOption||1);this.getElement().querySelectorAll(".bf-clrhc-list-item").forEach(((e,t)=>{e.addEventListener("click",(()=>{this.setActiveItem(t,o[t].objectId)}))}))}overrideColorForComponents(e){e.forEach((e=>{let t=this.getComponentColorsByCondition({height:e.clearanceHeight,status:e.isQualified,spaceUnit:this.componentsUnit});this.overrideColor(e.objectId,t,t)})),this.viewer.render()}overrideColor(e,t,i){this.model.overrideComponentsColorById([e],t),this.model.overrideComponentsFrameColor({ids:[e]},i)}createSelect(t){var i=new e.Bimface.UI.Select.SelectConfig;i.className="bf-select bf-select-clearance",i.options=[{id:0,name:"全部"},{id:1,name:"不符合"},{id:2,name:"符合"}];let n=new e.Bimface.UI.Select.Select(i);n.setCurrentOption(t),n.addEventListener("Change",(e=>{this.selectChange(e)})),this.getElement().querySelector("#cleanranceSelectId").appendChild(n.element)}selectChange(e){this.clearAll(),this.currentSelectOption=e.id,this.showComponentsByOption(e.id)}createTreeNode(t){if(t){var i=new e.Bimface.UI.Tree.TreeNodeConfig;if(i.isChecked=!1,i.hasCheckbox=!1,i.selection="root"!==t.type,"spaceId"===t.type){var n=new e.Bimface.UI.Button.ButtonConfig;n.className="bf-tree-icon bf-qlf-no",t.isQualified&&(n.className="bf-tree-icon bf-qlf-yes"),n.title=BimfaceLanguage.bf_panel_modelTree_transparent;var o=new e.Bimface.UI.Button.Button(n);i.icon=o}var s=new e.Bimface.UI.Tree.TreeNode(i);return s.type=t.type,s.status=t.status,s.filter=t.type,s.elevation=t.elevation,s.extData=t.space||t.spaceInfo,s.setData(`${t.id}`,t.name),s}}createTree(t){if(!t||0==t.length)return;var i=this.createTreeNode({type:"root",id:"all",name:"全部"});i.expand();var n=new e.Bimface.UI.Tree.Tree(i);let o,s;for(let e=0,n=t.length;e{this.nodeData=e,this.clearAll(!1),this.clearAllRooms(),this.clearSection(),"levelId"===e.type?(this.clearRightContent(),t&&this.createRoomForLevelId(e.id)):"spaceId"===e.type&&(this.currentSelectOption=1,t?this.setCleanranceRoomData(e):this.clearRightContent())})),n}clearAllRooms(){this.roomManager.clearAllRooms(),this.viewer.render()}createRoomForLevelId(e){let t=this.viewer._data.viewToken,i=this.buildSpaceIdListByLevelId(e);const n=this.model.getMetaData();let o={fileId:this.viewer._data.modelId,spaceIdList:i};"integrateModel"===n.modelType&&(o={integrateId:this.viewer._data.modelId,spaceIdList:i}),this.clearAll(),this.getDataByPath(`data/v1/feature-management/spaces/properties?view_token=${t}`,o,(e=>{e&&e.length&&(this.zoomToArea(null,!0,e[0].bboxMax.z,!0,null),e.forEach((e=>{this.createRoomBySpacesProperties(e)})))}))}enableDepthTest(e,t=!1){this.rooms.enableDepthTest([e],t),viewer3D.render()}clearAll(e=!0){this.clearOverrideColor(),this.currentIndex=0,e&&this.clearRightContent()}createRoomBySpacesProperties(t){let i,n,o;i=t.boundary;try{n={outer:i.outer,inner:i.inner};const s=this.getSpaceInfoBySpaceId(t.spaceId);let{roomColor:r,roomFrameColor:a}=this.getRoomColorsByCondition({height:s.clearanceHeight,status:s.isQualified,spaceUnit:s.unit});o={boundary:n,height:t.height,unit:t.unit};let l=new e.Bimface.Plugins.Rooms.RoomConfig;l.viewer=this.viewer,l.roomId=t.spaceId,l.geometry=o,l.roomColor=r,l.frameColor=a;const h=new e.Bimface.Plugins.Rooms.Room(l);this.roomManager.addRoom(h),this.viewer.render()}catch(e){console.warn(`Invalid room boundary [spaceId: ${t.spaceId}]!`)}}getComponentColorsByCondition(e){let{height:t,status:i,spaceUnit:n}=e;const o=this.getComponentsDisplayMode(),{mode:s}=o;let r;if("byStatus"===s||"default"===s)r=i?o.option.qualifiedObjectColor:o.option.unqualifiedObjectColor;else if("byHeight"===s){const e=o.option.unit;let i=o.option.colorList;t=this.viewer.globalUnitUtil.excute(t,n,e);const s=i.find((e=>t>=e.heightRange[0]&&tt>=e.heightRange[0]&&t{let t=[];e.forEach((e=>t.push([e.x-0,e.y-0,e.z-0]))),i.push(t)})):e.forEach((e=>i.push([e.x-0,e.y-0,e.z-0]))),i):i}buildSpaceIdListByLevelId(e){let t=[],i=this.checkResultData.results.find((t=>t.levelId===e));return i&&i.space&&i.space.forEach((e=>{t.push(e.spaceId)})),t}clearRightContent(){this.getElement().querySelector("#cleanranceRoomId").innerHTML='请选择对应空间'}clearOverrideColor(){this.viewer.clearSelectedComponents(),this.model.clearOverrideColorComponents(),this.model.restoreComponentsFrameColor({all:!0}),this.viewer.render()}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");t.Room=class{constructor(t){this.viewer=t.viewer,this.roomId=t.roomId,this.modelId=t.modelId,this.geometry=t.geometry,this.roomColor=t.roomColor,this.frameColor=t.frameColor,this.enableSelected=t.enableSelected,this.console=this.viewer.console,this.isValid=!0,this.unit=null,t.geometry.unit?this.unit="m"==t.geometry.unit||"Meter"==t.geometry.unit?"m":"mm":this.unit=this.viewer.globalUnitUtil.getGlobalUnit(),S(this),this.toleranceType={STRICT:"STRICT",ORDINARY:"ORDINARY",LENIENT:"LENIENT"},this.tolerence=.25;let i=this.geometry.boundary,n=this.geometry.grid,o=this.geometry.height,s=this.geometry.offset;if(i){if("String"===Object.prototype.toString.call(i).slice(8,-1)&&(i=JSON.parse(i)),i.outer){let e=[];if(i.outer.map((t=>{e.push([Number(t.x),Number(t.y),Number(t.z)])})),i.inner&&i.inner.length>0){let t=[];i.inner.map((e=>{let i=[];e.map((e=>{i.push([Number(e.x),Number(e.y),Number(e.z)])})),t.push(i)})),i=this.viewer.createBoundary(e,t)}else i=this.viewer.createBoundary(e)}}else if(n){let e=n.ids,t=n.fileId;const o=this.viewer.getViewer().getScene(),s=this.modelId||this.viewer.getDefaultModel().modelId;t&&t!=s||(t="default");const r=CLOUD.AxisGridManager.getInstance(o,s);if(!r.mapFileIdGridjson[t])return this.console.warn("createRoomByAxisGrids - 请先加载对应轴网,再调用接口."),void(this.isValid=!1);let a=r.getPartitionByAxisGrids(t,e),l=[],h=(new THREE.Matrix4).fromArray(this.viewer.getModel(s)._getModelTransformation()).invert();for(let e=0;e0))return this.console.warn("createRoomByAxisGrids - 所选轴线未形成闭合区域,或传入了多余轴线."),void(this.isValid=!1);{a.forEach((e=>{c.push([e.x,e.y,e.z])}));let e=this.viewer.createBoundary(c),t=this.viewer.globalUnitUtil.getDefaultUnit(),n=this.unit;i=this.viewer.globalUnitUtil.excute(e,t,n,["offsetZ","x","y","z"])}}if(o)o=o;else if(s&&s.length>=2){var r=s[0];o=s[1]-s[0];var a=i.clone?i.clone():JSON.parse(JSON.stringify(i));if(i.roomInnerBoundary&&(a.roomInnerBoundary=JSON.parse(JSON.stringify(i.roomInnerBoundary))),a.loops&&a.loops.length>0)for(var l=a.loops[0],h=l.length,c=0;c0){let t=[];o.map((e=>{let n=[];for(let t=0;t{t?(t.boundary&&(t.boundary=JSON.parse(t.boundary)),t=this.viewer.globalUnitUtil.revertTranslate(t,["area","x","y","z","perimeter"]),(t=this.viewer.globalUnitUtil.revertTranslate(t,["area"])).boundary=JSON.stringify(t.boundary),e&&e(t)):e&&e(t)}))}isPointInside(e,t){!1!==t&&(t=!0);let{roomBoundary:i,roomInnerBoundary:n}=this.getCustomizedRoom(),o=[],s=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId),r=this.viewer.getViewer().getModelManager().getModel(s).transformMatrix.clone(),a=new THREE.Vector3,l=new THREE.Quaternion,h=new THREE.Vector3;r.decompose(a,l,h),a=this.viewer.globalUnitUtil.revertVector(a),r.compose(a,l,h);for(let e=0;e0){let e=[];for(let t=0;tthis.containsInBoundary(e,i,t))))return!1;let c=Number(e.z.toFixed(10)),d=this.getRoomBoundingBox(),u=Number(d.min.z.toFixed(10)),g=Number(d.max.z.toFixed(10));return t?c>u&&c=u&&c<=g}setBoundary(e,t){if(!this.roomManager)return;this.roomManager.clearRoomsById([this.roomId],!1);if("String"===Object.prototype.toString.call(e).slice(8,-1)&&(e=JSON.parse(e)),e.outer){let t=[];if(e.outer.map((e=>{t.push([e.x,e.y,e.z])})),e.inner&&e.inner.length>0){let i=[];e.inner.map((e=>{let t=[];e.map((e=>{t.push([e.x,e.y,e.z])})),i.push(t)})),e=this.viewer.createBoundary(t,i)}else e=this.viewer.createBoundary(t)}t&&(this.unit="m"==t?"m":"mm",e=this.translateForUnit(e,["offsetZ","x","y","z"])),this.roomInfo.boundary=e,this.roomInfo.offset=[e.offsetZ||0,(e.offsetZ||0)+this.roomInfo.height],this.roomManager.addRoom(this),CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).applySelection(),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setHeight(e,t){if(!this.roomManager)return;this.roomManager.clearRoomsById([this.roomId],!1),t&&(this.unit="m"==t?"m":"mm",e=this.translateForUnit(e));let i=this.roomInfo.boundary.offsetZ;this.roomInfo.height=e,this.roomInfo.offset=[i||0,(i||0)+e],this.roomManager.addRoom(this),CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).applySelection(),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setRoomColor(e){var t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()),i=t.createMaterial({color:parseInt(e.getHEX(),16),transparent:!0,opacity:e.getAlpha()});this.roomInfo.faceColor=e;var n=t.createMaterial({color:parseInt(this.roomInfo.frameColor.getHEX(),16),opacity:this.roomInfo.frameColor.getAlpha()});t.setNodeMaterial(this.roomId,i,n),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setRoomFrameColor(e){var t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()),i=t.createMaterial({color:parseInt(this.roomInfo.faceColor.getHEX(),16),transparent:!0,opacity:this.roomInfo.faceColor.getAlpha()}),n=t.createMaterial({color:parseInt(e.getHEX(),16),opacity:e.getAlpha()});this.roomInfo.frameColor=e,t.setNodeMaterial(this.roomId,i,n),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}updateSolidInfo(e){const t=e?"Meter"==e.unit||"m"==e.unit?"m":"mm":this.unit?"Meter"==this.unit||"m"==this.unit?"m":"mm":"Meter"==this.viewer.globalUnitUtil.getGlobalUnit()||"m"==this.viewer.globalUnitUtil.getGlobalUnit()?"m":"mm",i={modelId:this.modelId,modelType:this.viewer.getModel(this.modelId)._data.modelType,sectionId:this.roomId,conditions:e?e.conditions:this.conditions,section:{id:this.roomId,name:e?e.name:this.name,unit:t,color:e?e.color:this.getRoomColor(),frameColor:e?e.frameColor:this.getRoomFrameColor(),geometry:{type:"extrusion",height:e?e.height:this.getHeight(),boundary:e?e.boundary:[{lineType:"Line",points:this.getBoundary().outer}]}}};this._solidInfo=i}translateForUnit(e,t){if(this.unit){let i=this.viewer.globalUnitUtil.getGlobalUnit();return this.viewer.globalUnitUtil.excute(e,this.unit,i,t)}return e}getAllComponentIds(){return this.viewer.getViewer().getAllModelUserIds()}getCustomizedRoom(){let e=this.roomInfo;if(e.boundary&&"user"!=e.boundary.belong){let t=[],i=[],n=e.boundary;for(let e=0;e2&&i.push(s)}let o=this.viewer.createBoundary(t,i);return o.offset=[o.offsetZ,o.offsetZ+e.height],o}return e.boundary.offset=e.offset,e.boundary}isContainsObjectId(e,t,i){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let n=this.viewer.globalUnitUtil.revertBBox(this.viewer.getViewer().getComponentInfoByUserId(e).boundingBox);return this.roomContains(n,t,i)}roomContains(e,t,i){let n=this.isRoomContainBoundingBoxByZ(e,i);if(0==n)return n;let o=this.isRoomBoundingBoxContainBoundingBoxByXY(e,t);if(0==o)return o;let s=this.isRoomBoundaryContainBoundingBoxByXY(e,t);return 0!=s||s}isRoomContainBoundingBoxByZ(e,t){let i=this.getRoomBoundingBox(),n=i.min.z,o=i.max.z,s=e.max.z,r=e.min.z,a=this.tolerence,l=this.viewer._opt.unit||this.viewer.getDefaultUnit();if("Meter"===this.viewer.globalUnitUtil.unitMap[l]&&(a/=1e3),t==this.toleranceType.STRICT)return r>=n-a&&s<=o+a;if(t==this.toleranceType.ORDINARY){let e=(r+s)/2;return this.isBetween(e,n,o)&&(this.isBetween(r,n,o)||this.isBetween(s,n,o))}return t==this.toleranceType.LENIENT?r<=o+a&&s>=n-a:void 0}isRoomBoundingBoxContainBoundingBoxByXY(e,t){let i=this.getRoomBoundingBox(),n=i.min.x,o=i.max.x,s=i.min.y,r=i.max.y,a=e.min.x,l=e.max.x,h=e.min.y,c=e.max.y,d=this.tolerence,u=this.viewer._opt.unit||this.viewer.getDefaultUnit();return"Meter"===this.viewer.globalUnitUtil.unitMap[u]&&(d/=1e3),t==this.toleranceType.STRICT?a>=n-d&&l<=o+d&&h>=s-d&&c<=r+d:t==this.toleranceType.ORDINARY||t==this.toleranceType.LENIENT?a<=o+d&&l>=n-d&&h<=r+d&&c>=s-d:void 0}isRoomBoundaryContainBoundingBoxByXY(e,t){let i=this.toFivePos(e),n=this.getCustomizedRoom().roomBoundary,o=[],s=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId);for(let e=0;e=3:t==this.toleranceType.LENIENT&&(a=r>=1),a}getRoomBoundingBox(){let e=this.getCustomizedRoom(),t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId),i=e.boundingBox,n=e.offset;i.min.z=n[0],i.max.z=n[1];let o=this.viewer.getViewer().getModelManager().getModel(t).transformMatrix.clone(),s=new THREE.Vector3,r=new THREE.Quaternion,a=new THREE.Vector3;return o.decompose(s,r,a),s=this.viewer.globalUnitUtil.revertVector(s),o.compose(s,r,a),(new THREE.Box3).setFromPoints([new THREE.Vector3(i.min.x,i.min.y,i.min.z),new THREE.Vector3(i.max.x,i.max.y,i.max.z)]).clone().applyMatrix4(o)}toFivePos(e){let t=[];return t.push(new THREE.Vector2(e.min.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.max.y)),t.push(new THREE.Vector2(e.min.x,e.max.y)),t.push(new THREE.Vector2((e.min.x+e.max.x)/2,(e.min.y+e.max.y)/2)),t}containsInBoundary(e,t,i){let n=!1;for(let i=0;is!=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.xMath.max(t.y,i.y)||e.y=t-n}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms").RoomConfig=class{constructor(){this.viewer=null,this.roomId=null,this.modelId=null,this.geometry=null,this.roomColor=null,this.frameColor=null,this.enableSelected=!0}},function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");t.RoomManager=class{constructor(e){if(this.viewer=e.viewer,this.viewer.roomManager&&!e.modelMode)return this.viewer.roomManager;this.rooms=[],!e.modelMode&&(this.viewer.roomManager=this),S(this)}addRoom(e){let t=!1;for(let i=0;i0)for(var o=0;o0)for(var n=0;n0)for(var n=0;n{t.modelId==i.modelId&&t.sections.map((n=>{const o=i.modelRooms.find((e=>e.roomId==n.id));if(o)return delete o.roomModelManager,o.setBoundary({outer:n.geometry.boundary[0].points}),o.setHeight(n.geometry.height),o.setRoomColor(new e.Web.Graphics.Color(n.color.red,n.color.green,n.color.blue,n.color.alpha)),o.setRoomFrameColor(new e.Web.Graphics.Color(n.frameColor.red,n.frameColor.green,n.frameColor.blue,n.frameColor.alpha)),void(o.roomModelManager=i);const s=new e.Bimface.Plugins.Rooms.RoomConfig;s.viewer=i.viewer,s.roomId=n.id,s.modelId=i.modelId,s.geometry={type:"extrusion",boundary:{outer:n.geometry.boundary[0].points},height:n.geometry.height,unit:n.unit},s.roomColor=new e.Web.Graphics.Color(n.color.red,n.color.green,n.color.blue,n.color.alpha),s.frameColor=new e.Web.Graphics.Color(n.frameColor.red,n.frameColor.green,n.frameColor.blue,n.frameColor.alpha);const r=new e.Bimface.Plugins.Rooms.Room(s);r.name=n.name,r.conditions=t.conditions,i.addRoom(r),r.roomModelManager=i}))}))}addRoom(e){this.modelRooms.push(e),this.viewerManager.addRoom(e),e.bindRoomByModelId(this.modelId)}getAllRoomIds(){return this.modelRooms.map((e=>e.roomId))}getAllRooms(){return this.modelRooms}hideAllRooms(){const e=this.getAllRoomIds();this.viewerManager.hideRoomsById(e)}showAllRooms(){const e=this.getAllRoomIds();this.viewerManager.showRoomsById(e)}clearAllRooms(){const e=this.getAllRoomIds();this.viewerManager.clearRoomsById(e)}clearRoomsById(e){this.viewerManager.clearRoomsById(e)}getRoomById(e){return this.viewerManager.getRoomById(e)}getRoomsByComponentId(e,t,i,n){return this.viewerManager.getRoomsByComponentId(e,t,i,n)}hideRoomsById(e){this.viewerManager.hideRoomsById(e)}showRoomsById(e){this.viewerManager.showRoomsById(e)}convertToClipperData(e){const t="Meter"==this.viewer.getGlobalUnit();return e.map((e=>{e.X=t?1e3*e.x:e.x,e.Y=t?1e3*e.y:e.y})),e}reConvertClipperData(e,t){const i="Meter"==this.viewer.getGlobalUnit();return e.map((e=>{e.x=i?e.X/1e3:e.X,e.y=i?e.Y/1e3:e.Y,e.z=t.getBoundary().outer[0].z})),e}loadAndCalculateOverLap(e,t){this.calculateOverlapArea(e,t)}calculateOverlapArea(e,t="plus"){const i=this.viewerManager.getRoomById(e);this.modelRooms.filter((e=>Math.abs(e.getBoundary().outer[0].z-i.getBoundary().outer[0].z)<1e-4)).map((n=>{if(n.roomId!==e){let e,o,s=new ClipperLib.Paths;"minus"==t?(e=this.convertToClipperData(n.getBoundary().outer),o=this.convertToClipperData(i.getBoundary().outer)):(o=this.convertToClipperData(n.getBoundary().outer),e=this.convertToClipperData(i.getBoundary().outer));const r=new ClipperLib.Clipper;r.AddPath(e,ClipperLib.PolyType.ptSubject,!0),r.AddPath(o,ClipperLib.PolyType.ptClip,!0),r.Execute(ClipperLib.ClipType.ctDifference,s,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),"minus"==t?n.setBoundary({outer:this.reConvertClipperData(s[0],n)},this.config.unit):i.setBoundary({outer:this.reConvertClipperData(s[0],n)},this.config.unit)}}))}}t.RoomModelManager=i}(),function(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=13)}([function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var i=0;ii[0]+o)return!1;var s=.5*n[1];return!(ti[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;i0&&r<.15||(e.mouseEditorMgr&&e.mouseEditorMgr.scaleIsEnable&&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);e.mouseEditorMgr&&e.mouseEditorMgr.dragIsEnable&&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:"isLeftButton",value:function(t){return this.mode===e.MouseMode||this.mode===e.MouseAndTouchMode?t===e.MouseLeftButton:t===e.TouchButton}},{key:"isMiddleButton",value:function(t){return(this.mode===e.MouseMode||this.mode===e.MouseAndTouchMode)&&t===e.MouseMiddleButton}},{key:"isRightButton",value:function(t){return(this.mode===e.MouseMode||this.mode===e.MouseAndTouchMode)&&t===e.MouseRightButton}},{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,o.MouseAndTouchMode=3,o.MouseLeftButton=0,o.MouseMiddleButton=1,o.MouseRightButton=2,o.TouchButton=1,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;i0?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();n0?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){this.mouseEditorMgr.zoomStart&&this.mouseEditorMgr.zoomStart(),null==t&&(t=1),("string"==typeof e||e instanceof String)&&(e=parseInt(e)),this.viewer.ZoomToElement(e,t),this.onViewChanges(),this.mouseEditorMgr.zoomEnd&&this.mouseEditorMgr.zoomEnd()}},{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.mouseEditorMgr.zoomStart&&this.mouseEditorMgr.zoomStart(),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(),this.mouseEditorMgr.zoomEnd&&this.mouseEditorMgr.zoomEnd()}},{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();i0&&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;in.min[0]&&o[1]n.min[1]}},{key:"drawMask",value:function(e,t){if(this.showMask){var i=e.getLayoutViewportBoundingBox(e.getActiveLayoutId(),this.needMaskVPId,this.drawingIndex),n=i.min,o=i.max;this.viewPortBBox[this.drawingIndex+"_"+this.viewPort]={min:n,max:o};var s=e.toScreenPoint(n),r=e.toScreenPoint(o);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;s0)){if(this.isRightButton(n)){if(this.sameAsMousedownPt(t,i)){if(0==this.points.length)return;this.reset(),this.notify("change",{type:"Distance",status:"reset"})}}else if(this.isLeftButton(n)){var o=0==e.getActiveLayoutId(),s=this.tmpPoint=e.snapToPoint(t,i),a=o?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],s.GetDrawingIndex()),l=this.tmpPoint.GetID(),h=this.tmpPoint.GetDrawingIndex();if(0==this.step&&(this.points=[],this.viewPort=o?a[2]:s.GetViewPortId(),this.firstPointOutsideVP=!1,e.isActiveLayoutViewportId(l,h)||-1==this.viewPort?(this.isOnLayout=!1,a[2]=-1,this.viewPort=-1,this.needMaskVPId=l,this.firstPointOutsideVP=!0,this.drawingIndex=-1):(this.isOnLayout=!0,this.viewPort=s.GetViewPortId(),this.drawingIndex=s.GetDrawingIndex(),this.firstPointOutsideVP=-1==this.viewPort)),this.parallel||(this.finalScreenPoint?(this.points[this.step]=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]),this.worldPtForOtherDrawing[this.step]=o?e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):e.toModelWorldWithIndex([this.finalScreenPoint[0],this.finalScreenPoint[1]],s.GetDrawingIndex())):(this.points[this.step]=e.snapToPoint(t,i),this.worldPtForOtherDrawing[this.step]=null)),o){if(a[2]!=this.viewPort)return this.points.splice(1,1)}else if(-1!=this.drawingIndex&&!this.tmpPointInsideBoundingBox(e,s,this.drawingIndex)&&(this.drawingIndex!=s.GetDrawingIndex()||this.viewPort!=s.GetViewPortId()))return this.points.splice(1,1);if(this.step=this.step+1,this.tmpPoint=null,this.step>=2){var c=this.points[0].GetPoint(),d=this.points[1].GetPoint(),u=[c,d],g=e.toScreenPoint(c),p=o?e.toModelWorld(g):e.toModelWorldWithIndex(g,s.GetDrawingIndex()),m=e.toScreenPoint(d),f=o?e.toModelWorld(m):e.toModelWorldWithIndex(m,s.GetDrawingIndex());u[0]=p,u[1]=f,this.worldPtForOtherDrawing[0]&&(u[0]=this.worldPtForOtherDrawing[0]),this.worldPtForOtherDrawing[1]&&(u[1]=this.worldPtForOtherDrawing[1]),l=this.points[0].GetID(),e.isActiveLayoutViewportId(l,this.points[0].GetDrawingIndex())&&(g=e.toScreenPoint(c),u[0]=e.toWorldPoint(g)),l=this.points[1].GetID(),e.isActiveLayoutViewportId(l,this.points[1].GetDrawingIndex())&&(m=e.toScreenPoint(d),u[1]=e.toWorldPoint(m)),"X"==this.parallel?u[1][0]=u[0][0]:"Y"==this.parallel&&(u[1][1]=u[0][1]);var w=r.default.distanceByArr(u[0],u[1]);this.notify("change",{distance:w,type:"Distance",status:"measured",start:u[0],end:u[1],viewPortId:this.viewPort,points:u,isOnLayout:this.isOnLayout,drawingIndex:this.drawingIndex,drawingIndexes:[this.drawingIndex,h],layoutId:e.getActiveLayoutId(),isOnBorder:e.isActiveLayoutViewportId(l,this.drawingIndex)}),this.points=[],this.step=0,this.pressShift=!1,this.parallel=!1,this.viewPort=null}else{var v=this.points[0].GetPoint();this.notify("change",{type:"Distance",status:"measuring",points:[v],end:null,layoutId:e.getActiveLayoutId()})}}this.redraw(e)}}},{key:"onEditing",value:function(e,t,i,n){this.tmpPointScreenPoint=[t,i];var o=this.tmpPoint=e.snapToPoint(t,i);if(this.step>0){var s=0==e.getActiveLayoutId(),r=s?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],o.GetDrawingIndex());if(s)this.viewPort&&r[2]!=this.viewPort&&-1!=this.viewPort?this.showMask=!0:this.showMask=!1,this.firstPointOutsideVP&&r[2]>0?this.needMaskVPId=r[2]:this.needMaskVPId=0;else{var a=o.GetID(),l=o.GetDrawingIndex();!this.tmpPointInsideBoundingBox(e,o,this.drawingIndex)&&(this.viewPort>=0&&e.isActiveLayoutViewportId(a,l)||this.viewPort&&!Number.isNaN(this.drawingIndex)&&(o.GetDrawingIndex()!=this.drawingIndex||o.GetDrawingIndex()==this.drawingIndex&&o.GetViewPortId()!=this.viewPort)&&-1!=this.viewPort)?this.showMask=!0:this.showMask=!1,this.needMaskVPId=0,this.firstPointOutsideVP&&o.GetViewPortId()>0?(this.needMaskVPId=o.GetViewPortId(),this.needMaskVPDrawingIndex=o.GetDrawingIndex()):(this.needMaskVPId=0,this.needMaskVPDrawingIndex=-1)}}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;i0&&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"PolylineDistanceMeasure":n=new g.default(this.drawing2D,t);break;case"capture":n=new p.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}();m.editorMode=-1,t.default=m},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;i0){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())||n.GetViewPortId()>-1?e.toViewportScreenPoint(n.GetPoint(),n.GetViewPortId?n.GetViewPortId():-1,n.GetDrawingIndex&&n.GetDrawingIndex()):e.toScreenPoint(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]-7,i[1]-7,14,14),t.stroke()):"PointOnLine"==n?(t.arc(i[0],i[1],6,0,2*Math.PI,!0),t.fill()):"MiddlePoint"==n?(t.lineWidth=2,t.moveTo(i[0],i[1]-7),t.lineTo(i[0]-8,i[1]+7),t.lineTo(i[0]+8,i[1]+7),t.closePath(),t.stroke()):"FootPoint"==n?(this.isFootPoint=!0,t.lineWidth=2,t.moveTo(i[0]-7.5,i[1]-7.5),t.lineTo(i[0]-7.5,i[1]+7.5),t.lineTo(i[0]+7.5,i[1]+7.5),t.moveTo(i[0]-7.5,i[1]-1),t.lineTo(i[0]+1,i[1]-1),t.lineTo(i[0]+1,i[1]+7.5),t.stroke()):"Intersection"==n&&(t.lineWidth=2,t.moveTo(i[0]-7,i[1]-7),t.lineTo(i[0]+7,i[1]+7),t.moveTo(i[0]-7,i[1]+7),t.lineTo(i[0]+7,i[1]-7),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){if(1==n&&!this.onlySnap){var o=e.getActiveLayoutId();this.markPoint?this.markPoint=null:this.finalScreenPoint?this.markPoint=0!=o?e.toWorldPoint([this.finalScreenPoint[0],this.finalScreenPoint[1]]):e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):this.markPoint=0!=o?e.toWorldPoint([t,i]):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>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();ni?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;it.max.x||e.max.yt.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;i0&&r.at(0)&&r.at(0).first&&o.push(r.at(0).first),r&&r.size()>0&&r.at(0)&&r.at(0).second&&o.push(r.at(0).second),s=o.toString().replace(",",".")}this.notify("selection",0==o.length?e.getSelectedIds():[s]),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.mouseEditorMgr&&e.mouseEditorMgr.dragIsEnable&&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;i0)){this.center=this.startCenter,this.redraw(e.point);var n=this.getRealPoint(this.center);i.end(this.drawing2D,n.x,n.y,1),!t&&i.redraw(this.drawing2D),i.clearSnapPoint(),this.dragging=!1}}}},{key:"redraw",value:function(e){if(this.center){var t=this.updateAuxMeasure(e||this.center);this.draw(t)}else this.editor.showMask=!1}},{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;i2)for(var u=1;u0))if(this.isRightButton(n)){if(this.sameAsMousedownPt(t,i)&&this.step<3){if(0==this.step)return;this.points=[],this.drawingIndexes=[],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(),viewPortId:u.GetViewPortId?u.GetViewPortId():-1,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.points=[],this.step=0,this.redraw(e),this.notify("change",{area:o,viewPortId:this.viewPort,type:"Area",status:"measured",points:s,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:e.getActiveLayoutId()}),this.viewPort=null,this.drawingIndexes=[]}}else if(this.isLeftButton(n)){var p=0==e.getActiveLayoutId();this.tmpPoint=e.snapToPoint(t,i);var m=this.tmpPoint.GetID(),f=this.tmpPoint.GetDrawingIndex(),w=p?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],this.tmpPoint.GetDrawingIndex());if(this.drawingIndexes.push(f),0==this.step&&(this.viewPort=p?w[2]:this.tmpPoint.GetViewPortId(),this.firstPointOutsideVP=!1,e.isActiveLayoutViewportId(m,f)||-1==w[2]?(w[2]=-1,this.viewPort=-1,this.needMaskVPId=m,this.firstPointOutsideVP=!0,this.drawingIndex=-1):(this.viewPort=this.tmpPoint.GetViewPortId(),this.drawingIndex=this.tmpPoint.GetDrawingIndex(),this.firstPointOutsideVP=-1==this.viewPort)),this.finalScreenPoint){var v=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]);this.worldPtForOtherDrawing[this.step]=p?e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):e.isActiveLayoutViewportId(m,this.drawingIndex)||this.tmpPointInsideBoundingBox(e,v,this.drawingIndex)?e.toModelWorldWithIndex([this.finalScreenPoint[0],this.finalScreenPoint[1]],v.GetDrawingIndex()):e.toWorldPoint([this.finalScreenPoint[0],this.finalScreenPoint[1]],v.GetDrawingIndex())}else{v=e.snapToPoint(t,i);this.worldPtForOtherDrawing[this.step]=p?null:this.tmpPointInsideBoundingBox(e,this.tmpPoint,this.drawingIndex)?w:null}if(this.parallel?this.points[this.step]=this.tmpPoint:this.points[this.step]=v,p){if(w[2]!=this.viewPort)return this.points.splice(1,1)}else if(-1!=this.drawingIndex&&!this.tmpPointInsideBoundingBox(e,v,this.drawingIndex)&&(this.drawingIndex!=this.tmpPoint.GetDrawingIndex()||this.viewPort!=this.tmpPoint.GetViewPortId()))return this.drawingIndexes.pop(),this.points.splice(1,1);this.step++,this.tmpPoint=null;var y=this.points,b=y.length,x=y[0].GetPoint(),E=v.GetPoint();if(b>2&&!l.default.isDesktop()&&this.isClosePath(e,x,E)){this.pressShift=!1,this.parallel=!1;var P=this.getArea(y.slice()),M=[],C=!0,T=!1,I=void 0;try{for(var S,D=y[Symbol.iterator]();!(C=(S=D.next()).done);C=!0){var B=S.value,_=B.GetID()>0&&!e.viewer.IsActiveLayoutElement(B.GetID());M.push({point:B.GetPoint(),viewPortId:this.viewPort,isActiveLayoutElement:!_})}}catch(e){T=!0,I=e}finally{try{!C&&D.return&&D.return()}finally{if(T)throw I}}this.notify("change",{area:P,viewPortId:this.viewPort,type:"Area",status:"measured",points:M,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:e.getActiveLayoutId(),isOnBorder:e.isActiveLayoutViewportId(m,f)}),this.points=[],this.drawingIndexes=[],this.step=0,this.viewPort=null}else{var A=[],k=!0,L=!1,V=void 0;try{for(var R,H=y[Symbol.iterator]();!(k=(R=H.next()).done);k=!0){var O=R.value,N=O.GetID()>0&&!e.viewer.IsActiveLayoutElement(O.GetID());A.push({point:O.GetPoint(),viewPortId:O.GetViewPortId?O.GetViewPortId():-1,isActiveLayoutElement:!N})}}catch(e){L=!0,V=e}finally{try{!k&&H.return&&H.return()}finally{if(L)throw V}}this.notify("change",{type:"Area",status:"measuring",points:A,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:e.getActiveLayoutId(),isOnBorder:e.isActiveLayoutViewportId(m,f)})}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;i0)){if(this.isRightButton(n)){if(this.sameAsMousedownPt(t,i)){if(0==this.points.length)return;this.reset(),this.notify("change",{type:"Angle",status:"reset"})}}else if(this.isLeftButton(n)){var o=0==e.getActiveLayoutId();this.tmpPoint=e.snapToPoint(t,i);var s=o?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],this.tmpPoint.GetDrawingIndex()),a=this.tmpPoint.GetID(),l=this.tmpPoint.GetDrawingIndex();if(0==this.step&&(this.points=[],this.viewPort=o?s[2]:this.tmpPoint.GetViewPortId(),this.firstPointOutsideVP=!1,e.isActiveLayoutViewportId(a,l)||-1==s[2]?(this.isOnLayout=!1,s[2]=-1,this.viewPort=-1,this.needMaskVPId=a,this.firstPointOutsideVP=!0,this.drawingIndex=-1):(this.isOnLayout=!0,this.viewPort=this.tmpPoint.GetViewPortId(),this.drawingIndex=this.tmpPoint.GetDrawingIndex(),this.firstPointOutsideVP=-1==this.viewPort)),this.parallel||(this.finalScreenPoint?(this.points[this.step]=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]),this.worldPtForOtherDrawing[this.step]=o?e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):e.toModelWorldWithIndex([this.finalScreenPoint[0],this.finalScreenPoint[1]],this.tmpPoint.GetDrawingIndex())):(this.points[this.step]=e.snapToPoint(t,i),this.worldPtForOtherDrawing[this.step]=null)),this.step>0){var h=this.points[this.step].GetPoint(),c=this.points[this.step-1].GetPoint();if(h[0]==c[0]&&h[1]==c[1])return}if(o&&s[2]!=this.viewPort)return this.points.splice(1,1);if(this.step=this.step+1,this.tmpPoint=null,this.step>=3){for(var d=[],u=this.points,g=[],p=0;p0&&(m=w)}d.push(m),g.push(e.toViewportScreenPoint([m[0],m[1]],m[2],-1!=this.drawingIndex&&this.drawingIndex))}"X"==this.parallel?d[2][0]=d[0][0]:"Y"==this.parallel&&(d[2][1]=d[0][1]);var v=r.default.angleByArr(g[0],g[1],g[2]);this.notify("change",{angle:v,type:"Angle",status:"measured",points:d,viewPortId:this.viewPort,isOnLayout:this.isOnLayout,drawingIndex:l,layoutId:e.getActiveLayoutId(),isOnBorder:e.isActiveLayoutViewportId(a,l)}),this.points=[],this.step=0,this.pressShift=!1,this.parallel=!1,this.viewPort=null}else{for(var y=[],b=0;b=2)for(var s=1;s0&&(m=w)}this.measureResult.points.length>0&&(g=r.default.distanceByArr(this.measureResult.points[this.measureResult.points.length-1],m),a.default.drawNotation(t,[(i[i.length-1][0]+this.tmpPointScreenPoint[0])/2,(i[i.length-1][1]+this.tmpPointScreenPoint[1])/2],this.getMeasureResult(g)))}var v=this.options.totalLengthText+":"+this.getMeasureResult(this.measureResult.totalDistance+g),y=a.default.measureText(v);a.default.drawNotation(t,[this.tmpPointScreenPoint[0]+10+y/2,this.tmpPointScreenPoint[1]-15],v)}}},{key:"onEditing",value:function(e,t,i,n){this.showMask=!1,this.isOcclusion=!1,this.tmpPoint=e.snapToPoint(t,i);var o=0==e.getActiveLayoutId();if(this.measureResult.points.length>2){var s=this.worldToScreen(e,this.points)[0];Math.abs(s[0]-t)<=8&&Math.abs(s[1]-i)<8?(t=s[0],i=s[1],this.isOcclusion=!0,this.options.measure.enableOcclusionCursor()):this.options.measure.enableMeasureCursor()}if(this.tmpPointScreenPoint=[t,i],this.step>0){var r=o?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],this.tmpPoint.GetDrawingIndex()),a=o?r[2]:this.tmpPoint.GetViewPortId();!this.tmpPointInsideBoundingBox(e,this.tmpPoint,this.drawingIndex)&&(this.viewPort&&a!=this.viewPort&&-1!=this.viewPort||this.viewPort&&!Number.isNaN(this.drawingIndex)&&(this.tmpPoint.GetDrawingIndex()!=this.drawingIndex||this.tmpPoint.GetDrawingIndex()==this.drawingIndex&&this.tmpPoint.GetViewPortId()!=this.viewPort)&&-1!=this.viewPort)?this.showMask=!0:this.showMask=!1,this.needMaskVPId=0,this.firstPointOutsideVP&&a>0?(this.needMaskVPId=a,this.needMaskVPDrawingIndex=this.tmpPoint.GetDrawingIndex()):(this.needMaskVPId=0,this.needMaskVPDrawingIndex=-1);var l=this.tmpPoint.GetID(),h=this.tmpPoint.GetDrawingIndex();this.viewPort>=0&&e.isActiveLayoutViewportId(l,h)&&(this.showMask=!0,this.needMaskVPDrawingIndex=h)}this.redraw(e)}},{key:"end",value:function(e,t,i,n){if(!(this.showMask||this.needMaskVPId>0)){if(this.tmpPoint=e.snapToPoint(t,i),this.isRightButton(n)){if(this.sameAsMousedownPt(t,i)&&this.step<2){if(0==this.step)return;this.points=[],this.step=0,this.measureResult={distance:[],points:[],totalDistance:0},this.redraw(e),this.notify("change",{type:"PolylineDistance",status:"reset"})}else if(this.sameAsMousedownPt(t,i)&&this.step>=2){var o=0==e.getActiveLayoutId()?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],-1!=this.drawingIndex?this.drawingIndex:this.tmpPoint.GetDrawingIndex());this.notify("change",{distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,type:"PolylineDistance",status:"measured",points:this.measureResult.points,viewPortId:o[2],isOnLayout:o[2]>0,drawingIndex:null!=this.drawingIndex?this.drawingIndex:this.tmpPoint.GetDrawingIndex(),drawingIndexes:this.drawingIndexes,layoutId:e.getActiveLayoutId()}),this.pressShift=!1,this.parallel=!1,this.viewPort=null,this.points=[],this.drawingIndexes=[],this.step=0,this.redraw(e),this.measureResult={distance:[],points:[],totalDistance:0}}}else if(this.isLeftButton(n)){var s=0==e.getActiveLayoutId(),a=s?e.toModelWorld([t,i]):e.toModelWorldWithIndex([t,i],this.tmpPoint.GetDrawingIndex()),l=this.tmpPoint.GetID(),h=this.tmpPoint.GetDrawingIndex();if(this.drawingIndexes.push(h),0==this.step&&(this.points=[],this.viewPort=s?a[2]:e.toModelWorldWithIndex([t,i],h),this.firstPointOutsideVP=!1,e.isActiveLayoutViewportId(l,h)||-1==a[2]?(this.isOnLayout=!1,a[2]=-1,this.viewPort=-1,this.needMaskVPId=l,this.firstPointOutsideVP=!0,this.drawingIndex=-1):(this.isOnLayout=!0,this.viewPort=this.tmpPoint.GetViewPortId(),this.drawingIndex=this.tmpPoint.GetDrawingIndex(),this.firstPointOutsideVP=-1==this.viewPort)),this.parallel||(this.finalScreenPoint?(this.points[this.step]=e.snapToPoint(this.finalScreenPoint[0],this.finalScreenPoint[1]),this.worldPtForOtherDrawing[this.step]=s?e.toModelWorld([this.finalScreenPoint[0],this.finalScreenPoint[1]]):e.toModelWorldWithIndex([this.finalScreenPoint[0],this.finalScreenPoint[1]],this.tmpPoint.GetDrawingIndex())):(this.points[this.step]=e.snapToPoint(t,i),this.worldPtForOtherDrawing[this.step]=null)),this.isOcclusion&&(this.points[this.points.length-1]=this.points[0]),s){if(a[2]!=this.viewPort)return this.points.splice(1,1)}else if(-1!=this.drawingIndex&&!this.tmpPointInsideBoundingBox(e,this.tmpPoint,this.drawingIndex)&&(this.drawingIndex!=this.tmpPoint.GetDrawingIndex()||this.viewPort!=this.tmpPoint.GetViewPortId()))return this.drawingIndexes.pop(),this.points.splice(1,1);this.step=this.step+1,this.tmpPoint=null;for(var c=[],d=this.points,u=0;u0&&(g=m)}c.push(g)}for(var f=[],w=0,v=1;v3&&void 0!==arguments[3])||arguments[3],o=this.measureText(i)+12;if(n){var s=o+4;this.fillRoundRect(e,t[0]-s/2+5,t[1]-13.5,s,27,4,"#FFFFFF")}this.fillRoundRect(e,t[0]-o/2+5,t[1]-11.5,o,23,4,e.strokeStyle),e.fillStyle="#FFFFFF",e.font="14px sans-serif",e.fillText(i,t[0]-o/2+11,t[1]+11.5-7)}},{key:"measureText",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"14px sans-serif",i=document.createElement("canvas"),n=i.getContext("2d");return n.font=t,n.measureText(e).width}},{key:"fillRoundRect",value:function(e,t,i,n,o,s,r){if(2*s>n||2*s>o)return!1;e.save(),e.translate(t,i),this.drawRoundRectPath(e,n,o,s),e.fillStyle=r||"#000",e.fill(),e.restore()}},{key:"strokeRoundRect",value:function(e,t,i,n,o,s,r,a){if(2*s>n||2*s>o)return!1;e.save(),e.translate(t,i),this.drawRoundRectPath(e,n,o,s),e.lineWidth=r||2,e.strokeStyle=a||"#000",e.stroke(),e.restore()}},{key:"drawRoundRectPath",value:function(e,t,i,n){e.beginPath(0),e.arc(t-n,i-n,n,0,Math.PI/2),e.lineTo(n,i),e.arc(n,i-n,n,Math.PI/2,Math.PI),e.lineTo(0,n),e.arc(n,n,n,Math.PI,3*Math.PI/2),e.lineTo(t-n,0),e.arc(t-n,n,n,3*Math.PI/2,2*Math.PI),e.lineTo(t,i-n),e.closePath()}}]),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-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}},{key:"createMouseAndTouchEditorManager",value:function(e){return new l.default(e)}}]),e}();h.sdkUrl="js/",h.drawingIDs=[],t.default=h},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;i0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetLayerIds(e),n=0,o=i.size();n1&&void 0!==arguments[1]?arguments[1]:0,i=0;i0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetLayoutIds(e),n=this.viewer.GetLayoutNames(e),o=0,s=i.size();o0?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;t0&&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;this.mouseEditorMgr.zoomStart&&this.mouseEditorMgr.zoomStart(),("string"==typeof e||e instanceof String)&&(e=parseInt(e)),this.viewer.ZoomToElement(e,t,i),this.onViewChanges(),this.mouseEditorMgr.zoomEnd&&this.mouseEditorMgr.zoomEnd()}},{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:"zoomToElementsWithBlock",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,o=new this.butterfly.ObjectIDList;o.clear();for(var s=0,r=t.length;s3&&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();r4&&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();a3&&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.mouseEditorMgr.zoomStart&&this.mouseEditorMgr.zoomStart(),this.viewer.ZoomToWorldBoxMinMax(e[0],e[1],e[2],t[0],t[1],t[2],i),this.mouseEditorMgr.zoomEnd&&this.mouseEditorMgr.zoomEnd()}},{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.mouseEditorMgr.zoomStart&&this.mouseEditorMgr.zoomStart(),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(),this.mouseEditorMgr.zoomEnd&&this.mouseEditorMgr.zoomEnd()}},{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();n0&&void 0!==arguments[0]?arguments[0]:0,t=[],i=this.viewer.GetHighlightIds(e),n=0,o=i.size();n0&&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;n1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n1&&void 0!==arguments[1]?arguments[1]:0;return this.viewer.IsActiveLayoutViewportId(parseInt(e),t)}},{key:"selectIdsWithViewport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments[2],n=new this.butterfly.ObjectIDList;n.clear();for(var o=0,s=e.length;o1&&void 0!==arguments[1]?arguments[1]:0,i=arguments[2],n=new this.butterfly.ObjectIDList;n.clear();for(var o=0,s=e.length;o1&&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:"highlightByIds2",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;n1&&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;e.toString().indexOf(".")>0&&(e=e.toString().split(".")[0]);var 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=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=this.viewer.ToViewportBoxMinMax(e[0],e[1],e[2],t[0],t[1],t[2],i,n),s=o.GetMinPt(),r=o.GetMaxPt();return[[s.x+this.translateX,s.y+this.translateY,s.z],[r.x+this.translateX,r.y+this.translateY,r.z]]}},{key:"getViewportBBox",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=this.viewer.GetViewportBBox(e,t),n=i.GetMinPt(),o=i.GetMaxPt();return{min:[n.x,n.y],max:[o.x,o.y]}}},{key:"getLayoutViewportBoundingBox",value:function(e,t,i){var n=this.viewer.GetLayoutViewportBoundingBox(e,t,i),o=n.GetMinPt(),s=n.GetMaxPt();return{min:[o.x,o.y],max:[s.x,s.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,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.normalizePt(e);n.x=n.x-this.translateX,n.y=n.y-this.translateY;var o=this.viewer.ToViewportScreenPointXYByViewportId(n.x,n.y,t,i);return[o.x,o.y,o.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:"toModelWorldWithIndex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=this.normalizePt(e),n=this.viewer.ToModelWorldPointXY2(i.x,i.y,t);return[n.x+this.translateX,n.y+this.translateY,n.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.viewportId,l=n.snapType,h=this.toViewportScreenPoint({x:n.snapPoint.x,y:n.snapPoint.y},a,n.modelIndex),c=this.toWorldPoint(h),d=[c[0]+this.translateX,c[1]+this.translateY,null!=c.z?c.z:-1],u=n.modelIndex;return{GetPoint:function(){return o},GetLayoutPoint:function(){return d},GetViewPortId:function(){return a},GetID:function(){return r},GetSnapType:function(){return l},GetSnapTypeName:function(){return n.snapType0&&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:"setElementBoxFillingColor",value:function(e,t,i,n){this.customManager.setFillingColor(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;i5&&void 0!==arguments[5]?arguments[5]:0,r=0;r1&&void 0!==arguments[1]?arguments[1]:0,i=0;i2&&void 0!==arguments[2]?arguments[2]:0,n=e;return e.ptr||((n=new this.butterfly.Vector2).x=e.x,n.y=e.y),this.viewer.GetViewportIdOfLayoutPoint(n,t,i)}},{key:"convertToXY",value:function(e){return{x:e.x,y:e.y}}},{key:"wcsToUcs",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=new this.butterfly.Vector2;n.x=e.x,n.y=e.y;var o=this.getViewportIdByLayoutPoint(n,t,i),s=n;0!=t&&(s=this.viewer.LayoutToModel(n.x,n.y,o));var r=this.viewer.Wcs2Ucs(s,t||"0",o,i);return this.convertToXY(r)}},{key:"ucsToWcs",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=new this.butterfly.Vector2;n.x=e.x,n.y=e.y;var o=this.getViewportIdByLayoutPoint(n,t,i),s=this.viewer.Ucs2Wcs(n,t||"0",o,i);return this.convertToXY(s)}},{key:"enableMinimap",value:function(e){this.minimap&&this.minimap.enableMiniMap(e)}},{key:"setMinimapBoundingBox",value:function(e){this.minimap&&this.minimap.setDrawingContentsBbox(e)}},{key:"setMinimapOffset",value:function(e){this.minimap.setOffset(e)}},{key:"hasMinimap",value:function(){return 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;a1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n4&&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;n1&&void 0!==arguments[1]?arguments[1]:0,i=new this.butterfly.ObjectIDList;i.clear();for(var n=0,o=e.length;n0&&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)}},{key:"destroy",value:function(){this.butterfly.JSEvents&&this.butterfly.JSEvents.removeAllEventListeners(),this.butterfly=null,this.viewer=null,this.customManager=null,this.model=null,this.mouseEditorMgr&&this.mouseEditorMgr.destroy&&this.mouseEditorMgr.destroy(),this.dc=null,this.dom=null}}]),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>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();n3&&void 0!==arguments[3]&&arguments[3],o=e,s=t;i=i||this.ctx,o=[o[0]+18/3.5,o[1]+18/3.5];var r=(s=[s[0]-18/3.5,s[1]-18/3.5])[1]-o[1],a=s[0]-o[0],l=Math.abs(a),h=Math.abs(r),c=parseInt(l/18),d=parseInt(h/18),u=0==c?l:l/c,g=0==d?h:h/d;n&&i.fillRect(e[0]+5,e[1]+5,t[0]-e[0]-10,t[1]-e[1]-10),i.beginPath(),this.drawSide("orientation",u,l,o[0],o[1],i),this.drawSide("orientation",u,l,o[0]+l,o[1]+h,i,!0),this.drawSide("portrait",g,h,o[0]+l,o[1],i),this.drawSide("portrait",g,h,o[0],o[1]+h,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;gi?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;i1&&o.some((function(e){i.revitBlockMatchModelIds[e].includes(t)&&(n=e)})),{blockId:n,ids:r[t]}):null}}]),e}();t.default=o}]),window.Glodon=e}();