(()=>{"use strict";var t={396(t,e,o){var i=o(601),n=o.n(i),s=o(314),d=o.n(s)()(n());d.push([t.id,"#compositor{width:100vw;height:100vh;background-color:#c6c0c6;position:relative;overflow:hidden}",""]);const r=d.toString();o.d(e,["A",0,r])},510(t,e,o){var i=o(601),n=o.n(i),s=o(314),d=o.n(s),r=o(417),h=o.n(r),a=new URL(o(63),o.b),c=d()(n()),l=h()(a);c.push([t.id,`#ghost{border:3px solid rgba(0,0,0,0);border-image:url(${l}) 3 repeat;image-rendering:pixelated;width:100%;height:100%}`,""]);const g=c.toString();o.d(e,["A",0,g])},767(t,e,o){var i=o(601),n=o.n(i),s=o(314),d=o.n(s)()(n());d.push([t.id,'#window{border:2px solid #000;position:relative;background-color:#c6c0c6;width:100%;height:100%}#inner{border:2px solid #000;position:absolute;display:flex;flex-direction:column;margin:2px;top:0;bottom:0;left:0;right:0}#title{border:2px solid #000;font-family:"win31";color:#fff;border-left:unset;border-top:unset;border-right:unset;height:20px;width:auto;background-color:#0100ab;padding:0;display:flex;justify-content:center}#title span{cursor:default}#content{background-color:#fff;width:100%;height:100%}',""]);const r=d.toString();o.d(e,["A",0,r])},314(t){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var o="",i=void 0!==e[5];return e[4]&&(o+="@supports (".concat(e[4],") {")),e[2]&&(o+="@media ".concat(e[2]," {")),i&&(o+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),o+=t(e),i&&(o+="}"),e[2]&&(o+="}"),e[4]&&(o+="}"),o}).join("")},e.i=function(t,o,i,n,s){"string"==typeof t&&(t=[[null,t,void 0]]);var d={};if(i)for(var r=0;r0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),o&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=o):c[2]=o),n&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=n):c[4]="".concat(n)),e.push(c))}},e}},417(t){t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},601(t){t.exports=function(t){return t[1]}},63(t){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAAXNSR0IB2cksfwAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+oLDhQFCx2O8gcAAAAySURBVBjTY2BgYPj///9/RgYGhv8MEIBJwxQQUEiESegMNICh4D8OBeSbRNBNZCv4DwCvHS/VJ3nRjgAAAABJRU5ErkJggg=="}};const e={};function o(i){const n=e[i];if(void 0!==n)return n.exports;const s=e[i]={id:i,exports:{}};return t[i](s,s.exports,o),s.exports}o.n=t=>{const e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{if(Array.isArray(e))for(var i=0;iObject.prototype.hasOwnProperty.call(t,e),o.b="undefined"!=typeof document&&document.baseURI||self.location.href;var i=o(767);const n=new CSSStyleSheet;n.replaceSync(i.A);class s extends HTMLElement{static observedAttributes=["data-x","data-y","data-width","data-height"];x=0;y=0;width=0;height=0;zIndex=0;constructor(){super();const t=this.attachShadow({mode:"open"}),e=document.createElement("template");e.innerHTML="
\n
\n
\n Program Manager\n
\n\n
\n\n
\n
\n
",t.adoptedStyleSheets=[n],t.appendChild(e.content.cloneNode(!0))}connectedCallback(){this.style.position="absolute"}setZIndex(t){this.zIndex=t,this.style.zIndex=t.toString()}applyDimensions(){this.style.left=this.toPixel(this.x),this.style.top=this.toPixel(this.y),this.style.width=this.toPixel(this.width),this.style.height=this.toPixel(this.height)}toPixel(t){return`${t}px`}isMouseOnTop(t,e){return t>this.x&&tthis.y&&e\n\n",t.adoptedStyleSheets=[r],t.appendChild(e.content.cloneNode(!0))}connectedCallback(){this.style.position="absolute",this.style.zIndex="100000"}applyDimensions(){this.style.left=this.toPixel(this.x),this.style.top=this.toPixel(this.y),this.style.width=this.toPixel(this.width),this.style.height=this.toPixel(this.height)}toPixel(t){return`${t}px`}}customElements.define("win-ghost",h);var a=o(396);const c=new CSSStyleSheet;c.replaceSync(a.A);class l extends HTMLElement{root;windows;draggedWindow=null;constructor(){super();const t=this.attachShadow({mode:"open"}),e=document.createElement("template");e.innerHTML="
\n\n
",t.adoptedStyleSheets=[c],t.appendChild(e.content.cloneNode(!0));const o=t.getElementById("compositor");if(null==o)throw"Compositor doesnt contain a root";this.root=o,this.windows={},this.windows.test=this.createWindow(100,100,320,180,"#DAA464"),this.windows.test2=this.createWindow(450,300,300,200,"#767F9E")}connectedCallback(){this.root.addEventListener("mousedown",t=>{this.windowSpaceMouseDown(t)}),this.root.addEventListener("mouseup",t=>{this.windowSpaceMouseUp(t)}),this.root.addEventListener("mousemove",t=>{this.windowSpaceMouseMove(t)})}getNextHighestZIndex(){let t=0;for(const e of Object.values(this.windows))e.zIndex>t&&(t=e.zIndex);return t+1}createWindow(t,e,o,i,n){const d=this.getNextHighestZIndex(),r=this.root.appendChild(new s);return r.x=t,r.y=e,r.width=o,r.height=i,r.style.backgroundColor=n,r.setZIndex(d),r.applyDimensions(),r}mouseEventToCompositorCoordinates(t){const e=this.root.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}windowSpaceMouseDown(t){if(t.preventDefault(),0!==t.button)return;const[e,o]=this.mouseEventToCompositorCoordinates(t);for(const t of Object.values(this.windows))if(t.isMouseOnTop(e,o)){this.setDraggedWindow(e,o,t);break}}setDraggedWindow(t,e,o){const i=new h;i.x=o.x,i.y=o.y,i.width=o.width,i.height=o.height;const n=this.root.appendChild(i);this.draggedWindow={window:o,mouseXOffset:t-o.x,mouseYOffset:e-o.y,ghost:n}}windowSpaceMouseUp(t){t.preventDefault(),null!=this.draggedWindow&&(this.draggedWindow.window.x=this.draggedWindow.ghost.x,this.draggedWindow.window.y=this.draggedWindow.ghost.y,this.draggedWindow.window.width=this.draggedWindow.ghost.width,this.draggedWindow.window.height=this.draggedWindow.ghost.height,this.draggedWindow.window.applyDimensions(),this.draggedWindow.window.setZIndex(this.getNextHighestZIndex()),this.draggedWindow.ghost.remove(),this.draggedWindow=null)}windowSpaceMouseMove(t){if(null==this.draggedWindow)return;const[e,o]=this.mouseEventToCompositorCoordinates(t);this.dragWindow(e,o)}dragWindow(t,e){null!=this.draggedWindow&&(this.draggedWindow.ghost.x=t-this.draggedWindow.mouseXOffset,this.draggedWindow.ghost.y=e-this.draggedWindow.mouseYOffset,this.draggedWindow.ghost.applyDimensions())}}customElements.define("win-compositor",l)})();