@atlas-viewer/atlas 2.3.4 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var un=Object.defineProperty;var mn=(r,e,t)=>e in r?un(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e,t)=>(mn(r,typeof e!="symbol"?e+"":e,t),t);var At=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver"];function Xe(){return At.reduce((r,e)=>(r[e]=[],r),{})}var Y=At.reduce((r,e)=>(r[e.slice(2).toLowerCase()]=e,r[e]=e,r),{});import{dna as Ce,DnaFactory as vt,mutate as pn,translate as yn}from"@atlas-viewer/dna";import{mutate as Ee,scaleAtOrigin as fn,translate as gn}from"@atlas-viewer/dna";var Ye="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Q=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Ye[t[r]&63];return e};var k=class{constructor(){a(this,"__id");a(this,"__revision",0);a(this,"__host");a(this,"__onCreate");a(this,"__parent");a(this,"__owner",{value:void 0});a(this,"__state",{});a(this,"eventHandlers");a(this,"scale",1);a(this,"layers",[]);a(this,"time",[]);a(this,"_crop");a(this,"cropData");a(this,"id");a(this,"addEventListener",(e,t,i)=>{let n=Y[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});a(this,"removeEventListener",(e,t)=>{let i=Y[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))});this.id=this.__id=Q(),this.eventHandlers=Xe()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,s=!1;if(n)for(let o=0;o<n;o++)try{i[o](t),s=!0}catch(h){console.error(e,h)}return s}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){Ee(this.points,gn(e,t))}atScale(e){Ee(this.points,fn(e,this.x,this.y)),this.scale*=e}transform(e){Ee(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var D=class r extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"priority");a(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ce(5)},this.points=Ce(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=vt.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:vt.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(vt.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let s=vt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);pn(s,yn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(s):this.crop=Ce(s)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=vt.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=vt.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,s){return r.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,s)}static fromImage(t,i,n,s){let o=new r;return o.applyProps({uri:t,id:s,display:n,target:i}),o}getImageUrl(){return this.uri}};import{dna as Qe,DnaFactory as Ut}from"@atlas-viewer/dna";var dt=class extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"getTexture");if(this.getTexture=()=>({source:void 0,hash:-1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Qe(5)},this.points=Qe(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Ut.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?Ut.singleBox(t.width/i,t.height/i):this.points}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;this.id=t.id,this.points.set(Ut.singleBox(t.target.width,t.target.height)),this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.getTexture=t.getTexture,this.display.points=n!==1?Ut.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as Je,hidePointsOutsideRegion as bn,mutate as ti,scale as vn,transform as wn,dna as xn,translate as Sn}from"@atlas-viewer/dna";function Ke(r,e,t=1){let i=e.length;if(i===0)throw new Error("No resources passed in.");let n=0,s=1/0;for(let o=0;o<i&&!(!e[o]||!e[o].display);o++){let h=Re(e[o].display.scale,r/(t||1));h<s&&(s=h,n=o)}return n}function Re(r,e){return Math.abs(r-e)}function ct(r,e){let t=Re(r.x,e.x),i=Re(r.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function qe(r){let e=r.length;return r.indexOf("/info.json")===e-10?r.slice(0,-10):r}function $t(r,e,t){return Math.min(Math.max(r,e),t)}var $=class r extends k{constructor(t){super();a(this,"id");a(this,"type","spacial-content");a(this,"display");a(this,"tileWidth");a(this,"style",{opacity:1});a(this,"points");a(this,"service");a(this,"format","jpg");a(this,"crop2");a(this,"version3");a(this,"tileUrl");this.tileUrl=qe(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:wn(t.points,vn(t.scaleFactor)),this.tileWidth=t.tileWidth,this.version3=t.version3,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",t.crop){this.cropData=t.crop;let i=xn([...this.points]),n=i.length/5,s=t.crop.x||0,o=t.crop.y||0,h=t.crop.x+t.crop.width,l=t.crop.y+t.crop.height;for(let c=0;c<n;c++){let d=c*5;i[d+1]<h&&i[d+3]>s&&i[d+2]<l&&i[d+4]>o?(i[d+1]=$t(i[d+1],s,h),i[d+3]=$t(i[d+3],s,h),i[d+2]=$t(i[d+2],o,l),i[d+4]=$t(i[d+4],o,l)):i[d]=0}ti(i,Sn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,s,o,h,l,c){n.height=n.height?n.height:n.width;let d=l?Math.floor(i.width/s):Math.ceil(i.width/s),u=l?Math.floor(i.height/s):Math.ceil(i.height/s),m=Math.ceil(d/n.width),y=Math.ceil(u/n.height),v=Je.grid(m,y),S=Je.grid(m,y),P=o?o["@context"]?Array.isArray(o["@context"])?o["@context"]:[o["@context"]]:[]:[],g=typeof c<"u"?c:P.indexOf("http://iiif.io/api/image/3/context.json")!==-1;for(let C=0;C<y;C++)for(let R=0;R<m;R++){let w=R*n.width,b=C*n.height;S.addPoints(w*s,b*s,R===m-1?i.width:(w+n.width)*s,C===y-1?i.height:(b+n.height)*s),v.addPoints(w,b,R===m-1?d:w+n.width,C===y-1?u:b+n.height)}let f=new r({url:t,scaleFactor:s,points:v.build(),displayPoints:S.build(),width:i.width,height:i.height,tileWidth:n.width,format:h,version3:g});return f.applyProps({service:o}),f}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],s=i[4]-i[2],o=Math.ceil(n/this.display.scale),h=Math.ceil(s/this.display.scale),l=`${o>this.tileWidth?this.tileWidth:o},`;return this.version3&&(l+=`${h>this.tileWidth?this.tileWidth:h}`),`${this.tileUrl}/${i[1]},${i[2]},${n},${s}/${l}/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let s=bn(this.crop||this.points,t);return[[this,s,i]]}transform(t){ti(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Pn,dna as En,DnaFactory as ei,translate as ii}from"@atlas-viewer/dna";var Vt=class extends k{constructor(){super(...arguments);a(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var Gt=class extends Vt{constructor(t){super();a(this,"id");a(this,"display");a(this,"points");a(this,"images",[]);a(this,"allImages",[]);a(this,"scaleFactors",[]);a(this,"aggregateBuffer",En(9));a(this,"lazyLoader");a(this,"isFullyLoaded",!1);a(this,"maxScaleFactor",0);a(this,"renderOptions");a(this,"_scheduleSortByScales",!1);a(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages){if(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof D&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)continue;if(Math.abs(i.display.scale-t)<.25||i.priority){let s=this.images.pop();s&&(s instanceof D||s.priority)?(i.priority&&this.images.push(i),this.images.push(s)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)});a(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});a(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=ei.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:ei.singleBox(t.width,t.height),height:t.height,width:t.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...t.renderOptions||{}},this.addImages(t.images)}applyProps(t){typeof t.renderSmallestFallback<"u"&&t.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=t.renderSmallestFallback),typeof t.renderLayers<"u"&&t.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=t.renderLayers),typeof t.minSize<"u"&&t.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=t.minSize),typeof t.maxImageSize<"u"&&t.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=t.maxImageSize),typeof t.quality<"u"&&t.quality!==this.renderOptions.quality&&(this.renderOptions.quality=t.quality)}appendChild(t){this.addImages([t])}removeChild(t){this.images.indexOf(t)!==-1&&(this.images=this.images.filter(i=>i!==t),this.sortByScales())}insertBefore(t,i){this.addImages([t])}hideInstance(){}addImages(t){for(let i of t)i.__parent=this,i.__owner=this.__owner;this.allImages.push(...t.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(t,i){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:i>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(t,i,n){if(this.images.length===0)return[];let s=Ke(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),o=this.images.length,h=i?Pn(i,ii(this.x,this.y)):ii(this.x,this.y);if(s!==this.images.length-1&&this.images[s+1]){let l=[];for(let u=o-1;u>=s;u--)l.push(u);let c=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(c)===-1&&l.unshift(c);let d=[];for(let u=0;u<l.length;u++)d.push(...this.images[l[u]].getAllPointsAt(t,h,n));return d}return this.images[s].getAllPointsAt(t,h,n)}};import{compose as si,DnaFactory as Yt,dnaLength as Rn,hidePointsOutsideRegion as oi,mutate as ai,scale as Tn,scaleAtOrigin as _n,translate as hi,dna as ut}from"@atlas-viewer/dna";import{dna as z,compose as Te,getIntersection as Cn,scale as ni,transform as _e,translate as Zt,hidePointsOutsideRegion as ri}from"@atlas-viewer/dna";function Xt(r,e,t,i,n){let s=Math.PI/180*n,o=Math.cos(s),h=Math.sin(s),l=o*(t-r)+h*(i-e)+r,c=o*(i-e)-h*(t-r)+e;return[l,c]}var J=class r extends k{constructor(t,i){super();a(this,"id");a(this,"type","world-object");a(this,"scale");a(this,"layers");a(this,"points");a(this,"worldPoints");a(this,"intersectionBuffer",z(5));a(this,"aggregateBuffer",z(9));a(this,"invertedBuffer",z(9));a(this,"rotation",0);a(this,"filteredPointsBuffer");a(this,"_updatedList",[]);a(this,"geometry");let{x:n=0,y:s=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=z([1,n,s,n+t.width,s+t.height]),this.worldPoints=z([1,n,s,n+t.width,s+t.height]),this.filteredPointsBuffer=z(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=z(5),this.worldPoints=z(5),this.filteredPointsBuffer=z(5))}static createWithProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let s=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(s),this.scale=s}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=z(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let s=this.layers.slice(0,n),o=this.layers.slice(n);this.layers=[...s,t,...o]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),ri(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let s=this.layers.length,o=[];for(let h=0;h<s;h++){let l=this.layers[h];if(i&&l.isShape){let d=_e(l.points,Zt(this.x,this.y));if(!l.intersects([t[1]-d[1],t[2]-d[2]]))continue}if(ri(_e(l.points,Zt(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&o.push(l),i){let d=l;o.push(...d.getObjectsAt(t,i))}}return o}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},s={x:t[3],y:t[2]},o={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,l=this.points[2]+(this.points[4]-this.points[2])/2,[c,d]=Xt(h,l,i.x,i.y,this.rotation),[u,m]=Xt(h,l,n.x,n.y,this.rotation),[y,v]=Xt(h,l,s.x,s.y,this.rotation),[S,P]=Xt(h,l,o.x,o.y,this.rotation),g=Math.min(c,u,y,S),f=Math.max(c,u,y,S),C=Math.min(d,m,v,P),R=Math.max(d,m,v,P);return z([t[0],g,C,f,R])}return t}getAllPointsAt(t,i,n){let s=Te(Zt(this.x,this.y),ni(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let o=Cn(t,this.points,this.intersectionBuffer),h=this.layers.length,l=[],c=_e(o,Te(ni(1/this.scale),Zt(-this.x,-this.y),this.invertedBuffer)),d=i?Te(i,s,this.aggregateBuffer):s,u=n*this.scale;for(let m=0;m<h;m++)l.push(...this.layers[m].getAllPointsAt(c,d,u));return l}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||z([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(i),this.filteredPointsBuffer=z(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let s=i*this.scale;for(let o=0;o<n;o++){let h=this.layers[o].getScheduledUpdates(t,s);h&&this._updatedList.push(...h)}return this._updatedList}};var V=class r extends k{constructor(t=0,i=0,n=100,s="left-to-right"){super();a(this,"id","world");a(this,"_width");a(this,"_height");a(this,"aspectRatio");a(this,"viewingDirection");a(this,"aggregateBuffer",ut(9));a(this,"isDirty",!1);a(this,"zones",[]);a(this,"filteredPointsBuffer");a(this,"selectedZone");a(this,"triggerQueue",[]);a(this,"activatedEvents",[]);a(this,"_updatedList",[]);a(this,"translationBuffer",ut(9));a(this,"needsRecalculate",!0);a(this,"emptyPaintables",[]);a(this,"renderOrder",[]);a(this,"points");a(this,"objects",[]);a(this,"subscriptions",[]);a(this,"_propagateEventTargets",[]);a(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=s,this.points=ut(n*5),this.filteredPointsBuffer=ut(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let s=[];for(let o of n)if(o.x&&o.y){let h=Yt.singleBox(1,1,o.x,o.y);s.push(this.getObjectsAt(h,!0).reverse())}return s.map(o=>this.propagateEvent(t,i,o,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,s,o={}){let h=Yt.singleBox(1,1,n,s),l=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,l,o)}propagateEvent(t,i,n,{bubbles:s=!1,cancelable:o=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let l=n.length;for(let u=l-1;u>=0;u--){this._propagateEventTargets.unshift(n[u][0]);let m=n[u][1].length;if(m)for(let y=0;y<m;y++)this._propagateEventTargets.unshift(n[u][1][y])}let c=this._propagateEventTargets.length,d=!1;for(let u=0;u<c&&(i.atlasTarget=this._propagateEventTargets[u],i.atlasWorld=this,d=this._propagateEventTargets[u].dispatchEvent(t,i)||d,!h);u++);return d&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let s=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,s/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Rn(this.points)===this.objects.length){let t=this.points,i=ut(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=ut(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),s=this.renderOrder.length;for(let l=0;l<s;l++){let c=this.renderOrder[l];this.objects[c]&&(i[l]=this.points[c*5+3],n[l]=this.points[c*5+4])}let o=Math.max(...i);o!==this._width&&(this._width=o,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:o,height:h}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:s,y:o}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(Yt.singleBox(t.width,t.height,0,0),this.objects.length*5);let l=new J(t);return l.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(l),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,s,o),this.filteredPointsBuffer=ut(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,l}scaleWorldObject(t,i){ai(this.points.subarray(t*5,t*5+5),_n(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){ai(this.points.subarray(t*5,t*5+5),hi(i,n));let s=this.objects[t];s&&(s.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=Yt.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=oi(this.points,t,this.filteredPointsBuffer),s=this.objects.length;this._updatedList=[];for(let o=0;o<s;o++)if(n[o*5]!==0){if(!this.objects[o])continue;this._updatedList.push(...this.objects[o].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),s=oi(this.points,t,this.filteredPointsBuffer),o=this.renderOrder.length,h=[];for(let l=0;l<o;l++){let c=this.renderOrder[l];if(s[c*5]!==0){let d=this.objects[c];if(!d||n&&n.objects.indexOf(d)===-1)continue;if(d.type!=="world-object"){h.push([d,[d]]);continue}i?h.push([d,d.getObjectsAt(t,i)]):h.push([d,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let s=this.getObjectsAt(t),o=si(Tn(n),hi(-t[1],-t[2]),this.translationBuffer),h=i?si(i,o,this.aggregateBuffer):o,l=s.length,c=[];for(let d=0;d<l;d++)s[d]&&c.push(...s[d][0].getAllPointsAt(t,h,n));return c}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let s=0;s<n;s++)this.subscriptions[s].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};function qs(r){let{src:e,target:t}=r,i=t?t.width:r.width,n=t?t.height:r.height;return new J({id:e,height:n,width:i,layers:[D.fromImage(e,{height:n,width:i},{width:r.width,height:r.height})]})}import{dna as On}from"@atlas-viewer/dna";var An={margin:0},li=class{constructor(e,t={}){a(this,"id");a(this,"config");a(this,"points");a(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...An,...t},this.points=On(5),this.objects=e,this.recalculateBounds()}recalculateBounds(){this.points.set([1,Math.min(...this.objects.map(e=>e.points[1]))-this.config.margin,Math.min(...this.objects.map(e=>e.points[2]))-this.config.margin,Math.max(...this.objects.map(e=>e.points[3]))+this.config.margin,Math.max(...this.objects.map(e=>e.points[4]))+this.config.margin])}getPointsAt(e,t,i){return[]}};import{dna as di,DnaFactory as ci}from"@atlas-viewer/dna";var Qt=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,Kt={},Mn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],K=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:di(5)});a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=Q(12),this.points=di(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=Kt[n]||Qt.exec(n)||Qt.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=Kt[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=Kt[t.style.outline]||Qt.exec(t.style.outline)||Qt.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=Kt[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Mn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=ci.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=ci.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import{dna as ui,DnaFactory as In}from"@atlas-viewer/dna";var ot=class extends k{constructor(){super();a(this,"type","spacial-content");a(this,"id");a(this,"points");a(this,"color","#000");a(this,"backgroundColor");a(this,"hovering");a(this,"pressing");a(this,"text","");a(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:ui(5)});a(this,"className");a(this,"html");a(this,"interactive",!1);a(this,"props",{font:"18px Arial, sans-serif",lineHeight:1,textAlign:"left",verticalAlign:"top",paddingX:0,paddingY:0,fitParent:!1,lineBreak:"auto",strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:"none",interactive:!1,relativeSize:!1});this.id="",this.points=ui(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:s,backgroundColor:o,fontSize:h=18,interactive:l,fontFamily:c="Arial, sans-serif",...d}){d.font=`${h}px ${c}`,this.interactive=l||!1,typeof n<"u"&&(this.text=n||""),s&&(this.color=s),o&&(this.backgroundColor=o),t&&(this.id=t),i&&(this.points=In.singleBox(i.width,i.height,i.x,i.y),this.display.points=this.points,this.display.width=i.width,this.display.height=i.height),this.props={...this.props,...d},this.__revision++}};import{DnaFactory as wt,mutate as yi,scale as bi,scaleAtOrigin as vi,transform as Oe,dna as ne,translate as kn,compose as Fn}from"@atlas-viewer/dna";import{dna as Lt,DnaFactory as Ln}from"@atlas-viewer/dna";var L=Math.pow,qt=Math.sqrt,Mt=Math.sin,mi=Math.cos,It=Math.PI,ee=1.70158,Jt=ee*1.525,fi=ee+1,gi=2*It/3,pi=2*It/4.5,te=function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},q={linear:r=>r,easeInQuad:function(r){return r*r},easeOutQuad:function(r){return 1-(1-r)*(1-r)},easeInOutQuad:function(r){return r<.5?2*r*r:1-L(-2*r+2,2)/2},easeInCubic:function(r){return r*r*r},easeOutCubic:function(r){return 1-L(1-r,3)},easeInOutCubic:function(r){return r<.5?4*r*r*r:1-L(-2*r+2,3)/2},easeInQuart:function(r){return r*r*r*r},easeOutQuart:function(r){return 1-L(1-r,4)},easeInOutQuart:function(r){return r<.5?8*r*r*r*r:1-L(-2*r+2,4)/2},easeInQuint:function(r){return r*r*r*r*r},easeOutQuint:function(r){return 1-L(1-r,5)},easeInOutQuint:function(r){return r<.5?16*r*r*r*r*r:1-L(-2*r+2,5)/2},easeInSine:function(r){return 1-mi(r*It/2)},easeOutSine:function(r){return Mt(r*It/2)},easeInOutSine:function(r){return-(mi(It*r)-1)/2},easeInExpo:function(r){return r===0?0:L(2,10*r-10)},easeOutExpo:function(r){return r===1?1:1-L(2,-10*r)},easeInOutExpo:function(r){return r===0?0:r===1?1:r<.5?L(2,20*r-10)/2:(2-L(2,-20*r+10))/2},easeInCirc:function(r){return 1-qt(1-L(r,2))},easeOutCirc:function(r){return qt(1-L(r-1,2))},easeInOutCirc:function(r){return r<.5?(1-qt(1-L(2*r,2)))/2:(qt(1-L(-2*r+2,2))+1)/2},easeInBack:function(r){return fi*r*r*r-ee*r*r},easeOutBack:function(r){return 1+fi*L(r-1,3)+ee*L(r-1,2)},easeInOutBack:function(r){return r<.5?L(2*r,2)*((Jt+1)*2*r-Jt)/2:(L(2*r-2,2)*((Jt+1)*(r*2-2)+Jt)+2)/2},easeInElastic:function(r){return r===0?0:r===1?1:-L(2,10*r-10)*Mt((r*10-10.75)*gi)},easeOutElastic:function(r){return r===0?0:r===1?1:L(2,-10*r)*Mt((r*10-.75)*gi)+1},easeInOutElastic:function(r){return r===0?0:r===1?1:r<.5?-(L(2,20*r-10)*Mt((20*r-11.125)*pi))/2:L(2,-20*r+10)*Mt((20*r-11.125)*pi)/2+1},easeInBounce:function(r){return 1-te(1-r)},easeOutBounce:te,easeInOutBounce:function(r){return r<.5?(1-te(1-2*r))/2:(1+te(2*r-1))/2}};var ie=class{constructor(e){a(this,"runtime");a(this,"pendingTransition");a(this,"lastZoomTo",null);a(this,"isConstraining",!1);a(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Lt(5),to:Lt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:q.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=Lt(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,s=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*s,e[2]=i.from[2]+(i.to[2]-i.from[2])*s,e[3]=i.from[3]+(i.to[3]-i.from[3])*s,e[4]=i.from[4]+(i.to[4]-i.from[4])*s,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.callback?.(),this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:q.easeOutExpo}}))}}resumeTransition(){this.lastZoomTo&&this.zoomTo(this.lastZoomTo.factor,this.lastZoomTo.options),this.isConstraining&&this.constrainBounds(),this.lastGoToRegion&&this.goToRegion(this.lastGoToRegion.target,this.lastGoToRegion.options)}zoomTo(e,t={}){let{origin:i,stream:n=!1,transition:s}=t;this.lastZoomTo={factor:e,options:t};let o=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(o,s,{duration:2e3*h,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:q.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||q.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Ln.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var To=Number.MIN_VALUE+1,tt=class{constructor(e,t,i,n=[],s){a(this,"id",Q());a(this,"ready",!1);a(this,"renderer");a(this,"world");a(this,"target");a(this,"homePosition");a(this,"manualHomePosition");a(this,"manualFocalPosition");a(this,"focalPosition");a(this,"transitionManager");a(this,"aggregate");a(this,"transformBuffer",ne(500));a(this,"lastTarget",ne(5));a(this,"zoomBuffer",ne(5));a(this,"logNextRender",!1);a(this,"pendingUpdate",!0);a(this,"isCommitting",!1);a(this,"firstRender",!0);a(this,"lastTime");a(this,"stopId");a(this,"mode","explore");a(this,"controllers",[]);a(this,"controllersRunning",!1);a(this,"controllerStopFunctions",[]);a(this,"maxScaleFactor",1);a(this,"_viewerToWorld",{x:0,y:0});a(this,"_lastGoodScale",1);a(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]});a(this,"fpsLimit");a(this,"options");a(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}});a(this,"_viewport",{x:0,y:0,width:0,height:0});a(this,"setViewport",e=>{let t=Math.round(typeof e.x>"u"?this.target[1]:e.x),i=Math.round(typeof e.y>"u"?this.target[2]:e.y);e.width?this.target[3]=t+e.width:this.target[3]=this.target[3]-this.target[1]+t,e.height?this.target[4]=i+e.height:this.target[4]=this.target[4]-this.target[2]+i,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-i)>.01&&(this.target[2]=i),this.pendingUpdate=!0});a(this,"render",e=>{let t=e-this.lastTime;if(this.isCommitting||this.fpsLimit&&t<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=e,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook("useFrame",t);let i=this.pendingUpdate,n=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!i&&!n&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook("useBeforeFrame",t),this.renderer.beforeFrame(this.world,t,this.target,this.hookOptions);let s=this.getScaleFactor(),o=this.renderer.getPointsAt(this.world,this.target,this.aggregate,s),h=o.length;for(let d=0;d<h;d++){let u=o[d][0],m=o[d][1],y=o[d][2],v=y?Oe(m,y,this.transformBuffer):m;this.renderer.prepareLayer(u,u.__parent&&y?Oe(u.__parent.crop||u.__parent.points,y):v);let S=v.length/5;for(let P=0;P<S;P++){let g=P*5;v[g]!==0&&(this.renderer.paint(u,P,v[g+1],v[g+2],v[g+3]-v[g+1],v[g+4]-v[g+2]),this.hook("useAfterPaint",u))}this.renderer.finishLayer(u,m)}this.renderer.afterFrame(this.world,t,this.target,this.hookOptions),this.hook("useAfterFrame",t),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger("ready")),this.world.flushSubscriptions();let l=this.world.getScheduledUpdates(this.target,s),c=l.length;if(c>0)for(let d=0;d<c;d++){let u=l[c-d-1]();u?u.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}});this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...s||{}},this.target=wt.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=wt.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ie(this),this.aggregate=bi(1),this.world.addLayoutSubscriber(o=>{o==="repaint"&&(this.pendingUpdate=!0),o==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}setHomePosition(e){this.homePosition.set(wt.projection(e||this.world)),this.pendingUpdate=!0}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize(),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},n=this.width*t,s=this.height*t,o=i.width/n,h=i.height/s,l=n/s;if(e.cover?o>h:o<h){let c=l*i.height,d=(c-i.width)/2;this.target[1]=Math.round(-d+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(c-d+i.x),this.target[4]=Math.round(i.height+i.y)}else{let c=i.width/l,d=(c-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-d),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+c-d)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,i-n);let s=t/e,o=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*s,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*o,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,s=Math.min(i,n),o=0,h=0,l=this.x+o,c=this.y+h;if(i<n){let d=this.height-this.width;this.focalPosition=wt.projection({x:l,y:c+d/2,width:s-o*2,height:s-h*2}),this.pendingUpdate=!0}else{let d=this.width-this.height;this.focalPosition=wt.projection({x:l+d/2,y:c,width:s-o*2,height:s-h*2}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:i=!1}={}){let{minX:n,maxX:s,minY:o,maxY:h}=this.getBounds({target:e,padding:t}),l=!1,c=i?e:ne(e),d=Math.round(e[3]-e[1]),u=Math.round(e[4]-e[2]);return n>e[1]&&(l=!0,c[1]=n,c[3]=n+d),o>e[2]&&(l=!0,c[2]=o,c[4]=o+u),s<e[1]&&(l=!0,c[1]=s,c[3]=s+d),h<e[2]&&(l=!0,c[2]=h,c[4]=h+u),[l,c]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,s=Math.abs(1-n);if(this.world.hasActiveZone()){let f=this.world.getActiveZone();if(f){let C=t[3]-t[1]<f.points[3]-f.points[1],R=t[4]-t[2]<f.points[4]-f.points[2];return{minX:C?f.points[1]-i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxX:R?f.points[2]-i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2,minY:C?f.points[3]+i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxY:R?f.points[4]+i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2}}}let o=t[3]-t[1],h=this.world.width,l=-o*s,c=h-o-l,d=t[4]-t[2],u=this.world.height,m=-d*s,y=u-d-m,v=Math.round(Math.max(l,c)),S=Math.round(Math.min(l,c)),P=Math.round(Math.max(m,y)),g=Math.round(Math.min(m,y));return{minX:S,maxX:v,minY:g,maxY:P}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,s=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),o=n?n.width:this.width,h=n?n.height:this.height,l=this.getRendererScreenPosition()?.width,c=this.world.width,d=l?l/c:1,u=this.options.maxUnderZoom,m=Math.max(d||1,this.options.maxOverZoom),y=1/e,v=s*y;if(y<1){let g=o*s,f=h*s,C=this.world.width/g,R=this.world.height/f;if(C>R){let w=this.world.width*v,O=~~(o*s)*u;w<O&&(e=this.world.width*s/(o*s*u))}else{let w=this.world.height*v,O=~~(h*s)*u;w<O&&(e=this.world.height*s/(h*s*u))}}else v>m&&(e=s/m);let P=Oe(this.target,vi(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(P,{ref:!0,panPadding:100}),P}clampRegion({x:e,y:t,width:i,height:n,padding:s=0}){let o=this.width,h=this.height,l=i/o<n/h,c=e-s,d=t-s,u=i+s*2,m=n+s*2;if(l){let v=m/h*o;return{x:c-(v-u)/2,y:d,width:v,height:m}}let y=u/o*h;return{x:c,y:d-(y-m)/2,width:u,height:y}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let s=wt.singleBox(i,n,e,t);return yi(s,Fn(bi(this.getScaleFactor()),kn(-this.target[1],-this.target[2]))),{x:s[1],y:s[2],width:s[3]-s[1],height:s[4]-s[2],strand:s}}setScale(e,t){yi(this.target,vi(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return typeof this.stopId<"u"&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}};import{dna as wi,DnaFactory as xi}from"@atlas-viewer/dna";var re=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,se={},Dn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],xt=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"isShape",!0);a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:wi(5)});a(this,"boundingBox",null);a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"shape",{type:"none"});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=Q(12),this.points=wi(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let t=this.shape.points;if(this.shape.points.length>2){let i=Math.min(...t.map(h=>h[0])),n=Math.min(...t.map(h=>h[1])),s=Math.max(0,...t.map(h=>h[0])),o=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:s-i,height:o-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,s=this.shape.points,o=this.boundingBox;if(o||(this.updateBoundingBox(),o=this.boundingBox),!o||i<o.x||i>o.x+o.width||n<o.y||n>o.height+o.y)return!1;let h=!1;for(let l=0,c=s.length-1;l<s.length;c=l++)s[l][1]>n!=s[c][1]>n&&i<(s[c][0]-s[l][0])*(n-s[l][1])/(s[c][1]-s[l][1])+s[l][0]&&(h=!h);return h}getAllPointsAt(t,i){return t[3]-t[1]===1&&t[4]-t[2]===1?this.intersects([t[1],t[2]])?[[this,this.points,i]]:[]:[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.points)if(this.shape.type!=="polygon"||this.shape.points.length!==t.points.length)this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox();else{let n=!1,s=t.points.length;for(let o=0;o<s;o++)if(t.points[o][0]!==this.shape.points[o][0]||t.points[o][1]!==this.shape.points[o][1]){n=!0;break}n&&(this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox())}if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),(t.open||t.open===!1)&&(i=!0,this.shape.open=t.open),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=se[n]||re.exec(n)||re.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=se[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=se[t.style.outline]||re.exec(t.style.outline)||re.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=se[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Dn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=xi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=xi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import Bn from"lru-cache";var Si=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,Pi={},Wn=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),oe={};var ae=class{constructor(e,t){a(this,"canvas");a(this,"ctx");a(this,"options");a(this,"imagesPending",0);a(this,"imagesLoaded",0);a(this,"imageIdsLoaded",[]);a(this,"frameIsRendering",!1);a(this,"pendingDrawCall",!1);a(this,"firstMeaningfulPaint",!1);a(this,"parallelTasks",8);a(this,"frameTasks",0);a(this,"loadingQueueOrdered",!0);a(this,"loadingQueue",[]);a(this,"currentTask",Promise.resolve());a(this,"tasksRunning",0);a(this,"stats");a(this,"averageJobTime",64);a(this,"lastKnownScale",1);a(this,"visible",[]);a(this,"previousVisible",[]);a(this,"rendererPosition");a(this,"dpi");a(this,"drawCalls",[]);a(this,"lastPaintedObject");a(this,"hostCache");a(this,"invalidated",[]);a(this,"_worker",()=>{if(this.loadingQueue.length){let e=this.loadingQueue.pop();e&&(this.tasksRunning++,this.frameTasks++,this.currentTask=e.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}});a(this,"_scheduled",0);a(this,"_doWork",()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let e=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(e=this.loadingQueue.length);for(let t=0;t<=e;t++)this._worker()});this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext("2d",{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.transition="opacity .3s",this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Bn({maxSize:1024*512*512,dispose:(i,n,s)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),s=n.width/e,o=n.height/t,h=(s<o?o:s)*(i&&this.dpi||1);return Number.isNaN(h)||(this.lastKnownScale=h),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let s=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,s.width,s.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let o="";n.filters.brightness&&(o+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(o+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(o+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(o+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(o+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(o+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(o+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(o+=`blur(${n.filters.blur}px) `),this.ctx.filter=o}else this.ctx.filter="none"}applyTransform(e,t,i,n,s){let o=e.__owner.value;if(o&&o.rotation){this.ctx.save();let h=t+n/2,l=i+s/2;this.ctx.translate(h,l),this.ctx.rotate(o.rotation*Math.PI/180),this.ctx.translate(-h,-l),this.lastPaintedObject=o}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,s,o){let h=this.ctx.globalAlpha;if(e instanceof D||e instanceof $){if(e.display.rotation){this.ctx.save();let d=i+s/2,u=n+o/2;e.crop&&(d-=e.crop[t*5+1],u-=e.crop[t*5+2]),this.ctx.translate(d,u),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-d,-u)}if(this.visible.push(e),typeof e.style&&e.style.opacity!=="undefined"){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let d=e.__host.canvas,u=this.getCanvasDims();if((d.indices.indexOf(t)===-1||this.invalidated.indexOf(d.canvases[t])!==-1)&&this.schedulePaintToCanvas(d,e,t,ct({x:i+s/2,y:n+s/2},{x:u.width/2,y:u.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(d.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let y=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];y[0]+=e.cropData.x/e.display.scale,y[1]+=e.cropData.y/e.display.scale;let v=e.x*this.lastKnownScale,S=e.y*this.lastKnownScale,P=[i+v,n+S,s,o];P[0]+=v,P[1]+=S,this.ctx.drawImage(m,y[0],y[1],y[2],y[3],P[0],P[1],P[2]+1,P[3]+1)}}else Wn?this.ctx.drawImage(m,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,s+1,o+1):this.ctx.drawImage(m,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,s+Number.MIN_VALUE+.5,o+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let l=e instanceof K&&this.options.box,c=e instanceof xt&&this.options.polygon;if((l||c)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let d=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),u=e.props.relativeStyle?1:s/e.width;typeof d.opacity<"u"&&(this.ctx.globalAlpha=d.opacity);let m=0;typeof d.borderWidth<"u"&&(m=parseInt(d.borderWidth,10)*u);let y=0;typeof d.outlineWidth<"u"&&(y=parseInt(d.outlineWidth,10)*u);let v=0;if(typeof d.outlineOffset<"u"&&(v=parseInt(d.outlineOffset,10)*u),d.borderColor&&(this.ctx.strokeStyle=d.borderColor),d.boxShadow){let S=d.boxShadow.split(/,(?![^(]*\))/);for(let P of S){let g=Pi[P]||Si.exec(P)||Si.exec(P);Pi[P]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*u,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*u,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*u,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,s,o),this.ctx.restore())}}if(this.ctx.fillStyle=d.backgroundColor||"transparent",this.ctx.lineWidth=m,c){let S=e.shape,P=S.points||[],g=P.length;this.ctx.beginPath();for(let f=0;f<g;f++)this.ctx.lineTo(i+P[f][0]*this.lastKnownScale,n+P[f][1]*this.lastKnownScale);S.open||this.ctx.closePath(),m&&this.ctx.stroke(),S.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,s+m,o+m),this.ctx.fillRect(i+m,n+m,s,o);y&&(d.outlineColor&&(this.ctx.strokeStyle=d.outlineColor),this.ctx.lineWidth=y,this.ctx.strokeRect(i-y/2-v,n-y/2-v,s+m*2+y+v*2,o+m*2+y+v*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(oe[e]&&oe[e].naturalWidth>0){t(oe[e]);return}try{let s=!1;n||setTimeout(()=>{s||this.loadImage(e,t,i,!0)},3e3);let o=document.createElement("img");o.decoding="auto",o.onload=function(){s=!0,t(o),oe[e]=o,o.onload=null},this.options.crossOrigin&&(o.crossOrigin="anonymous"),o.src=e,o.complete&&o.onload({}),o.width}catch(s){console.log("image error",s),i(s)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let s=`${t.id}--${t.display.scale}-${i}`,o=this.invalidated.indexOf(s);o!==-1&&this.invalidated.splice(o,1),e.canvases[i]=s,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:s,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(h=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h();return}let l=t.getImageUrl(i);this.loadImage(l,c=>{this.loadingQueue.push({id:s,scale:t.display.scale,distance:n,task:()=>new Promise(d=>{this.imageIdsLoaded.includes(s)||(this.imagesLoaded++,this.imageIdsLoaded.push(s)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let u=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),y=m.getContext("2d");m.width=u[3]-u[1],m.height=u[4]-u[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{y.drawImage(c,0,0,u[3]-u[1],u[4]-u[2]),d()})})}),h()},c=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof D||e instanceof $)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let s=t[3]-t[1]<n.points[3]-n.points[1],o=t[4]-t[2]<n.points[4]-n.points[2];return{x1:s?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:o?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:s?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:o?n.points[4]+i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity="1",this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity="1",this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}};var St=class{constructor(e){a(this,"renderers",[]);a(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,i,n,s,o){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,s,o)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}};import{DnaFactory as Nn,scale as zn}from"@atlas-viewer/dna";var he=class{constructor(e){a(this,"canvas");a(this,"context");a(this,"heightRatio",1);a(this,"widthRatio",1);a(this,"target",new Float32Array(5));a(this,"initialWidth");a(this,"initialHeight");a(this,"bounds");a(this,"aggregate");a(this,"delta",0);a(this,"renderNextFrame",!0);this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext("2d"),this.context.globalAlpha=.5,this.aggregate=zn(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,s=this.initialHeight/e.height,o=this.widthRatio>this.heightRatio?n:s;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,o);for(let[l,c]of h)if(l instanceof D&&l.__host.canvas){let d=c.length/5;for(let u=0;u<d;u++)if(l.__host.canvas.canvases[u]){let y={x1:c[u+1]*o,y1:c[u+2]*o,width:(c[u+3]-c[u+1])*o,height:(c[u+4]-c[u+2])*o}}}}e.getPoints().forEach((h,l,c)=>{if(l%5===0&&h){let d={x1:c[l+1]*o,y1:c[l+2]*o,x2:c[l+3]*o,y2:c[l+4]*o,width:(c[l+3]-c[l+1])*o,height:(c[l+4]-c[l+2])*o};this.context.strokeStyle="red",this.context.strokeRect(d.x1,d.y1,d.width,d.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*o,i[2]*o,(i[3]-i[1])*o,(i[4]-i[2])*o))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=Nn.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,s,o){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};var Ei=class{constructor(){a(this,"autoWidth",!1);a(this,"autoHeight",!0);a(this,"width");a(this,"height");a(this,"world");a(this,"content",[]);a(this,"viewingDirection","left-to-right");a(this,"rows");a(this,"columns",4);a(this,"spacing",20);a(this,"reversed",!1);a(this,"padding",20);this.world=V.withProps({width:0,height:0,viewingDirection:"left-to-right"}),this.width=0,this.height=0}setViewingDirection(e){this.viewingDirection=e}addContent(e){this.content.push(...e.map(t=>this.world.addObjectAt(t,{width:0,height:0,x:0,y:0})))}setWidth(e){this.width=e}setHeight(e){this.height=e}setSpacing(e){this.spacing=e}setPadding(e){this.padding=e}setRows(e){this.autoWidth=!0,this.rows=e}setColumns(e){this.autoHeight=!0,this.columns=e}recalculate(){if(this.height===0&&this.width===0||this.rows===0||this.columns===0)return;if(this.autoHeight&&!this.width)throw new Error("Cannot set auto height without setting a width");if(this.autoWidth&&!this.height)throw new Error("Cannot set auto width without setting a height");(this.viewingDirection==="left-to-right"||this.viewingDirection==="top-to-bottom")&&this.reversed&&(this.reversed=!1,this.content.reverse()),(this.viewingDirection==="right-to-left"||this.viewingDirection==="bottom-to-top")&&!this.reversed&&(this.reversed=!0,this.content.reverse());let e=this.content.length,t=()=>{if(this.autoWidth&&this.rows){let h=e>this.rows?this.rows:e;return{columns:Math.ceil(e/h),rows:h}}if(this.autoHeight&&this.columns){let h=e>this.columns?this.columns:e;return{columns:h,rows:Math.ceil(e/h)}}throw new Error("Something went wrong.")},{columns:i,rows:n}=t(),s=this.autoWidth?-1:this.width-this.padding*2,o=this.autoWidth?-1:(s-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,l=this.padding;for(let c=0;c<n&&h!==e;c++){let d=0,u=[];for(let m=0;m<i;m++){let y=this.reversed?e-h:h;if(h===e)break;let v=this.content[y],S=v.width,P=v.width/v.height,g=o/P;u.push([h,o,g,o/S]),g>d&&(d=g),h++}for(let m=0;m<i&&u[m];m++){let y=this.world.getPoints(),v=u[m][0],S=u[m][1],P=u[m][2],g=u[m][3],f=this.padding+m*(this.spacing+S),C=l+(d-P)/2,R=this.reversed?e-v:v,w=y[R*5+1],b=y[R*5+2];this.world.scaleWorldObject(v,g),(w!==f||b!==C)&&this.world.translateWorldObject(R,f-w,C-b)}l+=d+this.spacing}this.height=l+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};import Hn from"normalize-wheel";import{compose as jn,dna as Ae,scaleAtOrigin as Un,transform as Ri,translate as Ti}from"@atlas-viewer/dna";function Ci(r){return{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2]}}var _i="pan",Oi="scroll",$n="gesture",Vn={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},le=(r={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:s,enablePanOnWait:o,panOnWaitDelay:h,parentElement:l,requireMetaKeyForWheelZoom:c}={...Vn,...r},d={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:Ae(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function u(){S=0,g="",C(),C(void 0,"notice"),P=0}function m(){e.world.constraintBounds(),u()}function y(x){if(x.which>1){d.isPressing=!1;return}e.mode==="explore"&&(x.preventDefault(),d.pointerStart.x=x.atlas.x,d.pointerStart.y=x.atlas.y,e.transitionManager.stopTransition(),d.isPressing=!0)}function v(){u(),d.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),d.isPressing=!1)}let S=0,P=0,g="";function f(x){if(e.mode==="explore"){if(x.atlasTouches.length===1&&(P=performance.now(),s==!1&&x.preventDefault(),d.pointerStart.x=x.atlasTouches[0].x,d.pointerStart.y=x.atlasTouches[0].y),x.atlasTouches.length===2){g=$n,x.preventDefault();let T=x.atlasTouches[0].x,A=x.atlasTouches[1].x;d.pointerStart.x=(T+A)/2;let ht=x.atlasTouches[0].y,M=x.atlasTouches[1].y;d.pointerStart.y=(ht+M)/2,S=ct({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY})}e.transitionManager.stopTransition(),d.isPressing=!0}}function C(x,T="intent"){l&&(l.dataset[T]=x)}function R(x){let T=null,A=null,ht=!1,M=0;if(d.isPressing&&x.touches.length===2){let X=x.touches[0].clientX,rt=x.touches[1].clientX;T=(X+rt)/2;let yt=x.touches[0].clientY,bt=x.touches[1].clientY;A=(yt+bt)/2,M=ct({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY}),ht=!0}if(C(g),d.isPressing&&x.touches.length===1){if(o&&(performance.now()-P<h&&g==""&&(g=Oi),g==""&&(g=_i)),C(g),g==""&&s==!0||g==Oi){C("require-two-finger","notice");return}let X=x.touches[0];T=X.clientX,A=X.clientY}if(T!==null&&A!==null){let X=e.getRendererScreenPosition();if(X){let{x:rt,y:yt}=e.viewerToWorld(T-X.x,A-X.y),bt=M&&S?M/S:1;e.transitionManager.customTransition(p=>{p.from=Ae(e.target),p.to=Ri(p.from,jn(Ti(d.pointerStart.x-rt,d.pointerStart.y-yt),Un(1/bt,rt,yt)),d.mousemoveBuffer),p.elapsed_time=0,p.total_time=0,p.timingFunction=q.easeInOutExpo,p.done=!1})}S=M}g==_i&&x.preventDefault()}function w(x){if(d.isPressing){let T=e.getRendererScreenPosition();if(T){let{x:A,y:ht}=e.viewerToWorld(x.clientX-T.x,x.clientY-T.y);e.transitionManager.customTransition(M=>{M.from=Ae(e.target),M.to=Ri(M.from,Ti(d.pointerStart.x-A,d.pointerStart.y-ht),d.mousemoveBuffer),M.elapsed_time=0,M.total_time=0,M.timingFunction=q.easeInOutExpo,M.done=!1})}}}function b(x){e.mode==="explore"&&e.world.zoomIn(x.atlas)}function O(x){let A=1+Hn(x).spinY/t;e.world.zoomTo(A,x.atlas,!0)}function W(x){return c&&x.metaKey==!1?(C("meta-required","notice"),x.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",f),e.world.addEventListener("mousedown",y),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",w),l&&l.addEventListener("touchmove",R),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",b)),i&&(e.world.activatedEvents.push("onWheel"),c&&l?.addEventListener("wheel",W,{passive:!0,capture:!0}),e.world.addEventListener("wheel",O));let N=e.world.addLayoutSubscriber((x,T)=>{if(x==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),x==="zoom-to"&&T&&e.transitionManager.zoomTo(T.factor,{origin:T.point,stream:T.stream}),x==="go-home"){let A=T.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(Ci(e.homePosition),{transition:A})}if(x==="goto-region"&&T){let A=T.immediate?{duration:0}:{};e.transitionManager.goToRegion(T,{transition:A})}x==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:T?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",f),e.world.removeEventListener("mousedown",y),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),e.world.removeEventListener("mousemove",w),l&&(l.removeEventListener("touchmove",w),l.removeEventListener("wheel",W,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",b),i&&e.world.removeEventListener("wheel",O),N()}},updatePosition(){}});import{useCallback as ur,useEffect as G,useMemo as mr,useRef as Ui,useState as Me}from"react";import Gn,{useContext as Zn}from"react";import{jsx as Xn}from"react/jsx-runtime";var et=Gn.createContext("explore");et.displayName="Mode";var de=()=>Zn(et);function ca(r){return Xn(et.Provider,{value:r.mode,children:r.children})}import fr from"react-use-measure";import Ai from"react";var it=Ai.createContext(null);it.displayName="Atlas";var mt=Ai.createContext(null);mt.displayName="Bounds";import Bi,{useCallback as nr,useEffect as Wi,useRef as rr}from"react";import Qn from"react-reconciler";var kt,Yn=typeof performance=="object"&&typeof performance.now=="function";if(Yn){let r=performance;kt=()=>r.now()}else{let r=Date,e=r.now();kt=()=>r.now()-e}import{version as Kn}from"react";var qn=16;function Mi(r,e){r&&r.appendChild&&e&&r.appendChild(e)}function Li(r,e){r&&r.removeChild&&e&&r.removeChild(e)}function Jn(r,e){return Li(r.world,e)}function tr(r,e,t){return ki(r.world,e,t)}function ki(r,e,t){r&&r instanceof tt&&(r=r.world),r&&r.insertBefore&&r.insertBefore(e,t)}function Fi(r,e,t){if(t&&(r.applyProps&&r.applyProps(t),r instanceof k))for(let i of At){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&r.removeEventListener(n,e[i]),r.addEventListener(n,t[i]))}}function Di(r,e){let t=Object.keys(e),i=!1;for(let n of t)if(At.indexOf(n)!==-1){let s=Y[n];if(s){if(r.activatedEvents.indexOf(s)!==-1)continue;i=!0,r.activatedEvents.push(s)}}i&&r.triggerEventActivation()}var ce=new Map,Ii={};function er(r,{args:e=[],...t},i,n,s){if(!(i instanceof tt)&&s){let l=c=>c.return?l(c.return):c.stateNode&&c.stateNode.containerInfo;i=l(s)}let o,h=i.world;switch(r){case"world":o=V.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),o.activatedEvents=h.activatedEvents,o.eventHandlers=h.eventHandlers,o.subscriptions=h.subscriptions,o.triggerEventActivation(),h=o;break;case"box":o=new K;break;case"shape":o=new xt;break;case"worldObject":case"world-object":o=new J;break;case"worldImage":case"world-image":o=new D;break;case"texture":o=new dt;break;case"compositeImage":case"composite-image":o=new Gt({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":o=$.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format,t.useFloorCalc,t.version3);break;case"paragraph":o=new ot,o.text=t.children;break;default:return}return Di(h,t),Fi(o,{},t),o}function ir(r,e){if(e instanceof V)r.world=e;else if(e instanceof J)r.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Ft=Qn({unstable_now:kt,now:kt,createInstance:er,removeChild:Li,appendChild:Mi,appendInitialChild:Mi,insertBefore:ki,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<"u"?setTimeout:void 0,cancelTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,setTimeout:typeof setTimeout<"u"?setTimeout:void 0,clearTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:ir,removeChildFromContainer:Jn,createTextInstance(){},insertInContainerBefore:tr,prepareUpdate(r,e,t,i,n){return Di(n.world,i),i},commitUpdate(r,e,t,i,n,s){r.applyProps&&e&&Fi(r,i,e)},finalizeInitialChildren(r){return r?.__handlers},getChildHostContext(){return Ii},getRootHostContext(){return Ii},prepareForCommit(r){return r.isCommitting=!0,null},preparePortalMount(){},hideInstance(r){r&&r.points&&(r.points[0]=0)},unhideInstance(r,e){r&&r.points&&(r.points[0]=1)},getPublicInstance(r){return r},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(r){r.isCommitting=!1,r.pendingUpdate=!0,r.world&&r.world.needsRecalculate&&(r.world.recalculateWorldSize(),r.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(r){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),qn},getInstanceFromNode(r){throw console.log("getInstanceFromNode",r),new Error("Not implemented")},getInstanceFromScope(r){throw console.log("getInstanceFromScope",r),new Error("Not implemented")},prepareScopeUpdate(r,e){throw console.log("prepareScopeUpdate",r,e),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Ft.injectIntoDevTools({bundleType:0,version:Kn,rendererPackageName:"@atlas-viewer/atlas"});function Dt(r,e){let t=ce.get(r);t&&Ft.updateContainer(null,t,null,()=>{ce.delete(r),e&&e(r)})}var Bt={render(r,e){let t=ce.get(e);if(t)Ft.updateContainer(r,t,null);else{let i=Ft.createContainer(e,0,null,!1,null,"",()=>{},null);Ft.updateContainer(r,i,null),ce.set(e,i)}},unmountComponentAtNode(r,e){Dt(r,e)}};import*as ue from"react";var H=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?ue.useLayoutEffect:ue.useEffect;import{jsx as Wt}from"react/jsx-runtime";var Ni=Bi.memo(({children:r,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:s="explore"})=>{let o=nr(function(l){let c=rr(!1),d=()=>{e(!0)};return Wi(()=>{if(n&&!c.current){n.runtime.goHome();let u=t&&t(n);return void(u&&u.then?u.then(d):d())}return()=>{}},[]),Wi(()=>{c.current=!0},[]),l.children},[n]);return H(()=>{if(n){let h=n.runtime;s!==h.mode&&(h.mode=s),Bt.render(Wt(Bi.StrictMode,{children:Wt(o,{children:Wt(mt.Provider,{value:i,children:Wt(et.Provider,{value:s,children:Wt(it.Provider,{value:n,children:r})})})})}),h)}},[n,s,r]),H(()=>{if(n){let h=n.runtime;return()=>{Bt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var me=class{constructor(e,t){a(this,"canvas");a(this,"gl");a(this,"program");a(this,"fragmentShader");a(this,"vertexShader");a(this,"rectBuffer");a(this,"fragmentShaderSource",`
|
|
1
|
+
var un=Object.defineProperty;var mn=(r,e,t)=>e in r?un(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e,t)=>(mn(r,typeof e!="symbol"?e+"":e,t),t);var At=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver"];function Xe(){return At.reduce((r,e)=>(r[e]=[],r),{})}var Y=At.reduce((r,e)=>(r[e.slice(2).toLowerCase()]=e,r[e]=e,r),{});import{dna as Ce,DnaFactory as vt,mutate as pn,translate as yn}from"@atlas-viewer/dna";import{mutate as Ee,scaleAtOrigin as fn,translate as gn}from"@atlas-viewer/dna";var Ye="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Q=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Ye[t[r]&63];return e};var k=class{constructor(){a(this,"__id");a(this,"__revision",0);a(this,"__host");a(this,"__onCreate");a(this,"__parent");a(this,"__owner",{value:void 0});a(this,"__state",{});a(this,"eventHandlers");a(this,"scale",1);a(this,"layers",[]);a(this,"time",[]);a(this,"_crop");a(this,"cropData");a(this,"id");a(this,"addEventListener",(e,t,i)=>{let n=Y[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)});a(this,"removeEventListener",(e,t)=>{let i=Y[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))});this.id=this.__id=Q(),this.eventHandlers=Xe()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,s=!1;if(n)for(let o=0;o<n;o++)try{i[o](t),s=!0}catch(h){console.error(e,h)}return s}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){Ee(this.points,gn(e,t))}atScale(e){Ee(this.points,fn(e,this.x,this.y)),this.scale*=e}transform(e){Ee(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}};var D=class r extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"priority");a(this,"style",{opacity:1});if(!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Ce(5)},this.points=Ce(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=vt.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:vt.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(vt.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let s=vt.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);pn(s,yn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(s):this.crop=Ce(s)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=vt.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=vt.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,s){return r.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,s)}static fromImage(t,i,n,s){let o=new r;return o.applyProps({uri:t,id:s,display:n,target:i}),o}getImageUrl(){return this.uri}};import{dna as Qe,DnaFactory as Ut}from"@atlas-viewer/dna";var dt=class extends k{constructor(t){super();a(this,"type","spacial-content");a(this,"id");a(this,"uri");a(this,"display");a(this,"points");a(this,"getTexture");if(this.getTexture=()=>({source:void 0,hash:-1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:Qe(5)},this.points=Qe(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=Ut.singleBox(t.width,t.height),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:i!==1?Ut.singleBox(t.width/i,t.height/i):this.points}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;this.id=t.id,this.points.set(Ut.singleBox(t.target.width,t.target.height)),this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.getTexture=t.getTexture,this.display.points=n!==1?Ut.singleBox(t.target.width/n,t.target.height/n):this.points}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};import{DnaFactory as Je,hidePointsOutsideRegion as bn,mutate as ti,scale as vn,transform as wn,dna as xn,translate as Sn}from"@atlas-viewer/dna";function Ke(r,e,t=1){let i=e.length;if(i===0)throw new Error("No resources passed in.");let n=0,s=1/0;for(let o=0;o<i&&!(!e[o]||!e[o].display);o++){let h=Re(e[o].display.scale,r/(t||1));h<s&&(s=h,n=o)}return n}function Re(r,e){return Math.abs(r-e)}function ct(r,e){let t=Re(r.x,e.x),i=Re(r.y,e.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))}function qe(r){let e=r.length;return r.indexOf("/info.json")===e-10?r.slice(0,-10):r}function $t(r,e,t){return Math.min(Math.max(r,e),t)}var $=class r extends k{constructor(t){super();a(this,"id");a(this,"type","spacial-content");a(this,"display");a(this,"tileWidth");a(this,"style",{opacity:1});a(this,"points");a(this,"service");a(this,"format","jpg");a(this,"crop2");a(this,"version3");a(this,"tileUrl");this.tileUrl=qe(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:wn(t.points,vn(t.scaleFactor)),this.tileWidth=t.tileWidth,this.version3=t.version3,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",typeof t.version3<"u"&&(this.version3=t.version3),t.crop){this.cropData=t.crop;let i=xn([...this.points]),n=i.length/5,s=t.crop.x||0,o=t.crop.y||0,h=t.crop.x+t.crop.width,l=t.crop.y+t.crop.height;for(let c=0;c<n;c++){let d=c*5;i[d+1]<h&&i[d+3]>s&&i[d+2]<l&&i[d+4]>o?(i[d+1]=$t(i[d+1],s,h),i[d+3]=$t(i[d+3],s,h),i[d+2]=$t(i[d+2],o,l),i[d+4]=$t(i[d+4],o,l)):i[d]=0}ti(i,Sn(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,s,o,h,l,c){n.height=n.height?n.height:n.width;let d=l?Math.floor(i.width/s):Math.ceil(i.width/s),u=l?Math.floor(i.height/s):Math.ceil(i.height/s),m=Math.ceil(d/n.width),y=Math.ceil(u/n.height),v=Je.grid(m,y),S=Je.grid(m,y),P=o?o["@context"]?Array.isArray(o["@context"])?o["@context"]:[o["@context"]]:[]:[],g=typeof c<"u"?c:P.indexOf("http://iiif.io/api/image/3/context.json")!==-1;for(let C=0;C<y;C++)for(let R=0;R<m;R++){let w=R*n.width,b=C*n.height;S.addPoints(w*s,b*s,R===m-1?i.width:(w+n.width)*s,C===y-1?i.height:(b+n.height)*s),v.addPoints(w,b,R===m-1?d:w+n.width,C===y-1?u:b+n.height)}let f=new r({url:t,scaleFactor:s,points:v.build(),displayPoints:S.build(),width:i.width,height:i.height,tileWidth:n.width,format:h,version3:g});return f.applyProps({service:o}),f}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],s=i[4]-i[2],o=Math.ceil(n/this.display.scale),h=Math.ceil(s/this.display.scale),l=`${o>this.tileWidth?this.tileWidth:o},`;return this.version3&&(l+=`${h>this.tileWidth?this.tileWidth:h}`),`${this.tileUrl}/${i[1]},${i[2]},${n},${s}/${l}/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let s=bn(this.crop||this.points,t);return[[this,s,i]]}transform(t){ti(this.points,t)}getScheduledUpdates(t,i){return[]}};import{compose as Pn,dna as En,DnaFactory as ei,translate as ii}from"@atlas-viewer/dna";var Vt=class extends k{constructor(){super(...arguments);a(this,"type","spacial-content")}getAllPointsAt(t,i,n){return[[this,this.points,i]]}};var Gt=class extends Vt{constructor(t){super();a(this,"id");a(this,"display");a(this,"points");a(this,"images",[]);a(this,"allImages",[]);a(this,"scaleFactors",[]);a(this,"aggregateBuffer",En(9));a(this,"lazyLoader");a(this,"isFullyLoaded",!1);a(this,"maxScaleFactor",0);a(this,"renderOptions");a(this,"_scheduleSortByScales",!1);a(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages){if(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof D&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)continue;if(Math.abs(i.display.scale-t)<.25||i.priority){let s=this.images.pop();s&&(s instanceof D||s.priority)?(i.priority&&this.images.push(i),this.images.push(s)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)});a(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}});a(this,"fallback",[this.loadFullResource]);this.id=t.id,this.points=ei.singleBox(t.width,t.height),this.lazyLoader=t.loadFullImages,t.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:ei.singleBox(t.width,t.height),height:t.height,width:t.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:3,minSize:255,maxImageSize:2048,quality:1.5,...t.renderOptions||{}},this.addImages(t.images)}applyProps(t){typeof t.renderSmallestFallback<"u"&&t.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=t.renderSmallestFallback),typeof t.renderLayers<"u"&&t.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=t.renderLayers),typeof t.minSize<"u"&&t.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=t.minSize),typeof t.maxImageSize<"u"&&t.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=t.maxImageSize),typeof t.quality<"u"&&t.quality!==this.renderOptions.quality&&(this.renderOptions.quality=t.quality)}appendChild(t){this.addImages([t])}removeChild(t){this.images.indexOf(t)!==-1&&(this.images=this.images.filter(i=>i!==t),this.sortByScales())}insertBefore(t,i){this.addImages([t])}hideInstance(){}addImages(t){for(let i of t)i.__parent=this,i.__owner=this.__owner;this.allImages.push(...t.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(t,i){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:i>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(t,i,n){if(this.images.length===0)return[];let s=Ke(1/(n||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),o=this.images.length,h=i?Pn(i,ii(this.x,this.y)):ii(this.x,this.y);if(s!==this.images.length-1&&this.images[s+1]){let l=[];for(let u=o-1;u>=s;u--)l.push(u);let c=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(c)===-1&&l.unshift(c);let d=[];for(let u=0;u<l.length;u++)d.push(...this.images[l[u]].getAllPointsAt(t,h,n));return d}return this.images[s].getAllPointsAt(t,h,n)}};import{compose as si,DnaFactory as Yt,dnaLength as Rn,hidePointsOutsideRegion as oi,mutate as ai,scale as Tn,scaleAtOrigin as _n,translate as hi,dna as ut}from"@atlas-viewer/dna";import{dna as z,compose as Te,getIntersection as Cn,scale as ni,transform as _e,translate as Zt,hidePointsOutsideRegion as ri}from"@atlas-viewer/dna";function Xt(r,e,t,i,n){let s=Math.PI/180*n,o=Math.cos(s),h=Math.sin(s),l=o*(t-r)+h*(i-e)+r,c=o*(i-e)-h*(t-r)+e;return[l,c]}var J=class r extends k{constructor(t,i){super();a(this,"id");a(this,"type","world-object");a(this,"scale");a(this,"layers");a(this,"points");a(this,"worldPoints");a(this,"intersectionBuffer",z(5));a(this,"aggregateBuffer",z(9));a(this,"invertedBuffer",z(9));a(this,"rotation",0);a(this,"filteredPointsBuffer");a(this,"_updatedList",[]);a(this,"geometry");let{x:n=0,y:s=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=z([1,n,s,n+t.width,s+t.height]),this.worldPoints=z([1,n,s,n+t.width,s+t.height]),this.filteredPointsBuffer=z(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=z(5),this.worldPoints=z(5),this.filteredPointsBuffer=z(5))}static createWithProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let s=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(s),this.scale=s}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=z(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let s=this.layers.slice(0,n),o=this.layers.slice(n);this.layers=[...s,t,...o]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),ri(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let s=this.layers.length,o=[];for(let h=0;h<s;h++){let l=this.layers[h];if(i&&l.isShape){let d=_e(l.points,Zt(this.x,this.y));if(!l.intersects([t[1]-d[1],t[2]-d[2]]))continue}if(ri(_e(l.points,Zt(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&o.push(l),i){let d=l;o.push(...d.getObjectsAt(t,i))}}return o}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},s={x:t[3],y:t[2]},o={x:t[3],y:t[4]},h=this.points[1]+(this.points[3]-this.points[1])/2,l=this.points[2]+(this.points[4]-this.points[2])/2,[c,d]=Xt(h,l,i.x,i.y,this.rotation),[u,m]=Xt(h,l,n.x,n.y,this.rotation),[y,v]=Xt(h,l,s.x,s.y,this.rotation),[S,P]=Xt(h,l,o.x,o.y,this.rotation),g=Math.min(c,u,y,S),f=Math.max(c,u,y,S),C=Math.min(d,m,v,P),R=Math.max(d,m,v,P);return z([t[0],g,C,f,R])}return t}getAllPointsAt(t,i,n){let s=Te(Zt(this.x,this.y),ni(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let o=Cn(t,this.points,this.intersectionBuffer),h=this.layers.length,l=[],c=_e(o,Te(ni(1/this.scale),Zt(-this.x,-this.y),this.invertedBuffer)),d=i?Te(i,s,this.aggregateBuffer):s,u=n*this.scale;for(let m=0;m<h;m++)l.push(...this.layers[m].getAllPointsAt(c,d,u));return l}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||z([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(i),this.filteredPointsBuffer=z(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let s=i*this.scale;for(let o=0;o<n;o++){let h=this.layers[o].getScheduledUpdates(t,s);h&&this._updatedList.push(...h)}return this._updatedList}};var V=class r extends k{constructor(t=0,i=0,n=100,s="left-to-right"){super();a(this,"id","world");a(this,"_width");a(this,"_height");a(this,"aspectRatio");a(this,"viewingDirection");a(this,"aggregateBuffer",ut(9));a(this,"isDirty",!1);a(this,"zones",[]);a(this,"filteredPointsBuffer");a(this,"selectedZone");a(this,"triggerQueue",[]);a(this,"activatedEvents",[]);a(this,"_updatedList",[]);a(this,"translationBuffer",ut(9));a(this,"needsRecalculate",!0);a(this,"emptyPaintables",[]);a(this,"renderOrder",[]);a(this,"points");a(this,"objects",[]);a(this,"subscriptions",[]);a(this,"_propagateEventTargets",[]);a(this,"_alreadyFlushed",[]);this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=s,this.points=ut(n*5),this.filteredPointsBuffer=ut(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new r;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let s=[];for(let o of n)if(o.x&&o.y){let h=Yt.singleBox(1,1,o.x,o.y);s.push(this.getObjectsAt(h,!0).reverse())}return s.map(o=>this.propagateEvent(t,i,o,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,s,o={}){let h=Yt.singleBox(1,1,n,s),l=this.getObjectsAt(h,!0).reverse();return this.propagateEvent(t,i,l,o)}propagateEvent(t,i,n,{bubbles:s=!1,cancelable:o=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let h=!1;i.stopPropagation=()=>{h=!0};let l=n.length;for(let u=l-1;u>=0;u--){this._propagateEventTargets.unshift(n[u][0]);let m=n[u][1].length;if(m)for(let y=0;y<m;y++)this._propagateEventTargets.unshift(n[u][1][y])}let c=this._propagateEventTargets.length,d=!1;for(let u=0;u<c&&(i.atlasTarget=this._propagateEventTargets[u],i.atlasWorld=this,d=this._propagateEventTargets[u].dispatchEvent(t,i)||d,!h);u++);return d&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let s=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,s/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Rn(this.points)===this.objects.length){let t=this.points,i=ut(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=ut(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),s=this.renderOrder.length;for(let l=0;l<s;l++){let c=this.renderOrder[l];this.objects[c]&&(i[l]=this.points[c*5+3],n[l]=this.points[c*5+4])}let o=Math.max(...i);o!==this._width&&(this._width=o,t=!0);let h=Math.max(...n);h!==this._height&&(this._height=h,t=!0),t&&this.trigger("recalculate-world-size",{width:o,height:h}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:s,y:o}=i,h=n/t.width;this.checkResizeInternalBuffer(),this.points.set(Yt.singleBox(t.width,t.height,0,0),this.objects.length*5);let l=new J(t);return l.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(l),this.scaleWorldObject(this.objects.length-1,h),this.translateWorldObject(this.objects.length-1,s,o),this.filteredPointsBuffer=ut(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,l}scaleWorldObject(t,i){ai(this.points.subarray(t*5,t*5+5),_n(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){ai(this.points.subarray(t*5,t*5+5),hi(i,n));let s=this.objects[t];s&&(s.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=Yt.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=oi(this.points,t,this.filteredPointsBuffer),s=this.objects.length;this._updatedList=[];for(let o=0;o<s;o++)if(n[o*5]!==0){if(!this.objects[o])continue;this._updatedList.push(...this.objects[o].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),s=oi(this.points,t,this.filteredPointsBuffer),o=this.renderOrder.length,h=[];for(let l=0;l<o;l++){let c=this.renderOrder[l];if(s[c*5]!==0){let d=this.objects[c];if(!d||n&&n.objects.indexOf(d)===-1)continue;if(d.type!=="world-object"){h.push([d,[d]]);continue}i?h.push([d,d.getObjectsAt(t,i)]):h.push([d,this.emptyPaintables])}}return h}getPointsAt(t,i,n=1){let s=this.getObjectsAt(t),o=si(Tn(n),hi(-t[1],-t[2]),this.translationBuffer),h=i?si(i,o,this.aggregateBuffer):o,l=s.length,c=[];for(let d=0;d<l;d++)s[d]&&c.push(...s[d][0].getAllPointsAt(t,h,n));return c}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let s=0;s<n;s++)this.subscriptions[s].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};function qs(r){let{src:e,target:t}=r,i=t?t.width:r.width,n=t?t.height:r.height;return new J({id:e,height:n,width:i,layers:[D.fromImage(e,{height:n,width:i},{width:r.width,height:r.height})]})}import{dna as On}from"@atlas-viewer/dna";var An={margin:0},li=class{constructor(e,t={}){a(this,"id");a(this,"config");a(this,"points");a(this,"objects");this.id=e.map(i=>i.id).join("$$"),this.config={...An,...t},this.points=On(5),this.objects=e,this.recalculateBounds()}recalculateBounds(){this.points.set([1,Math.min(...this.objects.map(e=>e.points[1]))-this.config.margin,Math.min(...this.objects.map(e=>e.points[2]))-this.config.margin,Math.max(...this.objects.map(e=>e.points[3]))+this.config.margin,Math.max(...this.objects.map(e=>e.points[4]))+this.config.margin])}getPointsAt(e,t,i){return[]}};import{dna as di,DnaFactory as ci}from"@atlas-viewer/dna";var Qt=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,Kt={},Mn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],K=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:di(5)});a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=Q(12),this.points=di(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=Kt[n]||Qt.exec(n)||Qt.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=Kt[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=Kt[t.style.outline]||Qt.exec(t.style.outline)||Qt.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=Kt[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Mn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=ci.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=ci.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import{dna as ui,DnaFactory as In}from"@atlas-viewer/dna";var ot=class extends k{constructor(){super();a(this,"type","spacial-content");a(this,"id");a(this,"points");a(this,"color","#000");a(this,"backgroundColor");a(this,"hovering");a(this,"pressing");a(this,"text","");a(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:ui(5)});a(this,"className");a(this,"html");a(this,"interactive",!1);a(this,"props",{font:"18px Arial, sans-serif",lineHeight:1,textAlign:"left",verticalAlign:"top",paddingX:0,paddingY:0,fitParent:!1,lineBreak:"auto",strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:"none",interactive:!1,relativeSize:!1});this.id="",this.points=ui(5)}getAllPointsAt(t,i){return[[this,this.points,i]]}applyProps({id:t,target:i,text:n,color:s,backgroundColor:o,fontSize:h=18,interactive:l,fontFamily:c="Arial, sans-serif",...d}){d.font=`${h}px ${c}`,this.interactive=l||!1,typeof n<"u"&&(this.text=n||""),s&&(this.color=s),o&&(this.backgroundColor=o),t&&(this.id=t),i&&(this.points=In.singleBox(i.width,i.height,i.x,i.y),this.display.points=this.points,this.display.width=i.width,this.display.height=i.height),this.props={...this.props,...d},this.__revision++}};import{DnaFactory as wt,mutate as yi,scale as bi,scaleAtOrigin as vi,transform as Oe,dna as ne,translate as kn,compose as Fn}from"@atlas-viewer/dna";import{dna as Lt,DnaFactory as Ln}from"@atlas-viewer/dna";var L=Math.pow,qt=Math.sqrt,Mt=Math.sin,mi=Math.cos,It=Math.PI,ee=1.70158,Jt=ee*1.525,fi=ee+1,gi=2*It/3,pi=2*It/4.5,te=function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},q={linear:r=>r,easeInQuad:function(r){return r*r},easeOutQuad:function(r){return 1-(1-r)*(1-r)},easeInOutQuad:function(r){return r<.5?2*r*r:1-L(-2*r+2,2)/2},easeInCubic:function(r){return r*r*r},easeOutCubic:function(r){return 1-L(1-r,3)},easeInOutCubic:function(r){return r<.5?4*r*r*r:1-L(-2*r+2,3)/2},easeInQuart:function(r){return r*r*r*r},easeOutQuart:function(r){return 1-L(1-r,4)},easeInOutQuart:function(r){return r<.5?8*r*r*r*r:1-L(-2*r+2,4)/2},easeInQuint:function(r){return r*r*r*r*r},easeOutQuint:function(r){return 1-L(1-r,5)},easeInOutQuint:function(r){return r<.5?16*r*r*r*r*r:1-L(-2*r+2,5)/2},easeInSine:function(r){return 1-mi(r*It/2)},easeOutSine:function(r){return Mt(r*It/2)},easeInOutSine:function(r){return-(mi(It*r)-1)/2},easeInExpo:function(r){return r===0?0:L(2,10*r-10)},easeOutExpo:function(r){return r===1?1:1-L(2,-10*r)},easeInOutExpo:function(r){return r===0?0:r===1?1:r<.5?L(2,20*r-10)/2:(2-L(2,-20*r+10))/2},easeInCirc:function(r){return 1-qt(1-L(r,2))},easeOutCirc:function(r){return qt(1-L(r-1,2))},easeInOutCirc:function(r){return r<.5?(1-qt(1-L(2*r,2)))/2:(qt(1-L(-2*r+2,2))+1)/2},easeInBack:function(r){return fi*r*r*r-ee*r*r},easeOutBack:function(r){return 1+fi*L(r-1,3)+ee*L(r-1,2)},easeInOutBack:function(r){return r<.5?L(2*r,2)*((Jt+1)*2*r-Jt)/2:(L(2*r-2,2)*((Jt+1)*(r*2-2)+Jt)+2)/2},easeInElastic:function(r){return r===0?0:r===1?1:-L(2,10*r-10)*Mt((r*10-10.75)*gi)},easeOutElastic:function(r){return r===0?0:r===1?1:L(2,-10*r)*Mt((r*10-.75)*gi)+1},easeInOutElastic:function(r){return r===0?0:r===1?1:r<.5?-(L(2,20*r-10)*Mt((20*r-11.125)*pi))/2:L(2,-20*r+10)*Mt((20*r-11.125)*pi)/2+1},easeInBounce:function(r){return 1-te(1-r)},easeOutBounce:te,easeInOutBounce:function(r){return r<.5?(1-te(1-2*r))/2:(1+te(2*r-1))/2}};var ie=class{constructor(e){a(this,"runtime");a(this,"pendingTransition");a(this,"lastZoomTo",null);a(this,"isConstraining",!1);a(this,"lastGoToRegion",null);this.runtime=e,this.pendingTransition={from:Lt(5),to:Lt(5),elapsed_time:0,done:!0,total_time:0,timingFunction:q.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=Lt(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,s=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*s,e[2]=i.from[2]+(i.to[2]-i.from[2])*s,e[3]=i.from[3]+(i.to[3]-i.from[3])*s,e[4]=i.from[4]+(i.to[4]-i.from[4])*s,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.callback?.(),this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:q.easeOutExpo}}))}}resumeTransition(){this.lastZoomTo&&this.zoomTo(this.lastZoomTo.factor,this.lastZoomTo.options),this.isConstraining&&this.constrainBounds(),this.lastGoToRegion&&this.goToRegion(this.lastGoToRegion.target,this.lastGoToRegion.options)}zoomTo(e,t={}){let{origin:i,stream:n=!1,transition:s}=t;this.lastZoomTo={factor:e,options:t};let o=this.runtime.getZoomedPosition(e,{origin:i}),h=Math.abs(1-e);this.applyTransition(o,s,{duration:2e3*h,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastZoomTo=null}},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){this.isConstraining=!0;let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:q.easeOutQuart,constrain:!1,callback:()=>{this.isConstraining=!1}}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=Lt(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||q.easeInOutSine}goToRegion(e,{transition:t}={}){this.lastGoToRegion={target:e,options:{transition:t}};let i=this.runtime.clampRegion(e);this.applyTransition(Ln.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:q.easeOutExpo,constrain:!0,callback:()=>{this.lastGoToRegion=null}}),this.runtime.updateNextFrame()}};var To=Number.MIN_VALUE+1,tt=class{constructor(e,t,i,n=[],s){a(this,"id",Q());a(this,"ready",!1);a(this,"renderer");a(this,"world");a(this,"target");a(this,"homePosition");a(this,"manualHomePosition");a(this,"manualFocalPosition");a(this,"focalPosition");a(this,"transitionManager");a(this,"aggregate");a(this,"transformBuffer",ne(500));a(this,"lastTarget",ne(5));a(this,"zoomBuffer",ne(5));a(this,"logNextRender",!1);a(this,"pendingUpdate",!0);a(this,"isCommitting",!1);a(this,"firstRender",!0);a(this,"lastTime");a(this,"stopId");a(this,"mode","explore");a(this,"controllers",[]);a(this,"controllersRunning",!1);a(this,"controllerStopFunctions",[]);a(this,"maxScaleFactor",1);a(this,"_viewerToWorld",{x:0,y:0});a(this,"_lastGoodScale",1);a(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]});a(this,"fpsLimit");a(this,"options");a(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}});a(this,"_viewport",{x:0,y:0,width:0,height:0});a(this,"setViewport",e=>{let t=Math.round(typeof e.x>"u"?this.target[1]:e.x),i=Math.round(typeof e.y>"u"?this.target[2]:e.y);e.width?this.target[3]=t+e.width:this.target[3]=this.target[3]-this.target[1]+t,e.height?this.target[4]=i+e.height:this.target[4]=this.target[4]-this.target[2]+i,Math.abs(this.target[1]-t)>.01&&(this.target[1]=t),Math.abs(this.target[2]-i)>.01&&(this.target[2]=i),this.pendingUpdate=!0});a(this,"render",e=>{let t=e-this.lastTime;if(this.isCommitting||this.fpsLimit&&t<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=e,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook("useFrame",t);let i=this.pendingUpdate,n=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,t),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!i&&!n&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook("useBeforeFrame",t),this.renderer.beforeFrame(this.world,t,this.target,this.hookOptions);let s=this.getScaleFactor(),o=this.renderer.getPointsAt(this.world,this.target,this.aggregate,s),h=o.length;for(let d=0;d<h;d++){let u=o[d][0],m=o[d][1],y=o[d][2],v=y?Oe(m,y,this.transformBuffer):m;this.renderer.prepareLayer(u,u.__parent&&y?Oe(u.__parent.crop||u.__parent.points,y):v);let S=v.length/5;for(let P=0;P<S;P++){let g=P*5;v[g]!==0&&(this.renderer.paint(u,P,v[g+1],v[g+2],v[g+3]-v[g+1],v[g+4]-v[g+2]),this.hook("useAfterPaint",u))}this.renderer.finishLayer(u,m)}this.renderer.afterFrame(this.world,t,this.target,this.hookOptions),this.hook("useAfterFrame",t),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger("ready")),this.world.flushSubscriptions();let l=this.world.getScheduledUpdates(this.target,s),c=l.length;if(c>0)for(let d=0;d<c;d++){let u=l[c-d-1]();u?u.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}});this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...s||{}},this.target=wt.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=wt.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new ie(this),this.aggregate=bi(1),this.world.addLayoutSubscriber(o=>{o==="repaint"&&(this.pendingUpdate=!0),o==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}setHomePosition(e){this.homePosition.set(wt.projection(e||this.world)),this.pendingUpdate=!0}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize(),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},n=this.width*t,s=this.height*t,o=i.width/n,h=i.height/s,l=n/s;if(e.cover?o>h:o<h){let c=l*i.height,d=(c-i.width)/2;this.target[1]=Math.round(-d+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(c-d+i.x),this.target[4]=Math.round(i.height+i.y)}else{let c=i.width/l,d=(c-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-d),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+c-d)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.transitionManager.hasPending()&&this.transitionManager.stopTransition(),this.updateFocalPosition(e-t,i-n);let s=t/e,o=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*s,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*o,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0,this.transitionManager.resumeTransition()}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,s=Math.min(i,n),o=0,h=0,l=this.x+o,c=this.y+h;if(i<n){let d=this.height-this.width;this.focalPosition=wt.projection({x:l,y:c+d/2,width:s-o*2,height:s-h*2}),this.pendingUpdate=!0}else{let d=this.width-this.height;this.focalPosition=wt.projection({x:l+d/2,y:c,width:s-o*2,height:s-h*2}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:i=!1}={}){let{minX:n,maxX:s,minY:o,maxY:h}=this.getBounds({target:e,padding:t}),l=!1,c=i?e:ne(e),d=Math.round(e[3]-e[1]),u=Math.round(e[4]-e[2]);return n>e[1]&&(l=!0,c[1]=n,c[3]=n+d),o>e[2]&&(l=!0,c[2]=o,c[4]=o+u),s<e[1]&&(l=!0,c[1]=s,c[3]=s+d),h<e[2]&&(l=!0,c[2]=h,c[4]=h+u),[l,c]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,s=Math.abs(1-n);if(this.world.hasActiveZone()){let f=this.world.getActiveZone();if(f){let C=t[3]-t[1]<f.points[3]-f.points[1],R=t[4]-t[2]<f.points[4]-f.points[2];return{minX:C?f.points[1]-i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxX:R?f.points[2]-i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2,minY:C?f.points[3]+i:f.points[1]+(f.points[3]-f.points[1])/2-(t[3]-t[1])/2,maxY:R?f.points[4]+i:f.points[2]+(f.points[4]-f.points[2])/2-(t[4]-t[2])/2}}}let o=t[3]-t[1],h=this.world.width,l=-o*s,c=h-o-l,d=t[4]-t[2],u=this.world.height,m=-d*s,y=u-d-m,v=Math.round(Math.max(l,c)),S=Math.round(Math.min(l,c)),P=Math.round(Math.max(m,y)),g=Math.round(Math.min(m,y));return{minX:S,maxX:v,minY:g,maxY:P}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,s=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),o=n?n.width:this.width,h=n?n.height:this.height,l=this.getRendererScreenPosition()?.width,c=this.world.width,d=l?l/c:1,u=this.options.maxUnderZoom,m=Math.max(d||1,this.options.maxOverZoom),y=1/e,v=s*y;if(y<1){let g=o*s,f=h*s,C=this.world.width/g,R=this.world.height/f;if(C>R){let w=this.world.width*v,O=~~(o*s)*u;w<O&&(e=this.world.width*s/(o*s*u))}else{let w=this.world.height*v,O=~~(h*s)*u;w<O&&(e=this.world.height*s/(h*s*u))}}else v>m&&(e=s/m);let P=Oe(this.target,vi(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(P,{ref:!0,panPadding:100}),P}clampRegion({x:e,y:t,width:i,height:n,padding:s=0}){let o=this.width,h=this.height,l=i/o<n/h,c=e-s,d=t-s,u=i+s*2,m=n+s*2;if(l){let v=m/h*o;return{x:c-(v-u)/2,y:d,width:v,height:m}}let y=u/o*h;return{x:c,y:d-(y-m)/2,width:u,height:y}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let s=wt.singleBox(i,n,e,t);return yi(s,Fn(bi(this.getScaleFactor()),kn(-this.target[1],-this.target[2]))),{x:s[1],y:s[2],width:s[3]-s[1],height:s[4]-s[2],strand:s}}setScale(e,t){yi(this.target,vi(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return typeof this.stopId<"u"&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}};import{dna as wi,DnaFactory as xi}from"@atlas-viewer/dna";var re=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,se={},Dn=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],xt=class extends k{constructor(){super();a(this,"id");a(this,"type","spacial-content");a(this,"isShape",!0);a(this,"points");a(this,"hoverEvents",!1);a(this,"activeEvents",!1);a(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:wi(5)});a(this,"boundingBox",null);a(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}});a(this,"hovering");a(this,"pressing");a(this,"props",{});a(this,"shape",{type:"none"});a(this,"addHover",()=>{this.hovering=!0,this.__revision++});a(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++});a(this,"addPress",()=>{this.pressing=!0,this.__revision++});a(this,"removePress",()=>{this.pressing=!1,this.__revision++});this.id=Q(12),this.points=wi(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let t=this.shape.points;if(this.shape.points.length>2){let i=Math.min(...t.map(h=>h[0])),n=Math.min(...t.map(h=>h[1])),s=Math.max(0,...t.map(h=>h[0])),o=Math.max(0,...t.map(h=>h[1]));this.boundingBox={x:i,y:n,width:s-i,height:o-n};return}this.boundingBox=null}intersects(t){if(!t||this.shape.type==="none")return!1;let[i,n]=t,s=this.shape.points,o=this.boundingBox;if(o||(this.updateBoundingBox(),o=this.boundingBox),!o||i<o.x||i>o.x+o.width||n<o.y||n>o.height+o.y)return!1;let h=!1;for(let l=0,c=s.length-1;l<s.length;c=l++)s[l][1]>n!=s[c][1]>n&&i<(s[c][0]-s[l][0])*(n-s[l][1])/(s[c][1]-s[l][1])+s[l][0]&&(h=!h);return h}getAllPointsAt(t,i){return t[3]-t[1]===1&&t[4]-t[2]===1?this.intersects([t[1],t[2]])?[[this,this.points,i]]:[]:[[this,this.points,i]]}applyProps(t={}){let i=!1;if(t.points)if(this.shape.type!=="polygon"||this.shape.points.length!==t.points.length)this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox();else{let n=!1,s=t.points.length;for(let o=0;o<s;o++)if(t.points[o][0]!==this.shape.points[o][0]||t.points[o][1]!==this.shape.points[o][1]){n=!0;break}n&&(this.shape={type:"polygon",points:t.points,open:t.open},this.updateBoundingBox())}if(t.interactive!==this.props.interactive&&(i=!0,this.props.interactive=t.interactive),(t.open||t.open===!1)&&(i=!0,this.shape.open=t.open),t.style){let n=t.border||t.style.border;if(n!==this._parsed.border.id)if(!n)this._parsed.border.id=null,this._parsed.border.match=[];else{let s=se[n]||re.exec(n)||re.exec(n);s&&(this._parsed.border.id=n,this._parsed.border.match=se[n]=s)}if(this._parsed.border.id&&(t.style.borderWidth=this._parsed.border.match[1],t.style.borderStyle="solid",t.style.borderColor=this._parsed.border.match[4]),t.style.outline!==this._parsed.outline.id)if(!t.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let s=se[t.style.outline]||re.exec(t.style.outline)||re.exec(t.style.outline);s&&(this._parsed.outline.id=t.style.outline,this._parsed.outline.match=se[t.style.outline]=s)}this._parsed.outline.id&&(t.style.outlineWidth=this._parsed.outline.match[1],t.style.outlineStyle="solid",t.style.outlineColor=this._parsed.outline.match[4]),this.props.style=t.style,t.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.backgroundColor,i=!0),t.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=t.style.background,i=!0);for(let s of Dn)if(this.props.style[s]!==t.style[s]){i=!0;break}t.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=t.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),i=!0),t.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=t.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0)}t.href!==this.props.href&&(this.props.href=t.href,i=!0),t.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=t.hrefTarget,i=!0),t.title!==this.props.title&&(this.props.title=t.title,i=!0),t.className!==this.props.className&&(this.props.className=t.className,t.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),i=!0),t.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=t.relativeSize,i=!0),t.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=t.relativeStyle,i=!0),t.html!==this.props.html&&(this.props.html=t.html,i=!0),t.target&&(t.target.width!==this.display.width||t.target.height!==this.display.height||t.target.x!==this.points[1]||t.target.y!==this.points[2])&&(i=!0,this.points=xi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.points=xi.singleBox(t.target.width,t.target.height,t.target.x,t.target.y),this.display.width=t.target.width,this.display.height=t.target.height),i&&this.__revision++}};import Bn from"lru-cache";var Si=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,Pi={},Wn=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),oe={};var ae=class{constructor(e,t){a(this,"canvas");a(this,"ctx");a(this,"options");a(this,"imagesPending",0);a(this,"imagesLoaded",0);a(this,"imageIdsLoaded",[]);a(this,"frameIsRendering",!1);a(this,"pendingDrawCall",!1);a(this,"firstMeaningfulPaint",!1);a(this,"parallelTasks",8);a(this,"frameTasks",0);a(this,"loadingQueueOrdered",!0);a(this,"loadingQueue",[]);a(this,"currentTask",Promise.resolve());a(this,"tasksRunning",0);a(this,"stats");a(this,"averageJobTime",64);a(this,"lastKnownScale",1);a(this,"visible",[]);a(this,"previousVisible",[]);a(this,"rendererPosition");a(this,"dpi");a(this,"drawCalls",[]);a(this,"lastPaintedObject");a(this,"hostCache");a(this,"invalidated",[]);a(this,"_worker",()=>{if(this.loadingQueue.length){let e=this.loadingQueue.pop();e&&(this.tasksRunning++,this.frameTasks++,this.currentTask=e.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}});a(this,"_scheduled",0);a(this,"_doWork",()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let e=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(e=this.loadingQueue.length);for(let t=0;t<=e;t++)this._worker()});this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext("2d",{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.transition="opacity .3s",this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Bn({maxSize:1024*512*512,dispose:(i,n,s)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),s=n.width/e,o=n.height/t,h=(s<o?o:s)*(i&&this.dpi||1);return Number.isNaN(h)||(this.lastKnownScale=h),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let s=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,s.width,s.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let o="";n.filters.brightness&&(o+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(o+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(o+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(o+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(o+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(o+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(o+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(o+=`blur(${n.filters.blur}px) `),this.ctx.filter=o}else this.ctx.filter="none"}applyTransform(e,t,i,n,s){let o=e.__owner.value;if(o&&o.rotation){this.ctx.save();let h=t+n/2,l=i+s/2;this.ctx.translate(h,l),this.ctx.rotate(o.rotation*Math.PI/180),this.ctx.translate(-h,-l),this.lastPaintedObject=o}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,s,o){let h=this.ctx.globalAlpha;if(e instanceof D||e instanceof $){if(e.display.rotation){this.ctx.save();let d=i+s/2,u=n+o/2;e.crop&&(d-=e.crop[t*5+1],u-=e.crop[t*5+2]),this.ctx.translate(d,u),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-d,-u)}if(this.visible.push(e),typeof e.style&&e.style.opacity!=="undefined"){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let d=e.__host.canvas,u=this.getCanvasDims();if((d.indices.indexOf(t)===-1||this.invalidated.indexOf(d.canvases[t])!==-1)&&this.schedulePaintToCanvas(d,e,t,ct({x:i+s/2,y:n+s/2},{x:u.width/2,y:u.height/2})),!this.firstMeaningfulPaint)return;let m=this.hostCache.get(d.canvases[t]);if(m)if(e.crop&&e.cropData){if(e.crop[t*5]){let y=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];y[0]+=e.cropData.x/e.display.scale,y[1]+=e.cropData.y/e.display.scale;let v=e.x*this.lastKnownScale,S=e.y*this.lastKnownScale,P=[i+v,n+S,s,o];P[0]+=v,P[1]+=S,this.ctx.drawImage(m,y[0],y[1],y[2],y[3],P[0],P[1],P[2]+1,P[3]+1)}}else Wn?this.ctx.drawImage(m,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,s+1,o+1):this.ctx.drawImage(m,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,s+Number.MIN_VALUE+.5,o+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let l=e instanceof K&&this.options.box,c=e instanceof xt&&this.options.polygon;if((l||c)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let d=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),u=e.props.relativeStyle?1:s/e.width;typeof d.opacity<"u"&&(this.ctx.globalAlpha=d.opacity);let m=0;typeof d.borderWidth<"u"&&(m=parseInt(d.borderWidth,10)*u);let y=0;typeof d.outlineWidth<"u"&&(y=parseInt(d.outlineWidth,10)*u);let v=0;if(typeof d.outlineOffset<"u"&&(v=parseInt(d.outlineOffset,10)*u),d.borderColor&&(this.ctx.strokeStyle=d.borderColor),d.boxShadow){let S=d.boxShadow.split(/,(?![^(]*\))/);for(let P of S){let g=Pi[P]||Si.exec(P)||Si.exec(P);Pi[P]=g,g&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(g[1])*this.dpi*u,this.ctx.shadowOffsetY=parseInt(g[3])*this.dpi*u,this.ctx.shadowBlur=parseInt(g[5])*this.dpi*u,this.ctx.shadowColor=g[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+m,n+m,s,o),this.ctx.restore())}}if(this.ctx.fillStyle=d.backgroundColor||"transparent",this.ctx.lineWidth=m,c){let S=e.shape,P=S.points||[],g=P.length;this.ctx.beginPath();for(let f=0;f<g;f++)this.ctx.lineTo(i+P[f][0]*this.lastKnownScale,n+P[f][1]*this.lastKnownScale);S.open||this.ctx.closePath(),m&&this.ctx.stroke(),S.open||this.ctx.fill()}else m&&this.ctx.strokeRect(i+m/2,n+m/2,s+m,o+m),this.ctx.fillRect(i+m,n+m,s,o);y&&(d.outlineColor&&(this.ctx.strokeStyle=d.outlineColor),this.ctx.lineWidth=y,this.ctx.strokeRect(i-y/2-v,n-y/2-v,s+m*2+y+v*2,o+m*2+y+v*2))}this.ctx.globalAlpha=h}}loadImage(e,t,i,n=!1){if(oe[e]&&oe[e].naturalWidth>0){t(oe[e]);return}try{let s=!1;n||setTimeout(()=>{s||this.loadImage(e,t,i,!0)},3e3);let o=document.createElement("img");o.decoding="auto",o.onload=function(){s=!0,t(o),oe[e]=o,o.onload=null},this.options.crossOrigin&&(o.crossOrigin="anonymous"),o.src=e,o.complete&&o.onload({}),o.width}catch(s){console.log("image error",s),i(s)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let s=`${t.id}--${t.display.scale}-${i}`,o=this.invalidated.indexOf(s);o!==-1&&this.invalidated.splice(o,1),e.canvases[i]=s,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:s,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(h=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h();return}let l=t.getImageUrl(i);this.loadImage(l,c=>{this.loadingQueue.push({id:s,scale:t.display.scale,distance:n,task:()=>new Promise(d=>{this.imageIdsLoaded.includes(s)||(this.imagesLoaded++,this.imageIdsLoaded.push(s)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let u=t.display.points.slice(i*5,i*5+5),m=document.createElement("canvas"),y=m.getContext("2d");m.width=u[3]-u[1],m.height=u[4]-u[2],this.hostCache.set(e.canvases[i],m),this.drawCalls.push(()=>{y.drawImage(c,0,0,u[3]-u[1],u[4]-u[2]),d()})})}),h()},c=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),h()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof D||e instanceof $)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let s=t[3]-t[1]<n.points[3]-n.points[1],o=t[4]-t[2]<n.points[4]-n.points[2];return{x1:s?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:o?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:s?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:o?n.points[4]+i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity="1",this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity="1",this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}};var St=class{constructor(e){a(this,"renderers",[]);a(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let s=0;s<this.length;s++)this.renderers[s].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,i,n,s,o){for(let h=0;h<this.length;h++)this.renderers[h].paint(e,t,i,n,s,o)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}};import{DnaFactory as Nn,scale as zn}from"@atlas-viewer/dna";var he=class{constructor(e){a(this,"canvas");a(this,"context");a(this,"heightRatio",1);a(this,"widthRatio",1);a(this,"target",new Float32Array(5));a(this,"initialWidth");a(this,"initialHeight");a(this,"bounds");a(this,"aggregate");a(this,"delta",0);a(this,"renderNextFrame",!0);this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext("2d"),this.context.globalAlpha=.5,this.aggregate=zn(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,s=this.initialHeight/e.height,o=this.widthRatio>this.heightRatio?n:s;if(this.target=i,this.bounds){let h=e.getPointsAt(this.bounds,this.aggregate,o);for(let[l,c]of h)if(l instanceof D&&l.__host.canvas){let d=c.length/5;for(let u=0;u<d;u++)if(l.__host.canvas.canvases[u]){let y={x1:c[u+1]*o,y1:c[u+2]*o,width:(c[u+3]-c[u+1])*o,height:(c[u+4]-c[u+2])*o}}}}e.getPoints().forEach((h,l,c)=>{if(l%5===0&&h){let d={x1:c[l+1]*o,y1:c[l+2]*o,x2:c[l+3]*o,y2:c[l+4]*o,width:(c[l+3]-c[l+1])*o,height:(c[l+4]-c[l+2])*o};this.context.strokeStyle="red",this.context.strokeRect(d.x1,d.y1,d.width,d.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*o,i[2]*o,(i[3]-i[1])*o,(i[4]-i[2])*o))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=Nn.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,s,o){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};var Ei=class{constructor(){a(this,"autoWidth",!1);a(this,"autoHeight",!0);a(this,"width");a(this,"height");a(this,"world");a(this,"content",[]);a(this,"viewingDirection","left-to-right");a(this,"rows");a(this,"columns",4);a(this,"spacing",20);a(this,"reversed",!1);a(this,"padding",20);this.world=V.withProps({width:0,height:0,viewingDirection:"left-to-right"}),this.width=0,this.height=0}setViewingDirection(e){this.viewingDirection=e}addContent(e){this.content.push(...e.map(t=>this.world.addObjectAt(t,{width:0,height:0,x:0,y:0})))}setWidth(e){this.width=e}setHeight(e){this.height=e}setSpacing(e){this.spacing=e}setPadding(e){this.padding=e}setRows(e){this.autoWidth=!0,this.rows=e}setColumns(e){this.autoHeight=!0,this.columns=e}recalculate(){if(this.height===0&&this.width===0||this.rows===0||this.columns===0)return;if(this.autoHeight&&!this.width)throw new Error("Cannot set auto height without setting a width");if(this.autoWidth&&!this.height)throw new Error("Cannot set auto width without setting a height");(this.viewingDirection==="left-to-right"||this.viewingDirection==="top-to-bottom")&&this.reversed&&(this.reversed=!1,this.content.reverse()),(this.viewingDirection==="right-to-left"||this.viewingDirection==="bottom-to-top")&&!this.reversed&&(this.reversed=!0,this.content.reverse());let e=this.content.length,t=()=>{if(this.autoWidth&&this.rows){let h=e>this.rows?this.rows:e;return{columns:Math.ceil(e/h),rows:h}}if(this.autoHeight&&this.columns){let h=e>this.columns?this.columns:e;return{columns:h,rows:Math.ceil(e/h)}}throw new Error("Something went wrong.")},{columns:i,rows:n}=t(),s=this.autoWidth?-1:this.width-this.padding*2,o=this.autoWidth?-1:(s-this.spacing*(i-1))/i;if(this.autoHeight&&!this.autoWidth){let h=0,l=this.padding;for(let c=0;c<n&&h!==e;c++){let d=0,u=[];for(let m=0;m<i;m++){let y=this.reversed?e-h:h;if(h===e)break;let v=this.content[y],S=v.width,P=v.width/v.height,g=o/P;u.push([h,o,g,o/S]),g>d&&(d=g),h++}for(let m=0;m<i&&u[m];m++){let y=this.world.getPoints(),v=u[m][0],S=u[m][1],P=u[m][2],g=u[m][3],f=this.padding+m*(this.spacing+S),C=l+(d-P)/2,R=this.reversed?e-v:v,w=y[R*5+1],b=y[R*5+2];this.world.scaleWorldObject(v,g),(w!==f||b!==C)&&this.world.translateWorldObject(R,f-w,C-b)}l+=d+this.spacing}this.height=l+this.padding,this.world.resize(this.width,this.height);return}this.autoWidth&&this.autoHeight,!this.autoWidth&&this.autoHeight}getWorld(){return this.world}};import Hn from"normalize-wheel";import{compose as jn,dna as Ae,scaleAtOrigin as Un,transform as Ri,translate as Ti}from"@atlas-viewer/dna";function Ci(r){return{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2]}}var _i="pan",Oi="scroll",$n="gesture",Vn={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},le=(r={})=>({start:function(e){let{zoomWheelConstant:t,enableWheel:i,enableClickToZoom:n,ignoreSingleFingerTouch:s,enablePanOnWait:o,panOnWaitDelay:h,parentElement:l,requireMetaKeyForWheelZoom:c}={...Vn,...r},d={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:Ae(5),multiTouch:{distance:0}};e.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function u(){S=0,g="",C(),C(void 0,"notice"),P=0}function m(){e.world.constraintBounds(),u()}function y(x){if(x.which>1){d.isPressing=!1;return}e.mode==="explore"&&(x.preventDefault(),d.pointerStart.x=x.atlas.x,d.pointerStart.y=x.atlas.y,e.transitionManager.stopTransition(),d.isPressing=!0)}function v(){u(),d.isPressing&&(e.mode==="explore"&&e.world.constraintBounds(),d.isPressing=!1)}let S=0,P=0,g="";function f(x){if(e.mode==="explore"){if(x.atlasTouches.length===1&&(P=performance.now(),s==!1&&x.preventDefault(),d.pointerStart.x=x.atlasTouches[0].x,d.pointerStart.y=x.atlasTouches[0].y),x.atlasTouches.length===2){g=$n,x.preventDefault();let T=x.atlasTouches[0].x,A=x.atlasTouches[1].x;d.pointerStart.x=(T+A)/2;let ht=x.atlasTouches[0].y,M=x.atlasTouches[1].y;d.pointerStart.y=(ht+M)/2,S=ct({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY})}e.transitionManager.stopTransition(),d.isPressing=!0}}function C(x,T="intent"){l&&(l.dataset[T]=x)}function R(x){let T=null,A=null,ht=!1,M=0;if(d.isPressing&&x.touches.length===2){let X=x.touches[0].clientX,rt=x.touches[1].clientX;T=(X+rt)/2;let yt=x.touches[0].clientY,bt=x.touches[1].clientY;A=(yt+bt)/2,M=ct({x:x.touches[0].clientX,y:x.touches[0].clientY},{x:x.touches[1].clientX,y:x.touches[1].clientY}),ht=!0}if(C(g),d.isPressing&&x.touches.length===1){if(o&&(performance.now()-P<h&&g==""&&(g=Oi),g==""&&(g=_i)),C(g),g==""&&s==!0||g==Oi){C("require-two-finger","notice");return}let X=x.touches[0];T=X.clientX,A=X.clientY}if(T!==null&&A!==null){let X=e.getRendererScreenPosition();if(X){let{x:rt,y:yt}=e.viewerToWorld(T-X.x,A-X.y),bt=M&&S?M/S:1;e.transitionManager.customTransition(p=>{p.from=Ae(e.target),p.to=Ri(p.from,jn(Ti(d.pointerStart.x-rt,d.pointerStart.y-yt),Un(1/bt,rt,yt)),d.mousemoveBuffer),p.elapsed_time=0,p.total_time=0,p.timingFunction=q.easeInOutExpo,p.done=!1})}S=M}g==_i&&x.preventDefault()}function w(x){if(d.isPressing){let T=e.getRendererScreenPosition();if(T){let{x:A,y:ht}=e.viewerToWorld(x.clientX-T.x,x.clientY-T.y);e.transitionManager.customTransition(M=>{M.from=Ae(e.target),M.to=Ri(M.from,Ti(d.pointerStart.x-A,d.pointerStart.y-ht),d.mousemoveBuffer),M.elapsed_time=0,M.total_time=0,M.timingFunction=q.easeInOutExpo,M.done=!1})}}}function b(x){e.mode==="explore"&&e.world.zoomIn(x.atlas)}function O(x){let A=1+Hn(x).spinY/t;e.world.zoomTo(A,x.atlas,!0)}function W(x){return c&&x.metaKey==!1?(C("meta-required","notice"),x.stopPropagation(),!1):!0}e.world.addEventListener("mouseup",m),e.world.addEventListener("touchend",m),e.world.addEventListener("touchstart",f),e.world.addEventListener("mousedown",y),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",w),l&&l.addEventListener("touchmove",R),n&&(e.world.activatedEvents.push("onClick"),e.world.addEventListener("click",b)),i&&(e.world.activatedEvents.push("onWheel"),c&&l?.addEventListener("wheel",W,{passive:!0,capture:!0}),e.world.addEventListener("wheel",O));let N=e.world.addLayoutSubscriber((x,T)=>{if(x==="zone-changed"&&e.transitionManager.constrainBounds({transition:{duration:0}}),x==="zoom-to"&&T&&e.transitionManager.zoomTo(T.factor,{origin:T.point,stream:T.stream}),x==="go-home"){let A=T.immediate?{duration:0}:void 0;e.transitionManager.goToRegion(Ci(e.homePosition),{transition:A})}if(x==="goto-region"&&T){let A=T.immediate?{duration:0}:{};e.transitionManager.goToRegion(T,{transition:A})}x==="constrain-bounds"&&e.transitionManager.constrainBounds({transition:T?.immediate?{duration:0}:void 0})});return()=>{e.world.removeEventListener("mouseup",m),e.world.removeEventListener("touchend",m),e.world.removeEventListener("touchstart",f),e.world.removeEventListener("mousedown",y),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),e.world.removeEventListener("mousemove",w),l&&(l.removeEventListener("touchmove",w),l.removeEventListener("wheel",W,{passive:!0,capture:!0})),n&&e.world.removeEventListener("click",b),i&&e.world.removeEventListener("wheel",O),N()}},updatePosition(){}});import{useCallback as ur,useEffect as G,useMemo as mr,useRef as Ui,useState as Me}from"react";import Gn,{useContext as Zn}from"react";import{jsx as Xn}from"react/jsx-runtime";var et=Gn.createContext("explore");et.displayName="Mode";var de=()=>Zn(et);function ca(r){return Xn(et.Provider,{value:r.mode,children:r.children})}import fr from"react-use-measure";import Ai from"react";var it=Ai.createContext(null);it.displayName="Atlas";var mt=Ai.createContext(null);mt.displayName="Bounds";import Bi,{useCallback as nr,useEffect as Wi,useRef as rr}from"react";import Qn from"react-reconciler";var kt,Yn=typeof performance=="object"&&typeof performance.now=="function";if(Yn){let r=performance;kt=()=>r.now()}else{let r=Date,e=r.now();kt=()=>r.now()-e}import{version as Kn}from"react";var qn=16;function Mi(r,e){r&&r.appendChild&&e&&r.appendChild(e)}function Li(r,e){r&&r.removeChild&&e&&r.removeChild(e)}function Jn(r,e){return Li(r.world,e)}function tr(r,e,t){return ki(r.world,e,t)}function ki(r,e,t){r&&r instanceof tt&&(r=r.world),r&&r.insertBefore&&r.insertBefore(e,t)}function Fi(r,e,t){if(t&&(r.applyProps&&r.applyProps(t),r instanceof k))for(let i of At){let n=i.slice(2).toLowerCase();t[i]!==e[i]&&(e[i]&&r.removeEventListener(n,e[i]),r.addEventListener(n,t[i]))}}function Di(r,e){let t=Object.keys(e),i=!1;for(let n of t)if(At.indexOf(n)!==-1){let s=Y[n];if(s){if(r.activatedEvents.indexOf(s)!==-1)continue;i=!0,r.activatedEvents.push(s)}}i&&r.triggerEventActivation()}var ce=new Map,Ii={};function er(r,{args:e=[],...t},i,n,s){if(!(i instanceof tt)&&s){let l=c=>c.return?l(c.return):c.stateNode&&c.stateNode.containerInfo;i=l(s)}let o,h=i.world;switch(r){case"world":o=V.withProps({width:t.width,height:t.height,viewingDirection:"left-to-right"}),o.activatedEvents=h.activatedEvents,o.eventHandlers=h.eventHandlers,o.subscriptions=h.subscriptions,o.triggerEventActivation(),h=o;break;case"box":o=new K;break;case"shape":o=new xt;break;case"worldObject":case"world-object":o=new J;break;case"worldImage":case"world-image":o=new D;break;case"texture":o=new dt;break;case"compositeImage":case"composite-image":o=new Gt({id:t.id,width:t.width,height:t.height,images:[],renderOptions:t.renderOptions});break;case"tiledImage":case"tiled-image":o=$.fromTile(t.uri,t.display,t.tile,t.scaleFactor,void 0,t.format,t.useFloorCalc,t.version3);break;case"paragraph":o=new ot,o.text=t.children;break;default:return}return Di(h,t),Fi(o,{},t),o}function ir(r,e){if(e instanceof V)r.world=e;else if(e instanceof J)r.world.appendChild(e);else if(e)throw new Error("Invalid root")}var Ft=Qn({unstable_now:kt,now:kt,createInstance:er,removeChild:Li,appendChild:Mi,appendInitialChild:Mi,insertBefore:ki,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<"u"?setTimeout:void 0,cancelTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,setTimeout:typeof setTimeout<"u"?setTimeout:void 0,clearTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:ir,removeChildFromContainer:Jn,createTextInstance(){},insertInContainerBefore:tr,prepareUpdate(r,e,t,i,n){return Di(n.world,i),i},commitUpdate(r,e,t,i,n,s){r.applyProps&&e&&Fi(r,i,e)},finalizeInitialChildren(r){return r?.__handlers},getChildHostContext(){return Ii},getRootHostContext(){return Ii},prepareForCommit(r){return r.isCommitting=!0,null},preparePortalMount(){},hideInstance(r){r&&r.points&&(r.points[0]=0)},unhideInstance(r,e){r&&r.points&&(r.points[0]=1)},getPublicInstance(r){return r},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(r){r.isCommitting=!1,r.pendingUpdate=!0,r.world&&r.world.needsRecalculate&&(r.world.recalculateWorldSize(),r.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(r){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),qn},getInstanceFromNode(r){throw console.log("getInstanceFromNode",r),new Error("Not implemented")},getInstanceFromScope(r){throw console.log("getInstanceFromScope",r),new Error("Not implemented")},prepareScopeUpdate(r,e){throw console.log("prepareScopeUpdate",r,e),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Ft.injectIntoDevTools({bundleType:0,version:Kn,rendererPackageName:"@atlas-viewer/atlas"});function Dt(r,e){let t=ce.get(r);t&&Ft.updateContainer(null,t,null,()=>{ce.delete(r),e&&e(r)})}var Bt={render(r,e){let t=ce.get(e);if(t)Ft.updateContainer(r,t,null);else{let i=Ft.createContainer(e,0,null,!1,null,"",()=>{},null);Ft.updateContainer(r,i,null),ce.set(e,i)}},unmountComponentAtNode(r,e){Dt(r,e)}};import*as ue from"react";var H=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?ue.useLayoutEffect:ue.useEffect;import{jsx as Wt}from"react/jsx-runtime";var Ni=Bi.memo(({children:r,setIsReady:e,onCreated:t,bounds:i,preset:n,mode:s="explore"})=>{let o=nr(function(l){let c=rr(!1),d=()=>{e(!0)};return Wi(()=>{if(n&&!c.current){n.runtime.goHome();let u=t&&t(n);return void(u&&u.then?u.then(d):d())}return()=>{}},[]),Wi(()=>{c.current=!0},[]),l.children},[n]);return H(()=>{if(n){let h=n.runtime;s!==h.mode&&(h.mode=s),Bt.render(Wt(Bi.StrictMode,{children:Wt(o,{children:Wt(mt.Provider,{value:i,children:Wt(et.Provider,{value:s,children:Wt(it.Provider,{value:n,children:r})})})})}),h)}},[n,s,r]),H(()=>{if(n){let h=n.runtime;return()=>{Bt.unmountComponentAtNode(h)}}return()=>{}},[n]),null});var me=class{constructor(e,t){a(this,"canvas");a(this,"gl");a(this,"program");a(this,"fragmentShader");a(this,"vertexShader");a(this,"rectBuffer");a(this,"fragmentShaderSource",`
|
|
2
2
|
precision mediump float;
|
|
3
3
|
|
|
4
4
|
uniform sampler2D u_image;
|