text: /**
   * skylark-98js - A version of 98js.js that ported to running on skylarkjs
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylark-integration/skylark-98js/
   * @license MIT
   */
  define(["skylark-jquery","../win98"],function(t,e){function n(t){return document.createElement(t)}function i(t){return"object"==typeof t&&"tagName"in t?t.tagName.toLowerCase()+(t.id?"#"+t.id:"")+(t.className?"."+t.className.split(" ").join("."):"")+(t.src?`[src="${t.src}"]`:"")+(t.srcdoc?"[srcdoc]":"")+(t.href?`[href="${t.href}"]`:""):t?t.constructor.name:`${t}`}function o(e){let n=t(e).find("\n\t\t\tinput:enabled,\n\t\t\ttextarea:enabled,\n\t\t\tselect:enabled,\n\t\t\tbutton:enabled,\n\t\t\ta[href],\n\t\t\t[tabIndex='0'],\n\t\t\tdetails summary,\n\t\t\tiframe,\n\t\t\tobject,\n\t\t\tembed,\n\t\t\tvideo[controls],\n\t\t\taudio[controls],\n\t\t\t[contenteditable]:not([contenteditable='false'])\n\t\t").filter(":visible");const i={},o=[];for(const t of n.toArray())"input"===t.nodeName.toLowerCase()&&"radio"===t.type&&(i[t.name]?t.checked?(o.push(i[t.name]),i[t.name]=t):o.push(t):i[t.name]=t);return n.not(o)}var s=t(window);r.Z_INDEX=5;var a=[];function r(e){e=e||{};var c=t(n("div")).addClass("window os-window").appendTo("body");c[0].$window=c,c.element=c[0],c[0].id=`os-window-${Math.random().toString(36).substr(2,9)}`,c.$titlebar=t(n("div")).addClass("window-titlebar").appendTo(c),c.$title_area=t(n("div")).addClass("window-title-area").appendTo(c.$titlebar),c.$title=t(n("span")).addClass("window-title").appendTo(c.$title_area),e.toolWindow&&(e.minimizeButton=!1,e.maximizeButton=!1),!1!==e.minimizeButton&&(c.$minimize=t(n("button")).addClass("window-minimize-button window-action-minimize window-button").appendTo(c.$titlebar),c.$minimize.attr("aria-label","Minimize window"),c.$minimize.append("<span class='window-button-icon'></span>")),!1!==e.maximizeButton&&(c.$maximize=t(n("button")).addClass("window-maximize-button window-action-maximize window-button").appendTo(c.$titlebar),c.$maximize.attr("aria-label","Maximize or restore window"),e.resizable||c.$maximize.attr("disabled",!0),c.$maximize.append("<span class='window-button-icon'></span>")),!1!==e.closeButton&&(c.$x=t(n("button")).addClass("window-close-button window-action-close window-button").appendTo(c.$titlebar),c.$x.attr("aria-label","Close window"),c.$x.append("<span class='window-button-icon'></span>")),c.$content=t(n("div")).addClass("window-content").appendTo(c),c.$content.attr("tabIndex","-1"),c.$content.css("outline","none"),e.toolWindow&&c.addClass("tool-window"),e.parentWindow&&(e.parentWindow.addChildWindow(c),e.toolWindow&&(c[0].dataset.semanticParent=e.parentWindow[0].id));var l=e.$component;if("object"==typeof e.icon&&"tagName"in e.icon)e.icons={any:e.icon};else if(e.icon){if(console.warn("DEPRECATED: use options.icons instead of options.icon, e.g. new $Window({icons: {16: 'app-16x16.png', any: 'app-icon.svg'}})"),"undefined"==typeof $Icon||"undefined"==typeof TITLEBAR_ICON_SIZE)throw new Error("Use {icon: img_element} or {icons: {16: url_or_img_element}} options");c.icon_name=e.icon,c.$icon=$Icon(e.icon,TITLEBAR_ICON_SIZE).prependTo(c.$titlebar)}c.icons=e.icons||{};let d=16;c.setTitlebarIconSize=function(e){c.icons&&(c.$icon&&c.$icon.remove(),c.$icon=t(c.getIconAtSize(e)),c.$icon.prependTo(c.$titlebar)),d=e,c.trigger("icon-change")},c.getTitlebarIconSize=function(){return d},c.getIconAtSize=function(e){let i;if(c.icons[e])i=e;else if(c.icons.any)i="any";else{const t=Object.keys(c.icons).filter(t=>isFinite(t)&&isFinite(parseFloat(t)));t.sort((t,n)=>Math.abs(t-e)-Math.abs(n-e)),i=t[0]}if(i){const o=c.icons[i];let s;if(void 0!==o.nodeType)s=o.cloneNode(!0);else{s=n("img");const a=t(s);o.srcset?a.attr("srcset",o.srcset):a.attr("src",o.src||o),a.attr({width:i,height:i,draggable:!1}),a.css({width:e,height:e})}return s}return null},c.setTitlebarIconSize(d),c.getIconName=(()=>(console.warn("DEPRECATED: use $w.icons object instead of $w.icon_name"),c.icon_name)),c.setIconByID=(t=>{console.warn("DEPRECATED: use $w.setIcons(icons) instead of $w.setIconByID(icon_name)");var e=c.$icon;return c.$icon=$Icon(t,TITLEBAR_ICON_SIZE),e.replaceWith(c.$icon),c.icon_name=t,c.task&&c.task.updateIcon(),c.trigger("icon-change"),c}),c.setIcons=(t=>{c.icons=t,c.setTitlebarIconSize(d),c.task&&c.task.updateIcon()}),l&&c.addClass("component-window"),setTimeout(()=>{"rtl"==(window.get_direction?window.get_direction():getComputedStyle(c[0]).direction)&&c.addClass("rtl")},0);const m=t({}),u=t=>e=>{const n=()=>{e()};m.on(t,n);return()=>{m.off(t,n)}};c.onFocus=u("focus"),c.onBlur=u("blur"),c.onClosed=u("closed"),c.setDimensions=(({innerWidth:t,innerHeight:e,outerWidth:n,outerHeight:i})=>{let o,s;if(t&&(o=c.outerWidth()-c.$content.outerWidth()),e){s=c.outerHeight()-c.$content.outerHeight();const t=c.$content.find(".menus");t.length&&(s+=t.outerHeight())}n&&c.outerWidth(n),i&&c.outerHeight(i),t&&c.outerWidth(t+o),e&&c.outerHeight(e+s)}),c.setDimensions(e);let h=[];c.addChildWindow=(t=>{h.push(t)});const w=()=>{c.hasClass("focused")||(c.addClass("focused"),m.triggerHandler("focus"),c.trigger("focus"))},p=()=>{c.hasClass("focused")&&(c.removeClass("focused"),m.triggerHandler("blur"),c.trigger("blur"))};if(c.focus=(()=>{c.bringToFront(),M()}),c.blur=(()=>{p(),document.activeElement&&document.activeElement.closest(".window")==c[0]&&document.activeElement.blur()}),e.toolWindow)e.parentWindow?(e.parentWindow.onFocus(w),e.parentWindow.onBlur(p),document.activeElement&&document.activeElement.closest(".window")==e.parentWindow[0]&&w()):(t(window).on("focus",w),t(window).on("blur",p),document.hasFocus()&&w());else{const t=b(c[0],!0);function f(t){if(!z.has(t)){const e=b(t,!1);z.set(t,e),setTimeout(()=>{try{const n=e=>{"complete"==t.contentDocument.readyState?e():setTimeout(()=>{n(e)},100)};n(()=>{t.contentWindow.addEventListener("focusin",e),t.contentWindow.addEventListener("focusout",e),t.contentWindow.addEventListener("blur",e),t.contentWindow.addEventListener("focus",e),g(t.contentDocument)})}catch(e){k(t,e)}},100)}}function g(t){new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)"IFRAME"==t.tagName&&f(t)}).observe(t,{childList:!0,subtree:!0});for(const e of t.querySelectorAll("iframe"))f(e)}function b(t,e){return function(n){const i="IFRAME"==t.tagName?t.contentDocument:t,o=i.ownerDocument||i;let s=n?"focusout"===n.type||"blur"===n.type?n.relatedTarget:n.target:o.activeElement;n&&"blur"===n.type&&(s=null),o.activeElement&&"IFRAME"===o.activeElement.tagName&&(n&&"focusout"===n.type||n&&"blur"===n.type)&&!s&&(s=o.activeElement);const a=!s||s.window===s||!i.contains(s);if(a&&i!==s&&e&&p(),a||"HTML"===s.tagName||"BODY"===s.tagName||s===i||s.matches(".window-content")||s.closest(".menus")||s.closest(".window-titlebar")||(C.set(t,s),W(o,i,s,e)),!a&&"IFRAME"===s.tagName){const t=s;try{const n=t.contentDocument.activeElement;n&&"HTML"!==n.tagName&&"BODY"!==n.tagName&&!n.closest(".menus")&&(C.set(t,n),W(t.contentDocument,t.contentDocument,n,e))}catch(e){k(t,e)}}if(e)for(;;){const t=s&&s.closest&&s.closest("[data-semantic-parent]");if(!t)break;{const e=t.dataset.semanticParent,n=t.ownerDocument.getElementById(e);if(s=n,!n){console.warn("semantic parent not found with id",e);break}}}if(s&&s.window!==s&&i.contains(s)){if(w(),c.bringToFront(),!e){let e=t;for(;e;)e.dispatchEvent(new Event("focusin",{bubbles:!0,target:e,view:e.ownerDocument.defaultView})),e=e.currentView&&e.currentView.frameElement}}else e&&p()}}window.addEventListener("focusin",t),window.addEventListener("focusout",t),window.addEventListener("blur",t),window.addEventListener("focus",t),g(c.$content[0])}c.css("touch-action","none");let $,v,x,y=null;c.setMinimizeTarget=function(t){y=t},Object.defineProperty(c,"task",{get:()=>$,set(t){console.warn("DEPRECATED: use $w.setMinimizeTarget(taskbar_button_el) instead of setting $window.task object"),$=t}}),c.minimize=(()=>{if(y=y||$&&$.$task[0],X)Y.push(c.minimize);else if(c.is(":visible"))if(y&&!c.hasClass("minimized-without-taskbar")){const t=c.$titlebar[0].getBoundingClientRect(),e=y.getBoundingClientRect();c.animateTitlebar(t,e,()=>{c.hide(),c.blur()})}else{const t=150,e=10;if(c.hasClass("minimized-without-taskbar"))a[c._minimize_slot_index]=null;else{let t=0;for(;a[t];)t++;c._minimize_slot_index=t,a[t]=c}const n=c._minimize_slot_index*(t+e)+10,i=c.$titlebar.outerHeight();let o;const s=()=>{v={position:c.css("position"),left:c.css("left"),top:c.css("top"),width:c.css("width"),height:c.css("height")},c.addClass("minimized-without-taskbar"),c.hasClass("maximized")&&(c.removeClass("maximized"),c.addClass("was-maximized"),c.$maximize.removeClass("window-action-restore"),c.$maximize.addClass("window-action-maximize")),c.$minimize.removeClass("window-action-minimize"),c.$minimize.addClass("window-action-restore"),o?c.css({position:o.position,left:o.left,top:o.top,width:o.width,height:o.height}):c.css({position:"fixed",top:`calc(100% - ${i+5}px)`,left:n,width:t,height:i})},r=()=>{o={position:c.css("position"),left:c.css("left"),top:c.css("top"),width:c.css("width"),height:c.css("height")},c.removeClass("minimized-without-taskbar"),c.hasClass("was-maximized")&&(c.removeClass("was-maximized"),c.addClass("maximized"),c.$maximize.removeClass("window-action-maximize"),c.$maximize.addClass("window-action-restore")),c.$minimize.removeClass("window-action-restore"),c.$minimize.addClass("window-action-minimize"),c.css({width:"",height:""}),v&&c.css({position:v.position,left:v.left,top:v.top,width:v.width,height:v.height})},l=c.$titlebar[0].getBoundingClientRect();let d;c.css("transform",""),c.hasClass("minimized-without-taskbar")?(r(),d=c.$titlebar[0].getBoundingClientRect(),s()):(s(),d=c.$titlebar[0].getBoundingClientRect(),r()),c.animateTitlebar(l,d,()=>{c.hasClass("minimized-without-taskbar")?r():(s(),c.blur())})}}),c.unminimize=(()=>{if(X)Y.push(c.unminimize);else if(c.hasClass("minimized-without-taskbar"))c.minimize();else if(c.is(":hidden")){const t=y.getBoundingClientRect();c.show();const e=c.$titlebar[0].getBoundingClientRect();c.hide(),c.animateTitlebar(t,e,()=>{c.show(),c.bringToFront(),c.focus()})}}),c.maximize=(()=>{if(!e.resizable)return;if(X)return void Y.push(c.maximize);if(c.hasClass("minimized-without-taskbar"))return void c.minimize();const n=()=>{x={position:c.css("position"),left:c.css("left"),top:c.css("top"),width:c.css("width"),height:c.css("height")},c.addClass("maximized");const e=t(".taskbar"),n=window.innerWidth-t(window).width(),i=window.innerHeight-t(window).height(),o=e.length?e.outerHeight()+1:0;c.css({position:"fixed",top:0,left:0,width:`calc(100vw - ${n}px)`,height:`calc(100vh - ${i}px - ${o}px)`})},i=()=>{c.removeClass("maximized"),c.css({width:"",height:""}),x&&c.css({position:x.position,left:x.left,top:x.top,width:x.width,height:x.height})},o=c.$titlebar[0].getBoundingClientRect();let s;c.css("transform","");const a=c.hasClass("maximized");a?(i(),s=c.$titlebar[0].getBoundingClientRect(),n()):(n(),s=c.$titlebar[0].getBoundingClientRect(),i()),c.animateTitlebar(o,s,()=>{a?(i(),c.$maximize.removeClass("window-action-restore"),c.$maximize.addClass("window-action-maximize")):(n(),c.$maximize.removeClass("window-action-maximize"),c.$maximize.addClass("window-action-restore"))})}),c.restore=(()=>{c.is(".minimized-without-taskbar, .minimized")?c.unminimize():c.is(".maximized")&&c.maximize()}),c.$minimize&&c.$minimize.on("click",t=>{c.minimize()}),c.$maximize&&c.$maximize.on("click",t=>{c.maximize()}),c.$x&&c.$x.on("click",t=>{c.close()}),c.$title_area.on("dblclick",t=>{c.maximize()}),c.css({position:"absolute",zIndex:r.Z_INDEX++}),c.bringToFront=(()=>{c.css({zIndex:r.Z_INDEX++});for(const t of h)t.bringToFront()});var C=new Map,z=new Map,E=new Map,I=[],T=new WeakSet;const k=(t,n)=>{const o=e=>[`OS-GUI.js failed to access an iframe (${i(t)}) for focus integration.\n\t${e}\n\tOriginal error:\n\t`,n];let s;if(t.srcdoc)s=!1;else try{s=new URL(t.src).origin!==window.location.origin}catch(t){return void console.error(...o(`This may be a bug in OS-GUI. Is this a cross-origin iframe? Failed to parse URL (${t}).`))}s?e.iframes&&e.iframes.ignoreCrossOrigin&&!T.has(t)&&(console.warn(...o("Only same-origin iframes can work with focus integration (showing window as focused, refocusing last focused controls).\n\tIf you can re-host the content on the same origin, you can resolve this and enable focus integration.\n\tYou can also disable this warning by passing {iframes: {ignoreCrossOrigin: true}} to $Window.")),T.add(t)):console.error(...o("This may be a bug in OS-GUI, since it doesn't appear to be a cross-origin iframe."))},W=(t,e,n,i)=>{if(!r.DEBUG_FOCUS)return;let o=E.get(e);o||((o=t.createElementNS("http://www.w3.org/2000/svg","svg")).style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.pointerEvents="none",o.style.zIndex="100000000",o.style.direction="ltr",E.set(e,o),I.push(o),t.body.appendChild(o)),o._container_el=e,o._descendant_el=n,o._is_root=i,B()},_=t=>{const e=t._container_el,n=t._descendant_el,o=t._is_root;for(;t.lastChild;)t.removeChild(t.lastChild);const s=n.getBoundingClientRect&&n.getBoundingClientRect()||{left:0,top:0,width:innerWidth,height:innerHeight,right:innerWidth,bottom:innerHeight},a=e.getBoundingClientRect&&ontainer_el.getBoundingClientRect()||{left:0,top:0,width:innerWidth,height:innerHeight,right:innerWidth,bottom:innerHeight};for(const r of[s,a]){const a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x",r.left),a.setAttribute("y",r.top),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("stroke","#f44"),a.setAttribute("stroke-width","2"),a.setAttribute("fill","none"),o||a.setAttribute("stroke-dasharray","5,5"),t.appendChild(a);const c=document.createElementNS("http://www.w3.org/2000/svg","text");c.setAttribute("x",r.left),c.setAttribute("y",r.top+(r===s?20:0)),c.setAttribute("fill",r===s?"#f44":"aqua"),c.setAttribute("font-size","20"),c.style.textShadow="1px 1px 1px black, 0 0 10px black",c.textContent=i(r===s?n:e),t.appendChild(c)}const r=[[s.left,s.top,a.left,a.top],[s.right,s.top,a.right,a.top],[s.left,s.bottom,a.left,a.bottom],[s.right,s.bottom,a.right,a.bottom]];for(const e of r){const n=document.createElementNS("http://www.w3.org/2000/svg","line");n.setAttribute("x1",e[0]),n.setAttribute("y1",e[1]),n.setAttribute("x2",e[2]),n.setAttribute("y2",e[3]),n.setAttribute("stroke","green"),n.setAttribute("stroke-width","2"),t.appendChild(n)}};let A;const B=()=>{if(cancelAnimationFrame(A),r.DEBUG_FOCUS){A=requestAnimationFrame(B);for(const t of I)_(t)}else D()},D=()=>{cancelAnimationFrame(A);for(const t of I)t.remove();I.length=0,E.clear()},M=(t=c.$content[0])=>{const n=t.matches(".window-content")?c[0]:t,i=C.get(n);if(i){if(i.focus({preventScroll:!0}),"IFRAME"===i.tagName)try{M(i)}catch(t){k(i,t)}return}const s=o(t),a=s.filter(".default");if(a.length)a[0].focus({preventScroll:!0});else if(s.length)if("IFRAME"===s[0].tagName)try{M(s[0])}catch(t){k(s[0],t)}else s[0].focus({preventScroll:!0});else if(e.toolWindow&&e.parentWindow)e.parentWindow.triggerHandler("refocus-window");else if(t.focus({preventScroll:!0}),"IFRAME"===t.tagName)try{M(t.contentDocument.body)}catch(e){k(t,e)}};var R,S,H,N,F;c.on("refocus-window",()=>{M()}),c.on("pointerdown mousedown",function(t){c.bringToFront(),requestAnimationFrame(()=>{const e=C.get(window);if(document.activeElement&&document.activeElement!==document&&document.activeElement!==document.body&&document.activeElement!==c.$content[0]&&document.activeElement!==e)return;if(document.activeElement&&document.activeElement.closest&&document.activeElement.closest(".menus, .menu-popup"))return;const n=getComputedStyle(t.target);if("none"!==n.userSelect)return c.$content.focus(),void c.one("pointerup pointercancel",()=>{requestAnimationFrame(()=>{getSelection().toString().trim()||M()})});M()})}),s.on("focusin",t=>{C.set(window,t.target)}),c.on("keydown",e=>{if(e.isDefaultPrevented())return;if(e.ctrlKey||e.altKey||e.metaKey)return;if(e.target.closest(".menus"))return;const n=c.$content.find("button"),i=t(document.activeElement),s=n.index(i);switch(e.keyCode){case 40:case 39:i.is("button")&&!e.shiftKey&&s<n.length-1&&(n[s+1].focus(),e.preventDefault());break;case 38:case 37:i.is("button")&&!e.shiftKey&&s>0&&(n[s-1].focus(),e.preventDefault());break;case 32:case 13:if(i.is("button")&&!e.shiftKey){i.addClass("pressed");const e=()=>{i.removeClass("pressed"),i.off("focusout",e),t(window).off("keyup",n)},n=t=>{32!==t.keyCode&&13!==t.keyCode||e()};i.on("focusout",e),t(window).on("keyup",n)}break;case 9:{const t=o(c.$content[0]);if(t.length>0){const n=t.index(i);e.shiftKey?0===n&&(e.preventDefault(),t[t.length-1].focus()):n===t.length-1&&(e.preventDefault(),t[0].focus())}break}case 27:c.close()}}),c.applyBounds=(()=>{const t=Math.max(document.body.scrollWidth,innerWidth),e=Math.max(document.body.scrollHeight,innerHeight);c.css({left:Math.max(0,Math.min(t-c.width(),c.position().left)),top:Math.max(0,Math.min(e-c.height(),c.position().top))})}),c.bringTitleBarInBounds=(()=>{const t=Math.max(document.body.scrollWidth,innerWidth),e=Math.max(document.body.scrollHeight,innerHeight);c.css({left:Math.max(40-c.outerWidth(),Math.min(t-40,c.position().left)),top:Math.max(0,Math.min(e-c.$titlebar.outerHeight()-5,c.position().top))})}),c.center=(()=>{c.css({left:(innerWidth-c.width())/2+window.scrollX,top:(innerHeight-c.height())/2+window.scrollY}),c.applyBounds()}),s.on("resize",c.bringTitleBarInBounds);var O=t=>{F===(t.pointerId||t.originalEvent.pointerId)&&(H=t.clientX||H,N=t.clientY||N),c.css({left:H+scrollX-R,top:N+scrollY-S})};if(c.$titlebar.css("touch-action","none"),c.$titlebar.on("selectstart",t=>{t.preventDefault()}),c.$titlebar.on("mousedown","button",e=>{M();const n=e.currentTarget;if(!t(n).is(":enabled"))return;n.classList.add("pressing");const i=e=>{e&&"blur"===e.type&&document.hasFocus()||(n.classList.remove("pressing"),s.off("mouseup blur",i),t(n).off("mouseenter",o),t(n).off("mouseleave",a))},o=()=>{n.classList.add("pressing")},a=()=>{n.classList.remove("pressing")};s.on("mouseup blur",i),t(n).on("mouseenter",o),t(n).on("mouseleave",a)}),c.$titlebar.on("pointerdown",e=>{if(t(e.target).closest("button").length)return;if(c.hasClass("maximized"))return;const n=t.Event("window-drag-start");c.trigger(n),n.isDefaultPrevented()||(R=e.clientX+scrollX-c.position().left,S=e.clientY+scrollY-c.position().top,H=e.clientX,N=e.clientY,F=e.pointerId||e.originalEvent.pointerId,s.on("pointermove",O),s.on("scroll",O),t("body").addClass("dragging"))}),s.on("pointerup pointercancel",e=>{(e.pointerId||e.originalEvent.pointerId)===F&&(s.off("pointermove",O),s.off("scroll",O),t("body").removeClass("dragging"),c.bringTitleBarInBounds(),F=-1)}),c.$titlebar.on("dblclick",t=>{l&&l.dock()}),e.resizable){const n=0,i=-1,o=1,a=i,r=o,l=i,d=o;[[l,r],[l,n],[l,a],[n,a],[d,a],[d,n],[d,r],[n,r]].forEach(([i,o])=>{const m=t("<div>").addClass("handle").appendTo(c);let u="";i===l&&(u+="n"),i===d&&(u+="s"),o===a&&(u+="w"),o===r&&(u+="e"),u+="-resize";const h=(c.outerWidth()-c.width())/2,w=(c.outerWidth()-c.innerWidth())/2,p=c.outerHeight()-c.$content.outerHeight(),f=c.outerWidth()-c.$content.outerWidth();let g,b,$,v,x,y;function C(t){(t.pointerId||t.originalEvent.pointerId)===y&&(v=t.clientX,x=t.clientY,E())}function z(e){(e.pointerId||e.originalEvent.pointerId)===y&&(s.off("pointermove",C),s.off("scroll",onscroll),t("body").removeClass("dragging"),s.off("pointerup pointercancel",z),c.bringTitleBarInBounds())}function E(){const t=v+scrollX-b,n=x+scrollY-$;let s,m,u=0,h=0;o===r?(u=0,s=~~(t-g.x)):o===a?(u=~~(t-g.x),s=~~(g.x+g.width-t)):s=~~g.width,i===d?(h=0,m=~~(n-g.y)):i===l?(h=~~(n-g.y),m=~~(g.y+g.height-n)):m=~~g.height;let w={x:g.x+u,y:g.y+h,width:s,height:m};w.width=Math.max(1,w.width),w.height=Math.max(1,w.height),e.constrainRect&&(w=e.constrainRect(w,o,i)),w.width=Math.max(w.width,e.minOuterWidth||100),w.height=Math.max(w.height,e.minOuterHeight||0),w.width=Math.max(w.width,(e.minInnerWidth||0)+f),w.height=Math.max(w.height,(e.minInnerHeight||0)+p),o===a&&(w.x=Math.min(w.x,g.x+g.width-w.width)),i===l&&(w.y=Math.min(w.y,g.y+g.height-w.height)),c.css({top:w.y,left:w.x}),c.outerWidth(w.width),c.outerHeight(w.height)}m.css({position:"absolute",top:i===l?-w:i===n?`calc(${h}px - ${w}px)`:"",bottom:i===d?-w:"",left:o===a?-w:o===n?`calc(${h}px - ${w}px)`:"",right:o===r?-w:"",width:o===n?`calc(100% - ${h}px * 2 + ${2*w}px)`:`${h}px`,height:i===n?`calc(100% - ${h}px * 2 + ${2*w}px)`:`${h}px`,touchAction:"none",cursor:u}),m.on("pointerdown",e=>{e.preventDefault(),s.on("pointermove",C),s.on("scroll",E),t("body").addClass("dragging"),s.on("pointerup pointercancel",z),g={x:c.position().left,y:c.position().top,width:c.outerWidth(),height:c.outerHeight()},b=e.clientX+scrollX-g.x-(o===r?g.width:0),$=e.clientY+scrollY-g.y-(i===d?g.height:0),v=e.clientX,x=e.clientY,y=e.pointerId||e.originalEvent.pointerId,m[0].setPointerCapture(y)})})}c.$Button=((e,i)=>{return t(n("button")).appendTo(c.$content).text(e).on("click",()=>{i&&i(),c.close()})}),c.title=(t=>t?(c.$title.text(t),c.trigger("title-change"),c.task&&c.task.updateTitle(),c):c.$title.text()),c.getTitle=(()=>c.title());let L,X=!1,Y=[];return c.animateTitlebar=((t,e,n=(()=>{}))=>{X=!0;const i=c.$titlebar.clone(!0);i.find("button").remove(),i.appendTo("body");const o=r.OVERRIDE_TRANSITION_DURATION||200,s=`${o}ms`;i.css({transition:`left ${s} linear, top ${s} linear, width ${s} linear, height ${s} linear`,position:"fixed",zIndex:1e7,pointerEvents:"none",left:t.left,top:t.top,width:t.width,height:t.height}),setTimeout(()=>{i.css({left:e.left,top:e.top,width:e.width,height:e.height})},5);let a=!1;const l=()=>{if(a)return;a=!0,X=!1,i.remove(),n();let t=Y.shift();t&&t()};i.on("transitionend transitioncancel",l),setTimeout(l,1.2*o)}),c.close=(e=>{if(e&&!0!==e)throw new TypeError("force must be a boolean or undefined, not "+Object.prototype.toString.call(e));if(!e){var n=t.Event("close");if(c.trigger(n),n.isDefaultPrevented())return}l&&l.detach(),c.closed=!0,m.triggerHandler("closed"),c.trigger("closed"),c.remove(),t(t(".window:visible").toArray().sort((t,e)=>e.style.zIndex-t.style.zIndex)[0]).triggerHandler("refocus-window"),D()}),c.closed=!1,c.setMenuBar=(t=>{L&&L.element.remove(),t&&(c.$titlebar.after(t.element),t.setKeyboardScope(c[0]),L=t)}),e.title&&c.title(e.title),l||c.center(),c}return r.$FormWindow=function(e){var i=new r;return i.title(e),i.$form=t(n("form")).appendTo(i.$content),i.$main=t(n("div")).appendTo(i.$form),i.$buttons=t(n("div")).appendTo(i.$form).addClass("button-group"),i.$Button=((e,o)=>{var s=t(n("button")).appendTo(i.$buttons).text(e);return s.on("click",t=>{t.preventDefault(),o()}),s.on("pointerdown",()=>{s.focus()}),s}),i},r});
  //# sourceMappingURL=../sourcemaps/os-gui/$Window.js.map
  