@realsee/dnalogel
Version:
107 lines (94 loc) • 1.76 MB
JavaScript
"use strict";var Ey=Object.defineProperty,xy=Object.defineProperties;var ky=Object.getOwnPropertyDescriptors;var ba=Object.getOwnPropertySymbols;var hd=Object.prototype.hasOwnProperty,ud=Object.prototype.propertyIsEnumerable;var ui=Math.pow,ic=(n,t,e)=>t in n?Ey(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,R=(n,t)=>{for(var e in t||(t={}))hd.call(t,e)&&ic(n,e,t[e]);if(ba)for(var e of ba(t))ud.call(t,e)&&ic(n,e,t[e]);return n},de=(n,t)=>xy(n,ky(t));var Jn=(n,t)=>{var e={};for(var i in n)hd.call(n,i)&&t.indexOf(i)<0&&(e[i]=n[i]);if(n!=null&&ba)for(var i of ba(n))t.indexOf(i)<0&&ud.call(n,i)&&(e[i]=n[i]);return e};var f=(n,t,e)=>(ic(n,typeof t!="symbol"?t+"":t,e),e);var te=(n,t,e)=>new Promise((i,s)=>{var o=l=>{try{a(e.next(l))}catch(c){s(c)}},r=l=>{try{a(e.throw(l))}catch(c){s(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,r);a((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const at=require("@realsee/five"),G=require("three"),Kr=require("@realsee/five/line"),m0=require("@realsee/five/gltf-loader");function Sy(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=Sy(G);function Ty(){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 Dy(){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 v0(){}const dd=()=>Promise.resolve(),fd={__queue:Promise.resolve()};function Ly(n=dd){fd.__queue=fd.__queue.then(n).catch(dd)}function Aa(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 nc(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function wa(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 zy(n,t,e=v0){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const Oy=window,pd=window.requestAnimationFrame||Oy.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function Va(n,t=0){t<=0?pd(n):pd(()=>Va(n,t-1))}var Gi=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-Gi.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?Gi.Bounce.In(n*2)*.5:Gi.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}}}}),wo=function(){return performance.now()},y0=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=wo()),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}(),Ss={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Ss.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=Ss.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=Ss.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=Ss.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}}},Dh=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Gc=new y0,Cl=function(){function n(t,e){e===void 0&&(e=Gc),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=Gi.Linear.None,this._interpolationFunction=Ss.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Dh.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=wo()),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=wo()),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=wo()),!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=Gc),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=Gi.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Ss.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=wo()),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}(),jy="23.1.3",Ry=Dh.nextId,ln=Gc,_y=ln.getAll.bind(ln),Vy=ln.removeAll.bind(ln),By=ln.add.bind(ln),b0=ln.remove.bind(ln),Fy=ln.update.bind(ln),gd={Easing:Gi,Group:y0,Interpolation:Ss,now:wo,Sequence:Dh,nextId:Ry,Tween:Cl,VERSION:jy,getAll:_y,removeAll:Vy,add:By,remove:b0,update:Fy};function Hy(n,t,e,i=Gi.Linear.None){const s=new Cl(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var Mn=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(Mn||{});const Mr=Symbol("$$PAINT_BRUSH_EVENT$$");function Pa(n){return n[Mr]||(n[Mr]={}),n[Mr]}function Ny(n){n[Mr]||delete n[Mr]}let Gy=class{hasListener(t){const e=Pa(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=Pa(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){Ny(this);return}const i=Pa(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=Pa(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 Kn(){return((1+Math.random())*65536|0).toString(16).substring(1)}function Mt(){return(Kn()+Kn()+"-"+Kn()+"-4"+Kn().substr(0,3)+"-"+Kn()+"-"+Kn()+Kn()+Kn()).toLowerCase()}const Wy=`
<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 Uy=class extends Gy{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=Wy,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:Mn.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:Mn.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=Aa({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(Aa({x:d,y:p},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:g,end:m}=wa(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),Va(()=>{this.emitStateChange({type:Mn.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=Aa({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(Aa({x:d,y:p},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:g,end:m}=wa(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),Va(()=>{this.emitStateChange({type:Mn.Drawline,color:this.color,ready:this.ready,state:p,uuid:this.uuid})})}}emitStateChange(e,i=!0){if(e.type!==Mn.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};zy(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 Mn.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 Mn.Undo:this.handleUndo(o);break}}handleDrawLine(e,i,{withUndo:s=!1},o=v0){!i||Object.prototype.toString.call(i)!="[object Object]"||Object.keys(i).length===0||Ly(()=>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=nc(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=Hy({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(nc(l[y],m.clientWidth,m.clientHeight)),p.length<3)return;const{control:I,end:C}=wa(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(nc(l[g],this.clientWidth,this.clientHeight)),p.length<3)continue;const{control:m,end:v}=wa(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(),Va(i,60);return}i()}destroyBrush(){this.closeBrush(),this.ready=!1,this.emit("readyChange",!0)}};class Qy{constructor(t={}){f(this,"controller");const e=Object.assign({currentColor:"#f44336",onUndoText:"回退",onExitText:"关闭"},t);this.controller=new Uy(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 Xy(n){return typeof Symbol=="undefined"?`$Symbol<${n}>$`:Symbol(n)}const Er=Xy("$$EVENT$$");function fr(n){return n[Er]||(n[Er]={}),n[Er]}function Yy(n){n[Er]&&delete n[Er]}class St{hasListener(t){const e=fr(this);return!!(e!=null&&e[t]&&e[t].length>0)}on(t,e,i){const s=fr(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){Yy(this);return}const i=fr(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=fr(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=fr(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 Wc{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 Zy=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 Wc(this.min.x,this.max.x),this.yInterval=new Wc(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 qy(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&&Jy(e[e.length-2],e[e.length-1],n[s]);)e.pop();e.push(n[s])}return e.pop(),e}function Jy(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 md(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 Ky=({x:n,y:t,z:e})=>new G.Vector3(n,t,e),Lt=n=>new G.Vector3().fromArray(n),Re=n=>{if(n)return n instanceof G.Vector3?n:Array.isArray(n)?Lt(n):Ky(n)};function $y(n){if(n)return Array.isArray(n)?typeof n[0]=="number"?Re(n):n.map(Re):Re(n)}function sc(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 xi(n){var e;return((e=n.models)==null?void 0:e.filter(i=>i.name===n.state.workCode)[0])||n.model}class A0 extends St{constructor(e){super();f(this,"five");this.five=e}}const Vt=(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)},oc=new Map;class eb extends A0{constructor(e){super(e);f(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(oc.has(e))return oc.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return oc.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 Vt(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return Vt(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class Il extends A0{constructor(e){super(e);f(this,"workUtil",new eb(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return xi(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}class Or extends b.Raycaster{intersectObject(t,e=!0,i=[]){return Uc(t,this,i,e),i.sort(vd),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(vd),i}}function vd(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 Lh(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"&&Lh(o[r],t,e,!0)}}const Tn=new Or;Tn.params.Points.threshold=.02;function Xa(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 $r(n,t=200){let e;return function(...i){e||(n(...i),e=setTimeout(function(){e=null},t))}}function zh(n,t){let e=!1;const i=$r(()=>{e||(e=!0,n.ready().then(()=>{t(),e=!1}))},150);return n.on("camera.update",i),()=>{n.off("camera.update",i)}}const tb=new G.Vector2;class ea{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();Tn.set(this.five.camera.position,i);const s=(l=xi(this.five).intersectRaycaster(Tn))!=null?l:[],o=(c=Tn.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 Il(t),this.originPosition=e?Re(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=>Re(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 ki(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=zh(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=Re(t).clone(),this.positionsForRotate=e==null?void 0:e.map(i=>Re(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(tb);if(!t){this.container.style.left="-100%",this.container.style.top="-100%";return}const e=sc(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=sc(this.five.camera,r,t),c=sc(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}=Xa(this.onCameraUpdate,t);e(),this.disposers.push(i)}}}function w0(...n){return new ea(...n)}function os(n){return n.toLowerCase().includes("panorama")}function Ii(n){return!os(n)}var ji=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},jr={},ib={get exports(){return jr},set exports(n){jr=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(F,Q,$){return setTimeout(I(F,$),Q)}function d(F,Q,$){return Array.isArray(F)?(p(F,$[Q],$),!0):!1}function p(F,Q,$){var re;if(F)if(F.forEach)F.forEach(Q,$);else if(F.length!==s)for(re=0;re<F.length;)Q.call($,F[re],re,F),re++;else for(re in F)F.hasOwnProperty(re)&&Q.call($,F[re],re,F)}function g(F,Q,$){var re="DEPRECATED METHOD: "+Q+`
`+$+` AT
`;return function(){var Pe=new Error("get-stack-trace"),Oe=Pe&&Pe.stack?Pe.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",Qe=t.console&&(t.console.warn||t.console.log);return Qe&&Qe.call(t.console,re,Oe),F.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 Pe=arguments[re];if(Pe!==s&&Pe!==null)for(var Oe in Pe)Pe.hasOwnProperty(Oe)&&($[Oe]=Pe[Oe])}return $}:m=Object.assign;var v=g(function(Q,$,re){for(var Pe=Object.keys($),Oe=0;Oe<Pe.length;)(!re||re&&Q[Pe[Oe]]===s)&&(Q[Pe[Oe]]=$[Pe[Oe]]),Oe++;return Q},"extend","Use `assign`."),y=g(function(Q,$){return v(Q,$,!0)},"merge","Use `assign`.");function w(F,Q,$){var re=Q.prototype,Pe;Pe=F.prototype=Object.create(re),Pe.constructor=F,Pe._super=re,$&&m(Pe,$)}function I(F,Q){return function(){return F.apply(Q,arguments)}}function C(F,Q){return typeof F==a?F.apply(Q&&Q[0]||s,Q):F}function L(F,Q){return F===s?Q:F}function S(F,Q,$){p(A(Q),function(re){F.addEventListener(re,$,!1)})}function j(F,Q,$){p(A(Q),function(re){F.removeEventListener(re,$,!1)})}function z(F,Q){for(;F;){if(F==Q)return!0;F=F.parentNode}return!1}function O(F,Q){return F.indexOf(Q)>-1}function A(F){return F.trim().split(/\s+/g)}function M(F,Q,$){if(F.indexOf&&!$)return F.indexOf(Q);for(var re=0;re<F.length;){if($&&F[re][$]==Q||!$&&F[re]===Q)return re;re++}return-1}function E(F){return Array.prototype.slice.call(F,0)}function k(F,Q,$){for(var re=[],Pe=[],Oe=0;Oe<F.length;){var Qe=Q?F[Oe][Q]:F[Oe];M(Pe,Qe)<0&&re.push(F[Oe]),Pe[Oe]=Qe,Oe++}return $&&(Q?re=re.sort(function(kt,Rt){return kt[Q]>Rt[Q]}):re=re.sort()),re}function x(F,Q){for(var $,re,Pe=Q[0].toUpperCase()+Q.slice(1),Oe=0;Oe<o.length;){if($=o[Oe],re=$?$+Pe:Q,re in F)return re;Oe++}return s}var T=1;function V(){return T++}function N(F){var Q=F.ownerDocument||F;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",we="mouse",se="kinect",Ae=25,ue=1,le=2,be=4,ie=8,De=1,Ve=2,he=4,_e=8,ve=16,xe=Ve|he,ze=_e|ve,Xe=xe|ze,Ze=["x","y"],ot=["clientX","clientY"];function $e(F,Q){var $=this;this.manager=F,this.callback=Q,this.element=F.element,this.target=F.options.inputTarget,this.domHandler=function(re){C(F.options.enable,[F])&&$.handler(re)},this.init()}$e.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(N(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(N(this.element),this.evWin,this.domHandler)}};function tt(F){var Q,$=F.options.inputClass;return $?Q=$:q?Q=gn:oe?Q=Gn:ne?Q=vn:Q=Di,new Q(F,rt)}function rt(F,Q,$){var re=$.pointers.length,Pe=$.changedPointers.length,Oe=Q&ue&&re-Pe===0,Qe=Q&(be|ie)&&re-Pe===0;$.isFirst=!!Oe,$.isFinal=!!Qe,Oe&&(F.session={}),$.eventType=Q,ct(F,$),F.emit("hammer.input",$),F.recognize($),F.session.prevInput=$}function ct(F,Q){var $=F.session,re=Q.pointers,Pe=re.length;$.firstInput||($.firstInput=Ut(Q)),Pe>1&&!$.firstMultiple?$.firstMultiple=Ut(Q):Pe===1&&($.firstMultiple=!1);var Oe=$.firstInput,Qe=$.firstMultiple,Ct=Qe?Qe.center:Oe.center,kt=Q.center=li(re);Q.timeStamp=h(),Q.deltaTime=Q.timeStamp-Oe.timeStamp,Q.angle=Xt(Ct,kt),Q.distance=Qt(Ct,kt),Bt($,Q),Q.offsetDirection=ht(Q.deltaX,Q.deltaY);var Rt=bi(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=Qe?bs(Qe.pointers,re):1,Q.rotation=Qe?tr(Qe.pointers,re):0,Q.maxPointers=$.prevInput?Q.pointers.length>$.prevInput.maxPointers?Q.pointers.length:$.prevInput.maxPointers:Q.pointers.length,Zi($,Q);var ii=F.element;z(Q.srcEvent.target,ii)&&(ii=Q.srcEvent.target),Q.target=ii}function Bt(F,Q){var $=Q.center,re=F.offsetDelta||{},Pe=F.prevDelta||{},Oe=F.prevInput||{};(Q.eventType===ue||Oe.eventType===be)&&(Pe=F.prevDelta={x:Oe.deltaX||0,y:Oe.deltaY||0},re=F.offsetDelta={x:$.x,y:$.y}),Q.deltaX=Pe.x+($.x-re.x),Q.deltaY=Pe.y+($.y-re.y)}function Zi(F,Q){var $=F.lastInterval||Q,re=Q.timeStamp-$.timeStamp,Pe,Oe,Qe,Ct;if(Q.eventType!=ie&&(re>Ae||$.velocity===s)){var kt=Q.deltaX-$.deltaX,Rt=Q.deltaY-$.deltaY,ii=bi(re,kt,Rt);Oe=ii.x,Qe=ii.y,Pe=c(ii.x)>c(ii.y)?ii.x:ii.y,Ct=ht(kt,Rt),F.lastInterval=Q}else Pe=$.velocity,Oe=$.velocityX,Qe=$.velocityY,Ct=$.direction;Q.velocity=Pe,Q.velocityX=Oe,Q.velocityY=Qe,Q.direction=Ct}function Ut(F){for(var Q=[],$=0;$<F.pointers.length;)Q[$]={clientX:l(F.pointers[$].clientX),clientY:l(F.pointers[$].clientY)},$++;return{timeStamp:h(),pointers:Q,center:li(Q),deltaX:F.deltaX,deltaY:F.deltaY}}function li(F){var Q=F.length;if(Q===1)return{x:l(F[0].clientX),y:l(F[0].clientY)};for(var $=0,re=0,Pe=0;Pe<Q;)$+=F[Pe].clientX,re+=F[Pe].clientY,Pe++;return{x:l($/Q),y:l(re/Q)}}function bi(F,Q,$){return{x:Q/F||0,y:$/F||0}}function ht(F,Q){return F===Q?De:c(F)>=c(Q)?F<0?Ve:he:Q<0?_e:ve}function Qt(F,Q,$){$||($=Ze);var re=Q[$[0]]-F[$[0]],Pe=Q[$[1]]-F[$[1]];return Math.sqrt(re*re+Pe*Pe)}function Xt(F,Q,$){$||($=Ze);var re=Q[$[0]]-F[$[0]],Pe=Q[$[1]]-F[$[1]];return Math.atan2(Pe,re)*180/Math.PI}function tr(F,Q){return Xt(Q[1],Q[0],ot)+Xt(F[1],F[0],ot)}funct