@realsee/dnalogel
Version:
107 lines (94 loc) • 1.75 MB
JavaScript
(function(ge,F){typeof exports=="object"&&typeof module!="undefined"?F(exports,require("three"),require("@realsee/five/line"),require("@realsee/five"),require("@realsee/five/gltf-loader")):typeof define=="function"&&define.amd?define(["exports","three","@realsee/five/line","@realsee/five","@realsee/five/gltf-loader"],F):(ge=typeof globalThis!="undefined"?globalThis:ge||self,F(ge.dnalogel={},ge.THREE,ge.FiveSDK_Line,ge.FiveSDK,ge.FiveSDK_GLTFLoader))})(this,function(ge,F,lt,Ye,or){var wy,Py,Cy,Iy;"use strict";var aT=Object.defineProperty,lT=Object.defineProperties;var cT=Object.getOwnPropertyDescriptors;var nc=Object.getOwnPropertySymbols;var ky=Object.prototype.hasOwnProperty,xy=Object.prototype.propertyIsEnumerable;var Ai=Math.pow,pd=(ge,F,lt)=>F in ge?aT(ge,F,{enumerable:!0,configurable:!0,writable:!0,value:lt}):ge[F]=lt,V=(ge,F)=>{for(var lt in F||(F={}))ky.call(F,lt)&&pd(ge,lt,F[lt]);if(nc)for(var lt of nc(F))xy.call(F,lt)&&pd(ge,lt,F[lt]);return ge},de=(ge,F)=>lT(ge,cT(F));var ws=(ge,F)=>{var lt={};for(var Ye in ge)ky.call(ge,Ye)&&F.indexOf(Ye)<0&&(lt[Ye]=ge[Ye]);if(ge!=null&&nc)for(var Ye of nc(ge))F.indexOf(Ye)<0&&xy.call(ge,Ye)&&(lt[Ye]=ge[Ye]);return lt};var f=(ge,F,lt)=>(pd(ge,typeof F!="symbol"?F+"":F,lt),lt);var te=(ge,F,lt)=>new Promise((Ye,or)=>{var sc=vn=>{try{rr(lt.next(vn))}catch(so){or(so)}},b=vn=>{try{rr(lt.throw(vn))}catch(so){or(so)}},rr=vn=>vn.done?Ye(vn.value):Promise.resolve(vn.value).then(sc,b);rr((lt=lt.apply(ge,F)).next())});function sc(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const b=sc(F);function rr(){console.debug("%c %c@realsee/dnalogel %cv3.78.0",["background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAMCAMAAACHgmeRAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABLFBMVEUAAAAapPoap/oaqvkbrfkbr/gZnfwZoPsaqfnD4v/E4/8Ylv0clPm93/+/4P/B4f8Yj/683/8Wif+33P8Uhv+x2f8ShP+s1v8Pgf+n0/8Nf/+h0f8Lff8Lff8Nf/9dl/+czv8KfP8KfP+Lxf+Uyv+Xy/+Hwv+Jw/+Mxf+Oxv+RyP8aovsapfoap/oZmfwZm/wZnvsYnPsYkf4YlP0NePsDYfgYcfi43f+63v8Xiv8Xjf4EWfwCV/sWZ/qz2v+02/8Vh/8WiP8EUf8CTf4WXv2u1/+v2P8Thf8Thv8ETf8CR/8VV/+o1f+q1f8Qgv8Rg/8DSv8BRf8UVP+j0v+k0v8OgP8Pgf8DR/8DQv9Nhf+dzv+fz/+Kv/+Vyv+Xy/+azf+Oxv+Qx/+SyP////8MUhLdAAAAK3RSTlMACEWQ2bd98uQECPXxqO7c+Pb49vj2+Pb49vj23Oul8fMHA+TwerXXjEIG2P+bHgAAAAFiS0dEY1y+LaoAAAB+SURBVAjXY2BgZGJmYWVgYGBgY9fW0eVg4ORi4NbTNzDk4eXjZxAwMjYxNTO3EGQQsrSytrG1sxdmEHFwdHJ2cXUTZRBz9/D08vbxFWeQ8PMPCAwKDpFkkAoNC4+IjIqWZpCRlZOPiY2LV2BQVGJQTkhMUlEFWaOmrqGpxQAAyg0S9Dq+VPYAAAAASUVORK5CYII=')","background-repeat: no-repeat","background-position: 0 center","padding-left: 8px"].join(";"),"","background-color: #12ce9b;color:black;padding:0 6px;border-radius: 3px")}function vn(){const n=typeof OffscreenCanvas!="undefined",t=n&&new OffscreenCanvas(1,1).getContext("webgl")!==null;n&&!t&&Object.assign(window,{OffscreenCanvas:function(e,i){const s=document.createElement("canvas");return s.width=e,s.height=i,s}})}function so(){}const gd=()=>Promise.resolve(),md={__queue:Promise.resolve()};function Dy(n=gd){md.__queue=md.__queue.then(n).catch(gd)}function va(n,t,e){const i=n.x,s=n.y,o=Math.floor(i/t*1e4)/1e4,r=Math.floor(s/e*1e4)/1e4;return{x:o,y:r}}function oc(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function ya(n){if(n.length<2)return{};const t=n.slice(-2),e=t[0],i={x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2};return{control:e,end:i}}function Ty(n,t,e=so){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const Ly=window,vd=window.requestAnimationFrame||Ly.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function ba(n,t=0){t<=0?vd(n):vd(()=>ba(n,t-1))}var Fi=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var t=1.70158;return n===1?1:n*n*((t+1)*n-t)},Out:function(n){var t=1.70158;return n===0?0:--n*n*((t+1)*n+t)+1},InOut:function(n){var t=2.5949095;return(n*=2)<1?.5*(n*n*((t+1)*n-t)):.5*((n-=2)*n*((t+1)*n+t)+2)}}),Bounce:Object.freeze({In:function(n){return 1-Fi.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?Fi.Bounce.In(n*2)*.5:Fi.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(t){return Math.pow(t,n)},Out:function(t){return 1-Math.pow(1-t,n)},InOut:function(t){return t<.5?Math.pow(t*2,n)/2:(1-Math.pow(2-t*2,n))/2+.5}}}}),oo=function(){return performance.now()},yd=function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},n.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},n.prototype.update=function(t,e){t===void 0&&(t=oo()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var o=this._tweens[i[s]],r=!e;o&&o.update(t,r)===!1&&!e&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n}(),Ps={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Ps.Utils.Linear;return t<0?o(n[0],n[1],i):t>1?o(n[e],n[e-1],e-i):o(n[s],n[s+1>e?e:s+1],i-s)},Bezier:function(n,t){for(var e=0,i=n.length-1,s=Math.pow,o=Ps.Utils.Bernstein,r=0;r<=i;r++)e+=s(1-t,i-r)*s(t,r)*n[r]*o(i,r);return e},CatmullRom:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Ps.Utils.CatmullRom;return n[0]===n[e]?(t<0&&(s=Math.floor(i=e*(1+t))),o(n[(s-1+e)%e],n[s],n[(s+1)%e],n[(s+2)%e],i-s)):t<0?n[0]-(o(n[0],n[0],n[1],n[1],-i)-n[0]):t>1?n[e]-(o(n[e],n[e],n[e-1],n[e-1],i-e)-n[e]):o(n[s?s-1:0],n[s],n[e<s+1?e:s+1],n[e<s+2?e:s+2],i-s)},Utils:{Linear:function(n,t,e){return(t-n)*e+n},Bernstein:function(n,t){var e=Ps.Utils.Factorial;return e(n)/e(t)/e(n-t)},Factorial:function(){var n=[1];return function(t){var e=1;if(n[t])return n[t];for(var i=t;i>1;i--)e*=i;return n[t]=e,e}}(),CatmullRom:function(n,t,e,i,s){var o=(e-n)*.5,r=(i-t)*.5,a=s*s,l=s*a;return(2*t-2*e+o+r)*l+(-3*t+3*e-2*o-r)*a+o*s+t}}},rc=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),ac=new yd,Aa=function(){function n(t,e){e===void 0&&(e=ac),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Fi.Linear.None,this._interpolationFunction=Ps.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=rc.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},n.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},n.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},n.prototype.start=function(t,e){if(t===void 0&&(t=oo()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var o in this._valuesEnd)s[o]=this._valuesEnd[o];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},n.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},n.prototype._setupProperties=function(t,e,i,s,o){for(var r in i){var a=t[r],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(i[r]);if(!(c==="undefined"||c==="function")){if(h){var u=i[r];if(u.length===0)continue;for(var d=[a],p=0,g=u.length;p<g;p+=1){var m=this._handleRelativeValue(a,u[p]);if(isNaN(m)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(m)}h&&(i[r]=d)}if((c==="object"||l)&&a&&!h){e[r]=l?[]:{};var v=a;for(var y in v)e[r][y]=v[y];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var w={};for(var y in u)w[y]=u[y];i[r]=u=w}this._setupProperties(v,e[r],u,s[r],o)}else(typeof e[r]=="undefined"||o)&&(e[r]=a),l||(e[r]*=1),h?s[r]=i[r].slice().reverse():s[r]=e[r]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(t){return t===void 0&&(t=oo()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},n.prototype.resume=function(t){return t===void 0&&(t=oo()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},n.prototype.group=function(t){return t===void 0&&(t=ac),this._group=t,this},n.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},n.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},n.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},n.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},n.prototype.easing=function(t){return t===void 0&&(t=Fi.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Ps.Linear),this._interpolationFunction=t,this},n.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},n.prototype.onStart=function(t){return this._onStartCallback=t,this},n.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},n.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},n.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},n.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},n.prototype.onStop=function(t){return this._onStopCallback=t,this},n.prototype.update=function(t,e){var i=this,s;if(t===void 0&&(t=oo()),e===void 0&&(e=!0),this._isPaused)return!0;var o,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=t-this._startTime,l=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||a>c)return 1;var v=Math.trunc(a/l),y=a-v*l,w=Math.min(y/i._duration,1);return w===0&&a===i._duration?1:w},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,m=this._chainedTweens.length;g<m;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(t,e,i,s){for(var o in i)if(e[o]!==void 0){var r=e[o]||0,a=i[o],l=Array.isArray(t[o]),c=Array.isArray(a),h=!l&&c;h?t[o]=this._interpolationFunction(a,s):typeof a=="object"&&a?this._updateProperties(t[o],r,a,s):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(t[o]=r+(a-r)*s))}},n.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},n.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},n}(),zy="23.1.3",Oy=rc.nextId,Ji=ac,jy=Ji.getAll.bind(Ji),_y=Ji.removeAll.bind(Ji),Vy=Ji.add.bind(Ji),bd=Ji.remove.bind(Ji),By=Ji.update.bind(Ji),Ad={Easing:Fi,Group:yd,Interpolation:Ps,now:oo,Sequence:rc,nextId:Oy,Tween:Aa,VERSION:zy,getAll:jy,removeAll:_y,add:Vy,remove:bd,update:By};function Ry(n,t,e,i=Fi.Linear.None){const s=new Aa(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var yn=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(yn||{});const ar=Symbol("$$PAINT_BRUSH_EVENT$$");function wa(n){return n[ar]||(n[ar]={}),n[ar]}function Fy(n){n[ar]||delete n[ar]}let Ny=class{hasListener(t){const e=wa(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=wa(this);return s[t]||(s[t]=[]),s[t].push([e,i||!1]),()=>this.off(t,e)}once(t,e){return this.on(t,e,!0)}off(t,e){if(t===void 0){Fy(this);return}const i=wa(this);if(i[t]||(i[t]=[]),e===void 0){i[t].length=0;return}let s=0;for(;s<i[t].length&&i[t][s][0]!==e;s++);s<i[t].length&&i[t].splice(s,1)}emit(t,...e){let i=!1;const o=wa(this)[t]||[];for(let r of o.slice()){const[a,l=!1]=r,c=a(...e);l&&this.off(t,a),c===!1&&(i=!0)}return i}};function Nn(){return((1+Math.random())*65536|0).toString(16).substring(1)}function Mt(){return(Nn()+Nn()+"-"+Nn()+"-4"+Nn().substr(0,3)+"-"+Nn()+"-"+Nn()+Nn()+Nn()).toLowerCase()}const Gy=`
<style type="text/css">
#_gl_paintBrush {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
transform: translateZ(0);
z-index: 1997;
pointer-events: none;
opacity: 0;
transition: all 500ms;
}
#_gl_paintBrush.brushing {
opacity: 1;
}
#_gl_paintBrush ._paintBrush-canvas {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#_gl_paintBrush ._paintBrush-canvas--sync {
pointer-events: none;
z-index: 0;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#_gl_paintBrush ._paintBrush-canvas {
pointer-events: none;
z-index: 1;
}
#_gl_paintBrush.brushing ._paintBrush-canvas {
pointer-events: auto;
}
#_gl_paintBrush ._paintBrush-ctrl {
width: 140px;
height: 52px;
position: absolute;
bottom: 28px;
right: 50%;
transform: translateX(50%);
font-size: 10px;
color: white;
z-index: 2;
}
#_gl_paintBrush.brushing ._paintBrush-ctrl {
pointer-events: auto;
}
#_gl_paintBrush ._paintBrush-ctrl ._paintBrush-ctrlinner {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
border-radius: 26px;
padding: 8px 16px;
box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2);
background-image: linear-gradient(180deg, hsl(0deg 0% 0% / 57%), hsl(0deg 0% 0% / 70%) 117%);
}
._paintBrush-ctrlitem {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 38px;
height: 38px;
cursor: pointer;
}
._paintBrush-ctrlitem--undo >.brush-icon{
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjQ1LjY3NTI0OCUiIHgyPSItMTYuOTYxMDIzJSIgeTI9Ijg0LjIzODQxOTglIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgc3RvcC1vcGFjaXR5PSIwLjMwMzY3Njc5MiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xNDAuMDAwMDAwLCAtNzQwLjAwMDAwMCkiPgogICAgICAgICAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNDAuMDAwMDAwLCA3NDAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDQuMDAwMDAwLCAyLjk5MDY1OSkiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMCwzLjc1ODc1NzA5IEw5Ljg0Mzc1LDMuNzU4NzU3MDkgQzEyLjY5MTQ2ODIsMy43NTg3NTcwOSAxNSw2LjA2NzI4ODg1IDE1LDguOTE1MDA3MDkgQzE1LDExLjc2MjcyNTMgMTIuNjkxNDY4MiwxNC4wNzEyNTcxIDkuODQzNzUsMTQuMDcxMjU3MSBMMSwxNC4wNzEyNTcxIiBzdHJva2U9InVybCgjbGluZWFyR3JhZGllbnQtMSkiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cG9seWxpbmUgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBwb2ludHM9IjMuNzkwMjI3MDcgNy41Mzk2NjA2NCAwIDMuNzU4NzU3MDkgMy43OTAyMjcwNyAwIj48L3BvbHlsaW5lPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
._paintBrush-ctrlitem--close >.brush-icon {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwLjAyMDY5MyUiIHkxPSItMTMuNzMzMzc1MSUiIHgyPSI1MCUiIHkyPSIxMTQuMTEwOTk0JSIgaWQ9ImxpbmVhckdyYWRpZW50LTEiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIHN0b3Atb3BhY2l0eT0iMC42MDEwNDM0ODgiIG9mZnNldD0iNDkuMzA4NDg4MiUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSIgaWQ9ImxpbmVhckdyYWRpZW50LTIiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iNTUuOTY4MTUzNSUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnPgogICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNC4wMDAwMDAsIDUuMDAwMDAwKSIgZmlsbC1ydWxlPSJub256ZXJvIj4KICAgICAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik03LC0yLjk4ODE2NTY4IEM3LjUxMjgzNTg0LC0yLjk4ODE2NTY4IDcuOTM1NTA3MTYsLTIuNjAyMTI1NDkgNy45OTMyNzIyNywtMi4xMDQ3ODY4MSBMOCwtMS45ODgxNjU2OCBMOCwxMy45OTgxMTQ2IEM4LDE0LjU1MDM5OTMgNy41NTIyODQ3NSwxNC45OTgxMTQ2IDcsMTQuOTk4MTE0NiBDNi40ODcxNjQxNiwxNC45OTgxMTQ2IDYuMDY0NDkyODQsMTQuNjEyMDc0NCA2LjAwNjcyNzczLDE0LjExNDczNTcgTDYsMTMuOTk4MTE0NiBMNiwtMS45ODgxNjU2OCBDNiwtMi41NDA0NTA0MyA2LjQ0NzcxNTI1LC0yLjk4ODE2NTY4IDcsLTIuOTg4MTY1NjggWiIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNy4wMDAwMDAsIDYuMDA0OTc0KSByb3RhdGUoLTQ1LjAwMDAwMCkgdHJhbnNsYXRlKC03LjAwMDAwMCwgLTYuMDA0OTc0KSAiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNywtMi45ODgxNjU2OCBDNy41MTI4MzU4NCwtMi45ODgxNjU2OCA3LjkzNTUwNzE2LC0yLjYwMjEyNTQ5IDcuOTkzMjcyMjcsLTIuMTA0Nzg2ODEgTDgsLTEuOTg4MTY1NjggTDgsMTMuOTk4MTE0NiBDOCwxNC41NTAzOTkzIDcuNTUyMjg0NzUsMTQuOTk4MTE0NiA3LDE0Ljk5ODExNDYgQzYuNDg3MTY0MTYsMTQuOTk4MTE0NiA2LjA2NDQ5Mjg0LDE0LjYxMjA3NDQgNi4wMDY3Mjc3MywxNC4xMTQ3MzU3IEw2LDEzLjk5ODExNDYgTDYsLTEuOTg4MTY1NjggQzYsLTIuNTQwNDUwNDMgNi40NDc3MTUyNSwtMi45ODgxNjU2OCA3LC0yLjk4ODE2NTY4IFoiIGZpbGw9InVybCgjbGluZWFyR3JhZGllbnQtMikiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDcuMDAwMDAwLCA2LjAwNDk3NCkgcm90YXRlKC0xMzUuMDAwMDAwKSB0cmFuc2xhdGUoLTcuMDAwMDAwLCAtNi4wMDQ5NzQpICI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
</style>
`;let Hy=class extends Ny{constructor(e){super();f(this,"configs");f(this,"clientWidth");f(this,"clientHeight");f(this,"ready",!1);f(this,"uuid",Mt());f(this,"tween");f(this,"tweening",!1);f(this,"container");f(this,"canvas");f(this,"data",{});f(this,"tempLine",{});this.configs=e,this.clientWidth=document.body.clientWidth,this.clientHeight=document.body.clientHeight,this.container=this.ifInsertToDOM(),this.canvas={},this.initCtrl()}get color(){return this.configs.currentColor}get state(){return this.data}get dpr(){return this.configs.DPR||1}ifInsertToDOM(){if(this.container)return this.container;if(this.configs.container)this.configs.container.id="_gl_paintBrush",this.container=this.configs.container;else if(document.getElementById("_gl_paintBrush"))this.container=document.getElementById("_gl_paintBrush");else{const e=document.createElement("div");e.id="_gl_paintBrush",document.body.appendChild(e),this.container=e}return this.container.innerHTML=Gy,this.container}initCanvas(e){const i=document.createElement("canvas");i.className=e,i.width=this.clientWidth,i.height=this.clientHeight;const s=i.getContext("2d");if(s)return s.lineWidth=5*this.dpr,s.lineCap="round",s.lineJoin="round",this.container.appendChild(i),i}initCtrl(){const e=document.createElement("div");e.className="_paintBrush-ctrl";const i=document.createElement("div");i.className="_paintBrush-ctrlinner";const s=document.createElement("a");s.className="_paintBrush-ctrlitem _paintBrush-ctrlitem--undo",s.addEventListener("click",a=>{var d;if(a.stopPropagation(),this.configs.onClickUndo&&this.configs.onClickUndo(),!this.canvas[this.uuid]||!this.data[this.uuid]||this.data[this.uuid].length===0)return;const l=this.data[this.uuid].pop();l&&this.emitStateChange({type:yn.Undo,color:this.color,ready:this.ready,state:l,uuid:this.uuid});const c=(d=this.canvas[this.uuid])==null?void 0:d.getContext("2d");if(!this.canvas[this.uuid])return;const{width:h,height:u}=this.canvas[this.uuid];c&&c.clearRect(0,0,h,u),this.data[this.uuid].forEach(p=>this.handleDrawLine(this.uuid,p,{withUndo:!0}))});const o=document.createElement("a");return o.className="_paintBrush-ctrlitem _paintBrush-ctrlitem--close",o.addEventListener("click",a=>{a.stopPropagation(),this.closeBrush(),this.configs.onClickClose&&this.configs.onClickClose()}),[s,o].forEach(a=>{const l=document.createElement("i");l.className="brush-icon";const c=document.createElement("span");c.className="brush-txt",c.innerText=a.className.endsWith("undo")?this.configs.onUndoText:this.configs.onExitText,a.appendChild(l),a.appendChild(c)}),i.appendChild(s),i.appendChild(o),e.appendChild(i),this.container.appendChild(e),e}openBrush(){if(this.ready)return;this.canvas[this.uuid]||(this.canvas[this.uuid]=this.initCanvas("_paintBrush-canvas")),this.container.className="brushing";const e=this.canvas[this.uuid];e.getContext("2d").clearRect(0,0,e.width,e.height),this.openBrushHandle(),this.ready=!0,this.emit("readyChange",!0)}closeBrush(){this.ready&&(this.container.className="",this.data={},this.tempLine={},Object.keys(this.canvas).forEach(e=>{this.canvas[e].ontouchstart=()=>!1,this.canvas[e].ontouchmove=()=>!1,this.canvas[e].ontouchend=()=>!1,this.canvas[e].ontouchcancel=()=>!1;const i=this.canvas[e].getContext("2d");i&&i.clearRect(0,0,this.canvas[e].width,this.canvas[e].height)}),this.ready=!1,this.emit("readyChange",!1),this.emitStateChange({type:yn.Exit,color:this.color,ready:!1,uuid:this.uuid}))}updateCurrentColor(e){const i=this.canvas[this.uuid];if(!i)return;const s=i.getContext("2d");s&&(this.configs.currentColor=e,s.strokeStyle=e)}openBrushHandle(){const e=this.canvas[this.uuid];if(!e)return;const i=e.getContext("2d");if(!i)return;const s=this.color||"#6D92FF";i.strokeStyle=s;let o=null,r=[],a,l=[],c=0;const h=(u,d,p)=>{const g=this.color||"#ff0000";i.strokeStyle=g,i.beginPath(),i.moveTo(u.x,u.y),i.quadraticCurveTo(d.x,d.y,p.x,p.y),i.stroke()};e.onmousedown=u=>{u.preventDefault(),c=Date.now();const d=u.clientX,p=u.clientY;r=[],r.push({x:d,y:p}),o={x:d,y:p},a=va({x:d,y:p},this.clientWidth,this.clientHeight),l=[]},e.onmousemove=u=>{if(u.preventDefault(),!o)return;const d=Number(u.clientX),p=Number(u.clientY);if(Math.abs(d-o.x)<5&&Math.abs(p-o.y)<5||(r.push({x:d,y:p}),l.push(va({x:d,y:p},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:g,end:m}=ya(r);!g||!m||(h(o,g,m),o=m)},e.onmouseup=u=>{if(u.preventDefault(),o=null,r.length<3)return;this.data[this.uuid]||(this.data[this.uuid]=[]);const d=Date.now()-c,p={move:Object.assign({},a),uuid:this.uuid,line:[...l],color:this.color,duration:d<1280?d:d<2e3?1280:0};this.data[this.uuid].push(p),ba(()=>{this.emitStateChange({type:yn.Drawline,color:this.color,ready:this.ready,state:p,uuid:this.uuid})})},e.ontouchstart=u=>{u.preventDefault(),c=Date.now();const d=u.touches[0].clientX,p=u.touches[0].clientY;r=[],r.push({x:d,y:p}),o={x:d,y:p},a=va({x:d,y:p},this.clientWidth,this.clientHeight),l=[]},e.ontouchmove=u=>{if(u.preventDefault(),!o)return;const d=Number(u.touches[0].clientX),p=Number(u.touches[0].clientY);if(Math.abs(d-o.x)<5&&Math.abs(p-o.y)<5||(r.push({x:d,y:p}),l.push(va({x:d,y:p},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:g,end:m}=ya(r);!g||!m||(h(o,g,m),o=m)},e.ontouchend=e.ontouchcancel=u=>{if(u.preventDefault(),o=null,r.length<3)return;this.data[this.uuid]||(this.data[this.uuid]=[]);const d=Date.now()-c,p={move:Object.assign({},a),line:[...l],uuid:this.uuid,color:this.color,duration:d<1280?d:d<2e3?1280:0};this.data[this.uuid].push(p),ba(()=>{this.emitStateChange({type:yn.Drawline,color:this.color,ready:this.ready,state:p,uuid:this.uuid})})}}emitStateChange(e,i=!0){if(e.type!==yn.Drawline){this.emit("stateChange",e,i);return}const s=Date.now(),o=e.state;if(!o||!o.line)return;const r=Math.ceil(o.line.length/100);for(let a=0;a<r;a++){const l={uuid:this.uuid,color:this.color,ready:this.ready,type:e.type,state:{uuid:this.uuid,move:o.move,duration:o.duration,color:this.color,line:o.line.slice(a*100,(a+1)*100)},timestamp:s,end:a===r-1};Ty(a,20,()=>{this.emit("stateChange",l,i)})}}action(e){const{ready:i,type:s,uuid:o}=e;if(!i&&this.ready){this.closeBrush();return}if(i&&!this.ready){this.openBrush();return}if(this.ready)switch(s){case yn.Drawline:const{state:r,timestamp:a,end:l}=e;if(!a||!r)return;this.tempLine[a]=[].concat(this.tempLine[a]||[],r.line),l&&(Object.assign(r,{line:this.tempLine[a]}),this.handleDrawLine(o,r,{},()=>delete this.tempLine[a]));break;case yn.Undo:this.handleUndo(o);break}}handleDrawLine(e,i,{withUndo:s=!1},o=so){!i||Object.prototype.toString.call(i)!="[object Object]"||Object.keys(i).length===0||Dy(()=>new Promise(r=>{if(s||(this.canvas[e]||(this.canvas[e]=this.initCanvas("_paintBrush-canvas--sync")),this.data[e]||(this.data[e]=[]),this.data[e].push(i)),!this.canvas[e])return;const a=this.canvas[e].getContext("2d");if(!a)return;const{line:l=[],color:c="black",duration:h=0,uuid:u}=i,d=oc(i.move||{},this.clientWidth,this.clientHeight);let p=[d];if(a.strokeStyle=c,a.beginPath(),a.moveTo(d.x,d.y),h&&!s){let g=[];const m=this;m.tween=Ry({step:0},{step:l.length-1},h).onUpdate(({step:v})=>{var w;if(m.tweening=!0,!m.ready)return a.clearRect(0,0,m.canvas[u].width,m.canvas[u].height),(w=m.tween)==null?void 0:w.stop();const y=Math.floor(v);if(!g.find(I=>I===y)){if(g.push(y),p.push(oc(l[y],m.clientWidth,m.clientHeight)),p.length<3)return;const{control:I,end:C}=ya(p);if(!I||!C)return;a.quadraticCurveTo(I.x,I.y,C.x,C.y),a.stroke()}}).onComplete(v=>{m.tween=void 0,m.tweening=!1,g=[],p=[],o&&o(),r()})}else{for(let g=0;g<l.length;g++){if(p.push(oc(l[g],this.clientWidth,this.clientHeight)),p.length<3)continue;const{control:m,end:v}=ya(p);!m||!v||a.quadraticCurveTo(m.x,m.y,v.x,v.y)}a.stroke(),p=[],o&&o(),r()}}))}handleUndo(e){if(!this.canvas[e]||!this.data[e]||this.data[e].length===0)return;this.data[e].pop();const i=()=>{var o;const s=(o=this.canvas[e])==null?void 0:o.getContext("2d");s&&s.clearRect(0,0,this.canvas[e].width,this.canvas[e].height),this.data[e].forEach(r=>this.handleDrawLine(e,r,{withUndo:!0}))};if(this.tween&&this.tweening){this.tween.stop(),ba(i,60);return}i()}destroyBrush(){this.closeBrush(),this.ready=!1,this.emit("readyChange",!0)}};class Wy{constructor(t={}){f(this,"controller");const e=Object.assign({currentColor:"#f44336",onUndoText:"回退",onExitText:"关闭"},t);this.controller=new Hy(e)}on(t,e){this.controller.on(t,e)}off(t,e){this.controller.off(t,e)}once(t,e){this.controller.once(t,e)}show(){this.controller.openBrush()}action(t){this.controller.action(t)}get state(){return this.controller.state}get configs(){return this.controller.configs}dispose(){return this.controller.destroyBrush()}setCurrentColor(t){this.controller.updateCurrentColor(t)}}function Uy(n){return typeof Symbol=="undefined"?`$Symbol<${n}>$`:Symbol(n)}const lr=Uy("$$EVENT$$");function cr(n){return n[lr]||(n[lr]={}),n[lr]}function Qy(n){n[lr]&&delete n[lr]}class St{hasListener(t){const e=cr(this);return!!(e!=null&&e[t]&&e[t].length>0)}on(t,e,i){const s=cr(this);return s[t]||(s[t]=[]),s[t].push([e,i||!1]),()=>this.off(t,e)}once(t,e){return this.on(t,e,!0)}off(t,e){if(t===void 0){Qy(this);return}const i=cr(this);if(i[t]||(i[t]=[]),e===void 0){i[t].length=0;return}let s=0;for(;s<i[t].length&&i[t][s][0]!==e;s++);s<i[t].length&&i[t].splice(s,1)}emit(t,...e){let i=!1;const o=cr(this)[t]||[];for(let r of o.slice()){const[a,l=!1]=r,c=a(...e);l&&this.off(t,a),c===!1&&(i=!0)}return i}emitWithResult(t,...e){let i;const o=cr(this)[t]||[];for(let r of o.slice()){const[a,l=!1]=r,c=a(...e);i||(i=c),l&&this.off(t,a)}return i}}class lc{constructor(t=0,e=0){f(this,"min");f(this,"max");f(this,"isInterval",!0);this.min=t,this.max=e}fromArray(t){return this.min=t[0],this.max=t[1],this}isOverlap(t){return Math.min(this.max,t.max)<Math.max(this.min,t.min)}contains(t){return this.min<t.min&&this.max>t.max}}let Xy=class{constructor(t,e){f(this,"min");f(this,"max");f(this,"xInterval");f(this,"yInterval");f(this,"isRectangle",!0);this.min=t,this.max=e,this.xInterval=new lc(this.min.x,this.max.x),this.yInterval=new lc(this.min.y,this.max.y)}isOverlapWithRectangle(t){return!this.xInterval.isOverlap(t.xInterval)&&!this.yInterval.isOverlap(t.yInterval)}containsRect(t){return this.xInterval.contains(t.xInterval)&&this.yInterval.contains(t.yInterval)}};function Yy(n){n.sort(function(i,s){return i.x!=s.x?i.x-s.x:i.y-s.y});const t=n.length,e=[];for(let i=0;i<2*t;i++){const s=i<t?i:2*t-1-i;for(;e.length>=2&&Zy(e[e.length-2],e[e.length-1],n[s]);)e.pop();e.push(n[s])}return e.pop(),e}function Zy(n,t,e){const i=(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x),s=(n.x-t.x)*(e.x-t.x)+(n.y-t.y)*(e.y-t.y);return i<0||i==0&&s<=0}function wd(n,t){const e=n[0],i=n[1];let s=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){const a=t[o][0],l=t[o][1],c=t[r][0],h=t[r][1];l>i!=h>i&&e<(c-a)*(i-l)/(h-l)+a&&(s=!s)}return s}const qy=({x:n,y:t,z:e})=>new F.Vector3(n,t,e),Lt=n=>new F.Vector3().fromArray(n),Ve=n=>{if(n)return n instanceof F.Vector3?n:Array.isArray(n)?Lt(n):qy(n)};function Jy(n){if(n)return Array.isArray(n)?typeof n[0]=="number"?Ve(n):n.map(Ve):Ve(n)}function cc(n,t,e){const{x:i,y:s,z:o}=t.clone().project(n);return o>1?void 0:{leftPx:(i+1)/2*e.x,topPx:(-s+1)/2*e.y}}function wi(n){var e;return((e=n.models)==null?void 0:e.filter(i=>i.name===n.state.workCode)[0])||n.model}class Pd extends St{constructor(e){super();f(this,"five");this.five=e}}const _t=(n,t)=>{if(!t)return n;const e=new b.Vector3,i=new b.Quaternion,s=new b.Vector3;return t.decompose(e,i,s),n.clone().multiply(s).applyQuaternion(i).add(e)},hc=new Map;class Ky extends Pd{constructor(e){super(e);f(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(hc.has(e))return hc.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return hc.set(e,i),i}set workCode(e){this._workCode=e}get workCode(){var e;return(e=this._workCode)!=null?e:this.five.state.workCode}get work(){var e,i;return(i=(e=this.five.works)==null?void 0:e.find(s=>s.workCode===this.workCode))!=null?i:this.five.work}get observers(){var e;return(e=this.work)==null?void 0:e.observers}get transform(){var i,s,o,r;const e=(r=(i=this.work)==null?void 0:i.transform)!=null?r:(o=(s=this.work)==null?void 0:s.options)==null?void 0:o.transform;return e?e.clone():new b.Matrix4}getResolvedObserver(e){return this.five.works.getResolvedObserver({workCode:this.workCode,panoIndex:e})}getObserverPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.position;if(i)return _t(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return _t(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class Pa extends Pd{constructor(e){super(e);f(this,"workUtil",new Ky(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return wi(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}class hr extends b.Raycaster{intersectObject(t,e=!0,i=[]){return uc(t,this,i,e),i.sort(Cd),i}intersectObjects(t,e=!0,i=[]){for(let s=0,o=t.length;s<o;s++)uc(t[s],this,i,e);return i.sort(Cd),i}}function Cd(n,t){return n.distance-t.distance}function uc(n,t,e,i){let s=!0;if(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const o=n.children;for(let r=0,a=o.length;r<a;r++)uc(o[r],t,e,!0)}}function dc(n,t,e,i){let s=!0;if(n.type!=="Line2"&&(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0)){const o=n.children;for(let r=0,a=o.length;r<a;r++)o[r].type!=="Line2"&&dc(o[r],t,e,!0)}}const bn=new hr;bn.params.Points.threshold=.02;function Ca(n,t){if(!t||typeof ResizeObserver=="undefined"||!ResizeObserver)return{observe:()=>window.addEventListener("resize",n),unobserve:()=>window.removeEventListener("resize",n)};{const e=new ResizeObserver(n);return{observe:()=>e.observe(t),unobserve:()=>e.unobserve(t)}}}function ur(n,t=200){let e;return function(...i){e||(n(...i),e=setTimeout(function(){e=null},t))}}function fc(n,t){let e=!1;const i=ur(()=>{e||(e=!0,n.ready().then(()=>{t(),e=!1}))},150);return n.on("camera.update",i),()=>{n.off("camera.update",i)}}const $y=new F.Vector2;class dr{constructor(t,e,i){f(this,"container");f(this,"visible",!1);f(this,"enabled",!1);f(this,"visibles",[]);f(this,"wrapper");f(this,"positionsForRotate");f(this,"intersectCheck",!0);f(this,"extraObjectsForIntersectCheck",[]);f(this,"simulate3D",!1);f(this,"tagWrapper");f(this,"five");f(this,"originPosition");f(this,"transformedPosition");f(this,"disposer");f(this,"config");f(this,"fiveUtil");f(this,"disposers",[]);f(this,"onModeChange",()=>{this.visibles[3]=void 0,this.updateVisible()});f(this,"onPanoArrived",()=>{this.visibles[3]=void 0,this.updateVisible()});f(this,"onCameraUpdate",()=>{this.visible!==!1&&this.updateScreenPosition()});f(this,"onCameraFovUpdate",()=>{this.onCameraUpdate(),this.five.off("render.prepare",this.onCameraUpdate),this.five.on("render.prepare",this.onCameraUpdate),setTimeout(()=>{this.five.off("render.prepare",this.onCameraUpdate)},1e3)});f(this,"onFiveEveryReady",()=>{this.five.state.mode!=="Panorama"&&this.updateVisible()});f(this,"updateVisible",()=>{this.visible&&(this.updateIntersectCheckVisible(),this.needsRender=!0)});f(this,"applyVisible",()=>{this.visibles[3]===!0||this.visibles.every(e=>e!==!1)?(this.container.style.opacity="1",this.container.style.pointerEvents="auto"):(this.container.style.opacity="0",this.container.style.pointerEvents="none")});f(this,"updateIntersectCheckVisible",()=>{var l,c;if(!this.position)return;if(!this.intersectCheck){this.visibles[1]=!0;return}let t=!1,e=.01;this.fiveUtil.workUtil.fromType==="poincare"&&(e=.05);const i=this.transformedPosition.clone().sub(this.five.camera.position).normalize();bn.set(this.five.camera.position,i);const s=(l=wi(this.five).intersectRaycaster(bn))!=null?l:[],o=(c=bn.intersectObjects(this.extraObjectsForIntersectCheck,!0))!=null?c:[],a=[...s,...o].sort((h,u)=>h.distance-u.distance)[0];a?t=(a==null?void 0:a.distance)+e>this.transformedPosition.distanceTo(this.five.camera.position):t=!0,this.visibles[1]=t});var s,o,r;this.five=t,this.fiveUtil=(s=t.__fiveUtil__)!=null?s:t.__fiveUtil__=new Pa(t),this.originPosition=e?Ve(e).clone():void 0,this.transformedPosition=(o=this.originPosition)==null?void 0:o.clone(),this.positionsForRotate=(r=i==null?void 0:i.positionsForRotate)==null?void 0:r.map(a=>Ve(a).clone()),this.config=i!=null?i:{},this.container=(()=>{const a=document.createElement("div");return a.classList.add("light-tag"),a.style.width="0",a.style.height="0",a.style.position="absolute",i!=null&&i.disableOpacityTransition||(a.style.transition="opacity 0.2s linear"),a})(),this.addResizeListener(),this.show(),this.enable(),setTimeout(()=>{this.updateVisible(),this.needsRender=!0},0)}get position(){return this.transformedPosition}set needsRender(t){this.applyVisible()}show(t){this.visible=!0,this.visibles[0]=!0,t!=null&&t.force&&(this.visibles[3]=!0),this.container.style.opacity="1",this.container.style.pointerEvents="auto",this.updateVisible(),this.onCameraUpdate()}hide(){this.visible=!1,this.visibles[0]=!1,this.container.style.opacity="0",this.container.style.pointerEvents="none"}enable(){return te(this,null,function*(){var i,s,o,r;if(this.enabled||(this.enabled=!0,yield Ci(this.five),!this.enabled))return;if(this.wrapper=(s=this.config.wrapper)!=null?s:(i=this.five.getElement())==null?void 0:i.parentElement,!this.wrapper){console.error("lighttag: wrapper is required");return}const t=`light-tag-wrapper-${(r=(o=this.config)==null?void 0:o.namespace)!=null?r:"default"}`;if(!this.tagWrapper){let a=Array.from(this.wrapper.children).find(l=>l.id===t);if(!a){const l=document.createElement("div");a=l,l.id=t,l.style.position="absolute",l.style.overflow="hidden",l.style.top="0",l.style.left="0",l.style.width="100%",l.style.height="100%",l.style.pointerEvents="none",l.style.zIndex="1",this.wrapper.appendChild(a)}this.tagWrapper=a}this.tagWrapper.appendChild(this.container),this.updateVisible();const e=fc(this.five,this.onFiveEveryReady);this.five.on("cameraUpdate",this.onCameraUpdate),this.five.on("cameraFovUpdate",this.onCameraFovUpdate),this.five.on("panoArrived",this.onPanoArrived),this.five.on("modeChange",this.onModeChange),this.disposer=()=>{e(),this.five.off("cameraUpdate",this.onCameraUpdate),this.five.off("cameraFovUpdate",this.onCameraFovUpdate),this.five.off("panoArrived",this.onPanoArrived),this.five.off("modeChange",this.onModeChange)}})}disable(){var t;this.enabled&&(this.enabled=!1,this.tagWrapper&&this.container&&this.tagWrapper.contains(this.container)&&this.tagWrapper.removeChild(this.container),(t=this.disposer)==null||t.call(this))}destroy(){this.disable(),this.container.remove(),this.disposers.forEach(t=>t())}setPosition(t,e){this.transformedPosition=Ve(t).clone(),this.positionsForRotate=e==null?void 0:e.map(i=>Ve(i).clone()),this.onCameraUpdate(),setTimeout(()=>this.onCameraUpdate(),0)}setTransformMatrix(t){var e;this.transformedPosition=(e=this.originPosition)==null?void 0:e.clone().applyMatrix4(t),this.onCameraUpdate()}updateScreenPosition(){var o;if(!this.transformedPosition){this.container.style.left="-100%",this.container.style.top="-100%";return}const t=(o=this.five.renderer)==null?void 0:o.getSize($y);if(!t){this.container.style.left="-100%",this.container.style.top="-100%";return}const e=cc(this.five.camera,this.transformedPosition,t);if(!e){this.container.style.left="-100%",this.container.style.top="-100%";return}const i=(()=>{if(!this.simulate3D)return 1;const a=3*Math.tan(.5*this.five.camera.fov/180*Math.PI),l=this.transformedPosition.distanceTo(this.five.camera.position);return Math.max(Math.min(1-a*l/40,1),.75)})(),s=(()=>{if(this.positionsForRotate===void 0||this.positionsForRotate.length!==2)return 0;const[r,a]=this.positionsForRotate,l=cc(this.five.camera,r,t),c=cc(this.five.camera,a,t);if(!l||!c)return 0;const h=l.leftPx>c.leftPx?c:l,u=l.leftPx>c.leftPx?l:c,d=u.leftPx-h.leftPx,p=u.topPx-h.topPx;return Math.atan2(p,d)*(180/Math.PI)})();this.container.style.left=e.leftPx+"px",this.container.style.top=e.topPx+"px",this.container.style.transformOrigin="center",this.container.style.transform=`scale(${i})`,s&&(this.container.style.transform+=` rotate(${s}deg)`)}addResizeListener(){const t=this.five.getElement();if(t){const{observe:e,unobserve:i}=Ca(this.onCameraUpdate,t);e(),this.disposers.push(i)}}}function Id(...n){return new dr(...n)}function Gn(n){return n.toLowerCase().includes("panorama")}function Pi(n){return!Gn(n)}var zi=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},fr={},eb={get exports(){return fr},set exports(n){fr=n}};/*! Hammer.JS - v2.0.7 - 2016-04-22
* http://hammerjs.github.io/
*
* Copyright (c) 2016 Jorik Tangelder;
* Licensed under the MIT license */(function(n){(function(t,e,i,s){var o=["","webkit","Moz","MS","ms","o"],r=e.createElement("div"),a="function",l=Math.round,c=Math.abs,h=Date.now;function u(G,Q,$){return setTimeout(I(G,$),Q)}function d(G,Q,$){return Array.isArray(G)?(p(G,$[Q],$),!0):!1}function p(G,Q,$){var re;if(G)if(G.forEach)G.forEach(Q,$);else if(G.length!==s)for(re=0;re<G.length;)Q.call($,G[re],re,G),re++;else for(re in G)G.hasOwnProperty(re)&&Q.call($,G[re],re,G)}function g(G,Q,$){var re="DEPRECATED METHOD: "+Q+`
`+$+` AT
`;return function(){var Ce=new Error("get-stack-trace"),je=Ce&&Ce.stack?Ce.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",Xe=t.console&&(t.console.warn||t.console.log);return Xe&&Xe.call(t.console,re,je),G.apply(this,arguments)}}var m;typeof Object.assign!="function"?m=function(Q){if(Q===s||Q===null)throw new TypeError("Cannot convert undefined or null to object");for(var $=Object(Q),re=1;re<arguments.length;re++){var Ce=arguments[re];if(Ce!==s&&Ce!==null)for(var je in Ce)Ce.hasOwnProperty(je)&&($[je]=Ce[je])}return $}:m=Object.assign;var v=g(function(Q,$,re){for(var Ce=Object.keys($),je=0;je<Ce.length;)(!re||re&&Q[Ce[je]]===s)&&(Q[Ce[je]]=$[Ce[je]]),je++;return Q},"extend","Use `assign`."),y=g(function(Q,$){return v(Q,$,!0)},"merge","Use `assign`.");function w(G,Q,$){var re=Q.prototype,Ce;Ce=G.prototype=Object.create(re),Ce.constructor=G,Ce._super=re,$&&m(Ce,$)}function I(G,Q){return function(){return G.apply(Q,arguments)}}function C(G,Q){return typeof G==a?G.apply(Q&&Q[0]||s,Q):G}function L(G,Q){return G===s?Q:G}function S(G,Q,$){p(A(Q),function(re){G.addEventListener(re,$,!1)})}function j(G,Q,$){p(A(Q),function(re){G.removeEventListener(re,$,!1)})}function z(G,Q){for(;G;){if(G==Q)return!0;G=G.parentNode}return!1}function O(G,Q){return G.indexOf(Q)>-1}function A(G){return G.trim().split(/\s+/g)}function M(G,Q,$){if(G.indexOf&&!$)return G.indexOf(Q);for(var re=0;re<G.length;){if($&&G[re][$]==Q||!$&&G[re]===Q)return re;re++}return-1}function k(G){return Array.prototype.slice.call(G,0)}function E(G,Q,$){for(var re=[],Ce=[],je=0;je<G.length;){var Xe=Q?G[je][Q]:G[je];M(Ce,Xe)<0&&re.push(G[je]),Ce[je]=Xe,je++}return $&&(Q?re=re.sort(function(Tt,Rt){return Tt[Q]>Rt[Q]}):re=re.sort()),re}function x(G,Q){for(var $,re,Ce=Q[0].toUpperCase()+Q.slice(1),je=0;je<o.length;){if($=o[je],re=$?$+Ce:Q,re in G)return re;je++}return s}var D=1;function B(){return D++}function H(G){var Q=G.ownerDocument||G;return Q.defaultView||Q.parentWindow||t}var K=/mobile|tablet|ip(ad|hone|od)|android/i,ne="ontouchstart"in t,q=x(t,"PointerEvent")!==s,oe=ne&&K.test(navigator.userAgent),J="touch",fe="pen",Pe="mouse",se="kinect",we=25,ue=1,le=2,Ae=4,ie=8,Le=1,Re=2,he=4,Be=8,be=16,Ee=Re|he,Oe=Be|be,qe=Ee|Oe,Je=["x","y"],at=["clientX","clientY"];function it(G,Q){var $=this;this.manager=G,this.callback=Q,this.element=G.element,this.target=G.options.inputTarget,this.domHandler=function(re){C(G.options.enable,[G])&&$.handler(re)},this.init()}it.prototype={handler:function(){},init:function(){this.evEl&&S(this.element,this.evEl,this.domHandler),this.evTarget&&S(this.target,this.evTarget,this.domHandler),this.evWin&&S(H(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&j(this.element,this.evEl,this.domHandler),this.evTarget&&j(this.target,this.evTarget,this.domHandler),this.evWin&&j(H(this.element),this.evWin,this.domHandler)}};function nt(G){var Q,$=G.options.inputClass;return $?Q=$:q?Q=zn:oe?Q=fs:ne?Q=jn:Q=Bi,new Q(G,ht)}function ht(G,Q,$){var re=$.pointers.length,Ce=$.changedPointers.length,je=Q&ue&&re-Ce===0,Xe=Q&(Ae|ie)&&re-Ce===0;$.isFirst=!!je,$.isFinal=!!Xe,je&&(G.session={}),$.eventType=Q,ft(G,$),G.emit("hammer.input",$),G.recognize($),G.session.prevInput=$}function ft(G,Q){var $=G.session,re=Q.pointers,Ce=re.length;$.firstInput||($.firstInput=Zt(Q)),Ce>1&&!$.firstMultiple?$.firstMultiple=Zt(Q):Ce===1&&($.firstMultiple=!1);var je=$.firstInput,Xe=$.firstMultiple,Et=Xe?Xe.center:je.center,Tt=Q.center=vi(re);Q.timeStamp=h(),Q.deltaTime=Q.timeStamp-je.timeStamp,Q.angle=Jt(Et,Tt),Q.distance=qt(Et,Tt),Gt($,Q),Q.offsetDirection=pt(Q.deltaX,Q.deltaY);var Rt=Di(Q.deltaTime,Q.deltaX,Q.deltaY);Q.overallVelocityX=Rt.x,Q.overallVelocityY=Rt.y,Q.overallVelocity=c(Rt.x)>c(Rt.y)?Rt.x:Rt.y,Q.scale=Xe?Js(Xe.pointers,re):1,Q.rotation=Xe?oa(Xe.pointers,re):0,Q.maxPointers=$.prevInput?Q.pointers.length>$.prevInput.maxPointers?Q.pointers.length:$.prevInput.maxPointers:Q.pointers.length,un($,Q);var li=G.element;z(Q.srcEvent.target,li)&&(li=Q.srcEvent.target),Q.target=li}function Gt(G,Q){var $=Q.center,re=G.offsetDelta||{},Ce=G.prevDelta||{},je=G.prevInput||{};(Q.eventType===ue||je.eventType===Ae)&&(Ce=G.prevDelta={x:je.deltaX||0,y:je.deltaY||0},re=G.offsetDelta={x:$.x,y:$.y}),Q.deltaX=Ce.x+($.x-re.x),Q.deltaY=Ce.y+($.y-re.y)}function un(G,Q){var $=G.lastInterval||Q,re=Q.timeStamp-$.timeStamp,Ce,je,Xe,Et;if(Q.eventType!=ie&&(re>we||$.velocity===s)){var Tt=Q.deltaX-$.deltaX,Rt=Q.deltaY-$.deltaY,li=Di(re,Tt,Rt);je=li.x,Xe=li.y,Ce=c(li.x)>c(li.y)?li.x:li.y,Et=pt(Tt,Rt),G.lastInterval=Q}else Ce=$.velocity,je=$.velocityX,Xe=$.velocityY,Et=$.direction;Q.velocity=Ce,Q.velocityX=je,Q.velocityY=Xe,Q.direction=Et}function Zt(G){for(var Q=[],$=0;$<G.pointers.length;)Q[$]={clientX:l(G.pointers[$].clientX),clientY:l(G.pointers[$].clientY)},$++;return{timeStamp:h(),pointers:Q,center:vi(Q),deltaX:G.deltaX,deltaY:G.deltaY}}function vi(G){var Q=G.length;if(Q===1)return{x:l(G[0].clientX),y:l(G[0].clientY)};for(var $=0,re=0,Ce=0;Ce<Q;)$+=G[Ce].clientX,re+=G[Ce].clientY,Ce++;return{x:l($/Q),y:l(re