/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/bxy@0.1.117/web/modules.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const π=Math.PI;!async function(e,...t){return"modules"in e?n(e.modules):await(async([e],t,...o)=>await n(e,...(await Promise.all(t)).concat(o)))(t.splice(0,1),(t=t.map((e=>e instanceof Promise?async()=>await e:e)).reduce(((e,t)=>("function"==typeof t&&"AsyncFunction"===t.constructor.name?e[0].push(t()):e.push(t),e)),[[]]))[0],...t.slice(1,t.length));function n(t,...n){return t(e,...n).then(o)}async function o(t){e.dispatchEvent(new CustomEvent("modules",{bubbles:!0,composed:!0,detail:t}))}}(this,(async function ModulesExporter(environment,element,Project,Cookie,Keyboard){let load=[];class Modules extends(static_mixin()){static get base(){return this.element.base}static get url(){return this.element.url}static get version(){return this.package.version}get"@meta"(){return this.constructor.element.getAttribute("meta")}get"@modules"(){return this.get("@package.modules")}get"@package"(){return this.constructor.package}get"@url"(){return this.constructor.url}get"@emitter"(){return this.dot.get(window,"document.documentElement")||window}argument(){return this.is.argument(arguments[0])?arguments[0]:arguments}create(){return create_type(this,...arguments)}define(...e){return define_module(this,...e)}get(e){return get_module(this,e)}has(e){return has_module(this,e)}get resource(){return this.ProjectPackage.ModuleResource}set(e,t){return set_module(this,e,t)}get storage(){return this.import.storage()}get url(){return URL.get}get window_locator(){return window.location.href.replace(`${window.location.search}`,"").replace(`${window.location.hash}`,"")}}return Modules.prototype.keyboard=Keyboard(),Modules.prototype.static=static_module,Modules.prototype.static.mixin=static_mixin,Modules.element=element,Modules.package=await environment.fetch(element.package).then((e=>e.json())),element.url.href.includes("bxy@latest")&&(element.url=new URL(element.url.href.replace("bxy@latest",`bxy@${Modules.package.version}`))),await load_assets(environment.modules=new Modules);function create_type(e,t,...n){return e.is.function(t)?new t(...n):(e.is.object(t)&&(t=Object.create(t)),new Object(n.reduce(((e,t)=>Object.assign(e,t))),t))}async function load_assets(modules){return new Promise(load_assets_promise);function evaluate_asset(url){return window.fetch(new URL(url,element.url)).then((e=>e.text())).then((x=>{try{return eval(x)}catch(e){return"json"===url.extension?{}:null}}))}async function load_assets_promise(e){await evaluate_asset("prototype/URL.prototype.js"),evaluate_asset("prototype/HTMLElement.prototype.js");for(const e of load)once_module(modules,e,n);function t(...e){e=e.filter((e=>!1===load.includes(e))),load.push(...e);for(const t of e)once_module(modules,t,n),evaluate_asset(`module/${t}.js`)}function n(n){Object.defineProperty(modules,n.type,{configurable:!1,value:n.detail,writable:!1}),"dot"===n.type?t("wait"):"wait"===n.type?(t("element"),evaluate_asset("prototype/Event.prototype.js")):"element"===n.type?t("http","import"):"import"===n.type&&Modules.element.hasAttribute("meta")?t("meta"):0===load.length&&(load=null,1)&&function(){return Project(Modules.base).then(t).then(e);function t(e){return Cookie(modules),e.at("design")&&modules.import.class("Design"),e}}()}t("is","phrase","dot")}}function once_module(e,t,n){environment.addEventListener(t,(function e(t){environment.removeEventListener(t.type,e,!1),load.splice(load.indexOf(t.type),1),n(t)}),!1)}function define_module(e,t,n,o=!1){return n||console.warn(`Invalid module: "${t}"`),load&&load.includes(t)?(window.dispatchEvent(new CustomEvent(t,{detail:n.value})),n):!0===o?(Object.defineProperty(e,t,n),e[t]):set_module(e,t,n.value)}function get_module(e,t){return t in e?e[t]:"dot"in e?e.dot.get(e,t):null}function has_module(e,t){return t in e||"dot"in e&&e.dot.has(e,t)}function let_module(e){return function(t){if(!1===e.is.object(t))throw new Error("modules.let expects a valid object.");return Object.entries(t).reduce((function(e,t){return e.set(...t),e}),e)}}function set_module(e,t,n){return"dot"in e?e.dot.set(e,t,n):define_module(e,t,{value:n},!0),e.get(t)}function static_mixin(e){return class extends(e=e||class{}){dispatch(){return environment.modules["@emitter"].dispatch(...arguments),this}off(){return environment.modules["@emitter"].off(...arguments),this}on(){return environment.modules["@emitter"].on(...arguments),this}once(){return environment.modules["@emitter"].once(...arguments),this}send(){return this.dispatch(...arguments)}}}function static_module(e){return this.dot.get(this.constructor,e)}}),(async function(e=null){const t=/(.+):\/\/(.+)/i;return function(e){const n=e.hasAttribute("embedded");e.setAttribute("id","bxy"),e.base=window.document.head.querySelector("base"),e.base||(e.base=window.document.createElement("base"),e.base.href=new URL(window.location.href));try{e.source_url=new URL(e.getAttribute("src"))}catch(t){e.source_url=new URL(e.getAttribute("src"),window.location.href)}e.source_url.pathname.includes("/web/")?e.module_url=new URL(`${e.source_url.href.split("/web/")[0]}/`):e.module_url=e.source_url;e.module_url.origin.includes("https://unpkg.com")&&!e.module_url.href.includes("@")&&(e.module_url=new URL("https://unpkg.com/bxy@latest/"));e.url=new URL("web/",e.module_url),e.package=new URL("package.json",e.module_url),e.base.url=function(n){if(n&&(n=n.trim())&&n.endsWith(".meta"))return t.test(n)?new URL(n):new URL(n,window.location.href);return new URL("package."+(null===n?"json":"meta"),e.base.href)}(e.getAttribute("meta")),n&&e.base.setAttribute("embedded","");return e}(function(t=new RegExp("/bxy")){for(let n=0;n<window.document.scripts.length;n++)if((e=window.document.scripts.item(n)).hasAttribute("src")&&t.test(e.getAttribute("src")))return e;return e}())}),(function(e){const{dot:t,is:n}=window.modules,o=window.modules.set("ProjectPackage",class{constructor(o,i){!1===t.has(o,"project")&&(o.project={}),this.package=o,e.hasAttribute("embedded")&&delete this.package.project.main,this.element=e,this.main=function(e,o){!1===n.data(o)&&(o={});return o.url=function(...o){let i;t.has(e,o[0])&&(i=t.get(e,o[0]));i instanceof URL==!1?i=void 0:o.splice(0,1);n.nothing(i)&&t.has(e,"main.location")&&(i=t.get(e,"main.location"));i instanceof URL==!1&&(i=void 0);!1===n.nothing(i)&&o.push(i);return URL.join(...o)},o}(this,t.get(o,"project.main")),this.domain=function(e,n){!1===t.has(n,"project.domain")&&(n.project.domain={});!1===t.has(n,"project.domain.protocol")&&(n.project.domain.protocol=e.element.url.protocol.replace(":",""));!1===t.has(n,"project.domain.name")&&(n.project.domain.name=e.element.url.hostname);return n.project.domain}(this,o),n.text(this.domain.name)&&this.domain.name.startsWith("localhost")&&(this.domain.local=!0),this.subdomain=function(e,t,o={}){!1===n.array(t)&&(t=[]);for(const n of t)o[n]=new URL(`${e.domain.protocol}://${n}.${e.domain.name}/`);return o}(this,t.get(o,"project.subdomain")),async function(e,o=[]){for(const n in e.subdomain)t.set(e,n,e.subdomain[n]);t.has(e,"package.project.locations")&&await async function(n){return e[Symbol.for("locations")]=n,await Promise.all(Object.entries(n).map(o));function o(n){return async function(){const n=function(e,n=[]){t.has(e,"folder")&&n.push(t.get(e,"folder"));t.has(e,"version")&&n.push(t.get(e,"version"));return r(...n)}(arguments[1]),o=function(n){const o=t.has(n,"subdomain");return e.domain.local&&(t.has(n,"local")||o)?URL.join("/"):o?e.subdomain[n.subdomain]:URL.join()}(arguments[1]),s=t.has(arguments[1],"field")?arguments[1].field:arguments[0];t.set(e,s,Object.assign(URL.join(`${n}/`,o),arguments[1])),await i(arguments[1],"assets",{folder:n,location:s,origin:o}),await i(arguments[1],"items",{folder:n,location:s,origin:o}),await i(arguments[1],"locations",{folder:n,location:s,origin:o})}(...n)}}(t.get(e,"package.project.locations"));t.has(e,"main.define")&&await async function(n){for(const i in n)t.set(e,i,await(await window.modules.http(o(n[i]))).data);function o(n){return n.includes("http")?new URL(n):n.includes("@")?(n=n.split("@"),new URL(n[0],t.get(e,n[1]))):e.main.url(n)}}(t.get(e,"main.define"));if(Object.defineProperty(e.package,"locations",{get:()=>window.modules.project}),t.has(e,"main.assets"))for(const n of t.get(e,"main.assets"))"string"==typeof n?o.push({url:e.main.url(n)}):o.push(n);o.length&&window.modules.import.assets(...o);t.has(e,"main.wait")&&await window.modules.wait(...e.main.wait);return e;async function i(n,i,{origin:a,location:u,folder:c}){if(t.has(n,i))for(const l of Object.entries(t.get(n,i))){const n="locations"===i?l[0]:l[1],d=r(c,"locations"===i?l[1]:n),m=await s(a,"items"===i?`${d}/`:d);"assets"===i?o.push({location:u,url:m}):t.set(e,n,Object.assign(m,t.has(e,n)?t.get(e,n):null))}}async function s(e,t){return t=n.text(t)&&t.includes("${")?window.modules.tag(t):t,n.dictionary.locator.url(new URL(n.text(t)?t:"/",e))}function r(...e){return e.join("/").split("/").filter((e=>e.trim().length)).join("/")}}(window.modules.set("project",this)).then(i).catch(console.error)}get at(){return function(){return n=>t.get(e(arguments[0]),n);function e(){return new Proxy(window.modules.is.object(arguments[0])?arguments[0]:{},{get:(t,o)=>n(e(t,o),o),has:(t,n)=>o(e(t,n),n)});function e(e,n){if(!1===o(e,n))for(const i of["project","package","@","locations","global"])if(o(e,i))try{if(t.has(e[i],`@${n}`))return e[i];if(t.has(e[i],n))return e[i];if(t.has(e[`@${i}`],`@${n}`))return e[`@${i}`];if(t.has(e[`@${i}`],n))return e[`@${i}`]}catch(e){}return e}function n(e,n){return t.has(e,`@${n}`)?t.get(e,`@${n}`):t.has(e,n)?t.get(e,n):null}function o(e,n){return t.has(e,n)||t.has(e,`@${n}`)}}}(this.package)}get dependencies(){return this.package.dependencies}});return o.ModuleResource=function(){function e(t,...n){if(this instanceof e==!1)return async function(e,...t){const n=t.filter((e=>window.modules.has(e)||window.modules.is.defined(e))).length===t.length;try{!1===n&&(!1===window.modules.has("meta")&&await window.modules.import("meta"),e.json=await window.modules.import.meta(e.location.at("package.json")),await window.modules.import.assets(...e.assets))}catch(t){console.warn(`Modules: load_package_json() -> \nInvalid package.json from -> "${e}"\nError: ${e.error=t}`)}return e}(new e(...arguments),...n);this.location=t instanceof URL?t:HTMLElement.SourceCode.url(t)}return e.prototype={get assets(){return[this.index,this.dependencies]},get dependencies(){return Object.entries(window.modules.dot.get(this,"nest.dependencies")||{}).map(t,this)},get identity(){return this.location.basename.replace(`.${this.location.extension}`,"")},get index(){return n.call(this)},get nest(){return window.modules.dot.get(this,`json.nest.${this.identity}`)}},e;function t(e){return URL.is(e[1])?URL.get(e[1]):this.location.at(e[1])}function n(){const e=window.modules.dot.get(this,"json.browser")||window.modules.dot.get(this,"json.main");return e?this.location.at(e):null}}(),new Promise((async t=>new o(await async function(e,t=null){try{e.xml.variable?(t=window.modules.dot.get(window,e.xml.variable),window.modules.dot.delete(window,e.xml.variable),window.modules.is.text(t)&&(t=window.modules.meta.data(t))):t="meta"===e.url.extension?await window.modules.meta.import(e.url).catch(n):(await window.modules.http(e.url).catch(n)).json(!1,{})}catch(e){n(e)}return window.modules.is.data(t)?t:{};function n(t){console.warn(`No valid package assigned to 'modules.project' from -> "${e.url}"\nError: ${t.message}`)}}(e),t)))}),(function(e){const t="@cookie";return e.set("cookie",function(o){const i=e.get(`project.package.${t}`);i&&n(i.field,encodeURIComponent(e.meta.text(i.value)));return o}({field:t,delete:function(e){return this.set(e,"",-1)},set:n,get:function(t){const n=`${t}=`,o=window.document.cookie.split(";");for(let t=0;t<o.length;t++){let i=o[t];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(n))return e.meta.data(decodeURIComponent(i.substring(n.length,i.length)))}return null}}));function n(e,t,n=1,o="/"){const i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3);const s=`expires=${i.toUTCString()}`;return window.document.cookie=`${e}=${t}; ${s}; path=${o}`,this}}),(function(){const e={lock:144,0:96,1:97,2:98,3:99,4:100,5:101,6:102,7:103,8:104,9:105,multiply:106,add:107,subtract:109,decimal:110,divide:111},t={scroll:145,end:35,home:36,up:33,down:34,insert:45,delete:46,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},n={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,accent:192,get alt(){return this.option},get arrow(){return{down:this.down,left:this.left,right:this.right,up:this.up}},backslash:220,backspace:8,get bracket(){return{close:this.close,open:this.open}},break:19,capitals:20,get caps(){return this.capitals},close:221,comma:188,command:{left:91,right:93},control:17,dash:189,down:40,enter:13,equal:187,escape:27,left:37,open:219,option:18,period:190,quote:222,right:39,semicolon:186,get select(){return this.command.right},shift:16,slash:191,space:32,tab:9,up:38,get windows(){return{left:this.command.left,right:92}}};function o(e){if(this instanceof o==!1)return new o(...arguments);arguments[0]instanceof Event?this.event=arguments[0]:this.field=arguments[0],this.field=this.event?this.event.keyCode||this.event.charCode||this.event.which:arguments[0],this.key=i(this.field)||null,this.key&&("number"==typeof this.key.code&&(this[this.key.code]=!0),this[this.key.name]=!0,this[this.key.fieldset]=!0,this.name=this.key.name)}return o.numeric=e,o.functional=t,o.keymap=n,new Proxy(o,{get:(e,t)=>i(t)});function i(i){if(i in o)return s(o[i],i);"string"==typeof i&&(i=i.toLowerCase());let r=s(n,"keymap").get(i);return null===r&&null===(r=s(t,"functional").get(i))&&(r=s(e,"numeric").get(i)),r}function s(){return arguments[0]instanceof Object==!1?null:{data:arguments[0],entry:arguments.length>1?arguments[1]:null,get fields(){return Object.keys(this.data)},get entries(){return Object.entries(this.data)},get sets(){return this.values.map(s).filter((e=>null!==e))},get(){let t={entry:null,index:-1,get code(){return this.entry[1]},get name(){return this.entry[0]}};if(e(t.index=this.fields.indexOf(arguments[0]))&&e(t.index=this.values.indexOf(arguments[0])))for(const n of this.sets)if(!1===e(t=n.get(arguments[0]))){t.index=n.entry;break}return!1===e(t)&&!1===e(t.index)&&(t.entry=this.entries[t.index],t.fieldset=this.entry),e(t)||e(t.index)?null:t},get values(){return Object.values(this.data)}};function e(e){return null===e||-1===e}}}));
//# sourceMappingURL=/sm/448d3379dbc70c99e8d86523ad391389710a250bde3d0a29c6cdab81947cd0bf.map