lecodes-cli 2.5.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20618 -19047
- package/package.json +15 -18
- package/runtime/materials/foliage-cards.mat +16 -2
- package/runtime/materials/foliage-impostor.mat +103 -26
- package/runtime/materials/foliage.mat +12 -1
- package/runtime/materials/grass.mat +6 -3
- package/runtime/sdk-types.json +1 -1
- package/runtime/web/VERSION.json +3 -3
- package/runtime/web/assets/{materials-Cs_z1zLi.bin → materials-DE8QZ7Hn.bin} +0 -0
- package/runtime/web/assets/materials-world-CGNyYz_-.bin +0 -0
- package/runtime/web/player.js +16 -16
- package/runtime/web-lite/lite.js +2 -2
- package/src/commands/call.ts +96 -0
- package/src/commands/compile.ts +8 -4
- package/src/commands/desktop.ts +5 -4
- package/src/commands/dev.ts +42 -3
- package/src/commands/index.ts +2 -0
- package/src/commands/init/templates.ts +67 -3
- package/src/commands/plugin.ts +1 -1
- package/src/commands/render.ts +31 -22
- package/src/commands/test.ts +90 -24
- package/src/commands/web.ts +13 -4
- package/src/compile/headlessBundle.ts +5 -6
- package/src/compile/projectCompile.ts +35 -5
- package/src/declarations/lecodes-headless.d.ts +51 -2
- package/src/dev/backendCall.ts +44 -0
- package/src/dev/backendWorker.ts +60 -7
- package/src/dev/bots.ts +133 -0
- package/src/dev/devLink.ts +136 -0
- package/src/dev/devServer.ts +19 -6
- package/src/dev/localBackend.ts +57 -9
- package/src/dev/projectBackend.ts +227 -49
- package/src/hosts/desktopRenderer.ts +8 -2
- package/src/hosts/liteRunner.ts +1 -0
- package/src/plugin/generate.ts +5 -3
- package/runtime/web/assets/materials-world-BtoAfznA.bin +0 -0
package/runtime/web/player.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $n=Object.defineProperty;var Vn=(n,t,e)=>t in n?$n(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var b=(n,t,e)=>Vn(n,typeof t!="symbol"?t+"":t,e);import{K as we,k as Gn}from"./assets/keyboardMotion-C2Bk5H0n.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=e(r);fetch(r.href,i)}})();const jn="modulepreload",zn=function(n,t){return new URL(n,t).href},be={},H=function(t,e,s){let r=Promise.resolve();if(e&&e.length>0){let o=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const a=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=o(e.map(h=>{if(h=zn(h,s),h in be)return;be[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!s)for(let y=a.length-1;y>=0;y--){const x=a[y];if(x.href===h&&(!u||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":jn,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((y,x)=>{g.addEventListener("load",y),g.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},Kn={full:()=>H(()=>import("./assets/creator-full-B13Tbmyv.js"),[],import.meta.url),"2d":()=>H(()=>import("./assets/creator-2d-CP3Nfpma.js"),[],import.meta.url),ui:()=>H(()=>import("./assets/creator-ui-CQghF7sw.js"),[],import.meta.url)},Xn={full:()=>new URL(""+new URL("assets/creator-full-D1sSItG6.wasm",import.meta.url).href,import.meta.url).href,"2d":()=>new URL(""+new URL("assets/creator-2d-DLtO_8eE.wasm",import.meta.url).href,import.meta.url).href,ui:()=>new URL(""+new URL("assets/creator-ui-ByVRKvqF.wasm",import.meta.url).href,import.meta.url).href},Yn=async(n,t={})=>{const e=(await Kn[n]()).default,s=Xn[n](),r={locateFile:o=>o.endsWith(".wasm")?s:o,...t.glContext?{filament_glContext:t.glContext,filament_glOptions:t.glOptions??{}}:{},...t.gl2dContext?{creator2d_glContext:t.gl2dContext,creator2d_glOptions:t.gl2dOptions??{}}:{},...t.moduleArgs},i=await e(r);if(typeof i._creatorWebVersion!="function")throw new Error(`creator-web: ${n} is not a creator-web profile module`);return i},nn=1,rn=2,sn=3,ve=4,qn=5,Jn=6,Qn=7,xe=8,ne=15,on=4293918720,kt=n=>(on|n<<16)>>>0,Zn=kt(nn),tr=kt(rn),er=kt(sn),nr=kt(ne),Ee=n=>(n&4293918720)>>>0===on?n>>>16&15:0,Se=64*1024;class rr{constructor(t,e){b(this,"M");b(this,"host");b(this,"out",0);b(this,"table",[void 0]);b(this,"refs",[0]);b(this,"freeSlots",[]);b(this,"objIndex",new WeakMap);b(this,"pending");b(this,"hasPending",!1);b(this,"worlds",new Map);b(this,"nextWorld",2);b(this,"newWorld");b(this,"argBase",0);b(this,"argSp",0);b(this,"scratch",new DataView(new ArrayBuffer(8)));b(this,"classRegistry");b(this,"tracked",new Map);b(this,"fnRegistry");b(this,"opaques",new WeakMap);this.M=t,this.host=e.host,this.worlds.set(1,e.world),this.newWorld=e.newWorld,this.argBase=t._malloc(Se),this.argSp=this.argBase,this.classRegistry=new FinalizationRegistry(s=>{this.tracked.delete(s)&&this.M._jsbFinalize(s.cls,s.opaque)}),this.fnRegistry=new FinalizationRegistry(s=>{this.M._jsbFunctionGone(s)})}_init(t){this.out=t}write(t,e){const s=this.M;if(typeof e=="number")return s.HEAPF64[t>>3]=e!==e?NaN:e,0;let r=0,i,o=0;return e===void 0?i=Zn:e===null?i=tr:typeof e=="boolean"?(i=er,r=e?1:0):(r=o=this.alloc(e),i=kt(typeof e=="function"?qn:typeof e=="string"?Jn:Array.isArray(e)?Qn:typeof e=="object"?ve:xe)),s.HEAPU32[t>>2]=r,s.HEAPU32[(t>>2)+1]=i,o}writeOut(t){this.write(this.out,t)}writeOutException(){const t=this.M;t.HEAPU32[this.out>>2]=0,t.HEAPU32[(this.out>>2)+1]=nr}decode(t,e){switch(Ee(e)){case 0:return this.scratch.setUint32(0,t,!0),this.scratch.setUint32(4,e,!0),this.scratch.getFloat64(0,!0);case nn:case ne:return;case rn:return null;case sn:return t!==0;default:return this.table[t]}}readAt(t){const e=this.M;return this.decode(e.HEAPU32[t>>2],e.HEAPU32[(t>>2)+1])}valueAt(t){return t?this.readAt(t):void 0}takeOut(){const t=this.M,e=t.HEAPU32[this.out>>2],s=t.HEAPU32[(this.out>>2)+1],r=Ee(s);if(r===ne)return{value:void 0,threw:!0};const i=this.decode(e,s);return r>=ve&&r<=xe&&this.release(e),{value:i,threw:!1}}args(t,e){const s=new Array(t);for(let r=0;r<t;r++)s[r]=this.readAt(e+r*8);return s}alloc(t){const e=typeof t=="object"||typeof t=="function";if(e){const r=this.objIndex.get(t);if(r!==void 0)return this.refs[r]++,r}let s;return this.freeSlots.length>0?(s=this.freeSlots.pop(),this.table[s]=t,this.refs[s]=1):(s=this.table.length,this.table.push(t),this.refs.push(1)),e&&this.objIndex.set(t,s),s}dup(t){t>0&&this.refs[t]++}release(t){var s;if(t<=0)return;if(this.refs[t]<=0){console.warn(`[jsb] release of a dead handle ${t} (${typeof this.table[t]})`,(s=new Error().stack)==null?void 0:s.split(`
|
|
2
2
|
`).slice(2,6).join(`
|
|
3
3
|
`));return}if(--this.refs[t]>0)return;const e=this.table[t];(typeof e=="object"||typeof e=="function")&&this.objIndex.delete(e),this.table[t]=void 0,this.freeSlots.push(t)}liveHandles(){return this.table.length-1-this.freeSlots.length}global(t){var e;this.writeOut(((e=this.worlds.get(t))==null?void 0:e.global)??this.worlds.get(1).global)}newContext(){if(!this.newWorld)return 1;const t=this.nextWorld++;return this.worlds.set(t,this.newWorld()),t}freeContext(t){t!==1&&this.worlds.delete(t)}eval(t,e,s){const r=this.worlds.get(t)??this.worlds.get(1);try{this.writeOut(r.evaluate(e,s))}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}get(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}getIndex(t,e,s){const r=this.decode(t,e);if(r==null){this.writeOut(void 0);return}try{this.writeOut(r[s])}catch(i){this.pending=i,this.hasPending=!0,this.writeOutException()}}has(t,e,s){const r=this.decode(t,e);return(typeof r=="object"||typeof r=="function")&&r!==null&&s in r}set(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}setIndex(t,e,s,r){const i=this.table[t];i!=null&&(i[e]=this.decode(s,r))}keys(t,e,s){const r=this.M,i=this.decode(t,e),o=(typeof i=="object"||typeof i=="function")&&i!==null?Object.keys(i):[];let a=1;for(const h of o)a+=r.lengthBytesUTF8(h)+1;const c=r._malloc(a);let l=c;for(const h of o){const u=r.lengthBytesUTF8(h)+1;r.stringToUTF8(h,l,u),l+=u}return r.HEAPU32[s>>2]=o.length,c}newObject(t,e){const s={};if(t>0){this.opaques.set(s,{cls:t,opaque:e});const r={ref:new WeakRef(s),cls:t,opaque:e};this.tracked.set(r,r),this.classRegistry.register(s,r,r)}this.writeOut(s)}newArray(){this.writeOut([])}opaqueOf(t,e){const s=this.table[t];if(typeof s!="object"||s===null)return 0;const r=this.opaques.get(s);return r&&r.cls===e?r.opaque:0}json(t,e){let s;try{s=JSON.stringify(this.decode(t,e))}catch{s=void 0}this.writeOut(s)}parseJson(t){try{this.writeOut(JSON.parse(t))}catch(e){this.pending=e,this.hasPending=!0,this.writeOutException()}}newString(t){this.writeOut(t)}str(t,e,s){const r=this.M,i=this.decode(t,e);let o;try{o=typeof i=="string"?i:String(i)}catch{return 0}const a=r.lengthBytesUTF8(o),c=r._malloc(a+1);return r.stringToUTF8(o,c,a+1),r.HEAPU32[s>>2]=a,c}logString(t,e){const s=this.M,r=this.decode(t,e);let i;try{i=String(r)}catch{i=""}if(r instanceof Error&&typeof r.stack=="string"&&r.stack.length>0){const c=r.stack.startsWith(i)?r.stack.slice(i.length).replace(/^\n/,""):r.stack;c.trim().length>0&&(i+=`
|
|
4
|
-
`+c.replace(/[\r\n]+$/,""))}const o=s.lengthBytesUTF8(i),a=s._malloc(o+1);return s.stringToUTF8(i,a,o+1),a}toNumber(t){try{return Number(this.table[t])}catch{return NaN}}truthy(t){return!!this.table[t]}newError(t){this.writeOut(new Error(t))}throwNew(t,e){this.pending=t===1?new TypeError(e):new Error(e),this.hasPending=!0}takeException(){const t=this.hasPending?this.pending:void 0;this.pending=void 0,this.hasPending=!1,this.writeOut(t)}throwPending(){const t=this.hasPending?this.pending:new Error("native handler failed");throw this.pending=void 0,this.hasPending=!1,t}call(t,e,s,r,i,o){const a=this.table[e],c=this.decode(s,r),l=this.args(i,o);try{this.writeOut(a.apply(c,l))}catch(h){this.pending=h,this.hasPending=!0,this.writeOutException()}}construct(t,e,s){const r=this.table[t],i=this.args(e,s);try{this.writeOut(Reflect.construct(r,i))}catch(o){this.pending=o,this.hasPending=!0,this.writeOutException()}}typedArray(t,e,s){const i=this.M.HEAPU8.slice(e,e+s).buffer,o=[null,Uint8Array,Uint16Array,Uint32Array,Int32Array,Float32Array,Float64Array,Int16Array,Int8Array,Uint8ClampedArray];if(t===0){this.writeOut(i);return}const a=o[t];this.writeOut(a?new a(i):void 0)}arrayIn(t,e,s,r){const i=this.M,o=this.table[t];let a=null,c=0;if(s===2){if(!(o instanceof ArrayBuffer))return 0;a=new Uint8Array(o),c=a.byteLength}else{if(!ArrayBuffer.isView(o)||o instanceof DataView)return 0;const h=o,u=h.BYTES_PER_ELEMENT;if(s===0&&u!==e)return 0;a=new Uint8Array(h.buffer,h.byteOffset,h.byteLength),c=s===0?h.length:h.byteLength}const l=i._malloc(Math.max(a.byteLength,1));return a.byteLength>0&&i.HEAPU8.set(a,l),i.HEAPU32[r>>2]=c,l}arrayOut(t,e,s){const r=this.table[t];let i;if(r instanceof ArrayBuffer)i=new Uint8Array(r);else if(ArrayBuffer.isView(r))i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);else return;const o=Math.min(s,i.byteLength);o>0&&i.set(this.M.HEAPU8.subarray(e,e+o))}invoke(t,e){const s=e.length,r=this.argSp;let i=r,o=0;r+s*8>this.argBase+Se?(o=this.M._malloc(Math.max(s*8,8)),i=o):this.argSp=r+s*8;const a=[];for(let l=0;l<s;l++){const h=this.write(i+l*8,e[l]);h&&a.push(h)}let c;try{t(s,i),c=this.takeOut()}finally{for(const l of a)this.release(l);this.argSp=r,o&&this.M._free(o)}return c.threw&&this.throwPending(),c.value}defineMethod(t,e,s,r,i,o){const a=this.table[e];if(o){Object.defineProperty(a,s,{configurable:!0,enumerable:!1,get:()=>this.invoke(()=>this.M._jsbInvokeGetter(r),[])});return}const c=this.M,l=(...h)=>this.invoke((u,d)=>c._jsbInvoke(t,r,u,d),h);Object.defineProperty(l,"name",{value:s}),Object.defineProperty(l,"length",{value:i}),Object.defineProperty(a,s,{configurable:!0,enumerable:!1,writable:!0,value:l})}makeFunction(t,e,s,r){const i=this.M,o=(...a)=>this.invoke((c,l)=>i._jsbInvokeData(t,e,c,l),a);s&&Object.defineProperty(o,"name",{value:s}),Object.defineProperty(o,"length",{value:r}),this.fnRegistry.register(o,e),this.writeOut(o)}callback(t,e){return t?(...s)=>{if(e){if(e.done){console.warn("[jsb] a settled host callback was called again");return}e.done=!0}const r=this.M,i=s.length,o=e?e.ptrs.length:0,a=r._malloc(Math.max(i*8+o*4,8)),c=[];for(let h=0;h<i;h++){const u=this.write(a+h*8,s[h]);u&&c.push(u)}const l=a+i*8;for(let h=0;h<o;h++)r.HEAPU32[(l>>2)+h]=e.ptrs[h];r._jsbHostCall(t,i,a,l,o);for(const h of c)this.release(h);r._free(a)}:()=>{}}viewEvent(t,e,s){const r=this.M,i=r.stringToNewUTF8(e);if(s===void 0){r._jsbViewEvent(t,i,0),r._free(i);return}const o=r._malloc(8),a=this.write(o,s);r._jsbViewEvent(t,i,o),a&&this.release(a),r._free(o),r._free(i)}group(...t){return{ptrs:t.filter(e=>e!==0),done:!1}}strings(t,e){const s=this.M,r=new Array(e);for(let i=0;i<e;i++){const o=s.HEAPU32[(t>>2)+i];r[i]=o?s.UTF8ToString(o):""}return r}bytesOut(t,e){const s=this.M;let r=null;if(t instanceof Uint8Array?r=t:t instanceof ArrayBuffer?r=new Uint8Array(t):ArrayBuffer.isView(t)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),!r||r.byteLength===0)return e&&(s.HEAPU32[e>>2]=0),0;const i=s._malloc(r.byteLength+1);return s.HEAPU8.set(r,i),s.HEAPU8[i+r.byteLength]=0,e&&(s.HEAPU32[e>>2]=r.byteLength),i}gc(){const t=globalThis.gc,e=globalThis.Bun;for(let s=0;s<2;s++){if(e!=null&&e.gc)e.gc(!0);else if(typeof t=="function")t();else return;this.sweep()}}sweep(){for(const t of[...this.tracked.keys()])t.ref.deref()===void 0&&(this.tracked.delete(t),this.classRegistry.unregister(t),this.M._jsbFinalize(t.cls,t.opaque))}}const
|
|
5
|
-
`)){const s=e.indexOf(":");s>0&&t.set(Number(e.slice(0,s)),e.slice(s+1))}return t}).catch(n=>(console.warn("[creator-gl] creator-gl.js.symbols unavailable, wasm frames stay anonymous:",n),null))),
|
|
6
|
-
`).map(r=>{if(ot.lastIndex=0,!ot.test(r))return r;const i=
|
|
7
|
-
`):null},
|
|
8
|
-
`))if(
|
|
9
|
-
`+e)})};let ke=!1;const cr=()=>{ke||(ke=!0,addEventListener("error",n=>_e(n.error)),addEventListener("unhandledrejection",n=>_e(n.reason)))},H=[null];new TextDecoder("utf-8");const lr=async(n,t,e,s)=>{var f;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const g=new FormData;for(let[m,x,y]of t.body._entries)typeof x=="object"?g.append(m,new Blob([et(x._id)]),y):g.append(m,x);r=g}else typeof t.body=="string"?r=t.body:s(new Error("Invalid body"));const i=await fetch(n,{method:t.method,body:r,headers:t.headers,mode:"cors",credentials:"omit"}),o=typeof t.onProgress=="function"?t.onProgress:null;if(!o){const g=await i.arrayBuffer();H.push(g),e(H.length-1,i.status);return}const a=(f=i.body)==null?void 0:f.getReader();if(!a){const g=await i.arrayBuffer();H.push(g),e(H.length-1,i.status);return}const c=Number(i.headers.get("content-length"))||void 0;let l=0;const h=[];for(;;){const{done:g,value:m}=await a.read();if(g)break;m&&(h.push(m),l+=m.length,o({loaded:l,total:c}))}const u=new Uint8Array(l);let d=0;for(const g of h)u.set(g,d),d+=g.length;H.push(u.buffer),e(H.length-1,i.status)},ln=n=>{const t=new Blob([H[n]]);return URL.createObjectURL(t)},$t=n=>new Blob([H[n]]),et=n=>H[n],hr=n=>{H[n]=null},ft=n=>(H.push(n),H.length-1),fe=new Map,ur=(n,t)=>{fe.set(n,t);const e=It.get(n);e!==void 0&&(H[e]=t)},dr=n=>fe.has(n),It=new Map,fr=n=>{for(const[t,e]of It)if(e===n)return t},gr=n=>{const t=It.get(n);if(t!==void 0)return t;const e=fe.get(n);if(!e)return-1;H.push(e);const s=H.length-1;return It.set(n,s),s},Ft=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function hn(n){return typeof n=="object"&&n!==null&&"svg"in n}function pr(n){return typeof n=="object"&&n!==null&&"_id"in n}function mr(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const re="lecodes-canvas://";function yr(n){return n.startsWith(re)?Number(n.slice(re.length)):void 0}function wr(n){return typeof File<"u"&&n instanceof File}function un(n){let t=n.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const e=new TextEncoder().encode(t);let s="";for(const r of e)s+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(s)}`}function Vt(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function se(n){var i,o,a;const t=((i=n.match(/<svg\b[^>]*>/i))==null?void 0:i[0])??"",e=t.match(/viewBox\s*=\s*["']\s*[\d.+-]+\s+[\d.+-]+\s+([\d.+-]+)\s+([\d.+-]+)\s*["']/i);if(e){const c=parseFloat(e[1]),l=parseFloat(e[2]);if(c>0&&l>0)return{width:c,height:l}}const s=parseFloat(((o=t.match(/\bwidth\s*=\s*["']?([\d.]+)/i))==null?void 0:o[1])??""),r=parseFloat(((a=t.match(/\bheight\s*=\s*["']?([\d.]+)/i))==null?void 0:a[1])??"");return s>0&&r>0?{width:s,height:r}:null}function br(n){const t=/^data:image\/svg\+xml(;[^,]*)?,([\s\S]*)$/.exec(n);if(!t)return null;const e=t[2];try{if(/;base64/i.test(t[1]??"")){const s=atob(e),r=new Uint8Array(s.length);for(let i=0;i<s.length;i++)r[i]=s.charCodeAt(i);return new TextDecoder().decode(r)}return decodeURIComponent(e)}catch{return null}}async function vr(n,t){if(!Vt(n))return null;const e=br(n);if(e)return se(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?se(s):null}function xr(n={}){const t=new WeakMap;return e=>{var o,a;if(e==null)return;if(typeof e=="string")return e;if(typeof e!="object")return;const s=e,r=t.get(s);if(r!==void 0)return r;let i;return hn(s)?i=un(s.svg):mr(s)?i=re+s.canvasSurface:pr(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):wr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function Te(n,t){if(!t)return;const e=yr(n);if(e===void 0)return;const s=t.getSurface(e);if(s)return{src:n,naturalWidth:s.width,naturalHeight:s.height,handle:s.canvas}}const dn=n=>n==="monospaced"?"monospace":n;function Re(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${dn(n.family)}`}class Er{constructor(t={}){b(this,"ctx");b(this,"images",new Map);b(this,"pending",new Map);b(this,"resolver");b(this,"canvasSurfaces");b(this,"fontFormat","woff2");const e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(8,8);this.ctx=e.getContext("2d"),this.canvasSurfaces=t.canvasSurfaces,this.resolver=xr({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return dn(t)}measureText(t,e){return this.ctx.font=Re(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=Re(t);const e=this.ctx.measureText("Mg"),s=e.fontBoundingBoxAscent||e.actualBoundingBoxAscent||t.size*.8,r=e.fontBoundingBoxDescent||e.actualBoundingBoxDescent||t.size*.2;return{ascent:s,descent:r}}getImage(t){return Te(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=Te(t,this.canvasSurfaces);if(e)return Promise.resolve(e);const s=this.images.get(t);if(s)return Promise.resolve(s);const r=this.pending.get(t);if(r)return r;const i=(async()=>{const o=await this.decode(t);let a=o.naturalWidth,c=o.naturalHeight;if(Vt(t)){const h=await vr(t,u=>fetch(u).then(d=>d.ok?d.text():null));h&&(a=h.width,c=h.height)}const l={src:t,naturalWidth:a,naturalHeight:c,handle:o};return this.images.set(t,l),this.pending.delete(t),l})();return this.pending.set(t,i),i.catch(()=>this.pending.delete(t)),i}decode(t){return new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=i=>s(i),r.src=t})}async loadFont(t,e,s){if(typeof globalThis.FontFace>"u")return;const r=new FontFace(t,`url(${e})`,s);document.fonts.add(r),await r.load()}}function Sr(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function mt(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function lt(n){const{r:t,g:e,b:s,a:r}=Sr(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function ie(n){return n===void 0||(n>>>0&255)===0}function oe(n,t){if(!n)return;const e=Math.min(t.width,t.height)/2;return{tl:Math.min(n.tl,e),tr:Math.min(n.tr,e),br:Math.min(n.br,e),bl:Math.min(n.bl,e)}}function Ae(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function _r(n,t,e,s){const r={x:0,y:0,width:n,height:t};if(s==="fill"||n===0||t===0)return{src:r,dst:e};if(s==="cover"){const c=Math.max(e.width/n,e.height/t),l=e.width/c,h=e.height/c;return{src:{x:(n-l)/2,y:(t-h)/2,width:l,height:h},dst:e}}const i=Math.min(e.width/n,e.height/t),o=n*i,a=t*i;return{src:r,dst:{x:e.x+(e.width-o)/2,y:e.y+(e.height-a)/2,width:o,height:a}}}function kr(n,t){const e=n*Math.PI/180,s=Math.sin(e),r=-Math.cos(e),i=t.x+t.width/2,o=t.y+t.height/2,a=(Math.abs(t.width*s)+Math.abs(t.height*r))/2;return{x0:i-s*a,y0:o-r*a,x1:i+s*a,y1:o+r*a}}function Tr(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const g=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,m=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:g,ry:m}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,c=Math.min(r,i),l=Math.max(r,i),h=Math.min(o,a),u=Math.max(o,a);let d,f;if(n.shape==="circle"){let g;switch(n.extent){case"closest-side":g=Math.min(c,h);break;case"farthest-side":g=Math.max(l,u);break;case"closest-corner":g=Math.hypot(c,h);break;default:g=Math.hypot(l,u);break}d=f=g}else switch(n.extent){case"closest-side":d=c,f=h;break;case"farthest-side":d=l,f=u;break;case"closest-corner":d=c*Math.SQRT2,f=h*Math.SQRT2;break;default:d=l*Math.SQRT2,f=u*Math.SQRT2;break}return{cx:e,cy:s,rx:d,ry:f}}class Me{constructor(t,e=1){b(this,"ctx");b(this,"dpr");b(this,"groups",[]);b(this,"scratch");b(this,"scratchCtx");b(this,"tileCells",new WeakMap);this.ctx=t,this.dpr=e}beginGroup(t){const e=this.ctx,s=e.canvas.width,r=e.canvas.height;let i;typeof OffscreenCanvas<"u"?i=new OffscreenCanvas(s,r):(i=document.createElement("canvas"),i.width=s,i.height=r);const o=i.getContext("2d");o.setTransform(e.getTransform()),this.groups.push({parent:e,layer:i,alpha:t}),this.ctx=o}endGroup(){const t=this.groups.pop();t&&(this.ctx=t.parent,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha*=t.alpha,this.ctx.drawImage(t.layer,0,0),this.ctx.restore())}beginFrame(t,e){const{ctx:s,dpr:r}=this;s.setTransform(r,0,0,r,0,0),s.clearRect(0,0,t,e),s.globalAlpha=1}endFrame(){}save(){this.ctx.save()}restore(){this.ctx.restore()}setAlpha(t){this.ctx.globalAlpha*=t}translate(t,e){this.ctx.translate(t,e)}scale(t,e){this.ctx.scale(t,e)}transform(t,e,s,r,i,o){this.ctx.transform(t,e,s,r,i,o)}addRectPath(t,e){const s=this.ctx;e&&(e.tl||e.tr||e.br||e.bl)?s.roundRect(t.x,t.y,t.width,t.height,[e.tl,e.tr,e.br,e.bl]):s.rect(t.x,t.y,t.width,t.height)}path(t,e){this.ctx.beginPath(),this.addRectPath(t,e)}clipRoundRect(t,e){this.path(t,e),this.ctx.clip()}fillRoundRect(t,e,s){this.path(t,e),this.ctx.fillStyle=lt(s),this.ctx.fill()}clearRoundRect(t,e){const s=this.ctx;s.save(),s.globalCompositeOperation="destination-out",s.globalAlpha=1,this.path(t,e),s.fillStyle="#000",s.fill(),s.restore()}fillGradient(t,e,s){if(s.type==="radial"){this.fillRadial(t,e,s);return}const{x0:r,y0:i,x1:o,y1:a}=kr(s.angle,t),c=this.ctx.createLinearGradient(r,i,o,a);for(const l of s.stops)c.addColorStop(Math.max(0,Math.min(1,l.position)),lt(l.color));this.path(t,e),this.ctx.fillStyle=c,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=Tr(s,t),c=this.ctx,l=o||1e-6,h=a||1e-6;c.save(),this.path(t,e),c.clip(),c.translate(r,i),c.scale(l,h);const u=c.createRadialGradient(0,0,0,0,0,1);for(const x of s.stops)u.addColorStop(Math.max(0,Math.min(1,x.position)),lt(x.color));c.fillStyle=u;const d=(t.x-r)/l,f=(t.x+t.width-r)/l,g=(t.y-i)/h,m=(t.y+t.height-i)/h;c.fillRect(d,g,f-d,m-g),c.restore()}strokeBorder(t,e,s){const r=this.ctx,i=["top","right","bottom","left"].filter(a=>s[a]);if(i.length===4&&i.every(a=>s[a].width===s.top.width&&s[a].color===s.top.color)){const a=s.top.width,c=oe(e,t);r.beginPath(),this.addRectPath(t,c);const l={x:t.x+a,y:t.y+a,width:t.width-2*a,height:t.height-2*a};if(l.width>0&&l.height>0){const h=c&&oe({tl:Math.max(0,c.tl-a),tr:Math.max(0,c.tr-a),br:Math.max(0,c.br-a),bl:Math.max(0,c.bl-a)},l);this.addRectPath(l,h||void 0)}r.fillStyle=lt(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:c,color:l}=s[a];r.fillStyle=lt(l),a==="top"?r.fillRect(t.x,t.y,t.width,c):a==="bottom"?r.fillRect(t.x,t.y+t.height-c,t.width,c):a==="left"?r.fillRect(t.x,t.y,c,t.height):r.fillRect(t.x+t.width-c,t.y,c,t.height)}}getScratch(t,e){return this.scratch||(this.scratch=typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):document.createElement("canvas"),this.scratchCtx=this.scratch.getContext("2d")),(this.scratch.width<t||this.scratch.height<e)&&(this.scratch.width=Math.max(this.scratch.width,t),this.scratch.height=Math.max(this.scratch.height,e)),this.scratchCtx}tileCell(t,e,s){const r=t.handle,i=this.tileCells.get(r);if(i&&i.pw===e&&i.ph===s)return i.canvas;const o=t.rasterize?t.rasterize(e,s):t.handle,a=typeof OffscreenCanvas<"u"?new OffscreenCanvas(e,s):Object.assign(document.createElement("canvas"),{width:e,height:s});return a.getContext("2d").drawImage(o,0,0,e,s),this.tileCells.set(r,{pw:e,ph:s,canvas:a}),a}drawImage(t,e,s,r){if(!t.handle)return;if(r.tile){const f=t.naturalWidth,g=t.naturalHeight;if(f<=0||g<=0)return;const m=Math.max(1,Math.ceil(f*this.dpr)),x=Math.max(1,Math.ceil(g*this.dpr)),y=t.rasterize!==void 0||Vt(t.src),p=y?this.tileCell(t,m,x):t.handle,w=y?f/m:1,E=y?g/x:1,k=this.ctx.createPattern(p,"repeat");if(!k)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(w,E),this.ctx.fillStyle=k,this.ctx.fillRect(0,0,s.width/w,s.height/E),this.ctx.restore();return}const i=e?{src:e,dst:s}:_r(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const c=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),h=!e&&r.fit!=="cover";let u=t.handle;if(t.rasterize)if(h)u=t.rasterize(c,l);else{const f=Math.max(c/a.width,l/a.height),g=Math.max(1,Math.ceil(t.naturalWidth*f)),m=Math.max(1,Math.ceil(t.naturalHeight*f));u=t.rasterize(g,m);const x=g/t.naturalWidth,y=m/t.naturalHeight;a={x:a.x*x,y:a.y*y,width:a.width*x,height:a.height*y}}if(r.tint===void 0){h?this.ctx.drawImage(u,o.x,o.y,o.width,o.height):this.ctx.drawImage(u,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const d=this.getScratch(c,l);d.clearRect(0,0,c,l),d.globalCompositeOperation="source-over",h?d.drawImage(u,0,0,c,l):d.drawImage(u,a.x,a.y,a.width,a.height,0,0,c,l),d.globalCompositeOperation="source-in",d.fillStyle=lt(r.tint),d.fillRect(0,0,c,l),d.globalCompositeOperation="source-over",this.ctx.drawImage(d.canvas,0,0,c,l,o.x,o.y,o.width,o.height)}fillText(t,e,s,r,i){const o=this.ctx;o.font=`${r.italic?"italic ":""}${r.weight} ${r.size}px ${r.family}`,o.textBaseline="alphabetic",o.textAlign="left","letterSpacing"in o&&(o.letterSpacing=`${r.letterSpacing}px`),o.fillStyle=lt(i),o.fillText(t,e,s)}}const V=[null],_t=new Map,fn=n=>{if(!n.startsWith("id:"))return n;const t=Number(n.slice(3));return et(t)?ln(t):null},gn=n=>{const t=_t.get(n);t!==void 0&&(URL.revokeObjectURL(t),_t.delete(n))},Et=[!1],pn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),Et[t]&&(n.currentTime=0,n.play())})},Rr=(n,t)=>{const e=fn(n);if(e===null)return-1;const s=document.createElement("video");document.body.appendChild(s),s.crossOrigin="anonymous",s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e,s.playsInline=!0,s.controls=!1;const r=V.length;return e!==n&&_t.set(r,e),V.push(s),Et.push(!1),pn(s,r,t),r},Ar=(n,t)=>{const e=fn(n);if(e===null)return-1;const s=document.createElement("audio");document.body.appendChild(s),s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e;const r=V.length;return e!==n&&_t.set(r,e),V.push(s),Et.push(!1),pn(s,r,t),r},Mr=(n,t)=>{const e=V[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},Lr=(n,t)=>{const e=V[n];e&&(t?e.play():e.pause())},Pr=(n,t)=>{Et[n]=t},Or=n=>{var t;return((t=V[n])==null?void 0:t.currentTime)??0},Cr=(n,t)=>{const e=V[n];e&&(e.currentTime=t)},Ir=n=>{var e;const t=((e=V[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},ge=n=>V[n],mn=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},Fr=n=>{const t=V[n];t&&(mn(t),gn(n),V[n]=null,Et[n]=!1)},yn=()=>{for(let n of V)n&&mn(n);for(const n of[..._t.keys()])gn(n);V.length=1,Et.length=1},Nr=9,Ur=10,Br=12,Dr=13,Wr=14,Hr=15,$r=16,Vr=1,Gr=2,jr=4,Le=8,zr=16,Kr=32,Xr=64,Yr=256,qr=512,Jr=1024,Qr=2048,Zr=4096,Pe=0,Mt=1,Oe=2,ut=3;function Ce(n,t,e){const s=n.rect;return t>=s.x&&t<s.x+s.width&&e>=s.y&&e<s.y+s.height}function bt(n,t,e,s){let r=null,i=null,o=!1;const a=c=>{const l=Ce(c,t,e);if(l&&s(c)&&(r=c),!(c.clip&&!l))for(const h of c.children)h.overlay!==void 0&&(r=null,i=h,o=!Ce(h,t,e)),a(h)};return a(n),{node:r,blocker:r?null:i,outside:o}}const ts=255,it={color:4294967295,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function ae(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:c,textAlign:l,textDecoration:h}=t,u=s??it.fontSize;return{color:e??(n.type==="input"||n.type==="textarea"?ts:it.color),fontSize:u,fontFamily:r??it.fontFamily,fontWeight:i??it.fontWeight,fontStyle:o??it.fontStyle,lineHeight:a,letterSpacing:c??it.letterSpacing,textAlign:l??it.textAlign,textDecoration:h??it.textDecoration}}function wn(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}const es=10;function ce(n,t,e){const s=[];if(n.length===0)return[""];let r=n;for(;r;){if(e(r)<=t){s.push(r);break}let i=0,o=-1,a=0;for(;(a=r.indexOf(" ",a+1))!==-1&&!(e(r.substring(0,a))>t);)o=a;if(o>0)i=o;else{let c=r.indexOf(" ");c===-1&&(c=r.length);const l=r.substring(0,c);if(e(l)>t){for(let h=1;h<=l.length;h++)if(e(l.substring(0,h))>t){i=h-1;break}}else for(let h=c+1;h<=r.length;h++)if(e(r.substring(0,h))>t){i=h-1;break}}i<=0&&(i=1),s.push(r.substring(0,i)),r=r.substring(i+(o>0?1:0))}return s}function ns(n,t,e,s){const r=e.length;if(r<2||r>es||!isFinite(t))return e;const i=c=>ce(n,c,s).length;let o=Math.floor(t);if(i(o)!==r)return e;let a=0;for(const c of n.split(" "))a=Math.max(a,Math.ceil(s(c)));if(a>=o)return e;if(i(a)===r)o=a;else for(;o-a>1;){const c=a+o>>1;i(c)===r?o=c:a=c}return ce(n,o,s)}function rs(n,t,e){const s=t.length;if(s<2)return t;const r=t[s-1].trim();if(r.length===0||r.includes(" "))return t;const i=t[s-2].trimEnd(),o=i.lastIndexOf(" ");if(o<=0)return t;const a=i.slice(o+1)+" "+r;return e(a)>n?t:[...t.slice(0,s-2),i.slice(0,o),a]}function Nt(n,t,e,s="wrap",r=0){const i=[],o=s==="nowrap"?1/0:t;let a=s==="balance"||s==="pretty";for(const l of n.split(`
|
|
10
|
-
`)){let h=ce(l,o,e);a&&(r>0&&i.length+h.length>r?a=!1:s==="balance"?h=ns(l,o,h,e):h=rs(o,h,e));for(const u of h)i.push(u)}let c=0;for(const l of i)c=Math.max(c,e(l));return{lines:i,maxWidth:c}}function bn(n,t,e,s,r){const i=t.textWrap??"wrap",o=Nt(n,e,s,i,t.lineClamp??0),a=i==="nowrap"&&!r?1/0:e,c=ss(o.lines,t,a,s);return i!=="nowrap"||!r||t.textOverflow==="clip"||!isFinite(e)?c:c.map(l=>s(l)>e?vn(l,e,s):l)}const jt="…";function ss(n,t,e,s){const r=t.lineClamp??0;if(r<=0||n.length<=r)return n;const i=n.slice(0,r);return t.textOverflow==="clip"||(i[r-1]=vn(i[r-1],e,s)),i}function vn(n,t,e){if(!isFinite(t))return n+jt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+jt)>t;)r--;return s.slice(0,r).join("").trimEnd()+jt}function is(n,t,e){const s=ae(n),r=wn(s),i=isNaN(e)?1/0:e,o=l=>t.measureText(l,r),a=bn(n.text??"",n.style,i,o,!1);let c=0;for(const l of a)c=Math.max(c,o(l));return{width:Math.ceil(c),height:Math.ceil(a.length*s.lineHeight)}}function os(n,t,e){const s=n.style,r={family:s.fontFamily??"Roboto",size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.lineHeight,o=n.value??"";if(n.type==="input")return{width:Math.ceil(t.measureText(o,r)),height:Math.ceil(i)};const a=isNaN(e)?1/0:e,c=Nt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(c.maxWidth),height:Math.ceil(Math.max(1,c.lines.length)*i)}}function as(n,t,e,s){const r=n.imageSrcRaw;let i=0,o=0;if(n.sourceRect)i=n.sourceRect[2],o=n.sourceRect[3];else if(hn(r)){const l=se(r.svg);if(l)i=l.width,o=l.height;else{const h=t.getImage(t.resolveSrc(r)??"");i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}}else{const l=t.resolveSrc(r),h=l?t.getImage(l):void 0;i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),c=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*c,height:o*c}}const xn=(n,t,e,s)=>t?[n[0],n[1],n[2],n[3],n[4]+e*t[0]+s*t[2],n[5]+e*t[1]+s*t[3]]:n;function cs(n,t,e,s,r,i,o={}){t.beginFrame(s,r);for(const a of n)En(a.tree,t,e,o);t.endFrame()}function En(n,t,e,s){var h;const{style:r,rect:i}=n;t.save();const o=r.opacity!==void 0&&r.opacity<1?r.opacity:void 0,a=o!==void 0&&n.children.length>0;if(a?t.beginGroup(o):o!==void 0&&t.setAlpha(o),r.transform){const[u,d,f,g,m,x]=xn(r.transform,r.transformBox,i.width,i.height),y=r.transformOrigin,p=i.x+(y?y.xPercent?i.width*y.x/100:y.x:i.width/2),w=i.y+(y?y.yPercent?i.height*y.y/100:y.y:i.height/2);t.translate(p,w),t.transform(u,d,f,g,m,x),t.translate(-p,-w)}const c=oe(r.borderRadius,i);if(ie(r.backgroundColor)||t.fillRoundRect(i,c,r.backgroundColor),r.backgroundImage){const u=e.getImage(r.backgroundImage);u&&u.naturalWidth>0&&u.naturalHeight>0&&(t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(u,null,i,{fit:ls(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let u=r.backgroundGradients.length-1;u>=0;u--){const d=r.backgroundGradients[u];d.stops.length>0&&t.fillGradient(i,c,d)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const u=n.sourceRect;t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(n.image,u?{x:u[0],y:u[1],width:u[2],height:u[3]}:null,i,{fit:u?"fill":r.objectFit??"contain",tint:Vt(n.image.src)?r.tintColor:void 0,radius:c}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&us(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&ys(n,t,e,c),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,c):n.type==="video"?ds(n,t,e,c):((h=n.view)==null?void 0:h.label)!==void 0&&ms(n,n.view.name,n.view.label,t,e,c)),n.clip&&t.clipRoundRect(i,c);for(const u of n.children)u.overlay!==void 0&&!ie(u.overlay)&&t.fillRoundRect(i,void 0,u.overlay),En(u,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,c,Math.round(Math.min(1,r.dim)*255)>>>0);const l=hs(r.border);l&&t.strokeBorder(i,c,l),a&&t.endGroup(),t.restore()}function ls(n){return n==="contain"||n==="fill"?n:"cover"}function hs(n){if(!n)return null;const t={};let e=!1;for(const s of["top","right","bottom","left"]){const r=n[s];r&&r.width>0&&(r.color>>>0)%256!==0&&(t[s]=r,e=!0)}return e?t:null}const pe=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function us(n,t,e){var x,y,p;const s=n.style,r={family:pe(e,s.fontFamily),size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.color??255,o=s.lineHeight,a=s.textAlign??"start",c=e.fontMetrics(r),{rect:l,lines:h}=n,u=((x=n.padding)==null?void 0:x[0])??0,d=((y=n.padding)==null?void 0:y[1])??0,f=((p=n.padding)==null?void 0:p[2])??0,g=l.x+u,m=l.width-u-f;for(let w=0;w<h.length;w++){const E=h[w],L=l.y+d+w*o+(o-(c.ascent+c.descent))/2+c.ascent,C=e.measureText(E,r),F=a==="center"?g+(m-C)/2:a==="end"?g+m-C:g;if(t.fillText(E,F,L,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const U=Math.max(1,r.size/14),$=s.textDecoration==="underline"?L+U:L-r.size*.3;t.fillRoundRect({x:F,y:$,width:C,height:U},void 0,i)}}}function ds(n,t,e,s){const{rect:r}=n;ie(n.style.backgroundColor)&&t.fillRoundRect(r,s,286463999);const i=Math.min(r.width,r.height)*.3;if(i>=6){const o={family:"Roboto",size:i,weight:400,italic:!1,letterSpacing:0},a=e.fontMetrics(o),c=e.measureText("▶",o),l=r.x+(r.width-c)/2,h=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,h,o,4294967244)}}const fs=3722701567,gs=1263887359,ps=2324997119;function ms(n,t,e,s,r,i){const{rect:o}=n;s.fillRoundRect(o,i,fs);const a=pe(r,void 0),c={family:a,size:17,weight:600,italic:!1,letterSpacing:0},l={family:a,size:13,weight:400,italic:!1,letterSpacing:0},h=[];if(e&&h.push([e,c,gs]),t&&t!==e&&h.push([t,l,ps]),h.length===0)return;const u=4,d=h.map(([,g])=>{const m=r.fontMetrics(g);return m.ascent+m.descent});let f=o.y+(o.height-d.reduce((g,m)=>g+m,0)-u*(h.length-1))/2;s.save(),s.clipRoundRect(o,i),h.forEach(([g,m,x],y)=>{const p=o.x+(o.width-r.measureText(g,m))/2;s.fillText(g,p,f+r.fontMetrics(m).ascent,m,x),f+=d[y]+u}),s.restore()}function ys(n,t,e,s){var K,G,q,A,v;const r=n.style,i={family:pe(e,r.fontFamily),size:r.fontSize??14,weight:r.fontWeight??400,italic:r.fontStyle==="italic",letterSpacing:r.letterSpacing??0},o=n.value??"",a=o.length===0,c=r.inputType==="password"&&!a,l=a?r.placeholder??"":c?"•".repeat(o.length):o,h=a?r.placeholderColor??2576980479:r.color??255,{rect:u}=n,d=((K=n.padding)==null?void 0:K[0])??0,f=((G=n.padding)==null?void 0:G[1])??0,g=((q=n.padding)==null?void 0:q[2])??0,m=((A=n.padding)==null?void 0:A[3])??0,x=u.x+d,y=u.width-d-g,p=u.y+f,w=u.height-f-m,E=e.fontMetrics(i),k=r.lineHeight,L=r.textAlign??"start",C=n.type==="textarea",F=C?Nt(l,y,T=>e.measureText(T,i)).lines:[l],U=T=>L==="center"?x+(y-T)/2:L==="end"?x+y-T:x,$=T=>C?p+T*k+(k-(E.ascent+E.descent))/2+E.ascent:p+(w-(E.ascent+E.descent))/2+E.ascent;t.save(),t.clipRoundRect(u,s);for(let T=0;T<F.length;T++){const O=F[T];O.length>0&&t.fillText(O,U(e.measureText(O,i)),$(T),i,h)}if((v=n.state)!=null&&v.focused){const T=a?[""]:C?Nt(c?"•".repeat(o.length):o,y,N=>e.measureText(N,i)).lines:[l],O=T.length-1,j=e.measureText(T[O],i),J=a?U(0):U(j)+j,_=$(O),M=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:_-E.ascent,width:M,height:E.ascent+E.descent},void 0,r.color??255)}t.restore()}const ws=84,bs={display:{word:4},overflow:{word:5},scrollDirection:{word:6},borderTopWidth:{word:8},borderRightWidth:{word:9},borderBottomWidth:{word:10},borderLeftWidth:{word:11},color:{bit:12,word:16},backgroundColor:{word:17},borderTopColor:{word:19},borderRightColor:{word:20},borderBottomColor:{word:21},borderLeftColor:{word:22},placeholderColor:{bit:19,word:23},tintColor:{bit:21,word:25},overlayColor:{bit:23,word:27},backgroundImage:{word:28},backgroundSize:{word:29},backgroundGradient:{word:30},borderTopLeftRadius:{word:32},borderTopRightRadius:{word:33},borderBottomRightRadius:{word:34},borderBottomLeftRadius:{word:35},opacity:{word:36},transform:{word:37},transformOrigin:{word:50},fontSize:{word:55},fontWeight:{word:56},fontStyle:{word:57},fontFamily:{bit:39,word:58},lineHeight:{word:59},letterSpacing:{word:60},textAlign:{word:61},textDecoration:{word:62},lineClamp:{word:63},textOverflow:{word:64},textWrap:{word:65},objectFit:{word:66},placeholder:{word:67},type:{word:68},dim:{word:82}},vs={hidden:1},xs={horizontal:1},Es={italic:1},ht={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],textWrap:["wrap","nowrap","balance","pretty"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},Ss=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,_s=["farthest-corner","closest-side","closest-corner","farthest-side"],ks=52;function Ts(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Rs(n,t,e+i*ks));return r}function Rs(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],c=[];for(let l=0;l<o;l++){const h=a+l*8>>2;c.push({color:t[h]>>>0,position:n[h+1]})}if(i===1){const l=t[s+6],h={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:c};return l===4?{...h,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...h,extent:_s[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:c}}const R=bs,As=["start","center","end","start","end"];let Lt=0;function Sn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],c=F=>Ss(o,a,F),l=F=>{const U=s[i+F];return U===0?void 0:n.UTF8ToString(n._cuiStringOf(U))};e.backgroundColor=s[i+R.backgroundColor.word]>>>0,e.opacity=r[i+R.opacity.word],e.dim=r[i+R.dim.word],e.display=ht.display[s[i+R.display.word]],e.overflow=s[i+R.overflow.word]===vs.hidden?"hidden":"visible",e.scrollAxis=s[i+R.scrollDirection.word]===xs.horizontal?"x":"y",e.border={top:{width:r[i+R.borderTopWidth.word],color:s[i+R.borderTopColor.word]>>>0},right:{width:r[i+R.borderRightWidth.word],color:s[i+R.borderRightColor.word]>>>0},bottom:{width:r[i+R.borderBottomWidth.word],color:s[i+R.borderBottomColor.word]>>>0},left:{width:r[i+R.borderLeftWidth.word],color:s[i+R.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+R.borderTopLeftRadius.word],tr:r[i+R.borderTopRightRadius.word],br:r[i+R.borderBottomRightRadius.word],bl:r[i+R.borderBottomLeftRadius.word]},e.backgroundImage=l(R.backgroundImage.word),e.backgroundSize=ht.backgroundSize[s[i+R.backgroundSize.word]];const h=s[i+R.backgroundGradient.word];if(h===0)e.backgroundGradients=void 0;else{Lt===0&&(Lt=n._malloc(4));const F=n._cuiGradientOf(h,Lt),U=n.HEAPU32[Lt>>>2];e.backgroundGradients=F!==0&&U>0?Ts(n.HEAPF32,n.HEAPU32,F,U):void 0}const u=i+R.transform.word,d=r[u],f=r[u+1],g=r[u+3],m=r[u+4],x=r[u+6],y=r[u+7],p=r[u+9],w=r[u+10],E=r[u+11],k=r[u+12],L=p===0&&w===0&&E===0&&k===0;e.transform=d===1&&f===0&&g===0&&m===1&&x===0&&y===0&&L?void 0:[d,f,g,m,x,y],e.transformBox=L?void 0:[p,w,E,k];const C=i+R.transformOrigin.word;e.transformOrigin={x:r[C],y:r[C+1],xPercent:s[C+2]!==0,yPercent:s[C+3]!==0},e.color=c(R.color.bit)?s[i+R.color.word]>>>0:void 0,e.fontFamily=c(R.fontFamily.bit)?l(R.fontFamily.word):void 0,e.fontSize=r[i+R.fontSize.word],e.fontWeight=r[i+R.fontWeight.word],e.fontStyle=s[i+R.fontStyle.word]===Es.italic?"italic":"normal",e.lineHeight=r[i+R.lineHeight.word],e.letterSpacing=r[i+R.letterSpacing.word],e.textAlign=As[s[i+R.textAlign.word]]??"start",e.textDecoration=ht.textDecoration[s[i+R.textDecoration.word]],e.lineClamp=r[i+R.lineClamp.word],e.textOverflow=ht.textOverflow[s[i+R.textOverflow.word]],e.textWrap=ht.textWrap[s[i+R.textWrap.word]],e.objectFit=ht.objectFit[s[i+R.objectFit.word]],e.tintColor=c(R.tintColor.bit)?s[i+R.tintColor.word]>>>0:void 0,e.placeholder=l(R.placeholder.word),e.placeholderColor=c(R.placeholderColor.bit)?s[i+R.placeholderColor.word]>>>0:void 0,e.inputType=ht.type[s[i+R.type.word]],e.overlayColor=c(R.overlayColor.bit)?s[i+R.overlayColor.word]>>>0:void 0}function Ms(n,t){const e=n._cuiPaintOf(t);if(e===0)return!1;const s=e>>>2;return n.HEAPU32[s+2]!==0||n.HEAPU32[s+3]!==0}function Ls(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(Sn(n,s,e),!0)}function Ps(n,t){const e=n._paintCollect();if(e===0)return 0;const s=n._paintNodes()>>>2,r=n._paintRecords();for(let i=0;i<e;i++){const o=n.HEAPU32[s+i],a=r+i*ws*4;t(o,c=>Sn(n,a,c))}return e}function _n(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?le(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>le(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function Os(n,t=[],e){return JSON.stringify(_n(n,t,e),null,2)}function yt(n,t){const e=10**t;return Math.round(n*e)/e}function le(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),n.view&&(r.view=n.view.name),r.rect=[yt(s.x,t),yt(s.y,t),yt(s.width,t),yt(s.height,t)],e&&(r.id=n.id);const i=Is(n.style);return i&&(r.style=i),n.text!==void 0&&(r.text=n.text),n.lines&&(n.lines.length!==1||n.lines[0]!==n.text)&&(r.lines=n.lines),n.value!==void 0&&n.value!==""&&(r.value=n.value),n.style.placeholder!==void 0&&(r.placeholder=n.style.placeholder),n.image&&(r.image={src:n.image.src,natural:[n.image.naturalWidth,n.image.naturalHeight]}),n.sourceRect&&(r.sourceRect=n.sourceRect),n.state&&(n.state.pressed||(o=n.state.classes)!=null&&o.length)&&(r.state={...n.state.pressed?{pressed:!0}:{},...(a=n.state.classes)!=null&&a.length?{classes:n.state.classes}:{}}),n.scroll&&(r.scroll={offset:yt(n.scroll.offset,t),content:yt(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(c=>le(c,t,e))),r}function Cs(n){return n.tl===n.tr&&n.tr===n.br&&n.br===n.bl?n.tl:[n.tl,n.tr,n.br,n.bl]}function Is(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=mt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=mt(n.color)),n.fontSize!==void 0&&(t.fontSize=n.fontSize),n.fontFamily!==void 0&&(t.fontFamily=n.fontFamily),n.fontWeight!==void 0&&(t.fontWeight=n.fontWeight),n.fontStyle!==void 0&&n.fontStyle!=="normal"&&(t.fontStyle=n.fontStyle),n.lineHeight!==void 0&&(t.lineHeight=n.lineHeight),n.letterSpacing&&(t.letterSpacing=n.letterSpacing),n.textAlign!==void 0&&n.textAlign!=="start"&&(t.textAlign=n.textAlign),n.textDecoration!==void 0&&n.textDecoration!=="none"&&(t.textDecoration=n.textDecoration),n.lineClamp&&(t.lineClamp=n.lineClamp,n.textOverflow==="clip"&&(t.textOverflow=n.textOverflow)),n.textWrap!==void 0&&n.textWrap!=="wrap"&&(t.textWrap=n.textWrap),n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=mt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=mt(n.overlayColor)),n.backgroundImage!==void 0&&(t.backgroundImage=n.backgroundImage),n.backgroundSize!==void 0&&(t.backgroundSize=n.backgroundSize),n.backgroundGradients!==void 0&&n.backgroundGradients.length>0&&(t.backgroundGradients=n.backgroundGradients.map(e=>{const s=e.stops.map(r=>({color:mt(r.color),position:r.position}));if(e.type==="radial"){const r={type:"radial",shape:e.shape,extent:e.extent,cx:e.cx,cy:e.cy,stops:s};return e.extent==="explicit"&&(r.rx=e.rx,r.ry=e.ry,r.rxUnit=e.rxUnit,r.ryUnit=e.ryUnit),r}return{angle:e.angle,stops:s}})),n.borderRadius&&(n.borderRadius.tl||n.borderRadius.tr||n.borderRadius.br||n.borderRadius.bl)&&(t.borderRadius=Cs(n.borderRadius)),n.border){const e={};for(const s of["top","right","bottom","left"]){const r=n.border[s];r&&r.width>0&&(e[s]={width:r.width,color:mt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const Fs=.32,Ns=4,Us={},Ie=new Map;function he(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Ie.get(n);return t===void 0&&(t=un(n.slice(4)),Ie.set(n,t)),t}return n}class Bs{constructor(t,e){b(this,"parent",null);b(this,"children",[]);b(this,"style",{lineHeight:14*1.2});b(this,"name");b(this,"text","");b(this,"src");b(this,"value","");b(this,"sourceRect");b(this,"viewName");b(this,"viewParams");b(this,"playerId",0);b(this,"viewId",0);b(this,"flags",0);b(this,"layoutRect",null);b(this,"scrollOffset",0);b(this,"wrapCache");b(this,"jsNode");b(this,"bgRaw");b(this,"bgSrc");this.id=t,this.type=e,this.jsNode={type:e,_id:t}}get measured(){return this.type==="text"||this.type==="image"||this.editable}get editable(){return this.type==="input"||this.type==="textarea"}get scrollable(){return this.type==="scrollable"||this.type==="scrollableScreen"||this.type==="vlist"}get scrollAxis(){return this.style.scrollAxis==="x"?"x":"y"}get interactive(){return(this.flags&Vr)!==0}get imageSrcRaw(){return this.type==="image"?he(this.src):void 0}has(t){return(this.flags&t)!==0}}class Ds{constructor(t,e,s={}){b(this,"nodes",new Map);b(this,"root",null);b(this,"leaving",null);b(this,"leavingAbove",!1);b(this,"pagerShown",new Map);b(this,"pagerLeaving",new Map);b(this,"destKind",-1);b(this,"layerRoots",[]);b(this,"width",0);b(this,"height",0);b(this,"focused",null);b(this,"safeBottom",0);b(this,"shrunkRoot",0);b(this,"shrunkInset",0);b(this,"pressed",new Set);b(this,"gestures",new Map);b(this,"vlists",new Set);b(this,"frameCache",null);b(this,"painted",null);b(this,"fontsPending",0);b(this,"lastToast",null);b(this,"dirty",!0);b(this,"onDestination",null);b(this,"onDropped",null);b(this,"placeholders");b(this,"viewNames",new Map);b(this,"nativeDest",null);b(this,"layoutPtr",0);b(this,"padPtr",0);b(this,"lastCreated",0);b(this,"hoverX",0);b(this,"hoverY",0);b(this,"hoverInside",!1);b(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s,this.placeholders=new Map(Object.entries(s.nativeViews??{}))}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,c)=>{const l=this.measure(r,i,a);return t.setFloat32(4,l.width,!0),t.setFloat32(0,l.height,!0),t.getBigUint64(0,!0)};this.M._setMeasureFunc(this.M.addFunction(e,"jiififi"))}measure(t,e,s){const r=this.nodes.get(t);if(!r)return{width:0,height:0};const i=this.M;Ms(i,t)&&(Ls(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?is(o,this.host,e):r.type==="image"?as(o,this.host,e,s):r.editable?os(o,this.host,e):{width:0,height:0}}resize(t,e){this.width=t,this.height=e,this.M._creatorWebResize(t,e),this.M._setConditionValue(t,e),this.dirty=!0}setSafeArea(t,e=[]){const[s,r,i,o]=t??(this.width>this.height?[0,8,0,20]:[20,0,8,0]),a={top:1,right:2,bottom:4,left:8};this.M._setSafeAreaBars(e.reduce((c,l)=>c|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.safeBottom=i,this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&(this.shrunkInset=Math.max(0,i-this.keyboardHeight()),this.M._overrideRootSafeBottom(this.shrunkRoot,this.shrunkInset)),this.dirty=!0}layoutFrame(){const t=this.M;Ps(t,(r,i)=>{const o=this.nodes.get(r);o&&(i(o.style),this.resolveBackground(o))})>0&&(this.dirty=!0);const s=t._creatorWebLayoutFrame(this.width,this.height);s>0&&this.readLayoutBatch(s);for(const r of this.vlists)if(t._vlistExists(r.id)){t._vlistUpdateLayout(r.id);for(const i of r.children)this.deliverSubtree(i)}}needsPaint(){return this.dirty||this.frameCache===null||this.frameCache!==this.painted}deliverSubtree(t){const e=this.M;if(this.layoutPtr||(this.layoutPtr=e._malloc(16)),e._getLayoutPointer(t.id,this.layoutPtr)){const s=this.layoutPtr>>2,r={x:e.HEAPF32[s],y:e.HEAPF32[s+1],width:e.HEAPF32[s+2],height:e.HEAPF32[s+3]},i=t.layoutRect,o=!i||i.x!==r.x||i.y!==r.y||i.width!==r.width||i.height!==r.height;t.layoutRect=r,o&&(this.dirty=!0),o&&t.has(Le)&&e._creatorWebNodeLayout(t.id,r.x,r.y,r.width,r.height)}for(const s of t.children)this.deliverSubtree(s)}readLayoutBatch(t){const e=this.M,s=e._collectNodes()>>>2,r=e._collectRects()>>>2,i=e.HEAPU32,o=e.HEAPF32;for(let a=0;a<t;a++){const c=i[s+a],l=this.nodes.get(c);if(!l)continue;const h=o[r+a*4],u=o[r+a*4+1],d=o[r+a*4+2],f=o[r+a*4+3],g={x:h,y:u,width:d-h,height:f-u},m=l.layoutRect,x=!m||m.x!==g.x||m.y!==g.y||m.width!==g.width||m.height!==g.height;l.layoutRect=g,x&&(this.dirty=!0),x&&l.has(Le)&&e._creatorWebNodeLayout(c,h,u,g.width,g.height)}}frame(){if(this.frameCache&&!this.dirty)return this.frameCache;const t=[],e={x:0,y:0,width:this.width,height:this.height},s=this.nativeDest;if(s){const i={id:0,type:"native",rect:e,style:Us,children:[],view:{name:s.view,label:this.placeholders.get(s.view)}};s.name&&(i.name=s.name),t.push(this.destKind===ut?{tree:i}:{tree:i,leaving:!0})}const r=this.leaving?this.build(this.leaving,e):null;if(r&&!this.leavingAbove&&t.push({tree:r,leaving:!0}),this.root){const i=this.build(this.root,e);i&&t.push({tree:i})}r&&this.leavingAbove&&t.push({tree:r,leaving:!0});for(const i of this.layerRoots){const o=this.build(i,e);o&&t.push({tree:o,widget:!0})}return this.frameCache=t,this.dirty=!1,t}renderTree(){var t;return((t=this.frame().find(e=>!e.widget&&!e.leaving))==null?void 0:t.tree)??null}widgetTrees(){return this.frame().filter(t=>t.widget).map(t=>t.tree)}widgets(){return this.widgetTrees()}serialize(){return _n(this.renderTree(),this.widgetTrees())}toText(){return Os(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();cs(s,t,this.host,this.width,this.height,void 0,e),this.painted=s}build(t,e){const s=this.M,r=(i,o,a,c)=>{var y;if(i.style.display==="none")return null;let l,h,u,d;if(c)l=e.x,h=e.y,u=e.width,d=e.height;else{const p=i.layoutRect;if(!p)return null;l=o+p.x,h=a+p.y,u=p.width,d=p.height}const f={id:i.id,type:i.type,rect:{x:l,y:h,width:u,height:d},style:i.style,children:[]};i.name&&(f.name=i.name);const g=i;if(i.type==="text"){const p=ae(g),w=wn(p);f.text=i.text;const E=this.padding(i.id);(E[0]||E[1]||E[2]||E[3])&&(f.padding=E);const k=u-E[0]-E[2],L=`${k}|${w.size}|${w.weight}|${w.italic?1:0}|${w.letterSpacing}|${w.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.style.textWrap??""}|${i.text}`;if(((y=i.wrapCache)==null?void 0:y.key)===L)f.lines=i.wrapCache.lines;else{const C=U=>this.host.measureText(U,w),F=bn(i.text,i.style,k,C,!0);i.wrapCache={key:L,lines:F},f.lines=F}f.style={...i.style,color:p.color,fontSize:p.fontSize,fontFamily:p.fontFamily,fontWeight:p.fontWeight,fontStyle:p.fontStyle,lineHeight:p.lineHeight,letterSpacing:p.letterSpacing,textAlign:p.textAlign,textDecoration:p.textDecoration}}else if(i.type==="image"){const p=this.host.resolveSrc(i.imageSrcRaw),w=p?this.host.getImage(p):void 0;f.image=w??(p?{src:p,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const p=this.padding(i.id);(p[0]||p[1]||p[2]||p[3])&&(f.padding=p);const w=ae(g);f.style={...i.style,color:w.color,fontSize:w.fontSize,fontFamily:w.fontFamily,fontWeight:w.fontWeight,fontStyle:w.fontStyle,lineHeight:w.lineHeight,letterSpacing:w.letterSpacing,textAlign:w.textAlign,textDecoration:w.textDecoration}}else if(i.type==="native"){const p=i.viewName??"";f.view={name:p,label:this.placeholders.get(p)}}i.type==="widget"&&i.style.overlayColor!==void 0&&(f.overlay=i.style.overlayColor),i.interactive&&(f.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(f.state={...f.state,focused:!0}),i.style.overflow==="hidden"&&(f.clip=!0);let m=l,x=h;if(i.scrollable){const p=i.scrollAxis,w=p==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:w,axis:p},p==="x"?m=l-i.scrollOffset:x=h-i.scrollOffset}if(i.type==="pager"){const p=s._creatorWebPagerSelectedIndex(i.id),w=s._creatorWebPagerStackLen(i.id,p),E=w>0?s._creatorWebPagerPageNode(i.id,p,w-1):0,k=E?this.nodes.get(E):void 0;k?this.pagerShown.set(i.id,k):this.pagerShown.delete(i.id);const L=this.pagerLeaving.get(i.id);for(const C of L&&L.page!==k?L.above?[k,L.page]:[L.page,k]:[k]){const F=C?r(C,l,h,!1):null;F&&f.children.push(F)}return f}if(i.type==="vlist"){for(const p of i.children){const w=s._getParentNode(p.id);if(!w)continue;const E=s._vlistItemOffsetOf(i.id,w);if(Number.isNaN(E))continue;const k=r(p,l,h+E-i.scrollOffset,!1);k&&f.children.push(k)}return f}for(const p of i.children){const w=r(p,m,x,!1);w&&f.children.push(w)}return f};return r(t,0,0,!0)}paddingOf(t){return this.padding(t)}padding(t){const e=this.M;this.padPtr||(this.padPtr=e._malloc(16)),e._getPaddingPointer(t,this.padPtr);const s=this.padPtr>>2;return[e.HEAPF32[s],e.HEAPF32[s+1],e.HEAPF32[s+2],e.HEAPF32[s+3]]}withStr(t,e){const s=this.M.stringToNewUTF8(t);try{return e(s)}finally{this.M._free(s)}}get(t){return this.nodes.get(t)}findAll(t){const e=[],s=r=>{r.name===t&&e.push(r);for(const i of r.children)s(i)};for(const r of this.frame())s(r.tree);return e}findRect(t){const e=s=>{if(s.id===t)return s.rect;for(const r of s.children){const i=e(r);if(i)return i}return null};for(const s of this.frame()){const r=e(s.tree);if(r)return r}return null}toast(){return this.lastToast}pendingFonts(){return this.fontsPending}keyboardHeight(){return this.focused?this.options.keyboardHeight?this.options.keyboardHeight():Math.round(this.height*Fs):0}focusedId(){var t;return((t=this.focused)==null?void 0:t.id)??0}nodeFactory(t,e,s,r){this.lastCreated=t;const i=new Bs(t,e);this.nodes.set(t,i),e==="vlist"&&this.vlists.add(i);const o=this.nodes.get(s);o&&this.link(o,i,Math.max(0,r)),this.dirty=!0}link(t,e,s){e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),e.parent=t,t.children.splice(Math.min(s,t.children.length),0,e)}insertNode(t,e,s){const r=this.nodes.get(t),i=this.nodes.get(e);r&&i&&this.link(r,i,s),this.dirty=!0}removeNode(t,e){var i;const s=this.nodes.get(t),r=this.nodes.get(e);!s||!r||(this.forget(r),s.children=s.children.filter(o=>o!==r),r.parent===s&&(r.parent=null),((i=this.pagerLeaving.get(t))==null?void 0:i.page)===r&&this.pagerLeaving.delete(t),this.pagerShown.get(t)===r&&this.pagerShown.delete(t),this.dirty=!0)}releaseNode(t){const e=this.nodes.get(t);if(!e)return;this.nodes.delete(t),this.forget(e),e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),this.root===e&&(this.root=null),this.leaving===e&&(this.leaving=null),this.pagerShown.delete(t),this.pagerLeaving.delete(t);for(const[r,i]of this.pagerLeaving)i.page===e&&this.pagerLeaving.delete(r);this.focused===e&&(this.focused=null,this.shrinkTo(0,0),this.emitKeyboard());const s=this.layerRoots.indexOf(e);s>=0&&this.layerRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),e.type==="native"&&e.viewId&&this.viewNames.delete(e.viewId),this.dirty=!0}forget(t){for(const e of this.gestures.values())e.node===t&&(e.node=null),e.scroll===t&&(e.scroll=null),e.backdrop===t&&(e.backdrop=null),e.edit===t&&(e.edit=null);for(const e of t.children)this.forget(e)}setPropertyString(t,e,s){const r=this.nodes.get(t);if(!r)return;const i=s??"";switch(e){case"text":r.text=i,r.wrapCache=void 0;break;case"value":r.value=i;break;case"name":r.name=i||void 0;break;case"src":{r.src=i||void 0;const o=this.host.resolveSrc(this.srcOf(r));o&&!this.host.getImage(o)&&this.host.loadImage(o).then(()=>{this.nodes.get(t)===r&&this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0}).catch(()=>{});break}case"sourceRect":{const o=i.split(" ").map(Number);r.sourceRect=o.length===4?[o[0],o[1],o[2],o[3]]:void 0;break}case"focus":i==="1"||i==="true"?this.focusInput(t):this.focused===r&&this.blurInput();break;case"viewName":r.viewName=i;break;case"viewParams":r.viewParams=i;break}this.dirty=!0}srcOf(t){return he(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(he(e)):void 0;const s=t.bgSrc;s&&!this.host.getImage(s)&&this.host.loadImage(s).then(()=>{this.dirty=!0}).catch(()=>{})}t.style.backgroundImage=t.bgSrc}setPropertyInt(t,e,s){const r=this.nodes.get(t);r&&(e==="playerId"?r.playerId=s:e==="viewId"&&(r.viewId=s,r.viewName!==void 0&&this.viewNames.set(s,r.viewName))),this.dirty=!0}setFlags(t,e){const s=this.nodes.get(t);s&&(s.flags=e>>>0)}leave(t){this.root&&(this.leaving=this.root,this.leavingAbove=t,this.root=null)}openView(t,e,s,r,i,o){var c;this.destKind=t;const a=t===Pe?this.nodes.get(e)??null:null;if(a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,t===ut){this.viewNames.set(s,r);let l;for(const h of this.nodes.values())if(h.type==="native"&&h.viewId===s){l=h.name;break}this.nativeDest=this.placeholders.has(r)?{id:s,view:r,name:l}:null}this.focused&&this.blurInput(),this.dirty=!0,(c=this.onDestination)==null||c.call(this,t,s)}dropView(t,e,s){var r,i;if(t===Pe){const o=this.nodes.get(e)??null;o!==null&&this.leaving===o&&(this.leaving=null),o!==null&&this.root===o&&(this.root=null)}t===ut&&((r=this.nativeDest)==null?void 0:r.id)===s&&this.destKind!==ut&&(this.nativeDest=null),this.dirty=!0,(i=this.onDropped)==null||i.call(this,t,s)}closeView(){var t;this.destKind=-1,this.leave(!0),this.dirty=!0,(t=this.onDestination)==null||t.call(this,-1,0)}isViewSupported(t){return this.placeholders.has(t)}viewVersion(t){return this.placeholders.has(t)?1:0}viewCall(t,e,s,r,i){const o=this.viewNames.get(t);i(o!==void 0&&this.placeholders.has(o)?`headless draws native views only: ${o}.${e}`:"NativeView calls are not supported on this host")}layerOpen(t){const e=this.nodes.get(t);e&&!this.layerRoots.includes(e)&&this.layerRoots.push(e),this.dirty=!0}layerClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.layerRoots.indexOf(e):-1;s>=0&&this.layerRoots.splice(s,1),this.dirty=!0}registerFont(t,e,s,r,i,o){this.fontsPending++,this.host.loadFont(e,t,{weight:s,style:r===2?"italic":"normal"}).then(()=>{this.invalidateText(),i()},a=>o(String(a))).finally(()=>{this.fontsPending--})}invalidateText(){for(const t of this.nodes.values())t.wrapCache=void 0,t.measured&&t.type!=="image"&&this.M._nodeHasMeasure(t.id)&&this.M._markNodeDirty(t.id);this.dirty=!0}showToast(t,e){var s,r;this.lastToast=t,(r=(s=this.options).onToast)==null||r.call(s,t,e)}getButtonPressed(t){return this.pressed.has(t)}getTextValue(t){var e;return((e=this.nodes.get(t))==null?void 0:e.value)??""}getBoundingRect(t){const e=this.findRect(t);return e?[e.x,e.y,e.width,e.height]:null}longPressHandler(t,e){const s=this.gestures.get(t);s&&(s.swallowClick=!0)}vlistScroll(t,e,s){const r=this.nodes.get(t);r&&(r.scrollOffset=e),this.dirty=!0}pagerCommand(t,e,s){this.pagerLeaving.delete(t),this.dirty=!0}pagerShowPage(t,e,s){const r=this.nodes.get(e),i=this.pagerShown.get(t);r&&this.pagerShown.set(t,r),i&&i!==r&&this.pagerLeaving.set(t,{page:i,above:!s}),this.dirty=!0}pagerDropPage(t,e){var s;((s=this.pagerLeaving.get(t))==null?void 0:s.page.id)===e&&this.pagerLeaving.delete(t),this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent&&e.type!=="widget";)e=e.parent;return e}emitKeyboard(){var s,r;const t=this.keyboardHeight(),e=this.keyboardDuration();(r=(s=this.options).onKeyboard)==null||r.call(s,t,e),this.M._creatorWebKeyboardEvent(t,e)}shrinkTo(t,e){this.M._creatorWebSetShrunkRoot(t,e);const s=e>0?t:0;s!==this.shrunkRoot&&(this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&this.M._overrideRootSafeBottom(this.shrunkRoot,this.safeBottom),this.shrunkRoot=s,this.shrunkInset=this.safeBottom);const r=Math.max(0,this.safeBottom-e);s&&r!==this.shrunkInset&&this.nodes.has(s)&&(this.M._overrideRootSafeBottom(s,r),this.shrunkInset=r)}keyboardDuration(){return 0}refreshKeyboard(){this.focused&&(this.shrinkTo(this.rootOf(this.focused).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}focusInput(t){const e=this.nodes.get(t);!e||!e.editable||this.focused===e||(this.focused&&this.blurInput(),this.focused=e,this.M._setNodeFocused(t,1),e.has(qr)&&this.M._creatorWebNodeEvent(t,Dr),this.shrinkTo(this.rootOf(e).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}blurInput(){const t=this.focused;t&&(this.focused=null,this.M._setNodeFocused(t.id,0),t.has(Jr)&&this.M._creatorWebNodeEvent(t.id,Wr),this.shrinkTo(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Yr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Br,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Qr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Hr,e)),this.focused===t&&this.blurInput(),!0):!1}scrollMax(t){const e=this.findRect(t.id)??t.layoutRect??{width:0,height:0},s=t.scrollAxis==="x"?e.width:e.height,r=t.scrollAxis==="x"?this.M._getContentWidth(t.id):this.M._getContentHeight(t.id);return Math.max(0,r-s)}scrollBy(t,e){const s=this.nodes.get(t);if(!s||!s.scrollable)return!1;const r=this.scrollMax(s),i=s.scrollOffset+e,o=Math.min(r,Math.max(0,i)),a=i<0?i:i>r?i-r:0;return a!==0&&s.has(Kr)&&this.M._creatorWebNodeEventNum(t,Nr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(zr)&&this.M._creatorWebNodeScroll(t,o),this.dirty=!0,!0)}topInteractive(t,e){const s=this.frame();for(let r=s.length-1;r>=0;r--){const i=bt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i.node)return this.nodes.get(i.node.id)??null;if(i.blocker)return null}return null}setPressed(t,e){e?this.pressed.add(t.id):this.pressed.delete(t.id),this.nodes.get(t.id)===t&&this.M._setNodePressed(t.id,e?1:0),this.dirty=!0}pointerHover(t,e){this.hoverX=t,this.hoverY=e,this.hoverInside=!0,this.hoverMoved=!0}pointerLeave(){this.hoverInside&&(this.hoverInside=!1,this.hoverMoved=!0)}get hasHover(){return typeof this.M._creatorWebHover=="function"}tickHover(){if(!this.hasHover||!this.hoverMoved&&!this.dirty)return;this.hoverMoved=!1;const t=this.hoverInside?this.topInteractive(this.hoverX,this.hoverY):null;this.M._creatorWebHover((t==null?void 0:t.id)??0,this.hoverX,this.hoverY)}pointerDown(t,e,s){const r=this.M;r._creatorWeb2dSceneOpen()&&r._creatorWeb2dEmitPointer(0,t,e,s);const i={node:null,scroll:null,backdrop:null,edit:null,global:!1,dismiss:!0,lastX:e,lastY:s,acc:0,scrolling:!1,swallowClick:!1};this.gestures.set(t,i);const o=this.frame();for(let a=o.length-1;a>=0;a--){const c=bt(o[a].tree,e,s,l=>{var h;return((h=this.nodes.get(l.id))==null?void 0:h.editable)??!1});if(c.node){const l=this.nodes.get(c.node.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(c.blocker)break}for(let a=o.length-1;a>=0;a--){const c=o[a],l=bt(c.tree,e,s,d=>{var f;return((f=this.nodes.get(d.id))==null?void 0:f.interactive)??!1}),h=bt(c.tree,e,s,d=>!!d.scroll&&d.scroll.content>(d.scroll.axis==="x"?d.rect.width:d.rect.height)+.5),u=h.node?this.nodes.get(h.node.id)??null:null;if(l.node){const d=this.nodes.get(l.node.id);i.node=d,i.scroll=u,i.dismiss=d.type!=="button",this.setPressed(d,!0),r._creatorWebNodeTouchStart(d.id,t,e,s);return}if(u){i.scroll=u;return}if(l.blocker){i.backdrop=l.outside?this.nodes.get(l.blocker.id)??null:null;return}}i.global=!0,r._creatorWebSceneTouchStart(t,e,s)}pointerMove(t,e,s){const r=this.gestures.get(t);if(!r)return;const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(1,t,e,s);const o=e-r.lastX,a=s-r.lastY;if(r.lastX=e,r.lastY=s,r.acc+=Math.abs(o)+Math.abs(a),!r.edit){if(!r.scrolling&&r.scroll&&r.acc>Ns&&(r.scrolling=!0,r.node&&this.setPressed(r.node,!1)),r.scrolling&&r.scroll){this.scrollBy(r.scroll.id,r.scroll.scrollAxis==="x"?-o:-a);return}i._creatorWebTouchMove(t,e,s,o,a)}}pointerUp(t,e,s){const r=this.gestures.get(t);if(!r)return;this.gestures.delete(t);const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(2,t,e,s);const o=e-r.lastX,a=s-r.lastY;i._creatorWebTouchEnd(t,e,s,o,a),!r.edit&&(r.scrolling&&r.scroll&&r.scroll.has(Xr)&&i._creatorWebNodeEvent(r.scroll.id,Ur),r.dismiss&&!r.scrolling&&this.focused&&this.blurInput(),r.node?(this.setPressed(r.node,!1),!r.scrolling&&!r.swallowClick&&this.topInteractive(e,s)===r.node&&r.node.has(Gr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Zr)&&i._creatorWebNodeEvent(r.backdrop.id,$r):r.global&&(r.scrolling||i._creatorWebSceneTouchClick(t,e,s)))}pointerCancel(t){const e=this.gestures.get(t);if(!e)return;this.gestures.delete(t);const s=this.M;s._creatorWeb2dSceneOpen()&&s._creatorWeb2dEmitPointer(3,t,e.lastX,e.lastY),e.node&&this.setPressed(e.node,!1),s._creatorWebTouchCancel(t)}wheel(t,e,s,r){const i=this.frame();for(let o=i.length-1;o>=0;o--){const a=bt(i[o].tree,t,e,c=>!!c.scroll&&c.scroll.content>(c.scroll.axis==="x"?c.rect.width:c.rect.height)+.5);if(a.node){const c=this.nodes.get(a.node.id);return c?this.scrollBy(c.id,c.scrollAxis==="x"?s:r):!1}if(a.blocker)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(jr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const Ws=`
|
|
4
|
+
`+c.replace(/[\r\n]+$/,""))}const o=s.lengthBytesUTF8(i),a=s._malloc(o+1);return s.stringToUTF8(i,a,o+1),a}toNumber(t){try{return Number(this.table[t])}catch{return NaN}}truthy(t){return!!this.table[t]}newError(t){this.writeOut(new Error(t))}throwNew(t,e){this.pending=t===1?new TypeError(e):new Error(e),this.hasPending=!0}takeException(){const t=this.hasPending?this.pending:void 0;this.pending=void 0,this.hasPending=!1,this.writeOut(t)}throwPending(){const t=this.hasPending?this.pending:new Error("native handler failed");throw this.pending=void 0,this.hasPending=!1,t}call(t,e,s,r,i,o){const a=this.table[e],c=this.decode(s,r),l=this.args(i,o);try{this.writeOut(a.apply(c,l))}catch(h){this.pending=h,this.hasPending=!0,this.writeOutException()}}construct(t,e,s){const r=this.table[t],i=this.args(e,s);try{this.writeOut(Reflect.construct(r,i))}catch(o){this.pending=o,this.hasPending=!0,this.writeOutException()}}typedArray(t,e,s){const i=this.M.HEAPU8.slice(e,e+s).buffer,o=[null,Uint8Array,Uint16Array,Uint32Array,Int32Array,Float32Array,Float64Array,Int16Array,Int8Array,Uint8ClampedArray];if(t===0){this.writeOut(i);return}const a=o[t];this.writeOut(a?new a(i):void 0)}arrayIn(t,e,s,r){const i=this.M,o=this.table[t];let a=null,c=0;if(s===2){if(!(o instanceof ArrayBuffer))return 0;a=new Uint8Array(o),c=a.byteLength}else{if(!ArrayBuffer.isView(o)||o instanceof DataView)return 0;const h=o,u=h.BYTES_PER_ELEMENT;if(s===0&&u!==e)return 0;a=new Uint8Array(h.buffer,h.byteOffset,h.byteLength),c=s===0?h.length:h.byteLength}const l=i._malloc(Math.max(a.byteLength,1));return a.byteLength>0&&i.HEAPU8.set(a,l),i.HEAPU32[r>>2]=c,l}arrayOut(t,e,s){const r=this.table[t];let i;if(r instanceof ArrayBuffer)i=new Uint8Array(r);else if(ArrayBuffer.isView(r))i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);else return;const o=Math.min(s,i.byteLength);o>0&&i.set(this.M.HEAPU8.subarray(e,e+o))}invoke(t,e){const s=e.length,r=this.argSp;let i=r,o=0;r+s*8>this.argBase+Se?(o=this.M._malloc(Math.max(s*8,8)),i=o):this.argSp=r+s*8;const a=[];for(let l=0;l<s;l++){const h=this.write(i+l*8,e[l]);h&&a.push(h)}let c;try{t(s,i),c=this.takeOut()}finally{for(const l of a)this.release(l);this.argSp=r,o&&this.M._free(o)}return c.threw&&this.throwPending(),c.value}defineMethod(t,e,s,r,i,o){const a=this.table[e];if(o){Object.defineProperty(a,s,{configurable:!0,enumerable:!1,get:()=>this.invoke(()=>this.M._jsbInvokeGetter(r),[])});return}const c=this.M,l=(...h)=>this.invoke((u,d)=>c._jsbInvoke(t,r,u,d),h);Object.defineProperty(l,"name",{value:s}),Object.defineProperty(l,"length",{value:i}),Object.defineProperty(a,s,{configurable:!0,enumerable:!1,writable:!0,value:l})}makeFunction(t,e,s,r){const i=this.M,o=(...a)=>this.invoke((c,l)=>i._jsbInvokeData(t,e,c,l),a);s&&Object.defineProperty(o,"name",{value:s}),Object.defineProperty(o,"length",{value:r}),this.fnRegistry.register(o,e),this.writeOut(o)}callback(t,e){return t?(...s)=>{if(e){if(e.done){console.warn("[jsb] a settled host callback was called again");return}e.done=!0}const r=this.M,i=s.length,o=e?e.ptrs.length:0,a=r._malloc(Math.max(i*8+o*4,8)),c=[];for(let h=0;h<i;h++){const u=this.write(a+h*8,s[h]);u&&c.push(u)}const l=a+i*8;for(let h=0;h<o;h++)r.HEAPU32[(l>>2)+h]=e.ptrs[h];r._jsbHostCall(t,i,a,l,o);for(const h of c)this.release(h);r._free(a)}:()=>{}}viewEvent(t,e,s){const r=this.M,i=r.stringToNewUTF8(e);if(s===void 0){r._jsbViewEvent(t,i,0),r._free(i);return}const o=r._malloc(8),a=this.write(o,s);r._jsbViewEvent(t,i,o),a&&this.release(a),r._free(o),r._free(i)}group(...t){return{ptrs:t.filter(e=>e!==0),done:!1}}strings(t,e){const s=this.M,r=new Array(e);for(let i=0;i<e;i++){const o=s.HEAPU32[(t>>2)+i];r[i]=o?s.UTF8ToString(o):""}return r}bytesOut(t,e){const s=this.M;let r=null;if(t instanceof Uint8Array?r=t:t instanceof ArrayBuffer?r=new Uint8Array(t):ArrayBuffer.isView(t)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),!r||r.byteLength===0)return e&&(s.HEAPU32[e>>2]=0),0;const i=s._malloc(r.byteLength+1);return s.HEAPU8.set(r,i),s.HEAPU8[i+r.byteLength]=0,e&&(s.HEAPU32[e>>2]=r.byteLength),i}gc(){const t=globalThis.gc,e=globalThis.Bun;for(let s=0;s<2;s++){if(e!=null&&e.gc)e.gc(!0);else if(typeof t=="function")t();else return;this.sweep()}}sweep(){for(const t of[...this.tracked.keys()])t.ref.deref()===void 0&&(this.tracked.delete(t),this.classRegistry.unregister(t),this.M._jsbFinalize(t.cls,t.opaque))}}const sr=(n,t)=>{const e=new rr(n,t);return n.jsb=e,e},ir=""+new URL("assets/creator-full.js-CZ3EVfR2.symbols",import.meta.url).href,ot=/wasm-function\[(\d+)\]/g;let Vt=null;const an=()=>(Vt||(Vt=fetch(ir).then(n=>{if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.text()}).then(n=>{const t=new Map;for(const e of n.split(`
|
|
5
|
+
`)){const s=e.indexOf(":");s>0&&t.set(Number(e.slice(0,s)),e.slice(s+1))}return t}).catch(n=>(console.warn("[creator-gl] creator-gl.js.symbols unavailable, wasm frames stay anonymous:",n),null))),Vt),cn=n=>n.replace(/\\([0-9a-fA-F]{2})/g,(t,e)=>String.fromCharCode(parseInt(e,16))),or=/([\w.-]+)\.wasm(?=[^\w-]|$)/g,ln=n=>{const t=[...n.matchAll(or)].map(e=>e[1]);return t.length===0?null:t.some(e=>e.includes("creator-gl"))?"ours":"other"},ar=async n=>{if(ot.lastIndex=0,!ot.test(n))return null;const t=await an();if(!t)return null;let e=!1;const s=n.split(`
|
|
6
|
+
`).map(r=>{if(ot.lastIndex=0,!ot.test(r))return r;const i=ln(r);return i==="other"?r:r.replace(ot,(o,a)=>{const c=t.get(Number(a));return c===void 0?o:(e=!0,`${i===null?"?":""}${cn(c)} (${o})`)})});return e?s.join(`
|
|
7
|
+
`):null},cr=async n=>{if(ot.lastIndex=0,!ot.test(n))return[];const t=await an();if(!t)return[];const e=[];for(const s of n.split(`
|
|
8
|
+
`))if(ln(s)!=="other")for(const r of s.matchAll(ot)){const i=t.get(Number(r[1]));i!==void 0&&e.push(cn(i).replaceAll("std::__2::","std::"))}return e},_e=n=>{const t=n==null?void 0:n.stack;typeof t=="string"&&ar(t).then(e=>{e&&console.error(`[creator-gl] decoded wasm stack (via creator-gl.js.symbols):
|
|
9
|
+
`+e)})};let ke=!1;const lr=()=>{ke||(ke=!0,addEventListener("error",n=>_e(n.error)),addEventListener("unhandledrejection",n=>_e(n.reason)))},V=[null];new TextDecoder("utf-8");const hr=async(n,t,e,s)=>{var f;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const g=new FormData;for(let[y,x,w]of t.body._entries)typeof x=="object"?g.append(y,new Blob([et(x._id)]),w):g.append(y,x);r=g}else typeof t.body=="string"?r=t.body:s(new Error("Invalid body"));const i=await fetch(n,{method:t.method,body:r,headers:t.headers,mode:"cors",credentials:"omit"}),o=typeof t.onProgress=="function"?t.onProgress:null;if(!o){const g=await i.arrayBuffer();V.push(g),e(V.length-1,i.status);return}const a=(f=i.body)==null?void 0:f.getReader();if(!a){const g=await i.arrayBuffer();V.push(g),e(V.length-1,i.status);return}const c=Number(i.headers.get("content-length"))||void 0;let l=0;const h=[];for(;;){const{done:g,value:y}=await a.read();if(g)break;y&&(h.push(y),l+=y.length,o({loaded:l,total:c}))}const u=new Uint8Array(l);let d=0;for(const g of h)u.set(g,d),d+=g.length;V.push(u.buffer),e(V.length-1,i.status)},hn=n=>{const t=new Blob([V[n]]);return URL.createObjectURL(t)},Ht=n=>new Blob([V[n]]),et=n=>V[n],ur=n=>{V[n]=null},ft=n=>(V.push(n),V.length-1),fe=new Map,dr=(n,t)=>{fe.set(n,t);const e=Ot.get(n);e!==void 0&&(V[e]=t)},fr=n=>fe.has(n),Ot=new Map,gr=n=>{for(const[t,e]of Ot)if(e===n)return t},pr=n=>{const t=Ot.get(n);if(t!==void 0)return t;const e=fe.get(n);if(!e)return-1;V.push(e);const s=V.length-1;return Ot.set(n,s),s},It=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function un(n){return typeof n=="object"&&n!==null&&"svg"in n}function mr(n){return typeof n=="object"&&n!==null&&"_id"in n}function yr(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const re="lecodes-canvas://";function wr(n){return n.startsWith(re)?Number(n.slice(re.length)):void 0}function br(n){return typeof File<"u"&&n instanceof File}function dn(n){let t=n.trim();/\sxmlns\s*=/.test(t)||(t=t.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"'));const e=new TextEncoder().encode(t);let s="";for(const r of e)s+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(s)}`}function $t(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function se(n){var i,o,a;const t=((i=n.match(/<svg\b[^>]*>/i))==null?void 0:i[0])??"",e=t.match(/viewBox\s*=\s*["']\s*[\d.+-]+\s+[\d.+-]+\s+([\d.+-]+)\s+([\d.+-]+)\s*["']/i);if(e){const c=parseFloat(e[1]),l=parseFloat(e[2]);if(c>0&&l>0)return{width:c,height:l}}const s=parseFloat(((o=t.match(/\bwidth\s*=\s*["']?([\d.]+)/i))==null?void 0:o[1])??""),r=parseFloat(((a=t.match(/\bheight\s*=\s*["']?([\d.]+)/i))==null?void 0:a[1])??"");return s>0&&r>0?{width:s,height:r}:null}function vr(n){const t=/^data:image\/svg\+xml(;[^,]*)?,([\s\S]*)$/.exec(n);if(!t)return null;const e=t[2];try{if(/;base64/i.test(t[1]??"")){const s=atob(e),r=new Uint8Array(s.length);for(let i=0;i<s.length;i++)r[i]=s.charCodeAt(i);return new TextDecoder().decode(r)}return decodeURIComponent(e)}catch{return null}}async function xr(n,t){if(!$t(n))return null;const e=vr(n);if(e)return se(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?se(s):null}function Er(n={}){const t=new WeakMap;return e=>{var o,a;if(e==null)return;if(typeof e=="string")return e;if(typeof e!="object")return;const s=e,r=t.get(s);if(r!==void 0)return r;let i;return un(s)?i=dn(s.svg):yr(s)?i=re+s.canvasSurface:mr(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):br(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function Te(n,t){if(!t)return;const e=wr(n);if(e===void 0)return;const s=t.getSurface(e);if(s)return{src:n,naturalWidth:s.width,naturalHeight:s.height,handle:s.canvas}}const fn=n=>n==="monospaced"?"monospace":n;function Re(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${fn(n.family)}`}class Sr{constructor(t={}){b(this,"ctx");b(this,"images",new Map);b(this,"pending",new Map);b(this,"resolver");b(this,"canvasSurfaces");b(this,"fontFormat","woff2");const e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(8,8);this.ctx=e.getContext("2d"),this.canvasSurfaces=t.canvasSurfaces,this.resolver=Er({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return fn(t)}measureText(t,e){return this.ctx.font=Re(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=Re(t);const e=this.ctx.measureText("Mg"),s=e.fontBoundingBoxAscent||e.actualBoundingBoxAscent||t.size*.8,r=e.fontBoundingBoxDescent||e.actualBoundingBoxDescent||t.size*.2;return{ascent:s,descent:r}}getImage(t){return Te(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=Te(t,this.canvasSurfaces);if(e)return Promise.resolve(e);const s=this.images.get(t);if(s)return Promise.resolve(s);const r=this.pending.get(t);if(r)return r;const i=(async()=>{const o=await this.decode(t);let a=o.naturalWidth,c=o.naturalHeight;if($t(t)){const h=await xr(t,u=>fetch(u).then(d=>d.ok?d.text():null));h&&(a=h.width,c=h.height)}const l={src:t,naturalWidth:a,naturalHeight:c,handle:o};return this.images.set(t,l),this.pending.delete(t),l})();return this.pending.set(t,i),i.catch(()=>this.pending.delete(t)),i}decode(t){return new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=i=>s(i),r.src=t})}async loadFont(t,e,s){if(typeof globalThis.FontFace>"u")return;const r=new FontFace(t,`url(${e})`,s);document.fonts.add(r),await r.load()}}function _r(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function mt(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function lt(n){const{r:t,g:e,b:s,a:r}=_r(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function ie(n){return n===void 0||(n>>>0&255)===0}function oe(n,t){if(!n)return;const e=Math.min(t.width,t.height)/2;return{tl:Math.min(n.tl,e),tr:Math.min(n.tr,e),br:Math.min(n.br,e),bl:Math.min(n.bl,e)}}function Ae(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function kr(n,t,e,s){const r={x:0,y:0,width:n,height:t};if(s==="fill"||n===0||t===0)return{src:r,dst:e};if(s==="cover"){const c=Math.max(e.width/n,e.height/t),l=e.width/c,h=e.height/c;return{src:{x:(n-l)/2,y:(t-h)/2,width:l,height:h},dst:e}}const i=Math.min(e.width/n,e.height/t),o=n*i,a=t*i;return{src:r,dst:{x:e.x+(e.width-o)/2,y:e.y+(e.height-a)/2,width:o,height:a}}}function Tr(n,t){const e=n*Math.PI/180,s=Math.sin(e),r=-Math.cos(e),i=t.x+t.width/2,o=t.y+t.height/2,a=(Math.abs(t.width*s)+Math.abs(t.height*r))/2;return{x0:i-s*a,y0:o-r*a,x1:i+s*a,y1:o+r*a}}function Rr(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const g=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,y=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:g,ry:y}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,c=Math.min(r,i),l=Math.max(r,i),h=Math.min(o,a),u=Math.max(o,a);let d,f;if(n.shape==="circle"){let g;switch(n.extent){case"closest-side":g=Math.min(c,h);break;case"farthest-side":g=Math.max(l,u);break;case"closest-corner":g=Math.hypot(c,h);break;default:g=Math.hypot(l,u);break}d=f=g}else switch(n.extent){case"closest-side":d=c,f=h;break;case"farthest-side":d=l,f=u;break;case"closest-corner":d=c*Math.SQRT2,f=h*Math.SQRT2;break;default:d=l*Math.SQRT2,f=u*Math.SQRT2;break}return{cx:e,cy:s,rx:d,ry:f}}function Gt(n,t){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,t):Object.assign(document.createElement("canvas"),{width:n,height:t})}const Ar=8;class Me{constructor(t,e=1){b(this,"ctx");b(this,"dpr");b(this,"groups",[]);b(this,"tileCells",new WeakMap);b(this,"tintCells",new WeakMap);this.ctx=t,this.dpr=e}beginGroup(t){const e=this.ctx,s=e.canvas.width,r=e.canvas.height,i=Gt(s,r),o=i.getContext("2d");o.setTransform(e.getTransform()),this.groups.push({parent:e,layer:i,alpha:t}),this.ctx=o}endGroup(){const t=this.groups.pop();t&&(this.ctx=t.parent,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha*=t.alpha,this.ctx.drawImage(t.layer,0,0),this.ctx.restore())}beginFrame(t,e){const{ctx:s,dpr:r}=this;s.setTransform(r,0,0,r,0,0),s.clearRect(0,0,t,e),s.globalAlpha=1}endFrame(){}save(){this.ctx.save()}restore(){this.ctx.restore()}setAlpha(t){this.ctx.globalAlpha*=t}translate(t,e){this.ctx.translate(t,e)}scale(t,e){this.ctx.scale(t,e)}transform(t,e,s,r,i,o){this.ctx.transform(t,e,s,r,i,o)}addRectPath(t,e){const s=this.ctx;e&&(e.tl||e.tr||e.br||e.bl)?s.roundRect(t.x,t.y,t.width,t.height,[e.tl,e.tr,e.br,e.bl]):s.rect(t.x,t.y,t.width,t.height)}path(t,e){this.ctx.beginPath(),this.addRectPath(t,e)}clipRoundRect(t,e){this.path(t,e),this.ctx.clip()}fillRoundRect(t,e,s){this.path(t,e),this.ctx.fillStyle=lt(s),this.ctx.fill()}clearRoundRect(t,e){const s=this.ctx;s.save(),s.globalCompositeOperation="destination-out",s.globalAlpha=1,this.path(t,e),s.fillStyle="#000",s.fill(),s.restore()}fillGradient(t,e,s){if(s.type==="radial"){this.fillRadial(t,e,s);return}const{x0:r,y0:i,x1:o,y1:a}=Tr(s.angle,t),c=this.ctx.createLinearGradient(r,i,o,a);for(const l of s.stops)c.addColorStop(Math.max(0,Math.min(1,l.position)),lt(l.color));this.path(t,e),this.ctx.fillStyle=c,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=Rr(s,t),c=this.ctx,l=o||1e-6,h=a||1e-6;c.save(),this.path(t,e),c.clip(),c.translate(r,i),c.scale(l,h);const u=c.createRadialGradient(0,0,0,0,0,1);for(const x of s.stops)u.addColorStop(Math.max(0,Math.min(1,x.position)),lt(x.color));c.fillStyle=u;const d=(t.x-r)/l,f=(t.x+t.width-r)/l,g=(t.y-i)/h,y=(t.y+t.height-i)/h;c.fillRect(d,g,f-d,y-g),c.restore()}strokeBorder(t,e,s){const r=this.ctx,i=["top","right","bottom","left"].filter(a=>s[a]);if(i.length===4&&i.every(a=>s[a].width===s.top.width&&s[a].color===s.top.color)){const a=s.top.width,c=oe(e,t);r.beginPath(),this.addRectPath(t,c);const l={x:t.x+a,y:t.y+a,width:t.width-2*a,height:t.height-2*a};if(l.width>0&&l.height>0){const h=c&&oe({tl:Math.max(0,c.tl-a),tr:Math.max(0,c.tr-a),br:Math.max(0,c.br-a),bl:Math.max(0,c.bl-a)},l);this.addRectPath(l,h||void 0)}r.fillStyle=lt(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:c,color:l}=s[a];r.fillStyle=lt(l),a==="top"?r.fillRect(t.x,t.y,t.width,c):a==="bottom"?r.fillRect(t.x,t.y+t.height-c,t.width,c):a==="left"?r.fillRect(t.x,t.y,c,t.height):r.fillRect(t.x+t.width-c,t.y,c,t.height)}}tileCell(t,e,s){const r=t.handle,i=this.tileCells.get(r);if(i&&i.pw===e&&i.ph===s)return i.canvas;const o=t.rasterize?t.rasterize(e,s):t.handle,a=Gt(e,s);return a.getContext("2d").drawImage(o,0,0,e,s),this.tileCells.set(r,{pw:e,ph:s,canvas:a}),a}tintCell(t,e,s,r,i){let o=this.tintCells.get(t.handle);o||this.tintCells.set(t.handle,o=new Map);let a=o.get(e);if(a)o.delete(e);else{const c=Gt(s,r);i(c.getContext("2d")),a=c,o.size>=Ar&&o.delete(o.keys().next().value)}return o.set(e,a),a}drawImage(t,e,s,r){if(!t.handle)return;if(r.tile){const m=t.naturalWidth,E=t.naturalHeight;if(m<=0||E<=0)return;const k=Math.max(1,Math.ceil(m*this.dpr)),L=Math.max(1,Math.ceil(E*this.dpr)),C=t.rasterize!==void 0||$t(t.src),O=C?this.tileCell(t,k,L):t.handle,F=C?m/k:1,W=C?E/L:1,$=this.ctx.createPattern(O,"repeat");if(!$)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(F,W),this.ctx.fillStyle=$,this.ctx.fillRect(0,0,s.width/F,s.height/W),this.ctx.restore();return}const i=e?{src:e,dst:s}:kr(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const c=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),h=!e&&r.fit!=="cover";let u=c,d=l;if(t.rasterize&&!h){const m=Math.max(c/a.width,l/a.height);u=Math.max(1,Math.ceil(t.naturalWidth*m)),d=Math.max(1,Math.ceil(t.naturalHeight*m));const E=u/t.naturalWidth,k=d/t.naturalHeight;a={x:a.x*E,y:a.y*k,width:a.width*E,height:a.height*k}}const f=()=>t.rasterize?t.rasterize(u,d):t.handle,g=r.tint;if(g===void 0){const m=f();h?this.ctx.drawImage(m,o.x,o.y,o.width,o.height):this.ctx.drawImage(m,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const y=m=>Math.round(m*100)/100,x=`${c}x${l}|${g}`+(h?"":`|${u}x${d}:${y(a.x)},${y(a.y)},${y(a.width)},${y(a.height)}`),w=a,p=this.tintCell(t,x,c,l,m=>{const E=f();h?m.drawImage(E,0,0,c,l):m.drawImage(E,w.x,w.y,w.width,w.height,0,0,c,l),m.globalCompositeOperation="source-in",m.fillStyle=lt(g),m.fillRect(0,0,c,l)});this.ctx.drawImage(p,o.x,o.y,o.width,o.height)}fillText(t,e,s,r,i){const o=this.ctx;o.font=`${r.italic?"italic ":""}${r.weight} ${r.size}px ${r.family}`,o.textBaseline="alphabetic",o.textAlign="left","letterSpacing"in o&&(o.letterSpacing=`${r.letterSpacing}px`),o.fillStyle=lt(i),o.fillText(t,e,s)}}const G=[null],_t=new Map,gn=n=>{if(!n.startsWith("id:"))return n;const t=Number(n.slice(3));return et(t)?hn(t):null},pn=n=>{const t=_t.get(n);t!==void 0&&(URL.revokeObjectURL(t),_t.delete(n))},Et=[!1],mn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),Et[t]&&(n.currentTime=0,n.play())})},Mr=(n,t)=>{const e=gn(n);if(e===null)return-1;const s=document.createElement("video");document.body.appendChild(s),s.crossOrigin="anonymous",s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e,s.playsInline=!0,s.controls=!1;const r=G.length;return e!==n&&_t.set(r,e),G.push(s),Et.push(!1),mn(s,r,t),r},Lr=(n,t)=>{const e=gn(n);if(e===null)return-1;const s=document.createElement("audio");document.body.appendChild(s),s.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",s.src=e;const r=G.length;return e!==n&&_t.set(r,e),G.push(s),Et.push(!1),mn(s,r,t),r},Pr=(n,t)=>{const e=G[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},Cr=(n,t)=>{const e=G[n];e&&(t?e.play():e.pause())},Or=(n,t)=>{Et[n]=t},Ir=n=>{var t;return((t=G[n])==null?void 0:t.currentTime)??0},Fr=(n,t)=>{const e=G[n];e&&(e.currentTime=t)},Nr=n=>{var e;const t=((e=G[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},ge=n=>G[n],yn=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},Ur=n=>{const t=G[n];t&&(yn(t),pn(n),G[n]=null,Et[n]=!1)},wn=()=>{for(let n of G)n&&yn(n);for(const n of[..._t.keys()])pn(n);G.length=1,Et.length=1},Br=9,Dr=10,Wr=12,Hr=13,$r=14,Vr=15,Gr=16,jr=1,zr=2,Kr=4,Le=8,Xr=16,Yr=32,qr=64,Jr=256,Qr=512,Zr=1024,ts=2048,es=4096,Pe=0,Mt=1,Ce=2,ut=3;function Oe(n,t,e){const s=n.rect;return t>=s.x&&t<s.x+s.width&&e>=s.y&&e<s.y+s.height}function bt(n,t,e,s){let r=null,i=null,o=!1;const a=c=>{const l=Oe(c,t,e);if(l&&s(c)&&(r=c),!(c.clip&&!l))for(const h of c.children)h.overlay!==void 0&&(r=null,i=h,o=!Oe(h,t,e)),a(h)};return a(n),{node:r,blocker:r?null:i,outside:o}}const ns=255,it={color:4294967295,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function ae(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:c,textAlign:l,textDecoration:h}=t,u=s??it.fontSize;return{color:e??(n.type==="input"||n.type==="textarea"?ns:it.color),fontSize:u,fontFamily:r??it.fontFamily,fontWeight:i??it.fontWeight,fontStyle:o??it.fontStyle,lineHeight:a,letterSpacing:c??it.letterSpacing,textAlign:l??it.textAlign,textDecoration:h??it.textDecoration}}function bn(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}const rs=10;function ce(n,t,e){const s=[];if(n.length===0)return[""];let r=n;for(;r;){if(e(r)<=t){s.push(r);break}let i=0,o=-1,a=0;for(;(a=r.indexOf(" ",a+1))!==-1&&!(e(r.substring(0,a))>t);)o=a;if(o>0)i=o;else{let c=r.indexOf(" ");c===-1&&(c=r.length);const l=r.substring(0,c);if(e(l)>t){for(let h=1;h<=l.length;h++)if(e(l.substring(0,h))>t){i=h-1;break}}else for(let h=c+1;h<=r.length;h++)if(e(r.substring(0,h))>t){i=h-1;break}}i<=0&&(i=1),s.push(r.substring(0,i)),r=r.substring(i+(o>0?1:0))}return s}function ss(n,t,e,s){const r=e.length;if(r<2||r>rs||!isFinite(t))return e;const i=c=>ce(n,c,s).length;let o=Math.floor(t);if(i(o)!==r)return e;let a=0;for(const c of n.split(" "))a=Math.max(a,Math.ceil(s(c)));if(a>=o)return e;if(i(a)===r)o=a;else for(;o-a>1;){const c=a+o>>1;i(c)===r?o=c:a=c}return ce(n,o,s)}function is(n,t,e){const s=t.length;if(s<2)return t;const r=t[s-1].trim();if(r.length===0||r.includes(" "))return t;const i=t[s-2].trimEnd(),o=i.lastIndexOf(" ");if(o<=0)return t;const a=i.slice(o+1)+" "+r;return e(a)>n?t:[...t.slice(0,s-2),i.slice(0,o),a]}function Ft(n,t,e,s="wrap",r=0){const i=[],o=s==="nowrap"?1/0:t;let a=s==="balance"||s==="pretty";for(const l of n.split(`
|
|
10
|
+
`)){let h=ce(l,o,e);a&&(r>0&&i.length+h.length>r?a=!1:s==="balance"?h=ss(l,o,h,e):h=is(o,h,e));for(const u of h)i.push(u)}let c=0;for(const l of i)c=Math.max(c,e(l));return{lines:i,maxWidth:c}}function vn(n,t,e,s,r){const i=t.textWrap??"wrap",o=Ft(n,e,s,i,t.lineClamp??0),a=i==="nowrap"&&!r?1/0:e,c=os(o.lines,t,a,s);return i!=="nowrap"||!r||t.textOverflow==="clip"||!isFinite(e)?c:c.map(l=>s(l)>e?xn(l,e,s):l)}const jt="…";function os(n,t,e,s){const r=t.lineClamp??0;if(r<=0||n.length<=r)return n;const i=n.slice(0,r);return t.textOverflow==="clip"||(i[r-1]=xn(i[r-1],e,s)),i}function xn(n,t,e){if(!isFinite(t))return n+jt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+jt)>t;)r--;return s.slice(0,r).join("").trimEnd()+jt}function as(n,t,e){const s=ae(n),r=bn(s),i=isNaN(e)?1/0:e,o=l=>t.measureText(l,r),a=vn(n.text??"",n.style,i,o,!1);let c=0;for(const l of a)c=Math.max(c,o(l));return{width:Math.ceil(c),height:Math.ceil(a.length*s.lineHeight)}}function cs(n,t,e){const s=n.style,r={family:s.fontFamily??"Roboto",size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.lineHeight,o=n.value??"";if(n.type==="input")return{width:Math.ceil(t.measureText(o,r)),height:Math.ceil(i)};const a=isNaN(e)?1/0:e,c=Ft(o,a,l=>t.measureText(l,r));return{width:Math.ceil(c.maxWidth),height:Math.ceil(Math.max(1,c.lines.length)*i)}}function ls(n,t,e,s){const r=n.imageSrcRaw;let i=0,o=0;if(n.sourceRect)i=n.sourceRect[2],o=n.sourceRect[3];else if(un(r)){const l=se(r.svg);if(l)i=l.width,o=l.height;else{const h=t.getImage(t.resolveSrc(r)??"");i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}}else{const l=t.resolveSrc(r),h=l?t.getImage(l):void 0;i=(h==null?void 0:h.naturalWidth)??0,o=(h==null?void 0:h.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),c=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*c,height:o*c}}const En=(n,t,e,s)=>t?[n[0],n[1],n[2],n[3],n[4]+e*t[0]+s*t[2],n[5]+e*t[1]+s*t[3]]:n;function hs(n,t,e,s,r,i,o={}){t.beginFrame(s,r);for(const a of n)Sn(a.tree,t,e,o);t.endFrame()}function Sn(n,t,e,s){var h;const{style:r,rect:i}=n;t.save();const o=r.opacity!==void 0&&r.opacity<1?r.opacity:void 0,a=o!==void 0&&n.children.length>0;if(a?t.beginGroup(o):o!==void 0&&t.setAlpha(o),r.transform){const[u,d,f,g,y,x]=En(r.transform,r.transformBox,i.width,i.height),w=r.transformOrigin,p=i.x+(w?w.xPercent?i.width*w.x/100:w.x:i.width/2),m=i.y+(w?w.yPercent?i.height*w.y/100:w.y:i.height/2);t.translate(p,m),t.transform(u,d,f,g,y,x),t.translate(-p,-m)}const c=oe(r.borderRadius,i);if(ie(r.backgroundColor)||t.fillRoundRect(i,c,r.backgroundColor),r.backgroundImage){const u=e.getImage(r.backgroundImage);u&&u.naturalWidth>0&&u.naturalHeight>0&&(t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(u,null,i,{fit:us(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let u=r.backgroundGradients.length-1;u>=0;u--){const d=r.backgroundGradients[u];d.stops.length>0&&t.fillGradient(i,c,d)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const u=n.sourceRect;t.save(),Ae(c)&&t.clipRoundRect(i,c),t.drawImage(n.image,u?{x:u[0],y:u[1],width:u[2],height:u[3]}:null,i,{fit:u?"fill":r.objectFit??"contain",tint:$t(n.image.src)?r.tintColor:void 0,radius:c}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&fs(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&bs(n,t,e,c),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,c):n.type==="video"?gs(n,t,e,c):((h=n.view)==null?void 0:h.label)!==void 0&&ws(n,n.view.name,n.view.label,t,e,c)),n.clip&&t.clipRoundRect(i,c);for(const u of n.children)u.overlay!==void 0&&!ie(u.overlay)&&t.fillRoundRect(i,void 0,u.overlay),Sn(u,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,c,Math.round(Math.min(1,r.dim)*255)>>>0);const l=ds(r.border);l&&t.strokeBorder(i,c,l),a&&t.endGroup(),t.restore()}function us(n){return n==="contain"||n==="fill"?n:"cover"}function ds(n){if(!n)return null;const t={};let e=!1;for(const s of["top","right","bottom","left"]){const r=n[s];r&&r.width>0&&(r.color>>>0)%256!==0&&(t[s]=r,e=!0)}return e?t:null}const pe=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function fs(n,t,e){var x,w,p;const s=n.style,r={family:pe(e,s.fontFamily),size:s.fontSize??14,weight:s.fontWeight??400,italic:s.fontStyle==="italic",letterSpacing:s.letterSpacing??0},i=s.color??255,o=s.lineHeight,a=s.textAlign??"start",c=e.fontMetrics(r),{rect:l,lines:h}=n,u=((x=n.padding)==null?void 0:x[0])??0,d=((w=n.padding)==null?void 0:w[1])??0,f=((p=n.padding)==null?void 0:p[2])??0,g=l.x+u,y=l.width-u-f;for(let m=0;m<h.length;m++){const E=h[m],L=l.y+d+m*o+(o-(c.ascent+c.descent))/2+c.ascent,C=e.measureText(E,r),O=a==="center"?g+(y-C)/2:a==="end"?g+y-C:g;if(t.fillText(E,O,L,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const F=Math.max(1,r.size/14),W=s.textDecoration==="underline"?L+F:L-r.size*.3;t.fillRoundRect({x:O,y:W,width:C,height:F},void 0,i)}}}function gs(n,t,e,s){const{rect:r}=n;ie(n.style.backgroundColor)&&t.fillRoundRect(r,s,286463999);const i=Math.min(r.width,r.height)*.3;if(i>=6){const o={family:"Roboto",size:i,weight:400,italic:!1,letterSpacing:0},a=e.fontMetrics(o),c=e.measureText("▶",o),l=r.x+(r.width-c)/2,h=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,h,o,4294967244)}}const ps=3722701567,ms=1263887359,ys=2324997119;function ws(n,t,e,s,r,i){const{rect:o}=n;s.fillRoundRect(o,i,ps);const a=pe(r,void 0),c={family:a,size:17,weight:600,italic:!1,letterSpacing:0},l={family:a,size:13,weight:400,italic:!1,letterSpacing:0},h=[];if(e&&h.push([e,c,ms]),t&&t!==e&&h.push([t,l,ys]),h.length===0)return;const u=4,d=h.map(([,g])=>{const y=r.fontMetrics(g);return y.ascent+y.descent});let f=o.y+(o.height-d.reduce((g,y)=>g+y,0)-u*(h.length-1))/2;s.save(),s.clipRoundRect(o,i),h.forEach(([g,y,x],w)=>{const p=o.x+(o.width-r.measureText(g,y))/2;s.fillText(g,p,f+r.fontMetrics(y).ascent,y,x),f+=d[w]+u}),s.restore()}function bs(n,t,e,s){var $,j,q,A,v;const r=n.style,i={family:pe(e,r.fontFamily),size:r.fontSize??14,weight:r.fontWeight??400,italic:r.fontStyle==="italic",letterSpacing:r.letterSpacing??0},o=n.value??"",a=o.length===0,c=r.inputType==="password"&&!a,l=a?r.placeholder??"":c?"•".repeat(o.length):o,h=a?r.placeholderColor??2576980479:r.color??255,{rect:u}=n,d=(($=n.padding)==null?void 0:$[0])??0,f=((j=n.padding)==null?void 0:j[1])??0,g=((q=n.padding)==null?void 0:q[2])??0,y=((A=n.padding)==null?void 0:A[3])??0,x=u.x+d,w=u.width-d-g,p=u.y+f,m=u.height-f-y,E=e.fontMetrics(i),k=r.lineHeight,L=r.textAlign??"start",C=n.type==="textarea",O=C?Ft(l,w,T=>e.measureText(T,i)).lines:[l],F=T=>L==="center"?x+(w-T)/2:L==="end"?x+w-T:x,W=T=>C?p+T*k+(k-(E.ascent+E.descent))/2+E.ascent:p+(m-(E.ascent+E.descent))/2+E.ascent;t.save(),t.clipRoundRect(u,s);for(let T=0;T<O.length;T++){const I=O[T];I.length>0&&t.fillText(I,F(e.measureText(I,i)),W(T),i,h)}if((v=n.state)!=null&&v.focused){const T=a?[""]:C?Ft(c?"•".repeat(o.length):o,w,U=>e.measureText(U,i)).lines:[l],I=T.length-1,z=e.measureText(T[I],i),J=a?F(0):F(z)+z,_=W(I),M=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:_-E.ascent,width:M,height:E.ascent+E.descent},void 0,r.color??255)}t.restore()}const vs=84,xs={display:{word:4},overflow:{word:5},scrollDirection:{word:6},borderTopWidth:{word:8},borderRightWidth:{word:9},borderBottomWidth:{word:10},borderLeftWidth:{word:11},color:{bit:12,word:16},backgroundColor:{word:17},borderTopColor:{word:19},borderRightColor:{word:20},borderBottomColor:{word:21},borderLeftColor:{word:22},placeholderColor:{bit:19,word:23},tintColor:{bit:21,word:25},overlayColor:{bit:23,word:27},backgroundImage:{word:28},backgroundSize:{word:29},backgroundGradient:{word:30},borderTopLeftRadius:{word:32},borderTopRightRadius:{word:33},borderBottomRightRadius:{word:34},borderBottomLeftRadius:{word:35},opacity:{word:36},transform:{word:37},transformOrigin:{word:50},fontSize:{word:55},fontWeight:{word:56},fontStyle:{word:57},fontFamily:{bit:39,word:58},lineHeight:{word:59},letterSpacing:{word:60},textAlign:{word:61},textDecoration:{word:62},lineClamp:{word:63},textOverflow:{word:64},textWrap:{word:65},objectFit:{word:66},placeholder:{word:67},type:{word:68},dim:{word:82}},Es={hidden:1},Ss={horizontal:1},_s={italic:1},ht={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],textWrap:["wrap","nowrap","balance","pretty"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},ks=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,Ts=["farthest-corner","closest-side","closest-corner","farthest-side"],Rs=52;function As(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Ms(n,t,e+i*Rs));return r}function Ms(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],c=[];for(let l=0;l<o;l++){const h=a+l*8>>2;c.push({color:t[h]>>>0,position:n[h+1]})}if(i===1){const l=t[s+6],h={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:c};return l===4?{...h,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...h,extent:Ts[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:c}}const R=xs,Ls=["start","center","end","start","end"],Ie=new WeakMap;function _n(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],c=O=>ks(o,a,O),l=O=>{const F=s[i+O];return F===0?void 0:n.UTF8ToString(n._cuiStringOf(F))};e.backgroundColor=s[i+R.backgroundColor.word]>>>0,e.opacity=r[i+R.opacity.word],e.dim=r[i+R.dim.word],e.display=ht.display[s[i+R.display.word]],e.overflow=s[i+R.overflow.word]===Es.hidden?"hidden":"visible",e.scrollAxis=s[i+R.scrollDirection.word]===Ss.horizontal?"x":"y",e.border={top:{width:r[i+R.borderTopWidth.word],color:s[i+R.borderTopColor.word]>>>0},right:{width:r[i+R.borderRightWidth.word],color:s[i+R.borderRightColor.word]>>>0},bottom:{width:r[i+R.borderBottomWidth.word],color:s[i+R.borderBottomColor.word]>>>0},left:{width:r[i+R.borderLeftWidth.word],color:s[i+R.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+R.borderTopLeftRadius.word],tr:r[i+R.borderTopRightRadius.word],br:r[i+R.borderBottomRightRadius.word],bl:r[i+R.borderBottomLeftRadius.word]},e.backgroundImage=l(R.backgroundImage.word),e.backgroundSize=ht.backgroundSize[s[i+R.backgroundSize.word]];const h=s[i+R.backgroundGradient.word];if(h===0)e.backgroundGradients=void 0;else{let O=Ie.get(n);O===void 0&&(O=n._malloc(4),Ie.set(n,O));const F=n._cuiGradientOf(h,O),W=n.HEAPU32[O>>>2];e.backgroundGradients=F!==0&&W>0?As(n.HEAPF32,n.HEAPU32,F,W):void 0}const u=i+R.transform.word,d=r[u],f=r[u+1],g=r[u+3],y=r[u+4],x=r[u+6],w=r[u+7],p=r[u+9],m=r[u+10],E=r[u+11],k=r[u+12],L=p===0&&m===0&&E===0&&k===0;e.transform=d===1&&f===0&&g===0&&y===1&&x===0&&w===0&&L?void 0:[d,f,g,y,x,w],e.transformBox=L?void 0:[p,m,E,k];const C=i+R.transformOrigin.word;e.transformOrigin={x:r[C],y:r[C+1],xPercent:s[C+2]!==0,yPercent:s[C+3]!==0},e.color=c(R.color.bit)?s[i+R.color.word]>>>0:void 0,e.fontFamily=c(R.fontFamily.bit)?l(R.fontFamily.word):void 0,e.fontSize=r[i+R.fontSize.word],e.fontWeight=r[i+R.fontWeight.word],e.fontStyle=s[i+R.fontStyle.word]===_s.italic?"italic":"normal",e.lineHeight=r[i+R.lineHeight.word],e.letterSpacing=r[i+R.letterSpacing.word],e.textAlign=Ls[s[i+R.textAlign.word]]??"start",e.textDecoration=ht.textDecoration[s[i+R.textDecoration.word]],e.lineClamp=r[i+R.lineClamp.word],e.textOverflow=ht.textOverflow[s[i+R.textOverflow.word]],e.textWrap=ht.textWrap[s[i+R.textWrap.word]],e.objectFit=ht.objectFit[s[i+R.objectFit.word]],e.tintColor=c(R.tintColor.bit)?s[i+R.tintColor.word]>>>0:void 0,e.placeholder=l(R.placeholder.word),e.placeholderColor=c(R.placeholderColor.bit)?s[i+R.placeholderColor.word]>>>0:void 0,e.inputType=ht.type[s[i+R.type.word]],e.overlayColor=c(R.overlayColor.bit)?s[i+R.overlayColor.word]>>>0:void 0}function Ps(n,t){const e=n._cuiPaintOf(t);if(e===0)return!1;const s=e>>>2;return n.HEAPU32[s+2]!==0||n.HEAPU32[s+3]!==0}function Cs(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(_n(n,s,e),!0)}function Os(n,t){const e=n._paintCollect();if(e===0)return 0;const s=n._paintNodes()>>>2,r=n._paintRecords();for(let i=0;i<e;i++){const o=n.HEAPU32[s+i],a=r+i*vs*4;t(o,c=>_n(n,a,c))}return e}function kn(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?le(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>le(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function Is(n,t=[],e){return JSON.stringify(kn(n,t,e),null,2)}function yt(n,t){const e=10**t;return Math.round(n*e)/e}function le(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),n.view&&(r.view=n.view.name),r.rect=[yt(s.x,t),yt(s.y,t),yt(s.width,t),yt(s.height,t)],e&&(r.id=n.id);const i=Ns(n.style);return i&&(r.style=i),n.text!==void 0&&(r.text=n.text),n.lines&&(n.lines.length!==1||n.lines[0]!==n.text)&&(r.lines=n.lines),n.value!==void 0&&n.value!==""&&(r.value=n.value),n.style.placeholder!==void 0&&(r.placeholder=n.style.placeholder),n.image&&(r.image={src:n.image.src,natural:[n.image.naturalWidth,n.image.naturalHeight]}),n.sourceRect&&(r.sourceRect=n.sourceRect),n.state&&(n.state.pressed||(o=n.state.classes)!=null&&o.length)&&(r.state={...n.state.pressed?{pressed:!0}:{},...(a=n.state.classes)!=null&&a.length?{classes:n.state.classes}:{}}),n.scroll&&(r.scroll={offset:yt(n.scroll.offset,t),content:yt(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(c=>le(c,t,e))),r}function Fs(n){return n.tl===n.tr&&n.tr===n.br&&n.br===n.bl?n.tl:[n.tl,n.tr,n.br,n.bl]}function Ns(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=mt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=mt(n.color)),n.fontSize!==void 0&&(t.fontSize=n.fontSize),n.fontFamily!==void 0&&(t.fontFamily=n.fontFamily),n.fontWeight!==void 0&&(t.fontWeight=n.fontWeight),n.fontStyle!==void 0&&n.fontStyle!=="normal"&&(t.fontStyle=n.fontStyle),n.lineHeight!==void 0&&(t.lineHeight=n.lineHeight),n.letterSpacing&&(t.letterSpacing=n.letterSpacing),n.textAlign!==void 0&&n.textAlign!=="start"&&(t.textAlign=n.textAlign),n.textDecoration!==void 0&&n.textDecoration!=="none"&&(t.textDecoration=n.textDecoration),n.lineClamp&&(t.lineClamp=n.lineClamp,n.textOverflow==="clip"&&(t.textOverflow=n.textOverflow)),n.textWrap!==void 0&&n.textWrap!=="wrap"&&(t.textWrap=n.textWrap),n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=mt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=mt(n.overlayColor)),n.backgroundImage!==void 0&&(t.backgroundImage=n.backgroundImage),n.backgroundSize!==void 0&&(t.backgroundSize=n.backgroundSize),n.backgroundGradients!==void 0&&n.backgroundGradients.length>0&&(t.backgroundGradients=n.backgroundGradients.map(e=>{const s=e.stops.map(r=>({color:mt(r.color),position:r.position}));if(e.type==="radial"){const r={type:"radial",shape:e.shape,extent:e.extent,cx:e.cx,cy:e.cy,stops:s};return e.extent==="explicit"&&(r.rx=e.rx,r.ry=e.ry,r.rxUnit=e.rxUnit,r.ryUnit=e.ryUnit),r}return{angle:e.angle,stops:s}})),n.borderRadius&&(n.borderRadius.tl||n.borderRadius.tr||n.borderRadius.br||n.borderRadius.bl)&&(t.borderRadius=Fs(n.borderRadius)),n.border){const e={};for(const s of["top","right","bottom","left"]){const r=n.border[s];r&&r.width>0&&(e[s]={width:r.width,color:mt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const Us=.32,Bs=4,Ds={},Fe=new Map;function he(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Fe.get(n);return t===void 0&&(t=dn(n.slice(4)),Fe.set(n,t)),t}return n}class Ws{constructor(t,e){b(this,"parent",null);b(this,"children",[]);b(this,"style",{lineHeight:14*1.2});b(this,"name");b(this,"text","");b(this,"src");b(this,"value","");b(this,"sourceRect");b(this,"viewName");b(this,"viewParams");b(this,"playerId",0);b(this,"viewId",0);b(this,"flags",0);b(this,"layoutRect",null);b(this,"scrollOffset",0);b(this,"wrapCache");b(this,"jsNode");b(this,"bgRaw");b(this,"bgSrc");this.id=t,this.type=e,this.jsNode={type:e,_id:t}}get measured(){return this.type==="text"||this.type==="image"||this.editable}get editable(){return this.type==="input"||this.type==="textarea"}get scrollable(){return this.type==="scrollable"||this.type==="scrollableScreen"||this.type==="vlist"}get scrollAxis(){return this.style.scrollAxis==="x"?"x":"y"}get interactive(){return(this.flags&jr)!==0}get imageSrcRaw(){return this.type==="image"?he(this.src):void 0}has(t){return(this.flags&t)!==0}}class Hs{constructor(t,e,s={}){b(this,"nodes",new Map);b(this,"root",null);b(this,"leaving",null);b(this,"leavingAbove",!1);b(this,"pagerShown",new Map);b(this,"pagerLeaving",new Map);b(this,"destKind",-1);b(this,"layerRoots",[]);b(this,"width",0);b(this,"height",0);b(this,"focused",null);b(this,"safeBottom",0);b(this,"shrunkRoot",0);b(this,"shrunkInset",0);b(this,"pressed",new Set);b(this,"gestures",new Map);b(this,"vlists",new Set);b(this,"frameCache",null);b(this,"painted",null);b(this,"fontsPending",0);b(this,"lastToast",null);b(this,"dirty",!0);b(this,"onDestination",null);b(this,"onDropped",null);b(this,"placeholders");b(this,"viewNames",new Map);b(this,"nativeDest",null);b(this,"layoutPtr",0);b(this,"padPtr",0);b(this,"lastCreated",0);b(this,"hoverX",0);b(this,"hoverY",0);b(this,"hoverInside",!1);b(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s,this.placeholders=new Map(Object.entries(s.nativeViews??{}))}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,c)=>{const l=this.measure(r,i,a);return t.setFloat32(4,l.width,!0),t.setFloat32(0,l.height,!0),t.getBigUint64(0,!0)};this.M._setMeasureFunc(this.M.addFunction(e,"jiififi"))}measure(t,e,s){const r=this.nodes.get(t);if(!r)return{width:0,height:0};const i=this.M;Ps(i,t)&&(Cs(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?as(o,this.host,e):r.type==="image"?ls(o,this.host,e,s):r.editable?cs(o,this.host,e):{width:0,height:0}}resize(t,e){this.width=t,this.height=e,this.M._creatorWebResize(t,e),this.M._setConditionValue(t,e),this.dirty=!0}setSafeArea(t,e=[]){const[s,r,i,o]=t??(this.width>this.height?[0,8,0,20]:[20,0,8,0]),a={top:1,right:2,bottom:4,left:8};this.M._setSafeAreaBars(e.reduce((c,l)=>c|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.safeBottom=i,this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&(this.shrunkInset=Math.max(0,i-this.keyboardHeight()),this.M._overrideRootSafeBottom(this.shrunkRoot,this.shrunkInset)),this.dirty=!0}layoutFrame(){const t=this.M;Os(t,(r,i)=>{const o=this.nodes.get(r);o&&(i(o.style),this.resolveBackground(o))})>0&&(this.dirty=!0);const s=t._creatorWebLayoutFrame(this.width,this.height);s>0&&this.readLayoutBatch(s);for(const r of this.vlists)if(t._vlistExists(r.id)){t._vlistUpdateLayout(r.id);for(const i of r.children)this.deliverSubtree(i)}}needsPaint(){return this.dirty||this.frameCache===null||this.frameCache!==this.painted}deliverSubtree(t){const e=this.M;if(this.layoutPtr||(this.layoutPtr=e._malloc(16)),e._getLayoutPointer(t.id,this.layoutPtr)){const s=this.layoutPtr>>2,r={x:e.HEAPF32[s],y:e.HEAPF32[s+1],width:e.HEAPF32[s+2],height:e.HEAPF32[s+3]},i=t.layoutRect,o=!i||i.x!==r.x||i.y!==r.y||i.width!==r.width||i.height!==r.height;t.layoutRect=r,o&&(this.dirty=!0),o&&t.has(Le)&&e._creatorWebNodeLayout(t.id,r.x,r.y,r.width,r.height)}for(const s of t.children)this.deliverSubtree(s)}readLayoutBatch(t){const e=this.M,s=e._collectNodes()>>>2,r=e._collectRects()>>>2,i=e.HEAPU32,o=e.HEAPF32;for(let a=0;a<t;a++){const c=i[s+a],l=this.nodes.get(c);if(!l)continue;const h=o[r+a*4],u=o[r+a*4+1],d=o[r+a*4+2],f=o[r+a*4+3],g={x:h,y:u,width:d-h,height:f-u},y=l.layoutRect,x=!y||y.x!==g.x||y.y!==g.y||y.width!==g.width||y.height!==g.height;l.layoutRect=g,x&&(this.dirty=!0),x&&l.has(Le)&&e._creatorWebNodeLayout(c,h,u,g.width,g.height)}}frame(){if(this.frameCache&&!this.dirty)return this.frameCache;const t=[],e={x:0,y:0,width:this.width,height:this.height},s=this.nativeDest;if(s){const i={id:0,type:"native",rect:e,style:Ds,children:[],view:{name:s.view,label:this.placeholders.get(s.view)}};s.name&&(i.name=s.name),t.push(this.destKind===ut?{tree:i}:{tree:i,leaving:!0})}const r=this.leaving?this.build(this.leaving,e):null;if(r&&!this.leavingAbove&&t.push({tree:r,leaving:!0}),this.root){const i=this.build(this.root,e);i&&t.push({tree:i})}r&&this.leavingAbove&&t.push({tree:r,leaving:!0});for(const i of this.layerRoots){const o=this.build(i,e);o&&t.push({tree:o,widget:!0})}return this.frameCache=t,this.dirty=!1,t}renderTree(){var t;return((t=this.frame().find(e=>!e.widget&&!e.leaving))==null?void 0:t.tree)??null}widgetTrees(){return this.frame().filter(t=>t.widget).map(t=>t.tree)}widgets(){return this.widgetTrees()}serialize(){return kn(this.renderTree(),this.widgetTrees())}toText(){return Is(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();hs(s,t,this.host,this.width,this.height,void 0,e),this.painted=s}build(t,e){const s=this.M,r=(i,o,a,c)=>{var w;if(i.style.display==="none")return null;let l,h,u,d;if(c)l=e.x,h=e.y,u=e.width,d=e.height;else{const p=i.layoutRect;if(!p)return null;l=o+p.x,h=a+p.y,u=p.width,d=p.height}const f={id:i.id,type:i.type,rect:{x:l,y:h,width:u,height:d},style:i.style,children:[]};i.name&&(f.name=i.name);const g=i;if(i.type==="text"){const p=ae(g),m=bn(p);f.text=i.text;const E=this.padding(i.id);(E[0]||E[1]||E[2]||E[3])&&(f.padding=E);const k=u-E[0]-E[2],L=`${k}|${m.size}|${m.weight}|${m.italic?1:0}|${m.letterSpacing}|${m.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.style.textWrap??""}|${i.text}`;if(((w=i.wrapCache)==null?void 0:w.key)===L)f.lines=i.wrapCache.lines;else{const C=F=>this.host.measureText(F,m),O=vn(i.text,i.style,k,C,!0);i.wrapCache={key:L,lines:O},f.lines=O}f.style={...i.style,color:p.color,fontSize:p.fontSize,fontFamily:p.fontFamily,fontWeight:p.fontWeight,fontStyle:p.fontStyle,lineHeight:p.lineHeight,letterSpacing:p.letterSpacing,textAlign:p.textAlign,textDecoration:p.textDecoration}}else if(i.type==="image"){const p=this.host.resolveSrc(i.imageSrcRaw),m=p?this.host.getImage(p):void 0;f.image=m??(p?{src:p,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(f.sourceRect=i.sourceRect)}else if(i.editable){f.value=i.value;const p=this.padding(i.id);(p[0]||p[1]||p[2]||p[3])&&(f.padding=p);const m=ae(g);f.style={...i.style,color:m.color,fontSize:m.fontSize,fontFamily:m.fontFamily,fontWeight:m.fontWeight,fontStyle:m.fontStyle,lineHeight:m.lineHeight,letterSpacing:m.letterSpacing,textAlign:m.textAlign,textDecoration:m.textDecoration}}else if(i.type==="native"){const p=i.viewName??"";f.view={name:p,label:this.placeholders.get(p)}}i.type==="widget"&&i.style.overlayColor!==void 0&&(f.overlay=i.style.overlayColor),i.interactive&&(f.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(f.state={...f.state,focused:!0}),i.style.overflow==="hidden"&&(f.clip=!0);let y=l,x=h;if(i.scrollable){const p=i.scrollAxis,m=p==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);f.clip=!0,f.scroll={offset:i.scrollOffset,content:m,axis:p},p==="x"?y=l-i.scrollOffset:x=h-i.scrollOffset}if(i.type==="pager"){const p=s._creatorWebPagerSelectedIndex(i.id),m=s._creatorWebPagerStackLen(i.id,p),E=m>0?s._creatorWebPagerPageNode(i.id,p,m-1):0,k=E?this.nodes.get(E):void 0;k?this.pagerShown.set(i.id,k):this.pagerShown.delete(i.id);const L=this.pagerLeaving.get(i.id);for(const C of L&&L.page!==k?L.above?[k,L.page]:[L.page,k]:[k]){const O=C?r(C,l,h,!1):null;O&&f.children.push(O)}return f}if(i.type==="vlist"){for(const p of i.children){const m=s._getParentNode(p.id);if(!m)continue;const E=s._vlistItemOffsetOf(i.id,m);if(Number.isNaN(E))continue;const k=r(p,l,h+E-i.scrollOffset,!1);k&&f.children.push(k)}return f}for(const p of i.children){const m=r(p,y,x,!1);m&&f.children.push(m)}return f};return r(t,0,0,!0)}paddingOf(t){return this.padding(t)}padding(t){const e=this.M;this.padPtr||(this.padPtr=e._malloc(16)),e._getPaddingPointer(t,this.padPtr);const s=this.padPtr>>2;return[e.HEAPF32[s],e.HEAPF32[s+1],e.HEAPF32[s+2],e.HEAPF32[s+3]]}withStr(t,e){const s=this.M.stringToNewUTF8(t);try{return e(s)}finally{this.M._free(s)}}get(t){return this.nodes.get(t)}findAll(t){const e=[],s=r=>{r.name===t&&e.push(r);for(const i of r.children)s(i)};for(const r of this.frame())s(r.tree);return e}findRect(t){const e=s=>{if(s.id===t)return s.rect;for(const r of s.children){const i=e(r);if(i)return i}return null};for(const s of this.frame()){const r=e(s.tree);if(r)return r}return null}toast(){return this.lastToast}pendingFonts(){return this.fontsPending}keyboardHeight(){return this.focused?this.options.keyboardHeight?this.options.keyboardHeight():Math.round(this.height*Us):0}focusedId(){var t;return((t=this.focused)==null?void 0:t.id)??0}nodeFactory(t,e,s,r){this.lastCreated=t;const i=new Ws(t,e);this.nodes.set(t,i),e==="vlist"&&this.vlists.add(i);const o=this.nodes.get(s);o&&this.link(o,i,Math.max(0,r)),this.dirty=!0}link(t,e,s){e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),e.parent=t,t.children.splice(Math.min(s,t.children.length),0,e)}insertNode(t,e,s){const r=this.nodes.get(t),i=this.nodes.get(e);r&&i&&this.link(r,i,s),this.dirty=!0}removeNode(t,e){var i;const s=this.nodes.get(t),r=this.nodes.get(e);!s||!r||(this.forget(r),s.children=s.children.filter(o=>o!==r),r.parent===s&&(r.parent=null),((i=this.pagerLeaving.get(t))==null?void 0:i.page)===r&&this.pagerLeaving.delete(t),this.pagerShown.get(t)===r&&this.pagerShown.delete(t),this.dirty=!0)}releaseNode(t){const e=this.nodes.get(t);if(!e)return;this.nodes.delete(t),this.forget(e),e.parent&&(e.parent.children=e.parent.children.filter(r=>r!==e)),this.root===e&&(this.root=null),this.leaving===e&&(this.leaving=null),this.pagerShown.delete(t),this.pagerLeaving.delete(t);for(const[r,i]of this.pagerLeaving)i.page===e&&this.pagerLeaving.delete(r);this.focused===e&&(this.focused=null,this.shrinkTo(0,0),this.emitKeyboard());const s=this.layerRoots.indexOf(e);s>=0&&this.layerRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),e.type==="native"&&e.viewId&&this.viewNames.delete(e.viewId),this.dirty=!0}forget(t){for(const e of this.gestures.values())e.node===t&&(e.node=null),e.scroll===t&&(e.scroll=null),e.backdrop===t&&(e.backdrop=null),e.edit===t&&(e.edit=null);for(const e of t.children)this.forget(e)}setPropertyString(t,e,s){const r=this.nodes.get(t);if(!r)return;const i=s??"";switch(e){case"text":r.text=i,r.wrapCache=void 0;break;case"value":r.value=i;break;case"name":r.name=i||void 0;break;case"src":{r.src=i||void 0;const o=this.host.resolveSrc(this.srcOf(r));o&&!this.host.getImage(o)&&this.host.loadImage(o).then(()=>{this.nodes.get(t)===r&&this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0}).catch(()=>{});break}case"sourceRect":{const o=i.split(" ").map(Number);r.sourceRect=o.length===4?[o[0],o[1],o[2],o[3]]:void 0;break}case"focus":i==="1"||i==="true"?this.focusInput(t):this.focused===r&&this.blurInput();break;case"viewName":r.viewName=i;break;case"viewParams":r.viewParams=i;break}this.dirty=!0}srcOf(t){return he(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(he(e)):void 0;const s=t.bgSrc;s&&!this.host.getImage(s)&&this.host.loadImage(s).then(()=>{this.dirty=!0}).catch(()=>{})}t.style.backgroundImage=t.bgSrc}setPropertyInt(t,e,s){const r=this.nodes.get(t);r&&(e==="playerId"?r.playerId=s:e==="viewId"&&(r.viewId=s,r.viewName!==void 0&&this.viewNames.set(s,r.viewName))),this.dirty=!0}setFlags(t,e){const s=this.nodes.get(t);s&&(s.flags=e>>>0)}leave(t){this.root&&(this.leaving=this.root,this.leavingAbove=t,this.root=null)}openView(t,e,s,r,i,o){var c;this.destKind=t;const a=t===Pe?this.nodes.get(e)??null:null;if(a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,t===ut){this.viewNames.set(s,r);let l;for(const h of this.nodes.values())if(h.type==="native"&&h.viewId===s){l=h.name;break}this.nativeDest=this.placeholders.has(r)?{id:s,view:r,name:l}:null}this.focused&&this.blurInput(),this.dirty=!0,(c=this.onDestination)==null||c.call(this,t,s)}dropView(t,e,s){var r,i;if(t===Pe){const o=this.nodes.get(e)??null;o!==null&&this.leaving===o&&(this.leaving=null),o!==null&&this.root===o&&(this.root=null)}t===ut&&((r=this.nativeDest)==null?void 0:r.id)===s&&this.destKind!==ut&&(this.nativeDest=null),this.dirty=!0,(i=this.onDropped)==null||i.call(this,t,s)}closeView(){var t;this.destKind=-1,this.leave(!0),this.dirty=!0,(t=this.onDestination)==null||t.call(this,-1,0)}isViewSupported(t){return this.placeholders.has(t)}viewVersion(t){return this.placeholders.has(t)?1:0}viewCall(t,e,s,r,i){const o=this.viewNames.get(t);i(o!==void 0&&this.placeholders.has(o)?`headless draws native views only: ${o}.${e}`:"NativeView calls are not supported on this host")}layerOpen(t){const e=this.nodes.get(t);e&&!this.layerRoots.includes(e)&&this.layerRoots.push(e),this.dirty=!0}layerClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.layerRoots.indexOf(e):-1;s>=0&&this.layerRoots.splice(s,1),this.dirty=!0}registerFont(t,e,s,r,i,o){this.fontsPending++,this.host.loadFont(e,t,{weight:s,style:r===2?"italic":"normal"}).then(()=>{this.invalidateText(),i()},a=>o(String(a))).finally(()=>{this.fontsPending--})}invalidateText(){for(const t of this.nodes.values())t.wrapCache=void 0,t.measured&&t.type!=="image"&&this.M._nodeHasMeasure(t.id)&&this.M._markNodeDirty(t.id);this.dirty=!0}showToast(t,e){var s,r;this.lastToast=t,(r=(s=this.options).onToast)==null||r.call(s,t,e)}getButtonPressed(t){return this.pressed.has(t)}getTextValue(t){var e;return((e=this.nodes.get(t))==null?void 0:e.value)??""}getBoundingRect(t){const e=this.findRect(t);return e?[e.x,e.y,e.width,e.height]:null}longPressHandler(t,e){const s=this.gestures.get(t);s&&(s.swallowClick=!0)}vlistScroll(t,e,s){const r=this.nodes.get(t);r&&(r.scrollOffset=e),this.dirty=!0}pagerCommand(t,e,s){this.pagerLeaving.delete(t),this.dirty=!0}pagerShowPage(t,e,s){const r=this.nodes.get(e),i=this.pagerShown.get(t);r&&this.pagerShown.set(t,r),i&&i!==r&&this.pagerLeaving.set(t,{page:i,above:!s}),this.dirty=!0}pagerDropPage(t,e){var s;((s=this.pagerLeaving.get(t))==null?void 0:s.page.id)===e&&this.pagerLeaving.delete(t),this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent&&e.type!=="widget";)e=e.parent;return e}emitKeyboard(){var s,r;const t=this.keyboardHeight(),e=this.keyboardDuration();(r=(s=this.options).onKeyboard)==null||r.call(s,t,e),this.M._creatorWebKeyboardEvent(t,e)}shrinkTo(t,e){this.M._creatorWebSetShrunkRoot(t,e);const s=e>0?t:0;s!==this.shrunkRoot&&(this.shrunkRoot&&this.nodes.has(this.shrunkRoot)&&this.M._overrideRootSafeBottom(this.shrunkRoot,this.safeBottom),this.shrunkRoot=s,this.shrunkInset=this.safeBottom);const r=Math.max(0,this.safeBottom-e);s&&r!==this.shrunkInset&&this.nodes.has(s)&&(this.M._overrideRootSafeBottom(s,r),this.shrunkInset=r)}keyboardDuration(){return 0}refreshKeyboard(){this.focused&&(this.shrinkTo(this.rootOf(this.focused).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}focusInput(t){const e=this.nodes.get(t);!e||!e.editable||this.focused===e||(this.focused&&this.blurInput(),this.focused=e,this.M._setNodeFocused(t,1),e.has(Qr)&&this.M._creatorWebNodeEvent(t,Hr),this.shrinkTo(this.rootOf(e).id,this.keyboardHeight()),this.emitKeyboard(),this.dirty=!0)}blurInput(){const t=this.focused;t&&(this.focused=null,this.M._setNodeFocused(t.id,0),t.has(Zr)&&this.M._creatorWebNodeEvent(t.id,$r),this.shrinkTo(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Jr)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Wr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(ts)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Vr,e)),this.focused===t&&this.blurInput(),!0):!1}scrollMax(t){const e=this.findRect(t.id)??t.layoutRect??{width:0,height:0},s=t.scrollAxis==="x"?e.width:e.height,r=t.scrollAxis==="x"?this.M._getContentWidth(t.id):this.M._getContentHeight(t.id);return Math.max(0,r-s)}scrollBy(t,e){const s=this.nodes.get(t);if(!s||!s.scrollable)return!1;const r=this.scrollMax(s),i=s.scrollOffset+e,o=Math.min(r,Math.max(0,i)),a=i<0?i:i>r?i-r:0;return a!==0&&s.has(Yr)&&this.M._creatorWebNodeEventNum(t,Br,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Xr)&&this.M._creatorWebNodeScroll(t,o),this.dirty=!0,!0)}topInteractive(t,e){const s=this.frame();for(let r=s.length-1;r>=0;r--){const i=bt(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i.node)return this.nodes.get(i.node.id)??null;if(i.blocker)return null}return null}setPressed(t,e){e?this.pressed.add(t.id):this.pressed.delete(t.id),this.nodes.get(t.id)===t&&this.M._setNodePressed(t.id,e?1:0),this.dirty=!0}pointerHover(t,e){this.hoverX=t,this.hoverY=e,this.hoverInside=!0,this.hoverMoved=!0}pointerLeave(){this.hoverInside&&(this.hoverInside=!1,this.hoverMoved=!0)}get hasHover(){return typeof this.M._creatorWebHover=="function"}tickHover(){if(!this.hasHover||!this.hoverMoved&&!this.dirty)return;this.hoverMoved=!1;const t=this.hoverInside?this.topInteractive(this.hoverX,this.hoverY):null;this.M._creatorWebHover((t==null?void 0:t.id)??0,this.hoverX,this.hoverY)}pointerDown(t,e,s){const r=this.M;r._creatorWeb2dSceneOpen()&&r._creatorWeb2dEmitPointer(0,t,e,s);const i={node:null,scroll:null,backdrop:null,edit:null,global:!1,dismiss:!0,lastX:e,lastY:s,acc:0,scrolling:!1,swallowClick:!1};this.gestures.set(t,i);const o=this.frame();for(let a=o.length-1;a>=0;a--){const c=bt(o[a].tree,e,s,l=>{var h;return((h=this.nodes.get(l.id))==null?void 0:h.editable)??!1});if(c.node){const l=this.nodes.get(c.node.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(c.blocker)break}for(let a=o.length-1;a>=0;a--){const c=o[a],l=bt(c.tree,e,s,d=>{var f;return((f=this.nodes.get(d.id))==null?void 0:f.interactive)??!1}),h=bt(c.tree,e,s,d=>!!d.scroll&&d.scroll.content>(d.scroll.axis==="x"?d.rect.width:d.rect.height)+.5),u=h.node?this.nodes.get(h.node.id)??null:null;if(l.node){const d=this.nodes.get(l.node.id);i.node=d,i.scroll=u,i.dismiss=d.type!=="button",this.setPressed(d,!0),r._creatorWebNodeTouchStart(d.id,t,e,s);return}if(u){i.scroll=u;return}if(l.blocker){i.backdrop=l.outside?this.nodes.get(l.blocker.id)??null:null;return}}i.global=!0,r._creatorWebSceneTouchStart(t,e,s)}pointerMove(t,e,s){const r=this.gestures.get(t);if(!r)return;const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(1,t,e,s);const o=e-r.lastX,a=s-r.lastY;if(r.lastX=e,r.lastY=s,r.acc+=Math.abs(o)+Math.abs(a),!r.edit){if(!r.scrolling&&r.scroll&&r.acc>Bs&&(r.scrolling=!0,r.node&&this.setPressed(r.node,!1)),r.scrolling&&r.scroll){this.scrollBy(r.scroll.id,r.scroll.scrollAxis==="x"?-o:-a);return}i._creatorWebTouchMove(t,e,s,o,a)}}pointerUp(t,e,s){const r=this.gestures.get(t);if(!r)return;this.gestures.delete(t);const i=this.M;i._creatorWeb2dSceneOpen()&&i._creatorWeb2dEmitPointer(2,t,e,s);const o=e-r.lastX,a=s-r.lastY;i._creatorWebTouchEnd(t,e,s,o,a),!r.edit&&(r.scrolling&&r.scroll&&r.scroll.has(qr)&&i._creatorWebNodeEvent(r.scroll.id,Dr),r.dismiss&&!r.scrolling&&this.focused&&this.blurInput(),r.node?(this.setPressed(r.node,!1),!r.scrolling&&!r.swallowClick&&this.topInteractive(e,s)===r.node&&r.node.has(zr)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(es)&&i._creatorWebNodeEvent(r.backdrop.id,Gr):r.global&&(r.scrolling||i._creatorWebSceneTouchClick(t,e,s)))}pointerCancel(t){const e=this.gestures.get(t);if(!e)return;this.gestures.delete(t);const s=this.M;s._creatorWeb2dSceneOpen()&&s._creatorWeb2dEmitPointer(3,t,e.lastX,e.lastY),e.node&&this.setPressed(e.node,!1),s._creatorWebTouchCancel(t)}wheel(t,e,s,r){const i=this.frame();for(let o=i.length-1;o>=0;o--){const a=bt(i[o].tree,t,e,c=>!!c.scroll&&c.scroll.content>(c.scroll.axis==="x"?c.rect.width:c.rect.height)+.5);if(a.node){const c=this.nodes.get(a.node.id);return c?this.scrollBy(c.id,c.scrollAxis==="x"?s:r):!1}if(a.blocker)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Kr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const $s=`
|
|
11
11
|
.lc-field { position: absolute; left: 0; top: 0; margin: 0; border: none; outline: none; background: none; resize: none; box-sizing: border-box; transform-origin: 0 0; pointer-events: auto; overflow: hidden; -webkit-appearance: none; appearance: none; }
|
|
12
12
|
.lc-field::placeholder { color: var(--lc-placeholder, #999); opacity: 1; }
|
|
13
|
-
`,Fe=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Hs=n=>n.type==="native"||n.type==="video",$s=[1,0,0,1,0,0],zt=(n,t)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]],Vs=(n,t)=>{if(!n)return t;const e=Math.max(n.x,t.x),s=Math.max(n.y,t.y);return{x:e,y:s,width:Math.max(0,Math.min(n.x+n.width,t.x+t.width)-e),height:Math.max(0,Math.min(n.y+n.height,t.y+t.height)-s)}};class Ut extends Ds{constructor(e,s,r,i,o={}){super(e,s,o);b(this,"doc");b(this,"factories",new Map);b(this,"versions",new Map);b(this,"views",new Map);b(this,"wrappers",new Map);b(this,"shown",new Map);b(this,"destination",null);b(this,"field",null);b(this,"placedFor",null);b(this,"band",{root:0,height:0});b(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=Ws,i.appendChild(a)}paintOptions(){var e;return{surfaces:!0,editing:(e=this.field)==null?void 0:e.id}}registerView(e,s,r=1){this.factories.set(e,s),this.versions.set(e,r)}unregisterView(e){this.factories.delete(e),this.versions.delete(e)}isViewSupported(e){return this.factories.has(e)}viewVersion(e){return this.versions.get(e)??0}ensureView(e,s,r){const i=this.views.get(e);if(i&&(i.name!==s||i.params!==r))this.destroyView(e);else if(i)return i.handle;const o=this.factories.get(s);if(!o)return null;let a={};try{a=r?JSON.parse(r):{}}catch{}const c=o(a,{emit:(l,h)=>this.M.jsb.viewEvent(e,l,h)},this.doc);return c.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:c}),c}destroyView(e){var r,i;const s=this.views.get(e);s&&(this.views.delete(e),(i=(r=s.handle).destroy)==null||i.call(r),s.handle.el.remove())}viewCall(e,s,r,i,o){const a=this.views.get(e);if(!(a!=null&&a.handle.call)){o(`NativeView call "${s}": no live instance or no call handler (viewId ${e})`);return}try{Promise.resolve(a.handle.call(s,Array.isArray(r)?r:[])).then(c=>{c===void 0?i():i(c)},c=>o(c instanceof Error?c.message:String(c)))}catch(c){o(c instanceof Error?c.message:String(c))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==ut)return;this.dropDestination();const c=this.ensureView(r,i,o);if(!c)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(c.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===ut&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==ut&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return we}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),c=()=>{const l=Math.min(1,(r.performance.now()-a)/we),h=Vn(l);this.setBand(i,l<1?Math.round(o+(s-o)*h):s),l<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,c)=>{let l=a;const h=o.style.transform;if(h){const d=o.style.transformOrigin,f=o.rect.x+(d?d.xPercent?o.rect.width*d.x/100:d.x:o.rect.width/2),g=o.rect.y+(d?d.yPercent?o.rect.height*d.y/100:d.y:o.rect.height/2),m=xn(h,o.style.transformBox,o.rect.width,o.rect.height);l=zt(zt(zt(a,[1,0,0,1,f,g]),m),[1,0,0,1,-f,-g])}(Hs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:c});const u=o.clip?Vs(c,o.rect):c;for(const d of o.children)r(d,l,u)};for(const o of this.frame())r(o.tree,$s,null);return e}static put(e,s){const{rect:r}=s.node,i=e.style;i.position="absolute",i.left="0",i.top="0",i.width=r.width+"px",i.height=r.height+"px",i.transformOrigin="0 0",i.transform=`matrix(${s.matrix.join(",")}) translate(${r.x}px,${r.y}px)`;const o=s.clip;i.clipPath=o?`inset(${Math.max(0,o.y-r.y)}px ${Math.max(0,r.x+r.width-(o.x+o.width))}px ${Math.max(0,r.y+r.height-(o.y+o.height))}px ${Math.max(0,o.x-r.x)}px)`:""}surfaceElement(e){const s=this.get(e.id);if(!s)return null;if(s.type==="video"){const o=ge(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var u,d;const r=s.style,i=e.style,[o,a,c,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${c}px ${l}px ${o}px`,i.color=Fe(r.color,"#000000ff"),i.caretColor=i.color;const h=r.fontFamily??"Roboto";if(i.fontFamily=((d=(u=this.host).resolveFontFamily)==null?void 0:d.call(u,h))??h,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Fe(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const f=r.inputType??"text";e.type!==f&&(e.type=f)}}place(){var r;const e=this.frame();if(e===this.placedFor)return;this.placedFor=e;const s=new Set;for(const i of this.find()){const{node:o}=i;if(o.id===((r=this.field)==null?void 0:r.id)){this.styleField(this.field.el,o),Ut.put(this.field.el,i);continue}const a=this.surfaceElement(o);a&&(s.add(o.id),a.parentElement!==this.under&&this.under.appendChild(a),a.style.display="block",a.style.opacity="",a.style.pointerEvents="auto",a instanceof HTMLVideoElement&&(a.style.objectFit=o.style.objectFit??"contain"),Ut.put(a,i),this.shown.set(o.id,a))}for(const[i,o]of this.shown)s.has(i)||(o.style.display="none",this.shown.delete(i))}surfaceAt(e,s){const r=this.frame();for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.leaving)continue;const a=bt(o.tree,e,s,c=>{var l,h;return c.type==="native"||(((l=this.get(c.id))==null?void 0:l.interactive)??!1)||(((h=this.get(c.id))==null?void 0:h.editable)??!1)||!!c.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function Gs(n,t,e,s){const r=n.createElement("div");r.textContent=e,r.style.cssText="position:absolute;left:50%;bottom:48px;transform:translateX(-50%);max-width:80%;padding:10px 16px;border-radius:8px;background:rgba(30,30,30,0.92);color:#fff;font:13px/1.4 system-ui,sans-serif;z-index:30;pointer-events:none;",t.appendChild(r),setTimeout(()=>r.remove(),s>0?s:2e3)}const js=500,Ne=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],zs=(n,t)=>{const e=n.ownerDocument,{canvas:s}=t;s.style.display="block",s.style.pointerEvents="none",n.style.touchAction="none";const r=s.getContext("2d"),i=()=>{const v=e.createElement("div");return v.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;",v},o=i(),a=i();n.insertBefore(o,s),s.after(a);const c=new Er({resolveAssetUrl:v=>ln(v),canvasSurfaces:t.canvasHost}),l=new Ut(t.M,c,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(v,T)=>Gs(e,n,v,T)});let h=1,u=new Me(r,h),d=!0;const f=()=>{(d||l.needsPaint())&&(d=!1,l.paint(u,l.paintOptions())),l.place()};let g=1;const m=(v,T,O,j=1)=>{if(!(v<=0||T<=0)){O!==h&&(h=O,u=new Me(r,h)),g=j;for(const J of[o,a])Object.assign(J.style,{width:`${v}px`,height:`${T}px`,zoom:g===1?"":String(g)});d=!0,l.resize(v,T)}},x=v=>{l.setSafeArea([v.top,v.right,v.bottom,v.left],v.bars??[])},y=v=>{const T=n.getBoundingClientRect(),O=Ft(n)*g;return[(v.clientX-T.left)/O,(v.clientY-T.top)/O]},p=v=>v.target instanceof Node&&a.contains(v.target),w=v=>v.target instanceof Node&&o.contains(v.target),E=v=>{w(v)&&v.stopPropagation()},k=new Set,L=new Map,C=v=>{const T=L.get(v);T!==void 0&&(clearTimeout(T),L.delete(v))},F=v=>{if(p(v))return;const[T,O]=y(v);if(!l.surfaceAt(T,O)){E(v),k.add(v.pointerId);try{n.setPointerCapture(v.pointerId)}catch{}l.pointerDown(v.pointerId,T,O),C(v.pointerId),L.set(v.pointerId,window.setTimeout(()=>{L.delete(v.pointerId),l.longPress(v.pointerId,T,O)},js))}},U=v=>{const[T,O]=y(v);k.has(v.pointerId)&&(E(v),l.pointerMove(v.pointerId,T,O)),v.pointerType==="mouse"&&(p(v)||!k.has(v.pointerId)&&l.surfaceAt(T,O)?l.pointerLeave():l.pointerHover(T,O))},$=v=>{v.pointerType==="mouse"&&l.pointerLeave()},K=v=>{if(!k.delete(v.pointerId))return;E(v),C(v.pointerId);const[T,O]=y(v);l.pointerUp(v.pointerId,T,O)},G=v=>{k.delete(v.pointerId)&&(C(v.pointerId),l.pointerCancel(v.pointerId))},q=v=>{if(p(v))return;const[T,O]=y(v);if(l.surfaceAt(T,O))return;E(v);const j=v.deltaMode===1?16:v.deltaMode===2?l.height:1;l.wheel(T,O,v.deltaX*j,v.deltaY*j)&&v.preventDefault()},A=v=>{var J;if(p(v))return;const T="clientX"in v?v:(J=v.changedTouches)==null?void 0:J[0];if(!T)return;const[O,j]=y(T);l.surfaceAt(O,j)||(E(v),v.type==="mousedown"&&v.preventDefault())};n.addEventListener("pointerdown",F,!0),n.addEventListener("pointermove",U,!0),n.addEventListener("pointerleave",$),n.addEventListener("pointerup",K,!0),n.addEventListener("pointercancel",G,!0),n.addEventListener("wheel",q,{passive:!1,capture:!0});for(const v of Ne)n.addEventListener(v,A,!0);return{ui:l,render:f,resize:m,setSafeArea:x,destroy(){for(const v of L.keys())C(v);n.removeEventListener("pointerdown",F,!0),n.removeEventListener("pointermove",U,!0),n.removeEventListener("pointerleave",$),n.removeEventListener("pointerup",K,!0),n.removeEventListener("pointercancel",G,!0),n.removeEventListener("wheel",q,!0);for(const v of Ne)n.removeEventListener(v,A,!0);l.dispose(),o.remove(),a.remove()}}},Ks=["miter","round","bevel"],Xs=["butt","round","square"],Ys=["left","center","right","start","end"],qs=["alphabetic","top","middle","bottom","hanging","ideographic"],Ue=["nonzero","evenodd"],Js=["pad","reflect","repeat"],Kt={COLOR:0,RADIAL:2},St={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},X={SET_TRANSFORM:0,SAVE:1,RESTORE:2,CLIP:3,FILL_PATH:4,STROKE_PATH:5,FILL_TEXT:6,STROKE_TEXT:7,DRAW_IMAGE:8,CLEAR_RECT:9};class Qs{constructor(t,e){b(this,"pos",0);this.w=t,this.strings=e}f(){if(this.pos>=this.w.length)throw new Error("draw list: truncated");return this.w[this.pos++]}i(){return this.f()|0}str(){const t=this.i();if(t<0||t>=this.strings.length)throw new Error(`draw list: bad string index ${t}`);return this.strings[t]}color(){return[this.f(),this.f(),this.f(),this.f()]}matrix(){return[this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]}paint(){const t=this.i(),e=this.f();if(t===Kt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Kt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Js[this.i()]??"pad",c=this.i(),l=[];for(let h=0;h<c;h++)l.push({offset:this.f(),color:this.color()});return t===Kt.RADIAL?{kind:"radial",alpha:e,matrix:s,fx:r,fy:i,r0:o,spread:a,stops:l}:{kind:"linear",alpha:e,matrix:s,spread:a,stops:l}}stroke(){const t=this.f(),e=Ks[this.i()]??"miter",s=Xs[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let c=0;c<o;c++)a.push(this.f());return{width:t,join:e,cap:s,miterLimit:r,dashOffset:i,dash:a}}font(){return{family:this.str(),size:this.f(),weight:this.i(),italic:this.i()!==0}}path(){const t=this.i(),e=this.pos+t;if(e>this.w.length)throw new Error("draw list: truncated path");const s=[];for(;this.pos<e;)switch(this.i()){case St.MOVE:s.push(["M",this.f(),this.f()]);break;case St.LINE:s.push(["L",this.f(),this.f()]);break;case St.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case St.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case St.CLOSE:s.push(["Z"]);break;default:throw new Error("draw list: bad path verb")}return s}rect4(){return[this.f(),this.f(),this.f(),this.f()]}}const Zs=(n,t)=>{const e=new Qs(n,t),s=[];for(;e.pos+2<=n.length;){const r=e.i(),i=e.i(),o=e.pos+i;if(i<0||o>n.length)throw new Error("draw list: truncated command");switch(r){case X.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case X.SAVE:s.push({cmd:"save"});break;case X.RESTORE:s.push({cmd:"restore"});break;case X.CLIP:{const a=Ue[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Ue[e.i()]??"nonzero",c=e.paint();s.push({cmd:"fillPath",rule:a,paint:c,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),c=e.paint();s.push({cmd:"strokePath",stroke:a,paint:c,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),c=e.f(),l=e.f(),h=e.f(),u=e.font(),d=Ys[e.i()]??"start",f=qs[e.i()]??"alphabetic",g=e.f();if(r===X.STROKE_TEXT){const m=e.stroke();s.push({cmd:"strokeText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,stroke:m,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),c=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:c,dst:l,alpha:e.f()});break}case X.CLEAR_RECT:s.push({cmd:"clearRect",rect:e.rect4()});break}if(e.pos!==o){if(e.pos>o)throw new Error(`draw list: command ${r} overran its length`);e.pos=o}}return s},ti=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),kn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,Tn=(n,t=n.family)=>{const e=ti.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Pt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],ei=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Xt=(n,t)=>{n.beginPath();for(const e of t)switch(e[0]){case"M":n.moveTo(e[1],e[2]);break;case"L":n.lineTo(e[1],e[2]);break;case"Q":n.quadraticCurveTo(e[1],e[2],e[3],e[4]);break;case"C":n.bezierCurveTo(e[1],e[2],e[3],e[4],e[5],e[6]);break;case"Z":n.closePath();break}},Be=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,kn(e.color))},Ot=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=kn(t.color),s();return}const r=t.matrix;if(ei(r)){let o;if(t.kind==="linear"){const[a,c]=Pt(r,0,0),[l,h]=Pt(r,1,0);o=n.createLinearGradient(a,c,l,h)}else{const a=Math.hypot(r[0],r[1]),[c,l]=Pt(r,0,0),[h,u]=Pt(r,t.fx,t.fy);o=n.createRadialGradient(h,u,t.r0*a,c,l,a)}Be(o,t),n[e==="fill"?"fillStyle":"strokeStyle"]=o,s();return}n.save(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]);const i=t.kind==="linear"?n.createLinearGradient(0,0,1,0):n.createRadialGradient(t.fx,t.fy,t.r0,0,0,1);Be(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},De=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},We=(n,t,e)=>{n.font=Tn(t.font,e.fontFamily?e.fontFamily(t.font.family):t.font.family),n.textAlign=t.align,n.textBaseline=t.baseline,"letterSpacing"in n&&(n.letterSpacing=`${t.letterSpacing}px`)},ni=(n,t,e={})=>{var r;n.save();let s=0;try{n.setTransform(1,0,0,1,0,0),n.globalAlpha=1;for(const i of t)switch(i.cmd){case"setTransform":n.setTransform(i.matrix[0],i.matrix[1],i.matrix[2],i.matrix[3],i.matrix[4],i.matrix[5]);break;case"save":n.save(),s++;break;case"restore":s>0&&(n.restore(),s--);break;case"clip":Xt(n,i.path),n.clip(i.rule);break;case"fillPath":Xt(n,i.path),Ot(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Xt(n,i.path),De(n,i.stroke),Ot(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":We(n,i,e),Ot(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":We(n,i,e),De(n,i.stroke),Ot(n,i.paint,"stroke",()=>i.maxWidth>0?n.strokeText(i.text,i.x,i.y,i.maxWidth):n.strokeText(i.text,i.x,i.y));break;case"drawImage":{const o=(r=e.image)==null?void 0:r.call(e,i.surface);if(!o)break;n.globalAlpha=i.alpha,n.drawImage(o,i.src[0],i.src[1],i.src[2],i.src[3],i.dst[0],i.dst[1],i.dst[2],i.dst[3]);break}case"clearRect":n.clearRect(i.rect[0],i.rect[1],i.rect[2],i.rect[3]);break;default:{const o=i;throw new Error(`unhandled draw command ${o.cmd}`)}}}finally{for(;s>0;s--)n.restore();n.restore()}},ri=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,h,u)=>{if(!t)return null;let d=e.get(l);return d?(d.width!==h||d.height!==u)&&(d.width=h,d.height=u):(d=new OffscreenCanvas(h,u),e.set(l,d)),d},i={paint:(l,h,u,d,f,g)=>{const m=r(l,Math.max(1,h),Math.max(1,u)),x=m==null?void 0:m.getContext("2d");!m||!x||(x.setTransform(1,0,0,1,0,0),x.clearRect(0,0,m.width,m.height),ni(x,Zs(f,g),{image:y=>e.get(y)??null,fontFamily:n}))},measureText:(l,h,u,d,f,g)=>{if(g[0]=0,g[1]=0,g[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=Tn({family:h,size:u,weight:d,italic:f},h);const m=s.measureText(l);g[0]=m.width,g[1]=m.fontBoundingBoxAscent??m.actualBoundingBoxAscent,g[2]=m.fontBoundingBoxDescent??m.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,h)=>{const u=o(l);return u?(h[0]=u.width,h[1]=u.height,new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const h=e.get(l),u=h==null?void 0:h.getContext("2d");return!h||!u?null:{data:u.getImageData(0,0,h.width,h.height).data,width:h.width,height:h.height}};return{table:i,readSurface:o,getSurface:l=>{const h=e.get(l);return h?{canvas:h,width:h.width,height:h.height}:null},surfaceToDataUrl:l=>{var d;const h=e.get(l);if(!h||typeof document>"u")return null;const u=document.createElement("canvas");return u.width=h.width,u.height=h.height,(d=u.getContext("2d"))==null||d.drawImage(h,0,0),u.toDataURL()}}},si=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,ii=(n,t="woff2")=>{const e=/^\/\/ fonts: (.+)$/m.exec(n);if(!e)return[];const s=[];for(const r of e[1].split(";")){const i=r.indexOf("=");if(i===-1)continue;const o=/^(.+)@(\d+)(i?)$/.exec(r.slice(0,i));o&&s.push({family:o[1],weight:parseInt(o[2],10),italic:o[3]==="i",url:r.slice(i+1).replace("{fmt}",t)})}return s},oi=async(n,t,e=2e3)=>{const s=t??(typeof document>"u"?void 0:document);if(!(s!=null&&s.fonts)||n.length===0)return;const r=[];for(const i of n)try{const o=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});s.fonts.add(o),r.push(o.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(r),new Promise(i=>setTimeout(i,e))])},Rn="Roboto",ai=[`400 14px ${Rn}`],He="data-lecodes-fonts",ci=async(n=ai,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${He}]`)){const s=new URL(si,document.baseURI).href,r=e.createElement("style");r.setAttribute(He,""),r.textContent=`@font-face{font-family:"${Rn}";src:url("${s}") format("woff2");font-weight:100 900;font-display:swap}`,e.head.appendChild(r)}try{await Promise.all(n.map(s=>e.fonts.load(s)))}catch{}}},$e="2.5.1",Yt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},li=(n,t)=>Yt(n)!==null&&Yt(n)===Yt(t),hi=()=>({setMatrix(){},setVisible(){},setCameraMatrix(){},setProjection(){},clearProjection(){},setBackground(){},createExternalTexture:()=>null,onFrame:()=>()=>{},readPixels:(n,t)=>t(null,0,0),viewport:()=>({width:0,height:0,rotation:0})}),ui=n=>{var s,r;const t=((r=(s=n.screen)==null?void 0:s.orientation)==null?void 0:r.angle)??n.orientation??0;return(Math.round(t/90)%4+4)%4*90},di=(n,t)=>({width:(n==null?void 0:n.clientWidth)??0,height:(n==null?void 0:n.clientHeight)??0,rotation:ui(t)}),fi=[1,0,0,0,1,0],gi=(n,t,e)=>{const s=t*4,r=new Uint8Array(s);for(let i=0,o=e-1;i<o;i++,o--)r.set(n.subarray(i*s,i*s+s)),n.copyWithin(i*s,o*s,o*s+s),n.set(r,o*s);return n},pi=[171,75,84,88,32,50,48,187,13,10,26,10],mi=n=>n.length>=12&&pi.every((t,e)=>n[e]===t),yi=(n,t)=>{const e={antialias:!1,depth:!0,alpha:!1,stencil:!1,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:t},s=n.newCanvas(),r=s.getContext("webgl2",e);if(!r)throw new Error("WebGL2 is not available");let i=null,o=!1;const a=[],c=()=>{const u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),u},l=u=>{var g;u._creatorWebSetViewport(s.width,s.height);const{width:d,height:f}=n.size();d>0&&f>0&&((g=u._setDensityGL)==null||g.call(u,s.width/d,s.height/f))},h=(u,d,f,g)=>{const m=u.GL.getNewId(u.GL.textures);return u.GL.textures[m]=d,u._importTexture(m,f,g)>>>0};return{canvas:s,context:r,options:e,table(u){return i=u,{engineCreated(){a.length=0,u._createSwapChainHeadless(s.width,s.height),l(u),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(d,f,g,m){const x=et(d);if(!x){m(`createTexture: no buffer behind id ${d}`);return}const y=new Uint8Array(x);if(mi(y)){const p=u._malloc(y.length);u.HEAPU8.set(y,p);const w=u._createTextureFromKtx2(p,y.length)>>>0;if(u._free(p),w===4294967295){m("KTX2 transcode failed");return}g(w,u._getTextureWidth(w),u._getTextureHeight(w));return}createImageBitmap($t(d)).then(p=>{const w=c();r.texStorage2D(r.TEXTURE_2D,1,f&1?r.RGBA8:r.SRGB8_ALPHA8,p.width,p.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,p.width,p.height,r.RGBA,r.UNSIGNED_BYTE,p),g(h(u,w,p.width,p.height),p.width,p.height)},p=>m(p instanceof Error?p.message:String(p)))},createMediaPlayerTexture(d){const f=ge(d);if(!f)return 0;const g=c(),m=h(u,g,0,0);return a.push({video:f,texture:g,id:m,lastTime:0}),m}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&l(i)},frame(){for(const u of a)u.video.readyState<2||u.video.currentTime===u.lastTime||(u.lastTime=u.video.currentTime,r.bindTexture(r.TEXTURE_2D,u.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,u.video))},videoTexture(u){const d=a.find(m=>m.video===u);if(d)return d.id;if(!i||!o)return;const f=c(),g=h(i,f,0,0);return a.push({video:u,texture:f,id:g,lastTime:0}),g},readPixels(){const u=r.drawingBufferWidth,d=r.drawingBufferHeight;if(!o||u===0||d===0)return null;const f=new Uint8Array(u*d*4),g=r.getParameter(r.READ_FRAMEBUFFER_BINDING);return r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.readPixels(0,0,u,d,r.RGBA,r.UNSIGNED_BYTE,f),r.bindFramebuffer(r.READ_FRAMEBUFFER,g),{rgba:gi(f,u,d),width:u,height:d}},destroy(){var u;a.length=0,(u=r.getExtension("WEBGL_lose_context"))==null||u.loseContext()}}},wi=n=>{const t={alpha:!1,depth:!0,stencil:!0,antialias:!1,premultipliedAlpha:!1,desynchronized:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1},e=n.newCanvas(),s=e.getContext("webgl2",t);if(!s)throw new Error("WebGL2 is not available");let r=null,i=!1;const o=()=>{!r||!i||(r._c2dSetViewport(e.width,e.height),r._c2dSetDensity(n.size().factor))},a=()=>{r&&(r._creatorWeb2dEnsureInited(),i=!0,o(),e.style.display="block")},c=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:c}},show:a,hide:c,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ve=n=>{if(typeof n=="number"||typeof n=="bigint"||typeof WebAssembly<"u"&&n instanceof WebAssembly.RuntimeError)return!0;const t=n instanceof Error?n.stack??"":"";return/\bwasm\b|wasm-function|\.wasm/i.test(t)},Ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",An={};for(let n=0;n<Ge.length;n++)An[Ge[n]]=n;const bi=n=>{const t=[];let e=0,s=0;for(const r of n){const i=An[r];if(i===void 0)break;const o=i&32;if(s+=(i&31)<<e,o)e+=5;else{const a=s&1;s>>=1,t.push(a?-s:s),s=0,e=0}}return t};class vi{constructor(t){b(this,"sources");b(this,"lines");this.sources=t.sources,this.lines=[];let e=0,s=0,r=0;for(const i of t.mappings.split(";")){const o=[];let a=0;if(i)for(const c of i.split(",")){const l=bi(c);l.length!==0&&(a+=l[0],l.length>=4&&(e+=l[1],s+=l[2],r+=l[3],o.push([a,e,s,r])))}this.lines.push(o)}}originalPositionFor(t,e){const s=this.lines[t-1];if(!s||s.length===0)return null;let r=null;for(const o of s)if(o[0]<=e)r=o;else break;r??(r=s[0]);const i=this.sources[r[1]];return i===void 0?null:{source:i,line:r[2]+1,column:r[3]}}}const xi=n=>{const t=n.match(/\/\/# lecodesMap=data:application\/json;(?:charset=[^;]+;)?base64,([A-Za-z0-9+/=]+)\s*$/);if(!t)return null;try{const e=typeof atob=="function"?atob(t[1]):Buffer.from(t[1],"base64").toString("utf8");return new vi(JSON.parse(e))}catch{return null}};let wt=null;const Ei=()=>{if(wt!==null)return wt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return wt=e?parseInt(e[1],10)-1:2,wt}return wt=2,wt},qt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Ei(),r=[];for(const i of e.split(`
|
|
14
|
-
`)){const o=i.match(/<anonymous>:(\d+):(\d+)/);if(!o)continue;const a=parseInt(o[1],10)-s,c=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,c<0?0:c);if(!l)continue;const h=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:h?h[1]:null,source:l.source,line:l.line,column:l.column})}return r},
|
|
15
|
-
`);console.error(`[lecodes] native engine error — ${p||
|
|
16
|
-
at ${g.source}:${g.line}:${g.column}${g.fn?` (${g.fn})`:""}`:`[lecodes] ${f}`),(x=l.onError)==null||x.call(l,{message:f,frames:u,stack:h instanceof Error?h.stack:void 0})},r=(l,h)=>{for(let d=e.length-1;d>=0;d--){const f=e[d];if(!f.sourceMap)continue;const g=qt(l,f.sourceMap);if(g.length>0)return s(f,l,g,h)}const u=e[e.length-1];u&&
|
|
17
|
-
`),s(l,u,l.sourceMap?qt(u,l.sourceMap):[])},a=l=>r(l.error??l.message,l.message),c=l=>r(l.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",c),{track(l,h){const u={sourceMap:
|
|
18
|
-
`);return i={message:(u??"").replace(/^JsTask /,""),stack:d},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",c),e.length=0}}},Mn=n=>{var c,l,h,u;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const d of s[1].split(";"))e.add(d);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((c=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:c[1])??null,o=((h=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:h.trim())??null,a=new Set((((u=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:u[1])??"").split(";").map(d=>d.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:ii(t)}},ki=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",je=(n,t)=>Math.max(1,Math.round(n/t*1e3)/1e3),Ti=(n,t=1)=>{const e=n.ownerDocument,s=e.defaultView??window;let r=t>0?t:1,i=1/0;const o=(y,p)=>{const w=(s.devicePixelRatio||1)*Ft(n),E=Math.min(i,w*r),k=je(y,r),L=je(p,r);return{width:k,height:L,factor:E,scale:r,pixelWidth:Math.max(1,Math.round(k*E)),pixelHeight:Math.max(1,Math.round(L*E))}};let a=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const c=[],l=y=>{y.width!==a.pixelWidth&&(y.width=a.pixelWidth),y.height!==a.pixelHeight&&(y.height=a.pixelHeight)},h=()=>{const y=e.createElement("canvas");return y.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(y),l(y),c.push(y),y},u=new Set,d=y=>{if(!(y.width<=0||y.height<=0)){a=y;for(const p of c)l(p);for(const p of u)p(a)}};let f=null;const g=(y,p,w)=>{const E=o(y,p),k=w&&Math.abs(w.inlineSize-E.width*E.factor)<=1&&Math.abs(w.blockSize-E.height*E.factor)<=1;if(!w||!k){d(E);return}d({...E,pixelWidth:Math.max(1,w.inlineSize),pixelHeight:Math.max(1,w.blockSize)})},m=new ResizeObserver(([y])=>{var k;if(!y)return;const{width:p,height:w}=y.contentRect,E=((k=y.devicePixelContentBoxSize)==null?void 0:k[0])??null;f={width:p,height:w,device:E},g(p,w,E)});try{m.observe(n,{box:"device-pixel-content-box"})}catch{m.observe(n)}const x=y=>{y!==void 0&&(i=y>0?y:1/0);const p=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==a.pixelWidth||p.pixelHeight!==a.pixelHeight||p.factor!==a.factor||p.width!==a.width||p.height!==a.height)&&d(p)};return{root:n,doc:e,win:s,size:()=>a,scale:()=>r,newCanvas:h,remeasure:x,setScale(y){!(y>0)||y===r||(r=y,f?g(f.width,f.height,f.device):x())},onResize(y){return u.add(y),()=>{u.delete(y)}},destroy(){m.disconnect(),u.clear();for(const y of c)y.remove();c.length=0}}},Ri=n=>{const t=new Map;let e=0,s=[];const r=new Set,i=c=>{r.has(c)||(r.add(c),console.warn(`[web-host] gl.${c}: this host's engine has no such call yet (a runtime module of an older build) — ignored`))},o=c=>Float32Array.from(c);return{facade:n?{setMatrix(c,l){var h;(h=n.creator())==null||h.setWorldMatrix(c,o(l))},setVisible(c,l){var h;(h=n.creator())==null||h.setVisible(c,l)},setCameraMatrix(c,l){var u;const h=n.creator();if(h&&!h.setCameraMatrix)return i("setCameraMatrix");(u=h==null?void 0:h.setCameraMatrix)==null||u.call(h,c,o(l))},setProjection(c,l,h,u){var f;const d=n.creator();if(d&&!d.setCameraProjectionMatrix)return i("setProjection");(f=d==null?void 0:d.setCameraProjectionMatrix)==null||f.call(d,c,o(l),h,u)},clearProjection(c){var l,h;(h=(l=n.creator())==null?void 0:l.clearCameraProjectionMatrix)==null||h.call(l,c)},setBackground(c,l,h=fi){const u=n.creator();if(!u)return;if(!u.setSceneBackground||!n.surface)return i("setBackground");l&&l.nodeName!=="VIDEO"&&!r.has("setBackground(canvas)")&&(r.add("setBackground(canvas)"),console.warn("[web-host] gl.setBackground: the web player shows a video background only — a canvas is not shown (Web Lite shows it)"));const d=(l==null?void 0:l.nodeName)==="VIDEO"?l:null,f=d?n.surface.videoTexture(d):void 0;u.setSceneBackground(c,f??4294967295,Float32Array.from(h))},createExternalTexture:()=>null,onFrame(c){const l=e++;return t.set(l,c),()=>{t.delete(l)}},readPixels(c,l){if(!n.surface||n.presented()!==c){l(null,0,0);return}s.push({scene:c,then:l})},viewport:()=>di(n.view,n.view.ownerDocument.defaultView??window)}:hi(),before(){if(t.size!==0)for(const c of[...t.values()])c()},after(){if(s.length===0||!(n!=null&&n.surface))return;const c=n.presented(),l=s.filter(u=>u.scene===c);for(const u of s)u.scene!==c&&u.then(null,0,0);if(s=l,l.length===0||!n.frameRendered())return;s=[];const h=n.surface.readPixels();for(const u of l)h?u.then(h.rgba.slice(),h.width,h.height):u.then(null,0,0)},worldChanged(){t.clear();const c=s;s=[];for(const l of c)l.then(null,0,0)}}},Ai=(n,t)=>{const e=[],s=new Set;return{has:r=>s.has(r),register(r,i){s.has(r)||(s.add(r),i({registerView:(o,a,c=1)=>{e.push({id:r,version:c,kind:"view",name:o,factory:a})},registerService:(o,a,c=1)=>{e.push({id:r,version:c,kind:"service",name:o,factory:a})},putBuffer:ft,getBuffer:et,gl:t}))},allow(r){var o,a;const i=new Set(r);for(const c of e){const l=i.has(c.id);c.kind==="view"?l?(o=n.registerView)==null||o.call(n,c.name,c.factory,c.version):(a=n.unregisterView)==null||a.call(n,c.name):l?n.registerService(c.name,c.factory,c.version):n.unregisterService(c.name)}}}},Mi=n=>{const t=n.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);",n.appendChild(t);const e=i=>Math.round(parseFloat(i)||0),s=()=>{const i=getComputedStyle(t);return{top:e(i.paddingTop),right:e(i.paddingRight),bottom:e(i.paddingBottom),left:e(i.paddingLeft)}};let r=null;return{set(i){r=i},current:()=>r??s(),destroy(){t.remove()}}},Li={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-cards":"world",grass:"world","foliage-impostor":"world"},ze="material:",Pi=n=>{const t=new Set;for(const e of n)e.startsWith(ze)&&t.add(Li[e.slice(ze.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},Oi=""+new URL("assets/materials-Cs_z1zLi.bin",import.meta.url).href,Ci=""+new URL("assets/materials-world-BtoAfznA.bin",import.meta.url).href,Ii=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,Fi=""+new URL("assets/uberarchive-Ok2HfJvn.bin",import.meta.url).href,Ni={base:Oi,world:Ci},Ui=n=>{const t=new Uint8Array(n.reduce((s,r)=>s+r.byteLength,0));let e=0;for(const s of n)t.set(new Uint8Array(s),e),e+=s.byteLength;return t.buffer},Bi=async n=>{const t=async o=>{const a=await fetch(o);if(!a.ok)throw new Error(`${o} → HTTP ${a.status}`);return a.arrayBuffer()},e=Pi(n).map(o=>Ni[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(Ii),t(Fi),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:Ui(i)}:{}}},Di=n=>{const t=()=>n.push(document.hidden?"pause":"resume"),e=()=>n.push("online"),s=()=>n.push("offline");return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),window.addEventListener("offline",s),{table:{state:()=>document.hidden?"background":"active",isOnline:()=>navigator.onLine,openUrl(i){window.open(i,"_blank","noopener")},worldChange(){var i;(i=n.onWorldChange)==null||i.call(n)},setOrientation(i){var c,l,h,u;const o=i==="landscape"||i==="portrait"?i:"auto";if(n.onOrientation){n.onOrientation(o);return}const a=typeof screen<"u"?screen.orientation:void 0;if(a)try{o==="auto"?(c=a.unlock)==null||c.call(a):(u=(h=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:h.catch)==null||u.call(h,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},Wi=(n,t,e,s)=>{try{const r=document.createElement("input");r.type="file",r.multiple=e,s&&(r.accept=s),r.onchange=async()=>{const{files:i}=r;if(e){const o=[];if(!i)return n([]);for(let a of i)o.push([ft(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ft(await i[0].arrayBuffer()),i[0].name,i[0].size]])}},window.addEventListener("focus",()=>{setTimeout(()=>{(!r.files||r.files.length===0)&&n(e?[]:null)},300)},{once:!0}),r.click()}catch(r){t(r)}},Ln=n=>n==="camera"?"camera":n==="microphone"||n==="speech"?"microphone":n==="location"?"geolocation":null,Pn=(n,t,e)=>{const s=Ln(n);if(!s){e(`${n}: not a permission this host asks for`);return}const r=navigator.permissions;if(!(r!=null&&r.query)){t("prompt");return}r.query({name:s}).then(i=>t(i.state),()=>t("prompt"))},Hi=(n,t,e)=>{if(!Ln(n)){e(`${n}: not a permission this host asks for`);return}const s=()=>Pn(n,t,e);if(n==="location"){if(!navigator.geolocation){t("denied");return}navigator.geolocation.getCurrentPosition(()=>t("granted"),i=>i.code===i.PERMISSION_DENIED?t("denied"):s(),{timeout:15e3,maximumAge:1/0});return}const r=navigator.mediaDevices;if(!(r!=null&&r.getUserMedia)){t("denied");return}r.getUserMedia(n==="camera"?{video:!0}:{audio:!0}).then(i=>{for(const o of i.getTracks())o.stop();t("granted")},i=>{const o=i instanceof Error?i.name:"";o==="NotAllowedError"||o==="SecurityError"?t("denied"):s()})},$i=(n,t)=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return(t==null?void 0:t())||window.devicePixelRatio||1},vibrate(){var e;try{(e=navigator.vibrate)==null||e.call(navigator,30)}catch{}},clipboardWrite(e){var s;(s=navigator.clipboard)==null||s.writeText(e).catch(()=>{})},clipboardRead(e,s){const r=navigator.clipboard;if(!(r!=null&&r.readText)){s("Clipboard is not available");return}r.readText().then(e,i=>s(i instanceof Error?i.message:"Clipboard read failed"))},share(e){const s=URL.createObjectURL($t(e)),r=document.createElement("a");r.href=s,r.download="image.png",document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},openFilePicker:(e,s,r,i)=>Wi(e,s,r,i??void 0),queryPermission:Pn,requestPermission:Hi}),Vi=(n={})=>({local:t=>gr(t),dispose:t=>hr(t),request(t,e,s,r,i,o,a,c){if(t.startsWith("id:")){const u=Number(t.slice(3));o(u,et(u)?200:404);return}const l={};for(let u=0;u+1<s.length;u+=2)l[s[u]]=s[u+1];let h;if(i.length>0){const u=new FormData;for(const d of i)d.key!==null&&(d.bufferId>0?u.append(d.key,$t(d.bufferId),d.filename??void 0):u.append(d.key,d.value??""));h=u}else r!==null&&(h=r);(async()=>{var u;try{const d=await fetch(t,{method:e,headers:l,body:h,mode:"cors",credentials:"omit"}),f=c?(u=d.body)==null?void 0:u.getReader():void 0;if(!f){o(ft(await d.arrayBuffer()),d.status);return}const g=Number(d.headers.get("content-length"))||void 0,m=[];let x=0;for(;;){const{done:w,value:E}=await f.read();if(w)break;E&&(m.push(E),x+=E.length,c({loaded:x,total:g}))}const y=new Uint8Array(x);let p=0;for(const w of m)y.set(w,p),p+=w.length;o(ft(y.buffer),d.status)}catch(d){a(d instanceof Error?d.message:String(d))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ft(t.slice().buffer),bufferSlice(t,e,s){const r=et(t);if(!r)return null;const i=Math.max(0,Math.min(e,r.byteLength)),o=Math.max(i,Math.min(s,r.byteLength));return new Uint8Array(r,i,o-i)},systemBuffer:t=>{const e=n[t];return e?new Uint8Array(e):null}}),Ke=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Jt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Ct=4,Qt=16,Xe=16,Gi=.5,ji=n=>{const t=new Set;let e=null;const s=(_,M,N=-1,P=0)=>{e==null||e(_,M,N,P)},r=_=>{if(!_.code)return;const M=t.has(_.code);t.add(_.code),s(0,_.code,-1,M||_.repeat?1:0)},i=_=>{_.code&&t.delete(_.code)&&s(1,_.code)},o=()=>{for(const _ of[...t])_.startsWith("Gamepad")||(t.delete(_),s(1,_))},{root:a}=n;let c=0,l=0,h=0,u=0,d=0,f=0,g=0,m=0,x=0,y=0;const p=_=>{var P;if(_.pointerType&&_.pointerType!=="mouse")return;const M=a.getBoundingClientRect(),N=((P=n.scale)==null?void 0:P.call(n))||1;c=(_.clientX-M.left)/N,l=(_.clientY-M.top)/N,h+=(_.movementX||0)/N,u+=(_.movementY||0)/N},w=_=>{const M=Ke[_.button];M&&(t.add(M),s(0,M))},E=_=>{const M=Ke[_.button];M&&t.delete(M)&&s(1,M)},k=_=>{const M=_.deltaMode===0?.01:1;d+=_.deltaX*M,f+=_.deltaY*M},L=_=>{document.pointerLockElement===a&&_.preventDefault()},C=[],F=[],U=[],$=()=>{var M,N;const _=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let P=0;P<Ct;P++){const rt=_[P]??null,Q=!!rt&&rt.connected;if(Q!==!!C[P]){if(C[P]=Q,!Q){for(const D of Jt)t.delete(D+"@"+P)&&(s(1,D,P),K(D));U[P]=[],F[P]=[0,0,0,0,0,0]}s(Q?2:3,"",P)}if(!rt||!Q)continue;const ct=rt.axes,pt=rt.buttons,Rt=((M=pt[6])==null?void 0:M.value)??0,S=((N=pt[7])==null?void 0:N.value)??0;F[P]=[ct[0]??0,ct[1]??0,ct[2]??0,ct[3]??0,Rt,S];const I=U[P]??(U[P]=[]);for(let D=0;D<Jt.length;D++){const Z=pt[D],st=!!Z&&(Z.pressed||Z.value>Gi);if(st===!!I[D])continue;I[D]=st;const At=Jt[D];st?t.add(At+"@"+P):t.delete(At+"@"+P),K(At),s(st?0:1,At,P)}}},K=_=>{let M=!1;for(let N=0;N<Ct&&!M;N++)t.has(_+"@"+N)&&(M=!0);M?t.add(_):t.delete(_)};let G=0;const q=()=>{g=h,m=u,x=d,y=f,h=u=d=f=0,$(),G=requestAnimationFrame(q)},A=n.windows.filter((_,M,N)=>_&&N.indexOf(_)===M);for(const _ of A)n.keyboard!==!1&&(_.addEventListener("keydown",r),_.addEventListener("keyup",i)),_.addEventListener("blur",o);return a.addEventListener("pointermove",p,!0),a.addEventListener("mousedown",w,!0),window.addEventListener("mouseup",E,!0),a.addEventListener("wheel",k,{passive:!0,capture:!0}),a.addEventListener("contextmenu",L,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(q)),{inputKey:(_,M)=>M>=0&&_.startsWith("Gamepad")?t.has(_+"@"+M):t.has(_),inputRead:_=>{var M;switch(_){case 0:return c;case 1:return l;case 2:return g;case 3:return m;case 4:return x;case 5:return y;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let P=0;P<Ct;P++)C[P]&&N++;return N}}if(_>=Qt){const N=Math.floor((_-Qt)/Xe),P=(_-Qt)%Xe;return N>=Ct||!C[N]?0:P===0?1:((M=F[N])==null?void 0:M[P-1])??0}return 0},inputSetPointerLock:_=>{if(!_)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const M=a.requestPointerLock({unadjustedMovement:!0});return M&&typeof M.catch=="function"&&M.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:_=>{e=_},dispose:()=>{for(const _ of A)_.removeEventListener("keydown",r),_.removeEventListener("keyup",i),_.removeEventListener("blur",o);a.removeEventListener("pointermove",p,!0),a.removeEventListener("mousedown",w,!0),window.removeEventListener("mouseup",E,!0),a.removeEventListener("wheel",k,!0),a.removeEventListener("contextmenu",L,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},zi=n=>{const t=ji(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},Ki={createVideo:Rr,createAudio:Ar,setVolume:Mr,setPlaying:Lr,setLoop:Pr,time:Or,setTime:Cr,duration:Ir,remove:Fr},Xi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(d,f,g=1)=>{n.set(d,f),t.set(d,g)},unregisterService:d=>{n.delete(d),t.delete(d)},isServiceSupported:d=>n.has(d),serviceVersion:d=>t.get(d)??0,serviceOpen:(d,f,g)=>{const m=n.get(d);if(!m)return-1;const x=s++,y=m(f?JSON.parse(f):{},{emit:(p,w)=>{w===void 0?g(p):g(p,w)}});return e.set(x,y),x},serviceCall:(d,f,g,m,x)=>{const y=e.get(d);if(!(y!=null&&y.call)){x(`Service call "${f}": no live session or no call handler (serviceId ${d})`);return}try{Promise.resolve(y.call(f,Array.isArray(g)?g:[])).then(p=>{p===void 0?m():m(p)},p=>x(p instanceof Error?p.message:String(p)))}catch(p){x(p instanceof Error?p.message:String(p))}},serviceClose:d=>{var f,g;(g=(f=e.get(d))==null?void 0:f.close)==null||g.call(f),e.delete(d)},destroy:()=>{var d;for(const f of e.values())(d=f.close)==null||d.call(f);e.clear()}}},Yi=()=>{const n=Xi();return{table:{supported:n.isServiceSupported,version:n.serviceVersion,open:n.serviceOpen,call:n.serviceCall,close:n.serviceClose},registerService:n.registerService,unregisterService:n.unregisterService,dispose:n.destroy}},qi=()=>{const n=[];return{table:{open(e,s){const r=new WebSocket(e);return r.addEventListener("open",()=>s("open")),r.addEventListener("message",i=>s("message",i.data)),r.addEventListener("close",i=>s("close",i.code)),r.addEventListener("error",()=>s("error")),n.push(r),n.length-1},send(e,s){var r;(r=n[e])==null||r.send(s)},close(e){var s;(s=n[e])==null||s.close()}},dispose(){for(const e of n)e.readyState===WebSocket.OPEN&&e.close();n.length=0}}},Ji=n=>{const t=e=>`lecodes:${n}:${e}`;return{load(e){try{return window.localStorage.getItem(t(e))}catch{return null}},save(e,s){try{window.localStorage.setItem(t(e),s)}catch{}}}},Ye=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},Qi={fetch:lr,getBuffer:et,getBlob:$t,putBuffer:ft,putLocalBuffer:ur,hasLocalBuffer:dr,getLocalName:fr,getPlayer:ge,removePlayers:yn},Zi=(n,t)=>({nodeFactory(){},setPropertyString(){},setPropertyInt(){},setFlags(){},insertNode(){},removeNode(){},releaseNode(){},openView(e,s,r){n(e,r)},dropView(e,s,r){t(e,r)},closeView(){n(-1,0)},layerOpen(){},layerClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),to=async(n,t={})=>{var Rt;const e=t.header,s=t.profile??(e?ki(e):"full"),r=(e==null?void 0:e.preloads)??new Set,i=t.ui!==!1,o=s==="full",a=s==="2d"||s==="full"&&!!(e!=null&&e.is2d),c=Ti(n,t.scale??1),{doc:l,win:h}=c,u=i?Promise.all([ci(void 0,l),oi((e==null?void 0:e.bootFonts)??[],l)]):null,d=o?yi(c,r.has("capture")):null,f=a?wi(c):null,g=i?c.newCanvas():null,m=_i(h,o);o&&cr();const[x,y]=await Promise.all([Xn(s,{glContext:d==null?void 0:d.context,glOptions:d==null?void 0:d.options,gl2dContext:f==null?void 0:f.context,gl2dOptions:f==null?void 0:f.options,moduleArgs:{print:S=>{m.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?Bi(r):Promise.resolve({})]),p=(S,I)=>{const D=x.stringToNewUTF8(S);try{return I(D)}finally{x._free(D)}};let w=null,E=-1,k=-1,L=-1;const C=(S,I)=>{k=S,L=S===Mt?I:-1,S===Mt&&(d==null||d.show()),S===Oe&&(f==null||f.show()),w&&S===Mt&&I!==E&&(E=I,w.openScene(I))},F=S=>{S!==k&&(S===Mt&&(d==null||d.hide(),w&&E>=0&&(E=-1,w.closeScene())),S===Oe&&(f==null||f.hide()))};let U=null;const $=Ri(o||t.engine3d?{creator:()=>U==null?void 0:U._creator,surface:d,presented:()=>L,frameRendered:()=>{var S;return!!((S=x._creatorWebFrameRendered)!=null&&S.call(x))},view:(d==null?void 0:d.canvas)??n}:null),K=ri();let G=t.keyboardBand??0;const A=g?zs(n,{M:x,canvas:g,canvasHost:K,keyboardHeight:()=>{const S=h.visualViewport,I=S?Math.max(0,Math.round((h.innerHeight-S.height-S.offsetTop)/(Ft(n)*c.scale()))):0;return I>0?I:G},onKeyboard:t.onKeyboard}):null;A&&(A.ui.onDestination=C,A.ui.onDropped=F);const v=Di({onOrientation:t.onOrientation,onWorldChange:()=>$.worldChanged(),push:(S,I)=>{S==="url"&&I!==void 0&&p(I,D=>x._creatorWebSetLaunchUrl(D)),p(S,D=>{I===void 0?x._creatorWebAppEvent(D,0):p(I,Z=>x._creatorWebAppEvent(D,Z))})}}),T=qi(),O=Yi(),j=zi({windows:[...new Set([h,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,scale:()=>Ft(n)*c.scale(),push:(S,I,D,Z)=>p(I,st=>x._creatorWebInputEvent(S,st,D,Z)),keyboardHeight:()=>(A==null?void 0:A.ui.keyboardHeight())??0}),J={ui:(A==null?void 0:A.ui)??Zi(C,F),app:v.table,device:$i(t.language??(()=>(h.navigator.language||"en").slice(0,2)),()=>c.size().factor),fetch:Vi(y),storage:Ji(t.project??(e==null?void 0:e.name)??"app"),socket:T.table,service:O.table,input:j.table,media:Ki,canvas:K.table,...d?{gl:d.table(x)}:{},...f?{scene2d:f.table(x)}:{}},_=Ye(),M=_.global;U=M,rr(x,{host:J,world:_,newWorld:()=>{const S=Ye();return U=S.global,S}});const N=Ai({...A?{registerView:(S,I,D)=>A.ui.registerView(S,I,D),unregisterView:S=>A.ui.unregisterView(S)}:{},registerService:O.registerService,unregisterService:O.unregisterService},$.facade);x._creatorWebInit(),t.launchUrl&&p(t.launchUrl,S=>x._creatorWebSetLaunchUrl(S)),A==null||A.ui.install(),!o&&t.engine3d&&(w=await t.engine3d({newCanvas:c.newCanvas,preloads:r,canvasHost:K,stores:Qi}),Object.defineProperty(M,"_creator",{value:w,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Rt=M._creator)==null||Rt.createEngine());const P=Mi(n);t.safeArea&&P.set(t.safeArea);const rt=S=>{var I;d==null||d.resize(),f==null||f.resize(),(I=w==null?void 0:w._onResize)==null||I.call(w,S.width,S.height,S.factor),A?(A.resize(S.width,S.height,S.factor,S.scale),A.setSafeArea(P.current())):x._creatorWebResize(S.width,S.height)};c.onResize(rt),rt(c.size());let Q=0;const ct=S=>{Q=h.requestAnimationFrame(ct),$.before(),d==null||d.frame(),x._creatorWebTick(S),$.after(),f==null||f.frame(S),A&&(A.ui.layoutFrame(),A.ui.tickHover(),A.render())};Q=h.requestAnimationFrame(ct),await u;let pt=!1;return{profile:s,M:x,world:M,ui:(A==null?void 0:A.ui)??null,engine3d:()=>w,getBuffer:S=>et(S),run(S,I={}){const D=I.header??Mn(S);if(!li(D.sdk,$e))throw new Error(`This app was built with LeCodes SDK ${D.sdk??"older than 2.0"}; this host runs SDK ${$e}. It needs a new build.`);const Z=m.track(S,I.onError);return N.allow(D.plugins),p(S,st=>x._creatorWebRun(st)),{dispose:Z.drop}},registerPlugin:(S,I)=>N.register(S,I),hasPlugin:N.has,locate:m.locate,safeArea:()=>P.current(),setSafeArea(S){P.set(S),A==null||A.setSafeArea(P.current())},setKeyboardBand(S){G=S??0,A==null||A.ui.refreshKeyboard()},remeasure:c.remeasure,setScale:c.setScale,size:c.size,emitAppEvent:v.emit,destroy(){var S;pt||(pt=!0,h.cancelAnimationFrame(Q),m.dispose(),A==null||A.destroy(),j.dispose(),T.dispose(),O.dispose(),v.dispose(),yn(),P.destroy(),(S=w==null?void 0:w._dispose)==null||S.call(w),d==null||d.destroy(),f==null||f.destroy(),c.destroy())}}},eo=(n,t,e,s)=>new Promise(r=>{const i=n.ownerDocument.defaultView??window;i.requestAnimationFrame(()=>{try{const o=[...n.querySelectorAll("canvas")].filter(h=>h.width>0&&h.height>0&&i.getComputedStyle(h).display!=="none");if(o.length===0||t<=0||e<=0){r(null);return}const a=s??Math.max(...o.map(h=>h.width))/t,c=n.ownerDocument.createElement("canvas");c.width=Math.max(1,Math.round(t*a)),c.height=Math.max(1,Math.round(e*a));const l=c.getContext("2d");if(!l){r(null);return}l.fillStyle="#000000",l.fillRect(0,0,c.width,c.height);for(const h of o)l.drawImage(h,0,0,h.width,h.height,0,0,c.width,c.height);r(c.toDataURL("image/png"))}catch{r(null)}})}),no=n=>{if(typeof n=="string")return n;if(n instanceof Error)return n.stack?`${String(n)}
|
|
19
|
-
${n.stack}`:String(n);try{return JSON.stringify(n)}catch{return String(n)}},
|
|
13
|
+
`,Ne=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),Vs=n=>n.type==="native"||n.type==="video",Gs=[1,0,0,1,0,0],zt=(n,t)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]],js=(n,t)=>{if(!n)return t;const e=Math.max(n.x,t.x),s=Math.max(n.y,t.y);return{x:e,y:s,width:Math.max(0,Math.min(n.x+n.width,t.x+t.width)-e),height:Math.max(0,Math.min(n.y+n.height,t.y+t.height)-s)}};class Nt extends Hs{constructor(e,s,r,i,o={}){super(e,s,o);b(this,"doc");b(this,"factories",new Map);b(this,"versions",new Map);b(this,"views",new Map);b(this,"wrappers",new Map);b(this,"shown",new Map);b(this,"destination",null);b(this,"field",null);b(this,"placedFor",null);b(this,"band",{root:0,height:0});b(this,"slide",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=$s,i.appendChild(a)}paintOptions(){var e;return{surfaces:!0,editing:(e=this.field)==null?void 0:e.id}}registerView(e,s,r=1){this.factories.set(e,s),this.versions.set(e,r)}unregisterView(e){this.factories.delete(e),this.versions.delete(e)}isViewSupported(e){return this.factories.has(e)}viewVersion(e){return this.versions.get(e)??0}ensureView(e,s,r){const i=this.views.get(e);if(i&&(i.name!==s||i.params!==r))this.destroyView(e);else if(i)return i.handle;const o=this.factories.get(s);if(!o)return null;let a={};try{a=r?JSON.parse(r):{}}catch{}const c=o(a,{emit:(l,h)=>this.M.jsb.viewEvent(e,l,h)},this.doc);return c.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:c}),c}destroyView(e){var r,i;const s=this.views.get(e);s&&(this.views.delete(e),(i=(r=s.handle).destroy)==null||i.call(r),s.handle.el.remove())}viewCall(e,s,r,i,o){const a=this.views.get(e);if(!(a!=null&&a.handle.call)){o(`NativeView call "${s}": no live instance or no call handler (viewId ${e})`);return}try{Promise.resolve(a.handle.call(s,Array.isArray(r)?r:[])).then(c=>{c===void 0?i():i(c)},c=>o(c instanceof Error?c.message:String(c)))}catch(c){o(c instanceof Error?c.message:String(c))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==ut)return;this.dropDestination();const c=this.ensureView(r,i,o);if(!c)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(c.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===ut&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==ut&&this.dropDestination()}dropDestination(){var e;(e=this.destination)==null||e.el.remove(),this.destination=null}releaseNode(e){var r,i;const s=this.get(e);((r=this.field)==null?void 0:r.id)===e&&this.unmountField(),super.releaseNode(e),(i=this.shown.get(e))==null||i.remove(),this.shown.delete(e),this.wrappers.delete(e),(s==null?void 0:s.type)==="native"&&s.viewId&&this.destroyView(s.viewId)}keyboardDuration(){return we}shrinkTo(e,s){const r=this.doc.defaultView;if(!r){super.shrinkTo(e,s);return}this.slide&&(r.cancelAnimationFrame(this.slide.raf),this.slide=null);const i=s>0?e:this.band.root,o=this.band.height;if(o===s||i===0||!this.nodes.has(i)){this.setBand(i,s);return}const a=r.performance.now(),c=()=>{const l=Math.min(1,(r.performance.now()-a)/we),h=Gn(l);this.setBand(i,l<1?Math.round(o+(s-o)*h):s),l<1?this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}:this.slide=null};this.slide={root:i,from:o,to:s,start:a,raf:r.requestAnimationFrame(c)}}setBand(e,s){this.band=s>0?{root:e,height:s}:{root:0,height:0},super.shrinkTo(this.band.root,this.band.height),this.dirty=!0}focusInput(e){var i;if(super.focusInput(e),this.focusedId()!==e||((i=this.field)==null?void 0:i.id)===e)return;this.unmountField();const s=this.get(e);if(!s)return;const r=this.doc.createElement(s.type==="textarea"?"textarea":"input");r.className="lc-field",r.setAttribute("autocomplete","off"),r.value=s.value,r.addEventListener("input",()=>{this.focusedId()===e&&this.setInputValue(e,r.value)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&r.tagName==="INPUT"&&(o.preventDefault(),this.submitInput())}),r.addEventListener("blur",()=>{var o;((o=this.field)==null?void 0:o.el)===r&&this.focusedId()===e&&this.blurInput()}),this.over.appendChild(r),this.field={id:e,el:r},this.placedFor=null,this.place(),r.focus({preventScroll:!0})}blurInput(){super.blurInput(),this.unmountField()}unmountField(){const e=this.field;e&&(this.field=null,e.el.remove(),this.placedFor=null)}setPropertyString(e,s,r){var i,o;if(super.setPropertyString(e,s,r),s==="value"&&((i=this.field)==null?void 0:i.id)===e){const a=((o=this.get(e))==null?void 0:o.value)??"";this.field.el.value!==a&&(this.field.el.value=a)}}find(){var i;const e=[],s=(i=this.field)==null?void 0:i.id,r=(o,a,c)=>{let l=a;const h=o.style.transform;if(h){const d=o.style.transformOrigin,f=o.rect.x+(d?d.xPercent?o.rect.width*d.x/100:d.x:o.rect.width/2),g=o.rect.y+(d?d.yPercent?o.rect.height*d.y/100:d.y:o.rect.height/2),y=En(h,o.style.transformBox,o.rect.width,o.rect.height);l=zt(zt(zt(a,[1,0,0,1,f,g]),y),[1,0,0,1,-f,-g])}(Vs(o)||o.id===s)&&e.push({node:o,matrix:l,clip:c});const u=o.clip?js(c,o.rect):c;for(const d of o.children)r(d,l,u)};for(const o of this.frame())r(o.tree,Gs,null);return e}static put(e,s){const{rect:r}=s.node,i=e.style;i.position="absolute",i.left="0",i.top="0",i.width=r.width+"px",i.height=r.height+"px",i.transformOrigin="0 0",i.transform=`matrix(${s.matrix.join(",")}) translate(${r.x}px,${r.y}px)`;const o=s.clip;i.clipPath=o?`inset(${Math.max(0,o.y-r.y)}px ${Math.max(0,r.x+r.width-(o.x+o.width))}px ${Math.max(0,r.y+r.height-(o.y+o.height))}px ${Math.max(0,o.x-r.x)}px)`:""}surfaceElement(e){const s=this.get(e.id);if(!s)return null;if(s.type==="video"){const o=ge(s.playerId);return o instanceof HTMLVideoElement?o:null}if(!s.viewId)return null;const r=this.ensureView(s.viewId,s.viewName??"",s.viewParams??"");if(!r)return null;let i=this.wrappers.get(s.id);return i||(i=this.doc.createElement("div"),this.wrappers.set(s.id,i)),r.el.parentElement!==i&&i.replaceChildren(r.el),i}styleField(e,s){var u,d;const r=s.style,i=e.style,[o,a,c,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${c}px ${l}px ${o}px`,i.color=Ne(r.color,"#000000ff"),i.caretColor=i.color;const h=r.fontFamily??"Roboto";if(i.fontFamily=((d=(u=this.host).resolveFontFamily)==null?void 0:d.call(u,h))??h,i.fontSize=(r.fontSize??14)+"px",i.fontWeight=String(r.fontWeight??400),i.fontStyle=r.fontStyle??"normal",i.letterSpacing=(r.letterSpacing??0)+"px",i.lineHeight=e.tagName==="TEXTAREA"&&r.lineHeight!==void 0?r.lineHeight+"px":"normal",i.textAlign=r.textAlign==="center"?"center":r.textAlign==="end"?"right":"left",i.borderRadius="0",e.placeholder=r.placeholder??"",i.setProperty("--lc-placeholder",Ne(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const f=r.inputType??"text";e.type!==f&&(e.type=f)}}place(){var r;const e=this.frame();if(e===this.placedFor)return;this.placedFor=e;const s=new Set;for(const i of this.find()){const{node:o}=i;if(o.id===((r=this.field)==null?void 0:r.id)){this.styleField(this.field.el,o),Nt.put(this.field.el,i);continue}const a=this.surfaceElement(o);a&&(s.add(o.id),a.parentElement!==this.under&&this.under.appendChild(a),a.style.display="block",a.style.opacity="",a.style.pointerEvents="auto",a instanceof HTMLVideoElement&&(a.style.objectFit=o.style.objectFit??"contain"),Nt.put(a,i),this.shown.set(o.id,a))}for(const[i,o]of this.shown)s.has(i)||(o.style.display="none",this.shown.delete(i))}surfaceAt(e,s){const r=this.frame();for(let i=r.length-1;i>=0;i--){const o=r[i];if(o.leaving)continue;const a=bt(o.tree,e,s,c=>{var l,h;return c.type==="native"||(((l=this.get(c.id))==null?void 0:l.interactive)??!1)||(((h=this.get(c.id))==null?void 0:h.editable)??!1)||!!c.scroll});if(a.node)return a.node.type==="native";if(a.blocker)return!1}return this.destination!==null}dispose(){this.unmountField();for(const e of[...this.views.keys()])this.destroyView(e);this.dropDestination();for(const e of this.shown.values())e instanceof HTMLVideoElement||e.remove();this.shown.clear()}}function zs(n,t,e,s){const r=n.createElement("div");r.textContent=e,r.style.cssText="position:absolute;left:50%;bottom:48px;transform:translateX(-50%);max-width:80%;padding:10px 16px;border-radius:8px;background:rgba(30,30,30,0.92);color:#fff;font:13px/1.4 system-ui,sans-serif;z-index:30;pointer-events:none;",t.appendChild(r),setTimeout(()=>r.remove(),s>0?s:2e3)}const Ks=500,Ue=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],Xs=(n,t)=>{const e=n.ownerDocument,{canvas:s}=t;s.style.display="block",s.style.pointerEvents="none",n.style.touchAction="none";const r=s.getContext("2d"),i=()=>{const v=e.createElement("div");return v.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;",v},o=i(),a=i();n.insertBefore(o,s),s.after(a);const c=new Sr({resolveAssetUrl:v=>hn(v),canvasSurfaces:t.canvasHost}),l=new Nt(t.M,c,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onKeyboard:t.onKeyboard,onToast:(v,T)=>zs(e,n,v,T)});let h=1,u=new Me(r,h),d=!0;const f=()=>{(d||l.needsPaint())&&(d=!1,l.paint(u,l.paintOptions())),l.place()};let g=1;const y=(v,T,I,z=1)=>{if(!(v<=0||T<=0)){I!==h&&(h=I,u=new Me(r,h)),g=z;for(const J of[o,a])Object.assign(J.style,{width:`${v}px`,height:`${T}px`,zoom:g===1?"":String(g)});d=!0,l.resize(v,T)}},x=v=>{l.setSafeArea([v.top,v.right,v.bottom,v.left],v.bars??[])},w=v=>{const T=n.getBoundingClientRect(),I=It(n)*g;return[(v.clientX-T.left)/I,(v.clientY-T.top)/I]},p=v=>v.target instanceof Node&&a.contains(v.target),m=v=>v.target instanceof Node&&o.contains(v.target),E=v=>{m(v)&&v.stopPropagation()},k=new Set,L=new Map,C=v=>{const T=L.get(v);T!==void 0&&(clearTimeout(T),L.delete(v))},O=v=>{if(p(v))return;const[T,I]=w(v);if(!l.surfaceAt(T,I)){E(v),k.add(v.pointerId);try{n.setPointerCapture(v.pointerId)}catch{}l.pointerDown(v.pointerId,T,I),C(v.pointerId),L.set(v.pointerId,window.setTimeout(()=>{L.delete(v.pointerId),l.longPress(v.pointerId,T,I)},Ks))}},F=v=>{const[T,I]=w(v);k.has(v.pointerId)&&(E(v),l.pointerMove(v.pointerId,T,I)),v.pointerType==="mouse"&&(p(v)||!k.has(v.pointerId)&&l.surfaceAt(T,I)?l.pointerLeave():l.pointerHover(T,I))},W=v=>{v.pointerType==="mouse"&&l.pointerLeave()},$=v=>{if(!k.delete(v.pointerId))return;E(v),C(v.pointerId);const[T,I]=w(v);l.pointerUp(v.pointerId,T,I)},j=v=>{k.delete(v.pointerId)&&(C(v.pointerId),l.pointerCancel(v.pointerId))},q=v=>{if(p(v))return;const[T,I]=w(v);if(l.surfaceAt(T,I))return;E(v);const z=v.deltaMode===1?16:v.deltaMode===2?l.height:1;l.wheel(T,I,v.deltaX*z,v.deltaY*z)&&v.preventDefault()},A=v=>{var J;if(p(v))return;const T="clientX"in v?v:(J=v.changedTouches)==null?void 0:J[0];if(!T)return;const[I,z]=w(T);l.surfaceAt(I,z)||(E(v),v.type==="mousedown"&&v.preventDefault())};n.addEventListener("pointerdown",O,!0),n.addEventListener("pointermove",F,!0),n.addEventListener("pointerleave",W),n.addEventListener("pointerup",$,!0),n.addEventListener("pointercancel",j,!0),n.addEventListener("wheel",q,{passive:!1,capture:!0});for(const v of Ue)n.addEventListener(v,A,!0);return{ui:l,render:f,resize:y,setSafeArea:x,destroy(){for(const v of L.keys())C(v);n.removeEventListener("pointerdown",O,!0),n.removeEventListener("pointermove",F,!0),n.removeEventListener("pointerleave",W),n.removeEventListener("pointerup",$,!0),n.removeEventListener("pointercancel",j,!0),n.removeEventListener("wheel",q,!0);for(const v of Ue)n.removeEventListener(v,A,!0);l.dispose(),o.remove(),a.remove()}}},Ys=["miter","round","bevel"],qs=["butt","round","square"],Js=["left","center","right","start","end"],Qs=["alphabetic","top","middle","bottom","hanging","ideographic"],Be=["nonzero","evenodd"],Zs=["pad","reflect","repeat"],Kt={COLOR:0,RADIAL:2},St={MOVE:0,LINE:1,QUAD:2,CUBIC:3,CLOSE:4},X={SET_TRANSFORM:0,SAVE:1,RESTORE:2,CLIP:3,FILL_PATH:4,STROKE_PATH:5,FILL_TEXT:6,STROKE_TEXT:7,DRAW_IMAGE:8,CLEAR_RECT:9};class ti{constructor(t,e){b(this,"pos",0);this.w=t,this.strings=e}f(){if(this.pos>=this.w.length)throw new Error("draw list: truncated");return this.w[this.pos++]}i(){return this.f()|0}str(){const t=this.i();if(t<0||t>=this.strings.length)throw new Error(`draw list: bad string index ${t}`);return this.strings[t]}color(){return[this.f(),this.f(),this.f(),this.f()]}matrix(){return[this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]}paint(){const t=this.i(),e=this.f();if(t===Kt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Kt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Zs[this.i()]??"pad",c=this.i(),l=[];for(let h=0;h<c;h++)l.push({offset:this.f(),color:this.color()});return t===Kt.RADIAL?{kind:"radial",alpha:e,matrix:s,fx:r,fy:i,r0:o,spread:a,stops:l}:{kind:"linear",alpha:e,matrix:s,spread:a,stops:l}}stroke(){const t=this.f(),e=Ys[this.i()]??"miter",s=qs[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let c=0;c<o;c++)a.push(this.f());return{width:t,join:e,cap:s,miterLimit:r,dashOffset:i,dash:a}}font(){return{family:this.str(),size:this.f(),weight:this.i(),italic:this.i()!==0}}path(){const t=this.i(),e=this.pos+t;if(e>this.w.length)throw new Error("draw list: truncated path");const s=[];for(;this.pos<e;)switch(this.i()){case St.MOVE:s.push(["M",this.f(),this.f()]);break;case St.LINE:s.push(["L",this.f(),this.f()]);break;case St.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case St.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case St.CLOSE:s.push(["Z"]);break;default:throw new Error("draw list: bad path verb")}return s}rect4(){return[this.f(),this.f(),this.f(),this.f()]}}const ei=(n,t)=>{const e=new ti(n,t),s=[];for(;e.pos+2<=n.length;){const r=e.i(),i=e.i(),o=e.pos+i;if(i<0||o>n.length)throw new Error("draw list: truncated command");switch(r){case X.SET_TRANSFORM:s.push({cmd:"setTransform",matrix:e.matrix()});break;case X.SAVE:s.push({cmd:"save"});break;case X.RESTORE:s.push({cmd:"restore"});break;case X.CLIP:{const a=Be[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Be[e.i()]??"nonzero",c=e.paint();s.push({cmd:"fillPath",rule:a,paint:c,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),c=e.paint();s.push({cmd:"strokePath",stroke:a,paint:c,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),c=e.f(),l=e.f(),h=e.f(),u=e.font(),d=Js[e.i()]??"start",f=Qs[e.i()]??"alphabetic",g=e.f();if(r===X.STROKE_TEXT){const y=e.stroke();s.push({cmd:"strokeText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,stroke:y,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:c,y:l,maxWidth:h,font:u,align:d,baseline:f,letterSpacing:g,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),c=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:c,dst:l,alpha:e.f()});break}case X.CLEAR_RECT:s.push({cmd:"clearRect",rect:e.rect4()});break}if(e.pos!==o){if(e.pos>o)throw new Error(`draw list: command ${r} overran its length`);e.pos=o}}return s},ni=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),Tn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,Rn=(n,t=n.family)=>{const e=ni.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Lt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],ri=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,Xt=(n,t)=>{n.beginPath();for(const e of t)switch(e[0]){case"M":n.moveTo(e[1],e[2]);break;case"L":n.lineTo(e[1],e[2]);break;case"Q":n.quadraticCurveTo(e[1],e[2],e[3],e[4]);break;case"C":n.bezierCurveTo(e[1],e[2],e[3],e[4],e[5],e[6]);break;case"Z":n.closePath();break}},De=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,Tn(e.color))},Pt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=Tn(t.color),s();return}const r=t.matrix;if(ri(r)){let o;if(t.kind==="linear"){const[a,c]=Lt(r,0,0),[l,h]=Lt(r,1,0);o=n.createLinearGradient(a,c,l,h)}else{const a=Math.hypot(r[0],r[1]),[c,l]=Lt(r,0,0),[h,u]=Lt(r,t.fx,t.fy);o=n.createRadialGradient(h,u,t.r0*a,c,l,a)}De(o,t),n[e==="fill"?"fillStyle":"strokeStyle"]=o,s();return}n.save(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]);const i=t.kind==="linear"?n.createLinearGradient(0,0,1,0):n.createRadialGradient(t.fx,t.fy,t.r0,0,0,1);De(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},We=(n,t)=>{n.lineWidth=t.width,n.lineJoin=t.join,n.lineCap=t.cap,n.miterLimit=t.miterLimit,n.setLineDash(t.dash),n.lineDashOffset=t.dashOffset},He=(n,t,e)=>{n.font=Rn(t.font,e.fontFamily?e.fontFamily(t.font.family):t.font.family),n.textAlign=t.align,n.textBaseline=t.baseline,"letterSpacing"in n&&(n.letterSpacing=`${t.letterSpacing}px`)},si=(n,t,e={})=>{var r;n.save();let s=0;try{n.setTransform(1,0,0,1,0,0),n.globalAlpha=1;for(const i of t)switch(i.cmd){case"setTransform":n.setTransform(i.matrix[0],i.matrix[1],i.matrix[2],i.matrix[3],i.matrix[4],i.matrix[5]);break;case"save":n.save(),s++;break;case"restore":s>0&&(n.restore(),s--);break;case"clip":Xt(n,i.path),n.clip(i.rule);break;case"fillPath":Xt(n,i.path),Pt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":Xt(n,i.path),We(n,i.stroke),Pt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":He(n,i,e),Pt(n,i.paint,"fill",()=>i.maxWidth>0?n.fillText(i.text,i.x,i.y,i.maxWidth):n.fillText(i.text,i.x,i.y));break;case"strokeText":He(n,i,e),We(n,i.stroke),Pt(n,i.paint,"stroke",()=>i.maxWidth>0?n.strokeText(i.text,i.x,i.y,i.maxWidth):n.strokeText(i.text,i.x,i.y));break;case"drawImage":{const o=(r=e.image)==null?void 0:r.call(e,i.surface);if(!o)break;n.globalAlpha=i.alpha,n.drawImage(o,i.src[0],i.src[1],i.src[2],i.src[3],i.dst[0],i.dst[1],i.dst[2],i.dst[3]);break}case"clearRect":n.clearRect(i.rect[0],i.rect[1],i.rect[2],i.rect[3]);break;default:{const o=i;throw new Error(`unhandled draw command ${o.cmd}`)}}}finally{for(;s>0;s--)n.restore();n.restore()}},ii=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,h,u)=>{if(!t)return null;let d=e.get(l);return d?(d.width!==h||d.height!==u)&&(d.width=h,d.height=u):(d=new OffscreenCanvas(h,u),e.set(l,d)),d},i={paint:(l,h,u,d,f,g)=>{const y=r(l,Math.max(1,h),Math.max(1,u)),x=y==null?void 0:y.getContext("2d");!y||!x||(x.setTransform(1,0,0,1,0,0),x.clearRect(0,0,y.width,y.height),si(x,ei(f,g),{image:w=>e.get(w)??null,fontFamily:n}))},measureText:(l,h,u,d,f,g)=>{if(g[0]=0,g[1]=0,g[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=Rn({family:h,size:u,weight:d,italic:f},h);const y=s.measureText(l);g[0]=y.width,g[1]=y.fontBoundingBoxAscent??y.actualBoundingBoxAscent,g[2]=y.fontBoundingBoxDescent??y.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,h)=>{const u=o(l);return u?(h[0]=u.width,h[1]=u.height,new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const h=e.get(l),u=h==null?void 0:h.getContext("2d");return!h||!u?null:{data:u.getImageData(0,0,h.width,h.height).data,width:h.width,height:h.height}};return{table:i,readSurface:o,getSurface:l=>{const h=e.get(l);return h?{canvas:h,width:h.width,height:h.height}:null},surfaceToDataUrl:l=>{var d;const h=e.get(l);if(!h||typeof document>"u")return null;const u=document.createElement("canvas");return u.width=h.width,u.height=h.height,(d=u.getContext("2d"))==null||d.drawImage(h,0,0),u.toDataURL()}}},oi=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,ai=(n,t="woff2")=>{const e=/^\/\/ fonts: (.+)$/m.exec(n);if(!e)return[];const s=[];for(const r of e[1].split(";")){const i=r.indexOf("=");if(i===-1)continue;const o=/^(.+)@(\d+)(i?)$/.exec(r.slice(0,i));o&&s.push({family:o[1],weight:parseInt(o[2],10),italic:o[3]==="i",url:r.slice(i+1).replace("{fmt}",t)})}return s},ci=async(n,t,e=2e3)=>{const s=t??(typeof document>"u"?void 0:document);if(!(s!=null&&s.fonts)||n.length===0)return;const r=[];for(const i of n)try{const o=new FontFace(i.family,`url("${i.url}")`,{weight:String(i.weight),style:i.italic?"italic":"normal"});s.fonts.add(o),r.push(o.load().catch(()=>{}))}catch{}await Promise.race([Promise.all(r),new Promise(i=>setTimeout(i,e))])},An="Roboto",li=[`400 14px ${An}`],$e="data-lecodes-fonts",hi=async(n=li,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${$e}]`)){const s=new URL(oi,document.baseURI).href,r=e.createElement("style");r.setAttribute($e,""),r.textContent=`@font-face{font-family:"${An}";src:url("${s}") format("woff2");font-weight:100 900;font-display:swap}`,e.head.appendChild(r)}try{await Promise.all(n.map(s=>e.fonts.load(s)))}catch{}}},Ve="2.8.0",Yt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},ui=(n,t)=>Yt(n)!==null&&Yt(n)===Yt(t),di=()=>({setMatrix(){},setVisible(){},setCameraMatrix(){},setProjection(){},clearProjection(){},setBackground(){},createExternalTexture:()=>null,onFrame:()=>()=>{},readPixels:(n,t)=>t(null,0,0),viewport:()=>({width:0,height:0,rotation:0})}),fi=n=>{var s,r;const t=((r=(s=n.screen)==null?void 0:s.orientation)==null?void 0:r.angle)??n.orientation??0;return(Math.round(t/90)%4+4)%4*90},gi=(n,t)=>({width:(n==null?void 0:n.clientWidth)??0,height:(n==null?void 0:n.clientHeight)??0,rotation:fi(t)}),pi=[1,0,0,0,1,0],mi=(n,t,e)=>{const s=t*4,r=new Uint8Array(s);for(let i=0,o=e-1;i<o;i++,o--)r.set(n.subarray(i*s,i*s+s)),n.copyWithin(i*s,o*s,o*s+s),n.set(r,o*s);return n},yi=[171,75,84,88,32,50,48,187,13,10,26,10],wi=n=>n.length>=12&&yi.every((t,e)=>n[e]===t),bi=(n,t)=>{const e={antialias:!1,depth:!0,alpha:!1,stencil:!1,desynchronized:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"high-performance",premultipliedAlpha:!0,preserveDrawingBuffer:t},s=n.newCanvas(),r=s.getContext("webgl2",e);if(!r)throw new Error("WebGL2 is not available");let i=null,o=!1;const a=[],c=()=>{const u=r.createTexture();return r.bindTexture(r.TEXTURE_2D,u),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),u},l=u=>{var g;u._creatorWebSetViewport(s.width,s.height);const{width:d,height:f}=n.size();d>0&&f>0&&((g=u._setDensityGL)==null||g.call(u,s.width/d,s.height/f))},h=(u,d,f,g)=>{const y=u.GL.getNewId(u.GL.textures);return u.GL.textures[y]=d,u._importTexture(y,f,g)>>>0};return{canvas:s,context:r,options:e,table(u){return i=u,{engineCreated(){a.length=0,u._createSwapChainHeadless(s.width,s.height),l(u),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(d,f,g,y){const x=et(d);if(!x){y(`createTexture: no buffer behind id ${d}`);return}const w=new Uint8Array(x);if(wi(w)){const p=u._malloc(w.length);u.HEAPU8.set(w,p);const m=u._createTextureFromKtx2(p,w.length)>>>0;if(u._free(p),m===4294967295){y("KTX2 transcode failed");return}g(m,u._getTextureWidth(m),u._getTextureHeight(m));return}createImageBitmap(Ht(d)).then(p=>{const m=c();r.texStorage2D(r.TEXTURE_2D,1,f&1?r.RGBA8:r.SRGB8_ALPHA8,p.width,p.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,p.width,p.height,r.RGBA,r.UNSIGNED_BYTE,p),g(h(u,m,p.width,p.height),p.width,p.height)},p=>y(p instanceof Error?p.message:String(p)))},createMediaPlayerTexture(d){const f=ge(d);if(!f)return 0;const g=c(),y=h(u,g,0,0);return a.push({video:f,texture:g,id:y,lastTime:0}),y}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&l(i)},frame(){for(const u of a)u.video.readyState<2||u.video.currentTime===u.lastTime||(u.lastTime=u.video.currentTime,r.bindTexture(r.TEXTURE_2D,u.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,u.video))},videoTexture(u){const d=a.find(y=>y.video===u);if(d)return d.id;if(!i||!o)return;const f=c(),g=h(i,f,0,0);return a.push({video:u,texture:f,id:g,lastTime:0}),g},readPixels(){const u=r.drawingBufferWidth,d=r.drawingBufferHeight;if(!o||u===0||d===0)return null;const f=new Uint8Array(u*d*4),g=r.getParameter(r.READ_FRAMEBUFFER_BINDING);return r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.readPixels(0,0,u,d,r.RGBA,r.UNSIGNED_BYTE,f),r.bindFramebuffer(r.READ_FRAMEBUFFER,g),{rgba:mi(f,u,d),width:u,height:d}},destroy(){var u;a.length=0,(u=r.getExtension("WEBGL_lose_context"))==null||u.loseContext()}}},vi=n=>{const t={alpha:!1,depth:!0,stencil:!0,antialias:!1,premultipliedAlpha:!1,desynchronized:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1},e=n.newCanvas(),s=e.getContext("webgl2",t);if(!s)throw new Error("WebGL2 is not available");let r=null,i=!1;const o=()=>{!r||!i||(r._c2dSetViewport(e.width,e.height),r._c2dSetDensity(n.size().factor))},a=()=>{r&&(r._creatorWeb2dEnsureInited(),i=!0,o(),e.style.display="block")},c=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:c}},show:a,hide:c,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ge=n=>{if(typeof n=="number"||typeof n=="bigint"||typeof WebAssembly<"u"&&n instanceof WebAssembly.RuntimeError)return!0;const t=n instanceof Error?n.stack??"":"";return/\bwasm\b|wasm-function|\.wasm/i.test(t)},je="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mn={};for(let n=0;n<je.length;n++)Mn[je[n]]=n;const xi=n=>{const t=[];let e=0,s=0;for(const r of n){const i=Mn[r];if(i===void 0)break;const o=i&32;if(s+=(i&31)<<e,o)e+=5;else{const a=s&1;s>>=1,t.push(a?-s:s),s=0,e=0}}return t};class Ei{constructor(t){b(this,"sources");b(this,"lines");this.sources=t.sources,this.lines=[];let e=0,s=0,r=0;for(const i of t.mappings.split(";")){const o=[];let a=0;if(i)for(const c of i.split(",")){const l=xi(c);l.length!==0&&(a+=l[0],l.length>=4&&(e+=l[1],s+=l[2],r+=l[3],o.push([a,e,s,r])))}this.lines.push(o)}}originalPositionFor(t,e){const s=this.lines[t-1];if(!s||s.length===0)return null;let r=null;for(const o of s)if(o[0]<=e)r=o;else break;r??(r=s[0]);const i=this.sources[r[1]];return i===void 0?null:{source:i,line:r[2]+1,column:r[3]}}}const Si=n=>{const t=n.match(/\/\/# lecodesMap=data:application\/json;(?:charset=[^;]+;)?base64,([A-Za-z0-9+/=]+)\s*$/);if(!t)return null;try{const e=typeof atob=="function"?atob(t[1]):Buffer.from(t[1],"base64").toString("utf8");return new Ei(JSON.parse(e))}catch{return null}};let wt=null;const _i=()=>{if(wt!==null)return wt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return wt=e?parseInt(e[1],10)-1:2,wt}return wt=2,wt},qt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=_i(),r=[];for(const i of e.split(`
|
|
14
|
+
`)){const o=i.match(/<anonymous>:(\d+):(\d+)/);if(!o)continue;const a=parseInt(o[1],10)-s,c=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,c<0?0:c);if(!l)continue;const h=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:h?h[1]:null,source:l.source,line:l.line,column:l.column})}return r},ki=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,Ti=(n,t)=>{const e=[],s=(l,h,u,d)=>{var y,x;if(u.length===0&&Ge(h)){const w=typeof h=="number"||typeof h=="bigint"?`code ${h}`:h instanceof Error?h.message||h.name:String(h),p=[d,w].filter(E=>!!E).filter((E,k,L)=>L.indexOf(E)===k).join(`
|
|
15
|
+
`);console.error(`[lecodes] native engine error — ${p||w} (see the console for the engine's message)`);const m={message:"Native engine error",detail:p,frames:[],native:!0,stack:h instanceof Error?h.stack:void 0};(y=l.onError)==null||y.call(l,m),m.stack&&t&&cr(m.stack).then(E=>{var k;E.length>0&&((k=l.onError)==null||k.call(l,{...m,nativeFrames:E}))});return}const f=h instanceof Error?h.message:String(h),g=u[0];console.error(g?`[lecodes] ${f}
|
|
16
|
+
at ${g.source}:${g.line}:${g.column}${g.fn?` (${g.fn})`:""}`:`[lecodes] ${f}`),(x=l.onError)==null||x.call(l,{message:f,frames:u,stack:h instanceof Error?h.stack:void 0})},r=(l,h)=>{for(let d=e.length-1;d>=0;d--){const f=e[d];if(!f.sourceMap)continue;const g=qt(l,f.sourceMap);if(g.length>0)return s(f,l,g,h)}const u=e[e.length-1];u&&Ge(l)&&s(u,l,[],h)};let i=null;const o=()=>{const l=e[e.length-1],h=i;if(i=null,!h||!l)return;const u=new Error(h.message.replace(/^Error: /,""));u.stack=h.stack.join(`
|
|
17
|
+
`),s(l,u,l.sourceMap?qt(u,l.sourceMap):[])},a=l=>r(l.error??l.message,l.message),c=l=>r(l.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",c),{track(l,h){const u={sourceMap:Si(l),onError:h};return e.push(u),{drop(){const d=e.indexOf(u);d>=0&&e.splice(d,1)}}},locate(l){var u;const h=(u=e[e.length-1])==null?void 0:u.sourceMap;return h?qt(l,h):[]},runtimeLine(l){if(i&&/^\s+at /.test(l))return i.stack.push(l),!0;const h=ki.exec(l);if(!h||e.length===0)return!1;o();const[u,...d]=h[2].split(`
|
|
18
|
+
`);return i={message:(u??"").replace(/^JsTask /,""),stack:d},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",c),e.length=0}}},Ln=n=>{var c,l,h,u;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const d of s[1].split(";"))e.add(d);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((c=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:c[1])??null,o=((h=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:h.trim())??null,a=new Set((((u=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:u[1])??"").split(";").map(d=>d.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:ai(t)}},Ri=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",ze=(n,t)=>Math.max(1,Math.round(n/t*1e3)/1e3),Ai=(n,t=1)=>{const e=n.ownerDocument,s=e.defaultView??window;let r=t>0?t:1,i=1/0;const o=(w,p)=>{const m=(s.devicePixelRatio||1)*It(n),E=Math.min(i,m*r),k=ze(w,r),L=ze(p,r);return{width:k,height:L,factor:E,scale:r,pixelWidth:Math.max(1,Math.round(k*E)),pixelHeight:Math.max(1,Math.round(L*E))}};let a=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const c=[],l=w=>{w.width!==a.pixelWidth&&(w.width=a.pixelWidth),w.height!==a.pixelHeight&&(w.height=a.pixelHeight)},h=()=>{const w=e.createElement("canvas");return w.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(w),l(w),c.push(w),w},u=new Set,d=w=>{if(!(w.width<=0||w.height<=0)){a=w;for(const p of c)l(p);for(const p of u)p(a)}};let f=null;const g=(w,p,m)=>{const E=o(w,p),k=m&&Math.abs(m.inlineSize-E.width*E.factor)<=1&&Math.abs(m.blockSize-E.height*E.factor)<=1;if(!m||!k){d(E);return}d({...E,pixelWidth:Math.max(1,m.inlineSize),pixelHeight:Math.max(1,m.blockSize)})},y=new ResizeObserver(([w])=>{var k;if(!w)return;const{width:p,height:m}=w.contentRect,E=((k=w.devicePixelContentBoxSize)==null?void 0:k[0])??null;f={width:p,height:m,device:E},g(p,m,E)});try{y.observe(n,{box:"device-pixel-content-box"})}catch{y.observe(n)}const x=w=>{w!==void 0&&(i=w>0?w:1/0);const p=o(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==a.pixelWidth||p.pixelHeight!==a.pixelHeight||p.factor!==a.factor||p.width!==a.width||p.height!==a.height)&&d(p)};return{root:n,doc:e,win:s,size:()=>a,scale:()=>r,newCanvas:h,remeasure:x,setScale(w){!(w>0)||w===r||(r=w,f?g(f.width,f.height,f.device):x())},onResize(w){return u.add(w),()=>{u.delete(w)}},destroy(){y.disconnect(),u.clear();for(const w of c)w.remove();c.length=0}}},Mi=n=>{const t=new Map;let e=0,s=[];const r=new Set,i=c=>{r.has(c)||(r.add(c),console.warn(`[web-host] gl.${c}: this host's engine has no such call yet (a runtime module of an older build) — ignored`))},o=c=>Float32Array.from(c);return{facade:n?{setMatrix(c,l){var h;(h=n.creator())==null||h.setWorldMatrix(c,o(l))},setVisible(c,l){var h;(h=n.creator())==null||h.setVisible(c,l)},setCameraMatrix(c,l){var u;const h=n.creator();if(h&&!h.setCameraMatrix)return i("setCameraMatrix");(u=h==null?void 0:h.setCameraMatrix)==null||u.call(h,c,o(l))},setProjection(c,l,h,u){var f;const d=n.creator();if(d&&!d.setCameraProjectionMatrix)return i("setProjection");(f=d==null?void 0:d.setCameraProjectionMatrix)==null||f.call(d,c,o(l),h,u)},clearProjection(c){var l,h;(h=(l=n.creator())==null?void 0:l.clearCameraProjectionMatrix)==null||h.call(l,c)},setBackground(c,l,h=pi){const u=n.creator();if(!u)return;if(!u.setSceneBackground||!n.surface)return i("setBackground");l&&l.nodeName!=="VIDEO"&&!r.has("setBackground(canvas)")&&(r.add("setBackground(canvas)"),console.warn("[web-host] gl.setBackground: the web player shows a video background only — a canvas is not shown (Web Lite shows it)"));const d=(l==null?void 0:l.nodeName)==="VIDEO"?l:null,f=d?n.surface.videoTexture(d):void 0;u.setSceneBackground(c,f??4294967295,Float32Array.from(h))},createExternalTexture:()=>null,onFrame(c){const l=e++;return t.set(l,c),()=>{t.delete(l)}},readPixels(c,l){if(!n.surface||n.presented()!==c){l(null,0,0);return}s.push({scene:c,then:l})},viewport:()=>gi(n.view,n.view.ownerDocument.defaultView??window)}:di(),before(){if(t.size!==0)for(const c of[...t.values()])c()},after(){if(s.length===0||!(n!=null&&n.surface))return;const c=n.presented(),l=s.filter(u=>u.scene===c);for(const u of s)u.scene!==c&&u.then(null,0,0);if(s=l,l.length===0||!n.frameRendered())return;s=[];const h=n.surface.readPixels();for(const u of l)h?u.then(h.rgba.slice(),h.width,h.height):u.then(null,0,0)},worldChanged(){t.clear();const c=s;s=[];for(const l of c)l.then(null,0,0)}}},Li=(n,t)=>{const e=[],s=new Set;return{has:r=>s.has(r),register(r,i){s.has(r)||(s.add(r),i({registerView:(o,a,c=1)=>{e.push({id:r,version:c,kind:"view",name:o,factory:a})},registerService:(o,a,c=1)=>{e.push({id:r,version:c,kind:"service",name:o,factory:a})},putBuffer:ft,getBuffer:et,gl:t}))},allow(r){var o,a;const i=new Set(r);for(const c of e){const l=i.has(c.id);c.kind==="view"?l?(o=n.registerView)==null||o.call(n,c.name,c.factory,c.version):(a=n.unregisterView)==null||a.call(n,c.name):l?n.registerService(c.name,c.factory,c.version):n.unregisterService(c.name)}}}},Pi=n=>{const t=n.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);",n.appendChild(t);const e=i=>Math.round(parseFloat(i)||0),s=()=>{const i=getComputedStyle(t);return{top:e(i.paddingTop),right:e(i.paddingRight),bottom:e(i.paddingBottom),left:e(i.paddingLeft)}};let r=null;return{set(i){r=i},current:()=>r??s(),destroy(){t.remove()}}},Ci={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-cards":"world",grass:"world","foliage-impostor":"world"},Ke="material:",Oi=n=>{const t=new Set;for(const e of n)e.startsWith(Ke)&&t.add(Ci[e.slice(Ke.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},Ii=""+new URL("assets/materials-DE8QZ7Hn.bin",import.meta.url).href,Fi=""+new URL("assets/materials-world-CGNyYz_-.bin",import.meta.url).href,Ni=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,Ui=""+new URL("assets/uberarchive-Ok2HfJvn.bin",import.meta.url).href,Bi={base:Ii,world:Fi},Di=n=>{const t=new Uint8Array(n.reduce((s,r)=>s+r.byteLength,0));let e=0;for(const s of n)t.set(new Uint8Array(s),e),e+=s.byteLength;return t.buffer},Wi=async n=>{const t=async o=>{const a=await fetch(o);if(!a.ok)throw new Error(`${o} → HTTP ${a.status}`);return a.arrayBuffer()},e=Oi(n).map(o=>Bi[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(Ni),t(Ui),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:Di(i)}:{}}},Hi=n=>{const t=()=>n.push(document.hidden?"pause":"resume"),e=()=>n.push("online"),s=()=>n.push("offline");return document.addEventListener("visibilitychange",t),window.addEventListener("online",e),window.addEventListener("offline",s),{table:{state:()=>document.hidden?"background":"active",isOnline:()=>navigator.onLine,openUrl(i){window.open(i,"_blank","noopener")},worldChange(){var i;(i=n.onWorldChange)==null||i.call(n)},setOrientation(i){var c,l,h,u;const o=i==="landscape"||i==="portrait"?i:"auto";if(n.onOrientation){n.onOrientation(o);return}const a=typeof screen<"u"?screen.orientation:void 0;if(a)try{o==="auto"?(c=a.unlock)==null||c.call(a):(u=(h=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:h.catch)==null||u.call(h,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},$i=(n,t,e,s)=>{try{const r=document.createElement("input");r.type="file",r.multiple=e,s&&(r.accept=s),r.onchange=async()=>{const{files:i}=r;if(e){const o=[];if(!i)return n([]);for(let a of i)o.push([ft(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ft(await i[0].arrayBuffer()),i[0].name,i[0].size]])}},window.addEventListener("focus",()=>{setTimeout(()=>{(!r.files||r.files.length===0)&&n(e?[]:null)},300)},{once:!0}),r.click()}catch(r){t(r)}},Pn=n=>n==="camera"?"camera":n==="microphone"||n==="speech"?"microphone":n==="location"?"geolocation":null,Cn=(n,t,e)=>{const s=Pn(n);if(!s){e(`${n}: not a permission this host asks for`);return}const r=navigator.permissions;if(!(r!=null&&r.query)){t("prompt");return}r.query({name:s}).then(i=>t(i.state),()=>t("prompt"))},Vi=(n,t,e)=>{if(!Pn(n)){e(`${n}: not a permission this host asks for`);return}const s=()=>Cn(n,t,e);if(n==="location"){if(!navigator.geolocation){t("denied");return}navigator.geolocation.getCurrentPosition(()=>t("granted"),i=>i.code===i.PERMISSION_DENIED?t("denied"):s(),{timeout:15e3,maximumAge:1/0});return}const r=navigator.mediaDevices;if(!(r!=null&&r.getUserMedia)){t("denied");return}r.getUserMedia(n==="camera"?{video:!0}:{audio:!0}).then(i=>{for(const o of i.getTracks())o.stop();t("granted")},i=>{const o=i instanceof Error?i.name:"";o==="NotAllowedError"||o==="SecurityError"?t("denied"):s()})},Gi=(n,t)=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return(t==null?void 0:t())||window.devicePixelRatio||1},vibrate(){var e;try{(e=navigator.vibrate)==null||e.call(navigator,30)}catch{}},clipboardWrite(e){var s;(s=navigator.clipboard)==null||s.writeText(e).catch(()=>{})},clipboardRead(e,s){const r=navigator.clipboard;if(!(r!=null&&r.readText)){s("Clipboard is not available");return}r.readText().then(e,i=>s(i instanceof Error?i.message:"Clipboard read failed"))},share(e){const s=URL.createObjectURL(Ht(e)),r=document.createElement("a");r.href=s,r.download="image.png",document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(s)},openFilePicker:(e,s,r,i)=>$i(e,s,r,i??void 0),queryPermission:Cn,requestPermission:Vi}),ji=(n={})=>({local:t=>pr(t),dispose:t=>ur(t),request(t,e,s,r,i,o,a,c){if(t.startsWith("id:")){const u=Number(t.slice(3));o(u,et(u)?200:404);return}const l={};for(let u=0;u+1<s.length;u+=2)l[s[u]]=s[u+1];let h;if(i.length>0){const u=new FormData;for(const d of i)d.key!==null&&(d.bufferId>0?u.append(d.key,Ht(d.bufferId),d.filename??void 0):u.append(d.key,d.value??""));h=u}else r!==null&&(h=r);(async()=>{var u;try{const d=await fetch(t,{method:e,headers:l,body:h,mode:"cors",credentials:"omit"}),f=c?(u=d.body)==null?void 0:u.getReader():void 0;if(!f){o(ft(await d.arrayBuffer()),d.status);return}const g=Number(d.headers.get("content-length"))||void 0,y=[];let x=0;for(;;){const{done:m,value:E}=await f.read();if(m)break;E&&(y.push(E),x+=E.length,c({loaded:x,total:g}))}const w=new Uint8Array(x);let p=0;for(const m of y)w.set(m,p),p+=m.length;o(ft(w.buffer),d.status)}catch(d){a(d instanceof Error?d.message:String(d))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ft(t.slice().buffer),bufferSlice(t,e,s){const r=et(t);if(!r)return null;const i=Math.max(0,Math.min(e,r.byteLength)),o=Math.max(i,Math.min(s,r.byteLength));return new Uint8Array(r,i,o-i)},systemBuffer:t=>{const e=n[t];return e?new Uint8Array(e):null}}),Xe=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Jt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Ct=4,Qt=16,Ye=16,zi=.5,Ki=n=>{const t=new Set;let e=null;const s=(_,M,U=-1,P=0)=>{e==null||e(_,M,U,P)},r=_=>{if(!_.code)return;const M=t.has(_.code);t.add(_.code),s(0,_.code,-1,M||_.repeat?1:0)},i=_=>{_.code&&t.delete(_.code)&&s(1,_.code)},o=()=>{for(const _ of[...t])_.startsWith("Gamepad")||(t.delete(_),s(1,_))},{root:a}=n;let c=0,l=0,h=0,u=0,d=0,f=0,g=0,y=0,x=0,w=0;const p=_=>{var P;if(_.pointerType&&_.pointerType!=="mouse")return;const M=a.getBoundingClientRect(),U=((P=n.scale)==null?void 0:P.call(n))||1;c=(_.clientX-M.left)/U,l=(_.clientY-M.top)/U,h+=(_.movementX||0)/U,u+=(_.movementY||0)/U},m=_=>{const M=Xe[_.button];M&&(t.add(M),s(0,M))},E=_=>{const M=Xe[_.button];M&&t.delete(M)&&s(1,M)},k=_=>{const M=_.deltaMode===0?.01:1;d+=_.deltaX*M,f+=_.deltaY*M},L=_=>{document.pointerLockElement===a&&_.preventDefault()},C=[],O=[],F=[],W=()=>{var M,U;const _=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let P=0;P<Ct;P++){const rt=_[P]??null,Q=!!rt&&rt.connected;if(Q!==!!C[P]){if(C[P]=Q,!Q){for(const D of Jt)t.delete(D+"@"+P)&&(s(1,D,P),$(D));F[P]=[],O[P]=[0,0,0,0,0,0]}s(Q?2:3,"",P)}if(!rt||!Q)continue;const ct=rt.axes,pt=rt.buttons,Rt=((M=pt[6])==null?void 0:M.value)??0,S=((U=pt[7])==null?void 0:U.value)??0;O[P]=[ct[0]??0,ct[1]??0,ct[2]??0,ct[3]??0,Rt,S];const N=F[P]??(F[P]=[]);for(let D=0;D<Jt.length;D++){const Z=pt[D],st=!!Z&&(Z.pressed||Z.value>zi);if(st===!!N[D])continue;N[D]=st;const At=Jt[D];st?t.add(At+"@"+P):t.delete(At+"@"+P),$(At),s(st?0:1,At,P)}}},$=_=>{let M=!1;for(let U=0;U<Ct&&!M;U++)t.has(_+"@"+U)&&(M=!0);M?t.add(_):t.delete(_)};let j=0;const q=()=>{g=h,y=u,x=d,w=f,h=u=d=f=0,W(),j=requestAnimationFrame(q)},A=n.windows.filter((_,M,U)=>_&&U.indexOf(_)===M);for(const _ of A)n.keyboard!==!1&&(_.addEventListener("keydown",r),_.addEventListener("keyup",i)),_.addEventListener("blur",o);return a.addEventListener("pointermove",p,!0),a.addEventListener("mousedown",m,!0),window.addEventListener("mouseup",E,!0),a.addEventListener("wheel",k,{passive:!0,capture:!0}),a.addEventListener("contextmenu",L,!0),typeof requestAnimationFrame=="function"&&(j=requestAnimationFrame(q)),{inputKey:(_,M)=>M>=0&&_.startsWith("Gamepad")?t.has(_+"@"+M):t.has(_),inputRead:_=>{var M;switch(_){case 0:return c;case 1:return l;case 2:return g;case 3:return y;case 4:return x;case 5:return w;case 6:return document.pointerLockElement===a?1:0;case 7:{let U=0;for(let P=0;P<Ct;P++)C[P]&&U++;return U}}if(_>=Qt){const U=Math.floor((_-Qt)/Ye),P=(_-Qt)%Ye;return U>=Ct||!C[U]?0:P===0?1:((M=O[U])==null?void 0:M[P-1])??0}return 0},inputSetPointerLock:_=>{if(!_)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const M=a.requestPointerLock({unadjustedMovement:!0});return M&&typeof M.catch=="function"&&M.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:_=>{e=_},dispose:()=>{for(const _ of A)_.removeEventListener("keydown",r),_.removeEventListener("keyup",i),_.removeEventListener("blur",o);a.removeEventListener("pointermove",p,!0),a.removeEventListener("mousedown",m,!0),window.removeEventListener("mouseup",E,!0),a.removeEventListener("wheel",k,!0),a.removeEventListener("contextmenu",L,!0),j&&cancelAnimationFrame(j),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},Xi=n=>{const t=Ki(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},Yi={createVideo:Mr,createAudio:Lr,setVolume:Pr,setPlaying:Cr,setLoop:Or,time:Ir,setTime:Fr,duration:Nr,remove:Ur},qi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(d,f,g=1)=>{n.set(d,f),t.set(d,g)},unregisterService:d=>{n.delete(d),t.delete(d)},isServiceSupported:d=>n.has(d),serviceVersion:d=>t.get(d)??0,serviceOpen:(d,f,g)=>{const y=n.get(d);if(!y)return-1;const x=s++,w=y(f?JSON.parse(f):{},{emit:(p,m)=>{m===void 0?g(p):g(p,m)}});return e.set(x,w),x},serviceCall:(d,f,g,y,x)=>{const w=e.get(d);if(!(w!=null&&w.call)){x(`Service call "${f}": no live session or no call handler (serviceId ${d})`);return}try{Promise.resolve(w.call(f,Array.isArray(g)?g:[])).then(p=>{p===void 0?y():y(p)},p=>x(p instanceof Error?p.message:String(p)))}catch(p){x(p instanceof Error?p.message:String(p))}},serviceClose:d=>{var f,g;(g=(f=e.get(d))==null?void 0:f.close)==null||g.call(f),e.delete(d)},destroy:()=>{var d;for(const f of e.values())(d=f.close)==null||d.call(f);e.clear()}}},Ji=()=>{const n=qi();return{table:{supported:n.isServiceSupported,version:n.serviceVersion,open:n.serviceOpen,call:n.serviceCall,close:n.serviceClose},registerService:n.registerService,unregisterService:n.unregisterService,dispose:n.destroy}},Qi=()=>{const n=[];return{table:{open(e,s){const r=new WebSocket(e);return r.addEventListener("open",()=>s("open")),r.addEventListener("message",i=>s("message",i.data)),r.addEventListener("close",i=>s("close",i.code)),r.addEventListener("error",()=>s("error")),n.push(r),n.length-1},send(e,s){var r;(r=n[e])==null||r.send(s)},close(e){var s;(s=n[e])==null||s.close()}},dispose(){for(const e of n)e.readyState===WebSocket.OPEN&&e.close();n.length=0}}},Zi=n=>{const t=e=>`lecodes:${n}:${e}`;return{load(e){try{return window.localStorage.getItem(t(e))}catch{return null}},save(e,s){try{window.localStorage.setItem(t(e),s)}catch{}}}},qe=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},to={fetch:hr,getBuffer:et,getBlob:Ht,putBuffer:ft,putLocalBuffer:dr,hasLocalBuffer:fr,getLocalName:gr,getPlayer:ge,removePlayers:wn},eo=(n,t)=>({nodeFactory(){},setPropertyString(){},setPropertyInt(){},setFlags(){},insertNode(){},removeNode(){},releaseNode(){},openView(e,s,r){n(e,r)},dropView(e,s,r){t(e,r)},closeView(){n(-1,0)},layerOpen(){},layerClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),no=async(n,t={})=>{var Rt;const e=t.header,s=t.profile??(e?Ri(e):"full"),r=(e==null?void 0:e.preloads)??new Set,i=t.ui!==!1,o=s==="full",a=s==="2d"||s==="full"&&!!(e!=null&&e.is2d),c=Ai(n,t.scale??1),{doc:l,win:h}=c,u=i?Promise.all([hi(void 0,l),ci((e==null?void 0:e.bootFonts)??[],l)]):null,d=o?bi(c,r.has("capture")):null,f=a?vi(c):null,g=i?c.newCanvas():null,y=Ti(h,o);o&&lr();const[x,w]=await Promise.all([Yn(s,{glContext:d==null?void 0:d.context,glOptions:d==null?void 0:d.options,gl2dContext:f==null?void 0:f.context,gl2dOptions:f==null?void 0:f.options,moduleArgs:{print:S=>{y.runtimeLine(S)?console.debug(S):console.log(S)},printErr:S=>{console.error(S)}}}),o?Wi(r):Promise.resolve({})]),p=(S,N)=>{const D=x.stringToNewUTF8(S);try{return N(D)}finally{x._free(D)}};let m=null,E=-1,k=-1,L=-1;const C=(S,N)=>{k=S,L=S===Mt?N:-1,S===Mt&&(d==null||d.show()),S===Ce&&(f==null||f.show()),m&&S===Mt&&N!==E&&(E=N,m.openScene(N))},O=S=>{S!==k&&(S===Mt&&(d==null||d.hide(),m&&E>=0&&(E=-1,m.closeScene())),S===Ce&&(f==null||f.hide()))};let F=null;const W=Mi(o||t.engine3d?{creator:()=>F==null?void 0:F._creator,surface:d,presented:()=>L,frameRendered:()=>{var S;return!!((S=x._creatorWebFrameRendered)!=null&&S.call(x))},view:(d==null?void 0:d.canvas)??n}:null),$=ii();let j=t.keyboardBand??0;const A=g?Xs(n,{M:x,canvas:g,canvasHost:$,keyboardHeight:()=>{const S=h.visualViewport,N=S?Math.max(0,Math.round((h.innerHeight-S.height-S.offsetTop)/(It(n)*c.scale()))):0;return N>0?N:j},onKeyboard:t.onKeyboard}):null;A&&(A.ui.onDestination=C,A.ui.onDropped=O);const v=Hi({onOrientation:t.onOrientation,onWorldChange:()=>W.worldChanged(),push:(S,N)=>{S==="url"&&N!==void 0&&p(N,D=>x._creatorWebSetLaunchUrl(D)),p(S,D=>{N===void 0?x._creatorWebAppEvent(D,0):p(N,Z=>x._creatorWebAppEvent(D,Z))})}}),T=Qi(),I=Ji(),z=Xi({windows:[...new Set([h,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,scale:()=>It(n)*c.scale(),push:(S,N,D,Z)=>p(N,st=>x._creatorWebInputEvent(S,st,D,Z)),keyboardHeight:()=>(A==null?void 0:A.ui.keyboardHeight())??0}),J={ui:(A==null?void 0:A.ui)??eo(C,O),app:v.table,device:Gi(t.language??(()=>(h.navigator.language||"en").slice(0,2)),()=>c.size().factor),fetch:ji(w),storage:Zi(t.project??(e==null?void 0:e.name)??"app"),socket:T.table,service:I.table,input:z.table,media:Yi,canvas:$.table,...d?{gl:d.table(x)}:{},...f?{scene2d:f.table(x)}:{}},_=qe(),M=_.global;F=M,sr(x,{host:J,world:_,newWorld:()=>{const S=qe();return F=S.global,S}});const U=Li({...A?{registerView:(S,N,D)=>A.ui.registerView(S,N,D),unregisterView:S=>A.ui.unregisterView(S)}:{},registerService:I.registerService,unregisterService:I.unregisterService},W.facade);x._creatorWebInit(),t.launchUrl&&p(t.launchUrl,S=>x._creatorWebSetLaunchUrl(S)),A==null||A.ui.install(),!o&&t.engine3d&&(m=await t.engine3d({newCanvas:c.newCanvas,preloads:r,canvasHost:$,stores:to}),Object.defineProperty(M,"_creator",{value:m,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Rt=M._creator)==null||Rt.createEngine());const P=Pi(n);t.safeArea&&P.set(t.safeArea);const rt=S=>{var N;d==null||d.resize(),f==null||f.resize(),(N=m==null?void 0:m._onResize)==null||N.call(m,S.width,S.height,S.factor),A?(A.resize(S.width,S.height,S.factor,S.scale),A.setSafeArea(P.current())):x._creatorWebResize(S.width,S.height)};c.onResize(rt),rt(c.size());let Q=0;const ct=S=>{Q=h.requestAnimationFrame(ct),W.before(),d==null||d.frame(),x._creatorWebTick(S),W.after(),f==null||f.frame(S),A&&(A.ui.layoutFrame(),A.ui.tickHover(),A.render())};Q=h.requestAnimationFrame(ct),await u;let pt=!1;return{profile:s,M:x,world:M,ui:(A==null?void 0:A.ui)??null,engine3d:()=>m,getBuffer:S=>et(S),run(S,N={}){const D=N.header??Ln(S);if(!ui(D.sdk,Ve))throw new Error(`This app was built with LeCodes SDK ${D.sdk??"older than 2.0"}; this host runs SDK ${Ve}. It needs a new build.`);const Z=y.track(S,N.onError);return U.allow(D.plugins),p(S,st=>x._creatorWebRun(st)),{dispose:Z.drop}},registerPlugin:(S,N)=>U.register(S,N),hasPlugin:U.has,locate:y.locate,safeArea:()=>P.current(),setSafeArea(S){P.set(S),A==null||A.setSafeArea(P.current())},setKeyboardBand(S){j=S??0,A==null||A.ui.refreshKeyboard()},remeasure:c.remeasure,setScale:c.setScale,size:c.size,emitAppEvent:v.emit,destroy(){var S;pt||(pt=!0,h.cancelAnimationFrame(Q),y.dispose(),A==null||A.destroy(),z.dispose(),T.dispose(),I.dispose(),v.dispose(),wn(),P.destroy(),(S=m==null?void 0:m._dispose)==null||S.call(m),d==null||d.destroy(),f==null||f.destroy(),c.destroy())}}},ro=(n,t,e,s)=>new Promise(r=>{const i=n.ownerDocument.defaultView??window;i.requestAnimationFrame(()=>{try{const o=[...n.querySelectorAll("canvas")].filter(h=>h.width>0&&h.height>0&&i.getComputedStyle(h).display!=="none");if(o.length===0||t<=0||e<=0){r(null);return}const a=s??Math.max(...o.map(h=>h.width))/t,c=n.ownerDocument.createElement("canvas");c.width=Math.max(1,Math.round(t*a)),c.height=Math.max(1,Math.round(e*a));const l=c.getContext("2d");if(!l){r(null);return}l.fillStyle="#000000",l.fillRect(0,0,c.width,c.height);for(const h of o)l.drawImage(h,0,0,h.width,h.height,0,0,c.width,c.height);r(c.toDataURL("image/png"))}catch{r(null)}})}),so=n=>{if(typeof n=="string")return n;if(n instanceof Error)return n.stack?`${String(n)}
|
|
19
|
+
${n.stack}`:String(n);try{return JSON.stringify(n)}catch{return String(n)}},io=(n,t)=>{const e=o=>{fetch(`${n}/log`,{method:"POST",body:JSON.stringify(o),headers:{"content-type":"application/json"},keepalive:!0}).catch(()=>{})};let s=-1;const r=async()=>{try{const{v:o}=await(await fetch(`${n}/version`,{cache:"no-store"})).json();typeof o=="number"&&t(o)}catch{}setTimeout(r,2500)};setTimeout(r,2500);const i=()=>{let o;try{o=new WebSocket(n.replace(/^http/,"ws")+"/ws")}catch{return}o.onopen=()=>o.send(JSON.stringify({type:"hello",v:s})),o.onmessage=a=>{let c={};try{c=JSON.parse(String(a.data))}catch{return}c.type==="reload"&&typeof c.v=="number"&&t(c.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const c=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(c)?c:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(so).join(" ")}),error:o=>e({type:"error",text:o})}},oo={ar:()=>H(()=>import("./assets/ar-mVXX3kRQ.js"),[],import.meta.url).then(n=>t=>n.register(t,()=>H(()=>import("./assets/ar-D6oDL4pw.js"),[],import.meta.url).then(e=>e.resources))),"audio-recorder":()=>H(()=>import("./assets/audio-recorder-Bt-Caym7.js"),[],import.meta.url).then(n=>t=>n.register(t)),browser:()=>H(()=>import("./assets/browser-BpFb50ko.js"),[],import.meta.url).then(n=>t=>n.register(t)),camera:()=>H(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>H(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>H(()=>import("./assets/map-8PhtP3jn.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>H(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>H(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t)),speech:()=>H(()=>import("./assets/speech-DzDPVK_j.js"),[],import.meta.url).then(n=>t=>n.register(t)),webrtc:()=>H(()=>import("./assets/webrtc-CbCltXvl.js"),[],import.meta.url).then(n=>t=>n.register(t))},ao=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=oo[e];if(!(!s||n.hasPlugin(e)))try{n.registerPlugin(e,await s())}catch(r){console.warn(`[lecodes] the "${e}" plugin failed to load: ${r instanceof Error?r.message:String(r)}`)}}))},me=n=>typeof n=="object"&&n!==null,at=n=>typeof n=="number"&&Number.isFinite(n),co=n=>{if(!me(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return at(n.x)&&at(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return at(n.node)?{ask:"node",node:n.node}:null;default:return null}},On=n=>{if(!me(n))return null;const t=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0?Math.round(s):0,e=Array.isArray(n.bars)?n.bars.filter(s=>s==="top"||s==="right"||s==="bottom"||s==="left"):void 0;return{top:t(n.top),right:t(n.right),bottom:t(n.bottom),left:t(n.left),...e?{bars:e}:{}}},lo=n=>{const t=Number(n.get("keyboard-band"));return Number.isFinite(t)&&t>0?t:null},In=n=>at(n)&&n>0?Math.min(4,n):null,ho=n=>In(Number(n.get("scale"))),uo=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return On({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},fo=n=>{if(!me(n))return null;switch(n.type){case"lecodes:run":return typeof n.src=="string"?{type:"lecodes:run",src:n.src}:null;case"lecodes:reload":return{type:"lecodes:reload"};case"lecodes:safe-area":return{type:"lecodes:safe-area",insets:On(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:keyboard-band":return{type:"lecodes:keyboard-band",height:at(n.height)&&n.height>0?n.height:null};case"lecodes:scale":{const t=In(n.scale);return t===null?null:{type:"lecodes:scale",scale:t}}case"lecodes:inspect":{const t=co(n.question);return t&&at(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!at(n.request))return null;const t=at(n.pixelRatio)&&n.pixelRatio>0?Math.min(4,n.pixelRatio):void 0;return{type:"lecodes:capture",request:n.request,...t!==void 0?{pixelRatio:t}:{}}}default:return null}},go=(n,t)=>{try{const e=new URL(n,t);return e.origin===new URL(t).origin&&(e.protocol==="http:"||e.protocol==="https:")?e.href:null}catch{return null}},po=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=fo(r.data);i&&t(i)};return n.addEventListener("message",s),{embedded:e!==null,post(r){e==null||e.postMessage(r,"*")},close(){n.removeEventListener("message",s)}}},Tt=window.lecodesPlayerConfig??{},xt=document.getElementById("app"),Zt=document.getElementById("loader"),Je=document.getElementById("error"),nt=new URLSearchParams(location.search),Fn=n=>Zt==null?void 0:Zt.classList.toggle("on",n),Nn=n=>{Je&&(Je.textContent=window.parent===window?n:"")};let ue=Tt.language||nt.get("lang")||(navigator.language||"en").slice(0,2),Ut=Tt.safeArea??uo(nt),Bt=Tt.keyboardBand??lo(nt),tt=Tt.scale??ho(nt)??1,B=null;const Qe=()=>{var n;return(n=B==null?void 0:B.world)==null?void 0:n._creatorTree},Dt=nt.has("test")?{ready:!1,dump:()=>{var n;return((n=Qe())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Qe())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=xt.getBoundingClientRect();return[e.left+t[0]*tt,e.top+t[1]*tt,t[2]*tt,t[3]*tt]}}:null;Dt&&(window.lecodesTest=Dt);const mo=nt.has("inspect"),de=mo?H(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url):null;let vt=null;const yo=async(n,t)=>{const{createInspector:e}=await(de??H(()=>import("./assets/inspect-FppKjiJX.js"),[],import.meta.url));B&&vt===null&&(vt=e(B)),Y.post({type:"lecodes:inspected",request:n,answer:(vt==null?void 0:vt.answer(t))??null})},Ze=nt.has("dev")?new URL(nt.get("dev")||"..",location.href).href.replace(/\/$/,""):null,tn=n=>{var s;const t=n.frames[0],e=t?`
|
|
20
20
|
at ${t.source}:${t.line}:${t.column}${t.fn?` (${t.fn})`:""}`:(s=n.nativeFrames)!=null&&s.length?`
|
|
21
|
-
in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},
|
|
21
|
+
in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},Un=n=>{Nn(tn(n)),Y.post({type:"lecodes:error",error:n}),K==null||K.error(tn(n))},Bn=n=>Un({message:n,frames:[]});let dt=null,te=!1,ee=null;const wo=async n=>{Fn(!0),Nn(""),B==null||B.destroy(),B=null,vt=null,xt.replaceChildren();const t=await fetch(n.src,{cache:"no-store"});if(!t.ok)throw new Error(t.status===503?"No successful compile yet — check the terminal.":`${n.src} → HTTP ${t.status}`);const e=await t.text(),s=Ln(e);B=await no(xt,{header:s,language:()=>ue,launchUrl:location.href,...Ut?{safeArea:Ut}:{},...Bt?{keyboardBand:Bt}:{},scale:tt,...Y.embedded?{onKeyboard:(r,i)=>Y.post({type:"lecodes:keyboard",height:r,duration:i})}:{},...Y.embedded?{onOrientation:r=>Y.post({type:"lecodes:orientation",mode:r})}:{}}),await ao(B,s.plugins),de&&(await de).recordSites(B),B.run(e,{onError:Un}),Dt&&(Dt.ready=!0),K&&n.version!==void 0&&(Wt=K.versionOf(t,n.version),K.ran(Wt)),Y.post({type:"lecodes:ready",src:n.src})},gt=n=>{if(te){ee=n;return}te=!0,dt=n,wo(n).catch(t=>Bn(t instanceof Error?t.message:String(t))).finally(()=>{Fn(!1),te=!1;const t=ee;ee=null,t&>(t)})},ye=n=>{const t=go(n,location.href);t?gt({src:t}):Bn(`The player runs bundles of its own origin only: ${n}`)},Dn=n=>{Ut=n,B==null||B.setSafeArea(Ut)},bo=n=>{Bt=n,B==null||B.setKeyboardBand(Bt)},Wn=n=>{tt=n,B==null||B.setScale(tt)},Hn=async n=>{const t=B==null?void 0:B.size(),[e,s]=t?[t.width,t.height]:[Math.round(xt.clientWidth/tt),Math.round(xt.clientHeight/tt)];return{image:B?await ro(xt,e,s,n):null,width:e,height:s}},Y=po(window,n=>{switch(n.type){case"lecodes:run":ye(n.src);break;case"lecodes:reload":dt&>(dt);break;case"lecodes:safe-area":Dn(n.insets);break;case"lecodes:keyboard-band":bo(n.height);break;case"lecodes:scale":Wn(n.scale);break;case"lecodes:inspect":yo(n.request,n.question);break;case"lecodes:capture":Hn(n.pixelRatio).then(t=>Y.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===ue)break;ue=n.language,dt&>(dt);break}});let Wt=-1;const K=Ze?io(Ze,n=>{Wt>=0&&n!==Wt&>({src:K.bundleUrl(n),version:n})}):null;if(K||Y.embedded){let n=!1;for(const t of["log","warn","error"]){const e=console[t];console[t]=(...s)=>{if(e.apply(console,s),!(n||typeof s[0]=="string"&&s[0].startsWith("[lecodes] "))){n=!0;try{K==null||K.log(t,s),Y.post({type:"lecodes:log",level:t,text:s.map(r=>typeof r=="string"?r:r instanceof Error?String(r):(()=>{try{return JSON.stringify(r)}catch{return String(r)}})()).join(" ")})}finally{n=!1}}}}}window.lecodesPlayer={version:"13657f2a-2026-11-05",get host(){return B},run:ye,reload(){dt&>(dt)},setSafeArea:Dn,setScale:Wn,capture:async n=>(await Hn(n)).image};const en=Tt.src??nt.get("src");K?gt({src:K.bundleUrl(0),version:0}):en&&ye(en);export{H as _};
|