@hatiolab/things-scene 10.0.0-beta.133 → 10.0.0-beta.134
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-types/items/items-data-binding.d.ts +1 -1
- package/dist-types/items/items-data-binding.d.ts.map +1 -1
- package/package.json +1 -1
- package/things-scene-min.js +1 -1
- package/things-scene-min.js.map +1 -1
- package/things-scene-transfer.mjs +1 -1
- package/things-scene.mjs +1 -1
- package/things-scene.mjs.map +1 -1
package/things-scene.mjs
CHANGED
|
@@ -47,5 +47,5 @@ import t from"dompurify";import*as e from"three";import{Color as n,LinearSRGBCol
|
|
|
47
47
|
</button>`:z}
|
|
48
48
|
${n?I`<button class="closable" @click=${this.closeContainer}>close</button>`:z}
|
|
49
49
|
</div>
|
|
50
|
-
`,this.element)}catch(t){}}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",24):this.setState("height",this.get("height"))}}pg=new WeakMap,Ec.memoize(yg.prototype,"bounds",!0),Ec.register("container",yg);const bg=Math.sqrt(3),_g=2;function vg(t,e,n,i,r){const s=5+r,o=n.x,a=n.y,c=i.x,l=i.y;if(Math.abs(o-c)>s&&Math.abs(a-l)>s){const n=(l-a)/(c-o),i=a-n*o;if(Math.abs(e-(n*t+i))>s)return!1}let h,d,u,p;return o>c?(d=o,h=c):(d=c,h=o),a>l?(p=a,u=l):(p=l,u=a),!(d+5<t)&&(!(h-5>t)&&(!(p+5<e)&&!(u-5>e)))}function xg(t,e,n,i=2){for(let r=0;r<n.length-1;r++)if(vg(t,e,n[r],n[r+1],i))return!0;return!1}function wg(t,e,n,i){if("arrow"!=t.slice(-5))return n;const r=Math.atan2(i.y-n.y,i.x-n.x),s=1.5*e;return{x:n.x+Math.cos(r)*s,y:n.y+Math.sin(r)*s}}function Sg(t,e,n){let{lineWidth:i=_g,strokeStyle:r="#000000",lineCap:s=!1,alpha:o=1,begin:a="none",end:c="none",beginSize:l="size5",endSize:h="size5"}=n;if(("none"!=a||"none"!=c)&&(i=Number(i)||_g,t.lineCap=s,t.lineWidth=i,t.strokeStyle=r,t.fillStyle=r,t.globalAlpha*=o,"none"!=a&&Mg(t,e[0],e[1],i,a,kg(l,i)),"none"!=c)){const n=e.length;Mg(t,e[n-1],e[n-2],i,c,kg(h,i))}}function Mg(t,e,n,i,r,s){const{x:o,y:a}=e,c=Math.atan2(n.y-a,n.x-o);switch(t.beginPath(),t.translate(o,a),t.rotate(c),r){case"oval":t.ellipse(0,0,s.X,s.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-s.X,0),t.lineTo(0,-s.Y),t.lineTo(s.X,0),t.lineTo(0,s.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(bg*s.X,-s.Y),t.lineTo(bg*s.X,s.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(bg*s.X,-s.Y),t.lineTo(-s.X/1.5+bg*s.X,0),t.lineTo(bg*s.X,s.Y),t.fill();break;case"open-arrow":t.moveTo(bg*s.X+i,-s.Y),t.lineTo(i,0),t.lineTo(bg*s.X+i,s.Y),t.stroke();break;case"cross":t.moveTo(-s.X,-s.Y),t.lineTo(s.X,s.Y),t.moveTo(s.X,-s.Y),t.lineTo(-s.X,s.Y),t.stroke()}t.rotate(-c),t.translate(-o,-a),t.closePath()}function kg(t,e){const n={X:0,Y:0};switch(e*=1.2,t){case"size1":n.X=e,n.Y=e;break;case"size2":n.X=1.5*e,n.Y=e;break;case"size3":n.X=2*e,n.Y=e;break;case"size4":n.X=e,n.Y=1.5*e;break;case"size5":default:n.X=1.5*e,n.Y=1.5*e;break;case"size6":n.X=2*e,n.Y=1.5*e;break;case"size7":n.X=e,n.Y=2*e;break;case"size8":n.X=1.5*e,n.Y=2*e;break;case"size9":n.X=2*e,n.Y=2*e}return n}const Ag="N",Eg="S",Cg="E",Tg="W";class Pg{constructor({component:t,anchor:e,position:n,self:i}){this.component=t,this._anchorName=e,this._position=n,this.self=i}get position(){const t=this.anchor;if(t){const{position:e}=t,n=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(n.x,n.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Cg;const n=e.position;return n.y<=t.top?Ag:n.y>=t.top+t.height?Eg:n.x<=t.left?Tg:Cg}get boundaryPosition(){const t=this.anchor;if(t){let{position:e}=t,n=0,i=0;switch(this.direction){case Eg:i=20;break;case Ag:i=-20;break;case Tg:n=-20;break;default:n=20}e={x:e.x+n,y:e.y+i};const r=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}}}class Og extends Ec{isLine(){return!0}is3dish(){return!0}replaceRefids(t){["from","to"].forEach(e=>{const n=this.get(e);if(n?.component){const i=t.get(n.component)||n.component;this.set(e,{...n,component:i})}})}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:n}=this.getState("from")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._fromEnd=new Pg({component:i,fromto:"from",anchor:e,position:n,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:n}=this.getState("to")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._toEnd=new Pg({component:i,fromto:"to",anchor:e,position:n,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},n){n&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e})}render(t){const{begin:e="none",end:n="none",lineWidth:i,round:r=0}=this.state;let s=this.drawPath;Sg(t,s,this.state),t.beginPath();const o=wg(e,i,s[0],s[1]),a=wg(n,i,s[s.length-1],s[s.length-2]),c=s[0];s=[o,...s.slice(1,-1),a];let l={x:o.x,y:o.y};if(t.moveTo(o.x,o.y),s.length>=2&&$s(c)){const e=s[1],n=Js(e,r),i=Math.sqrt((o.x-e.x)**2+(o.y-e.y)**2),a=0!==i?Math.atan2(o.x-e.x,o.y-e.y):0,l=Math.sin(a)*Math.min(n,i/2)+e.x,h=Math.cos(a)*Math.min(n,i/2)+e.y,d=Ks({x:o.x,y:o.y},{x:l,y:h},c.bulge);d&&t.arc(d.cx,d.cy,d.radius,d.startAngle,d.endAngle,d.clockwise)}for(let e=1;e<s.length;e++){const n=l;l=s[e];const i=s[e+1];if(n.x===l.x&&n.y===l.y)continue;if(!i){t.lineTo(l.x,l.y);break}const o=Js(l,r);let a=Math.sqrt((n.x-l.x)*(n.x-l.x)+(n.y-l.y)*(n.y-l.y)),c=0!==a?Math.atan2(n.x-l.x,n.y-l.y):0,h=Math.sin(c)*Math.min(o,a/2)+l.x,d=Math.cos(c)*Math.min(o,a/2)+l.y;const u=o>0||0!==a?{x:h,y:d}:l;a=Math.sqrt((i.x-l.x)*(i.x-l.x)+(i.y-l.y)*(i.y-l.y)),c=0!==a?Math.atan2(i.x-l.x,i.y-l.y):0,h=Math.sin(c)*Math.min(o,a/2)+l.x,d=Math.cos(c)*Math.min(o,a/2)+l.y;const p=o>0||0!==a?{x:h,y:d}:l;if(t.lineTo(u.x,u.y),o>0&&t.quadraticCurveTo(l.x,l.y,p.x,p.y),$s(l)){const e=Js(i,r),n=Math.sqrt((l.x-i.x)**2+(l.y-i.y)**2),s=0!==n?Math.atan2(l.x-i.x,l.y-i.y):0,o=Math.sin(s)*Math.min(e,n/2)+i.x,a=Math.cos(s)*Math.min(e,n/2)+i.y,c=Ks({x:p.x,y:p.y},{x:o,y:a},l.bulge);c&&t.arc(c.cx,c.cy,c.radius,c.startAngle,c.endAngle,c.clockwise)}}this.drawStroke(t,void 0)}contains(t,e){const{lineWidth:n}=this.state;return xg(t,e,this.drawPath,n)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state,{x1:n,y1:i,x2:r,y2:s}=this.state;return[this.fromEnd?.position||t?.position||{x:n,y:i},this.toEnd?.position||e?.position||{x:r,y:s}]}set path(t){const[e,n]=t,{from:i,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...i,position:e},to:{...r,position:n}})}get textBounds(){const t=this.drawPath;let e,n,i=0;for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=(s.x-o.x)*(s.x-o.x)+(s.y-o.y)*(s.y-o.y);a>i&&(i=Math.ceil(a),e=s,n=o)}let{paddingTop:r,paddingLeft:s,paddingRight:o,paddingBottom:a}=this.state;return a||=0,r||=0,s||=0,o||=0,{left:Math.min(e.x,n.x)+s,top:Math.min(e.y,n.y)+r,width:Math.max(Math.abs(e.x-n.x)-s-o,0),height:Math.max(Math.abs(e.y-n.y)-r-a,0)}}get decorators(){return this.app.isEditMode?["decotag"]:[]}}Og.getTipNeckPos=wg,Og.containedInPath=xg,Og.drawEndTips=Sg,Ec.register("line",Og);const Dg={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class zg extends(bf(Cc)){is3dish(){return!0}render(t){const{cx:e,cy:n,rx:i,ry:r,startAngle:s,endAngle:o,anticlockwise:a}=this.state;t.beginPath(),t.ellipse(e,n,Math.abs(i),Math.abs(r),0,s||0,o||2*Math.PI,a),void 0!==s&&void 0!==o&&(t.lineTo(e,n),t.closePath())}get path(){const{cx:t,cy:e,rx:n,ry:i}=this.state;return[{x:t-n,y:e-i},{x:t+n,y:e-i},{x:t+n,y:e+i},{x:t-n,y:e+i}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2,rx:(n.x-e.x)/2,ry:(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i,rx:r,ry:s}=this.state,o=(t-n)/(2*r-.5),a=(e-i)/(2*s-.5);return o*o+a*a<.25}outline(t){return function(t,e){const{cx:n,cy:i,rx:r,ry:s}=t.model,o=2*Math.PI*e,a=n+r*Math.cos(o),c=i+s*Math.sin(o);return t.toScene(a,c)}(this,t)}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return Dg}}Ec.memoize(zg.prototype,"path",!1),Ec.register("ellipse",zg);const Ig={object:{fill:"rgba(180,180,180,0.18)",stroke:"#888888",icon:"?",label:"object"},transport:{fill:"rgba(100,180,255,0.18)",stroke:"#3a78c8",icon:"⇄",label:"transport"},facility:{fill:"rgba(160,140,220,0.18)",stroke:"#6b4ec8",icon:"◫",label:"facility"},vehicle:{fill:"rgba(120,200,140,0.18)",stroke:"#3a8c5e",icon:"⊙",label:"vehicle"},region:{fill:"rgba(220,200,100,0.18)",stroke:"#a0892a",icon:"▢",label:"region"},path:{fill:"rgba(200,140,160,0.18)",stroke:"#a0506a",icon:"⌐",label:"path"},"3d-asset":{fill:"rgba(255,180,80,0.18)",stroke:"#c87a2a",icon:"◈",label:"3D asset"}},Rg=[{type:"string",label:"placeholder-label",name:"placeholderLabel",description:'사용자에게 표시할 추가 라벨 (예: "Stocker A1")'},{type:"string",label:"hint",name:"placeholderHint",description:"구체화 시 참고 — 도면의 원본 식별자 / VLM 라벨 등"}];function Lg(t,e,n,i,r){const{left:s,top:o,width:a,height:c}=e,l=Math.max(a,1),h=Math.max(c,1);t.save(),t.fillStyle=n.fill,t.fillRect(s,o,l,h),t.strokeStyle=n.stroke,t.lineWidth=1.5,t.setLineDash([4,3]),t.strokeRect(s,o,l,h),t.setLineDash([]),t.restore(),Math.min(l,h)>=24&&(t.save(),t.fillStyle=n.stroke,t.font=`bold ${Math.min(20,.4*Math.min(l,h))}px Arial`,t.textAlign="center",t.textBaseline="middle",t.fillText(n.icon,s+l/2,o+h/2),t.restore());const d=i?`${n.label}: ${i}`:n.label;h>=32&&(t.save(),t.fillStyle=n.stroke,t.font="10px Arial",t.textAlign="center",t.textBaseline="bottom",t.fillText(d,s+l/2,o+h-4),t.restore()),r&&h>=40&&(t.save(),t.fillStyle=n.stroke,t.font="9px Arial",t.textAlign="right",t.textBaseline="top",t.fillText(`hint: ${r}`,s+l-4,o+4),t.restore())}const jg={mutable:!1,resizable:!0,rotatable:!0,properties:[...Rg,{type:"placeholder-convert",label:"",name:"_convert"}],help:"scene/component/placeholder"};class Fg extends(Pc(Cc)){get nature(){return jg}render(t){const{placeholderLabel:e,placeholderHint:n}=this.state;Lg(t,this.bounds,Ig.object,e,n)}}Ec.register("placeholder",Fg);const Ng=["placeholder"];function Hg(t,e=[]){return!!t&&(!!Ng.includes(t)||e.includes(t))}const Bg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e+1,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){const i=n[e+1];n[e+1]={...i||{},x:t.x,y:t.y}})},ondragend:function(t,e,n){}},Yg={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class Vg extends Cc{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get cornerEditable(){return!0}get path(){return this.state.path??[]}set path(t){this.set("path",t)}contains(t,e){const n=this.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}get controls(){const t=this.path;return t.map((e,n)=>{const i=t[n+1>=t.length?0:n+1];return{x:(e.x+i.x)/2,y:(e.y+i.y)/2,handler:Bg}})}get nature(){return Yg}}Ec.memoize(Vg.prototype,"controls",!1),Ec.register("polygon",Vg);const Gg=[];class Wg extends(Ul(Vg)){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach(e=>e.replaceRefids(t))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach(t=>t.dispose()),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return Lc.get(this.get("layout"))||Fc}reflow(){this.layout.reflow(this),this.components&&this.components.forEach(t=>{t.isContainer()&&t.reflow()})}get hierarchy(){const t=super.hierarchy;return this.components?.length&&(t.components=this.components.map(t=>t.hierarchy)),t}reparent(t,e={}){t&&t.parent!==this&&this.addComponent(t,{silent:!0})}addComponent(t,e=!1){const{ghost:n=!1,silent:i=!1}="boolean"==typeof e?{ghost:e}:e,r=t.parent;if(r){if(this===r)return;r.removeComponent(t,n||i)}const s=this._components.push(t)-1;i&&(t._silentAdd=!0),t.parent=this,t.added(this),n||i||this.trigger("add",this,t,s),t.delegate_on(this),i?(r&&this.root?._removeTraverse?.(t),this.trigger("add",this,t,s),t.trigger("added",this,t,s),delete t._silentAdd):n||t.trigger("added",this,t,s),this.root&&this.root.isReady&&t.invokeReady()}removeComponent(t,e=!1){const n=this._components.indexOf(t);-1!=n&&(this._components.splice(n,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,n=!1){const i=t.parent;i&&i.removeComponent(t,n);const r=this._components.splice(0,e);this._components=r.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),n||this.trigger("add",this,t,e),t.delegate_on(this),n||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach(t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)}),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach(t=>this.removeComponent(t,e)),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach(n=>{n.isContainer()?n.traverse(t,e):t.call(e,n)})}indexOf(t){return(this._components||Gg).indexOf(t)}size(){return(this._components||Gg).length}moveChildAt(t,e){const n=this.indexOf(e);if(-1==n)return;let i=this._components.splice(0,n);const r=this._components.splice(1);this._components=i.concat(r),t=Math.max(0,t),t=Math.min(t,this._components.length),i=this._components.splice(0,t),this._components=i.concat(e,this._components)}moveChildForward(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=n.concat(i,this._components)}moveChildToBack(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=this._components.concat(n,i)}symmetryX(t){super.symmetryX(t),this.components.map(t=>{t.symmetryX(0)})}findAll(t,...e){if("string"==typeof t)return tc(t,this,e[0]||this);if("function"!=typeof t)return[];let n=[];for(let i=this.components.length-1;i>=0;i--){const r=this.components[i].findAll(t,...e);r&&(n=n.concat(r))}return t(this,...e)&&n.push(this),n}findFirst(t,...e){if("string"==typeof t)return tc(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){const i=this.components[n].findFirst(t,...e);if(null!=i)return i}return t(this,...e)?this:void 0}}findById(t){return this.root.findAllById?.(t)?.[0]}findByRefid(t){return this.root.findByRefid?.(t)}capture(t,e,n){if(!this.app.isEditMode&&this.hidden)return!1;const i=this.fromParent(t,e);if(!this.contains(i.x,i.y))return!1;const r=this.bounds;i.x-=r.left,i.y-=r.top;const s=this.layout.capturables(this);for(let r=s.length-1;r>=0;r--){const o=s[r];let a;if(a="static"==o.position?o.capture(i.x,i.y,n):o.capture(t,e,n),a)return a}return this.capturable&&!n?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}const n=[],{left:i,top:r,width:s,height:o}=this.bounds;for(let e=0;e<t.length;e++){const a=this.fromParent(t[e].x,t[e].y);if(a.x<i||a.x>i+s||a.y<r||a.y>r+o)return!1;a.x-=i,a.y-=r,n.push(a)}const a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){const i=a[t];if(!i.isContainer())continue;const r=i.capturePath(n,e);if(r)return r}return this.focusible&&this}render(t){"popup"!==this.position&&super.render(t)}postrender(t){if("popup"===this.position)return void super.postrender(t);const e=this.layout.drawables(this);if(e.length>0){let{left:n=0,top:i=0,width:r,height:s}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(n,i,r,s),t.clip(),t.closePath()),t.translate(n,i),e.forEach(e=>{const n=this.root?.transitionEffect;n?.isReparenting(e)||e.draw(this.position&&"static"!==this.position?t:this.getContext(e))}),t.translate(-n,-i),t.restore()}super.postrender(t)}trim(){this.components.forEach(t=>{t.trim()}),super.trim()}}["layout"].forEach(t=>Ec.memoize(Wg.prototype,t,!1));const Ug={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){const i=n[e];n[e]={...i||{},x:t.x,y:t.y}})},ondragend:function(t,e,n){}},Xg={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class qg extends Og{get pathExtendable(){return!0}get cornerEditable(){return!0}get path(){const{from:t,to:e}=this.state,{path:n}=this.state;return[this.fromEnd?.position||t?.position||n[0],...n.slice(1,-1),this.toEnd?.position||e?.position||n[n.length-1]]}set path(t){const{from:e,to:n}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...n,position:t[t.length-1]},path:t})}get controls(){const t=this.path,e=[];for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];0==n&&e.push({x:i.x,y:i.y,handler:Ug}),e.push({x:(i.x+r.x)/2,y:(i.y+r.y)/2,handler:Ug}),n==t.length-2&&e.push({x:r.x,y:r.y,handler:Ug})}return e}get nature(){return Xg}}Ec.register("polyline",qg);const $g={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class Kg extends Og{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:n,direction:i,boundaryPosition:r=t}=this.fromEnd||{},{component:s,direction:o,boundaryPosition:a=e}=this.toEnd||{},c=[r,a],l=[];r&&l.push(r);let h,d=n?.bounds;d&&(h=n.toScene(d.left,d.top),h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y});const u=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:r.x,top:r.y,width:0,height:0};d=d||u;let p=s?.bounds;p&&(h=s.toScene(p.left,p.top),h=this.transcoordT2P(h.x,h.y),p={...p,left:h.x,top:h.y});const f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:a.x,top:a.y,width:0,height:0};p=p||f;const g=[u,f],m=u.left>f.left?f.left:u.left,y=u.top>f.top?f.top:u.top,b={left:m,top:y,width:u.left+u.width>f.left+f.width?u.left+u.width-m:f.left+f.width-m,height:u.top+u.height>f.top+f.height?u.top+u.height-y:f.top+f.height-y};let _,v,x,w,S,M,k,A,E,C,T=0,P=0;d.left+d.width<p.left?(w=0,S=1,E=i,C=o,_=(d.left+d.width+p.left)/2,T=p.left-_):p.left+p.width<d.left&&(w=1,S=0,E=o,C=i,_=(d.left+p.width+p.left)/2,T=d.left-_),d.top+d.height<p.top?(x=0,M=1,k=i,A=o,v=(d.top+d.height+p.top)/2,P=p.top-v):p.top+p.height<d.top&&(x=1,M=0,k=o,A=i,v=(d.top+p.height+p.top)/2,P=d.top-v);const O=[];if(_&&T>P){let t,e,n;switch(C){case Tg:switch(E){case Cg:O.push({x:_,y:c[w].y}),O.push({x:_,y:c[S].y});break;case Tg:t=g[w].top+g[w].height/2,e=t>c[S].y?Math.min(g[w].top,c[S].y):Math.max(g[w].top+g[w].height,c[S].y),O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:c[S].y});break;case Ag:case Eg:e=E===Eg?Math.max(c[w].y,c[S].y):Math.min(c[w].y,c[S].y),O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:c[S].y});break;default:return this.path}break;case Cg:switch(E){case Cg:e=c[w].y<c[S].y?Math.min(g[S].top,c[w].y):Math.max(g[S].top+g[S].height,c[w].y),n=e;break;case Tg:e=void 0!==v?v:c[w].y<c[S].y?b.top-.5*T:b.top+b.height+.5*T,n=e;break;case Eg:e=void 0!==v?Math.max(v,c[w].y):b.top+b.height,n=e;break;case Ag:e=v?Math.min(v,g[w].top):b.top,n=e;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;case Eg:switch(E){case Cg:e=c[w].y,n=c[w].y>c[S].y?c[w].y:g[S].top+g[S].height;break;case Tg:e=v?Math.max(v,g[S].top+g[S].height):b.top+b.height,n=e;break;case Eg:e=b.top+b.height,n=e;break;case Ag:e=v?Math.min(v,g[w].top):g[w].top,n=v?Math.max(v,g[S].top+g[S].height):g[S].top+g[S].height;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;case Ag:switch(E){case Cg:e=c[w].y,n=c[w].y<c[S].y?c[w].y:g[S].top;break;case Tg:e=v?Math.min(v,g[S].top):b.top,n=e;break;case Eg:e=void 0!==v?Math.max(v,c[w].y):c[w].y,n=void 0!==v?Math.min(v,c[S].y):c[S].y;break;case Ag:e=b.top,n=e;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;default:return this.path}l.push(...0===w?O:O.reverse())}else if(v){let t,e,n;switch(A){case Ag:switch(k){case Eg:O.push({x:c[x].x,y:v}),O.push({x:c[M].x,y:v});break;case Ag:t=g[x].left+g[x].width/2,e=t>c[M].x?Math.min(g[x].left,c[M].x):Math.max(g[x].left+g[x].width,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;case Tg:e=Math.min(c[x].x,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;case Cg:e=Math.max(c[x].x,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;default:return this.path}break;case Eg:switch(k){case Tg:e=b.left,n=e;break;case Cg:e=void 0!==_?Math.max(_,c[x].x):b.left+b.width,n=e;break;case Ag:e=void 0!==_?_:c[x].x<c[M].x?b.left-.5*P:b.left+b.width+.5*P,n=e;break;case Eg:e=c[x].x,n=c[x].x<c[M].x?Math.min(g[M].left,c[x].x):Math.max(g[M].left+g[M].width,c[x].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;case Cg:switch(k){case Tg:e=void 0!==_?Math.min(_,c[x].x):c[x].x,n=void 0!==_?Math.max(_,c[M].x):c[M].x;break;case Cg:e=b.left+b.width,n=e;break;case Ag:e=void 0!==_?Math.max(_,c[M].x):b.left+b.width,n=e;break;case Eg:e=c[x].x,n=Math.max(g[M].left+g[M].width,c[x].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;case Tg:switch(k){case Tg:e=b.left,n=e;break;case Cg:e=void 0!==_?Math.max(_,c[x].x):c[x].x,n=void 0!==_?Math.min(_,c[M].x):c[M].x;break;case Ag:e=b.left,n=e;break;case Eg:e=c[x].x<c[M].x?Math.min(g[M].left,c[x].x):c[x].x,n=Math.min(e,c[M].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;default:return this.path}l.push(...0===x?O:O.reverse())}else{let t,e;switch(i){case Ag:switch(o){case Ag:e=b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Eg:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top+b.height}),l.push({x:c[1].x,y:b.top+b.height});break;case Cg:t=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;case Tg:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case Eg:switch(o){case Ag:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top}),l.push({x:c[1].x,y:b.top});break;case Eg:case Cg:case Tg:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;case Tg:switch(o){case Ag:t=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:b.left,e=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(b.top,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case Eg:t=b.left,e=Math.max(b.top+b.height,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case Cg:t=b.left+b.width,l.push({x:c[0].x,y:b.top}),l.push({x:t,y:b.top}),l.push({x:t,y:c[1].y});break;case Tg:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case Cg:switch(o){case Ag:e=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Eg:e=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Cg:case Tg:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;default:return this.path}}return a&&l.push(a),[t,...l,e].filter((t,e,n)=>{if(0===e)return!0;const i=n[e-1];return t.x!==i.x||t.y!==i.y}).filter((t,e,n)=>{if(0===e||e>=n.length-1)return!0;const i=n[e-1],r=n[e+1];return!(t.x===i.x&&t.x===r.x||t.y===i.y&&t.y===r.y)})}get nature(){return $g}}Ec.register("ortholine",Kg);const Qg={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class Zg extends(Pc(Cc)){static get noimage(){return Zg.NOIMAGE||(Zg.NOIMAGE=new Image,Zg.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Zg.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){const{left:e,top:n,width:i,height:r,isGray:s=!1,alpha:o=1,src:a}=this.state;if(this.prepareIf(!this._image&&a),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(s&&this._offcanvas)t.drawImage(this._offcanvas,e,n,i,r);else try{t.drawImage(this._image,e,n,i,r)}catch(s){t.drawImage(Zg.noimage,e,n,i,r)}else!this.app.isViewMode&&t.drawImage(Zg.noimage,e,n,i,r)}get nature(){return Qg}get hasTextProperty(){return!1}async ready(){await super.ready();const{src:t}=this.state;if(!this._image&&t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((t,e)=>{this.prepare(()=>t(),t=>e(t))});e.track(`image:${t}`,"image",t,n)}else this.prepareIf(!0)}}prepare(t,e){const{src:n,crossOrigin:i}=this.state;if(n){this._image=new Image;try{i&&(this._image.crossOrigin=i),this._image.src=this.app.url(n)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){const t=this._image.width,e=this._image.height;this._offcanvas=Ec.createCanvas(t,e);const n=this._offcanvas.getContext("2d");n.drawImage(this._image,0,0);const i=function(t,e,n){let i;try{i=t.getImageData(0,0,e,n)}catch(t){return Qi("Get Image Data Error: "+(t instanceof Error?t.message:String(t))),null}const r=i.data;for(let t=0;t<e*n*4;t+=4){const e=r[t],n=r[t+1],s=r[t+2],o=Math.floor((e+n+s)/3);i.data[t]=o,i.data[t+1]=o,i.data[t+2]=o}return i}(n,t,e);n.putImageData(i,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void(this.src=e[n])}}Ec.register("image-view",Zg);class Jg extends(ug(Pc(Ec))){is3dish(){return!0}prerender(){}}var tm,em,nm={},im={},rm={};function sm(){if(em)return im;em=1,Object.defineProperty(im,"__esModule",{value:!0});var t=function(){if(tm)return rm;tm=1,Object.defineProperty(rm,"__esModule",{value:!0});var t=function(){function t(){}return t.bitsToNum=function(t){return t.reduce(function(t,e){return 2*t+e},0)},t.byteToBitArr=function(t){for(var e=[],n=7;n>=0;n--)e.push(!!(t&1<<n));return e},t.lzwDecode=function(t,e){for(var n,i,r=0,s=function(t){for(var n=0,i=0;i<t;i++)e.charCodeAt(r>>3)&1<<(7&r)&&(n|=1<<i),r++;return n},o=[],a=1<<t,c=a+1,l=t+1,h=[],d=function(){h=[],l=t+1;for(var e=0;e<a;e++)h[e]=[e];h[a]=[],h[c]=null};;)if(i=n,(n=s(l))!==a){if(n===c)break;if(n<h.length)i!==a&&h.push(h[i].concat(h[n][0]));else{if(n!==h.length)throw new Error("Invalid LZW code.");h.push(h[i].concat(h[i][0]))}o.push.apply(o,h[n]),h.length===1<<l&&l<12&&l++}else d();return o},t}();return rm.SuperGifUtils=t,rm}(),e=function(){function e(t,e){this.stream=t,this.handler=e}return e.prototype.parseCT=function(t){for(var e=[],n=0;n<t;n++)e.push(this.stream.readBytes(3));return e},e.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},e.prototype.parseHeader=function(){var e={};if(e.sig=this.stream.read(3),e.ver=this.stream.read(3),"GIF"!==e.sig)throw new Error("Not a GIF file.");e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.gctFlag=n.shift(),e.colorRes=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.sorted=n.shift(),e.gctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.bgColor=this.stream.readByte(),e.pixelAspectRatio=this.stream.readByte(),e.gctFlag&&(e.gct=this.parseCT(1<<e.gctSize+1)),this.handler.hdr&&this.handler.hdr(e)},e.prototype.parseExt=function(e){var n=this;switch(e.label=this.stream.readByte(),e.label){case 249:e.extType="gce",function(e){n.stream.readByte();var i=t.SuperGifUtils.byteToBitArr(n.stream.readByte());e.reserved=i.splice(0,3),e.disposalMethod=t.SuperGifUtils.bitsToNum(i.splice(0,3)),e.userInput=i.shift(),e.transparencyGiven=i.shift(),e.delayTime=n.stream.readUnsigned(),e.transparencyIndex=n.stream.readByte(),e.terminator=n.stream.readByte(),n.handler.gce&&n.handler.gce(e)}(e);break;case 254:e.extType="com",function(t){t.comment=n.readSubBlocks(),n.handler.com&&n.handler.com(t)}(e);break;case 1:e.extType="pte",function(t){n.stream.readByte(),t.ptHeader=n.stream.readBytes(12),t.ptData=n.readSubBlocks(),n.handler.pte&&n.handler.pte(t)}(e);break;case 255:e.extType="app",function(t){n.stream.readByte(),t.identifier=n.stream.read(8),t.authCode=n.stream.read(3),"NETSCAPE"===t.identifier?function(t){n.stream.readByte(),t.unknown=n.stream.readByte(),t.iterations=n.stream.readUnsigned(),t.terminator=n.stream.readByte(),n.handler.app&&n.handler.app.NETSCAPE&&n.handler.app.NETSCAPE(t)}(t):function(t){t.appData=n.readSubBlocks(),n.handler.app&&n.handler.app[t.identifier]&&n.handler.app[t.identifier](t)}(t)}(e);break;default:e.extType="unknown",function(t){t.data=n.readSubBlocks(),n.handler.unknown&&n.handler.unknown(t)}(e)}},e.prototype.parseImg=function(e){e.leftPos=this.stream.readUnsigned(),e.topPos=this.stream.readUnsigned(),e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.lctFlag&&(e.lct=this.parseCT(1<<e.lctSize+1)),e.lzwMinCodeSize=this.stream.readByte();var i=this.readSubBlocks();e.pixels=t.SuperGifUtils.lzwDecode(e.lzwMinCodeSize,i),e.interlaced&&(e.pixels=function(t,e){for(var n=new Array(t.length),i=t.length/e,r=function(i,r){var s=t.slice(r*e,(r+1)*e);n.splice.apply(n,[i*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,c=0;c<4;c++)for(var l=s[c];l<i;l+=o[c])r(l,a),a++;return n}(e.pixels,e.width)),this.handler.img&&this.handler.img(e)},e.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},e.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},e}();return im.SuperGifParser=e,im}var om,am,cm={};var lm=function(){if(am)return nm;am=1,Object.defineProperty(nm,"__esModule",{value:!0});var t=sm(),e=function(){if(om)return cm;om=1,Object.defineProperty(cm,"__esModule",{value:!0});var t=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],n=0;n<t;n++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",n=0;n<t;n++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();return cm.SuperGifStream=t,cm}(),n=function(){function n(t,e){var n=this;for(var i in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){n.pushFrame(),n.canvas.width=n.hdr.width*n.getCanvasScale(),n.canvas.height=n.hdr.height*n.getCanvasScale(),n.playerInit(),n.loading=!1,n.ready=!0,n.loadCallback&&n.loadCallback(n.gifImgElement)}},e)this.options[i]=e[i];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return n.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},n.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},n.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},n.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},n.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},n.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},n.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},n.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},n.prototype.parseStream=function(e){try{new t.SuperGifParser(e,this.handler).parse()}catch(t){this.handleError("parse")}},n.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},n.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},n.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},n.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},n.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},n.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},n.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var n=this.frames.length,i=t.lctFlag?t.lct:this.hdr.gct;n>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=n-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var r=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach(function(t,n){t!==e.transparency&&(r.data[4*n+0]=i[t][0],r.data[4*n+1]=i[t][1],r.data[4*n+2]=i[t][2],r.data[4*n+3]=255)}),this.frame.putImageData(r,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},n.prototype.doNothing=function(){},n.prototype.withProgress=function(t){return function(e){t(e)}},n.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},n.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},n.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},n.prototype.play=function(){this.playing=!0,this.step()},n.prototype.pause=function(){this.playing=!1},n.prototype.isPlaying=function(){return this.playing},n.prototype.getCanvas=function(){return this.canvas},n.prototype.isLoading=function(){return this.loading},n.prototype.isReady=function(){return this.ready},n.prototype.isAutoPlay=function(){return this.options.autoPlay},n.prototype.getLength=function(){return this.frames.length},n.prototype.getCurrentFrame=function(){return this.currentFrameIndex},n.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},n.prototype.loadURL=function(t,n){var i=this;if(this.loadSetup(n)){var r=new XMLHttpRequest;r.open("GET",t,!0),"overrideMimeType"in r?r.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in r?r.responseType="arraybuffer":r.setRequestHeader("Accept-Charset","x-user-defined"),r.onloadstart=function(){i.initialized||i.init()},r.onload=function(){if(200===r.status){var t=r.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var n=new e.SuperGifStream(t);setTimeout(function(){i.parseStream(n)},0)}else i.handleError("xhr - response")},r.onerror=function(){i.handleError("xhr")},r.send()}},n.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},n}();return nm.SuperGif=n,nm}();const hm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class dm extends Jg{async oncreate_element(t){const{src:e,play:n}=this.state;this.onchangesrc(e),this.onchangeplay(n)}buildImg(){const t=this.element;if(!t)return document.createElement("img");t.replaceChildren();const e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){const e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){const e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",String(0)),this._superGif=new lm.SuperGif(e,{autoPlay:!1}),this._superGif.init(),this.element&&Array.from(this.element.children).forEach(t=>{t.style.width="100%",t.style.height="100%"});const n=this._superGif.getCanvas();n.style.width="100%",n.style.height="100%",this._superGif.load(()=>{setTimeout(()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()},100)})}ondropfile(t,e){for(let n=0;n<t.length;n++)if(/\.gif$/.test(t[n].name))return void(this.src=e[n])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return hm}get tagName(){return"div"}}Ec.register("gif-view",dm);const um={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class pm extends(Pc(Cc)){static get image(){return pm.IMAGE||(pm.IMAGE=new Image,pm.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),pm.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}async ready(){super.ready(),this._audio=new Audio;const{src:t="",loop:e=!1,started:n=!1}=this.state;if(t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((e,n)=>{this._audio.addEventListener("canplay",()=>e(),{once:!0}),this._audio.addEventListener("error",()=>n(new Error(`Audio load failed: ${t}`)),{once:!0})});e.track(`audio:${t}`,"audio",t,n)}}this._audio.addEventListener("canplay",()=>{this.started&&this._audio.play()}),this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(n)}render(t){const{left:e,top:n,width:i,height:r}=this.state;t.beginPath(),this.drawImage(t,pm.image,e,n,i,r)}get nature(){return um}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void Qi(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("audio/"))return void(this.src=e[n])}}Ec.register("audio",pm);class fm extends(Pc(Ec)){is3dish(){return!0}}Ec.register("text",fm);const gm=["refid","left","top","width","height","rotation","animation","zPos"];class mm extends yg{isGroup(){return!0}is3dish(){return!0}get showMoveHandle(){return!1}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=gm.reduce((e,n)=>(t.hasOwnProperty(n)&&(e[n]=t[n]),e),{});return super.set(n,void 0)}capture(t,e,n){const i=super.capture(t,e,n);if(i!==this)return i}set bounds(t){if(this.__MUTATING__)return void(super.bounds=t);const e=this.bounds,n=t.width/e.width,i=t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i})),this.components&&this.components.forEach(t=>{if(t.mutable)t.mutatePath(null,function(t){return t.map(function(t){return{x:t.x*n,y:t.y*i}})});else{const e=t.bounds,r=t.center,s={x:r.x*(1-n),y:r.y*(1-i)},o=e.width*(1-n),a=e.height*(1-i),c=-(s.x-o/2),l=-(s.y-a/2);t.bounds={left:e.left+c,top:e.top+l,width:e.width*n,height:e.height*i}}})}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds(function(t){const e=Ec.union(this.components.map(t=>t.bounds));return this.components.forEach(t=>{const n=t.bounds;t.bounds={left:n.left-e.left,top:n.top-e.top,width:n.width,height:n.height}}),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}},this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds?.()}render(t){}postrender(t){const{top:e,left:n}=this.state;t.translate(n,e),this.layout.drawables(this).forEach(e=>{e.draw(t)}),t.translate(-n,-e)}}Ec.memoize(mm.prototype,"bounds",!0),Ec.register("group",mm);const ym={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class bm extends(Pc(Cc)){get ref(){const t=this.getState("ref");return t&&"string"==typeof t?this.root.findById?.(t):null}set ref(t){this.setState("ref",t)}get refScale(){const t=this.ref;if(!t)return{x:1,y:1};const e=t.bounds,n=this.bounds,i=n.width/e.width,r=n.height/e.height;return"both"===this.model.fit?{x:i,y:r}:{x:Math.min(i,r),y:Math.min(i,r)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){const e=this.ref.center,n=this.center,i=this.refScale;t.translate(n.x,n.y),t.scale(i.x,i.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r)}get nature(){return ym}get hasTextProperty(){return!1}}Ec.memoize(bm.prototype,"ref",!1),Ec.memoize(bm.prototype,"refScale",!1),Ec.register("local-ref",bm);class _m extends(ug(ql)){render(t){}is3dish(){return!0}get layout(){return Lc.get(this.get("layout"))||jc}}const vm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class xm extends _m{dispose(){this._releaseRef(),super.dispose()}get nature(){return vm}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){const{mode:e="view",round:n=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=n+"px"}async ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();const t=this._element_bounds,{offsetWidth:e,offsetHeight:n}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:n},(!t||t.offsetWidth!=e||t.offsetHeight!=n)&&this.ref&&this.root.target_element){const{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();const{ref:t,fit:e="ratio"}=this.state;if(!t)return;const n=this.app.refProvider;if(n&&t){const i=(async()=>{this.__ref=await n.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data})();this.root?.app?.loadTracker?.track(`ref:${t}`,"ref-board",t,i);try{await i}catch(t){Qi(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,n){super.onchange(t,e),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame(()=>{const{fit:t}=this.state;this.ref.fit(t)}),"data"in t&&this.ref&&requestAnimationFrame(()=>{this.ref.data=t.data})}}Ec.register("global-ref",xm);const wm="center-middle",Sm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"popup-position",name:"popupPosition",property:{options:["static","absolute"]}},{type:"select",label:"popup-origin",name:"origin",property:{options:["left-top","center-top","right-top","left-middle",wm,"right-middle","left-bottom","center-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"},{type:"string",label:"container-ref",name:"containerRef",placeholder:"PopupContainer id (same board)"},{type:"textarea",label:"html-template",name:"htmlTemplate",property:{language:"html"}},{type:"string",label:"anchor-ref",name:"anchorRef",placeholder:"component id (3D-tracked anchor)"},{type:"select",label:"anchor-pin",name:"anchorPin",property:{options:[{display:"Top",value:"top"},{display:"Center",value:"center"},{display:"Bottom",value:"bottom"}]}},{type:"number",label:"anchor-offset-x",name:"anchorOffsetX"},{type:"number",label:"anchor-offset-y",name:"anchorOffsetY"},{type:"number",label:"anchor-offset-z",name:"anchorOffsetZ"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup"};class Mm extends(Pc(Cc)){static get image(){return Mm._image||(Mm._image=new Image,Mm._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),Mm._image}async ready(){await super.ready(),this.show&&this.onchangeShow(!0)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,Mm.image,e,n,i,r)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){if(this.app.isEditMode)return;(this.getState("board")||this.getState("containerRef")||this.getState("htmlTemplate"))&&(t?this.openPopup(this.value):this.hidePopup())}openPopup(t,e){if(this.app.isEditMode)return;const n=this.getState("anchorRef"),i=n&&this.rootModel?.findById?this.rootModel.findById(n):void 0;Bu.show(this,this.getState("board"),{origin:this.getState("origin")||wm,modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,popupPosition:this.getState("popupPosition"),title:this.text,data:t||this.value,containerRef:this.getState("containerRef"),htmlTemplate:this.getState("htmlTemplate"),anchor:i,anchorPin:this.getState("anchorPin")||"top",anchorOffsetX:this.getState("anchorOffsetX")??0,anchorOffsetY:this.getState("anchorOffsetY")??0,anchorOffsetZ:this.getState("anchorOffsetZ")??0,constantSize:this.getState("constantSize")??!0,tether:this.getState("tether")??!1,offScreen:this.getState("offScreen")||"hide",...e})}hidePopup(){Bu.hide(this)}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return Sm}}Ec.register("popup",Mm);const km={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"billboard",name:"billboard"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup-container"};class Am extends yg{get nature(){return km}isPopupContainer(){return!0}}Ec.register("popup-container",Am);class Em extends Ec{render(t){const{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),this.drawStroke(t,void 0)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}}Ec.register("path",Em);const Cm={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class Tm extends Cc{is3dish(){return!0}contains(t,e){const{x1:n,y1:i,x2:r,y2:s,x3:o,y3:a}=this.state,c=[n,i,r,s,o,a];let l=!1;for(let n=0;n<c.length;n+=2){const i=(n+2)%c.length,r=c[n],s=c[n+1],o=c[i+1];s>e!=o>e&&t<(c[i]-r)*(e-s)/(o-s)+r&&(l=!l)}return l}get mutable(){return!0}get path(){const{x1:t,y1:e,x2:n,y2:i,x3:r,y3:s}=this.state;return[{x:t,y:e},{x:n,y:i},{x:r,y:s}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return Cm}}Ec.memoize(Tm.prototype,"path",!1),Ec.register("triangle",Tm);const Pm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"},Om={ondragmove:function(t,e,n){let{cx:i,rx:r}=n.model;r=Math.abs(r);let s=(n.fromParent(t.x,t.y).x-i)/r*100;s=s>=100||s<=-100?100:Math.abs(s),n.set({ratio:s})}};class Dm extends zg{is3dish(){return!0}render(t){let{ratio:e=50,cx:n,cy:i,rx:r,ry:s,startAngle:o,endAngle:a,anticlockwise:c}=this.state;r=Math.abs(r),s=Math.abs(s),t.beginPath(),t.ellipse(n,i,r,s,0,o||0,a||2*Math.PI,c),t.moveTo(n+r/100*e,i),t.ellipse(n,i,r/100*e,s/100*e,0,o||0,a||2*Math.PI,!0)}contains(t,e){let{cx:n,cy:i,rx:r,ry:s,ratio:o}=this.state;r=Math.abs(r),s=Math.abs(s);const a=(t-n)/(2*r-.5),c=(e-i)/(2*s-.5),l=(t-n)/(r/100*o*2-.5),h=(e-i)/(s/100*o*2-.5);let d=!1;return a*a+c*c<.25&&l*l+h*h>.25&&(d=!d),d}get controls(){let{cx:t,cy:e,rx:n,ratio:i}=this.state;return n=Math.abs(n),[{x:t+n/100*i,y:e,handler:Om}]}get nature(){return Pm}}Ec.memoize(Dm.prototype,"controls",!1),Ec.register("donut",Dm);const zm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"},Im={ondragmove:function(t,e,n){const{cy:i,ry:r}=n.model;let s=(n.fromParent(t.x,t.y).y-i)/r*100+100;s>=100?s=100:s<=0&&(s=0),n.set({ratio:s})}};class Rm extends zg{is3dish(){return!0}render(t){const{ratio:e=30,wing:n=5,cx:i,cy:r,rx:s,ry:o}=this.state;if(n<3)return;const a=1.5707963267948966,c=2*Math.PI/n,l=s-e/100*s,h=o-e/100*o;t.save(),t.beginPath(),t.translate(i,r),t.moveTo(s*Math.cos(-a),o*Math.sin(-a)),t.lineTo((s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let e=1;e<n;e++)t.lineTo(s*Math.cos(c*e-a),o*Math.sin(c*e-a)),t.lineTo((s-l)*(Math.cos(c*(e+1)-a)+Math.cos(c*e-a))/2,(o-h)*(Math.sin(c*(e+1)-a)+Math.sin(c*e-a))/2);t.closePath(),t.restore()}get controls(){const{cx:t,cy:e,ry:n,ratio:i}=this.state;return[{x:t,y:e-n+n*(i/100),handler:Im}]}get nature(){return zm}}Ec.memoize(Rm.prototype,"controls",!1),Ec.register("star",Rm);const Lm={mutable:!1,resizable:!1,rotatable:!1,properties:[]};class jm extends(bf(Cc)){is3dish(){return!1}isDescendible(){return!1}render(t){const{cx:e,cy:n,anticlockwise:i}=this.state,r=this.app?.scale||1;t.beginPath(),t.scale(1/r,1/r),t.ellipse(e,n,Math.abs(jm.RADIUS),Math.abs(jm.RADIUS),0,0,2*Math.PI,i),t.scale(r,r),t.closePath()}get path(){const{cx:t,cy:e}=this.state;return[{x:t-jm.RADIUS,y:e-jm.RADIUS},{x:t+jm.RADIUS,y:e-jm.RADIUS},{x:t+jm.RADIUS,y:e+jm.RADIUS},{x:t-jm.RADIUS,y:e+jm.RADIUS}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i}=this.state,r=(t-n)/(2*jm.RADIUS-.5),s=(e-i)/(2*jm.RADIUS-.5);return r*r+s*s<.25}outline(t){const{cx:e,cy:n}=this.state;return this.toScene(e,n)}get nature(){return Lm}}jm.RADIUS=5,Ec.memoize(jm.prototype,"path",!1),Ec.register("node",jm);class Fm extends Zd{getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds,i=this.component.state.depth||.5*Math.min(t,n),r=.15*Math.min(t,n,i),s=new R(1,1,1,4,r/Math.min(t,n,i));s.scale(t,i,n),this.object3d.geometry=s,this.object3d.material=new e.MeshStandardMaterial({color:"#5090d0",transparent:!0,opacity:.35,roughness:.6,metalness:.1,side:e.FrontSide,depthWrite:!1}),this.object3d.visible=!!this.component.app?.isEditMode}updateAlpha(){const t=this.object3d.material;t&&(t.opacity=this.component.app?.isEditMode?.35:0)}updateHidden(){this.object3d.visible=!!this.component.app?.isEditMode&&!this.component.state.hidden}updateDimension(){const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e);this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}updateFillStyle(){}updateStrokeStyle(){}updateText(){}clear(){return Hd(this.object3d),super.clear()}}const Nm="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="#5090d0">\n <path d="M32 20a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm0 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12z"/>\n <path d="M55.4 27.2l-3.6-.6c-.4-1.2-.8-2.4-1.4-3.4l2.2-3c.6-.8.4-2-.2-2.6l-3-3c-.8-.6-1.8-.8-2.6-.2l-3 2.2c-1.2-.6-2.2-1-3.4-1.4l-.6-3.6c-.2-1-1-1.6-2-1.6h-4.2c-1 0-1.8.6-2 1.6l-.6 3.6c-1.2.4-2.4.8-3.4 1.4l-3-2.2c-.8-.6-2-.4-2.6.2l-3 3c-.6.8-.8 1.8-.2 2.6l2.2 3c-.6 1.2-1 2.2-1.4 3.4l-3.6.6c-1 .2-1.6 1-1.6 2v4.2c0 1 .6 1.8 1.6 2l3.6.6c.4 1.2.8 2.4 1.4 3.4l-2.2 3c-.6.8-.4 2 .2 2.6l3 3c.8.6 1.8.8 2.6.2l3-2.2c1.2.6 2.2 1 3.4 1.4l.6 3.6c.2 1 1 1.6 2 1.6h4.2c1 0 1.8-.6 2-1.6l.6-3.6c1.2-.4 2.4-.8 3.4-1.4l3 2.2c.8.6 2 .4 2.6-.2l3-3c.6-.8.8-1.8.2-2.6l-2.2-3c.6-1.2 1-2.2 1.4-3.4l3.6-.6c1-.2 1.6-1 1.6-2v-4.2c0-1-.6-1.8-1.6-2z"/>\n</svg>');class Hm extends(Pc(Ec)){static get icon(){return Hm._defaultIcon||(Hm._defaultIcon=new Image,Hm._defaultIcon.src=Nm),Hm._defaultIcon}get serviceName(){}get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new Fm(this)}render(t){if(this.app?.isViewMode)return;const{left:e,top:n,width:i,height:r}=this.bounds,s=this.constructor.icon;t.beginPath(),t.globalAlpha=.6,this.drawImage(t,s,e,n,i,r),t.globalAlpha=1}added(t){super.added(t);const e=this.serviceName;e&&(this._registeredRoot=this.root,this._registeredRoot?.registerService?.(e,this))}removed(t){const e=this.serviceName;e&&this._registeredRoot&&(this._registeredRoot.unregisterService?.(e),this._registeredRoot=void 0),super.removed(t)}get controls(){return[]}}function Bm(t){return class extends t{animOnValueChange(t,e=!1,n){if(t==this._lastValue)return;if(this.root?.app?.suppressAnimations)return this._lastValue=t,this._anim_alpha=0,void this.invalidate();let i;i=e?t-(Number(n)||0):t-(this._lastValue||0),this._lastValue=t,this._anim_alpha=-i,this.animate({step:t=>{this._anim_alpha=i*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=Ws(this.getState("value"),this,void 0)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(xi(t)))}}}function Ym(t){return class extends t{_convertDataFormat(t,e){let n;if("json"===e)n=JSON.parse(t);else n=t;return n}isDataSource(){return!0}}}function Vm(t){var e;return(e=class extends t{is3dish(){return!0}get hasTextProperty(){return!1}get capturable(){return!1}render(t){}}).raycastTargetDefault=!1,e}const Gm="$base_url",Wm=[{type:"gltf-preset",label:"preset",name:"preset"},{type:"gltf-selector",label:"url",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:Gm,defaultStorage:"3d-model",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0,category:"application"},observe:function(t){const e=this.parentNode?.querySelector("[name=gltfInfo]");e&&(e.src=t);const n=this.parentNode?.querySelector("[name=fillStyleTargets]");n&&(n.src=t);const i=this.parentNode?.querySelector("[name=playTargets]");i&&(i.src=t)}},{type:"gltf-info",label:"",name:"gltfInfo",readonly:!0,property:{action:(t,e)=>{t._ratioLocking=!0;try{t.set(e)}finally{t._ratioLocking=!1}}},editor:{fullwidth:!0}},{type:"gltf-fill-targets",label:"fill-targets",name:"fillStyleTargets",editor:{fullwidth:!0}},{type:"gltf-play-targets",label:"play-targets",name:"playTargets",editor:{fullwidth:!0}}];function Um(t){return class extends t{constructor(){super(...arguments),this._snapshotLoading=!1,this._ratioLocking=!1}is3dish(){return!0}get hasTextProperty(){return!1}get controls(){return[]}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath();const s=this._topViewSnapshot;if(s)return void t.drawImage(s,e,n,i,r);this._ensureTopViewSnapshot(),t.rect(e,n,i,r),t.fillStyle="#f0f0f0",t.fill(),t.strokeStyle="#999",t.lineWidth=1,t.stroke();const o=this.getState("src"),a=o&&o.split("/").pop()?.replace(/\.[^.]+$/,"")||"GLTF",c=Math.max(10,.12*Math.min(i,r));t.fillStyle="#666",t.font=`${c}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,n+r/2,.9*i)}onchange(t,e){super.onchange?.(t,e),"src"in t&&(this._topViewSnapshot=void 0)}_ensureTopViewSnapshot(){if(this._snapshotLoading)return;const t=this.getState("src");if(!t)return;const e=iu.getTopViewCache(t);if(e)return this._topViewSnapshot=e,void this.invalidate();this._snapshotLoading=!0;const n=this.app.url(t);iu.loadGLTF(n).then(e=>{if(this._snapshotLoading=!1,this.getState("src")!==t)return;const n=iu.getTopViewCache(t);if(n)return this._topViewSnapshot=n,void this.invalidate();const i=iu.renderTopView(e.scene);iu.setTopViewCache(t,i),this._topViewSnapshot=i,this.invalidate()}).catch(()=>{this._snapshotLoading=!1})}buildRealObject(){return new iu(this)}get source(){return this.getState("src")}set source(t){this.setState("src",t)}get play(){return!1!==this.getState("play")}set play(t){this.setState("play",t)}get nodes(){return this.getState("nodes")}set nodes(t){this.setState("nodes",t)}get animations(){return this.getState("animations")}set animations(t){this.setState("animations",t)}get playTargets(){return this.getState("playTargets")}set playTargets(t){this.setState("playTargets",t)}get fillStyleTargets(){return this.getState("fillStyleTargets")}set fillStyleTargets(t){this.setState("fillStyleTargets",t)}get nodeNames(){const t=this.realObject;return t?.nodeNames??[]}get animationNames(){const t=this.realObject;return t?.animationNames??[]}set dimension(t){const{width:e=1,height:n=1,depth:i=1}=t;this.setState({width:e,height:n,depth:i}),this.realObject?.updateDimension()}_applyRatioLock(t){if(!("width"in t||"height"in t||"depth"in t))return t;const e=this.state.width||1,n=this.state.height||1,i=this.state.depth||1,r=Wp([(t.width??e)/e,(t.height??n)/n,(t.depth??i)/i]);return r?{...t,width:Math.round(e*r),height:Math.round(n*r),depth:Math.round(i*r)}:t}set(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.set(t)}finally{this._ratioLocking=!1}}setState(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.setState(t)}finally{this._ratioLocking=!1}}}}function Xm(t){return function(e){return Array.isArray(t)?t.forEach(t=>{Ec.register(t,e)}):Ec.register(t,e),e}}function qm(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function $m(t){if(qm(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class Km{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function Qm(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),i=e.onAvailable(()=>t.resumeEmit());return $m(e).isFull&&t.pauseEmit(),()=>{n?.(),i?.()}}class Zm{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,i){const r=e.maxCount??1/0;if(t<0||t>=r)return null;const s=this.owner?.state?.width??0,o=this.owner?.state?.height??0,a=i?.state?.width??0,c=i?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(o-c)/2),z:0}:{x:Math.max(0,(s-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Jm(t,e,n,i,r,s,o){const a=n.w,c=n.h,l=i.w,h=i.h,d=i.d,u=[],p=l+r,f=h+r,g=Math.max(1,Math.floor((a+r)/p)),m=Math.max(1,Math.floor((c+r)/f)),y=g*m,b=s&&s>0?Math.floor(s):4;if("row"===t||"column"===t){const n=o?.advanceAlongX??!1,i=o?.reverse??!1,r=n?g:m,s=n?m:g,l=(t,e,i)=>((t,e,n)=>u.push({x:-a/2+(t+.5)*p,y:n*d+d/2,z:-c/2+(e+.5)*f}))(n?t:e,n?e:t,i);let h=0;for(let n=0;n<r&&h<e;n++){const o=i?r-1-n:n;if("column"===t)for(let t=0;t<s&&h<e;t++)for(let n=0;n<b&&h<e;n++)l(o,t,n),h++;else for(let t=0;t<b&&h<e;t++)for(let n=0;n<s&&h<e;n++)l(o,n,t),h++}return u}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,g-n),i=Math.max(1,m-n),r=e*i,o=Math.min(t,r);for(let t=0;t<o;t++){const r=t%e,s=Math.floor(t/e),o=-a/2+(r+(g-e)/2+.5)*p,l=-c/2+(s+(m-i)/2+.5)*f;u.push({x:o,y:n*d+d/2,z:l})}if(t-=o,n++,1===e&&1===i){for(let e=0;e<t;e++)u.push({x:0,y:(n+e)*d+d/2,z:0});break}if(s&&n>=s)break}return u}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/y),i=n%y,r=i%g,o=Math.floor(i/g),m=(t(2*n)-.5)*l*.2,b=(t(2*n+1)-.5)*h*.2,_=-a/2+(r+.5)*p+m,v=-c/2+(o+.5)*f+b;if(u.push({x:_,y:e*d+d/2,z:v}),s&&e>=s-1&&i===y-1)break}return u}for(let n=0;n<e;n++){const e=Math.floor(n/y);if(s&&e>=s)break;const i=n%y,r=i%g,o=Math.floor(i/g);let l=-a/2+(r+.5)*p;const h=-c/2+(o+.5)*f;"staggered"===t&&e%2==1&&(l+=p/2),u.push({x:l,y:e*d+d/2,z:h})}return u}class ty{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,i={}){const r=i.gap??this.defaults.gap??0,s=i.heightLimit??this.defaults.heightLimit,o=i.fill??this.defaults.fill;return Jm(this.pattern,t,e,n,r,s,o).map(t=>({position:t}))}}class ey{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,i={}){const r=Math.max(1,this.cols),s=Math.max(1,this.rows),o=r*s,a=i.gap??this.defaults.gap??0,c=n.w+a,l=n.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/o),i=e%o,a=i%r,d=Math.floor(i/r);h.push({position:{x:(a-(r-1)/2)*c,z:(d-(s-1)/2)*l,y:t*n.d+n.d/2}})}return h}}class ny{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,i=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-i)/(e.h+i))),pitchX:e.w+n,pitchZ:e.h+i}}capacity(t,e,n){const{cols:i,rows:r}=this.grid(t,e);return i*r*Math.max(1,Math.floor(n))}layout(t,e,n,i={}){const{cols:r,rows:s,pitchX:o,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,l=null!=i.heightLimit?Math.max(1,Math.floor(i.heightLimit)):1/0,h=Number.isFinite(l),d=this.sliceFirst&&h,u=r*s,p=r*(h?l:1),f=r*s*(h?l:t),g=Math.min(t,f),m=[];for(let t=0;t<g;t++){let e,i,l;if(d){const n=Math.floor(t/p),s=t%p;e=s%r,l=Math.floor(s/r),i=n}else{l=Math.floor(t/u);const n=t%u;e=n%r,i=Math.floor(n/r)}this.fillFromFar&&(i=s-1-i),m.push({position:{x:(e-(r-1)/2)*o,z:(i-(s-1)/2)*a,y:l*c+n.d/2}})}return m}}function iy(t,e,n,i=0){for(let r=0;r<e.length;r++){const s=e[r],o=n[r];s&&o&&(s.parent!==t&&t.attach(s),s.position.set(o.position.x,i+o.position.y,o.position.z),o.rotation?s.quaternion.set(o.rotation.x,o.rotation.y,o.rotation.z,o.rotation.w):s.quaternion.identity())}}function ry(t,e,n,i=.12){const r=e.left+e.width/2,s=e.top+e.height/2,o=Math.min(n.w,n.h)*i,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let i=a.get(t);i||(i={x:r+e.position.x-n.w/2+o,y:s+e.position.z-n.h/2+o,w:n.w-2*o,h:n.h-2*o,count:0},a.set(t,i)),i.count++}return[...a.values()]}function sy(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}const oy=new e.Euler;function ay(t,n){oy.setFromQuaternion(new e.Quaternion(n.x,n.y,n.z,n.w),"YXZ"),t.rotationX=oy.x,t.rotation=-oy.y,t.rotationY=oy.z}const cy="_transferSlotId",ly=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function hy(t){return class extends t{async ready(){await(super.ready?.());const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=t[cy];null!=e&&n.set(String(e),t)}for(const[t,i]of n)if(!e.has(t)){try{this.removeItem(i,!0)}catch{}try{i?.dispose?.()}catch{}}for(const[t,i]of e){if(n.has(t))continue;if(null==i.itemId)continue;const e=this._createItemFromRecord(i);if(e){e[cy]=t;try{this.handoverIn(e)}catch{}}}for(const[t,i]of e){const e=n.get(t);if(e&&(i.itemState&&"function"==typeof e.setState))try{e.setState(i.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,i=[];for(const t of this._items){const e=t[cy];null!=e?n.set(String(e),t):i.push(t)}for(const i of t){const t=n.get(i)??null;e.push(this._slotRecordOf(i,t))}for(const t of i)e.push(this._slotRecordOf("",t));for(const[i,r]of n)t.includes(i)||e.push(this._slotRecordOf(i,r));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const i of n)i in e&&void 0!==e[i]&&(t[i]=e[i]);return Object.keys(t).length>0?t:void 0}const i={};for(const t of Object.keys(e))ly.has(t)||t.startsWith("_")||(i[t]=e[t]);return Object.keys(i).length>0?i:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=Ec.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}class dy{positionAt(t,e,n){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const uy=new dy,py=[{id:"__default__",maxCount:1/0}];function fy(t){var n;return n=class extends t{get slots(){return[]}get arrangementStrategy(){return uy}canReceive(t,e){const n=null!==this.findSlot(t);return fu.log({role:"target",contract:"canReceive",component:this,args:{carrier:sy(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:py;for(const n of e){if(n.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!n.allowedTypes.includes(e))continue}const e=n.maxCount??this.arrangementStrategy.capacity(n),i=this._countOccupied(n.id);if(!(i>=e))return fu.log({role:"target",contract:"findSlot",component:this,args:{carrier:sy(t)},result:{slotId:n.id,occupied:i,max:e}}),n}return fu.log({role:"target",contract:"findSlot",component:this,args:{carrier:sy(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const n=this.acceptanceRotation?.(t);if(!n)return;const i=this._realObject?.object3d;if(!i)return;i.updateWorldMatrix(!0,!1);const r=new e.Quaternion;i.getWorldQuaternion(r);const s=new e.Quaternion(n.x,n.y,n.z,n.w);return r.clone().multiply(s)}deliveryWorldPosition(t){const n=this._realObject,i=n?.object3d;if(!i)return;i.updateWorldMatrix(!0,!1);const r=new e.Vector3;i.getWorldPosition(r);const s=this._receivingSurfaceLocalY();if(null!==s){const t=new e.Vector3(0,s,0);return i.localToWorld(t),{x:r.x,y:t.y,z:r.z}}return{x:r.x,y:r.y,z:r.z}}attachPointFor(t){const e=t?.[cy];if(!e)return null;const n=this.slots.find(t=>t.id===e);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,i=n?n.state??{}:t??{},r={width:Number(i.width)||0,height:Number(i.height)||0,depth:Number(i.depth)||0},s=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!s)return null;const o=e.index??this._countOccupied(s.id),a=e.occupantCount??o,c=this.arrangementStrategy.positionAt(o,s,a,n??{state:{...r}});if(!c)return null;const l=Number(this.state?.width)||0,h=Number(this.state?.height)||0,d=c.x+r.width/2-l/2,u=c.y+r.height/2-h/2,p=this._realObject,f=p?.placementMode??"floor",g="space"===f?0:"inverted"===f?-r.depth/2:r.depth/2,m=this._receivingSurfaceLocalY();let y;y=null!==m?m+g:s.localPosition&&Number.isFinite(s.localPosition.z)?s.localPosition.z+g:g-(p?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??r,s)??void 0;return b?{position:{x:d,y:y,z:u},rotation:b}:{position:{x:d,y:y,z:u}}}_zPosFromSeatY(t,e,n){const i=this._realObject,r=i?.receivingSurfaceY??0,s=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===r&&!s)return null;const o=Number(e)||0,a=i?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-o/2:o/2)+(i?.geometricOffsetY??0)-r}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[cy]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[cy]===t).length:0}},n.__hasCapacity=!0,n}function gy(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return[];const o="number"==typeof t.rotation?t.rotation:0,a=Math.cos(o),c=Math.sin(o),l=n+r/2,h=i+s/2,d="inbound"===e?-1:1;return[{lx:-r/2,lz:0,odx:-1,odz:0},{lx:r/2,lz:0,odx:1,odz:0},{lx:0,lz:-s/2,odx:0,odz:-1},{lx:0,lz:s/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:l+e*a-n*c,z:h+e*c+n*a}),direction:{x:d*(t.odx*a-t.odz*c),z:d*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?s/2:r/2}})}function my(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return{inbounds:[],outbounds:[]};const o="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&r<s,l=n+r/2,h=i+s/2,d=c?s/2:r/2,u=c?0:1,p=c?1:0,f=Math.cos(o),g=Math.sin(o),m=(t,e)=>({x:l+t*f-e*g,z:h+t*g+e*f}),y=c?{lx:0,lz:-d}:{lx:-d,lz:0},b=c?{lx:0,lz:d}:{lx:d,lz:0},_=m(y.lx,y.lz),v=m(b.lx,b.lz),x={x:u*f-p*g,z:u*g+p*f},w=Math.hypot(x.x,x.z)||1,S={x:x.x/w,z:x.z/w},M={x:-S.x,z:-S.z},k=(c?r:s)/2;return a?{inbounds:[{worldPos:v,direction:M,halfSpan:k}],outbounds:[{worldPos:_,direction:M,halfSpan:k}]}:{inbounds:[{worldPos:_,direction:S,halfSpan:k}],outbounds:[{worldPos:v,direction:S,halfSpan:k}]}}function yy(t){const e=t.left??0,n=t.top??0,i=t.width??0,r=t.height??0;if(i<=0||r<=0)return null;const s="number"==typeof t.rotation?t.rotation:0,o="vertical"===t.orientation||"horizontal"!==t.orientation&&i<r,a=e+i/2,c=n+r/2,l=o?r/2:i/2,h=Math.cos(s),d=Math.sin(s),u=(t,e)=>({x:a+t*h-e*d,z:c+t*d+e*h});return{start:o?u(0,-l):u(-l,0),end:o?u(0,l):u(l,0)}}function by(t){const e=t.cx??0,n=t.cy??0,i=Math.abs(t.rx??100),r=Math.abs(t.ry??100),s=t.ratio??50,o=(i+i*s/100)/2,a=(r+r*s/100)/2,c=t.startAngle??0,l=t.endAngle??Math.PI/2,h="reverse"===t.status;if(i<=0||r<=0)return{inbounds:[],outbounds:[]};const d={x:e+o*Math.sin(c),z:n-a*Math.cos(c)},u={x:e+o*Math.sin(l),z:n-a*Math.cos(l)},p={x:Math.cos(c),z:Math.sin(c)},f={x:Math.cos(l),z:Math.sin(l)};return h?{inbounds:[{worldPos:u,direction:{x:-f.x,z:-f.z}}],outbounds:[{worldPos:d,direction:{x:-p.x,z:-p.z}}]}:{inbounds:[{worldPos:d,direction:p}],outbounds:[{worldPos:u,direction:f}]}}function _y(t){const e=my(t),n=e.outbounds[0];if(!n)return{inbounds:gy(t,"inbound"),outbounds:[]};const i=gy(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,i=t.worldPos.z-n.worldPos.z;return Math.hypot(e,i)>1}),r=n.direction,s=[];for(const t of i){const e=t.direction.x*r.x+t.direction.z*r.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+r.x,i=t.direction.z+r.z,o=Math.hypot(n,i)||1;s.push({worldPos:t.worldPos,direction:{x:n/o,z:i/o},halfSpan:t.halfSpan})}return{inbounds:[...i,...s],outbounds:e.outbounds}}function vy(t,e,n={}){const i=n.distance??5,r=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<r)return!1;const s=t.worldPos.x-e.worldPos.x,o=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,r=t.direction.z;if(Math.abs(s*n+o*r)>i)return!1;const a=Math.abs(s*-r+o*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(s,o)<=i}function xy(t,e,n,i=0){const r=n.width??0,s=n.height??0;if(r<=0||s<=0)return!1;const o=(n.left??0)+r/2,a=(n.top??0)+s/2,c="number"==typeof n.rotation?n.rotation:0,l=Math.cos(-c),h=Math.sin(-c),d=t-o,u=e-a,p=d*l-u*h,f=d*h+u*l;return Math.abs(p)<=r/2+i&&Math.abs(f)<=s/2+i}function wy(t,e,n){const i=n.width??0,r=n.height??0;if(i<=0||r<=0)return 1/0;const s=(n.left??0)+i/2,o=(n.top??0)+r/2;let a=t.x-s,c=t.z-o,l=e.x,h=e.z;const d="number"==typeof n.rotation?n.rotation:0;if(0!==d){const t=Math.cos(-d),e=Math.sin(-d),n=a*e+c*t,i=l*e+h*t;a=a*t-c*e,c=n,l=l*t-h*e,h=i}const u=i/2,p=r/2;let f=-1/0,g=1/0;if(Math.abs(l)<1e-9){if(a<-u||a>u)return 1/0}else{const t=(-u-a)/l,e=(u-a)/l;f=Math.max(f,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-p||c>p)return 1/0}else{const t=(-p-c)/h,e=(p-c)/h;f=Math.max(f,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<f?1/0:f>=0?f:g>=0?Math.min(-f,g):-g}function Sy(t,e,n,i=6){return!!xy(t.worldPos.x,t.worldPos.z,e,i)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function My(t,e,n){return t.outbounds.map(t=>{const i=[];for(const r of e){let e=null;for(const i of r.topology.inbounds){if(!vy(t,i,n))continue;const r=t.worldPos.x-i.worldPos.x,s=t.worldPos.z-i.worldPos.z,o=Math.hypot(r,s);(null===e||o<e)&&(e=o)}if(null===e&&r.bounds){const i=r.topology.outbounds[0]?.direction,s=!(r.topology.outbounds&&r.topology.outbounds.length)?n?.sinkMargin??30:6;if(Sy(t,r.bounds,i,s)){const n=wy(t.worldPos,t.direction,r.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(r.bounds.left??0)+(r.bounds.width??0)/2,i=(r.bounds.top??0)+(r.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-i)+1e3}}}null!==e&&i.push({id:r.id,dist:e})}return 0===i.length?null:(i.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),i[0].id)})}function ky(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const i=new Map,r=new Set;for(const n of t){const s=t.filter(t=>t.id!==n.id),o=My(n.topology,s,e);i.set(n.id,o);for(const t of o)null!=t&&r.add(t)}const s=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const s=i.get(t)??[];s.includes(e)||(s.push(e),i.set(t,s),r.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])s(e.id,t);for(const t of e.links.upstream??[])s(t,e.id)}const o=new Set,a=new Set;for(const e of t){(i.get(e.id)??[]).some(t=>null!=t)||o.add(e.id),r.has(e.id)||a.add(e.id)}return{nodes:n,out:i,sinks:o,sources:a}}function Ay(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const i=new Set([e]);for(const r of function(t,e,n){const i=n.get(e);if(i)return i;const r=new Set,s=[e],o=new Set([e]);for(;s.length;){const e=s.shift();for(const n of t.out.get(e)??[])null!=n&&(r.add(n),o.has(n)||(o.add(n),s.push(n)))}return n.set(e,r),r}(t,e,n))i.add(r);return i})}function Ey(t,e,n,i){return e===n?0:function(t,e,n){const i=n.get(e);if(i)return i;const r=new Map([[e,0]]),s=[e];for(;s.length;){const e=s.shift(),n=r.get(e);for(const i of t.out.get(e)??[])null==i||r.has(i)||(r.set(i,n+1),s.push(i))}return n.set(e,r),r}(t,e,i).get(n)??1/0}function Cy(t,e,n){const i=t.out.get(e)??[],r=new Map,s=[];for(let e=0;e<i.length;e++){const o=i[e];if(null==o)continue;const a=o===n?0:Ey(t,o,n,r);a!==1/0&&s.push({i:e,hops:1+a})}return s.sort((t,e)=>t.hops-e.hops||t.i-e.i),s.map(t=>t.i)}function Ty(t,e,n){const i=Cy(t,e,n);return i.length?i[0]:-1}function Py(t,e,n){return e===n||Cy(t,e,n).length>0}function Oy(t,e){const n=new Set;for(const i of Ay(t,e))for(const e of i)t.sinks.has(e)&&n.add(e);return n}function Dy(t,e,n){return zy(t,e,n).map(t=>t.index)}function zy(t,e,n){const i=n instanceof Set?n:new Set(n);if(0===i.size)return[];const r=t.out.get(e)??[],s=new Map,o=[...i].sort(),a=[];for(let e=0;e<r.length;e++){const n=r[e];if(null==n)continue;let i=1/0,c="";for(const e of o){const r=1+(n===e?0:Ey(t,n,e,s));r<i&&(i=r,c=e)}i!==1/0&&a.push({index:e,hops:i,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Iy(t,e={}){const n=[],i=e.loopCapableIds??new Set,r=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const i=t.nodes.get(e);if(!i||!i.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(r.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const s=function(t){const e=[],n=[...t.nodes.keys()].sort(),i=new Set,r=[],s=new Set,o=n=>{i.add(n),r.push(n),s.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(s.has(a)){const t=r.indexOf(a),n=r.slice(t),i=n.indexOf([...n].sort()[0]),s=[...n.slice(i),...n.slice(0,i)],o=s.join("→");e.some(t=>t.join("→")===o)||e.push(s)}else i.has(a)||o(a);r.pop(),s.delete(n)};for(const t of n)i.has(t)||o(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of s){t.some(t=>i.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const o=e.routingWeights;if(o)for(const[t,e]of[...o].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...r].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Ry(t,e){if(!t)return[];const n=[],i=new Set,r=t=>{if(!t||i.has(t))return;if(i.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,i=t.refid??t.state?.refid,r="string"==typeof e&&e.length>0?e:null!=i?String(i):void 0;if(r)try{const e=t.getSegmentTopology(),i=t.state??{},s={left:i.left,top:i.top,width:i.width,height:i.height,rotation:i.rotation};e&&n.push({id:r,topology:e,bounds:s})}catch{}}const s=t?.components;if(Array.isArray(s))for(const t of s)r(t)};return r(t),n}function Ly(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const i=t.getSegmentTopology();if(!i||0===i.outbounds.length)return null;const r=My(i,Ry(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of r)if(t)return t;return null}function jy(t){return!!t&&"function"==typeof t.routingConstraints}function Fy(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Ny(t,e=16){const n=[],i=t.parent??t.rootModel??t.root;if(!i)return n;const r=Ly(t);if(!r)return n;const s=Yy(i,r);if(!s)return n;const o=[{segment:s,accumulated:{},pathIds:[r],visited:new Set([r])}];for(;o.length>0;){const t=o.shift();if(t.pathIds.length>e)continue;const r=jy(t.segment)?t.segment.routingConstraints():null;if(r&&r.length>0)for(const e of r)for(const r of e.candidates){const s=Hy(t.accumulated,r);if(!s)continue;const a=By(t.segment,e.portId,i);a&&!t.visited.has(a.state?.id??"")?o.push({segment:a,accumulated:s,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:s,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Fy(t.segment)){const e=t.segment.acceptedCarrierData(),i=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:i});else for(const r of e){const e=Hy(t.accumulated,r);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:i})}continue}const e=Ly(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const r=Yy(i,e);if(!r)continue;o.push({segment:r,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function Hy(t,e){const n={...t};for(const[t,i]of Object.entries(e)){if(t in n&&n[t]!==i)return null;n[t]=i}return n}function By(t,e,n){if("straight"===e&&t.state?.downstreamRef)return Yy(n,t.state.downstreamRef);const i=Yy(n,e);if(i)return i;const r=Ly(t);return r?Yy(n,r):null}function Yy(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,i=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const r=t.components;if(Array.isArray(r))for(const t of r){const e=i(t);if(e)return e}return null};return i(t)}function Vy(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function Gy(t,e,n=5,i=[],r=n){const s=t.length,o=new Array(s).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,l=[],h=new Map,d=[],u=new Map;for(const t of i){const e=Array.isArray(t),n=e?t:t.positions,i=e?void 0:t.kind;if(!n.length)continue;const r=l.length;l.push({pos:n[0],members:[]});for(const t of n)d.push({pos:t,pt:r});i&&u.set(r,i)}const p=(t,e)=>{const i=c(t,e),r=h.get(`${t}:${"end"===e?"start":"end"}`),s=[];for(const t of d)Vy(t.pos,i)<=n&&!s.includes(t.pt)&&s.push(t.pt);for(let t=0;t<l.length;t++)Vy(l[t].pos,i)<=n&&!s.includes(t)&&s.push(t);let o=s.find(t=>t!==r)??-1;o<0&&(o=l.length,l.push({pos:i,members:[]})),l[o].members.push({seg:t,end:e}),h.set(`${t}:${e}`,o)};for(let t=0;t<s;t++)p(t,"start"),p(t,"end");const f=new Set,g=new Set,m=new Set;{const t=t=>{let e=-1,n=1/0;for(let i=0;i<l.length;i++){const r=Vy(l[i].pos,t);r<n&&(n=r,e=i)}for(const i of d){const r=Vy(i.pos,t);r<n&&(n=r,e=i.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:i}=t(n.pos);e>=0&&i<=r&&(f.add(e),("source"===n.kind?g:m).add(e))}}for(const[t,e]of u)f.add(t),("source"===e?g:m).add(t);const y=(t,e)=>"end"===e!==o[t],b=[],_=(e,n)=>{if(void 0===o[e])return o[e]=n,void b.push(e);o[e]!==n&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const n=h.get(`${t}:${e}`);if(void 0===n)continue;const i=l[n];if(2!==i.members.length||f.has(n))continue;const r=i.members[0],s=r.seg===t&&r.end===e?i.members[1]:r;if(s.seg===t)continue;const a="end"===e!==o[t],c="end"===s.end!==!a;_(s.seg,c)}},x=()=>{for(;b.length;)v(b.shift())},w=t=>{let e=-1,n="start",i=1/0;for(let r=0;r<s;r++)for(const s of["start","end"]){const o=Vy(c(r,s),t.pos);o<i&&(i=o,e=r,n=s)}if(e<0||i>r)return;const o="source"===t.kind?"end"===n:"start"===n;_(e,o)};for(const t of e)"source"===t.kind&&w(t);x();for(const t of e)"sink"===t.kind&&w(t);x();let S=!0;for(;S;){S=!1;for(const t of l){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===o[t.seg]);if(1!==e.length)continue;let n=0,i=0;for(const e of t.members)void 0!==o[e.seg]&&(y(e.seg,e.end)?n++:i++);const r=e[0];let s;0===i&&n>0?s="end"===r.end:0===n&&i>0&&(s="start"===r.end),void 0!==s&&(o[r.seg]=s,b.push(r.seg),x(),S=!0)}}if(o.some(t=>void 0===t)&&g.size>0&&m.size>0){const t=t=>{const e=new Array(l.length).fill(1/0),n=[];for(const i of t)e[i]=0,n.push(i);for(;n.length;){const t=n.shift();for(const i of l[t].members){const r=h.get(`${i.seg}:${"start"===i.end?"end":"start"}`);void 0!==r&&e[r]>e[t]+1&&(e[r]=e[t]+1,n.push(r))}}return e},e=t(g),n=t(m);for(let t=0;t<s;t++){if(void 0!==o[t])continue;const i=h.get(`${t}:start`),r=h.get(`${t}:end`);if(void 0===i||void 0===r)continue;if(l[i].members.length<2||l[r].members.length<2)continue;if(e[i]===1/0||e[r]===1/0||n[i]===1/0||n[r]===1/0)continue;let s;e[i]!==e[r]?s=e[i]<e[r]:n[i]!==n[r]&&(s=n[r]<n[i]),void 0!==s&&(o[t]=!s,b.push(t))}x()}const M=new Map;for(let e=0;e<s;e++)M.set(t[e].id,void 0===o[e]?"unknown":o[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function Wy(...t){}function Uy(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function Xy(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*qy(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*qy(t)}function $y(t,e,n){const i=e.width??0,r=e.height??0;if(i<=0||r<=0)return!1;const s=(e.left??0)+i/2,o=(e.top??0)+r/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-s,l=t.z-o,h=Math.cos(-a),d=Math.sin(-a),u=c*h-l*d,p=c*d+l*h;return Math.abs(u)<=i/2+n&&Math.abs(p)<=r/2+n}function Ky(t){const e=[],n=[],i=[],r=[];for(const s of qy(t)){const t=Xy(s);if(!t)continue;if(s.flowOrientable){const n=yy(s.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof s.openings){const t=s.state??{};(t.width??0)>0&&(t.height??0)>0&&r.push(t);continue}let o;try{o=s.getSegmentTopology()}catch{continue}if(!o)continue;const a=o.inbounds??[],c=o.outbounds??[],l="function"==typeof s.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||l))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&i.push({positions:t})}}for(const t of r){const r=[];for(const n of e)for(const e of[n.start,n.end])$y(e,t,16)&&r.push(e);let s=!1,o=!1;for(const e of n)$y(e.pos,t,16)&&("sink"===e.kind?s=!0:o=!0);const a=s&&!o?"sink":o&&!s?"source":void 0;(r.length>=2||a&&r.length>=1)&&i.push({positions:r,kind:a})}if(0===e.length||0===n.length)return new Map;return Gy(e,n,8,i,60).directions}function Qy(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:Ky(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const i=Xy(t),r=i?n.map.get(i):void 0;return"reverse"===r||"forward"!==r&&void 0}function Zy(t){return!!t&&"function"==typeof t.distanceToBoardPoint&&"function"==typeof t.routingLinks&&("function"==typeof t.registerDivertStation||"function"==typeof t.registerInductStation)}function Jy(t,e,n){if(!e)return null;const i=[],r=e=>{if(!e||e===n)return;if(Zy(e)){const n=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(e);if(n){const r=e.distanceToBoardPoint(t.x,t.y);i.push({id:n,component:e,distance:r})}}const s=e.components;if(Array.isArray(s))for(const t of s)r(t)};return r(e),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function tb(t){return!!t&&"function"==typeof t.routingDestination}function eb(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*nb(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*nb(t)}function ib(t){const e=[],n=new Map,i=new Map,r=new Set,s=[];for(const o of nb(t)){"function"==typeof o?.registerWithStationHost&&s.push(o);const t="function"==typeof o?.getSegmentTopology,a="function"==typeof o?.routingLinks?o.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||tb(o)||c||Zy(o)))continue;const l=eb(o);if(!l)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=o.getSegmentTopology()}catch{continue}if(!h)continue}const d=o.state??{},u={left:d.left,top:d.top,width:d.width,height:d.height,rotation:d.rotation};if(e.push({id:l,topology:h,bounds:u,links:a}),i.set(l,o),tb(o)){r.add(l);const t=o.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(l),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:i,routingTargetIds:r,stationClients:s}}function rb(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:i,components:r,routingTargetIds:s,stationClients:o}=ib(t),a=ky(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const i=[...e].sort((t,e)=>{const n=eb(t)??"",i=eb(e)??"";return n.localeCompare(i)});for(const e of i){const n=e.stationHostRef?.();let i=null;if(n&&(i=t.findById?.(n)??null),!i){const n=e.sorterFacingPoint?.()??e._sorterFacingPoint?.();n&&(i=Jy(n,t,e)?.component??null)}i&&"function"==typeof e.registerWithStationHost&&e.registerWithStationHost(i)}const r=e=>{if(!e)return;if(Zy(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const i=t.findById?.(n);i&&e.registerDivertStation(n,i)}const n=e.components;if(Array.isArray(n))for(const t of n)r(t)};r(t)}(t,o);const c=new Set;for(const[t,e]of r){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const l=new Map;for(const t of s){const e=r.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&l.set(t,n)}}const h=Iy(a,{routingTargetIds:s,loopCapableIds:c,routingWeights:l});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:i,components:r,issues:h},t.__flowGraph=e}return e}function sb(t){return rb(t)?.issues??[]}function ob(t){const e=rb(t);return e&&e.graph.nodes.size>0?e.graph:null}function ab(t,e){return rb(t)?.destToSinks.get(e)??[]}function cb(t,e){return rb(t)?.components.get(e)}function lb(t){const e=rb(t);return e?[...e.destToSinks.keys()]:[]}function hb(t){return eb(t)}function db(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function ub(t,e,n,i,r){if(1===i.length)return i[0];switch(t){case"index":default:return i[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),i[t%i.length]}case"weight":{const t=i.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(r.get(t.target))),s=t.reduce((t,e)=>t+e,0);if(s<=0)return i[0];const o=n.counters.get(e)??0;n.counters.set(e,o+1);let a=o%s;for(let e=0;e<i.length;e++){if(a<t[e])return i[e];a-=t[e]}return i[i.length-1]}case"utilization":{let t=1/0,e=i[0];for(const n of i){const i=db(r.get(n.target));i<t&&(t=i,e=n)}return e}}}function pb(t,e,n){const i=t?.root;if(!i)return null;const r=e?.state?.meta?.destination;if("string"!=typeof r||0===r.length)return null;const s=rb(i);if(!s||0===s.graph.nodes.size)return null;const o=eb(t);if(!o)return null;let a=s.destToSinks.get(r)??[];0===a.length&&(a=[r]);const c=zy(s.graph,o,a);if(0===c.length)return null;const l=s.graph.out.get(o)??[],h=c.filter(t=>{const n=l[t.index],i=n?s.components.get(n):null;return!i||"function"!=typeof i.canReceive||i.canReceive(e)});if(0===h.length)return l[c[0].index]??null;const d=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const i=e?.state?.routingBalancingPolicy;return i||"round-robin"}(t,i),u=ub(d,o,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(i),h,s.components);return l[u.index]??null}rg({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slots","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),rg({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,ob(t)}catch{return null}}}catch{}function fb(t,e,n){const i=pb(t,e,n);if(null==i)return null;const r=t?.root,s=cb(r,i)??r?.findById?.(i)??null;return s?{targetId:i,component:s,origin:"explicit"}:null}function gb(t){const e=t?.root,n=ob(e),i=hb(t);if(!n||!i)return null;const r=(n.out.get(i)??[]).find(Boolean);if(!r)return null;const s=cb(e,r)??e?.findById?.(r)??null;return s?{id:r,component:s}:null}function mb(t){const e=hb(t);return e?yb(t?.root,e):[]}function yb(t,e){if(!t||!e)return[];const n=ob(t);if(!n)return[];const i=new Set;for(const r of Oy(n,e)){const e=cb(t,r);if(tb(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&i.add(t)}}return[...i]}function bb(t,e){if(!t||!e)return[];const n=ob(t);if(!n)return[];const i=new Map;for(const t of n.out.values())for(const e of t)null!=e&&i.set(e,(i.get(e)??0)+1);const r=new Map;for(const s of Oy(n,e)){const e=cb(t,s);if(!tb(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let o=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(o=t)}null===o&&(o=i.get(s)??0,0===o&&(o=1)),r.set(n,(r.get(n)??0)+o)}return[...r].map(([t,e])=>({value:t,weight:e}))}function _b(t){return ob(t)}function vb(t){const e=ob(t);if(!e)return[];const n=new Set,i=new Set,r=t=>{if(!t)return;const s=hb(t);if(s&&e.nodes.has(s)){tb(t)&&n.add(s);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&i.add(s)}const o=t.components;if(Array.isArray(o))for(const t of o)r(t)};return r(t),Iy(e,{routingTargetIds:n,loopCapableIds:i})}function xb(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let i=0;for(const e of t)if(i+=e.weight,n<i)return e.value;return t[t.length-1].value}const wb={next:fb,downstream:gb,reachableDestinations:mb,reachableDestinationsFrom:yb,reachableDestinationsWeightedFrom:bb,pickWeightedDestination:xb,graphFor:_b,validate:vb};function Sb(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const i=t.prototype?.attachPointFor;return"function"==typeof i?i.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n&&(this._items.splice(n,1),t.parent=null,!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=t.parent;n&&("function"==typeof n.removeComponent&&-1!==n._components?.indexOf?.(t)&&n.removeComponent(t,!0),n!==this&&"function"==typeof n.removeItem&&-1!==n._items?.indexOf?.(t)&&n.removeItem(t,!0));const i=-1===this._items.indexOf(t);if(i&&this._items.push(t),t.parent=this,i&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}const r=t._realObject,s=r?.object3d;if(s){let n,i,o=e?.toParent3D,a="world-preserve";if(!o){const r=this.attachPointFor?.(t,{slotId:e?.slotId});r?.attach&&(o=r.attach,n=r.localPosition,i=r.localRotation,a=r.carryPolicy??"world-preserve")}o&&s.parent!==o&&(o.updateWorldMatrix?.(!0,!1),s.updateWorldMatrix?.(!0,!1),o.attach(s),r.suppressTransform=!0),o&&(n&&s.position.set(n.x,n.y,n.z),"world-preserve"!==a?i?s.rotation.set(i.x,i.y,i.z):s.quaternion.identity():i&&s.rotation.set(i.x,i.y,i.z),r?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}))}t.held?.(this),this._bumpReceived?.(t)}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)try{e.dispose?.()}catch{}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,i,r){for(let s=this._items.length-1;s>=0;s--){const o=this._items[s],a="static"===o.position?o.capture?.(t,e,r):o.capture?.(n,i,r);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const i=e.bounds;!e.showOverflow&&i&&(t.beginPath(),t.rect(i.left,i.top,i.width,i.height),t.clip(),t.closePath());const{left:r=0,top:s=0}=e.state??{};t.translate(r,s),this._drawItems(t),t.translate(-r,-s),t.restore()}capture(t,e,n){const i=this,r=this._items;if(r&&r.length>0&&(!i.app||i.app.isEditMode||!i.hidden)){const r=i.fromParent?.(t,e);if(r&&i.contains?.(r.x,r.y)){const s=i.bounds,o=this._captureItems(r.x-s.left,r.y-s.top,t,e,n);if(o)return o}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Mb(t){var n;const i=!!t.__hasCapacity,r=!!t.__hasTransferable,s=i?t:fy(t),o=r?s:function(t){var n;return(n=class extends t{reserve(t,e){const n=this.findSlot(t);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){fu.log({role:"target",contract:"receive:enter",component:this,args:{carrier:sy(t),options:e}});const n=this.reserve(t,e);if(!n){fu.log({role:"target",contract:"receive:reject",component:this,args:{carrier:sy(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,n,i={}){const r=t.slot,s=this._countOccupied(r.id),o=this.arrangementStrategy.positionAt(s,r,s,n);fu.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:s,slotId:r.id,occupantCount:s,carrier:sy(n)},result:o}),n[cy]=r.id;const a=n._realObject;let c,l;a?.object3d&&(a.object3d.updateWorldMatrix(!0,!1),c=new e.Vector3,l=new e.Quaternion,a.object3d.getWorldPosition(c),a.object3d.getWorldQuaternion(l));const{animated:h=!1,duration:d,ease:u}=i;"function"==typeof this.handoverIn?this.handoverIn(n,{slotId:r.id}):this.reparent?.(n,{animated:h,duration:d,ease:u}),!h&&n._realObject&&(n._realObject.suppressTransform=!1);{const t={},e=this.placementFor?.(n,{slot:r,index:s,occupantCount:s})??null;if(fu.log({role:"target",contract:"placementFor",component:this,args:{carrier:sy(n),slotId:r.id,index:s},result:e}),e){const i=n.state??{},s=this.state??{};t.left=e.position.x-(Number(i.width)||0)/2+(Number(s.width)||0)/2,t.top=e.position.z-(Number(i.height)||0)/2+(Number(s.height)||0)/2;const o=this._zPosFromSeatY(e.position.y,i.depth,r);null!==o&&(t.zPos=o),e.rotation&&ay(t,e.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=r.localPosition.z+e}const e=this.acceptanceRotation?.(n,r);fu.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:sy(n),slotId:r.id},result:e}),e&&ay(t,e)}const i=this.normalizePose?.(n,r);"function"==typeof this.normalizePose&&fu.log({role:"target",contract:"normalizePose",component:this,args:{carrier:sy(n),slotId:r.id},result:i}),i&&Object.assign(t,i),Object.keys(t).length&&(n.setState?.(t),fu.log({role:"target",contract:"receive:setState",component:this,args:{carrier:sy(n),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:n,container:this,slotId:r.id,preReceiveWorldPos:c,preReceiveWorldQuat:l}),fu.log({role:"target",contract:"receive:done",component:this,args:{carrier:sy(n),slotId:r.id}})}async dispatch(t,e,n={}){const i=new bu({source:this,target:e,carrier:t,options:n,physical:async()=>{delete t[cy]}}),r=await i.execute();"rolled-back"!==r.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:r.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const n=this.findSlot(t);if(!n){const n=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!n||t.allowedTypes.includes(n))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:n}})();return fu.log({role:"target",contract:"canAccept",component:this,args:{carrier:sy(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,n}(s),a=[...t.capabilities??[]];i||a.push("Capacity","PlacementSurface"),r||a.push("Transferable"),a.push("Holdable","FlowNode");var c,l,h;return hy((n=class extends(Sb(o)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},c=n,"symbol"==typeof(l="FlowNodeMixed")&&(l=l.description?"[".concat(l.description,"]"):""),Object.defineProperty(c,"name",{configurable:!0,value:h?"".concat(h," ",l):l}),n.capabilities=Object.freeze(a),n.isFlowNode=!0,n))}function kb(t){return!!t&&!0===t.isFlowNode}rg({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),rg({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),rg({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});const Ab={x:0,y:0,z:0,w:1};function Eb(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function Cb(t,e){const n=t.rotation,i=e.rotation,r=e.position,s=n.w*r.x+n.y*r.z-n.z*r.y,o=n.w*r.y+n.z*r.x-n.x*r.z,a=n.w*r.z+n.x*r.y-n.y*r.x,c=-n.x*r.x-n.y*r.y-n.z*r.z,l=s*n.w+c*-n.x+o*-n.z-a*-n.y,h=o*n.w+c*-n.y+a*-n.x-s*-n.z,d=a*n.w+c*-n.z+s*-n.y-o*-n.x,u={x:n.w*i.x+n.x*i.w+n.y*i.z-n.z*i.y,y:n.w*i.y-n.x*i.z+n.y*i.w+n.z*i.x,z:n.w*i.z+n.x*i.y-n.y*i.x+n.z*i.w,w:n.w*i.w-n.x*i.x-n.y*i.y-n.z*i.z};return{position:{x:t.position.x+l,y:t.position.y+h,z:t.position.z+d},rotation:u}}const Tb={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function Pb(t){const{carrierWorld:e,width:n,depth:i,entryHeight:r,mountLocalY:s,approachDistance:o,sides:a,toolType:c,tolerance:l,priority:h}=t,d="number"==typeof s?{position:{x:0,y:s,z:0},rotation:{...Ab}}:void 0,u=n/2,p=i/2;return a.map(t=>{const n=Tb[t],i="string"==typeof c?c:c[t]??"unknown",s={position:{x:n.axis.x*("east"===t||"west"===t?u:0),y:r,z:n.axis.z*("north"===t||"south"===t?p:0)},rotation:Eb(n.yaw)},a={position:{x:s.position.x+n.axis.x*o,y:r,z:s.position.z+n.axis.z*o},rotation:Eb(n.yaw)};return{id:`entry-${n.idSuffix}`,toolType:i,approach:Cb(e,a),engage:Cb(e,s),...d?{mount:d}:{},tolerance:l,priority:h}})}function Ob(t){const{carrierWorld:e,topY:n,approachDistance:i,toolType:r,mountLocalY:s,tolerance:o,priority:a,id:c}=t,l={position:{x:0,y:n,z:0},rotation:{...Ab}};return{id:c??"top",toolType:r,approach:Cb(e,{position:{x:0,y:n+i,z:0},rotation:{...Ab}}),engage:Cb(e,l),..."number"==typeof s?{mount:{position:{x:0,y:s,z:0},rotation:{...Ab}}}:{},tolerance:o,priority:a}}function Db(t,e){return t.filter(t=>t.toolType===e.toolType)}function zb(t,e){if(0===t.length)return null;const n=t.map(t=>{const n=t.approach.position.x-e.x,i=t.approach.position.y-e.y,r=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(n*n+i*i+r*r)}});return n.sort((t,e)=>{const n=t.f.priority??0,i=e.f.priority??0;return n!==i?n-i:t.dist-e.dist}),n[0].f}class Ib{constructor(t){this.owner=t}positionAt(t,e,n,i){if(0!==t)return null;const r=this.owner?.state?.width??0,s=this.owner?.state?.height??0,o=i?.state?.width??0,a=i?.state?.height??0;return{x:Math.max(0,(r-o)/2),y:Math.max(0,(s-a)/2),z:0}}capacity(t){return t.maxCount??1}}let Rb=1;function Lb(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const jb={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class Fb{constructor(t=jb){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+Rb++},n=(this._byResource.get(e.resource)??[]).filter(t=>Lb(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const i=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(i.every(t=>"b-yields"===t.decision)){const i=n.slice();for(const t of i)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:i,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:i}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:i}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>Lb(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let i=this._byReserver.get(t.reserverId);i||(i=[],this._byReserver.set(t.reserverId,i)),i.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const i=this._byReserver.get(t.reserverId);if(i){const e=i.findIndex(e=>e.id===t.id);e>=0&&i.splice(e,1),0===i.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const Nb=new Fb;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=Nb);class Hb{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const i of this.nodes.values()){const r=Bb(i.position,t);r<n&&(n=r,e=i)}return e}}function Bb(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}function Yb(t,e){return Math.sqrt(Bb(t,e))}function Vb(t,e,n={}){const i=new Hb,r=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,s=`${e.id}:end`;i.addNode({id:n,position:t[0],type:"lane-start"}),i.addNode({id:s,position:t[t.length-1],type:"lane-end"}),i.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:s});let o=0;for(let e=1;e<t.length;e++)o+=Yb(t[e-1],t[e]);const a=o/(e.speedLimit??r)*1e3;i.addEdge({fromNode:n,toNode:s,resource:e.id,distance:o,durationMs:a,forward:!0}),"twoway"===e.direction&&i.addEdge({fromNode:s,toNode:n,resource:e.id,distance:o,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const r=i.laneEndpoints.get(n);if(!r)continue;const s=i.nodes.get(r.startNodeId).position,o=i.nodes.get(r.endNodeId).position;let a=0,c=0,l=0;for(const e of t.lanes){if(e===n)continue;const t=i.laneEndpoints.get(e);if(!t)continue;const r=i.nodes.get(t.startNodeId).position,h=i.nodes.get(t.endNodeId).position;a+=Math.min(Bb(s,r),Bb(s,h)),c+=Math.min(Bb(o,r),Bb(o,h)),l++}if(0===l)continue;const h=a<c?r.startNodeId:r.endNodeId;e.push({laneId:n,nodeId:h,pos:i.nodes.get(h).position})}for(let n=0;n<e.length;n++)for(let r=0;r<e.length;r++){if(n===r)continue;const s=e[n],o=e[r],a=Yb(s.pos,o.pos);i.addEdge({fromNode:s.nodeId,toNode:o.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return i}function Gb(t,e,n,i={}){const r=t.nodes.get(e),s=t.nodes.get(n);if(!r||!s)return null;const o=i.speed?.max??100,a=e=>{const n=t.nodes.get(e);var i,r;return(i=n.position,r=s.position,Math.sqrt(function(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}(i,r)))/o*1e3},c=new Map,l=new Set,h=new Set,d={nodeId:e,gScore:0,fScore:a(e)};c.set(e,d),l.add(e);const u=i.startSimMs??0,p=i.deadlineSimMs;for(;l.size>0;){let e=null,i=null;for(const t of l){const n=c.get(t);(!i||n.fScore<i.fScore||n.fScore===i.fScore&&t<e)&&(i=n,e=t)}if(!i||!e)return null;if(e===n){const t=[];let e=i,n=0;for(;e&&e.cameFromEdge;){const i=e.cameFromEdge,r=u+(e.gScore-i.durationMs);t.unshift({resource:i.resource,timeWindow:{startSimMs:r,endSimMs:r+i.durationMs},fromPos:i.fromPos,toPos:i.toPos}),n+=i.distance,e=c.get(i.fromNodeId)}const r=i.gScore;return void 0!==p&&u+r>p?null:{segments:t,totalDurationMs:r,totalDistance:n}}l.delete(e),h.add(e);for(const n of t.edgesFrom(e)){if(h.has(n.toNode))continue;const e=i.gScore+n.durationMs,r=c.get(n.toNode);if(!r||e<r.gScore){const i=t.nodes.get(n.fromNode),r=t.nodes.get(n.toNode),s={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:i.position,toPos:r.position}};c.set(n.toNode,s),l.add(n.toNode)}}}return null}function Wb(t,e,n=0,i){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:i}))}const Ub={closed:!0,round:0,divisions:24};class Xb{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const i=t[e].x-t[e-1].x,r=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(i*i+r*r))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const i=this.cumulative;let r=0,s=i.length-2;for(;r<s;){const t=r+s>>1;i[t+1]<=n?r=t+1:s=t}const o=i[r+1]-i[r],a=o>0?(n-i[r])/o:0,c=this.points[r],l=this.points[r+1],h=l.x-c.x,d=l.y-c.y;return{x:c.x+h*a,y:c.y+d*a,theta:0===h&&0===d?0:Math.atan2(d,h)}}}function qb(t,e={}){const n={...Ub,...e},i=t.length;if(0===i)return new Xb([],n.closed);if(1===i)return new Xb([{x:t[0].x,y:t[0].y}],n.closed);const r=[],s=(t,e)=>{if(r.length>0){const n=r[r.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}r.push({x:t,y:e})},o=(n.closed,i);for(let e=0;e<o;e++){const r=0===e?n.closed?i-1:-1:e-1,o=e===i-1?n.closed?0:-1:e+1,a=r>=0?t[r]:null,c=t[e],l=o>=0?t[o]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&l?Js(c,n.round):0;let d,u,p,f;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(h,t/2);d=Math.sin(e)*n+c.x,u=Math.cos(e)*n+c.y}else d=c.x,u=c.y;if(l){const t=Math.sqrt((l.x-c.x)**2+(l.y-c.y)**2),e=0!==t?Math.atan2(l.x-c.x,l.y-c.y):0,n=Math.min(h,t/2);p=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else p=c.x,f=c.y;if(s(d,u),h>0&&a&&l)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,i=1-e;s(i*i*d+2*i*e*c.x+e*e*p,i*i*u+2*i*e*c.y+e*e*f)}else d===p&&u===f||s(p,f);if(l&&$s(c)){const t=Js(l,n.round),e=Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2),i=0!==e?Math.atan2(c.x-l.x,c.y-l.y):0,r=Math.min(t,e/2),o=Ks({x:p,y:f},{x:Math.sin(i)*r+l.x,y:Math.cos(i)*r+l.y},c.bulge);if(o){let t=o.endAngle-o.startAngle;if(o.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const i=e/n.divisions,r=o.startAngle+t*i;s(o.cx+o.radius*Math.cos(r),o.cy+o.radius*Math.sin(r))}}}}if(n.closed&&r.length>0){const t=r[0],e=r[r.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&r.push({x:t.x,y:t.y})}return new Xb(r,n.closed)}function $b(t,e){return qb(t,e).length}function Kb(t){return t?/forklift|agv|amr|oht|tugger|worker/i.test(t)?"mobile":/conveyor|sorter|induct|chute|belt/i.test(t)?"flow":/rack|shelf|stocker|cell/i.test(t)?"cell":/pallet|box|parcel|crate|drum|tray/i.test(t)?"atomic":/robot[-_]?arm|crane|lift/i.test(t)?"articulated":/spawn[-_]?point|sink[-_]?point/i.test(t)?"boundary":"":""}function Qb(t){const e=[];let n=t.parent;for(;n&&!n.isRootModel?.();){const t=n.state?.id??n.constructor?.name;t&&e.unshift(t),n=n.parent}return e.join(" › ")}function Zb(t,e=!0){const n=t.constructor?.name??t.state?.type??"Component",i={type:n,id:t.state?.id??`?${t._id??Math.random().toString(36).slice(2,7)}`,category:Kb(n),parentId:t.parent?.state?.id,parentPath:Qb(t)},r=t._realObject?.object3d;if(r){r.updateWorldMatrix?.(!0,!1);const t=r.matrixWorld?.elements;t&&(i.pose={position:{x:t[12],y:t[13],z:t[14]},rotation:{x:0,y:0,z:0,w:1}})}if(!0===t.isItem&&(i.isItem=!0),!0===t.isMover&&(i.isMover=!0),"function"!=typeof t.canReceive&&"function"!=typeof t.canAccept||(i.isHolder=!0),"function"==typeof t.pickupFrames)try{i.isPickable=t.pickupFrames().length>0}catch{i.isPickable=!1}if("string"==typeof t.toolType||"function"==typeof t.toolType?i.toolType="function"==typeof t.toolType?t.toolType():t.toolType:void 0!==t.toolType&&(i.toolType=String(t.toolType)),t.state&&"object"==typeof t.state){const e={};for(const[n,i]of Object.entries(t.state))"string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i&&null!==i||(e[n]=i);i.state=e}if(e){const e=t.components??[];i.childIds=e.map(t=>t.state?.id).filter(Boolean)}return i}function Jb(t){function e(t,n){if(!t)return;n.push(Zb(t));const i=t.components??[];for(const t of i)e(t,n)}function n(t,e){if(!e)return null;if(e.state?.id===t)return e;const i=e.components??[];for(const e of i){const i=n(t,e);if(i)return i}return null}return{version:"0.1.0",collectComponents(){const n=[];return e(t?.rootModel??t,n),n},getComponent(e){const i=n(e,t?.rootModel??t);if(!i)return null;const r={...Zb(i)};if("function"==typeof i.pickupFrames)try{r.pickupFrames=i.pickupFrames()}catch{}if("object"==typeof i.slots)try{r.slots=Array.isArray(i.slots)?i.slots:"function"==typeof i.slots?i.slots():[]}catch{}if("function"==typeof i.acceptanceRotation)try{r.acceptanceWorldQuat=i.deliveryWorldRotation?.(null)??void 0}catch{}if("function"==typeof i.deliveryWorldPosition)try{r.deliveryWorldPosition=i.deliveryWorldPosition(null)}catch{}return r},simStatus(){let e=0;const n=[t?.rootModel??t];for(;n.length>0;){const t=n.pop();if(!t)continue;!0===t.isItem&&e++;const i=t.components??[];for(const t of i)n.push(t)}return{simTime:zs.now,realTime:"undefined"!=typeof performance?performance.now():Date.now(),speed:zs.speed,paused:zs.isPaused,carrierCount:e}},transferLog(){const t={};_u.flows().forEach((e,n)=>{t[n]=e});const e={};_u.targetCounts().forEach((t,n)=>{e[n]=t});const n={};return _u.rejectReasonCounts().forEach((t,e)=>{n[e]=t}),{entries:_u.toJSON(),stats:_u.stats(),flows:t,targetCounts:e,rejectReasonCounts:n}},reservations(){const t=[...Nb.all()],e={},n={};for(const i of t)(e[i.resource]??=[]).push(i),(n[i.reserverId]??=[]).push(i);for(const t of Object.values(e))t.sort((t,e)=>t.timeWindow.startSimMs-e.timeWindow.startSimMs);for(const t of Object.values(n))t.sort((t,e)=>t.timeWindow.startSimMs-e.timeWindow.startSimMs);return{simTime:zs.now,all:t,byResource:e,byReserver:n}},conflicts(){const t=Nb.conflictLog(),e={},n={};let i=0,r=0;for(const s of t)e[s.resource]=(e[s.resource]??0)+1,n[s.proposed.reserverId]=(n[s.proposed.reserverId]??0)+1,"rejected"===s.outcome?i++:r++;return{simTime:zs.now,log:[...t],total:t.length,rejected:i,preempted:r,byResource:e,byReserver:n}}}}function t_(t){const e=Jb(t);return"undefined"!=typeof window&&(window.__SCENE_INSPECTOR__=e),e}let e_=0;const n_=new FinalizationRegistry(()=>{e_--});class i_{static get residents(){return e_}static get residentsCount(){return e_}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,e_++,n_.register(this,e_)}dispose(){if(this.disposer)for(const t in this.references)this.disposer(t,this.references[t]);this.references={},this.counters={}}get ids(){return Object.keys(this.references)}create(t){return new Promise((e,n)=>{this.creator?this.creator(t,n=>{n.release=()=>{this.disposer?.(t,n),delete n.release,Ji("RELEASED",t)},e(n)},n):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))})}add(t,e){const n=new Promise((n,i)=>{const r=this.references[t];if(r)r===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(r);else{const r=e=>{e.release=()=>{this.release(e)},this.references[t]=e,this.counters[t]=1,n(e)};if(e)r(e);else{if(!this.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));this.creator(t,r,i)}}});return this.references[t]||(this.references[t]=n),n}async get(t,e=!1){let n=this.references[t];if(n){if(!(n instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,n}if(e)return n=await n,this.counters[t]++,n}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(const e in this.references){if(this.references[e]===t)return e}}release(t){const e=this._id(t);if(!e)return void Qi("No Referenced ID");const n=this.references[e];n&&(this.counters[e]--,0==this.counters[e]&&(this.disposer?.(e,n),delete this.references[e],delete this.counters[e],delete t.release,Ji("RELEASED",e)))}}const r_={},s_={};let o_=[];function a_(t){const e=t.target,n="SCRIPT"===e.tagName?r_:s_,i=e.src||e.href;n[i]=!0,o_.forEach((t,e)=>{if(!t)return;const{resolve:r,scripts:s,styles:o}=t;if(n===r_){const t=s.indexOf(i);t>-1&&t<s.length-1&&l_(s[t+1])}s.some(t=>!r_[t])||o?.some(t=>!s_[t])||(r(),o_[e]=null)}),o_=o_.filter(Boolean)}function c_(t){if("string"==typeof t)return;const e=t.target,n=e.src,i="SCRIPT"===e.tagName?r_:s_;o_.forEach((e,r)=>{if(!e)return;const{reject:s,scripts:o,styles:a}=e;(i===r_&&o.includes(n)||i===s_&&!!a?.includes(n))&&(s(t),o_[r]=null)}),o_=o_.filter(Boolean),delete i[n],document.head.removeChild(e)}function l_(t){r_[t]=!1;const e=document.createElement("script");e.onload=a_,e.onerror=c_,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class h_{static load(t,e){const n="string"==typeof t?[t]:t,i="string"==typeof e?[e]:e;return new Promise(function(t,e){if(n&&!Array.isArray(n)||i&&!Array.isArray(i))return void e(new Error("invalid sources for load"));let r,s=!0;if(i?.forEach(t=>{t in s_||function(t){s_[t]=!1;const e=document.createElement("link");e.onload=a_,e.onerror=c_,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),s_[t]||(s=!1)}),n&&n.length>0)for(const t of n)t in r_?r_[t]||(s=!1):r??=t;if(r)l_(r);else if(s)return void t();o_.push({resolve:t,reject:e,scripts:n,styles:i})})}}const d_="0.0.0";function u_(t){if(!(t>0))return 1;let e=0;if(!(t&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function p_(t){const{lineWidth:n=0}=t.state;let{width:i,height:r}=t.bounds;i+=n,r+=n;const s=u_(2*i),o=u_(2*r),a=up(s,o),c=new e.CanvasTexture(a);return f_(a,t,2),c.needsUpdate=!0,c.wrapS=e.RepeatWrapping,c.wrapT=e.RepeatWrapping,c.offset.set(0,1-2*r/o),c.repeat.set(2*i/s,2*r/o),c.magFilter=e.NearestFilter,c.minFilter=e.LinearFilter,c.colorSpace=e.SRGBColorSpace,c}function f_(t,e,n){const{lineWidth:i=0}=e.state;let{left:r,top:s}=e.bounds;r-=i/2,s-=i/2;const o=t.getContext("2d");o.scale(n,n),o.translate(-r,-s),e.render(o),e.postrender(o)}function g_(t,e,n=2){const i=t.getContext("2d");i&&(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),f_(t,e,n))}const m_=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class y_ extends Zd{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds;if(!t||!n)return;const i=xd(this.component.state.material3d),r=new e.PlaneGeometry(1,1);r.rotateX(-Math.PI/2),this.object3d.geometry=r;const s=p_(this.component),o=new e.MeshStandardMaterial({map:s});Md(o,i),o.transparent=!0,this.object3d.material=o,this.object3d.castShadow=i.castShadow,this.object3d.receiveShadow=i.receiveShadow}updateDimension(){const{width:t,height:e}=this.component.bounds;this.object3d.scale.set(t,1,e)}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this._rebuildTexture()},100)}_rebuildTexture(){this.clear(),this.build(),this.updateTransform(),this.updateDimension(),this.updateHidden()}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(g_(n,this.component,2),e.needsUpdate=!0)}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!m_.has(e)){this._debouncedRebuild();break}}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),t.transparent=!0,this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hd(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}class b_ extends Zd{getObject3dInstance(){return new e.Mesh}build(){super.build(),this.buildGeometry(),this.buildMaterial()}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t,alpha:e=1}=this.component.state,n=this.object3d.material;if(!n)return;const i=Zd.buildFillStyleTexture(this.component);i?(n.map&&n.map.dispose(),i.needsUpdate=!0,n.map=i,n.needsUpdate=!0):"string"==typeof t&&(n.map&&(n.map.dispose(),n.map=null,n.needsUpdate=!0),"transparent"!==t&&"none"!==t&&n.color.set(zd(t))),Dd(n,e,t)}updateStrokeStyle(){const t=this.object3d.getObjectByName("__edgeLines__");t&&(this.object3d.remove(t),Hd(t));const{strokeStyle:n}=this.component.state;if(!n||"transparent"===n||"none"===n)return;const i=this.object3d.geometry;if(!i?.getAttribute("position"))return;const r=new e.EdgesGeometry(i),s=new e.LineBasicMaterial({color:n}),o=new e.LineSegments(r,s);o.name="__edgeLines__",this.object3d.add(o)}updateDimension(){const{width:t,height:e}=this.component.bounds,{depth:n=1}=this.component.state;if(!this.object3d)return;this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}buildMaterial(){const t=xd(this.component.state.material3d),n=new e.MeshStandardMaterial({transparent:!0});Md(n,t),this.object3d.material=n}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;t&&Md(t,xd(this.component.state.material3d))}clear(){return Hd(this.object3d),super.clear()}}function __(t,e,n,i){return[["bold",t],["italic",e],[n+"px",!0],[i,!0]].filter(t=>t[1]).map(t=>t[0]).join(" ")}function v_(t){let e=0;if(!((t=Math.abs(t)||1)&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function x_(t,e,n){const{bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",width:h=t.width,height:d=t.height,offsetX:u=0,offsetY:p=0}=n||{},f=t.getContext("2d");let g,m;f.imageSmoothingEnabled=!1,f.fillStyle=a,f.strokeStyle=a,f.font=__(i,r,o,s),"left"===c||"start"===c?(f.textAlign="left",g=u):"right"===c||"end"===c?(f.textAlign="right",g=u+h):(f.textAlign="center",g=u+h/2);const y=1.2*o,b=String(e).split("\n"),_=y*b.length;m="top"===l||"hanging"===l?p+.1*o:"bottom"===l||"alphabetic"===l?p+d-_+.1*o:p+(d-_)/2+.1*o,f.textBaseline="top";for(const t of b)f.fillText(t,g,m),m+=y}function w_(t,n,i,r){const s=v_(2*n),o=v_(2*i),a=up(s,o),c=a.getContext("2d"),{fillStyle:l}=r||{};if(l&&"object"==typeof l&&l.colorStops?.length){const t=Bd(l,2*n,2*i);t&&c.drawImage(t,0,0)}c.scale(2,2),"string"==typeof l&&""!==l&&"transparent"!==l&&(c.fillStyle=l,c.fillRect(0,0,n,i)),x_(a,t,r);const h=new e.CanvasTexture(a);return h.needsUpdate=!0,h.wrapS=e.RepeatWrapping,h.wrapT=e.RepeatWrapping,h.offset.set(0,1-2*i/o),h.repeat.set(2*n/s,2*i/o),h.minFilter=e.LinearFilter,h.colorSpace=e.SRGBColorSpace,h}function S_(t,n,i,r,s,o,a){const c=new Image;c.crossOrigin="anonymous",c.onload=()=>{const t=2*i,l=2*r,h=v_(t),d=v_(l),u=up(h,d),p=u.getContext("2d");if(o.color&&(p.fillStyle=o.color,p.fillRect(0,0,t,l)),o.fitPattern)p.drawImage(c,0,0,t,l);else{const e=2*(o.width||c.naturalWidth),n=2*(o.height||c.naturalHeight),i=2*(o.offsetX||0),r=2*(o.offsetY||0);let s=0,a=0;switch(o.align){case"center":s=(t-e)/2,a=(l-n)/2;break;case"left-top":break;case"left-bottom":a=l-n;break;case"right-top":s=t-e;break;case"right-bottom":s=t-e,a=l-n;break;case"left":a=(l-n)/2;break;case"right":s=t-e,a=(l-n)/2;break;case"top":s=(t-e)/2;break;case"bottom":s=(t-e)/2,a=l-n}const h=i+s,d=r+a;if(o.noRepeat)p.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,h,d,e,n);else{p.save(),p.rect(0,0,t,l),p.clip();const i=h>0?h-Math.ceil(h/e)*e:h;for(let r=d>0?d-Math.ceil(d/n)*n:d;r<l;r+=n)for(let s=i;s<t;s+=e)p.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,s,r,e,n);p.restore()}}n&&(p.scale(2,2),x_(u,n,s));const f=new e.CanvasTexture(u);f.needsUpdate=!0,f.wrapS=e.RepeatWrapping,f.wrapT=e.RepeatWrapping,f.offset.set(0,1-l/d),f.repeat.set(t/h,l/d),f.minFilter=e.LinearFilter,f.colorSpace=e.SRGBColorSpace,a(f)},c.onerror=()=>{const t=w_(n,i,r,s);a(t)},c.src=t}function M_(t,e){let{bold:n=!1,italic:i=!1,fontFamily:r="Serif",fontSize:s=10,lineHeight:o="normal"}=e||{};t=void 0===t||""==t?" ":String(t);const a=document.createElement("span");a.style.font=__(n,i,s,r),a.style.lineHeight=String(o),a.style.whiteSpace="pre",a.style.position="absolute",a.textContent=t,document.body.appendChild(a);const c=a.getBoundingClientRect();return document.body.removeChild(a),{width:c.width,height:c.height}}class k_ extends b_{get zPriority(){return Ud.DECAL}get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){this.updateDimension()}updateStrokeStyle(){}updateFillStyle(){this.updateText()}updateDimension(){const{width:t,height:n}=this.component.state,i=Math.abs(t)||1,r=Math.abs(n)||1;this.object3d.geometry&&this.object3d.geometry.dispose();const s=new e.PlaneGeometry(i,r);s.rotateX(-Math.PI/2),this.object3d.geometry=s}updateText(){const t=this.object3d.material;if(!t)return;const{width:e,height:n,bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",fillStyle:h}=this.component.state,d=Math.abs(e)||1,u=Math.abs(n)||1,p=this.component.text,f=h&&"none"!==h?h:"transparent",g={bold:i,italic:r,fontFamily:s,fontSize:o,fontColor:a,textAlign:c,textBaseline:l,width:d,height:u,fillStyle:f};if("object"==typeof f&&"pattern"===f?.type&&f.image){return void S_(this.component.app.url(h.image),p,d,u,g,h,e=>{t.map&&t.map.dispose(),t.map=e,t.color.set(16777215),t.needsUpdate=!0})}const m=w_(p,d,u,g);m?(t.map&&t.map.dispose(),t.map=m,t.color.set(16777215),m.needsUpdate=!0):"string"==typeof h&&(""!==h&&"transparent"!==h?t.color.set(zd(h)):t.opacity=0)}updateAlpha(){const{alpha:t=1}=this.component.state,e=this.object3d.material;e.opacity=t,e.transparent=!0}}wp("text",t=>new k_(t));const A_={input:"css3d",select:"css3d",textarea:"css3d",button:"css3d",iframe:"css3d",video:"css3d",label:"texture",table:"texture",progress:"texture"};function E_(t){const e=t.model?.type??"";return"texture"===(A_[e]??"css3d")?new y_(t):new _p(t)}wp("html-overlay-element",E_),wp("html-overlay-container",E_);class C_{setShape({extrudedShape:t,extrudedOptions:n}){this.extrudedShape=t,this.bb=new e.Box2,this.bb.setFromPoints(this.extrudedShape?.extractPoints(0).shape),this.extrudedOptions=n}generateTopUV(t,n,i,r,s){const o=n[3*i],a=n[3*i+1],c=n[3*r],l=n[3*r+1],h=n[3*s],d=n[3*s+1],u=this.bb,p=u.max.x-u.min.x,f=u.max.y-u.min.y;return[new e.Vector2((o-u.min.x)/p,1-(a-u.min.y)/f),new e.Vector2((c-u.min.x)/p,1-(l-u.min.y)/f),new e.Vector2((h-u.min.x)/p,1-(d-u.min.y)/f)]}generateSideWallUV(t,n,i,r,s,o){const a=n[3*i],c=n[3*i+1],l=n[3*i+2],h=n[3*r],d=n[3*r+1],u=n[3*r+2],p=n[3*s],f=n[3*s+1],g=n[3*s+2],m=n[3*o],y=n[3*o+1],b=n[3*o+2],_=this.extrudedOptions?.depth||100,v=this.bb,x=v.max.x-v.min.x,w=v.max.y-v.min.y;return Math.abs(c-d)<.01?[new e.Vector2(a/x,1-l/_),new e.Vector2(h/x,1-u/_),new e.Vector2(p/x,1-g/_),new e.Vector2(m/x,1-b/_)]:[new e.Vector2(c/w,1-l/_),new e.Vector2(d/w,1-u/_),new e.Vector2(f/w,1-g/_),new e.Vector2(y/w,1-b/_)]}}class T_ extends Zd{clear(){return this._mesh=void 0,super.clear()}get shape(){return null}get boundUVGenerator(){return this._boundUVGenerator||(this._boundUVGenerator=new C_),this._boundUVGenerator}build(){super.build();const t=this.effectiveDepth,n=this.shape;if(!n)return;const i=this.boundUVGenerator;i&&i.setShape({extrudedShape:n,extrudedOptions:{depth:t}});const r=this.createGeometry(n),s=this.createMaterials();this._mesh=new e.Mesh(r,s),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const n=this.effectiveDepth,{lineWidth:i=0}=this.component.state,r={steps:1,depth:n,bevelEnabled:i>0,bevelThickness:0,bevelSize:i,bevelSegments:1,UVGenerator:this.boundUVGenerator},s=new e.ExtrudeGeometry(t,r);return s.center(),s}createMaterials(){const t=xd(this.component.state.material3d),n=new e.MeshStandardMaterial;Md(n,t);const i=new e.MeshStandardMaterial;return Md(i,t),[n,i]}createTexture(){const{width:t,height:n}=this.component.bounds,i=v_(t),r=v_(n),s=up(i,r);this.component.render(s.getContext("2d"));const o=new e.CanvasTexture(s);return o.needsUpdate=!0,o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.offset.set(0,1-n/r),o.repeat.set(t/i,n/r),o.minFilter=e.LinearFilter,o}getMaterials(){if(!this._mesh)return;const t=this._mesh.material;return Array.isArray(t)?t:void 0}updateMaterial3d(){super.updateMaterial3d();const t=this.getMaterials();if(!t)return;const e=xd(this.component.state.material3d);for(const n of t)Md(n,e)}updateAlpha(){const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this.getMaterials();i&&(Dd(i[0],t,e),Dd(i[1],t,n))}updateStrokeStyle(){const t=this.getMaterials();if(!t)return;const{strokeStyle:e}=this.component.state;t[1].color.set(zd(e))}updateFillStyle(){this._applyCapTexture()}updateText(){this._applyCapTexture()}_applyCapTexture(){const t=this.getMaterials();if(!t)return;const e=t[0],{fillStyle:n}=this.component.state,i=this.component.hasTextProperty?this.component.text:"";if(!i){const t=Zd.buildFillStyleTexture(this.component);return t?(e.map&&e.map.dispose(),e.map=t,e.color.set(16777215)):(e.map&&(e.map.dispose(),e.map=null),e.color.set(zd(n))),void(e.needsUpdate=!0)}const{bold:r=!1,italic:s=!1,fontFamily:o="Serif",fontSize:a=10,fontColor:c="black",textAlign:l="center",textBaseline:h="middle",paddingTop:d=0,paddingLeft:u=0,paddingRight:p=0,paddingBottom:f=0}=this.component.state,{width:g,height:m}=this.component.bounds,y=Math.abs(g)||1,b=Math.abs(m)||1,_={bold:r,italic:s,fontFamily:o,fontSize:a,fontColor:c,textAlign:l,textBaseline:h,width:Math.max(y-u-p,0),height:Math.max(b-d-f,0),fillStyle:n,offsetX:u,offsetY:d};if("object"==typeof n&&"pattern"===n?.type&&n.image){return void S_(this.component.app.url(n.image),i,y,b,_,n,t=>{e.map&&e.map.dispose(),e.map=t,e.color.set(16777215),e.needsUpdate=!0})}e.map&&e.map.dispose();const v=w_(i,y,b,_);e.map=v,e.color.set(16777215),e.needsUpdate=!0}updateDimension(){super.updateDimension()}onchange(t,e){if("path"in t&&this._mesh){const t=this._mesh.geometry,e=this.shape;if(e){const n=this.createGeometry(e);this._mesh.geometry=n,t.dispose()}}super.onchange(t,e)}}class P_ extends T_{get shape(){const{cx:t=0,cy:n=0,rx:i=1,ry:r=1,startAngle:s=0,endAngle:o=2*Math.PI,anticlockwise:a=!1}=this.component.state,c=new e.EllipseCurve(t,n,Math.abs(i),Math.abs(r),s,o,a,0);return new e.Shape(c.getPoints(50))}}wp("ellipse",t=>new P_(t));class O_ extends T_{get shape(){const{width:t,height:n,round:i=0}=this.component.state,r=Tc(i,t,n);if(r>0){const i=r,s=new e.Path;return s.moveTo(i,0),s.lineTo(t-i,0),s.quadraticCurveTo(t,0,t,i),s.lineTo(t,n-i),s.quadraticCurveTo(t,n,t-i,n),s.lineTo(i,n),s.quadraticCurveTo(0,n,0,n-i),s.lineTo(0,i),s.quadraticCurveTo(0,0,i,0),new e.Shape(s.getPoints(12))}const s=new e.Shape;return s.moveTo(0,0),s.lineTo(t,0),s.lineTo(t,n),s.lineTo(0,n),s.lineTo(0,0),s}}function D_(t,n={}){const i=n.round??0,r=n.divisions??24;if(!t||0===t.length)return new e.Shape;const s=t.some(t=>$s(t)),o=i>0||t.some(t=>Js(t,0)>0);if(s||o){const n=new e.Path;for(let e=0;e<t.length;e++){const r=t[(e-1+t.length)%t.length],s=t[e],o=t[(e+1)%t.length];if(r.x===s.x&&r.y===s.y)continue;const a=Js(s,i);let c=Math.sqrt((r.x-s.x)**2+(r.y-s.y)**2),l=0!==c?Math.atan2(r.x-s.x,r.y-s.y):0;const h=Math.sin(l)*Math.min(a,c/2)+s.x,d=Math.cos(l)*Math.min(a,c/2)+s.y;c=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2),l=0!==c?Math.atan2(o.x-s.x,o.y-s.y):0;const u=Math.sin(l)*Math.min(a,c/2)+s.x,p=Math.cos(l)*Math.min(a,c/2)+s.y;if(0===e?n.moveTo(h,d):n.lineTo(h,d),a>0&&n.quadraticCurveTo(s.x,s.y,u,p),$s(s)){const t=Js(o,i),e=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),r=0!==e?Math.atan2(s.x-o.x,s.y-o.y):0,a=Ks({x:u,y:p},{x:Math.sin(r)*Math.min(t,e/2)+o.x,y:Math.cos(r)*Math.min(t,e/2)+o.y},s.bulge);a&&n.absarc(a.cx,a.cy,a.radius,a.startAngle,a.endAngle,a.clockwise)}}return new e.Shape(n.getPoints(r))}const a=new e.Shape;for(let e=0;e<t.length;e++)0===e?a.moveTo(t[e].x,t[e].y):a.lineTo(t[e].x,t[e].y);return a}wp("rect",t=>new O_(t));class z_ extends T_{get shape(){const{path:t=[],round:e=0}=this.component.state;return D_(t,{round:e,divisions:24})}build(){Object.getPrototypeOf(T_.prototype).build.call(this);const t=this.effectiveDepth,n=this.shape;if(!n)return;const i=this.boundUVGenerator,r=this.minMax;if(i&&void 0!==r.minX&&void 0!==r.maxX&&void 0!==r.minY&&void 0!==r.maxY){const n=new e.Shape;n.moveTo(r.minX,r.minY),n.lineTo(r.maxX,r.minY),n.lineTo(r.maxX,r.maxY),n.lineTo(r.minX,r.maxY),n.closePath(),i.setShape({extrudedShape:n,extrudedOptions:{depth:t}})}else i&&i.setShape({extrudedShape:n,extrudedOptions:{depth:t}});const s=this.createGeometry(n),o=this.createMaterials();this._mesh=new e.Mesh(s,o),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const n=this.effectiveDepth,{lineWidth:i=0}=this.component.state,r={steps:1,depth:n,bevelEnabled:i>0,bevelThickness:0,bevelSize:i,bevelSegments:1,UVGenerator:this.boundUVGenerator},s=new e.ExtrudeGeometry(t,r),o=this.minMax;if(void 0!==o.minX&&void 0!==o.maxX&&void 0!==o.minY&&void 0!==o.maxY){const t=(o.minX+o.maxX)/2,e=(o.minY+o.maxY)/2;s.translate(-t,-e,0),s.computeBoundingBox();const n=s.boundingBox;n&&s.translate(0,0,-(n.min.z+n.max.z)/2)}else s.center();return s}get minMax(){if(!this._minMax){const{path:t}=this.component.state;let e,n,i,r;t.forEach((t,s)=>{if(0==s)return e=i=t.x,void(n=r=t.y);e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),this._minMax={minX:e,minY:n,maxX:i,maxY:r}}return this._minMax}}wp("polygon",t=>new z_(t));class I_ extends T_{get shape(){const{cx:t=0,cy:n=0,rx:i=1,ry:r=1,ratio:s=50,startAngle:o=0,endAngle:a=2*Math.PI,anticlockwise:c=!1}=this.component.state,l=Math.abs(i),h=Math.abs(r),d=new e.EllipseCurve(t,n,l,h,o,a,c,0),u=new e.Shape(d.getPoints(50)),p=l/100*s,f=h/100*s;if(p>0&&f>0){const i=new e.EllipseCurve(t,n,p,f,o,a,c,0),r=new e.Path(i.getPoints(50));u.holes.push(r)}return u}}wp("donut",t=>new I_(t));class R_ extends T_{get shape(){const{x1:t=0,y1:n=0,x2:i=0,y2:r=0,x3:s=0,y3:o=0,round:a=0}=this.component.state,c=[{x:t,y:n},{x:i,y:r},{x:s,y:o}];if(a>0){const t=new e.Path;for(let e=0;e<c.length;e++){const n=c[(e-1+c.length)%c.length],i=c[e],r=c[(e+1)%c.length];let s=Math.sqrt((n.x-i.x)**2+(n.y-i.y)**2),o=0!==s?Math.atan2(n.x-i.x,n.y-i.y):0;const l=Math.sin(o)*Math.min(a,s/2)+i.x,h=Math.cos(o)*Math.min(a,s/2)+i.y;s=Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2),o=0!==s?Math.atan2(r.x-i.x,r.y-i.y):0;const d=Math.sin(o)*Math.min(a,s/2)+i.x,u=Math.cos(o)*Math.min(a,s/2)+i.y;0===e?t.moveTo(l,h):t.lineTo(l,h),t.quadraticCurveTo(i.x,i.y,d,u)}return new e.Shape(t.getPoints(12))}const l=new e.Shape;return l.moveTo(t,n),l.lineTo(i,r),l.lineTo(s,o),l.closePath(),l}}wp("triangle",t=>new R_(t));class L_ extends T_{get shape(){const{ratio:t=30,wing:n=5,cx:i=0,cy:r=0,rx:s=1,ry:o=1}=this.component.state;if(n<3)return null;const a=Math.PI/2,c=2*Math.PI/n,l=s-t/100*s,h=o-t/100*o,d=new e.Shape;d.moveTo(i+s*Math.cos(-a),r+o*Math.sin(-a)),d.lineTo(i+(s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,r+(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let t=1;t<n;t++)d.lineTo(i+s*Math.cos(c*t-a),r+o*Math.sin(c*t-a)),d.lineTo(i+(s-l)*(Math.cos(c*(t+1)-a)+Math.cos(c*t-a))/2,r+(o-h)*(Math.sin(c*(t+1)-a)+Math.sin(c*t-a))/2);return d.closePath(),d}}wp("star",t=>new L_(t));const j_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/sphere"};class F_ extends b_{buildGeometry(){const{rx:t=0,ry:n=0,rz:i}=this.component.state,r=i??t,s=new e.SphereGeometry(1,32,16);s.scale(t,r,n),this.object3d.geometry=s}updateDimension(){this.buildGeometry()}get effectiveDepth(){const{rx:t=0,rz:e}=this.component.state,n=e??t;return Math.max(2*n,1)}}let N_=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new F_(this)}get nature(){return j_}};N_=cg([Xm("sphere")],N_);class H_ extends Zd{getObject3dInstance(){return new e.Sprite}build(){super.build(),this.buildMaterial()}get cz(){const{zPos:t=0}=this.component.state,{height:e}=this.component.bounds,{tz:n=0}=this.component.delta(),i=this.component.parent?._realObject;return t+n+e/2-(i?.geometricOffsetY??0)}get geometricOffsetY(){const{height:t=0}=this.component.bounds;return t/2}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=Zd.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(zd(t)):e.opacity=0)}}class B_ extends H_{buildMaterial(){const t=this.object3d.material;t&&t.dispose(),this.object3d.material=new e.SpriteMaterial({map:p_(this.component),alphaTest:.01,sizeAttenuation:!1})}get scale(){const{width:t,height:e}=this.component.bounds,n=this.threeContainer,{width:i=1,height:r=1}=n?.bounds??{},{scale:s=1}=this.component.state;return{x:s*t/i,y:s*e/r,z:s}}update(){this.build(),this.updateHidden()}updateFillStyle(){this.update()}updateStrokeStyle(){this.update()}updateAlpha(){this.update()}updateText(){this.update()}}const Y_={mutable:!1,resizable:!0,rotatable:!0,properties:[]};let V_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new B_(this)}get nature(){return Y_}};V_=cg([Xm("sprite")],V_);const G_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cube"};class W_ extends b_{buildGeometry(){const{width:t=0,height:n=0,depth:i=0}=this.component.state,r=new e.BoxGeometry(1,1,1);r.scale(t,i,n),this.object3d.geometry=r}}let U_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new W_(this)}get nature(){return G_}};U_=cg([Xm("cube")],U_);const X_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cylinder"};class q_ extends b_{buildGeometry(){const{rx:t=0,ry:n=0}=this.component.state,i=this.component.state.depth??1,r=new e.CylinderGeometry(1,1,1,25);r.scale(t||1,i||1,n||1),this.object3d.geometry=r}updateDimension(){this.buildGeometry()}}let $_=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new q_(this)}get nature(){return X_}};$_=cg([Xm("cylinder")],$_);const K_={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"color",label:"box-color",name:"boxColor",property:"boxColor"}],help:"scene/component/banner"};class Q_ extends Zd{get zPriority(){return Ud.DECAL}build(){super.build();const{width:t=1,height:e=1,depth:n=1}=this.component.state;this.object3d.add(this.createCube(t,e,n));const i=this.createTextureBoard(t,n);i.position.set(0,0,.5*e+1),this.object3d.add(i)}createCube(t,n,i){const{boxColor:r="#ccaa76"}=this.component.state,s=xd(this.component.state.material3d),o=new e.BoxGeometry(t,i,n),a=new e.MeshStandardMaterial({color:r,side:e.FrontSide});Md(a,s);const c=new e.Mesh(o,a);return c.castShadow=s.castShadow,c.receiveShadow=s.receiveShadow,c}createTextureBoard(t,n){const i=xd(this.component.state.material3d),{fillStyle:r="#ccaa76"}=this.component.state,s=Zd.buildFillStyleTexture(this.component),o=new e.MeshStandardMaterial(s?{map:s}:{color:r||"#ccaa76",side:e.FrontSide});Md(o,i);const a=new e.PlaneGeometry(t,n,1,1),c=new e.Mesh(a,o);return c.castShadow=i.castShadow,c.receiveShadow=i.receiveShadow,c}updateMaterial3d(){super.updateMaterial3d();const t=xd(this.component.state.material3d);this.object3d.traverse(e=>{if(e.isMesh){const n=e.material;n&&Md(n,t),e.castShadow=t.castShadow,e.receiveShadow=t.receiveShadow}})}updateFillStyle(){this.update()}onchange(t,e){super.onchange(t,e),"boxColor"in t&&this.update()}}let Z_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}get nature(){return K_}buildRealObject(){return new Q_(this)}};var J_;Z_=cg([Xm("banner")],Z_);const tv={far:1e5,fov:80,near:1,zoom:1},ev={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"near",name:"near"},{type:"number",label:"far",name:"far"},{type:"number",label:"fov",name:"fov"},{type:"number",label:"zoom",name:"zoom"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/camera"};class nv extends Zd{getObject3dInstance(){return new e.Mesh}updateCamera(){const{near:t=tv.near,far:n=tv.far,fov:i=tv.fov,zoom:r=tv.zoom,showHelper:s}=this.component.state;this.camera.far=n,this.camera.fov=i,this.camera.near=t,this.camera.zoom=r,s?this.helper||(this.helper=new e.CameraHelper(this.camera),this.object3d.add(this.helper)):this.helper&&(this.object3d.remove(this.helper),delete this.helper)}build(){super.build();const{width:t=0,height:n=0,depth:i=0,fillStyle:r="lightgray"}=this.component.state;this.object3d.geometry=new e.BoxGeometry(t,i,n);const s=xd(this.component.state.material3d),o=new e.MeshStandardMaterial({color:r});Md(o,s),this.object3d.material=o,this.object3d.castShadow=s.castShadow,this.object3d.receiveShadow=s.receiveShadow,this.camera=new e.PerspectiveCamera,this.camera.position.set(0,0,0),this.object3d.add(this.camera),this.object3d.lookAt(0,0,0),this.updateCamera()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}}let iv=J_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}static get image(){return J_._image||(J_._image=new Image,J_._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA1IAAANSAQMAAABV6G1EAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAABlBMVEX6+voBAQGV71ZvAAAFO0lEQVR42u3dMZLkNBiGYakUKFRIqKOISxDvETiCTBEQcgQOQE7clyAi8REm7KDXIhgYoMa/7fbIX+2K9w022MCP/25Z28GW5RwRERERERERERERERERERERERERERERERERERERERERERERERHRl9mv7fdPn7879sf8Mcq3J3r5EJXaUy3Wddrcd6qNybx9F2/lZ63H+nVCa9Oe9elZa5ksa/dDbE+3fsm4v27C89bd+i6W3l+XdcnSWtuxyvPW+hqorbWb0Jr7Pl3m4tjfVMIZ625d6L5pxTPWw7rQY9P6pqu1dF8aq5d83cE3rXrGWluIxV6h53eotv4c1V3Ln7Nm66ZvvZf8SSues16sD2jubz2sC839fmvYiz7t//LJna27wsr7VjlnNWtPeHTfNlae2bZvnaTePUd+74fqV2LNxv6zdN8O3z9HSWhlc4F+dOvdsKbe2+F7q+zPddq6W2ts6r31vrN825/rtPWwvvcL5losy11uxQNz5U6fYT4w12mrWf80TUNZdetXal/LtwNW6WOFI1Y9bU3GVnfFXM9bneZKwrmKcK4qnKsK52q6uULTzRWFVjpkta/OykKrCq02puWFVhRaSWjlQa0itJrO8oNaQWgloZWFVhnUqjrLN50VBrWi0MpCqwitOqjVdFYQWlFopUGtLLSq0GpjWl5oRaGVBrWy0KpCq+ksP6gVhFYSWllolUGtqrNW/jvBZVYY1IpCKwutIrTqoFbTWUFoxUGtJLSK0KpCq41peaEVhVYa1MpCqwqtprP8oFYUWklo5UGtIrSazvJCKwxqRaGVhVYZ1Ko664ems34UWj8Nav0stBoWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhbW/9L6RWgp37WofIek8j2cyveLTkqrCq0itLLQSkJL+Q5k5budle/HVr73e/24gAHenZ6FlvK9+srzAoLQUp65oDy3QnoeRxFaWWgpz2pRnncThJbyzCDpuUtVaBWhlYWW8qwx5RlqynPovNBSnuUnPaOwCK0stJLQUp4BqjzbVHk+rFNaVWgVoZWFlvJc6Si0lGdzK88cV57bLj2PvgitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqxyyahcrH7JKFysJ54rCuYJwLi+cywnn+vdlLp+rCOfKwrnStXP95zLxiJX7WEFoeaHljO/xEqsaf9/FWqz1bM+VzloP655df2uxrnP9XPHKue7OeMDsuWInyx+Y67T1Yv0gs+cKvay6P5fvZZULrdnYFBbbcr2sdKF1MxbZFdZkLLItq3aay6/vJ102eusD2rJKl633nw/o3n+uxbrpLSv1svL6M95hQ3xYNz33t16sC21Zoc+28Xahm+u+Ic7WhbYs1+dRfrvQ5LpvHOaFNq3SZ8n/faEt6twDtli7wrJpxT6P1183/di0Ti36u3XT903Ld1qGrzf9smmdWhyTddNzf8t8UqdtK/dZGq8P2DZ1ZnHcrQ/osWO5PkvDuby7NE58Yctk7Qq3PSv3+bpc3F0aJ56wF+uLX9xu6eOb4es9z/vWc0vR3oZuByjnf2t/fP/54B/2WvvWEREREREREREREREREREREREREREREREREREREREREREREREREX2J/QlrTpqHD8xO1gAAAABJRU5ErkJggg=="),J_._image}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,J_.image,e,n,i,r)}buildRealObject(){return new nv(this)}get nature(){return ev}};iv=J_=cg([Xm("camera")],iv);const rv={mutable:!1,resizable:!0,rotatable:!0,properties:[...Wm],"value-property":"source",help:"scene/component/gltf-object"};let sv=class extends(Um(Pc(Cc))){get nature(){return rv}};sv=cg([Xm("gltf-object")],sv);const ov={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"light-type",name:"lightType",property:{options:["","point","directional"]}},{type:"number",label:"intensity",name:"intensity"},{type:"number",label:"distance",name:"distance"},{type:"number",label:"decay",name:"decay"},{type:"checkbox",label:"cast-shadow",name:"castShadow"},{type:"number",label:"near",name:"near",placeholder:"0.5"},{type:"number",label:"far",name:"far",placeholder:"1000"},{type:"number",label:"fov",name:"fov",placeholder:"90"},{type:"number",label:"zoom",name:"zoom",placeholder:"1"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/light"};class av extends Zd{updatePointLight(){const{lightType:t="point",distance:n=0,intensity:i=10,decay:r=1,fillStyle:s="white",castShadow:o,near:a=.5,far:c=1e3,fov:l=90,zoom:h=1,showHelper:d}=this.component.state;if(this.object3d.color=new e.Color(s),"point"==t&&(this.object3d.distance=n,this.object3d.decay=r),this.object3d.intensity=i,this.object3d.castShadow=o,o){const t=this.object3d.shadow?.camera;t.far=c,t.near=a,t.fov=l,t.zoom=h}if(d){const t=this.object3d.shadow?.camera;this.helper||(this.helper=new e.CameraHelper(t),this.object3d.add(this.helper))}else this.helper&&(this.object3d.remove(this.helper),delete this.helper)}getObject3dInstance(){const{lightType:t="point"}=this.component.state;return"point"==t?new e.PointLight:new e.DirectionalLight}update(){this.clear(),this.build(),this.updateDimension(),this.updateHidden(),this.updatePointLight()}}let cv=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new av(this)}get anchors(){return[]}get nature(){return ov}};cv=cg([Xm("light")],cv);const lv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/wall"};class hv extends b_{buildGeometry(){const{width:t=0,height:n=0,depth:i=0}=this.component.state,r=new e.BoxGeometry(1,1,1);r.scale(t,i,n),this.object3d.geometry=r}}let dv=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new hv(this)}get nature(){return lv}};dv=cg([Xm("wall")],dv);const uv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"},{type:"checkbox",label:"hide-in-2d-view",name:"hideIn2DView"},{type:"checkbox",label:"hide-in-3d-view",name:"hideIn3DView"}],help:"scene/component/floor-plate"};class pv extends Zd{get zPriority(){return Ud.FLOOR}get receivingSurfaceY(){return this.placementSurfaceY()}resolveShadow(){const t=this.component.state,e=t.material3d,{alpha:n=1,fillStyle:i}=t,r=n>=.9&&"none"!==i;return{receive:e?.receiveShadow??!0,cast:e?.castShadow??r}}updateHidden(){const t=this.component.state,e=!!this.component.app?.isViewMode;this.object3d.visible=!(t.hidden||e&&t.hideIn3DView)}clear(){return this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0),this._mesh=void 0,super.clear()}build(){super.build();const{width:t,height:n,depth:i=1}=this.component.state;if(!t||!n)return;const r=Math.abs(t),s=Math.abs(n),o=Math.max(i,.5),a=new e.BoxGeometry(r,o,s),c=this._buildTopMaterial(),l=this._buildSideMaterial(),h=[l,l,c,l,l,l];this._mesh=new e.Mesh(a,h),this._mesh.position.y=0;const{cast:d,receive:u}=this.resolveShadow();this._mesh.castShadow=d,this._mesh.receiveShadow=u,this.object3d.add(this._mesh)}_buildTopMaterial(){const{alpha:t=1,fillStyle:n}=this.component.state,i=xd(this.component.state.material3d),r=Zd.buildFillStyleTexture(this.component);if(r){this._topTexture=r;const s=new e.MeshStandardMaterial({map:r,side:e.DoubleSide});return Dd(s,t,n),s.depthWrite=s.opacity>=.9,Md(s,i),s}const s="string"==typeof n&&"none"!==n?zd(n):"#e0e0e0",o=new e.MeshStandardMaterial({color:s,side:e.DoubleSide});return Dd(o,t,n),o.depthWrite=o.opacity>=.9,Md(o,i),o}_buildSideMaterial(){const{strokeStyle:t,alpha:n=1}=this.component.state,i="string"==typeof t&&t?zd(t):"#999999",r=xd(this.component.state.material3d),s=new e.MeshStandardMaterial({color:i});return Md(s,r),s.side=e.DoubleSide,Dd(s,.8*n,t),s.depthWrite=s.opacity>=.9,s}updateAlpha(){if(!this._mesh)return;const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this._mesh.material;for(let r=0;r<i.length;r++){const s=i[r];2===r?Dd(s,t,e):Dd(s,.8*t,n),s.depthWrite=s.opacity>=.9}}updateFillStyle(){if(!this._mesh)return;this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0);const t=this._mesh.material;t[2].dispose(),t[2]=this._buildTopMaterial()}updateStrokeStyle(){if(!this._mesh)return;const t=this._mesh.material,e=this._buildSideMaterial();for(let n=0;n<t.length;n++)2!==n&&(t[n].dispose(),t[n]=e)}}let fv=class extends ql{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new pv(this)}get nature(){return uv}get hidden(){return!!this.getState("hideIn2DView")||super.hidden}};fv=cg([Xm("floor-plate")],fv);function gv(t,n={}){const i=n.size??5,r=n.color??4500172,s=n.emissive??2245734,o=new e.SphereGeometry(i,16,12),a=new e.MeshStandardMaterial({color:r,emissive:s,emissiveIntensity:.15,metalness:.3,roughness:.4,transparent:!0,opacity:.35}),c=new e.Mesh(o,a);n.position&&c.position.set(n.position[0],n.position[1],n.position[2]),c.userData.alwaysRaycast=!0,c.scale.setScalar(1),c.visible=n.visible??!(!0===t.app?.isViewMode);const l=()=>{a.emissiveIntensity=.9,a.opacity=.95,c.scale.setScalar(1.35),t.invalidate?.()},h=()=>{a.emissiveIntensity=.15,a.opacity=.35,c.scale.setScalar(1),t.invalidate?.()};return t.on("mouseenter",l),t.on("mouseleave",h),c.userData.dispose=()=>{t.off("mouseenter",l),t.off("mouseleave",h)},c}class mv extends b_{get zPriority(){return Ud.DECAL}get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){const{width:t,height:n}=this.component.state,i=Math.abs(t)||1,r=Math.abs(n)||1,s=new e.PlaneGeometry(i,r);s.rotateX(-Math.PI/2),this.object3d.geometry=s}updateDimension(){this.update()}build(){super.build();const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=Math.max(2,.04*Math.min(n,i));this.object3d.add(gv(this.component,{size:r,position:[n/2-r,r,-i/2+r]}))}}const yv={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/decal"};let bv=class extends(Vm(Pc(Cc))){buildRealObject(){return new mv(this)}get nature(){return yv}};bv=cg([Xm("decal")],bv);class _v extends Zd{getObject3dInstance(){return new e.Group}get allowedGizmoModes(){return this.component.isGroup?.()?["translate"]:null}}const vv="#dde2e8",xv="#9c9c9c",wv="#e8e8ec",Sv=.35;function Mv(t,n,i,r,s){if(!n.visible)return new e.MeshStandardMaterial({transparent:!0,opacity:0,depthWrite:!1});const o=n.alpha*i,a="wall"===r?vv:"floor"===r?xv:wv,c=new e.MeshStandardMaterial({metalness:0,roughness:"wall"===r?.6:.85,transparent:o<1,opacity:o,side:s?e.BackSide:e.DoubleSide});return function(t,e,n,i,r,s){if("string"==typeof n&&n&&"transparent"!==n)t.color.set(n);else{if(n&&"object"==typeof n){const i=!s,o=Zd.buildFillStyleTexture(e,n,{mirror:i,rotation:r});if(o)return t.map&&t.map.dispose(),t.map=o,void t.color.set("#ffffff")}t.color.set(i)}}(c,t,n.fillStyle,a,n.rotation,n.mirror),c}class kv extends _v{get zPriority(){return Ud.BACKDROP}get position(){if(this.component.state.fitToBoard){return{x:0,y:super.position.y,z:0}}return super.position}build(){super.build();const t=this.component.state;let n=t.width,i=t.height;if(t.fitToBoard){const t=this.component.rootModel,e=t?.state;e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(n=e.width,i=e.height)}const r=this.effectiveDepth||Math.min(n,i)||200,s=t.alpha??1,o=!1!==t.seeThrough,a={east:this._resolveFace("east",vv,!0,Sv),west:this._resolveFace("west",vv,!0,Sv),north:this._resolveFace("north",vv,!0,Sv),south:this._resolveFace("south",vv,!0,Sv),floor:this._resolveFace("floor",xv,!0,1),ceiling:this._resolveFace("ceiling",wv,!0,1)},c=[Mv(this.component,a.east,s,"wall",o),Mv(this.component,a.west,s,"wall",o),Mv(this.component,a.ceiling,s,"ceiling",o),Mv(this.component,a.floor,s,"floor",o),Mv(this.component,a.south,s,"wall",o),Mv(this.component,a.north,s,"wall",o)],l=new e.BoxGeometry(n,r,i),h=new e.Mesh(l,c);if(h.receiveShadow=!0,this.object3d.add(h),this.component.app?.isEditMode){const t=new e.LineBasicMaterial({color:4473941,transparent:!0,opacity:.7}),n=new e.LineSegments(new e.EdgesGeometry(l),t);this.object3d.add(n)}const d=.04*Math.min(n,i,r);this.object3d.add(gv(this.component,{size:d,position:[n/2,r/2+d,-i/2]}))}_resolveFace(t,e,n,i){const r=this.component.state,s=r.faces?.[t]??{},o=s.visible,a=s.alpha,c=s.rotation,l=90===c||180===c||270===c?c:0;return{fillStyle:s.fillStyle??e,visible:"boolean"==typeof o?o:n,alpha:"number"==typeof a&&Number.isFinite(a)?a:i,rotation:l,mirror:!0===s.mirror}}updateDimension(){}onchange(t,e){["alpha","width","height","depth","fitToBoard","faces","seeThrough"].some(e=>e in t)?this.update():super.onchange(t,e)}updateAlpha(){}}const Av={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"checkbox",label:"fit-to-board",name:"fitToBoard"},{type:"checkbox",label:"see-through",name:"seeThrough"},{type:"backdrop-faces",label:"",name:"faces"}],help:"scene/component/backdrop"};let Ev=class extends(Vm(Pc(Cc))){buildRealObject(){return new kv(this)}get nature(){return Av}added(t){super.added?.(t),this.state.fitToBoard&&(this._syncFromRoot(!0),this._attachRootListener())}async ready(){await(super.ready?.()),this.state.fitToBoard&&this._syncFromRoot(!1)}removed(t){this._detachRootListener(),super.removed?.(t)}dispose(){this._detachRootListener(),super.dispose?.()}onchange(t,e){"fitToBoard"in t&&(t.fitToBoard?(this._syncFromRoot(!0),this._attachRootListener()):this._detachRootListener()),super.onchange?.(t,e)}_syncFromRoot(t=!1){const e=this.rootModel;if(!e||e===this)return;const n=e.state;if(!n)return;const i={},r=Number.isFinite(n.width)?n.width:this.state.width,s=Number.isFinite(n.height)?n.height:this.state.height;r!==this.state.width&&(i.width=r),s!==this.state.height&&(i.height=s);const o=Number.isFinite(n.left)?n.left:0,a=Number.isFinite(n.top)?n.top:0;if(o!==this.state.left&&(i.left=o),a!==this.state.top&&(i.top=a),t){const t=this.state.depth;if(!("number"==typeof t&&Number.isFinite(t)&&t>0)){const e=Math.min(r,s);e!==t&&(i.depth=e)}}Object.keys(i).length>0&&this.set(i)}_attachRootListener(){if(this._onRootChange)return;const t=this.rootModel;t&&t!==this&&(this._onRootChange=t=>{("width"in t||"height"in t||"left"in t||"top"in t)&&this._syncFromRoot()},t.on?.("change",this._onRootChange))}_detachRootListener(){if(!this._onRootChange)return;const t=this.rootModel;t?.off?.("change",this._onRootChange),this._onRootChange=void 0}};function Cv(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function Tv(t,n,i,r){const s=[];for(let o=1;o<=r;o++){const a=o/r,c=1-a;s.push(new e.Vector3(c*c*t.x+2*c*a*n.x+a*a*i.x,c*c*t.y+2*c*a*n.y+a*a*i.y,c*c*t.z+2*c*a*n.z+a*a*i.z))}return s}Ev=cg([Xm("backdrop")],Ev);class Pv extends Zd{getObject3dInstance(){return new e.Group}get gizmoTransformable(){return!0}get syncZPosOffset(){return 0}get geometricOffsetY(){return 0}syncFromObject3D(){}applyDimensionFromGizmo(t){}build(){super.build(),this._buildLine()}get smoothedPath(){const t=this.worldPath;if(t.length<2)return t;const{round:n=0}=this.component.state;if(n<=0||t.length<3)return t;const i=[];i.push(t[0]);for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=t[r+1];if(!a){i.push(o);break}const c=s.x-o.x,l=s.y-o.y,h=s.z-o.z,d=Math.sqrt(c*c+l*l+h*h),u=Math.min(n,d/2),p=a.x-o.x,f=a.y-o.y,g=a.z-o.z,m=Math.sqrt(p*p+f*f+g*g),y=Math.min(n,m/2),b=d>0?new e.Vector3(o.x+c/d*u,o.y+l/d*u,o.z+h/d*u):o.clone(),_=m>0?new e.Vector3(o.x+p/m*y,o.y+f/m*y,o.z+g/m*y):o.clone();i.push(b),i.push(...Tv(b,o,_,8))}return i}_buildLine(){const t=this.smoothedPath;if(t.length<2)return;const{strokeStyle:n,lineWidth:i=2,alpha:r=1,lineDash:s,begin:o="none",beginSize:a="size5",end:c="none",endSize:l="size5"}=this.component.state,h=Math.max(i,1),d="string"==typeof n&&"transparent"!==n?zd(n):"#000000",u=new e.Color(d),p=this._getResolution(),f=o,g=c,m=Cv(f,h),y=Cv(g,h),b=t[0],_=t[t.length-1],v=(new e.Vector3).subVectors(t[1],b).normalize(),x=(new e.Vector3).subVectors(t[t.length-2],_).normalize(),k=[...t];m>0&&(k[0]=b.clone().add(v.clone().multiplyScalar(m))),y>0&&(k[k.length-1]=_.clone().add(x.clone().multiplyScalar(y)));const A=new M;A.setPositions(k.flatMap(t=>[t.x,t.y,t.z]));const E=function(t,e){switch(t){case"round-dot":return{dashSize:e,gapSize:e};case"square-dot":return{dashSize:2*e,gapSize:e};case"dash":return{dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashSize:4*e,gapSize:2*e};case"long-dash":return{dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashSize:6*e,gapSize:2*e};case"long-dash-dot-dot":return{dashSize:6*e,gapSize:e};default:return null}}(s,h),C=new S({color:u.getHex(),linewidth:h,worldUnits:!0,transparent:r<1,opacity:r,resolution:p,dashed:!!E,dashSize:E?.dashSize??1,gapSize:E?.gapSize??1,dashScale:1});if(this._line2=new w(A,C),this._line2.computeLineDistances(),this.object3d.add(this._line2),"none"!==f){const t=gp(f,fp(a,h));if(t){const n=(new e.Quaternion).setFromUnitVectors(new e.Vector3(1,0,0),v.clone().negate());this._placeTip(t,b,n,u,r,p)}}if("none"!==g){const t=gp(g,fp(l,h));if(t){const n=(new e.Quaternion).setFromUnitVectors(new e.Vector3(1,0,0),x.clone().negate());this._placeTip(t,_,n,u,r,p)}}}_placeTip(t,e,n,i,r,s){const o=t.mesh||t.line2||t.group;if(o){if(o.position.copy(e),o.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(i),e.transparent=r<1,e.opacity=r}else if(t.line2){const e=t.line2.material;e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution.copy(s)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color&&e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution&&e.resolution.copy(s)}});this.object3d.add(o)}}_getResolution(){const t=this.threeContainer?.renderer3d;if(t){return t.getSize(new e.Vector2)}return new e.Vector2(window.innerWidth,window.innerHeight)}onGizmoDragEnd(t){const e=this._component,n=e.path;if(!n||n.length<2)return;const i=this.object3d,{width:r=0,height:s=0}=e.parent?.bounds??{},{x:o,y:a}=e.center,c=i.position,l=i.rotation,h=i.scale,d=this.position;if(Math.abs(c.x-d.x)<.001&&Math.abs(c.y-d.y)<.001&&Math.abs(c.z-d.z)<.001&&Math.abs(l.x)<.001&&Math.abs(l.y)<.001&&Math.abs(l.z)<.001&&Math.abs(h.x-1)<.001&&Math.abs(h.y-1)<.001&&Math.abs(h.z-1)<.001)return;const u=Pv.computeBakedPath(n,{x:o,y:a},{width:r,height:s},i);this._suppressOnchange=!0,e.set({rotation:0,rotationX:0,rotationY:0,zPos:0}),e.mutatePath(null,()=>u),this._suppressOnchange=!1,this.update()}static computeBakedPath(t,n,i,r){const s=i.width,o=i.height,a=n.x,c=n.y;return r.updateMatrixWorld(!0),t.map(t=>{const n=new e.Vector3(t.x-a,t.z||0,t.y-c).applyMatrix4(r.matrixWorld),i={x:n.x+s/2,y:n.z+o/2};return Math.abs(n.y)>.001&&(i.z=n.y),i})}updateStrokeStyle(){this.updateDimension()}updateAlpha(){this.updateDimension()}updateDimension(){this.clear(),this.build()}onchange(t,e){("path"in t||"from"in t||"to"in t)&&(this.updateDimension(),this.updatePosition()),("round"in t||"lineDash"in t||"lineWidth"in t||"begin"in t||"end"in t||"beginSize"in t||"endSize"in t)&&this.updateDimension(),super.onchange(t,e)}clear(){for(;this.object3d.children.length>0;){const t=this.object3d.children[0];this.object3d.remove(t),Hd(t)}return this._line2=void 0,super.clear()}}class Ov extends Pv{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center,r=this.component,s=r.fromEnd?.component?._realObject?.object3d?.position?.y??0,o=r.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((r,a)=>{const c=t.length>1?a/(t.length-1):0;return new e.Vector3(r.x-n,r.z||s+(o-s)*c,r.y-i)})}}wp("line",t=>new Ov(t));class Dv extends Pv{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center;return t.map(t=>new e.Vector3(t.x-n,t.z||0,t.y-i))}}wp("polyline",t=>new Dv(t));class zv extends Pv{get worldPath(){const t=this.component.drawPath;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center,r=this.component,s=r.fromEnd?.component?._realObject?.object3d?.position?.y??0,o=r.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((r,a)=>{const c=t.length>1?a/(t.length-1):0;return new e.Vector3(r.x-n,r.z||s+(o-s)*c,r.y-i)})}}wp("ortholine",t=>new zv(t)),wp("group",t=>new _v(t));class Iv extends Zd{build(){super.build()}update(){}}const Rv={far:1e5,fov:80,near:1,zoom:1};class Lv extends Zd{build(){super.build()}update(){super.update(),this.updateCamera()}getObject3dInstance(){return new e.PerspectiveCamera}updateCamera(){const{near:t=Rv.near,far:e=Rv.far,fov:n=Rv.fov,zoom:i=Rv.zoom}=this.component.state;this.object3d.far=e,this.object3d.fov=n,this.object3d.near=t,this.object3d.zoom=i}}class jv extends b_{buildGeometry(){const{width:t,height:n}=this.component.state.dimension;this.object3d.geometry=new e.PlaneGeometry(t,n)}buildMaterial(){this.object3d.material=new e.MeshStandardMaterial({opacity:0,side:e.DoubleSide,blending:e.NoBlending})}}class Fv extends Zd{getObject3dInstance(){return new e.Scene}dispose(){for(const t of this.object3d.children)Hd(t);this._animationMixer&&(this._animationMixer.stopAllAction(),this._animationMixer.uncacheRoot(this.object3d),this._animationMixer=void 0),super.dispose()}clear(){return this._floor&&(this.object3d.remove(this._floor),this._floor.material instanceof Array?this._floor.material.forEach(t=>t.dispose()):this._floor.material.dispose(),this._floor.geometry.dispose(),delete this._floor),super.clear()}get floor(){return this._floor}set floor(t){this._floor&&(this.object3d.remove(this._floor),this._floor.clear(),delete this._floor),t&&(this._floor=t,this.object3d.add(t)),this.component.invalidate()}build(){super.build(),this.floor=Dp(this.component)}updateTransform(){}updateDimension(){}updatePosition(){}updateRotate(){}updateScale(){}updateAlpha(){}updateHidden(){}get animationMixer(){return this._animationMixer||(this._animationMixer=new e.AnimationMixer(this.object3d)),this._animationMixer}}const Nv=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Hv extends Zd{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds;if(!t||!n)return;const i=xd(this.component.state.material3d),r=new e.PlaneGeometry(1,1);r.rotateX(-Math.PI/2),this.object3d.geometry=r;const s=p_(this.component),o=new e.MeshStandardMaterial({map:s});Md(o,i),o.transparent=!0,this.object3d.material=o,this.object3d.castShadow=i.castShadow,this.object3d.receiveShadow=i.receiveShadow}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}get dimension(){const{width:t,height:e}=this.component.bounds;return{width:t||1,height:e||1,depth:1}}get scale(){const t=super.scale,{width:e,height:n}=this.dimension;return{x:t.x*e,y:t.y,z:t.z*n}}updateDimension(){this.updateTransform()}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this.update()},100)}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(g_(n,this.component,2),e.needsUpdate=!0)}update(){this.clear(),this.build(),this.updateDimension(),this.updateTransform(),this.updateHidden()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!Nv.has(e)){this._debouncedRebuild();break}}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),t.transparent=!0,this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hd(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}const Bv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"precision",name:"precision",property:{options:[{display:"High",value:"highp"},{display:"Medium",value:"mediump"},{display:"Low",value:"lowp"}]}},{type:"checkbox",label:"anti-alias",name:"antialias",property:"antialias"},{type:"checkbox",label:"3dmode",name:"threed",property:"threed"},{type:"checkbox",label:"auto-rotate",name:"autoRotate",property:"autoRotate"},{type:"checkbox",label:"debug",name:"debug",property:"debug"}],help:"scene/component/three-container"};let Yv=class extends yg{constructor(){super(...arguments),this._capability=new sf}get sceneManager(){return this._capability.sceneManager}get cameraManager(){return this._capability.cameraManager}get rendererManager(){return this._capability.rendererManager}get lightManager(){return this._capability.lightManager}get controlsManager(){return this._capability.controlsManager}get eventManager(){return this._capability.eventManager}containable(t){return!0}is3dContainer(){return!0}getLightingConfig(){return{hemisphere:{skyColor:16777215,groundColor:14540253,intensity:1},directional:{color:16777215,intensity:1.2,attachToCamera:!0,castShadow:!1}}}getCss3DSceneAttribute(){return"three-container:css3d-renderer"}init_scene3d(){this._capability.isInitialized&&this._capability.destroy(),this._capability.init(this,{lightingConfig:this.getLightingConfig(),css3DSceneAttribute:this.getCss3DSceneAttribute(),skipEnvironment:!0,skipPostprocessing:!0,skipShadowMap:!0}),this._capability.buildOverlays(),this._capability.resize(),this.onchangeData&&this.onchangeData(this.data,this.data)}destroy_scene3d(){this.stop(),this._capability.destroy()}stop(){}resize(){this._capability.resize()}get scene3d(){return this._capability.isInitialized||this.init_scene3d(),this._capability.scene3d}get renderer3d(){return this._capability.renderer3d}get mixer(){return this._capability.mixer}get css3DScene(){return this._capability.css3DScene}get css3DRenderer(){return this._capability.css3DRenderer}render_threed(){this._capability.renderThreeD()}get _parentIs3dMode(){return!!this.rootModel?.is3dMode}render(t){this._parentIs3dMode||(this.app.isViewMode&&this.setState("threed",!0),!this.state.threed||this._capability.noSupportWebgl?super.render(t):this._capability.camera&&this._capability.renderCSS3D())}postrender(t){if(this._parentIs3dMode)return;const{left:e,top:n,debug:i,threed:r}=this.state;let{width:s,height:o}=this.bounds;if(s=Math.floor(s),o=Math.floor(o),r){if(this._capability.isInitialized||this.init_scene3d(),this._capability.noSupportWebgl)return void this._capability.showWebglNoSupportText(t,this.state.width,this.state.height);if(!this._capability.renderer3d)return;this._capability.renderThreeD();const r=this._capability.domElement;if(!r||!r.width||!r.height)return;t.drawImage(r,0,0,r.width,r.height,e,n,s,o),i&&this._capability.showDebugFPS(t)}else super.postrender(t)}dispose(){this._capability.dispose(),super.dispose()}get layout(){return Lc.get("three")}get nature(){return Bv}getObjectByRaycast(){return this._capability.getObjectByRaycast()}getObjectsByRaycast(){return this._capability.getObjectsByRaycast()}onchange(t,e){(t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._capability.destroy(),this._capability.onchange(t)}onmousedown(t){this._capability.onMouseDown(t)}onmouseup(t){this._capability.onMouseUp(t)}onmousemove(t){this._capability.onMouseMove(t)}onmouseleave(t){this._capability.onMouseLeave(t)}onwheel(t){this._capability.onWheel(t)&&this.invalidate()}ondblclick(t){this._capability.onDblClick(t)&&this.invalidate()}ondragstart(t){this._capability.onDragStart(t)}ondragmove(t){this._capability.onDragMove(t)&&this.invalidate()}ondragend(t){this._capability.onDragEnd(t)&&this.invalidate()}ontouchstart(t){this._capability.onTouchStart(t)}onpan(t){this._capability.onPan(t)&&this.invalidate()}ontouchend(t){this._capability.onTouchEnd(t)}onkeydown(t){this._capability.onKeyDown(t)}onpinch(t){this._capability.onPinch(t)&&this.invalidate()}ondoubletap(){this._capability.onDoubleTap(),this.invalidate()}};var Vv;Yv=cg([Xm("3d-container")],Yv),Sp(t=>new y_(t)),function(t){t.compile=Ol,t.duplicate=Dl,t.select=tc,t.match=Qa}(Vv||(Vv={})),Li.registerResidents(()=>({componentResidentsCount:Ec.residentsCount,sceneResidentsCount:wu.residentsCount,referenceMapResidentsCount:i_.residentsCount,sceneResidents:Ec.residents}));var Gv=Object.freeze({__proto__:null,AbsoluteLayout:Fc,Animation:Ma,AudioPlayer:pm,BULGE_EPSILON:qs,get Banner(){return Z_},Banner3D:Q_,BoxSelectionManager:Zp,COMMON_PLACEHOLDER_PROPERTIES:Rg,CORE_PLACEHOLDER_TYPES:Ng,get Camera(){return iv},Camera3D:nv,CameraBookmarkManager:Qp,CameraManager:Lp,Capacity:fy,CapacityEventTracker:Km,CardLayout:Hc,CenteringQueueStrategy:Zm,CenteringSlotStrategy:Ib,Component:Ec,Connectable:bf,Container:yg,ContainerAbstract:ql,ControlsManager:Hp,get Cube(){return U_},Cube3D:W_,get Cylinder(){return $_},Cylinder3D:q_,DEFAULT:Kr,DEFAULT_PLACEMENT:Gd,DPPX:Xr,DataLagTracker:Jl,DataSource:Ym,Donut:Dm,DonutExtrude:I_,Ellipse:zg,EllipseExtrude:P_,EventManager3D:Bp,EventMap:pl,FPS:hp,FixedSlotStrategy:dy,get FloorPlate(){return fv},FlowEngine:wb,FlowNode:Mb,GESTURES:qr,get GLTFObject(){return sv},GLTF_BASE_URL_ALIAS:Gm,GenericObject:Fg,GifView:dm,GizmoManager:Vp,GizmoOperationManager:Up,GlobalRef:xm,GltfComponent:Um,GridStacking:ey,Group:mm,HTMLAbsoluteLayout:jc,HTMLOverlayContainer:_m,HTMLOverlayElement:Jg,Holdable:Sb,ImageView:Zg,InfoWindow:Ic,InteractionManager:Xp,ItemsDataBinding:hy,KEYEVENTS:$r,Layer:Yu,Layout:Lc,LightManager:Fp,LightObject:av,Line:Og,Line3D:Ov,LinearHorizontalLayout:Yc,LinearVerticalLayout:Gc,LoadTracker:nh,LoadingOverlay:Pd,LocalRef:bm,MATERIAL_PRESETS:vd,MAX_UNDO_SIZE:30,MODE_ADD:3,MODE_EDIT:1,MODE_PASTE_DATABIND:5,MODE_PASTE_STYLE:4,MODE_SHIFT:2,MODE_VIEW:0,get Model(){return Vv},MoveHandle:Ul,NOTHING:Fr,NavGraph:Hb,Node:jm,OrthoLine:Kg,OrthoLine3D:zv,PIXEL_RATIO:dp,PLACEHOLDER_THEMES:Ig,Path:Em,PatternStacking:ty,PlacementManager:qp,get PointLight(){return cv},Polygon:Vg,PolygonContainer:Wg,PolygonExtrude:z_,PolygonPathPolyline:Xb,Polyline:qg,Polyline3D:Dv,Popup:Mm,PopupContainer:Am,Pose6DOF:_l,RealObject:Zd,RealObjectCamera:Lv,RealObjectDomElement:_p,RealObjectDomTexture:y_,RealObjectDummy:Iv,RealObjectExternalModel:Jd,RealObjectExtrude:T_,RealObjectGLTF:iu,RealObjectGroup:_v,RealObjectLine:Pv,RealObjectMesh:b_,RealObjectPlane:jv,RealObjectPlane2D:Hv,RealObjectScene:Fv,RealObjectService:Fm,RealObjectSprite:H_,RealObjectSprite2D:B_,RealObjectText:k_,Rect:xf,RectExtrude:O_,RectPath:Pc,ReferenceMap:i_,RendererManager:jp,ReservationTable:Fb,RootContainer:Zl,Ruler:Sf,SCALE_MIN:Od,SCENE_MODE:Wr,Scene:wu,SceneManager:Rp,ScenePopup:Bu,SceneSearchEngine:su,ScriptLoader:h_,SearchOverlay:au,ServiceComponent:Hm,Shape:Cc,get Sphere(){return N_},Sphere3D:F_,get Sprite(){return V_},Star:Rm,StarExtrude:L_,TRANSFER_SLOT_KEY:cy,TableLayout:Wc,Text:fm,ThreeCapability:sf,get ThreeContainer(){return Yv},ThreeDOnly:Vm,Tracker:lu,Transfer:bu,TransitionEffect:Wl,Triangle:Tm,TriangleExtrude:R_,UNIT_DIMENSION:Id,UNIT_ROTATE:jd,UNIT_SCALE:Rd,UNIT_TRANSLATE:Ld,ValueHolder:Bm,VertexGizmoManager:rf,VolumeStacking:ny,get Wall(){return dv},Wall3D:hv,Z_PRIORITY:Ud,allDestinations:lb,anchorsConnect:vy,animate:Sa,applyAlpha:Dd,applyMaterial3dProps:Md,applyPolicy:ub,applySeatingRotation:ay,applyStackLayout:iy,applyZPriorityToMaterials:qd,arcSegmentTopology:by,autoWireBackPressure:Qm,buildArrow3D:yp,buildContractInspector:Jb,buildFlowGraph:ky,buildNavGraph:Vb,buildShapeFromPolygonPath:D_,buildTether:Du,bulgeFromDrag:Zs,bulgeHandlePosition:Qs,canReach:Py,capability:ng,chooseNearestPickupFrame:zb,clearTether:Iu,collectAdjacentSegments:Ry,compile:Aa,componentForNode:cb,computeArcParams:Ks,computeFlowMap:Ky,computeStackPositions:Jm,cornerHandlePosition:to,cornerRadiusFromDrag:eo,create:Mu,createCanvas:up,createCanvasTexture:p_,createFloor:Dp,createRealObjectFor:Mp,createSelectionHandle3D:gv,dataLagTracker:th,debug:Ji,deliversInto:Sy,delta:xa,disposeObject3D:Hd,disposeTether:Ru,downstream:gb,drawTextTexture:x_,effectiveCornerRadius:Js,enumerateDataScenarios:Ny,error:Qi,filterByToolType:Db,findNearestStationHost:Jy,flattenPolygonPath:qb,flowGraphFor:ob,flowGraphIssues:sb,flowReverseFor:Qy,fontStyle:__,footprint2D:ry,frameClock:Rs,ftId:Uy,ftrace:Wy,getAllCapabilityMeta:og,getCapabilityMeta:sg,getPose:Ml,getWorldPose:kl,globalSimClock:zs,gltfNatureProperties:Wm,graphFor:_b,hasArc:$s,hasCapacity:qm,inferCapacity:$m,inferDownstreamId:Ly,inferFlowDirections:Gy,initFontFamilyWatcher:Zr,inspector:kd,installContractInspector:t_,isFlowNode:kb,isGenericPlaceholder:Hg,isRoutingTarget:tb,isStateDriven:Wd,isStationHost:Zy,matchOutbounds:My,metrics:Li,next:fb,nextHop:Ty,nextHops:Cy,nextHopsToAny:Dy,nextHopsToAnyDetailed:zy,nodeIdOf:hb,opaqueColor:zd,pickWeightedDestination:xb,planPathAStar:Gb,planToReservations:Wb,pointInRotatedRect:xy,polygonOffsetForPriority:Xd,polygonPathLength:$b,projectToScreen:Cu,quatFromYaw:Eb,rayAbsDistanceToRect:wy,reachableByOutbound:Ay,reachableDestinations:mb,reachableDestinationsFrom:yb,reachableDestinationsWeightedFrom:bb,reachableSinks:Oy,receiptToJSON:mu,recommendsLogarithmicDepthForSky:Ip,rectFaceAnchors:gy,rectangularFootprintFrames:Pb,registerCapabilityMeta:rg,registerDefaultRealObjectFactory:Sp,registerRealObjectFactory:wp,renderCanvasTexture:f_,renderPlaceholder:Lg,reservationTable:Nb,resolveAnchorWorldPosition:Ou,resolveMaterial3d:xd,resolveNextHop:pb,sceneComponent:Xm,setPose:Al,setWorldPose:El,sinksForDestination:ab,standardYieldPolicy:jb,stopFPSMeasure:lp,straightSegmentEndpoints:yy,straightSegmentMultiInbound:_y,straightSegmentTopology:my,textBounds:M_,textTexture:w_,toThreeSide:Sd,topApproachFrame:Ob,transferLog:_u,transferTracer:fu,uniformZ:no,updateDefaultFontFamily:Qr,updateTether:zu,validate:vb,validateFlowGraph:Iy,version:d_,warn:Zi});const Wv=globalThis;"undefined"==typeof globalThis||Wv.scene||(Wv.scene=Gv);export{Fc as AbsoluteLayout,Ma as Animation,pm as AudioPlayer,qs as BULGE_EPSILON,Z_ as Banner,Q_ as Banner3D,Zp as BoxSelectionManager,Rg as COMMON_PLACEHOLDER_PROPERTIES,Ng as CORE_PLACEHOLDER_TYPES,iv as Camera,nv as Camera3D,Qp as CameraBookmarkManager,Lp as CameraManager,fy as Capacity,Km as CapacityEventTracker,Hc as CardLayout,Zm as CenteringQueueStrategy,Ib as CenteringSlotStrategy,Ec as Component,bf as Connectable,yg as Container,ql as ContainerAbstract,Hp as ControlsManager,U_ as Cube,W_ as Cube3D,$_ as Cylinder,q_ as Cylinder3D,Kr as DEFAULT,Gd as DEFAULT_PLACEMENT,Xr as DPPX,Jl as DataLagTracker,Ym as DataSource,Dm as Donut,I_ as DonutExtrude,zg as Ellipse,P_ as EllipseExtrude,Bp as EventManager3D,pl as EventMap,hp as FPS,dy as FixedSlotStrategy,fv as FloorPlate,wb as FlowEngine,Mb as FlowNode,qr as GESTURES,sv as GLTFObject,Gm as GLTF_BASE_URL_ALIAS,Fg as GenericObject,dm as GifView,Vp as GizmoManager,Up as GizmoOperationManager,xm as GlobalRef,Um as GltfComponent,ey as GridStacking,mm as Group,jc as HTMLAbsoluteLayout,_m as HTMLOverlayContainer,Jg as HTMLOverlayElement,Sb as Holdable,Zg as ImageView,Ic as InfoWindow,Xp as InteractionManager,hy as ItemsDataBinding,$r as KEYEVENTS,Yu as Layer,Lc as Layout,Fp as LightManager,av as LightObject,Og as Line,Ov as Line3D,Yc as LinearHorizontalLayout,Gc as LinearVerticalLayout,nh as LoadTracker,Pd as LoadingOverlay,bm as LocalRef,vd as MATERIAL_PRESETS,Ur as MAX_UNDO_SIZE,Yr as MODE_ADD,Hr as MODE_EDIT,Gr as MODE_PASTE_DATABIND,Vr as MODE_PASTE_STYLE,Br as MODE_SHIFT,Nr as MODE_VIEW,Vv as Model,Ul as MoveHandle,Fr as NOTHING,Hb as NavGraph,jm as Node,Kg as OrthoLine,zv as OrthoLine3D,dp as PIXEL_RATIO,Ig as PLACEHOLDER_THEMES,Em as Path,ty as PatternStacking,qp as PlacementManager,cv as PointLight,Vg as Polygon,Wg as PolygonContainer,z_ as PolygonExtrude,Xb as PolygonPathPolyline,qg as Polyline,Dv as Polyline3D,Mm as Popup,Am as PopupContainer,_l as Pose6DOF,Zd as RealObject,Lv as RealObjectCamera,_p as RealObjectDomElement,y_ as RealObjectDomTexture,Iv as RealObjectDummy,Jd as RealObjectExternalModel,T_ as RealObjectExtrude,iu as RealObjectGLTF,_v as RealObjectGroup,Pv as RealObjectLine,b_ as RealObjectMesh,jv as RealObjectPlane,Hv as RealObjectPlane2D,Fv as RealObjectScene,Fm as RealObjectService,H_ as RealObjectSprite,B_ as RealObjectSprite2D,k_ as RealObjectText,xf as Rect,O_ as RectExtrude,Pc as RectPath,i_ as ReferenceMap,jp as RendererManager,Fb as ReservationTable,Zl as RootContainer,Sf as Ruler,Od as SCALE_MIN,Wr as SCENE_MODE,wu as Scene,Rp as SceneManager,Bu as ScenePopup,su as SceneSearchEngine,h_ as ScriptLoader,au as SearchOverlay,Hm as ServiceComponent,Cc as Shape,N_ as Sphere,F_ as Sphere3D,V_ as Sprite,Rm as Star,L_ as StarExtrude,cy as TRANSFER_SLOT_KEY,Wc as TableLayout,fm as Text,sf as ThreeCapability,Yv as ThreeContainer,Vm as ThreeDOnly,lu as Tracker,bu as Transfer,Wl as TransitionEffect,Tm as Triangle,R_ as TriangleExtrude,Id as UNIT_DIMENSION,jd as UNIT_ROTATE,Rd as UNIT_SCALE,Ld as UNIT_TRANSLATE,Bm as ValueHolder,rf as VertexGizmoManager,ny as VolumeStacking,dv as Wall,hv as Wall3D,Ud as Z_PRIORITY,lb as allDestinations,vy as anchorsConnect,Sa as animate,Dd as applyAlpha,Md as applyMaterial3dProps,ub as applyPolicy,ay as applySeatingRotation,iy as applyStackLayout,qd as applyZPriorityToMaterials,by as arcSegmentTopology,Qm as autoWireBackPressure,yp as buildArrow3D,Jb as buildContractInspector,ky as buildFlowGraph,Vb as buildNavGraph,D_ as buildShapeFromPolygonPath,Du as buildTether,Zs as bulgeFromDrag,Qs as bulgeHandlePosition,Py as canReach,ng as capability,zb as chooseNearestPickupFrame,Iu as clearTether,Ry as collectAdjacentSegments,Aa as compile,cb as componentForNode,Ks as computeArcParams,Ky as computeFlowMap,Jm as computeStackPositions,to as cornerHandlePosition,eo as cornerRadiusFromDrag,Mu as create,up as createCanvas,p_ as createCanvasTexture,Dp as createFloor,Mp as createRealObjectFor,gv as createSelectionHandle3D,th as dataLagTracker,Ji as debug,Sy as deliversInto,xa as delta,Hd as disposeObject3D,Ru as disposeTether,gb as downstream,x_ as drawTextTexture,Js as effectiveCornerRadius,Ny as enumerateDataScenarios,Qi as error,Db as filterByToolType,Jy as findNearestStationHost,qb as flattenPolygonPath,ob as flowGraphFor,sb as flowGraphIssues,Qy as flowReverseFor,__ as fontStyle,ry as footprint2D,Rs as frameClock,Uy as ftId,Wy as ftrace,og as getAllCapabilityMeta,sg as getCapabilityMeta,Ml as getPose,kl as getWorldPose,zs as globalSimClock,Wm as gltfNatureProperties,_b as graphFor,$s as hasArc,qm as hasCapacity,$m as inferCapacity,Ly as inferDownstreamId,Gy as inferFlowDirections,Zr as initFontFamilyWatcher,kd as inspector,t_ as installContractInspector,kb as isFlowNode,Hg as isGenericPlaceholder,tb as isRoutingTarget,Wd as isStateDriven,Zy as isStationHost,My as matchOutbounds,Li as metrics,fb as next,Ty as nextHop,Cy as nextHops,Dy as nextHopsToAny,zy as nextHopsToAnyDetailed,hb as nodeIdOf,zd as opaqueColor,xb as pickWeightedDestination,Gb as planPathAStar,Wb as planToReservations,xy as pointInRotatedRect,Xd as polygonOffsetForPriority,$b as polygonPathLength,Cu as projectToScreen,Eb as quatFromYaw,wy as rayAbsDistanceToRect,Ay as reachableByOutbound,mb as reachableDestinations,yb as reachableDestinationsFrom,bb as reachableDestinationsWeightedFrom,Oy as reachableSinks,mu as receiptToJSON,Ip as recommendsLogarithmicDepthForSky,gy as rectFaceAnchors,Pb as rectangularFootprintFrames,rg as registerCapabilityMeta,Sp as registerDefaultRealObjectFactory,wp as registerRealObjectFactory,f_ as renderCanvasTexture,Lg as renderPlaceholder,Nb as reservationTable,Ou as resolveAnchorWorldPosition,xd as resolveMaterial3d,pb as resolveNextHop,Xm as sceneComponent,Al as setPose,El as setWorldPose,ab as sinksForDestination,jb as standardYieldPolicy,lp as stopFPSMeasure,yy as straightSegmentEndpoints,_y as straightSegmentMultiInbound,my as straightSegmentTopology,M_ as textBounds,w_ as textTexture,Sd as toThreeSide,Ob as topApproachFrame,_u as transferLog,fu as transferTracer,no as uniformZ,Qr as updateDefaultFontFamily,zu as updateTether,vb as validate,Iy as validateFlowGraph,d_ as version,Zi as warn};
|
|
50
|
+
`,this.element)}catch(t){}}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",24):this.setState("height",this.get("height"))}}pg=new WeakMap,Ec.memoize(yg.prototype,"bounds",!0),Ec.register("container",yg);const bg=Math.sqrt(3),_g=2;function vg(t,e,n,i,r){const s=5+r,o=n.x,a=n.y,c=i.x,l=i.y;if(Math.abs(o-c)>s&&Math.abs(a-l)>s){const n=(l-a)/(c-o),i=a-n*o;if(Math.abs(e-(n*t+i))>s)return!1}let h,d,u,p;return o>c?(d=o,h=c):(d=c,h=o),a>l?(p=a,u=l):(p=l,u=a),!(d+5<t)&&(!(h-5>t)&&(!(p+5<e)&&!(u-5>e)))}function xg(t,e,n,i=2){for(let r=0;r<n.length-1;r++)if(vg(t,e,n[r],n[r+1],i))return!0;return!1}function wg(t,e,n,i){if("arrow"!=t.slice(-5))return n;const r=Math.atan2(i.y-n.y,i.x-n.x),s=1.5*e;return{x:n.x+Math.cos(r)*s,y:n.y+Math.sin(r)*s}}function Sg(t,e,n){let{lineWidth:i=_g,strokeStyle:r="#000000",lineCap:s=!1,alpha:o=1,begin:a="none",end:c="none",beginSize:l="size5",endSize:h="size5"}=n;if(("none"!=a||"none"!=c)&&(i=Number(i)||_g,t.lineCap=s,t.lineWidth=i,t.strokeStyle=r,t.fillStyle=r,t.globalAlpha*=o,"none"!=a&&Mg(t,e[0],e[1],i,a,kg(l,i)),"none"!=c)){const n=e.length;Mg(t,e[n-1],e[n-2],i,c,kg(h,i))}}function Mg(t,e,n,i,r,s){const{x:o,y:a}=e,c=Math.atan2(n.y-a,n.x-o);switch(t.beginPath(),t.translate(o,a),t.rotate(c),r){case"oval":t.ellipse(0,0,s.X,s.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-s.X,0),t.lineTo(0,-s.Y),t.lineTo(s.X,0),t.lineTo(0,s.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(bg*s.X,-s.Y),t.lineTo(bg*s.X,s.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(bg*s.X,-s.Y),t.lineTo(-s.X/1.5+bg*s.X,0),t.lineTo(bg*s.X,s.Y),t.fill();break;case"open-arrow":t.moveTo(bg*s.X+i,-s.Y),t.lineTo(i,0),t.lineTo(bg*s.X+i,s.Y),t.stroke();break;case"cross":t.moveTo(-s.X,-s.Y),t.lineTo(s.X,s.Y),t.moveTo(s.X,-s.Y),t.lineTo(-s.X,s.Y),t.stroke()}t.rotate(-c),t.translate(-o,-a),t.closePath()}function kg(t,e){const n={X:0,Y:0};switch(e*=1.2,t){case"size1":n.X=e,n.Y=e;break;case"size2":n.X=1.5*e,n.Y=e;break;case"size3":n.X=2*e,n.Y=e;break;case"size4":n.X=e,n.Y=1.5*e;break;case"size5":default:n.X=1.5*e,n.Y=1.5*e;break;case"size6":n.X=2*e,n.Y=1.5*e;break;case"size7":n.X=e,n.Y=2*e;break;case"size8":n.X=1.5*e,n.Y=2*e;break;case"size9":n.X=2*e,n.Y=2*e}return n}const Ag="N",Eg="S",Cg="E",Tg="W";class Pg{constructor({component:t,anchor:e,position:n,self:i}){this.component=t,this._anchorName=e,this._position=n,this.self=i}get position(){const t=this.anchor;if(t){const{position:e}=t,n=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(n.x,n.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Cg;const n=e.position;return n.y<=t.top?Ag:n.y>=t.top+t.height?Eg:n.x<=t.left?Tg:Cg}get boundaryPosition(){const t=this.anchor;if(t){let{position:e}=t,n=0,i=0;switch(this.direction){case Eg:i=20;break;case Ag:i=-20;break;case Tg:n=-20;break;default:n=20}e={x:e.x+n,y:e.y+i};const r=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}}}class Og extends Ec{isLine(){return!0}is3dish(){return!0}replaceRefids(t){["from","to"].forEach(e=>{const n=this.get(e);if(n?.component){const i=t.get(n.component)||n.component;this.set(e,{...n,component:i})}})}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:n}=this.getState("from")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._fromEnd=new Pg({component:i,fromto:"from",anchor:e,position:n,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:n}=this.getState("to")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._toEnd=new Pg({component:i,fromto:"to",anchor:e,position:n,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},n){n&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e})}render(t){const{begin:e="none",end:n="none",lineWidth:i,round:r=0}=this.state;let s=this.drawPath;Sg(t,s,this.state),t.beginPath();const o=wg(e,i,s[0],s[1]),a=wg(n,i,s[s.length-1],s[s.length-2]),c=s[0];s=[o,...s.slice(1,-1),a];let l={x:o.x,y:o.y};if(t.moveTo(o.x,o.y),s.length>=2&&$s(c)){const e=s[1],n=Js(e,r),i=Math.sqrt((o.x-e.x)**2+(o.y-e.y)**2),a=0!==i?Math.atan2(o.x-e.x,o.y-e.y):0,l=Math.sin(a)*Math.min(n,i/2)+e.x,h=Math.cos(a)*Math.min(n,i/2)+e.y,d=Ks({x:o.x,y:o.y},{x:l,y:h},c.bulge);d&&t.arc(d.cx,d.cy,d.radius,d.startAngle,d.endAngle,d.clockwise)}for(let e=1;e<s.length;e++){const n=l;l=s[e];const i=s[e+1];if(n.x===l.x&&n.y===l.y)continue;if(!i){t.lineTo(l.x,l.y);break}const o=Js(l,r);let a=Math.sqrt((n.x-l.x)*(n.x-l.x)+(n.y-l.y)*(n.y-l.y)),c=0!==a?Math.atan2(n.x-l.x,n.y-l.y):0,h=Math.sin(c)*Math.min(o,a/2)+l.x,d=Math.cos(c)*Math.min(o,a/2)+l.y;const u=o>0||0!==a?{x:h,y:d}:l;a=Math.sqrt((i.x-l.x)*(i.x-l.x)+(i.y-l.y)*(i.y-l.y)),c=0!==a?Math.atan2(i.x-l.x,i.y-l.y):0,h=Math.sin(c)*Math.min(o,a/2)+l.x,d=Math.cos(c)*Math.min(o,a/2)+l.y;const p=o>0||0!==a?{x:h,y:d}:l;if(t.lineTo(u.x,u.y),o>0&&t.quadraticCurveTo(l.x,l.y,p.x,p.y),$s(l)){const e=Js(i,r),n=Math.sqrt((l.x-i.x)**2+(l.y-i.y)**2),s=0!==n?Math.atan2(l.x-i.x,l.y-i.y):0,o=Math.sin(s)*Math.min(e,n/2)+i.x,a=Math.cos(s)*Math.min(e,n/2)+i.y,c=Ks({x:p.x,y:p.y},{x:o,y:a},l.bulge);c&&t.arc(c.cx,c.cy,c.radius,c.startAngle,c.endAngle,c.clockwise)}}this.drawStroke(t,void 0)}contains(t,e){const{lineWidth:n}=this.state;return xg(t,e,this.drawPath,n)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state,{x1:n,y1:i,x2:r,y2:s}=this.state;return[this.fromEnd?.position||t?.position||{x:n,y:i},this.toEnd?.position||e?.position||{x:r,y:s}]}set path(t){const[e,n]=t,{from:i,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...i,position:e},to:{...r,position:n}})}get textBounds(){const t=this.drawPath;let e,n,i=0;for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=(s.x-o.x)*(s.x-o.x)+(s.y-o.y)*(s.y-o.y);a>i&&(i=Math.ceil(a),e=s,n=o)}let{paddingTop:r,paddingLeft:s,paddingRight:o,paddingBottom:a}=this.state;return a||=0,r||=0,s||=0,o||=0,{left:Math.min(e.x,n.x)+s,top:Math.min(e.y,n.y)+r,width:Math.max(Math.abs(e.x-n.x)-s-o,0),height:Math.max(Math.abs(e.y-n.y)-r-a,0)}}get decorators(){return this.app.isEditMode?["decotag"]:[]}}Og.getTipNeckPos=wg,Og.containedInPath=xg,Og.drawEndTips=Sg,Ec.register("line",Og);const Dg={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class zg extends(bf(Cc)){is3dish(){return!0}render(t){const{cx:e,cy:n,rx:i,ry:r,startAngle:s,endAngle:o,anticlockwise:a}=this.state;t.beginPath(),t.ellipse(e,n,Math.abs(i),Math.abs(r),0,s||0,o||2*Math.PI,a),void 0!==s&&void 0!==o&&(t.lineTo(e,n),t.closePath())}get path(){const{cx:t,cy:e,rx:n,ry:i}=this.state;return[{x:t-n,y:e-i},{x:t+n,y:e-i},{x:t+n,y:e+i},{x:t-n,y:e+i}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2,rx:(n.x-e.x)/2,ry:(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i,rx:r,ry:s}=this.state,o=(t-n)/(2*r-.5),a=(e-i)/(2*s-.5);return o*o+a*a<.25}outline(t){return function(t,e){const{cx:n,cy:i,rx:r,ry:s}=t.model,o=2*Math.PI*e,a=n+r*Math.cos(o),c=i+s*Math.sin(o);return t.toScene(a,c)}(this,t)}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return Dg}}Ec.memoize(zg.prototype,"path",!1),Ec.register("ellipse",zg);const Ig={object:{fill:"rgba(180,180,180,0.18)",stroke:"#888888",icon:"?",label:"object"},transport:{fill:"rgba(100,180,255,0.18)",stroke:"#3a78c8",icon:"⇄",label:"transport"},facility:{fill:"rgba(160,140,220,0.18)",stroke:"#6b4ec8",icon:"◫",label:"facility"},vehicle:{fill:"rgba(120,200,140,0.18)",stroke:"#3a8c5e",icon:"⊙",label:"vehicle"},region:{fill:"rgba(220,200,100,0.18)",stroke:"#a0892a",icon:"▢",label:"region"},path:{fill:"rgba(200,140,160,0.18)",stroke:"#a0506a",icon:"⌐",label:"path"},"3d-asset":{fill:"rgba(255,180,80,0.18)",stroke:"#c87a2a",icon:"◈",label:"3D asset"}},Rg=[{type:"string",label:"placeholder-label",name:"placeholderLabel",description:'사용자에게 표시할 추가 라벨 (예: "Stocker A1")'},{type:"string",label:"hint",name:"placeholderHint",description:"구체화 시 참고 — 도면의 원본 식별자 / VLM 라벨 등"}];function Lg(t,e,n,i,r){const{left:s,top:o,width:a,height:c}=e,l=Math.max(a,1),h=Math.max(c,1);t.save(),t.fillStyle=n.fill,t.fillRect(s,o,l,h),t.strokeStyle=n.stroke,t.lineWidth=1.5,t.setLineDash([4,3]),t.strokeRect(s,o,l,h),t.setLineDash([]),t.restore(),Math.min(l,h)>=24&&(t.save(),t.fillStyle=n.stroke,t.font=`bold ${Math.min(20,.4*Math.min(l,h))}px Arial`,t.textAlign="center",t.textBaseline="middle",t.fillText(n.icon,s+l/2,o+h/2),t.restore());const d=i?`${n.label}: ${i}`:n.label;h>=32&&(t.save(),t.fillStyle=n.stroke,t.font="10px Arial",t.textAlign="center",t.textBaseline="bottom",t.fillText(d,s+l/2,o+h-4),t.restore()),r&&h>=40&&(t.save(),t.fillStyle=n.stroke,t.font="9px Arial",t.textAlign="right",t.textBaseline="top",t.fillText(`hint: ${r}`,s+l-4,o+4),t.restore())}const jg={mutable:!1,resizable:!0,rotatable:!0,properties:[...Rg,{type:"placeholder-convert",label:"",name:"_convert"}],help:"scene/component/placeholder"};class Fg extends(Pc(Cc)){get nature(){return jg}render(t){const{placeholderLabel:e,placeholderHint:n}=this.state;Lg(t,this.bounds,Ig.object,e,n)}}Ec.register("placeholder",Fg);const Ng=["placeholder"];function Hg(t,e=[]){return!!t&&(!!Ng.includes(t)||e.includes(t))}const Bg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e+1,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){const i=n[e+1];n[e+1]={...i||{},x:t.x,y:t.y}})},ondragend:function(t,e,n){}},Yg={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class Vg extends Cc{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get cornerEditable(){return!0}get path(){return this.state.path??[]}set path(t){this.set("path",t)}contains(t,e){const n=this.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}get controls(){const t=this.path;return t.map((e,n)=>{const i=t[n+1>=t.length?0:n+1];return{x:(e.x+i.x)/2,y:(e.y+i.y)/2,handler:Bg}})}get nature(){return Yg}}Ec.memoize(Vg.prototype,"controls",!1),Ec.register("polygon",Vg);const Gg=[];class Wg extends(Ul(Vg)){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach(e=>e.replaceRefids(t))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach(t=>t.dispose()),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return Lc.get(this.get("layout"))||Fc}reflow(){this.layout.reflow(this),this.components&&this.components.forEach(t=>{t.isContainer()&&t.reflow()})}get hierarchy(){const t=super.hierarchy;return this.components?.length&&(t.components=this.components.map(t=>t.hierarchy)),t}reparent(t,e={}){t&&t.parent!==this&&this.addComponent(t,{silent:!0})}addComponent(t,e=!1){const{ghost:n=!1,silent:i=!1}="boolean"==typeof e?{ghost:e}:e,r=t.parent;if(r){if(this===r)return;r.removeComponent(t,n||i)}const s=this._components.push(t)-1;i&&(t._silentAdd=!0),t.parent=this,t.added(this),n||i||this.trigger("add",this,t,s),t.delegate_on(this),i?(r&&this.root?._removeTraverse?.(t),this.trigger("add",this,t,s),t.trigger("added",this,t,s),delete t._silentAdd):n||t.trigger("added",this,t,s),this.root&&this.root.isReady&&t.invokeReady()}removeComponent(t,e=!1){const n=this._components.indexOf(t);-1!=n&&(this._components.splice(n,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,n=!1){const i=t.parent;i&&i.removeComponent(t,n);const r=this._components.splice(0,e);this._components=r.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),n||this.trigger("add",this,t,e),t.delegate_on(this),n||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach(t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)}),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach(t=>this.removeComponent(t,e)),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach(n=>{n.isContainer()?n.traverse(t,e):t.call(e,n)})}indexOf(t){return(this._components||Gg).indexOf(t)}size(){return(this._components||Gg).length}moveChildAt(t,e){const n=this.indexOf(e);if(-1==n)return;let i=this._components.splice(0,n);const r=this._components.splice(1);this._components=i.concat(r),t=Math.max(0,t),t=Math.min(t,this._components.length),i=this._components.splice(0,t),this._components=i.concat(e,this._components)}moveChildForward(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=n.concat(i,this._components)}moveChildToBack(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=this._components.concat(n,i)}symmetryX(t){super.symmetryX(t),this.components.map(t=>{t.symmetryX(0)})}findAll(t,...e){if("string"==typeof t)return tc(t,this,e[0]||this);if("function"!=typeof t)return[];let n=[];for(let i=this.components.length-1;i>=0;i--){const r=this.components[i].findAll(t,...e);r&&(n=n.concat(r))}return t(this,...e)&&n.push(this),n}findFirst(t,...e){if("string"==typeof t)return tc(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){const i=this.components[n].findFirst(t,...e);if(null!=i)return i}return t(this,...e)?this:void 0}}findById(t){return this.root.findAllById?.(t)?.[0]}findByRefid(t){return this.root.findByRefid?.(t)}capture(t,e,n){if(!this.app.isEditMode&&this.hidden)return!1;const i=this.fromParent(t,e);if(!this.contains(i.x,i.y))return!1;const r=this.bounds;i.x-=r.left,i.y-=r.top;const s=this.layout.capturables(this);for(let r=s.length-1;r>=0;r--){const o=s[r];let a;if(a="static"==o.position?o.capture(i.x,i.y,n):o.capture(t,e,n),a)return a}return this.capturable&&!n?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}const n=[],{left:i,top:r,width:s,height:o}=this.bounds;for(let e=0;e<t.length;e++){const a=this.fromParent(t[e].x,t[e].y);if(a.x<i||a.x>i+s||a.y<r||a.y>r+o)return!1;a.x-=i,a.y-=r,n.push(a)}const a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){const i=a[t];if(!i.isContainer())continue;const r=i.capturePath(n,e);if(r)return r}return this.focusible&&this}render(t){"popup"!==this.position&&super.render(t)}postrender(t){if("popup"===this.position)return void super.postrender(t);const e=this.layout.drawables(this);if(e.length>0){let{left:n=0,top:i=0,width:r,height:s}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(n,i,r,s),t.clip(),t.closePath()),t.translate(n,i),e.forEach(e=>{const n=this.root?.transitionEffect;n?.isReparenting(e)||e.draw(this.position&&"static"!==this.position?t:this.getContext(e))}),t.translate(-n,-i),t.restore()}super.postrender(t)}trim(){this.components.forEach(t=>{t.trim()}),super.trim()}}["layout"].forEach(t=>Ec.memoize(Wg.prototype,t,!1));const Ug={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){const i=n[e];n[e]={...i||{},x:t.x,y:t.y}})},ondragend:function(t,e,n){}},Xg={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class qg extends Og{get pathExtendable(){return!0}get cornerEditable(){return!0}get path(){const{from:t,to:e}=this.state,{path:n}=this.state;return[this.fromEnd?.position||t?.position||n[0],...n.slice(1,-1),this.toEnd?.position||e?.position||n[n.length-1]]}set path(t){const{from:e,to:n}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...n,position:t[t.length-1]},path:t})}get controls(){const t=this.path,e=[];for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];0==n&&e.push({x:i.x,y:i.y,handler:Ug}),e.push({x:(i.x+r.x)/2,y:(i.y+r.y)/2,handler:Ug}),n==t.length-2&&e.push({x:r.x,y:r.y,handler:Ug})}return e}get nature(){return Xg}}Ec.register("polyline",qg);const $g={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class Kg extends Og{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:n,direction:i,boundaryPosition:r=t}=this.fromEnd||{},{component:s,direction:o,boundaryPosition:a=e}=this.toEnd||{},c=[r,a],l=[];r&&l.push(r);let h,d=n?.bounds;d&&(h=n.toScene(d.left,d.top),h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y});const u=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:r.x,top:r.y,width:0,height:0};d=d||u;let p=s?.bounds;p&&(h=s.toScene(p.left,p.top),h=this.transcoordT2P(h.x,h.y),p={...p,left:h.x,top:h.y});const f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:a.x,top:a.y,width:0,height:0};p=p||f;const g=[u,f],m=u.left>f.left?f.left:u.left,y=u.top>f.top?f.top:u.top,b={left:m,top:y,width:u.left+u.width>f.left+f.width?u.left+u.width-m:f.left+f.width-m,height:u.top+u.height>f.top+f.height?u.top+u.height-y:f.top+f.height-y};let _,v,x,w,S,M,k,A,E,C,T=0,P=0;d.left+d.width<p.left?(w=0,S=1,E=i,C=o,_=(d.left+d.width+p.left)/2,T=p.left-_):p.left+p.width<d.left&&(w=1,S=0,E=o,C=i,_=(d.left+p.width+p.left)/2,T=d.left-_),d.top+d.height<p.top?(x=0,M=1,k=i,A=o,v=(d.top+d.height+p.top)/2,P=p.top-v):p.top+p.height<d.top&&(x=1,M=0,k=o,A=i,v=(d.top+p.height+p.top)/2,P=d.top-v);const O=[];if(_&&T>P){let t,e,n;switch(C){case Tg:switch(E){case Cg:O.push({x:_,y:c[w].y}),O.push({x:_,y:c[S].y});break;case Tg:t=g[w].top+g[w].height/2,e=t>c[S].y?Math.min(g[w].top,c[S].y):Math.max(g[w].top+g[w].height,c[S].y),O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:c[S].y});break;case Ag:case Eg:e=E===Eg?Math.max(c[w].y,c[S].y):Math.min(c[w].y,c[S].y),O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:c[S].y});break;default:return this.path}break;case Cg:switch(E){case Cg:e=c[w].y<c[S].y?Math.min(g[S].top,c[w].y):Math.max(g[S].top+g[S].height,c[w].y),n=e;break;case Tg:e=void 0!==v?v:c[w].y<c[S].y?b.top-.5*T:b.top+b.height+.5*T,n=e;break;case Eg:e=void 0!==v?Math.max(v,c[w].y):b.top+b.height,n=e;break;case Ag:e=v?Math.min(v,g[w].top):b.top,n=e;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;case Eg:switch(E){case Cg:e=c[w].y,n=c[w].y>c[S].y?c[w].y:g[S].top+g[S].height;break;case Tg:e=v?Math.max(v,g[S].top+g[S].height):b.top+b.height,n=e;break;case Eg:e=b.top+b.height,n=e;break;case Ag:e=v?Math.min(v,g[w].top):g[w].top,n=v?Math.max(v,g[S].top+g[S].height):g[S].top+g[S].height;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;case Ag:switch(E){case Cg:e=c[w].y,n=c[w].y<c[S].y?c[w].y:g[S].top;break;case Tg:e=v?Math.min(v,g[S].top):b.top,n=e;break;case Eg:e=void 0!==v?Math.max(v,c[w].y):c[w].y,n=void 0!==v?Math.min(v,c[S].y):c[S].y;break;case Ag:e=b.top,n=e;break;default:return this.path}O.push({x:c[w].x,y:e}),O.push({x:_,y:e}),O.push({x:_,y:n}),O.push({x:c[S].x,y:n});break;default:return this.path}l.push(...0===w?O:O.reverse())}else if(v){let t,e,n;switch(A){case Ag:switch(k){case Eg:O.push({x:c[x].x,y:v}),O.push({x:c[M].x,y:v});break;case Ag:t=g[x].left+g[x].width/2,e=t>c[M].x?Math.min(g[x].left,c[M].x):Math.max(g[x].left+g[x].width,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;case Tg:e=Math.min(c[x].x,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;case Cg:e=Math.max(c[x].x,c[M].x),O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:c[M].x,y:v});break;default:return this.path}break;case Eg:switch(k){case Tg:e=b.left,n=e;break;case Cg:e=void 0!==_?Math.max(_,c[x].x):b.left+b.width,n=e;break;case Ag:e=void 0!==_?_:c[x].x<c[M].x?b.left-.5*P:b.left+b.width+.5*P,n=e;break;case Eg:e=c[x].x,n=c[x].x<c[M].x?Math.min(g[M].left,c[x].x):Math.max(g[M].left+g[M].width,c[x].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;case Cg:switch(k){case Tg:e=void 0!==_?Math.min(_,c[x].x):c[x].x,n=void 0!==_?Math.max(_,c[M].x):c[M].x;break;case Cg:e=b.left+b.width,n=e;break;case Ag:e=void 0!==_?Math.max(_,c[M].x):b.left+b.width,n=e;break;case Eg:e=c[x].x,n=Math.max(g[M].left+g[M].width,c[x].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;case Tg:switch(k){case Tg:e=b.left,n=e;break;case Cg:e=void 0!==_?Math.max(_,c[x].x):c[x].x,n=void 0!==_?Math.min(_,c[M].x):c[M].x;break;case Ag:e=b.left,n=e;break;case Eg:e=c[x].x<c[M].x?Math.min(g[M].left,c[x].x):c[x].x,n=Math.min(e,c[M].x);break;default:return this.path}O.push({x:e,y:c[x].y}),O.push({x:e,y:v}),O.push({x:n,y:v}),O.push({x:n,y:c[M].y});break;default:return this.path}l.push(...0===x?O:O.reverse())}else{let t,e;switch(i){case Ag:switch(o){case Ag:e=b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Eg:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top+b.height}),l.push({x:c[1].x,y:b.top+b.height});break;case Cg:t=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;case Tg:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case Eg:switch(o){case Ag:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top}),l.push({x:c[1].x,y:b.top});break;case Eg:case Cg:case Tg:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;case Tg:switch(o){case Ag:t=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:b.left,e=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(b.top,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case Eg:t=b.left,e=Math.max(b.top+b.height,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case Cg:t=b.left+b.width,l.push({x:c[0].x,y:b.top}),l.push({x:t,y:b.top}),l.push({x:t,y:c[1].y});break;case Tg:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case Cg:switch(o){case Ag:e=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Eg:e=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case Cg:case Tg:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;default:return this.path}}return a&&l.push(a),[t,...l,e].filter((t,e,n)=>{if(0===e)return!0;const i=n[e-1];return t.x!==i.x||t.y!==i.y}).filter((t,e,n)=>{if(0===e||e>=n.length-1)return!0;const i=n[e-1],r=n[e+1];return!(t.x===i.x&&t.x===r.x||t.y===i.y&&t.y===r.y)})}get nature(){return $g}}Ec.register("ortholine",Kg);const Qg={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class Zg extends(Pc(Cc)){static get noimage(){return Zg.NOIMAGE||(Zg.NOIMAGE=new Image,Zg.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Zg.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){const{left:e,top:n,width:i,height:r,isGray:s=!1,alpha:o=1,src:a}=this.state;if(this.prepareIf(!this._image&&a),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(s&&this._offcanvas)t.drawImage(this._offcanvas,e,n,i,r);else try{t.drawImage(this._image,e,n,i,r)}catch(s){t.drawImage(Zg.noimage,e,n,i,r)}else!this.app.isViewMode&&t.drawImage(Zg.noimage,e,n,i,r)}get nature(){return Qg}get hasTextProperty(){return!1}async ready(){await super.ready();const{src:t}=this.state;if(!this._image&&t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((t,e)=>{this.prepare(()=>t(),t=>e(t))});e.track(`image:${t}`,"image",t,n)}else this.prepareIf(!0)}}prepare(t,e){const{src:n,crossOrigin:i}=this.state;if(n){this._image=new Image;try{i&&(this._image.crossOrigin=i),this._image.src=this.app.url(n)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){const t=this._image.width,e=this._image.height;this._offcanvas=Ec.createCanvas(t,e);const n=this._offcanvas.getContext("2d");n.drawImage(this._image,0,0);const i=function(t,e,n){let i;try{i=t.getImageData(0,0,e,n)}catch(t){return Qi("Get Image Data Error: "+(t instanceof Error?t.message:String(t))),null}const r=i.data;for(let t=0;t<e*n*4;t+=4){const e=r[t],n=r[t+1],s=r[t+2],o=Math.floor((e+n+s)/3);i.data[t]=o,i.data[t+1]=o,i.data[t+2]=o}return i}(n,t,e);n.putImageData(i,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void(this.src=e[n])}}Ec.register("image-view",Zg);class Jg extends(ug(Pc(Ec))){is3dish(){return!0}prerender(){}}var tm,em,nm={},im={},rm={};function sm(){if(em)return im;em=1,Object.defineProperty(im,"__esModule",{value:!0});var t=function(){if(tm)return rm;tm=1,Object.defineProperty(rm,"__esModule",{value:!0});var t=function(){function t(){}return t.bitsToNum=function(t){return t.reduce(function(t,e){return 2*t+e},0)},t.byteToBitArr=function(t){for(var e=[],n=7;n>=0;n--)e.push(!!(t&1<<n));return e},t.lzwDecode=function(t,e){for(var n,i,r=0,s=function(t){for(var n=0,i=0;i<t;i++)e.charCodeAt(r>>3)&1<<(7&r)&&(n|=1<<i),r++;return n},o=[],a=1<<t,c=a+1,l=t+1,h=[],d=function(){h=[],l=t+1;for(var e=0;e<a;e++)h[e]=[e];h[a]=[],h[c]=null};;)if(i=n,(n=s(l))!==a){if(n===c)break;if(n<h.length)i!==a&&h.push(h[i].concat(h[n][0]));else{if(n!==h.length)throw new Error("Invalid LZW code.");h.push(h[i].concat(h[i][0]))}o.push.apply(o,h[n]),h.length===1<<l&&l<12&&l++}else d();return o},t}();return rm.SuperGifUtils=t,rm}(),e=function(){function e(t,e){this.stream=t,this.handler=e}return e.prototype.parseCT=function(t){for(var e=[],n=0;n<t;n++)e.push(this.stream.readBytes(3));return e},e.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},e.prototype.parseHeader=function(){var e={};if(e.sig=this.stream.read(3),e.ver=this.stream.read(3),"GIF"!==e.sig)throw new Error("Not a GIF file.");e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.gctFlag=n.shift(),e.colorRes=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.sorted=n.shift(),e.gctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.bgColor=this.stream.readByte(),e.pixelAspectRatio=this.stream.readByte(),e.gctFlag&&(e.gct=this.parseCT(1<<e.gctSize+1)),this.handler.hdr&&this.handler.hdr(e)},e.prototype.parseExt=function(e){var n=this;switch(e.label=this.stream.readByte(),e.label){case 249:e.extType="gce",function(e){n.stream.readByte();var i=t.SuperGifUtils.byteToBitArr(n.stream.readByte());e.reserved=i.splice(0,3),e.disposalMethod=t.SuperGifUtils.bitsToNum(i.splice(0,3)),e.userInput=i.shift(),e.transparencyGiven=i.shift(),e.delayTime=n.stream.readUnsigned(),e.transparencyIndex=n.stream.readByte(),e.terminator=n.stream.readByte(),n.handler.gce&&n.handler.gce(e)}(e);break;case 254:e.extType="com",function(t){t.comment=n.readSubBlocks(),n.handler.com&&n.handler.com(t)}(e);break;case 1:e.extType="pte",function(t){n.stream.readByte(),t.ptHeader=n.stream.readBytes(12),t.ptData=n.readSubBlocks(),n.handler.pte&&n.handler.pte(t)}(e);break;case 255:e.extType="app",function(t){n.stream.readByte(),t.identifier=n.stream.read(8),t.authCode=n.stream.read(3),"NETSCAPE"===t.identifier?function(t){n.stream.readByte(),t.unknown=n.stream.readByte(),t.iterations=n.stream.readUnsigned(),t.terminator=n.stream.readByte(),n.handler.app&&n.handler.app.NETSCAPE&&n.handler.app.NETSCAPE(t)}(t):function(t){t.appData=n.readSubBlocks(),n.handler.app&&n.handler.app[t.identifier]&&n.handler.app[t.identifier](t)}(t)}(e);break;default:e.extType="unknown",function(t){t.data=n.readSubBlocks(),n.handler.unknown&&n.handler.unknown(t)}(e)}},e.prototype.parseImg=function(e){e.leftPos=this.stream.readUnsigned(),e.topPos=this.stream.readUnsigned(),e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.lctFlag&&(e.lct=this.parseCT(1<<e.lctSize+1)),e.lzwMinCodeSize=this.stream.readByte();var i=this.readSubBlocks();e.pixels=t.SuperGifUtils.lzwDecode(e.lzwMinCodeSize,i),e.interlaced&&(e.pixels=function(t,e){for(var n=new Array(t.length),i=t.length/e,r=function(i,r){var s=t.slice(r*e,(r+1)*e);n.splice.apply(n,[i*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,c=0;c<4;c++)for(var l=s[c];l<i;l+=o[c])r(l,a),a++;return n}(e.pixels,e.width)),this.handler.img&&this.handler.img(e)},e.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},e.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},e}();return im.SuperGifParser=e,im}var om,am,cm={};var lm=function(){if(am)return nm;am=1,Object.defineProperty(nm,"__esModule",{value:!0});var t=sm(),e=function(){if(om)return cm;om=1,Object.defineProperty(cm,"__esModule",{value:!0});var t=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],n=0;n<t;n++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",n=0;n<t;n++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();return cm.SuperGifStream=t,cm}(),n=function(){function n(t,e){var n=this;for(var i in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){n.pushFrame(),n.canvas.width=n.hdr.width*n.getCanvasScale(),n.canvas.height=n.hdr.height*n.getCanvasScale(),n.playerInit(),n.loading=!1,n.ready=!0,n.loadCallback&&n.loadCallback(n.gifImgElement)}},e)this.options[i]=e[i];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return n.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},n.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},n.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},n.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},n.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},n.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},n.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},n.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},n.prototype.parseStream=function(e){try{new t.SuperGifParser(e,this.handler).parse()}catch(t){this.handleError("parse")}},n.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},n.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},n.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},n.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},n.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},n.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},n.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var n=this.frames.length,i=t.lctFlag?t.lct:this.hdr.gct;n>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=n-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var r=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach(function(t,n){t!==e.transparency&&(r.data[4*n+0]=i[t][0],r.data[4*n+1]=i[t][1],r.data[4*n+2]=i[t][2],r.data[4*n+3]=255)}),this.frame.putImageData(r,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},n.prototype.doNothing=function(){},n.prototype.withProgress=function(t){return function(e){t(e)}},n.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},n.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},n.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},n.prototype.play=function(){this.playing=!0,this.step()},n.prototype.pause=function(){this.playing=!1},n.prototype.isPlaying=function(){return this.playing},n.prototype.getCanvas=function(){return this.canvas},n.prototype.isLoading=function(){return this.loading},n.prototype.isReady=function(){return this.ready},n.prototype.isAutoPlay=function(){return this.options.autoPlay},n.prototype.getLength=function(){return this.frames.length},n.prototype.getCurrentFrame=function(){return this.currentFrameIndex},n.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},n.prototype.loadURL=function(t,n){var i=this;if(this.loadSetup(n)){var r=new XMLHttpRequest;r.open("GET",t,!0),"overrideMimeType"in r?r.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in r?r.responseType="arraybuffer":r.setRequestHeader("Accept-Charset","x-user-defined"),r.onloadstart=function(){i.initialized||i.init()},r.onload=function(){if(200===r.status){var t=r.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var n=new e.SuperGifStream(t);setTimeout(function(){i.parseStream(n)},0)}else i.handleError("xhr - response")},r.onerror=function(){i.handleError("xhr")},r.send()}},n.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},n}();return nm.SuperGif=n,nm}();const hm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class dm extends Jg{async oncreate_element(t){const{src:e,play:n}=this.state;this.onchangesrc(e),this.onchangeplay(n)}buildImg(){const t=this.element;if(!t)return document.createElement("img");t.replaceChildren();const e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){const e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){const e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",String(0)),this._superGif=new lm.SuperGif(e,{autoPlay:!1}),this._superGif.init(),this.element&&Array.from(this.element.children).forEach(t=>{t.style.width="100%",t.style.height="100%"});const n=this._superGif.getCanvas();n.style.width="100%",n.style.height="100%",this._superGif.load(()=>{setTimeout(()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()},100)})}ondropfile(t,e){for(let n=0;n<t.length;n++)if(/\.gif$/.test(t[n].name))return void(this.src=e[n])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return hm}get tagName(){return"div"}}Ec.register("gif-view",dm);const um={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class pm extends(Pc(Cc)){static get image(){return pm.IMAGE||(pm.IMAGE=new Image,pm.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),pm.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}async ready(){super.ready(),this._audio=new Audio;const{src:t="",loop:e=!1,started:n=!1}=this.state;if(t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((e,n)=>{this._audio.addEventListener("canplay",()=>e(),{once:!0}),this._audio.addEventListener("error",()=>n(new Error(`Audio load failed: ${t}`)),{once:!0})});e.track(`audio:${t}`,"audio",t,n)}}this._audio.addEventListener("canplay",()=>{this.started&&this._audio.play()}),this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(n)}render(t){const{left:e,top:n,width:i,height:r}=this.state;t.beginPath(),this.drawImage(t,pm.image,e,n,i,r)}get nature(){return um}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void Qi(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("audio/"))return void(this.src=e[n])}}Ec.register("audio",pm);class fm extends(Pc(Ec)){is3dish(){return!0}}Ec.register("text",fm);const gm=["refid","left","top","width","height","rotation","animation","zPos"];class mm extends yg{isGroup(){return!0}is3dish(){return!0}get showMoveHandle(){return!1}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=gm.reduce((e,n)=>(t.hasOwnProperty(n)&&(e[n]=t[n]),e),{});return super.set(n,void 0)}capture(t,e,n){const i=super.capture(t,e,n);if(i!==this)return i}set bounds(t){if(this.__MUTATING__)return void(super.bounds=t);const e=this.bounds,n=t.width/e.width,i=t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i})),this.components&&this.components.forEach(t=>{if(t.mutable)t.mutatePath(null,function(t){return t.map(function(t){return{x:t.x*n,y:t.y*i}})});else{const e=t.bounds,r=t.center,s={x:r.x*(1-n),y:r.y*(1-i)},o=e.width*(1-n),a=e.height*(1-i),c=-(s.x-o/2),l=-(s.y-a/2);t.bounds={left:e.left+c,top:e.top+l,width:e.width*n,height:e.height*i}}})}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds(function(t){const e=Ec.union(this.components.map(t=>t.bounds));return this.components.forEach(t=>{const n=t.bounds;t.bounds={left:n.left-e.left,top:n.top-e.top,width:n.width,height:n.height}}),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}},this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds?.()}render(t){}postrender(t){const{top:e,left:n}=this.state;t.translate(n,e),this.layout.drawables(this).forEach(e=>{e.draw(t)}),t.translate(-n,-e)}}Ec.memoize(mm.prototype,"bounds",!0),Ec.register("group",mm);const ym={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class bm extends(Pc(Cc)){get ref(){const t=this.getState("ref");return t&&"string"==typeof t?this.root.findById?.(t):null}set ref(t){this.setState("ref",t)}get refScale(){const t=this.ref;if(!t)return{x:1,y:1};const e=t.bounds,n=this.bounds,i=n.width/e.width,r=n.height/e.height;return"both"===this.model.fit?{x:i,y:r}:{x:Math.min(i,r),y:Math.min(i,r)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){const e=this.ref.center,n=this.center,i=this.refScale;t.translate(n.x,n.y),t.scale(i.x,i.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r)}get nature(){return ym}get hasTextProperty(){return!1}}Ec.memoize(bm.prototype,"ref",!1),Ec.memoize(bm.prototype,"refScale",!1),Ec.register("local-ref",bm);class _m extends(ug(ql)){render(t){}is3dish(){return!0}get layout(){return Lc.get(this.get("layout"))||jc}}const vm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class xm extends _m{dispose(){this._releaseRef(),super.dispose()}get nature(){return vm}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){const{mode:e="view",round:n=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=n+"px"}async ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();const t=this._element_bounds,{offsetWidth:e,offsetHeight:n}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:n},(!t||t.offsetWidth!=e||t.offsetHeight!=n)&&this.ref&&this.root.target_element){const{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();const{ref:t,fit:e="ratio"}=this.state;if(!t)return;const n=this.app.refProvider;if(n&&t){const i=(async()=>{this.__ref=await n.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data})();this.root?.app?.loadTracker?.track(`ref:${t}`,"ref-board",t,i);try{await i}catch(t){Qi(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,n){super.onchange(t,e),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame(()=>{const{fit:t}=this.state;this.ref.fit(t)}),"data"in t&&this.ref&&requestAnimationFrame(()=>{this.ref.data=t.data})}}Ec.register("global-ref",xm);const wm="center-middle",Sm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"popup-position",name:"popupPosition",property:{options:["static","absolute"]}},{type:"select",label:"popup-origin",name:"origin",property:{options:["left-top","center-top","right-top","left-middle",wm,"right-middle","left-bottom","center-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"},{type:"string",label:"container-ref",name:"containerRef",placeholder:"PopupContainer id (same board)"},{type:"textarea",label:"html-template",name:"htmlTemplate",property:{language:"html"}},{type:"string",label:"anchor-ref",name:"anchorRef",placeholder:"component id (3D-tracked anchor)"},{type:"select",label:"anchor-pin",name:"anchorPin",property:{options:[{display:"Top",value:"top"},{display:"Center",value:"center"},{display:"Bottom",value:"bottom"}]}},{type:"number",label:"anchor-offset-x",name:"anchorOffsetX"},{type:"number",label:"anchor-offset-y",name:"anchorOffsetY"},{type:"number",label:"anchor-offset-z",name:"anchorOffsetZ"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup"};class Mm extends(Pc(Cc)){static get image(){return Mm._image||(Mm._image=new Image,Mm._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),Mm._image}async ready(){await super.ready(),this.show&&this.onchangeShow(!0)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,Mm.image,e,n,i,r)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){if(this.app.isEditMode)return;(this.getState("board")||this.getState("containerRef")||this.getState("htmlTemplate"))&&(t?this.openPopup(this.value):this.hidePopup())}openPopup(t,e){if(this.app.isEditMode)return;const n=this.getState("anchorRef"),i=n&&this.rootModel?.findById?this.rootModel.findById(n):void 0;Bu.show(this,this.getState("board"),{origin:this.getState("origin")||wm,modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,popupPosition:this.getState("popupPosition"),title:this.text,data:t||this.value,containerRef:this.getState("containerRef"),htmlTemplate:this.getState("htmlTemplate"),anchor:i,anchorPin:this.getState("anchorPin")||"top",anchorOffsetX:this.getState("anchorOffsetX")??0,anchorOffsetY:this.getState("anchorOffsetY")??0,anchorOffsetZ:this.getState("anchorOffsetZ")??0,constantSize:this.getState("constantSize")??!0,tether:this.getState("tether")??!1,offScreen:this.getState("offScreen")||"hide",...e})}hidePopup(){Bu.hide(this)}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return Sm}}Ec.register("popup",Mm);const km={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"billboard",name:"billboard"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup-container"};class Am extends yg{get nature(){return km}isPopupContainer(){return!0}}Ec.register("popup-container",Am);class Em extends Ec{render(t){const{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),this.drawStroke(t,void 0)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}}Ec.register("path",Em);const Cm={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class Tm extends Cc{is3dish(){return!0}contains(t,e){const{x1:n,y1:i,x2:r,y2:s,x3:o,y3:a}=this.state,c=[n,i,r,s,o,a];let l=!1;for(let n=0;n<c.length;n+=2){const i=(n+2)%c.length,r=c[n],s=c[n+1],o=c[i+1];s>e!=o>e&&t<(c[i]-r)*(e-s)/(o-s)+r&&(l=!l)}return l}get mutable(){return!0}get path(){const{x1:t,y1:e,x2:n,y2:i,x3:r,y3:s}=this.state;return[{x:t,y:e},{x:n,y:i},{x:r,y:s}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return Cm}}Ec.memoize(Tm.prototype,"path",!1),Ec.register("triangle",Tm);const Pm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"},Om={ondragmove:function(t,e,n){let{cx:i,rx:r}=n.model;r=Math.abs(r);let s=(n.fromParent(t.x,t.y).x-i)/r*100;s=s>=100||s<=-100?100:Math.abs(s),n.set({ratio:s})}};class Dm extends zg{is3dish(){return!0}render(t){let{ratio:e=50,cx:n,cy:i,rx:r,ry:s,startAngle:o,endAngle:a,anticlockwise:c}=this.state;r=Math.abs(r),s=Math.abs(s),t.beginPath(),t.ellipse(n,i,r,s,0,o||0,a||2*Math.PI,c),t.moveTo(n+r/100*e,i),t.ellipse(n,i,r/100*e,s/100*e,0,o||0,a||2*Math.PI,!0)}contains(t,e){let{cx:n,cy:i,rx:r,ry:s,ratio:o}=this.state;r=Math.abs(r),s=Math.abs(s);const a=(t-n)/(2*r-.5),c=(e-i)/(2*s-.5),l=(t-n)/(r/100*o*2-.5),h=(e-i)/(s/100*o*2-.5);let d=!1;return a*a+c*c<.25&&l*l+h*h>.25&&(d=!d),d}get controls(){let{cx:t,cy:e,rx:n,ratio:i}=this.state;return n=Math.abs(n),[{x:t+n/100*i,y:e,handler:Om}]}get nature(){return Pm}}Ec.memoize(Dm.prototype,"controls",!1),Ec.register("donut",Dm);const zm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"},Im={ondragmove:function(t,e,n){const{cy:i,ry:r}=n.model;let s=(n.fromParent(t.x,t.y).y-i)/r*100+100;s>=100?s=100:s<=0&&(s=0),n.set({ratio:s})}};class Rm extends zg{is3dish(){return!0}render(t){const{ratio:e=30,wing:n=5,cx:i,cy:r,rx:s,ry:o}=this.state;if(n<3)return;const a=1.5707963267948966,c=2*Math.PI/n,l=s-e/100*s,h=o-e/100*o;t.save(),t.beginPath(),t.translate(i,r),t.moveTo(s*Math.cos(-a),o*Math.sin(-a)),t.lineTo((s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let e=1;e<n;e++)t.lineTo(s*Math.cos(c*e-a),o*Math.sin(c*e-a)),t.lineTo((s-l)*(Math.cos(c*(e+1)-a)+Math.cos(c*e-a))/2,(o-h)*(Math.sin(c*(e+1)-a)+Math.sin(c*e-a))/2);t.closePath(),t.restore()}get controls(){const{cx:t,cy:e,ry:n,ratio:i}=this.state;return[{x:t,y:e-n+n*(i/100),handler:Im}]}get nature(){return zm}}Ec.memoize(Rm.prototype,"controls",!1),Ec.register("star",Rm);const Lm={mutable:!1,resizable:!1,rotatable:!1,properties:[]};class jm extends(bf(Cc)){is3dish(){return!1}isDescendible(){return!1}render(t){const{cx:e,cy:n,anticlockwise:i}=this.state,r=this.app?.scale||1;t.beginPath(),t.scale(1/r,1/r),t.ellipse(e,n,Math.abs(jm.RADIUS),Math.abs(jm.RADIUS),0,0,2*Math.PI,i),t.scale(r,r),t.closePath()}get path(){const{cx:t,cy:e}=this.state;return[{x:t-jm.RADIUS,y:e-jm.RADIUS},{x:t+jm.RADIUS,y:e-jm.RADIUS},{x:t+jm.RADIUS,y:e+jm.RADIUS},{x:t-jm.RADIUS,y:e+jm.RADIUS}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i}=this.state,r=(t-n)/(2*jm.RADIUS-.5),s=(e-i)/(2*jm.RADIUS-.5);return r*r+s*s<.25}outline(t){const{cx:e,cy:n}=this.state;return this.toScene(e,n)}get nature(){return Lm}}jm.RADIUS=5,Ec.memoize(jm.prototype,"path",!1),Ec.register("node",jm);class Fm extends Zd{getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds,i=this.component.state.depth||.5*Math.min(t,n),r=.15*Math.min(t,n,i),s=new R(1,1,1,4,r/Math.min(t,n,i));s.scale(t,i,n),this.object3d.geometry=s,this.object3d.material=new e.MeshStandardMaterial({color:"#5090d0",transparent:!0,opacity:.35,roughness:.6,metalness:.1,side:e.FrontSide,depthWrite:!1}),this.object3d.visible=!!this.component.app?.isEditMode}updateAlpha(){const t=this.object3d.material;t&&(t.opacity=this.component.app?.isEditMode?.35:0)}updateHidden(){this.object3d.visible=!!this.component.app?.isEditMode&&!this.component.state.hidden}updateDimension(){const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e);this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}updateFillStyle(){}updateStrokeStyle(){}updateText(){}clear(){return Hd(this.object3d),super.clear()}}const Nm="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="#5090d0">\n <path d="M32 20a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm0 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12z"/>\n <path d="M55.4 27.2l-3.6-.6c-.4-1.2-.8-2.4-1.4-3.4l2.2-3c.6-.8.4-2-.2-2.6l-3-3c-.8-.6-1.8-.8-2.6-.2l-3 2.2c-1.2-.6-2.2-1-3.4-1.4l-.6-3.6c-.2-1-1-1.6-2-1.6h-4.2c-1 0-1.8.6-2 1.6l-.6 3.6c-1.2.4-2.4.8-3.4 1.4l-3-2.2c-.8-.6-2-.4-2.6.2l-3 3c-.6.8-.8 1.8-.2 2.6l2.2 3c-.6 1.2-1 2.2-1.4 3.4l-3.6.6c-1 .2-1.6 1-1.6 2v4.2c0 1 .6 1.8 1.6 2l3.6.6c.4 1.2.8 2.4 1.4 3.4l-2.2 3c-.6.8-.4 2 .2 2.6l3 3c.8.6 1.8.8 2.6.2l3-2.2c1.2.6 2.2 1 3.4 1.4l.6 3.6c.2 1 1 1.6 2 1.6h4.2c1 0 1.8-.6 2-1.6l.6-3.6c1.2-.4 2.4-.8 3.4-1.4l3 2.2c.8.6 2 .4 2.6-.2l3-3c.6-.8.8-1.8.2-2.6l-2.2-3c.6-1.2 1-2.2 1.4-3.4l3.6-.6c1-.2 1.6-1 1.6-2v-4.2c0-1-.6-1.8-1.6-2z"/>\n</svg>');class Hm extends(Pc(Ec)){static get icon(){return Hm._defaultIcon||(Hm._defaultIcon=new Image,Hm._defaultIcon.src=Nm),Hm._defaultIcon}get serviceName(){}get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new Fm(this)}render(t){if(this.app?.isViewMode)return;const{left:e,top:n,width:i,height:r}=this.bounds,s=this.constructor.icon;t.beginPath(),t.globalAlpha=.6,this.drawImage(t,s,e,n,i,r),t.globalAlpha=1}added(t){super.added(t);const e=this.serviceName;e&&(this._registeredRoot=this.root,this._registeredRoot?.registerService?.(e,this))}removed(t){const e=this.serviceName;e&&this._registeredRoot&&(this._registeredRoot.unregisterService?.(e),this._registeredRoot=void 0),super.removed(t)}get controls(){return[]}}function Bm(t){return class extends t{animOnValueChange(t,e=!1,n){if(t==this._lastValue)return;if(this.root?.app?.suppressAnimations)return this._lastValue=t,this._anim_alpha=0,void this.invalidate();let i;i=e?t-(Number(n)||0):t-(this._lastValue||0),this._lastValue=t,this._anim_alpha=-i,this.animate({step:t=>{this._anim_alpha=i*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=Ws(this.getState("value"),this,void 0)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(xi(t)))}}}function Ym(t){return class extends t{_convertDataFormat(t,e){let n;if("json"===e)n=JSON.parse(t);else n=t;return n}isDataSource(){return!0}}}function Vm(t){var e;return(e=class extends t{is3dish(){return!0}get hasTextProperty(){return!1}get capturable(){return!1}render(t){}}).raycastTargetDefault=!1,e}const Gm="$base_url",Wm=[{type:"gltf-preset",label:"preset",name:"preset"},{type:"gltf-selector",label:"url",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:Gm,defaultStorage:"3d-model",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0,category:"application"},observe:function(t){const e=this.parentNode?.querySelector("[name=gltfInfo]");e&&(e.src=t);const n=this.parentNode?.querySelector("[name=fillStyleTargets]");n&&(n.src=t);const i=this.parentNode?.querySelector("[name=playTargets]");i&&(i.src=t)}},{type:"gltf-info",label:"",name:"gltfInfo",readonly:!0,property:{action:(t,e)=>{t._ratioLocking=!0;try{t.set(e)}finally{t._ratioLocking=!1}}},editor:{fullwidth:!0}},{type:"gltf-fill-targets",label:"fill-targets",name:"fillStyleTargets",editor:{fullwidth:!0}},{type:"gltf-play-targets",label:"play-targets",name:"playTargets",editor:{fullwidth:!0}}];function Um(t){return class extends t{constructor(){super(...arguments),this._snapshotLoading=!1,this._ratioLocking=!1}is3dish(){return!0}get hasTextProperty(){return!1}get controls(){return[]}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath();const s=this._topViewSnapshot;if(s)return void t.drawImage(s,e,n,i,r);this._ensureTopViewSnapshot(),t.rect(e,n,i,r),t.fillStyle="#f0f0f0",t.fill(),t.strokeStyle="#999",t.lineWidth=1,t.stroke();const o=this.getState("src"),a=o&&o.split("/").pop()?.replace(/\.[^.]+$/,"")||"GLTF",c=Math.max(10,.12*Math.min(i,r));t.fillStyle="#666",t.font=`${c}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,n+r/2,.9*i)}onchange(t,e){super.onchange?.(t,e),"src"in t&&(this._topViewSnapshot=void 0)}_ensureTopViewSnapshot(){if(this._snapshotLoading)return;const t=this.getState("src");if(!t)return;const e=iu.getTopViewCache(t);if(e)return this._topViewSnapshot=e,void this.invalidate();this._snapshotLoading=!0;const n=this.app.url(t);iu.loadGLTF(n).then(e=>{if(this._snapshotLoading=!1,this.getState("src")!==t)return;const n=iu.getTopViewCache(t);if(n)return this._topViewSnapshot=n,void this.invalidate();const i=iu.renderTopView(e.scene);iu.setTopViewCache(t,i),this._topViewSnapshot=i,this.invalidate()}).catch(()=>{this._snapshotLoading=!1})}buildRealObject(){return new iu(this)}get source(){return this.getState("src")}set source(t){this.setState("src",t)}get play(){return!1!==this.getState("play")}set play(t){this.setState("play",t)}get nodes(){return this.getState("nodes")}set nodes(t){this.setState("nodes",t)}get animations(){return this.getState("animations")}set animations(t){this.setState("animations",t)}get playTargets(){return this.getState("playTargets")}set playTargets(t){this.setState("playTargets",t)}get fillStyleTargets(){return this.getState("fillStyleTargets")}set fillStyleTargets(t){this.setState("fillStyleTargets",t)}get nodeNames(){const t=this.realObject;return t?.nodeNames??[]}get animationNames(){const t=this.realObject;return t?.animationNames??[]}set dimension(t){const{width:e=1,height:n=1,depth:i=1}=t;this.setState({width:e,height:n,depth:i}),this.realObject?.updateDimension()}_applyRatioLock(t){if(!("width"in t||"height"in t||"depth"in t))return t;const e=this.state.width||1,n=this.state.height||1,i=this.state.depth||1,r=Wp([(t.width??e)/e,(t.height??n)/n,(t.depth??i)/i]);return r?{...t,width:Math.round(e*r),height:Math.round(n*r),depth:Math.round(i*r)}:t}set(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.set(t)}finally{this._ratioLocking=!1}}setState(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.setState(t)}finally{this._ratioLocking=!1}}}}function Xm(t){return function(e){return Array.isArray(t)?t.forEach(t=>{Ec.register(t,e)}):Ec.register(t,e),e}}function qm(t){return!!t&&"function"==typeof t.capacity&&"function"==typeof t.available}function $m(t){if(qm(t)){const e=t.capacity(),n=t.available();return{capacity:e,available:n,isFull:0===n}}if("function"==typeof t?.slotIds){const e=t.slotIds().length,n="function"==typeof t.emptySlotIds?t.emptySlotIds().length:e;return{capacity:e,available:n,isFull:0===n}}const e=t?.state?.capacity,n=Array.isArray(t?.state?.data)?t.state.data.length:0;if("number"==typeof e){const t=Math.max(0,e-n);return{capacity:e,available:t,isFull:0===t}}return{capacity:1/0,available:1/0,isFull:!1}}class Km{constructor(){this.wasFull=!1,this.availableListeners=[],this.fullListeners=[]}notify(t){const e=0===t;if(e&&!this.wasFull){this.wasFull=!0;for(const t of this.fullListeners)try{t()}catch(t){}}else if(!e&&this.wasFull){this.wasFull=!1;for(const t of this.availableListeners)try{t()}catch(t){}}}onAvailable(t){return this.availableListeners.push(t),()=>{const e=this.availableListeners.indexOf(t);e>=0&&this.availableListeners.splice(e,1)}}onFull(t){return this.fullListeners.push(t),()=>{const e=this.fullListeners.indexOf(t);e>=0&&this.fullListeners.splice(e,1)}}dispose(){this.availableListeners=[],this.fullListeners=[]}}function Qm(t,e){if(!t||!e)return()=>{};if("function"!=typeof t.pauseEmit||"function"!=typeof t.resumeEmit)return()=>{};if("function"!=typeof e.onFull||"function"!=typeof e.onAvailable)return()=>{};const n=e.onFull(()=>t.pauseEmit()),i=e.onAvailable(()=>t.resumeEmit());return $m(e).isFull&&t.pauseEmit(),()=>{n?.(),i?.()}}class Zm{constructor(t,e=1,n="horizontal"){this.owner=t,this.itemSpacing=e,this.axis=n}positionAt(t,e,n,i){const r=e.maxCount??1/0;if(t<0||t>=r)return null;const s=this.owner?.state?.width??0,o=this.owner?.state?.height??0,a=i?.state?.width??0,c=i?.state?.height??0;return"horizontal"===this.axis?{x:t*this.itemSpacing,y:Math.max(0,(o-c)/2),z:0}:{x:Math.max(0,(s-a)/2),y:t*this.itemSpacing,z:0}}capacity(t){return t.maxCount??1/0}}function Jm(t,e,n,i,r,s,o){const a=n.w,c=n.h,l=i.w,h=i.h,d=i.d,u=[],p=l+r,f=h+r,g=Math.max(1,Math.floor((a+r)/p)),m=Math.max(1,Math.floor((c+r)/f)),y=g*m,b=s&&s>0?Math.floor(s):4;if("row"===t||"column"===t){const n=o?.advanceAlongX??!1,i=o?.reverse??!1,r=n?g:m,s=n?m:g,l=(t,e,i)=>((t,e,n)=>u.push({x:-a/2+(t+.5)*p,y:n*d+d/2,z:-c/2+(e+.5)*f}))(n?t:e,n?e:t,i);let h=0;for(let n=0;n<r&&h<e;n++){const o=i?r-1-n:n;if("column"===t)for(let t=0;t<s&&h<e;t++)for(let n=0;n<b&&h<e;n++)l(o,t,n),h++;else for(let t=0;t<b&&h<e;t++)for(let n=0;n<s&&h<e;n++)l(o,n,t),h++}return u}if("pyramid"===t){let t=e,n=0;for(;t>0;){const e=Math.max(1,g-n),i=Math.max(1,m-n),r=e*i,o=Math.min(t,r);for(let t=0;t<o;t++){const r=t%e,s=Math.floor(t/e),o=-a/2+(r+(g-e)/2+.5)*p,l=-c/2+(s+(m-i)/2+.5)*f;u.push({x:o,y:n*d+d/2,z:l})}if(t-=o,n++,1===e&&1===i){for(let e=0;e<t;e++)u.push({x:0,y:(n+e)*d+d/2,z:0});break}if(s&&n>=s)break}return u}if("pile"===t){const t=t=>(43758.5453*Math.sin(12.9898*t)%1+1)%1;for(let n=0;n<e;n++){const e=Math.floor(n/y),i=n%y,r=i%g,o=Math.floor(i/g),m=(t(2*n)-.5)*l*.2,b=(t(2*n+1)-.5)*h*.2,_=-a/2+(r+.5)*p+m,v=-c/2+(o+.5)*f+b;if(u.push({x:_,y:e*d+d/2,z:v}),s&&e>=s-1&&i===y-1)break}return u}for(let n=0;n<e;n++){const e=Math.floor(n/y);if(s&&e>=s)break;const i=n%y,r=i%g,o=Math.floor(i/g);let l=-a/2+(r+.5)*p;const h=-c/2+(o+.5)*f;"staggered"===t&&e%2==1&&(l+=p/2),u.push({x:l,y:e*d+d/2,z:h})}return u}class ty{constructor(t,e={}){this.pattern=t,this.defaults=e}layout(t,e,n,i={}){const r=i.gap??this.defaults.gap??0,s=i.heightLimit??this.defaults.heightLimit,o=i.fill??this.defaults.fill;return Jm(this.pattern,t,e,n,r,s,o).map(t=>({position:t}))}}class ey{constructor(t,e,n={}){this.cols=t,this.rows=e,this.defaults=n}layout(t,e,n,i={}){const r=Math.max(1,this.cols),s=Math.max(1,this.rows),o=r*s,a=i.gap??this.defaults.gap??0,c=n.w+a,l=n.h+a,h=[];for(let e=0;e<t;e++){const t=Math.floor(e/o),i=e%o,a=i%r,d=Math.floor(i/r);h.push({position:{x:(a-(r-1)/2)*c,z:(d-(s-1)/2)*l,y:t*n.d+n.d/2}})}return h}}class ny{constructor(t=.1,e=!1,n=!1){this.gapRatio=t,this.fillFromFar=e,this.sliceFirst=n}grid(t,e){const n=e.w*this.gapRatio,i=e.h*this.gapRatio;return{cols:Math.max(1,Math.floor((t.w-n)/(e.w+n))),rows:Math.max(1,Math.floor((t.h-i)/(e.h+i))),pitchX:e.w+n,pitchZ:e.h+i}}capacity(t,e,n){const{cols:i,rows:r}=this.grid(t,e);return i*r*Math.max(1,Math.floor(n))}layout(t,e,n,i={}){const{cols:r,rows:s,pitchX:o,pitchZ:a}=this.grid(e,n),c=n.d+n.d*this.gapRatio,l=null!=i.heightLimit?Math.max(1,Math.floor(i.heightLimit)):1/0,h=Number.isFinite(l),d=this.sliceFirst&&h,u=r*s,p=r*(h?l:1),f=r*s*(h?l:t),g=Math.min(t,f),m=[];for(let t=0;t<g;t++){let e,i,l;if(d){const n=Math.floor(t/p),s=t%p;e=s%r,l=Math.floor(s/r),i=n}else{l=Math.floor(t/u);const n=t%u;e=n%r,i=Math.floor(n/r)}this.fillFromFar&&(i=s-1-i),m.push({position:{x:(e-(r-1)/2)*o,z:(i-(s-1)/2)*a,y:l*c+n.d/2}})}return m}}function iy(t,e,n,i=0){for(let r=0;r<e.length;r++){const s=e[r],o=n[r];s&&o&&(s.parent!==t&&t.attach(s),s.position.set(o.position.x,i+o.position.y,o.position.z),o.rotation?s.quaternion.set(o.rotation.x,o.rotation.y,o.rotation.z,o.rotation.w):s.quaternion.identity())}}function ry(t,e,n,i=.12){const r=e.left+e.width/2,s=e.top+e.height/2,o=Math.min(n.w,n.h)*i,a=new Map;for(const e of t){const t=`${Math.round(e.position.x)},${Math.round(e.position.z)}`;let i=a.get(t);i||(i={x:r+e.position.x-n.w/2+o,y:s+e.position.z-n.h/2+o,w:n.w-2*o,h:n.h-2*o,count:0},a.set(t,i)),i.count++}return[...a.values()]}function sy(t){return{id:t?.state?.id??t?.id??t?.refid,type:t?.state?.type??t?.type}}const oy=new e.Euler;function ay(t,n){oy.setFromQuaternion(new e.Quaternion(n.x,n.y,n.z,n.w),"YXZ"),t.rotationX=oy.x,t.rotation=-oy.y,t.rotationY=oy.z}const cy="_transferSlotId",ly=new Set(["left","top","width","height","depth","zPos","rotation","rotationX","rotationY","rotationZ","scale","translate","material3d","fillStyle","strokeStyle","lineWidth","lineDash","alpha","opacity","hidden","text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline","shadow","border","cssText","object3d","_realObject","refid","id"]);function hy(t){return class extends t{async ready(){await super.ready();const t=this.state?.data;Array.isArray(t)&&0===this._items.length&&!this.isRecordStorage&&this._reconcileItems(t)}set data(t){if(Array.isArray(t)){if(this.isRecordStorage){const e=this.setState;return void("function"==typeof e&&e.call(this,{data:t}))}this._reconcileItems(t)}else this.setState?.({data:t})}get data(){if(this.isRecordStorage)return this.state?.data??[];const t=this._exportSlotRecords();return 0===t.length?this.state?.data:t}_reconcileItems(t){const e=new Map;for(const n of t){const t=this._recordKey(n);t&&e.set(t,n)}const n=new Map;for(const t of this._items){const e=t[cy];null!=e&&n.set(String(e),t)}for(const[t,i]of n)if(!e.has(t)){try{this.removeItem(i,!0)}catch{}try{i?.dispose?.()}catch{}}for(const[t,i]of e){if(n.has(t))continue;if(null==i.itemId)continue;const e=this._createItemFromRecord(i);if(e){e[cy]=t;try{this.handoverIn(e)}catch{}}}for(const[t,i]of e){const e=n.get(t);if(e&&(i.itemState&&"function"==typeof e.setState))try{e.setState(i.itemState)}catch{}}}_exportSlotRecords(){const t=this.slotIds?.()??[],e=[],n=new Map,i=[];for(const t of this._items){const e=t[cy];null!=e?n.set(String(e),t):i.push(t)}for(const i of t){const t=n.get(i)??null;e.push(this._slotRecordOf(i,t))}for(const t of i)e.push(this._slotRecordOf("",t));for(const[i,r]of n)t.includes(i)||e.push(this._slotRecordOf(i,r));return e}_recordKey(t){return t.slotId??t.cellId??""}_slotRecordOf(t,e){if(!e)return{slotId:t,itemId:null};const n=e?.state?.id;return{slotId:t,itemId:null!=n?String(n):null,itemType:e?.state?.type,itemState:this._extractItemState(e)}}_extractItemState(t){const e=t?.state;if(!e||"object"!=typeof e)return;const n=this._businessFields?.();if(Array.isArray(n)){if(0===n.length)return;const t={};for(const i of n)i in e&&void 0!==e[i]&&(t[i]=e[i]);return Object.keys(t).length>0?t:void 0}const i={};for(const t of Object.keys(e))ly.has(t)||t.startsWith("_")||(i[t]=e[t]);return Object.keys(i).length>0?i:void 0}_businessFields(){return null}_createItemFromRecord(t){const e=t.itemType??t.type;if(!e)return null;try{const n=Ec.register?.(e);if(n&&"function"==typeof n){return new n({type:e,...t.itemState??{}})}}catch{}return null}}}class dy{positionAt(t,e,n){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const uy=new dy,py=[{id:"__default__",maxCount:1/0}];function fy(t){var n;return n=class extends t{get slots(){return[]}get arrangementStrategy(){return uy}canReceive(t,e){const n=null!==this.findSlot(t);return fu.log({role:"target",contract:"canReceive",component:this,args:{carrier:sy(t)},result:n}),n}findSlot(t){const e=this.slots.length?this.slots:py;for(const n of e){if(n.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!n.allowedTypes.includes(e))continue}const e=n.maxCount??this.arrangementStrategy.capacity(n),i=this._countOccupied(n.id);if(!(i>=e))return fu.log({role:"target",contract:"findSlot",component:this,args:{carrier:sy(t)},result:{slotId:n.id,occupied:i,max:e}}),n}return fu.log({role:"target",contract:"findSlot",component:this,args:{carrier:sy(t)},result:null}),null}acceptanceRotation(t,e){}deliveryWorldRotation(t){const n=this.acceptanceRotation?.(t);if(!n)return;const i=this._realObject?.object3d;if(!i)return;i.updateWorldMatrix(!0,!1);const r=new e.Quaternion;i.getWorldQuaternion(r);const s=new e.Quaternion(n.x,n.y,n.z,n.w);return r.clone().multiply(s)}deliveryWorldPosition(t){const n=this._realObject,i=n?.object3d;if(!i)return;i.updateWorldMatrix(!0,!1);const r=new e.Vector3;i.getWorldPosition(r);const s=this._receivingSurfaceLocalY();if(null!==s){const t=new e.Vector3(0,s,0);return i.localToWorld(t),{x:r.x,y:t.y,z:r.z}}return{x:r.x,y:r.y,z:r.z}}attachPointFor(t){const e=t?.[cy];if(!e)return null;const n=this.slots.find(t=>t.id===e);return n?{position:n.localPosition??{x:0,y:0,z:0},rotation:n.localRotation??{x:0,y:0,z:0},slotId:n.id}:null}placementFor(t,e={}){const n=t&&"object"==typeof t&&"state"in t?t:void 0,i=n?n.state??{}:t??{},r={width:Number(i.width)||0,height:Number(i.height)||0,depth:Number(i.depth)||0},s=e.slot??this.slots.find(t=>{const e=t.maxCount??this.arrangementStrategy.capacity(t);return this._countOccupied(t.id)<e});if(!s)return null;const o=e.index??this._countOccupied(s.id),a=e.occupantCount??o,c=this.arrangementStrategy.positionAt(o,s,a,n??{state:{...r}});if(!c)return null;const l=Number(this.state?.width)||0,h=Number(this.state?.height)||0,d=c.x+r.width/2-l/2,u=c.y+r.height/2-h/2,p=this._realObject,f=p?.placementMode??"floor",g="space"===f?0:"inverted"===f?-r.depth/2:r.depth/2,m=this._receivingSurfaceLocalY();let y;y=null!==m?m+g:s.localPosition&&Number.isFinite(s.localPosition.z)?s.localPosition.z+g:g-(p?.geometricOffsetY??0);const b=this.acceptanceRotation?.(n??r,s)??void 0;return b?{position:{x:d,y:y,z:u},rotation:b}:{position:{x:d,y:y,z:u}}}_zPosFromSeatY(t,e,n){const i=this._realObject,r=i?.receivingSurfaceY??0,s=!(!n.localPosition||!Number.isFinite(n.localPosition.z));if(0===r&&!s)return null;const o=Number(e)||0,a=i?.placementMode??"floor";return t-("space"===a?0:"inverted"===a?-o/2:o/2)+(i?.geometricOffsetY??0)-r}_receivingSurfaceLocalY(){const t=this._realObject,e=t?.receivingSurfaceY;return"number"!=typeof e||0===e?null:e-(t.geometricOffsetY??0)}_countOccupied(t){const e=this._items;if(e)return e.filter(e=>e?.[cy]===t).length;const n=this.components;return n?n.filter(e=>e.parent===this&&e[cy]===t).length:0}},n.__hasCapacity=!0,n}function gy(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return[];const o="number"==typeof t.rotation?t.rotation:0,a=Math.cos(o),c=Math.sin(o),l=n+r/2,h=i+s/2,d="inbound"===e?-1:1;return[{lx:-r/2,lz:0,odx:-1,odz:0},{lx:r/2,lz:0,odx:1,odz:0},{lx:0,lz:-s/2,odx:0,odz:-1},{lx:0,lz:s/2,odx:0,odz:1}].map(t=>{var e,n;return{worldPos:(e=t.lx,n=t.lz,{x:l+e*a-n*c,z:h+e*c+n*a}),direction:{x:d*(t.odx*a-t.odz*c),z:d*(t.odx*c+t.odz*a)},halfSpan:0!==t.odx?s/2:r/2}})}function my(t,e){const n=t.left??0,i=t.top??0,r=t.width??0,s=t.height??0;if(r<=0||s<=0)return{inbounds:[],outbounds:[]};const o="number"==typeof t.rotation?t.rotation:0,a=e??"reverse"===t.status,c="vertical"===t.orientation||"horizontal"!==t.orientation&&r<s,l=n+r/2,h=i+s/2,d=c?s/2:r/2,u=c?0:1,p=c?1:0,f=Math.cos(o),g=Math.sin(o),m=(t,e)=>({x:l+t*f-e*g,z:h+t*g+e*f}),y=c?{lx:0,lz:-d}:{lx:-d,lz:0},b=c?{lx:0,lz:d}:{lx:d,lz:0},_=m(y.lx,y.lz),v=m(b.lx,b.lz),x={x:u*f-p*g,z:u*g+p*f},w=Math.hypot(x.x,x.z)||1,S={x:x.x/w,z:x.z/w},M={x:-S.x,z:-S.z},k=(c?r:s)/2;return a?{inbounds:[{worldPos:v,direction:M,halfSpan:k}],outbounds:[{worldPos:_,direction:M,halfSpan:k}]}:{inbounds:[{worldPos:_,direction:S,halfSpan:k}],outbounds:[{worldPos:v,direction:S,halfSpan:k}]}}function yy(t){const e=t.left??0,n=t.top??0,i=t.width??0,r=t.height??0;if(i<=0||r<=0)return null;const s="number"==typeof t.rotation?t.rotation:0,o="vertical"===t.orientation||"horizontal"!==t.orientation&&i<r,a=e+i/2,c=n+r/2,l=o?r/2:i/2,h=Math.cos(s),d=Math.sin(s),u=(t,e)=>({x:a+t*h-e*d,z:c+t*d+e*h});return{start:o?u(0,-l):u(-l,0),end:o?u(0,l):u(l,0)}}function by(t){const e=t.cx??0,n=t.cy??0,i=Math.abs(t.rx??100),r=Math.abs(t.ry??100),s=t.ratio??50,o=(i+i*s/100)/2,a=(r+r*s/100)/2,c=t.startAngle??0,l=t.endAngle??Math.PI/2,h="reverse"===t.status;if(i<=0||r<=0)return{inbounds:[],outbounds:[]};const d={x:e+o*Math.sin(c),z:n-a*Math.cos(c)},u={x:e+o*Math.sin(l),z:n-a*Math.cos(l)},p={x:Math.cos(c),z:Math.sin(c)},f={x:Math.cos(l),z:Math.sin(l)};return h?{inbounds:[{worldPos:u,direction:{x:-f.x,z:-f.z}}],outbounds:[{worldPos:d,direction:{x:-p.x,z:-p.z}}]}:{inbounds:[{worldPos:d,direction:p}],outbounds:[{worldPos:u,direction:f}]}}function _y(t){const e=my(t),n=e.outbounds[0];if(!n)return{inbounds:gy(t,"inbound"),outbounds:[]};const i=gy(t,"inbound").filter(t=>{const e=t.worldPos.x-n.worldPos.x,i=t.worldPos.z-n.worldPos.z;return Math.hypot(e,i)>1}),r=n.direction,s=[];for(const t of i){const e=t.direction.x*r.x+t.direction.z*r.z;if(Math.abs(e)>=.1)continue;const n=t.direction.x+r.x,i=t.direction.z+r.z,o=Math.hypot(n,i)||1;s.push({worldPos:t.worldPos,direction:{x:n/o,z:i/o},halfSpan:t.halfSpan})}return{inbounds:[...i,...s],outbounds:e.outbounds}}function vy(t,e,n={}){const i=n.distance??5,r=n.cosine??.9;if(t.direction.x*e.direction.x+t.direction.z*e.direction.z<r)return!1;const s=t.worldPos.x-e.worldPos.x,o=t.worldPos.z-e.worldPos.z;if("number"==typeof t.halfSpan&&"number"==typeof e.halfSpan){const n=t.direction.x,r=t.direction.z;if(Math.abs(s*n+o*r)>i)return!1;const a=Math.abs(s*-r+o*n);return t.halfSpan+e.halfSpan-a>0}return Math.hypot(s,o)<=i}function xy(t,e,n,i=0){const r=n.width??0,s=n.height??0;if(r<=0||s<=0)return!1;const o=(n.left??0)+r/2,a=(n.top??0)+s/2,c="number"==typeof n.rotation?n.rotation:0,l=Math.cos(-c),h=Math.sin(-c),d=t-o,u=e-a,p=d*l-u*h,f=d*h+u*l;return Math.abs(p)<=r/2+i&&Math.abs(f)<=s/2+i}function wy(t,e,n){const i=n.width??0,r=n.height??0;if(i<=0||r<=0)return 1/0;const s=(n.left??0)+i/2,o=(n.top??0)+r/2;let a=t.x-s,c=t.z-o,l=e.x,h=e.z;const d="number"==typeof n.rotation?n.rotation:0;if(0!==d){const t=Math.cos(-d),e=Math.sin(-d),n=a*e+c*t,i=l*e+h*t;a=a*t-c*e,c=n,l=l*t-h*e,h=i}const u=i/2,p=r/2;let f=-1/0,g=1/0;if(Math.abs(l)<1e-9){if(a<-u||a>u)return 1/0}else{const t=(-u-a)/l,e=(u-a)/l;f=Math.max(f,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}if(Math.abs(h)<1e-9){if(c<-p||c>p)return 1/0}else{const t=(-p-c)/h,e=(p-c)/h;f=Math.max(f,Math.min(t,e)),g=Math.min(g,Math.max(t,e))}return g<f?1/0:f>=0?f:g>=0?Math.min(-f,g):-g}function Sy(t,e,n,i=6){return!!xy(t.worldPos.x,t.worldPos.z,e,i)&&(!n||t.direction.x*n.x+t.direction.z*n.z>=0)}function My(t,e,n){return t.outbounds.map(t=>{const i=[];for(const r of e){let e=null;for(const i of r.topology.inbounds){if(!vy(t,i,n))continue;const r=t.worldPos.x-i.worldPos.x,s=t.worldPos.z-i.worldPos.z,o=Math.hypot(r,s);(null===e||o<e)&&(e=o)}if(null===e&&r.bounds){const i=r.topology.outbounds[0]?.direction,s=!(r.topology.outbounds&&r.topology.outbounds.length)?n?.sinkMargin??30:6;if(Sy(t,r.bounds,i,s)){const n=wy(t.worldPos,t.direction,r.bounds);if(Number.isFinite(n))e=n+1e3;else{const n=(r.bounds.left??0)+(r.bounds.width??0)/2,i=(r.bounds.top??0)+(r.bounds.height??0)/2;e=Math.hypot(t.worldPos.x-n,t.worldPos.z-i)+1e3}}}null!==e&&i.push({id:r.id,dist:e})}return 0===i.length?null:(i.sort((t,e)=>t.dist-e.dist||(t.id<e.id?-1:1)),i[0].id)})}function ky(t,e){const n=new Map;for(const e of t)n.set(e.id,e);const i=new Map,r=new Set;for(const n of t){const s=t.filter(t=>t.id!==n.id),o=My(n.topology,s,e);i.set(n.id,o);for(const t of o)null!=t&&r.add(t)}const s=(t,e)=>{if(!n.has(t)||!n.has(e)||t===e)return;const s=i.get(t)??[];s.includes(e)||(s.push(e),i.set(t,s),r.add(e))};for(const e of t)if(e.links){for(const t of e.links.downstream??[])s(e.id,t);for(const t of e.links.upstream??[])s(t,e.id)}const o=new Set,a=new Set;for(const e of t){(i.get(e.id)??[]).some(t=>null!=t)||o.add(e.id),r.has(e.id)||a.add(e.id)}return{nodes:n,out:i,sinks:o,sources:a}}function Ay(t,e){const n=new Map;return(t.out.get(e)??[]).map(e=>{if(null==e)return new Set;const i=new Set([e]);for(const r of function(t,e,n){const i=n.get(e);if(i)return i;const r=new Set,s=[e],o=new Set([e]);for(;s.length;){const e=s.shift();for(const n of t.out.get(e)??[])null!=n&&(r.add(n),o.has(n)||(o.add(n),s.push(n)))}return n.set(e,r),r}(t,e,n))i.add(r);return i})}function Ey(t,e,n,i){return e===n?0:function(t,e,n){const i=n.get(e);if(i)return i;const r=new Map([[e,0]]),s=[e];for(;s.length;){const e=s.shift(),n=r.get(e);for(const i of t.out.get(e)??[])null==i||r.has(i)||(r.set(i,n+1),s.push(i))}return n.set(e,r),r}(t,e,i).get(n)??1/0}function Cy(t,e,n){const i=t.out.get(e)??[],r=new Map,s=[];for(let e=0;e<i.length;e++){const o=i[e];if(null==o)continue;const a=o===n?0:Ey(t,o,n,r);a!==1/0&&s.push({i:e,hops:1+a})}return s.sort((t,e)=>t.hops-e.hops||t.i-e.i),s.map(t=>t.i)}function Ty(t,e,n){const i=Cy(t,e,n);return i.length?i[0]:-1}function Py(t,e,n){return e===n||Cy(t,e,n).length>0}function Oy(t,e){const n=new Set;for(const i of Ay(t,e))for(const e of i)t.sinks.has(e)&&n.add(e);return n}function Dy(t,e,n){return zy(t,e,n).map(t=>t.index)}function zy(t,e,n){const i=n instanceof Set?n:new Set(n);if(0===i.size)return[];const r=t.out.get(e)??[],s=new Map,o=[...i].sort(),a=[];for(let e=0;e<r.length;e++){const n=r[e];if(null==n)continue;let i=1/0,c="";for(const e of o){const r=1+(n===e?0:Ey(t,n,e,s));r<i&&(i=r,c=e)}i!==1/0&&a.push({index:e,hops:i,target:c})}return a.sort((t,e)=>t.hops-e.hops||t.index-e.index),a}function Iy(t,e={}){const n=[],i=e.loopCapableIds??new Set,r=e.routingTargetIds??new Set;for(const e of[...t.sources].sort()){const i=t.nodes.get(e);if(!i||!i.topology.outbounds?.length)continue;(t.out.get(e)??[]).some(t=>null!=t)||n.push({severity:"error",code:"orphan-source",nodeId:e,message:`source 노드 "${e}" 가 outgoing edge 0 — 아무 데도 carrier 를 보낼 수 없음`})}for(const e of[...t.nodes.keys()].sort()){(t.out.get(e)??[]).some(t=>null!=t)||(r.has(e)||t.sources.has(e)||n.push({severity:"error",code:"dead-end",nodeId:e,message:`노드 "${e}" 가 outgoing 0 인데 RoutingTarget 자격 없음 — routing 미정의 종착`}))}const s=function(t){const e=[],n=[...t.nodes.keys()].sort(),i=new Set,r=[],s=new Set,o=n=>{i.add(n),r.push(n),s.add(n);for(const a of t.out.get(n)??[])if(null!=a)if(s.has(a)){const t=r.indexOf(a),n=r.slice(t),i=n.indexOf([...n].sort()[0]),s=[...n.slice(i),...n.slice(0,i)],o=s.join("→");e.some(t=>t.join("→")===o)||e.push(s)}else i.has(a)||o(a);r.pop(),s.delete(n)};for(const t of n)i.has(t)||o(t);return e.sort((t,e)=>t[0].localeCompare(e[0])||t.length-e.length),e}(t);for(const t of s){t.some(t=>i.has(t))||n.push({severity:"error",code:"cycle",cycle:t,message:`의도 cycle 자격 (isLoop) 없는 cycle: ${t.join(" → ")} → ${t[0]}`})}const o=e.routingWeights;if(o)for(const[t,e]of[...o].sort((t,e)=>t[0].localeCompare(e[0])))(!Number.isFinite(e)||e<=0)&&n.push({severity:"warning",code:"invalid-weight",nodeId:t,message:`RoutingTarget "${t}" 의 routingWeight=${e} — weight ≤ 0 비정상, weight 정책에서 제외됨`});const a=new Set;for(const e of t.out.values())for(const t of e)null!=t&&a.add(t);for(const e of[...r].sort())t.nodes.has(e)&&(a.has(e)||n.push({severity:"warning",code:"unreachable-target",nodeId:e,message:`RoutingTarget "${e}" 에 incoming edge 0 — 누구도 이쪽으로 carrier 를 보내지 않음`}));return n.sort((t,e)=>t.code!==e.code?t.code.localeCompare(e.code):(t.nodeId??"").localeCompare(e.nodeId??"")),n}function Ry(t,e){if(!t)return[];const n=[],i=new Set,r=t=>{if(!t||i.has(t))return;if(i.add(t),t!==e&&"function"==typeof t?.getSegmentTopology){const e=t.state?.id,i=t.refid??t.state?.refid,r="string"==typeof e&&e.length>0?e:null!=i?String(i):void 0;if(r)try{const e=t.getSegmentTopology(),i=t.state??{},s={left:i.left,top:i.top,width:i.width,height:i.height,rotation:i.rotation};e&&n.push({id:r,topology:e,bounds:s})}catch{}}const s=t?.components;if(Array.isArray(s))for(const t of s)r(t)};return r(t),n}function Ly(t,e){const n=t.state?.targetRef??t.state?.downstreamRef;if("string"==typeof n&&n.length>0)return n;if("function"!=typeof t.getSegmentTopology)return null;const i=t.getSegmentTopology();if(!i||0===i.outbounds.length)return null;const r=My(i,Ry(t.parent??t.rootModel??t.root,t).filter(t=>t.topology.inbounds.length>0),e);for(const t of r)if(t)return t;return null}function jy(t){return!!t&&"function"==typeof t.routingConstraints}function Fy(t){return!!t&&"function"==typeof t.acceptedCarrierData}function Ny(t,e=16){const n=[],i=t.parent??t.rootModel??t.root;if(!i)return n;const r=Ly(t);if(!r)return n;const s=Yy(i,r);if(!s)return n;const o=[{segment:s,accumulated:{},pathIds:[r],visited:new Set([r])}];for(;o.length>0;){const t=o.shift();if(t.pathIds.length>e)continue;const r=jy(t.segment)?t.segment.routingConstraints():null;if(r&&r.length>0)for(const e of r)for(const r of e.candidates){const s=Hy(t.accumulated,r);if(!s)continue;const a=By(t.segment,e.portId,i);a&&!t.visited.has(a.state?.id??"")?o.push({segment:a,accumulated:s,pathIds:[...t.pathIds,a.state?.id??"?"],visited:new Set([...t.visited,a.state?.id??""])}):n.push({data:s,weight:1,pathIds:[...t.pathIds,`${e.portId}`],destination:e.portId})}else{if(Fy(t.segment)){const e=t.segment.acceptedCarrierData(),i=t.segment.state?.id;if(0===e.length)n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:i});else for(const r of e){const e=Hy(t.accumulated,r);e&&n.push({data:e,weight:1,pathIds:t.pathIds,destination:i})}continue}const e=Ly(t.segment);if(!e||t.visited.has(e)){n.push({data:t.accumulated,weight:1,pathIds:t.pathIds,destination:t.pathIds[t.pathIds.length-1]});continue}const r=Yy(i,e);if(!r)continue;o.push({segment:r,accumulated:t.accumulated,pathIds:[...t.pathIds,e],visited:new Set([...t.visited,e])})}}return n}function Hy(t,e){const n={...t};for(const[t,i]of Object.entries(e)){if(t in n&&n[t]!==i)return null;n[t]=i}return n}function By(t,e,n){if("straight"===e&&t.state?.downstreamRef)return Yy(n,t.state.downstreamRef);const i=Yy(n,e);if(i)return i;const r=Ly(t);return r?Yy(n,r):null}function Yy(t,e){if(!t||!e)return null;if("function"==typeof t.findById)return t.findById(e);const n=new Set,i=t=>{if(!t||n.has(t))return null;if(n.add(t),t.state?.id===e)return t;const r=t.components;if(Array.isArray(r))for(const t of r){const e=i(t);if(e)return e}return null};return i(t)}function Vy(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}function Gy(t,e,n=5,i=[],r=n){const s=t.length,o=new Array(s).fill(void 0),a=new Set,c=(e,n)=>"start"===n?t[e].start:t[e].end,l=[],h=new Map,d=[],u=new Map;for(const t of i){const e=Array.isArray(t),n=e?t:t.positions,i=e?void 0:t.kind;if(!n.length)continue;const r=l.length;l.push({pos:n[0],members:[]});for(const t of n)d.push({pos:t,pt:r});i&&u.set(r,i)}const p=(t,e)=>{const i=c(t,e),r=h.get(`${t}:${"end"===e?"start":"end"}`),s=[];for(const t of d)Vy(t.pos,i)<=n&&!s.includes(t.pt)&&s.push(t.pt);for(let t=0;t<l.length;t++)Vy(l[t].pos,i)<=n&&!s.includes(t)&&s.push(t);let o=s.find(t=>t!==r)??-1;o<0&&(o=l.length,l.push({pos:i,members:[]})),l[o].members.push({seg:t,end:e}),h.set(`${t}:${e}`,o)};for(let t=0;t<s;t++)p(t,"start"),p(t,"end");const f=new Set,g=new Set,m=new Set;{const t=t=>{let e=-1,n=1/0;for(let i=0;i<l.length;i++){const r=Vy(l[i].pos,t);r<n&&(n=r,e=i)}for(const i of d){const r=Vy(i.pos,t);r<n&&(n=r,e=i.pt)}return{pt:e,d:n}};for(const n of e){const{pt:e,d:i}=t(n.pos);e>=0&&i<=r&&(f.add(e),("source"===n.kind?g:m).add(e))}}for(const[t,e]of u)f.add(t),("source"===e?g:m).add(t);const y=(t,e)=>"end"===e!==o[t],b=[],_=(e,n)=>{if(void 0===o[e])return o[e]=n,void b.push(e);o[e]!==n&&a.add(t[e].id)},v=t=>{for(const e of["start","end"]){const n=h.get(`${t}:${e}`);if(void 0===n)continue;const i=l[n];if(2!==i.members.length||f.has(n))continue;const r=i.members[0],s=r.seg===t&&r.end===e?i.members[1]:r;if(s.seg===t)continue;const a="end"===e!==o[t],c="end"===s.end!==!a;_(s.seg,c)}},x=()=>{for(;b.length;)v(b.shift())},w=t=>{let e=-1,n="start",i=1/0;for(let r=0;r<s;r++)for(const s of["start","end"]){const o=Vy(c(r,s),t.pos);o<i&&(i=o,e=r,n=s)}if(e<0||i>r)return;const o="source"===t.kind?"end"===n:"start"===n;_(e,o)};for(const t of e)"source"===t.kind&&w(t);x();for(const t of e)"sink"===t.kind&&w(t);x();let S=!0;for(;S;){S=!1;for(const t of l){if(t.members.length<3)continue;const e=t.members.filter(t=>void 0===o[t.seg]);if(1!==e.length)continue;let n=0,i=0;for(const e of t.members)void 0!==o[e.seg]&&(y(e.seg,e.end)?n++:i++);const r=e[0];let s;0===i&&n>0?s="end"===r.end:0===n&&i>0&&(s="start"===r.end),void 0!==s&&(o[r.seg]=s,b.push(r.seg),x(),S=!0)}}if(o.some(t=>void 0===t)&&g.size>0&&m.size>0){const t=t=>{const e=new Array(l.length).fill(1/0),n=[];for(const i of t)e[i]=0,n.push(i);for(;n.length;){const t=n.shift();for(const i of l[t].members){const r=h.get(`${i.seg}:${"start"===i.end?"end":"start"}`);void 0!==r&&e[r]>e[t]+1&&(e[r]=e[t]+1,n.push(r))}}return e},e=t(g),n=t(m);for(let t=0;t<s;t++){if(void 0!==o[t])continue;const i=h.get(`${t}:start`),r=h.get(`${t}:end`);if(void 0===i||void 0===r)continue;if(l[i].members.length<2||l[r].members.length<2)continue;if(e[i]===1/0||e[r]===1/0||n[i]===1/0||n[r]===1/0)continue;let s;e[i]!==e[r]?s=e[i]<e[r]:n[i]!==n[r]&&(s=n[r]<n[i]),void 0!==s&&(o[t]=!s,b.push(t))}x()}const M=new Map;for(let e=0;e<s;e++)M.set(t[e].id,void 0===o[e]?"unknown":o[e]?"reverse":"forward");return{directions:M,conflicts:[...a]}}function Wy(...t){}function Uy(t){return String(t?.state?.id??t?.refid??t?.state?.refid??"?")}function Xy(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*qy(t){if(!t)return;("function"==typeof t.getSegmentTopology||t.flowOrientable)&&(yield t);const e=t.components;if(Array.isArray(e))for(const t of e)yield*qy(t)}function $y(t,e,n){const i=e.width??0,r=e.height??0;if(i<=0||r<=0)return!1;const s=(e.left??0)+i/2,o=(e.top??0)+r/2,a="number"==typeof e.rotation?e.rotation:0,c=t.x-s,l=t.z-o,h=Math.cos(-a),d=Math.sin(-a),u=c*h-l*d,p=c*d+l*h;return Math.abs(u)<=i/2+n&&Math.abs(p)<=r/2+n}function Ky(t){const e=[],n=[],i=[],r=[];for(const s of qy(t)){const t=Xy(s);if(!t)continue;if(s.flowOrientable){const n=yy(s.state??{});n&&e.push({id:t,start:n.start,end:n.end});continue}if("function"==typeof s.openings){const t=s.state??{};(t.width??0)>0&&(t.height??0)>0&&r.push(t);continue}let o;try{o=s.getSegmentTopology()}catch{continue}if(!o)continue;const a=o.inbounds??[],c=o.outbounds??[],l="function"==typeof s.routingDestination;if(0===a.length&&c.length>0)for(const t of c)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"source"});else if(a.length>0&&(0===c.length||l))for(const t of a)n.push({pos:{x:t.worldPos.x,z:t.worldPos.z},kind:"sink"});else if(a.length>0||c.length>0){const t=[];for(const e of a)t.push({x:e.worldPos.x,z:e.worldPos.z});for(const e of c)t.push({x:e.worldPos.x,z:e.worldPos.z});t.length&&i.push({positions:t})}}for(const t of r){const r=[];for(const n of e)for(const e of[n.start,n.end])$y(e,t,16)&&r.push(e);let s=!1,o=!1;for(const e of n)$y(e.pos,t,16)&&("sink"===e.kind?s=!0:o=!0);const a=s&&!o?"sink":o&&!s?"source":void 0;(r.length>=2||a&&r.length>=1)&&i.push({positions:r,kind:a})}if(0===e.length||0===n.length)return new Map;return Gy(e,n,8,i,60).directions}function Qy(t){const e=t?.root;if(!e)return;if(e.__flowComputing)return;let n=e.__flowOrientation;if(!n){e.__flowComputing=!0;try{n={map:Ky(e)}}finally{e.__flowComputing=!1}e.__flowOrientation=n}const i=Xy(t),r=i?n.map.get(i):void 0;return"reverse"===r||"forward"!==r&&void 0}function Zy(t){return!!t&&"function"==typeof t.distanceToBoardPoint&&"function"==typeof t.routingLinks&&("function"==typeof t.registerDivertStation||"function"==typeof t.registerInductStation)}function Jy(t,e,n){if(!e)return null;const i=[],r=e=>{if(!e||e===n)return;if(Zy(e)){const n=function(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}(e);if(n){const r=e.distanceToBoardPoint(t.x,t.y);i.push({id:n,component:e,distance:r})}}const s=e.components;if(Array.isArray(s))for(const t of s)r(t)};return r(e),0===i.length?null:(i.sort((t,e)=>t.distance-e.distance||t.id.localeCompare(e.id)),i[0])}function tb(t){return!!t&&"function"==typeof t.routingDestination}function eb(t){const e=t?.state?.id;if("string"==typeof e&&e.length>0)return e;const n=t?.refid??t?.state?.refid;return null!=n?String(n):void 0}function*nb(t){if(!t)return;yield t;const e=t.components;if(Array.isArray(e))for(const t of e)yield*nb(t)}function ib(t){const e=[],n=new Map,i=new Map,r=new Set,s=[];for(const o of nb(t)){"function"==typeof o?.registerWithStationHost&&s.push(o);const t="function"==typeof o?.getSegmentTopology,a="function"==typeof o?.routingLinks?o.routingLinks():void 0,c=!(!a||!((a.downstream?.length??0)>0||(a.upstream?.length??0)>0));if(!(t||tb(o)||c||Zy(o)))continue;const l=eb(o);if(!l)continue;let h={inbounds:[],outbounds:[]};if(t){try{h=o.getSegmentTopology()}catch{continue}if(!h)continue}const d=o.state??{},u={left:d.left,top:d.top,width:d.width,height:d.height,rotation:d.rotation};if(e.push({id:l,topology:h,bounds:u,links:a}),i.set(l,o),tb(o)){r.add(l);const t=o.routingDestination();if("string"==typeof t&&t.length>0){const e=n.get(t)??[];e.push(l),n.set(t,e)}}}return{nodes:e,destToSinks:n,components:i,routingTargetIds:r,stationClients:s}}function rb(t){if(!t)return null;let e=t.__flowGraph;if(!e){const{nodes:n,destToSinks:i,components:r,routingTargetIds:s,stationClients:o}=ib(t),a=ky(n);!function(t,e){if(!t)return;const n=t=>{if(!t)return;"function"==typeof t.clearStations&&t.clearStations();const e=t.components;if(Array.isArray(e))for(const t of e)n(t)};n(t);const i=[...e].sort((t,e)=>{const n=eb(t)??"",i=eb(e)??"";return n.localeCompare(i)});for(const e of i){const n=e.stationHostRef?.();let i=null;if(n&&(i=t.findById?.(n)??null),!i){const n=e.sorterFacingPoint?.()??e._sorterFacingPoint?.();n&&(i=Jy(n,t,e)?.component??null)}i&&"function"==typeof e.registerWithStationHost&&e.registerWithStationHost(i)}const r=e=>{if(!e)return;if(Zy(e)&&"function"==typeof e.resolveDownstream&&"function"==typeof e.registerDivertStation)for(const n of e.resolveDownstream()){const i=t.findById?.(n);i&&e.registerDivertStation(n,i)}const n=e.components;if(Array.isArray(n))for(const t of n)r(t)};r(t)}(t,o);const c=new Set;for(const[t,e]of r){((e?.state?.type??e?.model?.type??"").includes("loop")||!0===e?.isLoop)&&c.add(t)}const l=new Map;for(const t of s){const e=r.get(t);if("function"==typeof e?.routingWeight){const n=e.routingWeight();"number"==typeof n&&(!Number.isFinite(n)||n<=0)&&l.set(t,n)}}const h=Iy(a,{routingTargetIds:s,loopCapableIds:c,routingWeights:l});if(h.length>0&&"undefined"!=typeof console){const t=h.filter(t=>"error"===t.severity),e=h.filter(t=>"warning"===t.severity);t.length>0?console.warn(`[FlowGraph] ${t.length} error(s) / ${e.length} warning(s):`,h):console.info(`[FlowGraph] ${e.length} warning(s):`,h)}e={graph:a,destToSinks:i,components:r,issues:h},t.__flowGraph=e}return e}function sb(t){return rb(t)?.issues??[]}function ob(t){const e=rb(t);return e&&e.graph.nodes.size>0?e.graph:null}function ab(t,e){return rb(t)?.destToSinks.get(e)??[]}function cb(t,e){return rb(t)?.components.get(e)}function lb(t){const e=rb(t);return e?[...e.destToSinks.keys()]:[]}function hb(t){return eb(t)}function db(t){const e="number"==typeof t?.inventoryCount?t.inventoryCount:"function"==typeof t?.size?t.size():0,n=t?.state?.capacity;return"number"==typeof n&&n>0?e/n:e}function ub(t,e,n,i,r){if(1===i.length)return i[0];switch(t){case"index":default:return i[0];case"round-robin":{const t=n.counters.get(e)??0;return n.counters.set(e,t+1),i[t%i.length]}case"weight":{const t=i.map(t=>function(t){if("function"==typeof t?.routingWeight){const e=t.routingWeight();if("number"==typeof e&&Number.isFinite(e)&&e>0)return e}return 1}(r.get(t.target))),s=t.reduce((t,e)=>t+e,0);if(s<=0)return i[0];const o=n.counters.get(e)??0;n.counters.set(e,o+1);let a=o%s;for(let e=0;e<i.length;e++){if(a<t[e])return i[e];a-=t[e]}return i[i.length-1]}case"utilization":{let t=1/0,e=i[0];for(const n of i){const i=db(r.get(n.target));i<t&&(t=i,e=n)}return e}}}function pb(t,e,n){const i=t?.root;if(!i)return null;const r=e?.state?.meta?.destination;if("string"!=typeof r||0===r.length)return null;const s=rb(i);if(!s||0===s.graph.nodes.size)return null;const o=eb(t);if(!o)return null;let a=s.destToSinks.get(r)??[];0===a.length&&(a=[r]);const c=zy(s.graph,o,a);if(0===c.length)return null;const l=s.graph.out.get(o)??[],h=c.filter(t=>{const n=l[t.index],i=n?s.components.get(n):null;return!i||"function"!=typeof i.canReceive||i.canReceive(e)});if(0===h.length)return l[c[0].index]??null;const d=n?.policy??function(t,e){const n=t?.state?.balancingPolicy;if(n)return n;const i=e?.state?.routingBalancingPolicy;return i||"round-robin"}(t,i),u=ub(d,o,function(t){return t.__balancingState||(t.__balancingState={counters:new Map}),t.__balancingState}(i),h,s.components);return l[u.index]??null}rg({name:"Capacity",description:"Item 을 *보유(keep)* 하는 측면 — slot 위상 / 수용 판정(canReceive/findSlot) / 3D 안착(placementFor/attachPointFor/acceptanceRotation) / delivery 좌표 질의 / 점유 수. 이동(receive/dispatch 등)은 Transferable 소관.",methods:["get slots","get arrangementStrategy","canReceive","findSlot","placementFor","attachPointFor","acceptanceRotation","deliveryWorldRotation","deliveryWorldPosition","_countOccupied"],sourceFile:"src/items/capacity-mixin.ts"}),rg({name:"PlacementSurface",description:"carrier 가 holder 위 *정확히 어디에 앉는가* 의 단일 진입점 — placementFor(carrier, ctx) → SeatingPose (holder object3d local frame, 순수 함수). I1 접촉 (밑면 = 받침 상면) / I2 frame-explicit (parent-child 비가정 — Sovereign handover 와 reparent 양쪽이 같은 값 소비) / I3 순수성 / I4 per-carrier 치수. default 구현은 Capacity(FlowNode) 가 기존 receivingSurfaceY + ArrangementStrategy + acceptanceRotation 합성과 수치 동일하게 제공.",methods:["placementFor"],models:["CarrierDims","PlacementContext","SeatingPose"],sourceFile:"src/items/capacity-mixin.ts"});try{globalThis.__operatoBuildFlowGraph=(t,e)=>{try{return e?.force&&t&&delete t.__flowGraph,ob(t)}catch{return null}}}catch{}function fb(t,e,n){const i=pb(t,e,n);if(null==i)return null;const r=t?.root,s=cb(r,i)??r?.findById?.(i)??null;return s?{targetId:i,component:s,origin:"explicit"}:null}function gb(t){const e=t?.root,n=ob(e),i=hb(t);if(!n||!i)return null;const r=(n.out.get(i)??[]).find(Boolean);if(!r)return null;const s=cb(e,r)??e?.findById?.(r)??null;return s?{id:r,component:s}:null}function mb(t){const e=hb(t);return e?yb(t?.root,e):[]}function yb(t,e){if(!t||!e)return[];const n=ob(t);if(!n)return[];const i=new Set;for(const r of Oy(n,e)){const e=cb(t,r);if(tb(e)){const t=e.routingDestination();"string"==typeof t&&t.length>0&&i.add(t)}}return[...i]}function bb(t,e){if(!t||!e)return[];const n=ob(t);if(!n)return[];const i=new Map;for(const t of n.out.values())for(const e of t)null!=e&&i.set(e,(i.get(e)??0)+1);const r=new Map;for(const s of Oy(n,e)){const e=cb(t,s);if(!tb(e))continue;const n=e.routingDestination();if("string"!=typeof n||0===n.length)continue;let o=null;if("function"==typeof e.routingWeight){const t=e.routingWeight();"number"==typeof t&&Number.isFinite(t)&&t>0&&(o=t)}null===o&&(o=i.get(s)??0,0===o&&(o=1)),r.set(n,(r.get(n)??0)+o)}return[...r].map(([t,e])=>({value:t,weight:e}))}function _b(t){return ob(t)}function vb(t){const e=ob(t);if(!e)return[];const n=new Set,i=new Set,r=t=>{if(!t)return;const s=hb(t);if(s&&e.nodes.has(s)){tb(t)&&n.add(s);((t?.state?.type??t?.model?.type??"").includes("loop")||!0===t?.isLoop)&&i.add(s)}const o=t.components;if(Array.isArray(o))for(const t of o)r(t)};return r(t),Iy(e,{routingTargetIds:n,loopCapableIds:i})}function xb(t){if(0===t.length)return;const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0)return t[Math.floor(Math.random()*t.length)].value;const n=Math.random()*e;let i=0;for(const e of t)if(i+=e.weight,n<i)return e.value;return t[t.length-1].value}const wb={next:fb,downstream:gb,reachableDestinations:mb,reachableDestinationsFrom:yb,reachableDestinationsWeightedFrom:bb,pickWeightedDestination:xb,graphFor:_b,validate:vb};function Sb(t){var e;return e=class extends t{constructor(){super(...arguments),this._items=[]}get items(){return this._items}containsItem(t){return-1!==this._items.indexOf(t)}attachPointFor(e,n){const i=t.prototype?.attachPointFor;return"function"==typeof i?i.call(this,e,n):null}addItem(t,e){if(!t||this.containsItem(t))return;const n=t.parent;if(n&&"function"==typeof n.removeItem&&n!==this&&n.removeItem(t,!0),this._items.push(t),t.parent=this,!e?.silent&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}t.held?.(this)}removeItem(t,e){if(!t)return;const n=this._items.indexOf(t);if(-1!==n&&(this._items.splice(n,1),t.parent=null,!e)){if("function"==typeof this.trigger)try{this.trigger("release",this,t,n)}catch{}t.released?.(this)}}forEachItem(t,e){this._items.forEach(t,e)}handoverIn(t,e){if(!t)return;const n=t.parent;n&&("function"==typeof n.removeComponent&&-1!==n._components?.indexOf?.(t)&&n.removeComponent(t,!0),n!==this&&"function"==typeof n.removeItem&&-1!==n._items?.indexOf?.(t)&&n.removeItem(t,!0));const i=-1===this._items.indexOf(t);if(i&&this._items.push(t),t.parent=this,i&&"function"==typeof this.trigger)try{this.trigger("hold",this,t,this._items.length-1)}catch{}const r=t._realObject,s=r?.object3d;if(s){let n,i,o=e?.toParent3D,a="world-preserve";if(!o){const r=this.attachPointFor?.(t,{slotId:e?.slotId});r?.attach&&(o=r.attach,n=r.localPosition,i=r.localRotation,a=r.carryPolicy??"world-preserve")}o&&s.parent!==o&&(o.updateWorldMatrix?.(!0,!1),s.updateWorldMatrix?.(!0,!1),o.attach(s),r.suppressTransform=!0),o&&(n&&s.position.set(n.x,n.y,n.z),"world-preserve"!==a?i?s.rotation.set(i.x,i.y,i.z):s.quaternion.identity():i&&s.rotation.set(i.x,i.y,i.z),r?.setTransientPlacement?.({policy:"carried",meta:{carryPolicy:a}}))}t.held?.(this),this._bumpReceived?.(t)}handoverOut(t){this.removeItem(t),this._bumpDispatched?.(t)}dispose(){const t=this._items.slice();this._items.length=0;for(const e of t)try{e.dispose?.()}catch{}super.dispose?.()}_drawItems(t){const e=this.root?.transitionEffect;for(const t of this._items)e?.isReparenting?.(t)||t.draw?.(this.getContext?.(t))}_captureItems(t,e,n,i,r){for(let s=this._items.length-1;s>=0;s--){const o=this._items[s],a="static"===o.position?o.capture?.(t,e,r):o.capture?.(n,i,r);if(a)return a}return null}postrender(t){super.postrender?.(t);const e=this;if("popup"===e.position)return;const n=this._items;if(!n||0===n.length)return;t.save();const i=e.bounds;!e.showOverflow&&i&&(t.beginPath(),t.rect(i.left,i.top,i.width,i.height),t.clip(),t.closePath());const{left:r=0,top:s=0}=e.state??{};t.translate(r,s),this._drawItems(t),t.translate(-r,-s),t.restore()}capture(t,e,n){const i=this,r=this._items;if(r&&r.length>0&&(!i.app||i.app.isEditMode||!i.hidden)){const r=i.fromParent?.(t,e);if(r&&i.contains?.(r.x,r.y)){const s=i.bounds,o=this._captureItems(r.x-s.left,r.y-s.top,t,e,n);if(o)return o}}return super.capture?.(t,e,n)}},e.capabilities=Object.freeze([...t.capabilities??[],"Holdable"]),e}function Mb(t){var n;const i=!!t.__hasCapacity,r=!!t.__hasTransferable,s=i?t:fy(t),o=r?s:function(t){var n;return(n=class extends t{reserve(t,e){const n=this.findSlot(t);return n?{slot:n,token:Symbol("slot-reservation")}:null}release(t){}async receive(t,e={}){fu.log({role:"target",contract:"receive:enter",component:this,args:{carrier:sy(t),options:e}});const n=this.reserve(t,e);if(!n){fu.log({role:"target",contract:"receive:reject",component:this,args:{carrier:sy(t)},result:{reason:"no-slot"}}),this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const e=new Error("receive rejected: no-slot");throw e.reason="no-slot",e}this.commit(n,t,e)}commit(t,n,i={}){const r=t.slot,s=this._countOccupied(r.id),o=this.arrangementStrategy.positionAt(s,r,s,n);fu.log({role:"target",contract:"arrangementStrategy.positionAt",component:this,args:{idx:s,slotId:r.id,occupantCount:s,carrier:sy(n)},result:o}),n[cy]=r.id;const a=n._realObject;let c,l;a?.object3d&&(a.object3d.updateWorldMatrix(!0,!1),c=new e.Vector3,l=new e.Quaternion,a.object3d.getWorldPosition(c),a.object3d.getWorldQuaternion(l));const{animated:h=!1,duration:d,ease:u}=i;"function"==typeof this.handoverIn?this.handoverIn(n,{slotId:r.id}):this.reparent?.(n,{animated:h,duration:d,ease:u}),!h&&n._realObject&&(n._realObject.suppressTransform=!1);{const t={},e=this.placementFor?.(n,{slot:r,index:s,occupantCount:s})??null;if(fu.log({role:"target",contract:"placementFor",component:this,args:{carrier:sy(n),slotId:r.id,index:s},result:e}),e){const i=n.state??{},s=this.state??{};t.left=e.position.x-(Number(i.width)||0)/2+(Number(s.width)||0)/2,t.top=e.position.z-(Number(i.height)||0)/2+(Number(s.height)||0)/2;const o=this._zPosFromSeatY(e.position.y,i.depth,r);null!==o&&(t.zPos=o),e.rotation&&ay(t,e.rotation)}else{if(o&&(t.left=o.x,t.top=o.y),0!==(this._realObject?.receivingSurfaceY??0))t.zPos=0;else if(r.localPosition&&Number.isFinite(r.localPosition.z)){const e=this._realObject?.geometricOffsetY??0;t.zPos=r.localPosition.z+e}const e=this.acceptanceRotation?.(n,r);fu.log({role:"target",contract:"acceptanceRotation",component:this,args:{carrier:sy(n),slotId:r.id},result:e}),e&&ay(t,e)}const i=this.normalizePose?.(n,r);"function"==typeof this.normalizePose&&fu.log({role:"target",contract:"normalizePose",component:this,args:{carrier:sy(n),slotId:r.id},result:i}),i&&Object.assign(t,i),Object.keys(t).length&&(n.setState?.(t),fu.log({role:"target",contract:"receive:setState",component:this,args:{carrier:sy(n),keys:Object.keys(t)}}))}this.trigger("transfer-received",{type:"transfer-received",component:n,container:this,slotId:r.id,preReceiveWorldPos:c,preReceiveWorldQuat:l}),fu.log({role:"target",contract:"receive:done",component:this,args:{carrier:sy(n),slotId:r.id}})}async dispatch(t,e,n={}){const i=new bu({source:this,target:e,carrier:t,options:n,physical:async()=>{delete t[cy]}}),r=await i.execute();"rolled-back"!==r.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:r.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}canAccept(t){const e=(()=>{const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const n=this.findSlot(t);if(!n){const n=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!n||t.allowedTypes.includes(n))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:n}})();return fu.log({role:"target",contract:"canAccept",component:this,args:{carrier:sy(t)},result:e.ok?{ok:!0,slotId:e.slot.id}:{ok:!1,reason:e.reason}}),e}accept(t,e){return this.receive(t,e)}}).__hasTransferable=!0,n}(s),a=[...t.capabilities??[]];i||a.push("Capacity","PlacementSurface"),r||a.push("Transferable"),a.push("Holdable","FlowNode");var c,l,h;return hy((n=class extends(Sb(o)){get isFlowNode(){return!0}containable(t){return!!t&&!0===t.isItem}get showMoveHandle(){return!1}inboundPorts(){return[]}outboundPorts(){return[]}_bumpReceived(t){const e=this.state?.received??0;this.setState?.({received:e+1})}_bumpDispatched(t){const e=this.state?.dispatched??0;this.setState?.({dispatched:e+1})}_bumpRejected(t,e){const n=this.state?.rejected??0;this.setState?.({rejected:n+1})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e){}resolveDownstream(){const t=this.state?.downstreamRef;if(!t)return[];return(this.root?.findAll?.(t)??[]).map(t=>t?.state?.id).filter(Boolean)}routingLinks(){return{downstream:this.resolveDownstream()}}},c=n,"symbol"==typeof(l="FlowNodeMixed")&&(l=l.description?"[".concat(l.description,"]"):""),Object.defineProperty(c,"name",{configurable:!0,value:h?"".concat(h," ",l):l}),n.capabilities=Object.freeze(a),n.isFlowNode=!0,n))}function kb(t){return!!t&&!0===t.isFlowNode}rg({name:"Holdable",description:"어떤 Component 든 item(데이타바인딩 동적 물건) 을 보유하는 capability. _items + add/remove/forEach + handover + hold/release event + dispose cascade. Container(정적 _components) 와 직교 — 컨테이너 비의존.",methods:["addItem","removeItem","forEachItem","containsItem","handoverIn","handoverOut","_drawItems","_captureItems","dispose"],sourceFile:"src/components/mixins/holdable.ts"}),rg({name:"Transferable",description:"Item 을 노드 간에 옮기는 *이동(move)* 측면. 수용 트랜잭션 라이프사이클(reserve → commit → release)과 receive/accept/dispatch/route 를 제공. 보유(keep — slots/findSlot/canReceive 등)는 Capacity 소관.",methods:["reserve","commit","release","receive","accept","canAccept","dispatch","route","resolveRoute","rejectRoute"],sourceFile:"src/transfer/transferable-mixin.ts"}),rg({name:"FlowNode",description:"Flow graph 의 노드 — 구조 (inbound/outbound port + slot) + flow (route + 5-phase transfer stat). 보유(_items/handover)는 Holdable base 위임. 모든 flow 컴포넌트의 base — Storable/Mobile/Processable 의도가 위에 직교로 적용.",methods:["inboundPorts","outboundPorts","slotIds","slotAt","route","resolveRoute","rejectRoute"],models:["Port","SlotInfo","Vec3"],sourceFile:"src/flow/flow-node.ts"});const Ab={x:0,y:0,z:0,w:1};function Eb(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function Cb(t,e){const n=t.rotation,i=e.rotation,r=e.position,s=n.w*r.x+n.y*r.z-n.z*r.y,o=n.w*r.y+n.z*r.x-n.x*r.z,a=n.w*r.z+n.x*r.y-n.y*r.x,c=-n.x*r.x-n.y*r.y-n.z*r.z,l=s*n.w+c*-n.x+o*-n.z-a*-n.y,h=o*n.w+c*-n.y+a*-n.x-s*-n.z,d=a*n.w+c*-n.z+s*-n.y-o*-n.x,u={x:n.w*i.x+n.x*i.w+n.y*i.z-n.z*i.y,y:n.w*i.y-n.x*i.z+n.y*i.w+n.z*i.x,z:n.w*i.z+n.x*i.y-n.y*i.x+n.z*i.w,w:n.w*i.w-n.x*i.x-n.y*i.y-n.z*i.z};return{position:{x:t.position.x+l,y:t.position.y+h,z:t.position.z+d},rotation:u}}const Tb={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function Pb(t){const{carrierWorld:e,width:n,depth:i,entryHeight:r,mountLocalY:s,approachDistance:o,sides:a,toolType:c,tolerance:l,priority:h}=t,d="number"==typeof s?{position:{x:0,y:s,z:0},rotation:{...Ab}}:void 0,u=n/2,p=i/2;return a.map(t=>{const n=Tb[t],i="string"==typeof c?c:c[t]??"unknown",s={position:{x:n.axis.x*("east"===t||"west"===t?u:0),y:r,z:n.axis.z*("north"===t||"south"===t?p:0)},rotation:Eb(n.yaw)},a={position:{x:s.position.x+n.axis.x*o,y:r,z:s.position.z+n.axis.z*o},rotation:Eb(n.yaw)};return{id:`entry-${n.idSuffix}`,toolType:i,approach:Cb(e,a),engage:Cb(e,s),...d?{mount:d}:{},tolerance:l,priority:h}})}function Ob(t){const{carrierWorld:e,topY:n,approachDistance:i,toolType:r,mountLocalY:s,tolerance:o,priority:a,id:c}=t,l={position:{x:0,y:n,z:0},rotation:{...Ab}};return{id:c??"top",toolType:r,approach:Cb(e,{position:{x:0,y:n+i,z:0},rotation:{...Ab}}),engage:Cb(e,l),..."number"==typeof s?{mount:{position:{x:0,y:s,z:0},rotation:{...Ab}}}:{},tolerance:o,priority:a}}function Db(t,e){return t.filter(t=>t.toolType===e.toolType)}function zb(t,e){if(0===t.length)return null;const n=t.map(t=>{const n=t.approach.position.x-e.x,i=t.approach.position.y-e.y,r=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(n*n+i*i+r*r)}});return n.sort((t,e)=>{const n=t.f.priority??0,i=e.f.priority??0;return n!==i?n-i:t.dist-e.dist}),n[0].f}class Ib{constructor(t){this.owner=t}positionAt(t,e,n,i){if(0!==t)return null;const r=this.owner?.state?.width??0,s=this.owner?.state?.height??0,o=i?.state?.width??0,a=i?.state?.height??0;return{x:Math.max(0,(r-o)/2),y:Math.max(0,(s-a)/2),z:0}}capacity(t){return t.maxCount??1}}let Rb=1;function Lb(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const jb={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class Fb{constructor(t=jb){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+Rb++},n=(this._byResource.get(e.resource)??[]).filter(t=>Lb(t.timeWindow,e.timeWindow));if(0===n.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const i=n.map(t=>{const n=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:n}});if(i.every(t=>"b-yields"===t.decision)){const i=n.slice();for(const t of i)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:i,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:i}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:n.slice(),outcome:"rejected"}),{ok:!1,conflicts:i}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>Lb(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const n=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);n<0?e.push(t):e.splice(n,0,t);let i=this._byReserver.get(t.reserverId);i||(i=[],this._byReserver.set(t.reserverId,i)),i.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const n=e.findIndex(e=>e.id===t.id);if(n<0)return!1;e.splice(n,1),0===e.length&&this._byResource.delete(t.resource);const i=this._byReserver.get(t.reserverId);if(i){const e=i.findIndex(e=>e.id===t.id);e>=0&&i.splice(e,1),0===i.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const Nb=new Fb;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=Nb);class Hb{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,n=1/0;for(const i of this.nodes.values()){const r=Bb(i.position,t);r<n&&(n=r,e=i)}return e}}function Bb(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}function Yb(t,e){return Math.sqrt(Bb(t,e))}function Vb(t,e,n={}){const i=new Hb,r=n.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const n=`${e.id}:start`,s=`${e.id}:end`;i.addNode({id:n,position:t[0],type:"lane-start"}),i.addNode({id:s,position:t[t.length-1],type:"lane-end"}),i.laneEndpoints.set(e.id,{startNodeId:n,endNodeId:s});let o=0;for(let e=1;e<t.length;e++)o+=Yb(t[e-1],t[e]);const a=o/(e.speedLimit??r)*1e3;i.addEdge({fromNode:n,toNode:s,resource:e.id,distance:o,durationMs:a,forward:!0}),"twoway"===e.direction&&i.addEdge({fromNode:s,toNode:n,resource:e.id,distance:o,durationMs:a,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const n of t.lanes){const r=i.laneEndpoints.get(n);if(!r)continue;const s=i.nodes.get(r.startNodeId).position,o=i.nodes.get(r.endNodeId).position;let a=0,c=0,l=0;for(const e of t.lanes){if(e===n)continue;const t=i.laneEndpoints.get(e);if(!t)continue;const r=i.nodes.get(t.startNodeId).position,h=i.nodes.get(t.endNodeId).position;a+=Math.min(Bb(s,r),Bb(s,h)),c+=Math.min(Bb(o,r),Bb(o,h)),l++}if(0===l)continue;const h=a<c?r.startNodeId:r.endNodeId;e.push({laneId:n,nodeId:h,pos:i.nodes.get(h).position})}for(let n=0;n<e.length;n++)for(let r=0;r<e.length;r++){if(n===r)continue;const s=e[n],o=e[r],a=Yb(s.pos,o.pos);i.addEdge({fromNode:s.nodeId,toNode:o.nodeId,resource:t.id,distance:a,durationMs:t.crossingTimeMs,forward:!0})}}return i}function Gb(t,e,n,i={}){const r=t.nodes.get(e),s=t.nodes.get(n);if(!r||!s)return null;const o=i.speed?.max??100,a=e=>{const n=t.nodes.get(e);var i,r;return(i=n.position,r=s.position,Math.sqrt(function(t,e){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r}(i,r)))/o*1e3},c=new Map,l=new Set,h=new Set,d={nodeId:e,gScore:0,fScore:a(e)};c.set(e,d),l.add(e);const u=i.startSimMs??0,p=i.deadlineSimMs;for(;l.size>0;){let e=null,i=null;for(const t of l){const n=c.get(t);(!i||n.fScore<i.fScore||n.fScore===i.fScore&&t<e)&&(i=n,e=t)}if(!i||!e)return null;if(e===n){const t=[];let e=i,n=0;for(;e&&e.cameFromEdge;){const i=e.cameFromEdge,r=u+(e.gScore-i.durationMs);t.unshift({resource:i.resource,timeWindow:{startSimMs:r,endSimMs:r+i.durationMs},fromPos:i.fromPos,toPos:i.toPos}),n+=i.distance,e=c.get(i.fromNodeId)}const r=i.gScore;return void 0!==p&&u+r>p?null:{segments:t,totalDurationMs:r,totalDistance:n}}l.delete(e),h.add(e);for(const n of t.edgesFrom(e)){if(h.has(n.toNode))continue;const e=i.gScore+n.durationMs,r=c.get(n.toNode);if(!r||e<r.gScore){const i=t.nodes.get(n.fromNode),r=t.nodes.get(n.toNode),s={nodeId:n.toNode,gScore:e,fScore:e+a(n.toNode),cameFromEdge:{fromNodeId:n.fromNode,resource:n.resource,distance:n.distance,durationMs:n.durationMs,fromPos:i.position,toPos:r.position}};c.set(n.toNode,s),l.add(n.toNode)}}}return null}function Wb(t,e,n=0,i){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:n,metadata:i}))}const Ub={closed:!0,round:0,divisions:24};class Xb{constructor(t,e){this.points=t,this.closed=e;const n=[0];for(let e=1;e<t.length;e++){const i=t[e].x-t[e-1].x,r=t[e].y-t[e-1].y;n.push(n[e-1]+Math.sqrt(i*i+r*r))}this.cumulative=n,this.length=n[n.length-1]??0}sample(t){const e=this.length;if(0===this.points.length)return{x:0,y:0,theta:0};if(0===e)return{x:this.points[0].x,y:this.points[0].y,theta:0};let n=t;this.closed?n=(t%e+e)%e:n<0?n=0:n>e&&(n=e);const i=this.cumulative;let r=0,s=i.length-2;for(;r<s;){const t=r+s>>1;i[t+1]<=n?r=t+1:s=t}const o=i[r+1]-i[r],a=o>0?(n-i[r])/o:0,c=this.points[r],l=this.points[r+1],h=l.x-c.x,d=l.y-c.y;return{x:c.x+h*a,y:c.y+d*a,theta:0===h&&0===d?0:Math.atan2(d,h)}}}function qb(t,e={}){const n={...Ub,...e},i=t.length;if(0===i)return new Xb([],n.closed);if(1===i)return new Xb([{x:t[0].x,y:t[0].y}],n.closed);const r=[],s=(t,e)=>{if(r.length>0){const n=r[r.length-1];if(Math.abs(n.x-t)<1e-9&&Math.abs(n.y-e)<1e-9)return}r.push({x:t,y:e})},o=(n.closed,i);for(let e=0;e<o;e++){const r=0===e?n.closed?i-1:-1:e-1,o=e===i-1?n.closed?0:-1:e+1,a=r>=0?t[r]:null,c=t[e],l=o>=0?t[o]:null;if(a&&a.x===c.x&&a.y===c.y)continue;const h=a&&l?Js(c,n.round):0;let d,u,p,f;if(a){const t=Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),e=0!==t?Math.atan2(a.x-c.x,a.y-c.y):0,n=Math.min(h,t/2);d=Math.sin(e)*n+c.x,u=Math.cos(e)*n+c.y}else d=c.x,u=c.y;if(l){const t=Math.sqrt((l.x-c.x)**2+(l.y-c.y)**2),e=0!==t?Math.atan2(l.x-c.x,l.y-c.y):0,n=Math.min(h,t/2);p=Math.sin(e)*n+c.x,f=Math.cos(e)*n+c.y}else p=c.x,f=c.y;if(s(d,u),h>0&&a&&l)for(let t=1;t<=n.divisions;t++){const e=t/n.divisions,i=1-e;s(i*i*d+2*i*e*c.x+e*e*p,i*i*u+2*i*e*c.y+e*e*f)}else d===p&&u===f||s(p,f);if(l&&$s(c)){const t=Js(l,n.round),e=Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2),i=0!==e?Math.atan2(c.x-l.x,c.y-l.y):0,r=Math.min(t,e/2),o=Ks({x:p,y:f},{x:Math.sin(i)*r+l.x,y:Math.cos(i)*r+l.y},c.bulge);if(o){let t=o.endAngle-o.startAngle;if(o.clockwise)for(;t>0;)t-=2*Math.PI;else for(;t<0;)t+=2*Math.PI;for(let e=1;e<=n.divisions;e++){const i=e/n.divisions,r=o.startAngle+t*i;s(o.cx+o.radius*Math.cos(r),o.cy+o.radius*Math.sin(r))}}}}if(n.closed&&r.length>0){const t=r[0],e=r[r.length-1];(Math.abs(e.x-t.x)>1e-9||Math.abs(e.y-t.y)>1e-9)&&r.push({x:t.x,y:t.y})}return new Xb(r,n.closed)}function $b(t,e){return qb(t,e).length}function Kb(t){return t?/forklift|agv|amr|oht|tugger|worker/i.test(t)?"mobile":/conveyor|sorter|induct|chute|belt/i.test(t)?"flow":/rack|shelf|stocker|cell/i.test(t)?"cell":/pallet|box|parcel|crate|drum|tray/i.test(t)?"atomic":/robot[-_]?arm|crane|lift/i.test(t)?"articulated":/spawn[-_]?point|sink[-_]?point/i.test(t)?"boundary":"":""}function Qb(t){const e=[];let n=t.parent;for(;n&&!n.isRootModel?.();){const t=n.state?.id??n.constructor?.name;t&&e.unshift(t),n=n.parent}return e.join(" › ")}function Zb(t,e=!0){const n=t.constructor?.name??t.state?.type??"Component",i={type:n,id:t.state?.id??`?${t._id??Math.random().toString(36).slice(2,7)}`,category:Kb(n),parentId:t.parent?.state?.id,parentPath:Qb(t)},r=t._realObject?.object3d;if(r){r.updateWorldMatrix?.(!0,!1);const t=r.matrixWorld?.elements;t&&(i.pose={position:{x:t[12],y:t[13],z:t[14]},rotation:{x:0,y:0,z:0,w:1}})}if(!0===t.isItem&&(i.isItem=!0),!0===t.isMover&&(i.isMover=!0),"function"!=typeof t.canReceive&&"function"!=typeof t.canAccept||(i.isHolder=!0),"function"==typeof t.pickupFrames)try{i.isPickable=t.pickupFrames().length>0}catch{i.isPickable=!1}if("string"==typeof t.toolType||"function"==typeof t.toolType?i.toolType="function"==typeof t.toolType?t.toolType():t.toolType:void 0!==t.toolType&&(i.toolType=String(t.toolType)),t.state&&"object"==typeof t.state){const e={};for(const[n,i]of Object.entries(t.state))"string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i&&null!==i||(e[n]=i);i.state=e}if(e){const e=t.components??[];i.childIds=e.map(t=>t.state?.id).filter(Boolean)}return i}function Jb(t){function e(t,n){if(!t)return;n.push(Zb(t));const i=t.components??[];for(const t of i)e(t,n)}function n(t,e){if(!e)return null;if(e.state?.id===t)return e;const i=e.components??[];for(const e of i){const i=n(t,e);if(i)return i}return null}return{version:"0.1.0",collectComponents(){const n=[];return e(t?.rootModel??t,n),n},getComponent(e){const i=n(e,t?.rootModel??t);if(!i)return null;const r={...Zb(i)};if("function"==typeof i.pickupFrames)try{r.pickupFrames=i.pickupFrames()}catch{}if("object"==typeof i.slots)try{r.slots=Array.isArray(i.slots)?i.slots:"function"==typeof i.slots?i.slots():[]}catch{}if("function"==typeof i.acceptanceRotation)try{r.acceptanceWorldQuat=i.deliveryWorldRotation?.(null)??void 0}catch{}if("function"==typeof i.deliveryWorldPosition)try{r.deliveryWorldPosition=i.deliveryWorldPosition(null)}catch{}return r},simStatus(){let e=0;const n=[t?.rootModel??t];for(;n.length>0;){const t=n.pop();if(!t)continue;!0===t.isItem&&e++;const i=t.components??[];for(const t of i)n.push(t)}return{simTime:zs.now,realTime:"undefined"!=typeof performance?performance.now():Date.now(),speed:zs.speed,paused:zs.isPaused,carrierCount:e}},transferLog(){const t={};_u.flows().forEach((e,n)=>{t[n]=e});const e={};_u.targetCounts().forEach((t,n)=>{e[n]=t});const n={};return _u.rejectReasonCounts().forEach((t,e)=>{n[e]=t}),{entries:_u.toJSON(),stats:_u.stats(),flows:t,targetCounts:e,rejectReasonCounts:n}},reservations(){const t=[...Nb.all()],e={},n={};for(const i of t)(e[i.resource]??=[]).push(i),(n[i.reserverId]??=[]).push(i);for(const t of Object.values(e))t.sort((t,e)=>t.timeWindow.startSimMs-e.timeWindow.startSimMs);for(const t of Object.values(n))t.sort((t,e)=>t.timeWindow.startSimMs-e.timeWindow.startSimMs);return{simTime:zs.now,all:t,byResource:e,byReserver:n}},conflicts(){const t=Nb.conflictLog(),e={},n={};let i=0,r=0;for(const s of t)e[s.resource]=(e[s.resource]??0)+1,n[s.proposed.reserverId]=(n[s.proposed.reserverId]??0)+1,"rejected"===s.outcome?i++:r++;return{simTime:zs.now,log:[...t],total:t.length,rejected:i,preempted:r,byResource:e,byReserver:n}}}}function t_(t){const e=Jb(t);return"undefined"!=typeof window&&(window.__SCENE_INSPECTOR__=e),e}let e_=0;const n_=new FinalizationRegistry(()=>{e_--});class i_{static get residents(){return e_}static get residentsCount(){return e_}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,e_++,n_.register(this,e_)}dispose(){if(this.disposer)for(const t in this.references)this.disposer(t,this.references[t]);this.references={},this.counters={}}get ids(){return Object.keys(this.references)}create(t){return new Promise((e,n)=>{this.creator?this.creator(t,n=>{n.release=()=>{this.disposer?.(t,n),delete n.release,Ji("RELEASED",t)},e(n)},n):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))})}add(t,e){const n=new Promise((n,i)=>{const r=this.references[t];if(r)r===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(r);else{const r=e=>{e.release=()=>{this.release(e)},this.references[t]=e,this.counters[t]=1,n(e)};if(e)r(e);else{if(!this.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));this.creator(t,r,i)}}});return this.references[t]||(this.references[t]=n),n}async get(t,e=!1){let n=this.references[t];if(n){if(!(n instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,n}if(e)return n=await n,this.counters[t]++,n}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(const e in this.references){if(this.references[e]===t)return e}}release(t){const e=this._id(t);if(!e)return void Qi("No Referenced ID");const n=this.references[e];n&&(this.counters[e]--,0==this.counters[e]&&(this.disposer?.(e,n),delete this.references[e],delete this.counters[e],delete t.release,Ji("RELEASED",e)))}}const r_={},s_={};let o_=[];function a_(t){const e=t.target,n="SCRIPT"===e.tagName?r_:s_,i=e.src||e.href;n[i]=!0,o_.forEach((t,e)=>{if(!t)return;const{resolve:r,scripts:s,styles:o}=t;if(n===r_){const t=s.indexOf(i);t>-1&&t<s.length-1&&l_(s[t+1])}s.some(t=>!r_[t])||o?.some(t=>!s_[t])||(r(),o_[e]=null)}),o_=o_.filter(Boolean)}function c_(t){if("string"==typeof t)return;const e=t.target,n=e.src,i="SCRIPT"===e.tagName?r_:s_;o_.forEach((e,r)=>{if(!e)return;const{reject:s,scripts:o,styles:a}=e;(i===r_&&o.includes(n)||i===s_&&!!a?.includes(n))&&(s(t),o_[r]=null)}),o_=o_.filter(Boolean),delete i[n],document.head.removeChild(e)}function l_(t){r_[t]=!1;const e=document.createElement("script");e.onload=a_,e.onerror=c_,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class h_{static load(t,e){const n="string"==typeof t?[t]:t,i="string"==typeof e?[e]:e;return new Promise(function(t,e){if(n&&!Array.isArray(n)||i&&!Array.isArray(i))return void e(new Error("invalid sources for load"));let r,s=!0;if(i?.forEach(t=>{t in s_||function(t){s_[t]=!1;const e=document.createElement("link");e.onload=a_,e.onerror=c_,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),s_[t]||(s=!1)}),n&&n.length>0)for(const t of n)t in r_?r_[t]||(s=!1):r??=t;if(r)l_(r);else if(s)return void t();o_.push({resolve:t,reject:e,scripts:n,styles:i})})}}const d_="0.0.0";function u_(t){if(!(t>0))return 1;let e=0;if(!(t&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function p_(t){const{lineWidth:n=0}=t.state;let{width:i,height:r}=t.bounds;i+=n,r+=n;const s=u_(2*i),o=u_(2*r),a=up(s,o),c=new e.CanvasTexture(a);return f_(a,t,2),c.needsUpdate=!0,c.wrapS=e.RepeatWrapping,c.wrapT=e.RepeatWrapping,c.offset.set(0,1-2*r/o),c.repeat.set(2*i/s,2*r/o),c.magFilter=e.NearestFilter,c.minFilter=e.LinearFilter,c.colorSpace=e.SRGBColorSpace,c}function f_(t,e,n){const{lineWidth:i=0}=e.state;let{left:r,top:s}=e.bounds;r-=i/2,s-=i/2;const o=t.getContext("2d");o.scale(n,n),o.translate(-r,-s),e.render(o),e.postrender(o)}function g_(t,e,n=2){const i=t.getContext("2d");i&&(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),f_(t,e,n))}const m_=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class y_ extends Zd{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds;if(!t||!n)return;const i=xd(this.component.state.material3d),r=new e.PlaneGeometry(1,1);r.rotateX(-Math.PI/2),this.object3d.geometry=r;const s=p_(this.component),o=new e.MeshStandardMaterial({map:s});Md(o,i),o.transparent=!0,this.object3d.material=o,this.object3d.castShadow=i.castShadow,this.object3d.receiveShadow=i.receiveShadow}updateDimension(){const{width:t,height:e}=this.component.bounds;this.object3d.scale.set(t,1,e)}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this._rebuildTexture()},100)}_rebuildTexture(){this.clear(),this.build(),this.updateTransform(),this.updateDimension(),this.updateHidden()}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(g_(n,this.component,2),e.needsUpdate=!0)}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!m_.has(e)){this._debouncedRebuild();break}}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),t.transparent=!0,this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hd(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}class b_ extends Zd{getObject3dInstance(){return new e.Mesh}build(){super.build(),this.buildGeometry(),this.buildMaterial()}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t,alpha:e=1}=this.component.state,n=this.object3d.material;if(!n)return;const i=Zd.buildFillStyleTexture(this.component);i?(n.map&&n.map.dispose(),i.needsUpdate=!0,n.map=i,n.needsUpdate=!0):"string"==typeof t&&(n.map&&(n.map.dispose(),n.map=null,n.needsUpdate=!0),"transparent"!==t&&"none"!==t&&n.color.set(zd(t))),Dd(n,e,t)}updateStrokeStyle(){const t=this.object3d.getObjectByName("__edgeLines__");t&&(this.object3d.remove(t),Hd(t));const{strokeStyle:n}=this.component.state;if(!n||"transparent"===n||"none"===n)return;const i=this.object3d.geometry;if(!i?.getAttribute("position"))return;const r=new e.EdgesGeometry(i),s=new e.LineBasicMaterial({color:n}),o=new e.LineSegments(r,s);o.name="__edgeLines__",this.object3d.add(o)}updateDimension(){const{width:t,height:e}=this.component.bounds,{depth:n=1}=this.component.state;if(!this.object3d)return;this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}buildMaterial(){const t=xd(this.component.state.material3d),n=new e.MeshStandardMaterial({transparent:!0});Md(n,t),this.object3d.material=n}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;t&&Md(t,xd(this.component.state.material3d))}clear(){return Hd(this.object3d),super.clear()}}function __(t,e,n,i){return[["bold",t],["italic",e],[n+"px",!0],[i,!0]].filter(t=>t[1]).map(t=>t[0]).join(" ")}function v_(t){let e=0;if(!((t=Math.abs(t)||1)&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function x_(t,e,n){const{bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",width:h=t.width,height:d=t.height,offsetX:u=0,offsetY:p=0}=n||{},f=t.getContext("2d");let g,m;f.imageSmoothingEnabled=!1,f.fillStyle=a,f.strokeStyle=a,f.font=__(i,r,o,s),"left"===c||"start"===c?(f.textAlign="left",g=u):"right"===c||"end"===c?(f.textAlign="right",g=u+h):(f.textAlign="center",g=u+h/2);const y=1.2*o,b=String(e).split("\n"),_=y*b.length;m="top"===l||"hanging"===l?p+.1*o:"bottom"===l||"alphabetic"===l?p+d-_+.1*o:p+(d-_)/2+.1*o,f.textBaseline="top";for(const t of b)f.fillText(t,g,m),m+=y}function w_(t,n,i,r){const s=v_(2*n),o=v_(2*i),a=up(s,o),c=a.getContext("2d"),{fillStyle:l}=r||{};if(l&&"object"==typeof l&&l.colorStops?.length){const t=Bd(l,2*n,2*i);t&&c.drawImage(t,0,0)}c.scale(2,2),"string"==typeof l&&""!==l&&"transparent"!==l&&(c.fillStyle=l,c.fillRect(0,0,n,i)),x_(a,t,r);const h=new e.CanvasTexture(a);return h.needsUpdate=!0,h.wrapS=e.RepeatWrapping,h.wrapT=e.RepeatWrapping,h.offset.set(0,1-2*i/o),h.repeat.set(2*n/s,2*i/o),h.minFilter=e.LinearFilter,h.colorSpace=e.SRGBColorSpace,h}function S_(t,n,i,r,s,o,a){const c=new Image;c.crossOrigin="anonymous",c.onload=()=>{const t=2*i,l=2*r,h=v_(t),d=v_(l),u=up(h,d),p=u.getContext("2d");if(o.color&&(p.fillStyle=o.color,p.fillRect(0,0,t,l)),o.fitPattern)p.drawImage(c,0,0,t,l);else{const e=2*(o.width||c.naturalWidth),n=2*(o.height||c.naturalHeight),i=2*(o.offsetX||0),r=2*(o.offsetY||0);let s=0,a=0;switch(o.align){case"center":s=(t-e)/2,a=(l-n)/2;break;case"left-top":break;case"left-bottom":a=l-n;break;case"right-top":s=t-e;break;case"right-bottom":s=t-e,a=l-n;break;case"left":a=(l-n)/2;break;case"right":s=t-e,a=(l-n)/2;break;case"top":s=(t-e)/2;break;case"bottom":s=(t-e)/2,a=l-n}const h=i+s,d=r+a;if(o.noRepeat)p.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,h,d,e,n);else{p.save(),p.rect(0,0,t,l),p.clip();const i=h>0?h-Math.ceil(h/e)*e:h;for(let r=d>0?d-Math.ceil(d/n)*n:d;r<l;r+=n)for(let s=i;s<t;s+=e)p.drawImage(c,0,0,c.naturalWidth,c.naturalHeight,s,r,e,n);p.restore()}}n&&(p.scale(2,2),x_(u,n,s));const f=new e.CanvasTexture(u);f.needsUpdate=!0,f.wrapS=e.RepeatWrapping,f.wrapT=e.RepeatWrapping,f.offset.set(0,1-l/d),f.repeat.set(t/h,l/d),f.minFilter=e.LinearFilter,f.colorSpace=e.SRGBColorSpace,a(f)},c.onerror=()=>{const t=w_(n,i,r,s);a(t)},c.src=t}function M_(t,e){let{bold:n=!1,italic:i=!1,fontFamily:r="Serif",fontSize:s=10,lineHeight:o="normal"}=e||{};t=void 0===t||""==t?" ":String(t);const a=document.createElement("span");a.style.font=__(n,i,s,r),a.style.lineHeight=String(o),a.style.whiteSpace="pre",a.style.position="absolute",a.textContent=t,document.body.appendChild(a);const c=a.getBoundingClientRect();return document.body.removeChild(a),{width:c.width,height:c.height}}class k_ extends b_{get zPriority(){return Ud.DECAL}get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){this.updateDimension()}updateStrokeStyle(){}updateFillStyle(){this.updateText()}updateDimension(){const{width:t,height:n}=this.component.state,i=Math.abs(t)||1,r=Math.abs(n)||1;this.object3d.geometry&&this.object3d.geometry.dispose();const s=new e.PlaneGeometry(i,r);s.rotateX(-Math.PI/2),this.object3d.geometry=s}updateText(){const t=this.object3d.material;if(!t)return;const{width:e,height:n,bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",fillStyle:h}=this.component.state,d=Math.abs(e)||1,u=Math.abs(n)||1,p=this.component.text,f=h&&"none"!==h?h:"transparent",g={bold:i,italic:r,fontFamily:s,fontSize:o,fontColor:a,textAlign:c,textBaseline:l,width:d,height:u,fillStyle:f};if("object"==typeof f&&"pattern"===f?.type&&f.image){return void S_(this.component.app.url(h.image),p,d,u,g,h,e=>{t.map&&t.map.dispose(),t.map=e,t.color.set(16777215),t.needsUpdate=!0})}const m=w_(p,d,u,g);m?(t.map&&t.map.dispose(),t.map=m,t.color.set(16777215),m.needsUpdate=!0):"string"==typeof h&&(""!==h&&"transparent"!==h?t.color.set(zd(h)):t.opacity=0)}updateAlpha(){const{alpha:t=1}=this.component.state,e=this.object3d.material;e.opacity=t,e.transparent=!0}}wp("text",t=>new k_(t));const A_={input:"css3d",select:"css3d",textarea:"css3d",button:"css3d",iframe:"css3d",video:"css3d",label:"texture",table:"texture",progress:"texture"};function E_(t){const e=t.model?.type??"";return"texture"===(A_[e]??"css3d")?new y_(t):new _p(t)}wp("html-overlay-element",E_),wp("html-overlay-container",E_);class C_{setShape({extrudedShape:t,extrudedOptions:n}){this.extrudedShape=t,this.bb=new e.Box2,this.bb.setFromPoints(this.extrudedShape?.extractPoints(0).shape),this.extrudedOptions=n}generateTopUV(t,n,i,r,s){const o=n[3*i],a=n[3*i+1],c=n[3*r],l=n[3*r+1],h=n[3*s],d=n[3*s+1],u=this.bb,p=u.max.x-u.min.x,f=u.max.y-u.min.y;return[new e.Vector2((o-u.min.x)/p,1-(a-u.min.y)/f),new e.Vector2((c-u.min.x)/p,1-(l-u.min.y)/f),new e.Vector2((h-u.min.x)/p,1-(d-u.min.y)/f)]}generateSideWallUV(t,n,i,r,s,o){const a=n[3*i],c=n[3*i+1],l=n[3*i+2],h=n[3*r],d=n[3*r+1],u=n[3*r+2],p=n[3*s],f=n[3*s+1],g=n[3*s+2],m=n[3*o],y=n[3*o+1],b=n[3*o+2],_=this.extrudedOptions?.depth||100,v=this.bb,x=v.max.x-v.min.x,w=v.max.y-v.min.y;return Math.abs(c-d)<.01?[new e.Vector2(a/x,1-l/_),new e.Vector2(h/x,1-u/_),new e.Vector2(p/x,1-g/_),new e.Vector2(m/x,1-b/_)]:[new e.Vector2(c/w,1-l/_),new e.Vector2(d/w,1-u/_),new e.Vector2(f/w,1-g/_),new e.Vector2(y/w,1-b/_)]}}class T_ extends Zd{clear(){return this._mesh=void 0,super.clear()}get shape(){return null}get boundUVGenerator(){return this._boundUVGenerator||(this._boundUVGenerator=new C_),this._boundUVGenerator}build(){super.build();const t=this.effectiveDepth,n=this.shape;if(!n)return;const i=this.boundUVGenerator;i&&i.setShape({extrudedShape:n,extrudedOptions:{depth:t}});const r=this.createGeometry(n),s=this.createMaterials();this._mesh=new e.Mesh(r,s),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const n=this.effectiveDepth,{lineWidth:i=0}=this.component.state,r={steps:1,depth:n,bevelEnabled:i>0,bevelThickness:0,bevelSize:i,bevelSegments:1,UVGenerator:this.boundUVGenerator},s=new e.ExtrudeGeometry(t,r);return s.center(),s}createMaterials(){const t=xd(this.component.state.material3d),n=new e.MeshStandardMaterial;Md(n,t);const i=new e.MeshStandardMaterial;return Md(i,t),[n,i]}createTexture(){const{width:t,height:n}=this.component.bounds,i=v_(t),r=v_(n),s=up(i,r);this.component.render(s.getContext("2d"));const o=new e.CanvasTexture(s);return o.needsUpdate=!0,o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.offset.set(0,1-n/r),o.repeat.set(t/i,n/r),o.minFilter=e.LinearFilter,o}getMaterials(){if(!this._mesh)return;const t=this._mesh.material;return Array.isArray(t)?t:void 0}updateMaterial3d(){super.updateMaterial3d();const t=this.getMaterials();if(!t)return;const e=xd(this.component.state.material3d);for(const n of t)Md(n,e)}updateAlpha(){const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this.getMaterials();i&&(Dd(i[0],t,e),Dd(i[1],t,n))}updateStrokeStyle(){const t=this.getMaterials();if(!t)return;const{strokeStyle:e}=this.component.state;t[1].color.set(zd(e))}updateFillStyle(){this._applyCapTexture()}updateText(){this._applyCapTexture()}_applyCapTexture(){const t=this.getMaterials();if(!t)return;const e=t[0],{fillStyle:n}=this.component.state,i=this.component.hasTextProperty?this.component.text:"";if(!i){const t=Zd.buildFillStyleTexture(this.component);return t?(e.map&&e.map.dispose(),e.map=t,e.color.set(16777215)):(e.map&&(e.map.dispose(),e.map=null),e.color.set(zd(n))),void(e.needsUpdate=!0)}const{bold:r=!1,italic:s=!1,fontFamily:o="Serif",fontSize:a=10,fontColor:c="black",textAlign:l="center",textBaseline:h="middle",paddingTop:d=0,paddingLeft:u=0,paddingRight:p=0,paddingBottom:f=0}=this.component.state,{width:g,height:m}=this.component.bounds,y=Math.abs(g)||1,b=Math.abs(m)||1,_={bold:r,italic:s,fontFamily:o,fontSize:a,fontColor:c,textAlign:l,textBaseline:h,width:Math.max(y-u-p,0),height:Math.max(b-d-f,0),fillStyle:n,offsetX:u,offsetY:d};if("object"==typeof n&&"pattern"===n?.type&&n.image){return void S_(this.component.app.url(n.image),i,y,b,_,n,t=>{e.map&&e.map.dispose(),e.map=t,e.color.set(16777215),e.needsUpdate=!0})}e.map&&e.map.dispose();const v=w_(i,y,b,_);e.map=v,e.color.set(16777215),e.needsUpdate=!0}updateDimension(){super.updateDimension()}onchange(t,e){if("path"in t&&this._mesh){const t=this._mesh.geometry,e=this.shape;if(e){const n=this.createGeometry(e);this._mesh.geometry=n,t.dispose()}}super.onchange(t,e)}}class P_ extends T_{get shape(){const{cx:t=0,cy:n=0,rx:i=1,ry:r=1,startAngle:s=0,endAngle:o=2*Math.PI,anticlockwise:a=!1}=this.component.state,c=new e.EllipseCurve(t,n,Math.abs(i),Math.abs(r),s,o,a,0);return new e.Shape(c.getPoints(50))}}wp("ellipse",t=>new P_(t));class O_ extends T_{get shape(){const{width:t,height:n,round:i=0}=this.component.state,r=Tc(i,t,n);if(r>0){const i=r,s=new e.Path;return s.moveTo(i,0),s.lineTo(t-i,0),s.quadraticCurveTo(t,0,t,i),s.lineTo(t,n-i),s.quadraticCurveTo(t,n,t-i,n),s.lineTo(i,n),s.quadraticCurveTo(0,n,0,n-i),s.lineTo(0,i),s.quadraticCurveTo(0,0,i,0),new e.Shape(s.getPoints(12))}const s=new e.Shape;return s.moveTo(0,0),s.lineTo(t,0),s.lineTo(t,n),s.lineTo(0,n),s.lineTo(0,0),s}}function D_(t,n={}){const i=n.round??0,r=n.divisions??24;if(!t||0===t.length)return new e.Shape;const s=t.some(t=>$s(t)),o=i>0||t.some(t=>Js(t,0)>0);if(s||o){const n=new e.Path;for(let e=0;e<t.length;e++){const r=t[(e-1+t.length)%t.length],s=t[e],o=t[(e+1)%t.length];if(r.x===s.x&&r.y===s.y)continue;const a=Js(s,i);let c=Math.sqrt((r.x-s.x)**2+(r.y-s.y)**2),l=0!==c?Math.atan2(r.x-s.x,r.y-s.y):0;const h=Math.sin(l)*Math.min(a,c/2)+s.x,d=Math.cos(l)*Math.min(a,c/2)+s.y;c=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2),l=0!==c?Math.atan2(o.x-s.x,o.y-s.y):0;const u=Math.sin(l)*Math.min(a,c/2)+s.x,p=Math.cos(l)*Math.min(a,c/2)+s.y;if(0===e?n.moveTo(h,d):n.lineTo(h,d),a>0&&n.quadraticCurveTo(s.x,s.y,u,p),$s(s)){const t=Js(o,i),e=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),r=0!==e?Math.atan2(s.x-o.x,s.y-o.y):0,a=Ks({x:u,y:p},{x:Math.sin(r)*Math.min(t,e/2)+o.x,y:Math.cos(r)*Math.min(t,e/2)+o.y},s.bulge);a&&n.absarc(a.cx,a.cy,a.radius,a.startAngle,a.endAngle,a.clockwise)}}return new e.Shape(n.getPoints(r))}const a=new e.Shape;for(let e=0;e<t.length;e++)0===e?a.moveTo(t[e].x,t[e].y):a.lineTo(t[e].x,t[e].y);return a}wp("rect",t=>new O_(t));class z_ extends T_{get shape(){const{path:t=[],round:e=0}=this.component.state;return D_(t,{round:e,divisions:24})}build(){Object.getPrototypeOf(T_.prototype).build.call(this);const t=this.effectiveDepth,n=this.shape;if(!n)return;const i=this.boundUVGenerator,r=this.minMax;if(i&&void 0!==r.minX&&void 0!==r.maxX&&void 0!==r.minY&&void 0!==r.maxY){const n=new e.Shape;n.moveTo(r.minX,r.minY),n.lineTo(r.maxX,r.minY),n.lineTo(r.maxX,r.maxY),n.lineTo(r.minX,r.maxY),n.closePath(),i.setShape({extrudedShape:n,extrudedOptions:{depth:t}})}else i&&i.setShape({extrudedShape:n,extrudedOptions:{depth:t}});const s=this.createGeometry(n),o=this.createMaterials();this._mesh=new e.Mesh(s,o),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const n=this.effectiveDepth,{lineWidth:i=0}=this.component.state,r={steps:1,depth:n,bevelEnabled:i>0,bevelThickness:0,bevelSize:i,bevelSegments:1,UVGenerator:this.boundUVGenerator},s=new e.ExtrudeGeometry(t,r),o=this.minMax;if(void 0!==o.minX&&void 0!==o.maxX&&void 0!==o.minY&&void 0!==o.maxY){const t=(o.minX+o.maxX)/2,e=(o.minY+o.maxY)/2;s.translate(-t,-e,0),s.computeBoundingBox();const n=s.boundingBox;n&&s.translate(0,0,-(n.min.z+n.max.z)/2)}else s.center();return s}get minMax(){if(!this._minMax){const{path:t}=this.component.state;let e,n,i,r;t.forEach((t,s)=>{if(0==s)return e=i=t.x,void(n=r=t.y);e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),this._minMax={minX:e,minY:n,maxX:i,maxY:r}}return this._minMax}}wp("polygon",t=>new z_(t));class I_ extends T_{get shape(){const{cx:t=0,cy:n=0,rx:i=1,ry:r=1,ratio:s=50,startAngle:o=0,endAngle:a=2*Math.PI,anticlockwise:c=!1}=this.component.state,l=Math.abs(i),h=Math.abs(r),d=new e.EllipseCurve(t,n,l,h,o,a,c,0),u=new e.Shape(d.getPoints(50)),p=l/100*s,f=h/100*s;if(p>0&&f>0){const i=new e.EllipseCurve(t,n,p,f,o,a,c,0),r=new e.Path(i.getPoints(50));u.holes.push(r)}return u}}wp("donut",t=>new I_(t));class R_ extends T_{get shape(){const{x1:t=0,y1:n=0,x2:i=0,y2:r=0,x3:s=0,y3:o=0,round:a=0}=this.component.state,c=[{x:t,y:n},{x:i,y:r},{x:s,y:o}];if(a>0){const t=new e.Path;for(let e=0;e<c.length;e++){const n=c[(e-1+c.length)%c.length],i=c[e],r=c[(e+1)%c.length];let s=Math.sqrt((n.x-i.x)**2+(n.y-i.y)**2),o=0!==s?Math.atan2(n.x-i.x,n.y-i.y):0;const l=Math.sin(o)*Math.min(a,s/2)+i.x,h=Math.cos(o)*Math.min(a,s/2)+i.y;s=Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2),o=0!==s?Math.atan2(r.x-i.x,r.y-i.y):0;const d=Math.sin(o)*Math.min(a,s/2)+i.x,u=Math.cos(o)*Math.min(a,s/2)+i.y;0===e?t.moveTo(l,h):t.lineTo(l,h),t.quadraticCurveTo(i.x,i.y,d,u)}return new e.Shape(t.getPoints(12))}const l=new e.Shape;return l.moveTo(t,n),l.lineTo(i,r),l.lineTo(s,o),l.closePath(),l}}wp("triangle",t=>new R_(t));class L_ extends T_{get shape(){const{ratio:t=30,wing:n=5,cx:i=0,cy:r=0,rx:s=1,ry:o=1}=this.component.state;if(n<3)return null;const a=Math.PI/2,c=2*Math.PI/n,l=s-t/100*s,h=o-t/100*o,d=new e.Shape;d.moveTo(i+s*Math.cos(-a),r+o*Math.sin(-a)),d.lineTo(i+(s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,r+(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let t=1;t<n;t++)d.lineTo(i+s*Math.cos(c*t-a),r+o*Math.sin(c*t-a)),d.lineTo(i+(s-l)*(Math.cos(c*(t+1)-a)+Math.cos(c*t-a))/2,r+(o-h)*(Math.sin(c*(t+1)-a)+Math.sin(c*t-a))/2);return d.closePath(),d}}wp("star",t=>new L_(t));const j_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/sphere"};class F_ extends b_{buildGeometry(){const{rx:t=0,ry:n=0,rz:i}=this.component.state,r=i??t,s=new e.SphereGeometry(1,32,16);s.scale(t,r,n),this.object3d.geometry=s}updateDimension(){this.buildGeometry()}get effectiveDepth(){const{rx:t=0,rz:e}=this.component.state,n=e??t;return Math.max(2*n,1)}}let N_=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new F_(this)}get nature(){return j_}};N_=cg([Xm("sphere")],N_);class H_ extends Zd{getObject3dInstance(){return new e.Sprite}build(){super.build(),this.buildMaterial()}get cz(){const{zPos:t=0}=this.component.state,{height:e}=this.component.bounds,{tz:n=0}=this.component.delta(),i=this.component.parent?._realObject;return t+n+e/2-(i?.geometricOffsetY??0)}get geometricOffsetY(){const{height:t=0}=this.component.bounds;return t/2}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=Zd.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(zd(t)):e.opacity=0)}}class B_ extends H_{buildMaterial(){const t=this.object3d.material;t&&t.dispose(),this.object3d.material=new e.SpriteMaterial({map:p_(this.component),alphaTest:.01,sizeAttenuation:!1})}get scale(){const{width:t,height:e}=this.component.bounds,n=this.threeContainer,{width:i=1,height:r=1}=n?.bounds??{},{scale:s=1}=this.component.state;return{x:s*t/i,y:s*e/r,z:s}}update(){this.build(),this.updateHidden()}updateFillStyle(){this.update()}updateStrokeStyle(){this.update()}updateAlpha(){this.update()}updateText(){this.update()}}const Y_={mutable:!1,resizable:!0,rotatable:!0,properties:[]};let V_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new B_(this)}get nature(){return Y_}};V_=cg([Xm("sprite")],V_);const G_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cube"};class W_ extends b_{buildGeometry(){const{width:t=0,height:n=0,depth:i=0}=this.component.state,r=new e.BoxGeometry(1,1,1);r.scale(t,i,n),this.object3d.geometry=r}}let U_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new W_(this)}get nature(){return G_}};U_=cg([Xm("cube")],U_);const X_={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cylinder"};class q_ extends b_{buildGeometry(){const{rx:t=0,ry:n=0}=this.component.state,i=this.component.state.depth??1,r=new e.CylinderGeometry(1,1,1,25);r.scale(t||1,i||1,n||1),this.object3d.geometry=r}updateDimension(){this.buildGeometry()}}let $_=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new q_(this)}get nature(){return X_}};$_=cg([Xm("cylinder")],$_);const K_={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"color",label:"box-color",name:"boxColor",property:"boxColor"}],help:"scene/component/banner"};class Q_ extends Zd{get zPriority(){return Ud.DECAL}build(){super.build();const{width:t=1,height:e=1,depth:n=1}=this.component.state;this.object3d.add(this.createCube(t,e,n));const i=this.createTextureBoard(t,n);i.position.set(0,0,.5*e+1),this.object3d.add(i)}createCube(t,n,i){const{boxColor:r="#ccaa76"}=this.component.state,s=xd(this.component.state.material3d),o=new e.BoxGeometry(t,i,n),a=new e.MeshStandardMaterial({color:r,side:e.FrontSide});Md(a,s);const c=new e.Mesh(o,a);return c.castShadow=s.castShadow,c.receiveShadow=s.receiveShadow,c}createTextureBoard(t,n){const i=xd(this.component.state.material3d),{fillStyle:r="#ccaa76"}=this.component.state,s=Zd.buildFillStyleTexture(this.component),o=new e.MeshStandardMaterial(s?{map:s}:{color:r||"#ccaa76",side:e.FrontSide});Md(o,i);const a=new e.PlaneGeometry(t,n,1,1),c=new e.Mesh(a,o);return c.castShadow=i.castShadow,c.receiveShadow=i.receiveShadow,c}updateMaterial3d(){super.updateMaterial3d();const t=xd(this.component.state.material3d);this.object3d.traverse(e=>{if(e.isMesh){const n=e.material;n&&Md(n,t),e.castShadow=t.castShadow,e.receiveShadow=t.receiveShadow}})}updateFillStyle(){this.update()}onchange(t,e){super.onchange(t,e),"boxColor"in t&&this.update()}}let Z_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}get nature(){return K_}buildRealObject(){return new Q_(this)}};var J_;Z_=cg([Xm("banner")],Z_);const tv={far:1e5,fov:80,near:1,zoom:1},ev={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"near",name:"near"},{type:"number",label:"far",name:"far"},{type:"number",label:"fov",name:"fov"},{type:"number",label:"zoom",name:"zoom"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/camera"};class nv extends Zd{getObject3dInstance(){return new e.Mesh}updateCamera(){const{near:t=tv.near,far:n=tv.far,fov:i=tv.fov,zoom:r=tv.zoom,showHelper:s}=this.component.state;this.camera.far=n,this.camera.fov=i,this.camera.near=t,this.camera.zoom=r,s?this.helper||(this.helper=new e.CameraHelper(this.camera),this.object3d.add(this.helper)):this.helper&&(this.object3d.remove(this.helper),delete this.helper)}build(){super.build();const{width:t=0,height:n=0,depth:i=0,fillStyle:r="lightgray"}=this.component.state;this.object3d.geometry=new e.BoxGeometry(t,i,n);const s=xd(this.component.state.material3d),o=new e.MeshStandardMaterial({color:r});Md(o,s),this.object3d.material=o,this.object3d.castShadow=s.castShadow,this.object3d.receiveShadow=s.receiveShadow,this.camera=new e.PerspectiveCamera,this.camera.position.set(0,0,0),this.object3d.add(this.camera),this.object3d.lookAt(0,0,0),this.updateCamera()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}}let iv=J_=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}static get image(){return J_._image||(J_._image=new Image,J_._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA1IAAANSAQMAAABV6G1EAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAABlBMVEX6+voBAQGV71ZvAAAFO0lEQVR42u3dMZLkNBiGYakUKFRIqKOISxDvETiCTBEQcgQOQE7clyAi8REm7KDXIhgYoMa/7fbIX+2K9w022MCP/25Z28GW5RwRERERERERERERERERERERERERERERERERERERERERERERERHRl9mv7fdPn7879sf8Mcq3J3r5EJXaUy3Wddrcd6qNybx9F2/lZ63H+nVCa9Oe9elZa5ksa/dDbE+3fsm4v27C89bd+i6W3l+XdcnSWtuxyvPW+hqorbWb0Jr7Pl3m4tjfVMIZ625d6L5pxTPWw7rQY9P6pqu1dF8aq5d83cE3rXrGWluIxV6h53eotv4c1V3Ln7Nm66ZvvZf8SSues16sD2jubz2sC839fmvYiz7t//LJna27wsr7VjlnNWtPeHTfNlae2bZvnaTePUd+74fqV2LNxv6zdN8O3z9HSWhlc4F+dOvdsKbe2+F7q+zPddq6W2ts6r31vrN825/rtPWwvvcL5losy11uxQNz5U6fYT4w12mrWf80TUNZdetXal/LtwNW6WOFI1Y9bU3GVnfFXM9bneZKwrmKcK4qnKsK52q6uULTzRWFVjpkta/OykKrCq02puWFVhRaSWjlQa0itJrO8oNaQWgloZWFVhnUqjrLN50VBrWi0MpCqwitOqjVdFYQWlFopUGtLLSq0GpjWl5oRaGVBrWy0KpCq+ksP6gVhFYSWllolUGtqrNW/jvBZVYY1IpCKwutIrTqoFbTWUFoxUGtJLSK0KpCq41peaEVhVYa1MpCqwqtprP8oFYUWklo5UGtIrSazvJCKwxqRaGVhVYZ1Ko664ems34UWj8Nav0stBoWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhbW/9L6RWgp37WofIek8j2cyveLTkqrCq0itLLQSkJL+Q5k5budle/HVr73e/24gAHenZ6FlvK9+srzAoLQUp65oDy3QnoeRxFaWWgpz2pRnncThJbyzCDpuUtVaBWhlYWW8qwx5RlqynPovNBSnuUnPaOwCK0stJLQUp4BqjzbVHk+rFNaVWgVoZWFlvJc6Si0lGdzK88cV57bLj2PvgitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqxyyahcrH7JKFysJ54rCuYJwLi+cywnn+vdlLp+rCOfKwrnStXP95zLxiJX7WEFoeaHljO/xEqsaf9/FWqz1bM+VzloP655df2uxrnP9XPHKue7OeMDsuWInyx+Y67T1Yv0gs+cKvay6P5fvZZULrdnYFBbbcr2sdKF1MxbZFdZkLLItq3aay6/vJ102eusD2rJKl633nw/o3n+uxbrpLSv1svL6M95hQ3xYNz33t16sC21Zoc+28Xahm+u+Ic7WhbYs1+dRfrvQ5LpvHOaFNq3SZ8n/faEt6twDtli7wrJpxT6P1183/di0Ti36u3XT903Ld1qGrzf9smmdWhyTddNzf8t8UqdtK/dZGq8P2DZ1ZnHcrQ/osWO5PkvDuby7NE58Yctk7Qq3PSv3+bpc3F0aJ56wF+uLX9xu6eOb4es9z/vWc0vR3oZuByjnf2t/fP/54B/2WvvWEREREREREREREREREREREREREREREREREREREREREREREREREX2J/QlrTpqHD8xO1gAAAABJRU5ErkJggg=="),J_._image}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,J_.image,e,n,i,r)}buildRealObject(){return new nv(this)}get nature(){return ev}};iv=J_=cg([Xm("camera")],iv);const rv={mutable:!1,resizable:!0,rotatable:!0,properties:[...Wm],"value-property":"source",help:"scene/component/gltf-object"};let sv=class extends(Um(Pc(Cc))){get nature(){return rv}};sv=cg([Xm("gltf-object")],sv);const ov={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"light-type",name:"lightType",property:{options:["","point","directional"]}},{type:"number",label:"intensity",name:"intensity"},{type:"number",label:"distance",name:"distance"},{type:"number",label:"decay",name:"decay"},{type:"checkbox",label:"cast-shadow",name:"castShadow"},{type:"number",label:"near",name:"near",placeholder:"0.5"},{type:"number",label:"far",name:"far",placeholder:"1000"},{type:"number",label:"fov",name:"fov",placeholder:"90"},{type:"number",label:"zoom",name:"zoom",placeholder:"1"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/light"};class av extends Zd{updatePointLight(){const{lightType:t="point",distance:n=0,intensity:i=10,decay:r=1,fillStyle:s="white",castShadow:o,near:a=.5,far:c=1e3,fov:l=90,zoom:h=1,showHelper:d}=this.component.state;if(this.object3d.color=new e.Color(s),"point"==t&&(this.object3d.distance=n,this.object3d.decay=r),this.object3d.intensity=i,this.object3d.castShadow=o,o){const t=this.object3d.shadow?.camera;t.far=c,t.near=a,t.fov=l,t.zoom=h}if(d){const t=this.object3d.shadow?.camera;this.helper||(this.helper=new e.CameraHelper(t),this.object3d.add(this.helper))}else this.helper&&(this.object3d.remove(this.helper),delete this.helper)}getObject3dInstance(){const{lightType:t="point"}=this.component.state;return"point"==t?new e.PointLight:new e.DirectionalLight}update(){this.clear(),this.build(),this.updateDimension(),this.updateHidden(),this.updatePointLight()}}let cv=class extends zg{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new av(this)}get anchors(){return[]}get nature(){return ov}};cv=cg([Xm("light")],cv);const lv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/wall"};class hv extends b_{buildGeometry(){const{width:t=0,height:n=0,depth:i=0}=this.component.state,r=new e.BoxGeometry(1,1,1);r.scale(t,i,n),this.object3d.geometry=r}}let dv=class extends(Pc(Cc)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new hv(this)}get nature(){return lv}};dv=cg([Xm("wall")],dv);const uv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"},{type:"checkbox",label:"hide-in-2d-view",name:"hideIn2DView"},{type:"checkbox",label:"hide-in-3d-view",name:"hideIn3DView"}],help:"scene/component/floor-plate"};class pv extends Zd{get zPriority(){return Ud.FLOOR}get receivingSurfaceY(){return this.placementSurfaceY()}resolveShadow(){const t=this.component.state,e=t.material3d,{alpha:n=1,fillStyle:i}=t,r=n>=.9&&"none"!==i;return{receive:e?.receiveShadow??!0,cast:e?.castShadow??r}}updateHidden(){const t=this.component.state,e=!!this.component.app?.isViewMode;this.object3d.visible=!(t.hidden||e&&t.hideIn3DView)}clear(){return this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0),this._mesh=void 0,super.clear()}build(){super.build();const{width:t,height:n,depth:i=1}=this.component.state;if(!t||!n)return;const r=Math.abs(t),s=Math.abs(n),o=Math.max(i,.5),a=new e.BoxGeometry(r,o,s),c=this._buildTopMaterial(),l=this._buildSideMaterial(),h=[l,l,c,l,l,l];this._mesh=new e.Mesh(a,h),this._mesh.position.y=0;const{cast:d,receive:u}=this.resolveShadow();this._mesh.castShadow=d,this._mesh.receiveShadow=u,this.object3d.add(this._mesh)}_buildTopMaterial(){const{alpha:t=1,fillStyle:n}=this.component.state,i=xd(this.component.state.material3d),r=Zd.buildFillStyleTexture(this.component);if(r){this._topTexture=r;const s=new e.MeshStandardMaterial({map:r,side:e.DoubleSide});return Dd(s,t,n),s.depthWrite=s.opacity>=.9,Md(s,i),s}const s="string"==typeof n&&"none"!==n?zd(n):"#e0e0e0",o=new e.MeshStandardMaterial({color:s,side:e.DoubleSide});return Dd(o,t,n),o.depthWrite=o.opacity>=.9,Md(o,i),o}_buildSideMaterial(){const{strokeStyle:t,alpha:n=1}=this.component.state,i="string"==typeof t&&t?zd(t):"#999999",r=xd(this.component.state.material3d),s=new e.MeshStandardMaterial({color:i});return Md(s,r),s.side=e.DoubleSide,Dd(s,.8*n,t),s.depthWrite=s.opacity>=.9,s}updateAlpha(){if(!this._mesh)return;const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this._mesh.material;for(let r=0;r<i.length;r++){const s=i[r];2===r?Dd(s,t,e):Dd(s,.8*t,n),s.depthWrite=s.opacity>=.9}}updateFillStyle(){if(!this._mesh)return;this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0);const t=this._mesh.material;t[2].dispose(),t[2]=this._buildTopMaterial()}updateStrokeStyle(){if(!this._mesh)return;const t=this._mesh.material,e=this._buildSideMaterial();for(let n=0;n<t.length;n++)2!==n&&(t[n].dispose(),t[n]=e)}}let fv=class extends ql{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new pv(this)}get nature(){return uv}get hidden(){return!!this.getState("hideIn2DView")||super.hidden}};fv=cg([Xm("floor-plate")],fv);function gv(t,n={}){const i=n.size??5,r=n.color??4500172,s=n.emissive??2245734,o=new e.SphereGeometry(i,16,12),a=new e.MeshStandardMaterial({color:r,emissive:s,emissiveIntensity:.15,metalness:.3,roughness:.4,transparent:!0,opacity:.35}),c=new e.Mesh(o,a);n.position&&c.position.set(n.position[0],n.position[1],n.position[2]),c.userData.alwaysRaycast=!0,c.scale.setScalar(1),c.visible=n.visible??!(!0===t.app?.isViewMode);const l=()=>{a.emissiveIntensity=.9,a.opacity=.95,c.scale.setScalar(1.35),t.invalidate?.()},h=()=>{a.emissiveIntensity=.15,a.opacity=.35,c.scale.setScalar(1),t.invalidate?.()};return t.on("mouseenter",l),t.on("mouseleave",h),c.userData.dispose=()=>{t.off("mouseenter",l),t.off("mouseleave",h)},c}class mv extends b_{get zPriority(){return Ud.DECAL}get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){const{width:t,height:n}=this.component.state,i=Math.abs(t)||1,r=Math.abs(n)||1,s=new e.PlaneGeometry(i,r);s.rotateX(-Math.PI/2),this.object3d.geometry=s}updateDimension(){this.update()}build(){super.build();const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=Math.max(2,.04*Math.min(n,i));this.object3d.add(gv(this.component,{size:r,position:[n/2-r,r,-i/2+r]}))}}const yv={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/decal"};let bv=class extends(Vm(Pc(Cc))){buildRealObject(){return new mv(this)}get nature(){return yv}};bv=cg([Xm("decal")],bv);class _v extends Zd{getObject3dInstance(){return new e.Group}get allowedGizmoModes(){return this.component.isGroup?.()?["translate"]:null}}const vv="#dde2e8",xv="#9c9c9c",wv="#e8e8ec",Sv=.35;function Mv(t,n,i,r,s){if(!n.visible)return new e.MeshStandardMaterial({transparent:!0,opacity:0,depthWrite:!1});const o=n.alpha*i,a="wall"===r?vv:"floor"===r?xv:wv,c=new e.MeshStandardMaterial({metalness:0,roughness:"wall"===r?.6:.85,transparent:o<1,opacity:o,side:s?e.BackSide:e.DoubleSide});return function(t,e,n,i,r,s){if("string"==typeof n&&n&&"transparent"!==n)t.color.set(n);else{if(n&&"object"==typeof n){const i=!s,o=Zd.buildFillStyleTexture(e,n,{mirror:i,rotation:r});if(o)return t.map&&t.map.dispose(),t.map=o,void t.color.set("#ffffff")}t.color.set(i)}}(c,t,n.fillStyle,a,n.rotation,n.mirror),c}class kv extends _v{get zPriority(){return Ud.BACKDROP}get position(){if(this.component.state.fitToBoard){return{x:0,y:super.position.y,z:0}}return super.position}build(){super.build();const t=this.component.state;let n=t.width,i=t.height;if(t.fitToBoard){const t=this.component.rootModel,e=t?.state;e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(n=e.width,i=e.height)}const r=this.effectiveDepth||Math.min(n,i)||200,s=t.alpha??1,o=!1!==t.seeThrough,a={east:this._resolveFace("east",vv,!0,Sv),west:this._resolveFace("west",vv,!0,Sv),north:this._resolveFace("north",vv,!0,Sv),south:this._resolveFace("south",vv,!0,Sv),floor:this._resolveFace("floor",xv,!0,1),ceiling:this._resolveFace("ceiling",wv,!0,1)},c=[Mv(this.component,a.east,s,"wall",o),Mv(this.component,a.west,s,"wall",o),Mv(this.component,a.ceiling,s,"ceiling",o),Mv(this.component,a.floor,s,"floor",o),Mv(this.component,a.south,s,"wall",o),Mv(this.component,a.north,s,"wall",o)],l=new e.BoxGeometry(n,r,i),h=new e.Mesh(l,c);if(h.receiveShadow=!0,this.object3d.add(h),this.component.app?.isEditMode){const t=new e.LineBasicMaterial({color:4473941,transparent:!0,opacity:.7}),n=new e.LineSegments(new e.EdgesGeometry(l),t);this.object3d.add(n)}const d=.04*Math.min(n,i,r);this.object3d.add(gv(this.component,{size:d,position:[n/2,r/2+d,-i/2]}))}_resolveFace(t,e,n,i){const r=this.component.state,s=r.faces?.[t]??{},o=s.visible,a=s.alpha,c=s.rotation,l=90===c||180===c||270===c?c:0;return{fillStyle:s.fillStyle??e,visible:"boolean"==typeof o?o:n,alpha:"number"==typeof a&&Number.isFinite(a)?a:i,rotation:l,mirror:!0===s.mirror}}updateDimension(){}onchange(t,e){["alpha","width","height","depth","fitToBoard","faces","seeThrough"].some(e=>e in t)?this.update():super.onchange(t,e)}updateAlpha(){}}const Av={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"checkbox",label:"fit-to-board",name:"fitToBoard"},{type:"checkbox",label:"see-through",name:"seeThrough"},{type:"backdrop-faces",label:"",name:"faces"}],help:"scene/component/backdrop"};let Ev=class extends(Vm(Pc(Cc))){buildRealObject(){return new kv(this)}get nature(){return Av}added(t){super.added?.(t),this.state.fitToBoard&&(this._syncFromRoot(!0),this._attachRootListener())}async ready(){await super.ready(),this.state.fitToBoard&&this._syncFromRoot(!1)}removed(t){this._detachRootListener(),super.removed?.(t)}dispose(){this._detachRootListener(),super.dispose?.()}onchange(t,e){"fitToBoard"in t&&(t.fitToBoard?(this._syncFromRoot(!0),this._attachRootListener()):this._detachRootListener()),super.onchange?.(t,e)}_syncFromRoot(t=!1){const e=this.rootModel;if(!e||e===this)return;const n=e.state;if(!n)return;const i={},r=Number.isFinite(n.width)?n.width:this.state.width,s=Number.isFinite(n.height)?n.height:this.state.height;r!==this.state.width&&(i.width=r),s!==this.state.height&&(i.height=s);const o=Number.isFinite(n.left)?n.left:0,a=Number.isFinite(n.top)?n.top:0;if(o!==this.state.left&&(i.left=o),a!==this.state.top&&(i.top=a),t){const t=this.state.depth;if(!("number"==typeof t&&Number.isFinite(t)&&t>0)){const e=Math.min(r,s);e!==t&&(i.depth=e)}}Object.keys(i).length>0&&this.set(i)}_attachRootListener(){if(this._onRootChange)return;const t=this.rootModel;t&&t!==this&&(this._onRootChange=t=>{("width"in t||"height"in t||"left"in t||"top"in t)&&this._syncFromRoot()},t.on?.("change",this._onRootChange))}_detachRootListener(){if(!this._onRootChange)return;const t=this.rootModel;t?.off?.("change",this._onRootChange),this._onRootChange=void 0}};function Cv(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function Tv(t,n,i,r){const s=[];for(let o=1;o<=r;o++){const a=o/r,c=1-a;s.push(new e.Vector3(c*c*t.x+2*c*a*n.x+a*a*i.x,c*c*t.y+2*c*a*n.y+a*a*i.y,c*c*t.z+2*c*a*n.z+a*a*i.z))}return s}Ev=cg([Xm("backdrop")],Ev);class Pv extends Zd{getObject3dInstance(){return new e.Group}get gizmoTransformable(){return!0}get syncZPosOffset(){return 0}get geometricOffsetY(){return 0}syncFromObject3D(){}applyDimensionFromGizmo(t){}build(){super.build(),this._buildLine()}get smoothedPath(){const t=this.worldPath;if(t.length<2)return t;const{round:n=0}=this.component.state;if(n<=0||t.length<3)return t;const i=[];i.push(t[0]);for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=t[r+1];if(!a){i.push(o);break}const c=s.x-o.x,l=s.y-o.y,h=s.z-o.z,d=Math.sqrt(c*c+l*l+h*h),u=Math.min(n,d/2),p=a.x-o.x,f=a.y-o.y,g=a.z-o.z,m=Math.sqrt(p*p+f*f+g*g),y=Math.min(n,m/2),b=d>0?new e.Vector3(o.x+c/d*u,o.y+l/d*u,o.z+h/d*u):o.clone(),_=m>0?new e.Vector3(o.x+p/m*y,o.y+f/m*y,o.z+g/m*y):o.clone();i.push(b),i.push(...Tv(b,o,_,8))}return i}_buildLine(){const t=this.smoothedPath;if(t.length<2)return;const{strokeStyle:n,lineWidth:i=2,alpha:r=1,lineDash:s,begin:o="none",beginSize:a="size5",end:c="none",endSize:l="size5"}=this.component.state,h=Math.max(i,1),d="string"==typeof n&&"transparent"!==n?zd(n):"#000000",u=new e.Color(d),p=this._getResolution(),f=o,g=c,m=Cv(f,h),y=Cv(g,h),b=t[0],_=t[t.length-1],v=(new e.Vector3).subVectors(t[1],b).normalize(),x=(new e.Vector3).subVectors(t[t.length-2],_).normalize(),k=[...t];m>0&&(k[0]=b.clone().add(v.clone().multiplyScalar(m))),y>0&&(k[k.length-1]=_.clone().add(x.clone().multiplyScalar(y)));const A=new M;A.setPositions(k.flatMap(t=>[t.x,t.y,t.z]));const E=function(t,e){switch(t){case"round-dot":return{dashSize:e,gapSize:e};case"square-dot":return{dashSize:2*e,gapSize:e};case"dash":return{dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashSize:4*e,gapSize:2*e};case"long-dash":return{dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashSize:6*e,gapSize:2*e};case"long-dash-dot-dot":return{dashSize:6*e,gapSize:e};default:return null}}(s,h),C=new S({color:u.getHex(),linewidth:h,worldUnits:!0,transparent:r<1,opacity:r,resolution:p,dashed:!!E,dashSize:E?.dashSize??1,gapSize:E?.gapSize??1,dashScale:1});if(this._line2=new w(A,C),this._line2.computeLineDistances(),this.object3d.add(this._line2),"none"!==f){const t=gp(f,fp(a,h));if(t){const n=(new e.Quaternion).setFromUnitVectors(new e.Vector3(1,0,0),v.clone().negate());this._placeTip(t,b,n,u,r,p)}}if("none"!==g){const t=gp(g,fp(l,h));if(t){const n=(new e.Quaternion).setFromUnitVectors(new e.Vector3(1,0,0),x.clone().negate());this._placeTip(t,_,n,u,r,p)}}}_placeTip(t,e,n,i,r,s){const o=t.mesh||t.line2||t.group;if(o){if(o.position.copy(e),o.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(i),e.transparent=r<1,e.opacity=r}else if(t.line2){const e=t.line2.material;e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution.copy(s)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color&&e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution&&e.resolution.copy(s)}});this.object3d.add(o)}}_getResolution(){const t=this.threeContainer?.renderer3d;if(t){return t.getSize(new e.Vector2)}return new e.Vector2(window.innerWidth,window.innerHeight)}onGizmoDragEnd(t){const e=this._component,n=e.path;if(!n||n.length<2)return;const i=this.object3d,{width:r=0,height:s=0}=e.parent?.bounds??{},{x:o,y:a}=e.center,c=i.position,l=i.rotation,h=i.scale,d=this.position;if(Math.abs(c.x-d.x)<.001&&Math.abs(c.y-d.y)<.001&&Math.abs(c.z-d.z)<.001&&Math.abs(l.x)<.001&&Math.abs(l.y)<.001&&Math.abs(l.z)<.001&&Math.abs(h.x-1)<.001&&Math.abs(h.y-1)<.001&&Math.abs(h.z-1)<.001)return;const u=Pv.computeBakedPath(n,{x:o,y:a},{width:r,height:s},i);this._suppressOnchange=!0,e.set({rotation:0,rotationX:0,rotationY:0,zPos:0}),e.mutatePath(null,()=>u),this._suppressOnchange=!1,this.update()}static computeBakedPath(t,n,i,r){const s=i.width,o=i.height,a=n.x,c=n.y;return r.updateMatrixWorld(!0),t.map(t=>{const n=new e.Vector3(t.x-a,t.z||0,t.y-c).applyMatrix4(r.matrixWorld),i={x:n.x+s/2,y:n.z+o/2};return Math.abs(n.y)>.001&&(i.z=n.y),i})}updateStrokeStyle(){this.updateDimension()}updateAlpha(){this.updateDimension()}updateDimension(){this.clear(),this.build()}onchange(t,e){("path"in t||"from"in t||"to"in t)&&(this.updateDimension(),this.updatePosition()),("round"in t||"lineDash"in t||"lineWidth"in t||"begin"in t||"end"in t||"beginSize"in t||"endSize"in t)&&this.updateDimension(),super.onchange(t,e)}clear(){for(;this.object3d.children.length>0;){const t=this.object3d.children[0];this.object3d.remove(t),Hd(t)}return this._line2=void 0,super.clear()}}class Ov extends Pv{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center,r=this.component,s=r.fromEnd?.component?._realObject?.object3d?.position?.y??0,o=r.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((r,a)=>{const c=t.length>1?a/(t.length-1):0;return new e.Vector3(r.x-n,r.z||s+(o-s)*c,r.y-i)})}}wp("line",t=>new Ov(t));class Dv extends Pv{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center;return t.map(t=>new e.Vector3(t.x-n,t.z||0,t.y-i))}}wp("polyline",t=>new Dv(t));class zv extends Pv{get worldPath(){const t=this.component.drawPath;if(!t||t.length<2)return[];const{x:n,y:i}=this.component.center,r=this.component,s=r.fromEnd?.component?._realObject?.object3d?.position?.y??0,o=r.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((r,a)=>{const c=t.length>1?a/(t.length-1):0;return new e.Vector3(r.x-n,r.z||s+(o-s)*c,r.y-i)})}}wp("ortholine",t=>new zv(t)),wp("group",t=>new _v(t));class Iv extends Zd{build(){super.build()}update(){}}const Rv={far:1e5,fov:80,near:1,zoom:1};class Lv extends Zd{build(){super.build()}update(){super.update(),this.updateCamera()}getObject3dInstance(){return new e.PerspectiveCamera}updateCamera(){const{near:t=Rv.near,far:e=Rv.far,fov:n=Rv.fov,zoom:i=Rv.zoom}=this.component.state;this.object3d.far=e,this.object3d.fov=n,this.object3d.near=t,this.object3d.zoom=i}}class jv extends b_{buildGeometry(){const{width:t,height:n}=this.component.state.dimension;this.object3d.geometry=new e.PlaneGeometry(t,n)}buildMaterial(){this.object3d.material=new e.MeshStandardMaterial({opacity:0,side:e.DoubleSide,blending:e.NoBlending})}}class Fv extends Zd{getObject3dInstance(){return new e.Scene}dispose(){for(const t of this.object3d.children)Hd(t);this._animationMixer&&(this._animationMixer.stopAllAction(),this._animationMixer.uncacheRoot(this.object3d),this._animationMixer=void 0),super.dispose()}clear(){return this._floor&&(this.object3d.remove(this._floor),this._floor.material instanceof Array?this._floor.material.forEach(t=>t.dispose()):this._floor.material.dispose(),this._floor.geometry.dispose(),delete this._floor),super.clear()}get floor(){return this._floor}set floor(t){this._floor&&(this.object3d.remove(this._floor),this._floor.clear(),delete this._floor),t&&(this._floor=t,this.object3d.add(t)),this.component.invalidate()}build(){super.build(),this.floor=Dp(this.component)}updateTransform(){}updateDimension(){}updatePosition(){}updateRotate(){}updateScale(){}updateAlpha(){}updateHidden(){}get animationMixer(){return this._animationMixer||(this._animationMixer=new e.AnimationMixer(this.object3d)),this._animationMixer}}const Nv=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Hv extends Zd{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new e.Mesh}build(){super.build();const{width:t,height:n}=this.component.bounds;if(!t||!n)return;const i=xd(this.component.state.material3d),r=new e.PlaneGeometry(1,1);r.rotateX(-Math.PI/2),this.object3d.geometry=r;const s=p_(this.component),o=new e.MeshStandardMaterial({map:s});Md(o,i),o.transparent=!0,this.object3d.material=o,this.object3d.castShadow=i.castShadow,this.object3d.receiveShadow=i.receiveShadow}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Dd(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}get dimension(){const{width:t,height:e}=this.component.bounds;return{width:t||1,height:e||1,depth:1}}get scale(){const t=super.scale,{width:e,height:n}=this.dimension;return{x:t.x*e,y:t.y,z:t.z*n}}updateDimension(){this.updateTransform()}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this.update()},100)}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(g_(n,this.component,2),e.needsUpdate=!0)}update(){this.clear(),this.build(),this.updateDimension(),this.updateTransform(),this.updateHidden()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!Nv.has(e)){this._debouncedRebuild();break}}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=xd(this.component.state.material3d);Md(t,e),t.transparent=!0,this.object3d.castShadow=e.castShadow,this.object3d.receiveShadow=e.receiveShadow}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hd(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}const Bv={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"precision",name:"precision",property:{options:[{display:"High",value:"highp"},{display:"Medium",value:"mediump"},{display:"Low",value:"lowp"}]}},{type:"checkbox",label:"anti-alias",name:"antialias",property:"antialias"},{type:"checkbox",label:"3dmode",name:"threed",property:"threed"},{type:"checkbox",label:"auto-rotate",name:"autoRotate",property:"autoRotate"},{type:"checkbox",label:"debug",name:"debug",property:"debug"}],help:"scene/component/three-container"};let Yv=class extends yg{constructor(){super(...arguments),this._capability=new sf}get sceneManager(){return this._capability.sceneManager}get cameraManager(){return this._capability.cameraManager}get rendererManager(){return this._capability.rendererManager}get lightManager(){return this._capability.lightManager}get controlsManager(){return this._capability.controlsManager}get eventManager(){return this._capability.eventManager}containable(t){return!0}is3dContainer(){return!0}getLightingConfig(){return{hemisphere:{skyColor:16777215,groundColor:14540253,intensity:1},directional:{color:16777215,intensity:1.2,attachToCamera:!0,castShadow:!1}}}getCss3DSceneAttribute(){return"three-container:css3d-renderer"}init_scene3d(){this._capability.isInitialized&&this._capability.destroy(),this._capability.init(this,{lightingConfig:this.getLightingConfig(),css3DSceneAttribute:this.getCss3DSceneAttribute(),skipEnvironment:!0,skipPostprocessing:!0,skipShadowMap:!0}),this._capability.buildOverlays(),this._capability.resize(),this.onchangeData&&this.onchangeData(this.data,this.data)}destroy_scene3d(){this.stop(),this._capability.destroy()}stop(){}resize(){this._capability.resize()}get scene3d(){return this._capability.isInitialized||this.init_scene3d(),this._capability.scene3d}get renderer3d(){return this._capability.renderer3d}get mixer(){return this._capability.mixer}get css3DScene(){return this._capability.css3DScene}get css3DRenderer(){return this._capability.css3DRenderer}render_threed(){this._capability.renderThreeD()}get _parentIs3dMode(){return!!this.rootModel?.is3dMode}render(t){this._parentIs3dMode||(this.app.isViewMode&&this.setState("threed",!0),!this.state.threed||this._capability.noSupportWebgl?super.render(t):this._capability.camera&&this._capability.renderCSS3D())}postrender(t){if(this._parentIs3dMode)return;const{left:e,top:n,debug:i,threed:r}=this.state;let{width:s,height:o}=this.bounds;if(s=Math.floor(s),o=Math.floor(o),r){if(this._capability.isInitialized||this.init_scene3d(),this._capability.noSupportWebgl)return void this._capability.showWebglNoSupportText(t,this.state.width,this.state.height);if(!this._capability.renderer3d)return;this._capability.renderThreeD();const r=this._capability.domElement;if(!r||!r.width||!r.height)return;t.drawImage(r,0,0,r.width,r.height,e,n,s,o),i&&this._capability.showDebugFPS(t)}else super.postrender(t)}dispose(){this._capability.dispose(),super.dispose()}get layout(){return Lc.get("three")}get nature(){return Bv}getObjectByRaycast(){return this._capability.getObjectByRaycast()}getObjectsByRaycast(){return this._capability.getObjectsByRaycast()}onchange(t,e){(t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._capability.destroy(),this._capability.onchange(t)}onmousedown(t){this._capability.onMouseDown(t)}onmouseup(t){this._capability.onMouseUp(t)}onmousemove(t){this._capability.onMouseMove(t)}onmouseleave(t){this._capability.onMouseLeave(t)}onwheel(t){this._capability.onWheel(t)&&this.invalidate()}ondblclick(t){this._capability.onDblClick(t)&&this.invalidate()}ondragstart(t){this._capability.onDragStart(t)}ondragmove(t){this._capability.onDragMove(t)&&this.invalidate()}ondragend(t){this._capability.onDragEnd(t)&&this.invalidate()}ontouchstart(t){this._capability.onTouchStart(t)}onpan(t){this._capability.onPan(t)&&this.invalidate()}ontouchend(t){this._capability.onTouchEnd(t)}onkeydown(t){this._capability.onKeyDown(t)}onpinch(t){this._capability.onPinch(t)&&this.invalidate()}ondoubletap(){this._capability.onDoubleTap(),this.invalidate()}};var Vv;Yv=cg([Xm("3d-container")],Yv),Sp(t=>new y_(t)),function(t){t.compile=Ol,t.duplicate=Dl,t.select=tc,t.match=Qa}(Vv||(Vv={})),Li.registerResidents(()=>({componentResidentsCount:Ec.residentsCount,sceneResidentsCount:wu.residentsCount,referenceMapResidentsCount:i_.residentsCount,sceneResidents:Ec.residents}));var Gv=Object.freeze({__proto__:null,AbsoluteLayout:Fc,Animation:Ma,AudioPlayer:pm,BULGE_EPSILON:qs,get Banner(){return Z_},Banner3D:Q_,BoxSelectionManager:Zp,COMMON_PLACEHOLDER_PROPERTIES:Rg,CORE_PLACEHOLDER_TYPES:Ng,get Camera(){return iv},Camera3D:nv,CameraBookmarkManager:Qp,CameraManager:Lp,Capacity:fy,CapacityEventTracker:Km,CardLayout:Hc,CenteringQueueStrategy:Zm,CenteringSlotStrategy:Ib,Component:Ec,Connectable:bf,Container:yg,ContainerAbstract:ql,ControlsManager:Hp,get Cube(){return U_},Cube3D:W_,get Cylinder(){return $_},Cylinder3D:q_,DEFAULT:Kr,DEFAULT_PLACEMENT:Gd,DPPX:Xr,DataLagTracker:Jl,DataSource:Ym,Donut:Dm,DonutExtrude:I_,Ellipse:zg,EllipseExtrude:P_,EventManager3D:Bp,EventMap:pl,FPS:hp,FixedSlotStrategy:dy,get FloorPlate(){return fv},FlowEngine:wb,FlowNode:Mb,GESTURES:qr,get GLTFObject(){return sv},GLTF_BASE_URL_ALIAS:Gm,GenericObject:Fg,GifView:dm,GizmoManager:Vp,GizmoOperationManager:Up,GlobalRef:xm,GltfComponent:Um,GridStacking:ey,Group:mm,HTMLAbsoluteLayout:jc,HTMLOverlayContainer:_m,HTMLOverlayElement:Jg,Holdable:Sb,ImageView:Zg,InfoWindow:Ic,InteractionManager:Xp,ItemsDataBinding:hy,KEYEVENTS:$r,Layer:Yu,Layout:Lc,LightManager:Fp,LightObject:av,Line:Og,Line3D:Ov,LinearHorizontalLayout:Yc,LinearVerticalLayout:Gc,LoadTracker:nh,LoadingOverlay:Pd,LocalRef:bm,MATERIAL_PRESETS:vd,MAX_UNDO_SIZE:30,MODE_ADD:3,MODE_EDIT:1,MODE_PASTE_DATABIND:5,MODE_PASTE_STYLE:4,MODE_SHIFT:2,MODE_VIEW:0,get Model(){return Vv},MoveHandle:Ul,NOTHING:Fr,NavGraph:Hb,Node:jm,OrthoLine:Kg,OrthoLine3D:zv,PIXEL_RATIO:dp,PLACEHOLDER_THEMES:Ig,Path:Em,PatternStacking:ty,PlacementManager:qp,get PointLight(){return cv},Polygon:Vg,PolygonContainer:Wg,PolygonExtrude:z_,PolygonPathPolyline:Xb,Polyline:qg,Polyline3D:Dv,Popup:Mm,PopupContainer:Am,Pose6DOF:_l,RealObject:Zd,RealObjectCamera:Lv,RealObjectDomElement:_p,RealObjectDomTexture:y_,RealObjectDummy:Iv,RealObjectExternalModel:Jd,RealObjectExtrude:T_,RealObjectGLTF:iu,RealObjectGroup:_v,RealObjectLine:Pv,RealObjectMesh:b_,RealObjectPlane:jv,RealObjectPlane2D:Hv,RealObjectScene:Fv,RealObjectService:Fm,RealObjectSprite:H_,RealObjectSprite2D:B_,RealObjectText:k_,Rect:xf,RectExtrude:O_,RectPath:Pc,ReferenceMap:i_,RendererManager:jp,ReservationTable:Fb,RootContainer:Zl,Ruler:Sf,SCALE_MIN:Od,SCENE_MODE:Wr,Scene:wu,SceneManager:Rp,ScenePopup:Bu,SceneSearchEngine:su,ScriptLoader:h_,SearchOverlay:au,ServiceComponent:Hm,Shape:Cc,get Sphere(){return N_},Sphere3D:F_,get Sprite(){return V_},Star:Rm,StarExtrude:L_,TRANSFER_SLOT_KEY:cy,TableLayout:Wc,Text:fm,ThreeCapability:sf,get ThreeContainer(){return Yv},ThreeDOnly:Vm,Tracker:lu,Transfer:bu,TransitionEffect:Wl,Triangle:Tm,TriangleExtrude:R_,UNIT_DIMENSION:Id,UNIT_ROTATE:jd,UNIT_SCALE:Rd,UNIT_TRANSLATE:Ld,ValueHolder:Bm,VertexGizmoManager:rf,VolumeStacking:ny,get Wall(){return dv},Wall3D:hv,Z_PRIORITY:Ud,allDestinations:lb,anchorsConnect:vy,animate:Sa,applyAlpha:Dd,applyMaterial3dProps:Md,applyPolicy:ub,applySeatingRotation:ay,applyStackLayout:iy,applyZPriorityToMaterials:qd,arcSegmentTopology:by,autoWireBackPressure:Qm,buildArrow3D:yp,buildContractInspector:Jb,buildFlowGraph:ky,buildNavGraph:Vb,buildShapeFromPolygonPath:D_,buildTether:Du,bulgeFromDrag:Zs,bulgeHandlePosition:Qs,canReach:Py,capability:ng,chooseNearestPickupFrame:zb,clearTether:Iu,collectAdjacentSegments:Ry,compile:Aa,componentForNode:cb,computeArcParams:Ks,computeFlowMap:Ky,computeStackPositions:Jm,cornerHandlePosition:to,cornerRadiusFromDrag:eo,create:Mu,createCanvas:up,createCanvasTexture:p_,createFloor:Dp,createRealObjectFor:Mp,createSelectionHandle3D:gv,dataLagTracker:th,debug:Ji,deliversInto:Sy,delta:xa,disposeObject3D:Hd,disposeTether:Ru,downstream:gb,drawTextTexture:x_,effectiveCornerRadius:Js,enumerateDataScenarios:Ny,error:Qi,filterByToolType:Db,findNearestStationHost:Jy,flattenPolygonPath:qb,flowGraphFor:ob,flowGraphIssues:sb,flowReverseFor:Qy,fontStyle:__,footprint2D:ry,frameClock:Rs,ftId:Uy,ftrace:Wy,getAllCapabilityMeta:og,getCapabilityMeta:sg,getPose:Ml,getWorldPose:kl,globalSimClock:zs,gltfNatureProperties:Wm,graphFor:_b,hasArc:$s,hasCapacity:qm,inferCapacity:$m,inferDownstreamId:Ly,inferFlowDirections:Gy,initFontFamilyWatcher:Zr,inspector:kd,installContractInspector:t_,isFlowNode:kb,isGenericPlaceholder:Hg,isRoutingTarget:tb,isStateDriven:Wd,isStationHost:Zy,matchOutbounds:My,metrics:Li,next:fb,nextHop:Ty,nextHops:Cy,nextHopsToAny:Dy,nextHopsToAnyDetailed:zy,nodeIdOf:hb,opaqueColor:zd,pickWeightedDestination:xb,planPathAStar:Gb,planToReservations:Wb,pointInRotatedRect:xy,polygonOffsetForPriority:Xd,polygonPathLength:$b,projectToScreen:Cu,quatFromYaw:Eb,rayAbsDistanceToRect:wy,reachableByOutbound:Ay,reachableDestinations:mb,reachableDestinationsFrom:yb,reachableDestinationsWeightedFrom:bb,reachableSinks:Oy,receiptToJSON:mu,recommendsLogarithmicDepthForSky:Ip,rectFaceAnchors:gy,rectangularFootprintFrames:Pb,registerCapabilityMeta:rg,registerDefaultRealObjectFactory:Sp,registerRealObjectFactory:wp,renderCanvasTexture:f_,renderPlaceholder:Lg,reservationTable:Nb,resolveAnchorWorldPosition:Ou,resolveMaterial3d:xd,resolveNextHop:pb,sceneComponent:Xm,setPose:Al,setWorldPose:El,sinksForDestination:ab,standardYieldPolicy:jb,stopFPSMeasure:lp,straightSegmentEndpoints:yy,straightSegmentMultiInbound:_y,straightSegmentTopology:my,textBounds:M_,textTexture:w_,toThreeSide:Sd,topApproachFrame:Ob,transferLog:_u,transferTracer:fu,uniformZ:no,updateDefaultFontFamily:Qr,updateTether:zu,validate:vb,validateFlowGraph:Iy,version:d_,warn:Zi});const Wv=globalThis;"undefined"==typeof globalThis||Wv.scene||(Wv.scene=Gv);export{Fc as AbsoluteLayout,Ma as Animation,pm as AudioPlayer,qs as BULGE_EPSILON,Z_ as Banner,Q_ as Banner3D,Zp as BoxSelectionManager,Rg as COMMON_PLACEHOLDER_PROPERTIES,Ng as CORE_PLACEHOLDER_TYPES,iv as Camera,nv as Camera3D,Qp as CameraBookmarkManager,Lp as CameraManager,fy as Capacity,Km as CapacityEventTracker,Hc as CardLayout,Zm as CenteringQueueStrategy,Ib as CenteringSlotStrategy,Ec as Component,bf as Connectable,yg as Container,ql as ContainerAbstract,Hp as ControlsManager,U_ as Cube,W_ as Cube3D,$_ as Cylinder,q_ as Cylinder3D,Kr as DEFAULT,Gd as DEFAULT_PLACEMENT,Xr as DPPX,Jl as DataLagTracker,Ym as DataSource,Dm as Donut,I_ as DonutExtrude,zg as Ellipse,P_ as EllipseExtrude,Bp as EventManager3D,pl as EventMap,hp as FPS,dy as FixedSlotStrategy,fv as FloorPlate,wb as FlowEngine,Mb as FlowNode,qr as GESTURES,sv as GLTFObject,Gm as GLTF_BASE_URL_ALIAS,Fg as GenericObject,dm as GifView,Vp as GizmoManager,Up as GizmoOperationManager,xm as GlobalRef,Um as GltfComponent,ey as GridStacking,mm as Group,jc as HTMLAbsoluteLayout,_m as HTMLOverlayContainer,Jg as HTMLOverlayElement,Sb as Holdable,Zg as ImageView,Ic as InfoWindow,Xp as InteractionManager,hy as ItemsDataBinding,$r as KEYEVENTS,Yu as Layer,Lc as Layout,Fp as LightManager,av as LightObject,Og as Line,Ov as Line3D,Yc as LinearHorizontalLayout,Gc as LinearVerticalLayout,nh as LoadTracker,Pd as LoadingOverlay,bm as LocalRef,vd as MATERIAL_PRESETS,Ur as MAX_UNDO_SIZE,Yr as MODE_ADD,Hr as MODE_EDIT,Gr as MODE_PASTE_DATABIND,Vr as MODE_PASTE_STYLE,Br as MODE_SHIFT,Nr as MODE_VIEW,Vv as Model,Ul as MoveHandle,Fr as NOTHING,Hb as NavGraph,jm as Node,Kg as OrthoLine,zv as OrthoLine3D,dp as PIXEL_RATIO,Ig as PLACEHOLDER_THEMES,Em as Path,ty as PatternStacking,qp as PlacementManager,cv as PointLight,Vg as Polygon,Wg as PolygonContainer,z_ as PolygonExtrude,Xb as PolygonPathPolyline,qg as Polyline,Dv as Polyline3D,Mm as Popup,Am as PopupContainer,_l as Pose6DOF,Zd as RealObject,Lv as RealObjectCamera,_p as RealObjectDomElement,y_ as RealObjectDomTexture,Iv as RealObjectDummy,Jd as RealObjectExternalModel,T_ as RealObjectExtrude,iu as RealObjectGLTF,_v as RealObjectGroup,Pv as RealObjectLine,b_ as RealObjectMesh,jv as RealObjectPlane,Hv as RealObjectPlane2D,Fv as RealObjectScene,Fm as RealObjectService,H_ as RealObjectSprite,B_ as RealObjectSprite2D,k_ as RealObjectText,xf as Rect,O_ as RectExtrude,Pc as RectPath,i_ as ReferenceMap,jp as RendererManager,Fb as ReservationTable,Zl as RootContainer,Sf as Ruler,Od as SCALE_MIN,Wr as SCENE_MODE,wu as Scene,Rp as SceneManager,Bu as ScenePopup,su as SceneSearchEngine,h_ as ScriptLoader,au as SearchOverlay,Hm as ServiceComponent,Cc as Shape,N_ as Sphere,F_ as Sphere3D,V_ as Sprite,Rm as Star,L_ as StarExtrude,cy as TRANSFER_SLOT_KEY,Wc as TableLayout,fm as Text,sf as ThreeCapability,Yv as ThreeContainer,Vm as ThreeDOnly,lu as Tracker,bu as Transfer,Wl as TransitionEffect,Tm as Triangle,R_ as TriangleExtrude,Id as UNIT_DIMENSION,jd as UNIT_ROTATE,Rd as UNIT_SCALE,Ld as UNIT_TRANSLATE,Bm as ValueHolder,rf as VertexGizmoManager,ny as VolumeStacking,dv as Wall,hv as Wall3D,Ud as Z_PRIORITY,lb as allDestinations,vy as anchorsConnect,Sa as animate,Dd as applyAlpha,Md as applyMaterial3dProps,ub as applyPolicy,ay as applySeatingRotation,iy as applyStackLayout,qd as applyZPriorityToMaterials,by as arcSegmentTopology,Qm as autoWireBackPressure,yp as buildArrow3D,Jb as buildContractInspector,ky as buildFlowGraph,Vb as buildNavGraph,D_ as buildShapeFromPolygonPath,Du as buildTether,Zs as bulgeFromDrag,Qs as bulgeHandlePosition,Py as canReach,ng as capability,zb as chooseNearestPickupFrame,Iu as clearTether,Ry as collectAdjacentSegments,Aa as compile,cb as componentForNode,Ks as computeArcParams,Ky as computeFlowMap,Jm as computeStackPositions,to as cornerHandlePosition,eo as cornerRadiusFromDrag,Mu as create,up as createCanvas,p_ as createCanvasTexture,Dp as createFloor,Mp as createRealObjectFor,gv as createSelectionHandle3D,th as dataLagTracker,Ji as debug,Sy as deliversInto,xa as delta,Hd as disposeObject3D,Ru as disposeTether,gb as downstream,x_ as drawTextTexture,Js as effectiveCornerRadius,Ny as enumerateDataScenarios,Qi as error,Db as filterByToolType,Jy as findNearestStationHost,qb as flattenPolygonPath,ob as flowGraphFor,sb as flowGraphIssues,Qy as flowReverseFor,__ as fontStyle,ry as footprint2D,Rs as frameClock,Uy as ftId,Wy as ftrace,og as getAllCapabilityMeta,sg as getCapabilityMeta,Ml as getPose,kl as getWorldPose,zs as globalSimClock,Wm as gltfNatureProperties,_b as graphFor,$s as hasArc,qm as hasCapacity,$m as inferCapacity,Ly as inferDownstreamId,Gy as inferFlowDirections,Zr as initFontFamilyWatcher,kd as inspector,t_ as installContractInspector,kb as isFlowNode,Hg as isGenericPlaceholder,tb as isRoutingTarget,Wd as isStateDriven,Zy as isStationHost,My as matchOutbounds,Li as metrics,fb as next,Ty as nextHop,Cy as nextHops,Dy as nextHopsToAny,zy as nextHopsToAnyDetailed,hb as nodeIdOf,zd as opaqueColor,xb as pickWeightedDestination,Gb as planPathAStar,Wb as planToReservations,xy as pointInRotatedRect,Xd as polygonOffsetForPriority,$b as polygonPathLength,Cu as projectToScreen,Eb as quatFromYaw,wy as rayAbsDistanceToRect,Ay as reachableByOutbound,mb as reachableDestinations,yb as reachableDestinationsFrom,bb as reachableDestinationsWeightedFrom,Oy as reachableSinks,mu as receiptToJSON,Ip as recommendsLogarithmicDepthForSky,gy as rectFaceAnchors,Pb as rectangularFootprintFrames,rg as registerCapabilityMeta,Sp as registerDefaultRealObjectFactory,wp as registerRealObjectFactory,f_ as renderCanvasTexture,Lg as renderPlaceholder,Nb as reservationTable,Ou as resolveAnchorWorldPosition,xd as resolveMaterial3d,pb as resolveNextHop,Xm as sceneComponent,Al as setPose,El as setWorldPose,ab as sinksForDestination,jb as standardYieldPolicy,lp as stopFPSMeasure,yy as straightSegmentEndpoints,_y as straightSegmentMultiInbound,my as straightSegmentTopology,M_ as textBounds,w_ as textTexture,Sd as toThreeSide,Ob as topApproachFrame,_u as transferLog,fu as transferTracer,no as uniformZ,Qr as updateDefaultFontFamily,zu as updateTether,vb as validate,Iy as validateFlowGraph,d_ as version,Zi as warn};
|
|
51
51
|
//# sourceMappingURL=things-scene.mjs.map
|