lecodes-cli 2.0.6 → 2.0.8

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "8895e4e-2026-10-04",
3
- "commit": "8895e4e",
4
- "date": "2026-10-04T20:22:12.619Z"
2
+ "version": "3caa7cd-2026-10-06",
3
+ "commit": "3caa7cd",
4
+ "date": "2026-10-06T14:31:20.268Z"
5
5
  }
@@ -6,16 +6,16 @@ var Tn=Object.defineProperty;var kn=(n,t,e)=>t in n?Tn(n,t,{enumerable:!0,config
6
6
  `).map(r=>{if(tt.lastIndex=0,!tt.test(r))return r;const i=Ze(r);return i==="other"?r:r.replace(tt,(o,a)=>{const h=t.get(Number(a));return h===void 0?o:(e=!0,`${i===null?"?":""}${Qe(h)} (${o})`)})});return e?s.join(`
7
7
  `):null},jn=async n=>{if(tt.lastIndex=0,!tt.test(n))return[];const t=await Je();if(!t)return[];const e=[];for(const s of n.split(`
8
8
  `))if(Ze(s)!=="other")for(const r of s.matchAll(tt)){const i=t.get(Number(r[1]));i!==void 0&&e.push(Qe(i).replaceAll("std::__2::","std::"))}return e},we=n=>{const t=n==null?void 0:n.stack;typeof t=="string"&&Gn(t).then(e=>{e&&console.error(`[creator-gl] decoded wasm stack (via creator-gl.js.symbols):
9
- `+e)})};let be=!1;const Vn=()=>{be||(be=!0,addEventListener("error",n=>we(n.error)),addEventListener("unhandledrejection",n=>we(n.reason)))},B=[null];new TextDecoder("utf-8");const zn=async(n,t,e,s)=>{var d;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const p=new FormData;for(let[b,g,x]of t.body._entries)typeof g=="object"?p.append(b,new Blob([et(g._id)]),x):p.append(b,g);r=p}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 p=await i.arrayBuffer();B.push(p),e(B.length-1,i.status);return}const a=(d=i.body)==null?void 0:d.getReader();if(!a){const p=await i.arrayBuffer();B.push(p),e(B.length-1,i.status);return}const h=Number(i.headers.get("content-length"))||void 0;let l=0;const c=[];for(;;){const{done:p,value:b}=await a.read();if(p)break;b&&(c.push(b),l+=b.length,o({loaded:l,total:h}))}const f=new Uint8Array(l);let u=0;for(const p of c)f.set(p,u),u+=p.length;B.push(f.buffer),e(B.length-1,i.status)},Xn=n=>{const t=new Blob([B[n]]);return URL.createObjectURL(t)},Ot=n=>new Blob([B[n]]),et=n=>B[n],Yn=n=>{B[n]=null},ot=n=>(B.push(n),B.length-1),oe=new Map,Kn=(n,t)=>{oe.set(n,t);const e=At.get(n);e!==void 0&&(B[e]=t)},qn=n=>oe.has(n),At=new Map,Jn=n=>{for(const[t,e]of At)if(e===n)return t},Qn=n=>{const t=At.get(n);if(t!==void 0)return t;const e=oe.get(n);if(!e)return-1;B.push(e);const s=B.length-1;return At.set(n,s),s},ae=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function tn(n){return typeof n=="object"&&n!==null&&"svg"in n}function Zn(n){return typeof n=="object"&&n!==null&&"_id"in n}function tr(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const Jt="lecodes-canvas://";function er(n){return n.startsWith(Jt)?Number(n.slice(Jt.length)):void 0}function nr(n){return typeof File<"u"&&n instanceof File}function en(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 It(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function Qt(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 h=parseFloat(e[1]),l=parseFloat(e[2]);if(h>0&&l>0)return{width:h,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 rr(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 sr(n,t){if(!It(n))return null;const e=rr(n);if(e)return Qt(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?Qt(s):null}function ir(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 tn(s)?i=en(s.svg):tr(s)?i=Jt+s.canvasSurface:Zn(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):nr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function ve(n,t){if(!t)return;const e=er(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 nn=n=>n==="monospaced"?"monospace":n;function xe(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${nn(n.family)}`}class or{constructor(t={}){w(this,"ctx");w(this,"images",new Map);w(this,"pending",new Map);w(this,"resolver");w(this,"canvasSurfaces");w(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=ir({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return nn(t)}measureText(t,e){return this.ctx.font=xe(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=xe(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 ve(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=ve(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,h=o.naturalHeight;if(It(t)){const c=await sr(t,f=>fetch(f).then(u=>u.ok?u.text():null));c&&(a=c.width,h=c.height)}const l={src:t,naturalWidth:a,naturalHeight:h,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 ar(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function lt(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function st(n){const{r:t,g:e,b:s,a:r}=ar(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function rn(n){return n===void 0||(n>>>0&255)===0}function Zt(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 Se(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function cr(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 h=Math.max(e.width/n,e.height/t),l=e.width/h,c=e.height/h;return{src:{x:(n-l)/2,y:(t-c)/2,width:l,height:c},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 lr(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 hr(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const p=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,b=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:p,ry:b}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,h=Math.min(r,i),l=Math.max(r,i),c=Math.min(o,a),f=Math.max(o,a);let u,d;if(n.shape==="circle"){let p;switch(n.extent){case"closest-side":p=Math.min(h,c);break;case"farthest-side":p=Math.max(l,f);break;case"closest-corner":p=Math.hypot(h,c);break;default:p=Math.hypot(l,f);break}u=d=p}else switch(n.extent){case"closest-side":u=h,d=c;break;case"farthest-side":u=l,d=f;break;case"closest-corner":u=h*Math.SQRT2,d=c*Math.SQRT2;break;default:u=l*Math.SQRT2,d=f*Math.SQRT2;break}return{cx:e,cy:s,rx:u,ry:d}}class Ee{constructor(t,e=1){w(this,"ctx");w(this,"dpr");w(this,"groups",[]);w(this,"scratch");w(this,"scratchCtx");w(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=st(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}=lr(s.angle,t),h=this.ctx.createLinearGradient(r,i,o,a);for(const l of s.stops)h.addColorStop(Math.max(0,Math.min(1,l.position)),st(l.color));this.path(t,e),this.ctx.fillStyle=h,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=hr(s,t),h=this.ctx,l=o||1e-6,c=a||1e-6;h.save(),this.path(t,e),h.clip(),h.translate(r,i),h.scale(l,c);const f=h.createRadialGradient(0,0,0,0,0,1);for(const g of s.stops)f.addColorStop(Math.max(0,Math.min(1,g.position)),st(g.color));h.fillStyle=f;const u=(t.x-r)/l,d=(t.x+t.width-r)/l,p=(t.y-i)/c,b=(t.y+t.height-i)/c;h.fillRect(u,p,d-u,b-p),h.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,h=Zt(e,t);r.beginPath(),this.addRectPath(t,h);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 c=h&&Zt({tl:Math.max(0,h.tl-a),tr:Math.max(0,h.tr-a),br:Math.max(0,h.br-a),bl:Math.max(0,h.bl-a)},l);this.addRectPath(l,c||void 0)}r.fillStyle=st(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:h,color:l}=s[a];r.fillStyle=st(l),a==="top"?r.fillRect(t.x,t.y,t.width,h):a==="bottom"?r.fillRect(t.x,t.y+t.height-h,t.width,h):a==="left"?r.fillRect(t.x,t.y,h,t.height):r.fillRect(t.x+t.width-h,t.y,h,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 d=t.naturalWidth,p=t.naturalHeight;if(d<=0||p<=0)return;const b=Math.max(1,Math.ceil(d*this.dpr)),g=Math.max(1,Math.ceil(p*this.dpr)),x=t.rasterize!==void 0||It(t.src),m=x?this.tileCell(t,b,g):t.handle,v=x?d/b:1,_=x?p/g:1,M=this.ctx.createPattern(m,"repeat");if(!M)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(v,_),this.ctx.fillStyle=M,this.ctx.fillRect(0,0,s.width/v,s.height/_),this.ctx.restore();return}const i=e?{src:e,dst:s}:cr(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const h=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),c=!e&&r.fit!=="cover";let f=t.handle;if(t.rasterize)if(c)f=t.rasterize(h,l);else{const d=Math.max(h/a.width,l/a.height),p=Math.max(1,Math.ceil(t.naturalWidth*d)),b=Math.max(1,Math.ceil(t.naturalHeight*d));f=t.rasterize(p,b);const g=p/t.naturalWidth,x=b/t.naturalHeight;a={x:a.x*g,y:a.y*x,width:a.width*g,height:a.height*x}}if(r.tint===void 0){c?this.ctx.drawImage(f,o.x,o.y,o.width,o.height):this.ctx.drawImage(f,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const u=this.getScratch(h,l);u.clearRect(0,0,h,l),u.globalCompositeOperation="source-over",c?u.drawImage(f,0,0,h,l):u.drawImage(f,a.x,a.y,a.width,a.height,0,0,h,l),u.globalCompositeOperation="source-in",u.fillStyle=st(r.tint),u.fillRect(0,0,h,l),u.globalCompositeOperation="source-over",this.ctx.drawImage(u.canvas,0,0,h,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=st(i),o.fillText(t,e,s)}}const $=[null],yt=[!1],sn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),yt[t]&&(n.currentTime=0,n.play())})},ur=(n,t)=>{const e=document.createElement("video");document.body.appendChild(e),e.crossOrigin="anonymous",e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n,e.playsInline=!0,e.controls=!1;const s=$.length;return $.push(e),yt.push(!1),sn(e,s,t),s},dr=(n,t)=>{const e=document.createElement("audio");document.body.appendChild(e),e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n;const s=$.length;return $.push(e),yt.push(!1),sn(e,s,t),s},fr=(n,t)=>{const e=$[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},pr=(n,t)=>{const e=$[n];e&&(t?e.play():e.pause())},gr=(n,t)=>{yt[n]=t},mr=n=>{var t;return((t=$[n])==null?void 0:t.currentTime)??0},yr=(n,t)=>{const e=$[n];e&&(e.currentTime=t)},wr=n=>{var e;const t=((e=$[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},ce=n=>$[n],on=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},br=n=>{const t=$[n];t&&(on(t),$[n]=null,yt[n]=!1)},an=()=>{for(let n of $)n&&on(n);$.length=1,yt.length=1},vr=9,xr=10,Sr=12,Er=13,_r=14,Tr=15,kr=16,Rr=1,Ar=2,Mr=4,_e=8,Lr=16,Pr=32,Cr=64,Or=256,Ir=512,Fr=1024,Nr=2048,Ur=4096,Te=0,Ut=1,ke=2,Wt=3;function Wr(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 ft(n,t,e,s){let r=null;const i=o=>{const a=Wr(o,t,e);if(a&&s(o)&&(r=o),!(o.clip&&!a))for(const h of o.children)i(h)};return i(n),r}const Dr=78,Hr={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:46},fontSize:{word:51},fontWeight:{word:52},fontStyle:{word:53},fontFamily:{bit:39,word:54},lineHeight:{word:55},letterSpacing:{word:56},textAlign:{word:57},textDecoration:{word:58},lineClamp:{word:59},textOverflow:{word:60},objectFit:{word:61},placeholder:{word:62},type:{word:63},dim:{word:77}},Br={hidden:1},$r={horizontal:1},Gr={italic:1},ht={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},jr=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,Vr=["farthest-corner","closest-side","closest-corner","farthest-side"],zr=52;function Xr(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Yr(n,t,e+i*zr));return r}function Yr(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],h=[];for(let l=0;l<o;l++){const c=a+l*8>>2;h.push({color:t[c]>>>0,position:n[c+1]})}if(i===1){const l=t[s+6],c={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:h};return l===4?{...c,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...c,extent:Vr[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:h}}const T=Hr,Kr=["start","center","end","start","end"];let _t=0;function cn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],h=v=>jr(o,a,v),l=v=>{const _=s[i+v];return _===0?void 0:n.UTF8ToString(n._cuiStringOf(_))};e.backgroundColor=s[i+T.backgroundColor.word]>>>0,e.opacity=r[i+T.opacity.word],e.dim=r[i+T.dim.word],e.display=ht.display[s[i+T.display.word]],e.overflow=s[i+T.overflow.word]===Br.hidden?"hidden":"visible",e.scrollAxis=s[i+T.scrollDirection.word]===$r.horizontal?"x":"y",e.border={top:{width:r[i+T.borderTopWidth.word],color:s[i+T.borderTopColor.word]>>>0},right:{width:r[i+T.borderRightWidth.word],color:s[i+T.borderRightColor.word]>>>0},bottom:{width:r[i+T.borderBottomWidth.word],color:s[i+T.borderBottomColor.word]>>>0},left:{width:r[i+T.borderLeftWidth.word],color:s[i+T.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+T.borderTopLeftRadius.word],tr:r[i+T.borderTopRightRadius.word],br:r[i+T.borderBottomRightRadius.word],bl:r[i+T.borderBottomLeftRadius.word]},e.backgroundImage=l(T.backgroundImage.word),e.backgroundSize=ht.backgroundSize[s[i+T.backgroundSize.word]];const c=s[i+T.backgroundGradient.word];if(c===0)e.backgroundGradients=void 0;else{_t===0&&(_t=n._malloc(4));const v=n._cuiGradientOf(c,_t),_=n.HEAPU32[_t>>>2];e.backgroundGradients=v!==0&&_>0?Xr(n.HEAPF32,n.HEAPU32,v,_):void 0}const f=i+T.transform.word,u=r[f],d=r[f+1],p=r[f+3],b=r[f+4],g=r[f+6],x=r[f+7];e.transform=u===1&&d===0&&p===0&&b===1&&g===0&&x===0?void 0:[u,d,p,b,g,x];const m=i+T.transformOrigin.word;e.transformOrigin={x:r[m],y:r[m+1],xPercent:s[m+2]!==0,yPercent:s[m+3]!==0},e.color=h(T.color.bit)?s[i+T.color.word]>>>0:void 0,e.fontFamily=h(T.fontFamily.bit)?l(T.fontFamily.word):void 0,e.fontSize=r[i+T.fontSize.word],e.fontWeight=r[i+T.fontWeight.word],e.fontStyle=s[i+T.fontStyle.word]===Gr.italic?"italic":"normal",e.lineHeight=r[i+T.lineHeight.word],e.letterSpacing=r[i+T.letterSpacing.word],e.textAlign=Kr[s[i+T.textAlign.word]]??"start",e.textDecoration=ht.textDecoration[s[i+T.textDecoration.word]],e.lineClamp=r[i+T.lineClamp.word],e.textOverflow=ht.textOverflow[s[i+T.textOverflow.word]],e.objectFit=ht.objectFit[s[i+T.objectFit.word]],e.tintColor=h(T.tintColor.bit)?s[i+T.tintColor.word]>>>0:void 0,e.placeholder=l(T.placeholder.word),e.placeholderColor=h(T.placeholderColor.bit)?s[i+T.placeholderColor.word]>>>0:void 0,e.inputType=ht.type[s[i+T.type.word]],e.overlayColor=h(T.overlayColor.bit)?s[i+T.overlayColor.word]>>>0:void 0}function qr(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 Jr(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(cn(n,s,e),!0)}function Qr(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*Dr*4;t(o,h=>cn(n,a,h))}return e}const Z={color:255,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function te(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:h,textAlign:l,textDecoration:c}=t,f=s??Z.fontSize;return{color:e??Z.color,fontSize:f,fontFamily:r??Z.fontFamily,fontWeight:i??Z.fontWeight,fontStyle:o??Z.fontStyle,lineHeight:a,letterSpacing:h??Z.letterSpacing,textAlign:l??Z.textAlign,textDecoration:c??Z.textDecoration}}function ln(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}function vt(n,t,e){const s=[];let r=0;for(const i of n.split(`
10
- `)){if(i.length===0){s.push("");continue}let o=i;for(;o;){if(e(o)<=t){s.push(o),r=Math.max(r,e(o));break}let a=0,h=-1,l=0;for(;(l=o.indexOf(" ",l+1))!==-1&&!(e(o.substring(0,l))>t);)h=l;if(h>0)a=h;else{let f=o.indexOf(" ");f===-1&&(f=o.length);const u=o.substring(0,f);if(e(u)>t){for(let d=1;d<=u.length;d++)if(e(u.substring(0,d))>t){a=d-1;break}}else for(let d=f+1;d<=o.length;d++)if(e(o.substring(0,d))>t){a=d-1;break}}a<=0&&(a=1);const c=o.substring(0,a);s.push(c),r=Math.max(r,e(c)),o=o.substring(a+(h>0?1:0))}}return{lines:s,maxWidth:r}}const Dt="…";function hn(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]=Zr(i[r-1],e,s)),i}function Zr(n,t,e){if(!isFinite(t))return n+Dt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+Dt)>t;)r--;return s.slice(0,r).join("").trimEnd()+Dt}function ts(n,t,e){const s=te(n),r=ln(s),i=isNaN(e)?1/0:e,o=c=>t.measureText(c,r),a=vt(n.text??"",i,o),h=hn(a.lines,n.style,i,o);let l=a.maxWidth;if(h!==a.lines){l=0;for(const c of h)l=Math.max(l,o(c))}return{width:Math.ceil(l),height:Math.ceil(h.length*s.lineHeight)}}function es(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,h=vt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(h.maxWidth),height:Math.ceil(Math.max(1,h.lines.length)*i)}}function ns(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(tn(r)){const l=Qt(r.svg);if(l)i=l.width,o=l.height;else{const c=t.getImage(t.resolveSrc(r)??"");i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}}else{const l=t.resolveSrc(r),c=l?t.getImage(l):void 0;i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),h=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*h,height:o*h}}function rs(n,t,e,s,r,i,o={}){t.beginFrame(s,r);const a=n.filter(h=>h.widget);for(const h of n)h.widget||ee(h.tree,t,e,o);for(const h of a)h.backdrop&&t.fillRoundRect({x:0,y:0,width:s,height:r},void 0,h.backdrop.color);for(const h of a)ee(h.tree,t,e,o);t.endFrame()}function ee(n,t,e,s){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[c,f,u,d,p,b]=r.transform,g=r.transformOrigin,x=i.x+(g?g.xPercent?i.width*g.x/100:g.x:i.width/2),m=i.y+(g?g.yPercent?i.height*g.y/100:g.y:i.height/2);t.translate(x,m),t.transform(c,f,u,d,p,b),t.translate(-x,-m)}const h=Zt(r.borderRadius,i);if(rn(r.backgroundColor)||t.fillRoundRect(i,h,r.backgroundColor),r.backgroundImage){const c=e.getImage(r.backgroundImage);c&&c.naturalWidth>0&&c.naturalHeight>0&&(t.save(),Se(h)&&t.clipRoundRect(i,h),t.drawImage(c,null,i,{fit:ss(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let c=r.backgroundGradients.length-1;c>=0;c--){const f=r.backgroundGradients[c];f.stops.length>0&&t.fillGradient(i,h,f)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const c=n.sourceRect;t.save(),Se(h)&&t.clipRoundRect(i,h),t.drawImage(n.image,c?{x:c[0],y:c[1],width:c[2],height:c[3]}:null,i,{fit:c?"fill":r.objectFit??"contain",tint:It(n.image.src)?r.tintColor:void 0,radius:h}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&os(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&cs(n,t,e,h),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,h):n.type==="video"&&as(n,t,e,h)),n.clip&&t.clipRoundRect(i,h);for(const c of n.children)ee(c,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,h,Math.round(Math.min(1,r.dim)*255)>>>0);const l=is(r.border);l&&t.strokeBorder(i,h,l),a&&t.endGroup(),t.restore()}function ss(n){return n==="contain"||n==="fill"?n:"cover"}function is(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 un=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function os(n,t,e){var g,x,m;const s=n.style,r={family:un(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",h=e.fontMetrics(r),{rect:l,lines:c}=n,f=((g=n.padding)==null?void 0:g[0])??0,u=((x=n.padding)==null?void 0:x[1])??0,d=((m=n.padding)==null?void 0:m[2])??0,p=l.x+f,b=l.width-f-d;for(let v=0;v<c.length;v++){const _=c[v],P=l.y+u+v*o+(o-(h.ascent+h.descent))/2+h.ascent,I=e.measureText(_,r),F=a==="center"?p+(b-I)/2:a==="end"?p+b-I:p;if(t.fillText(_,F,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const D=Math.max(1,r.size/14),R=s.textDecoration==="underline"?P+D:P-r.size*.3;t.fillRoundRect({x:F,y:R,width:I,height:D},void 0,i)}}}function as(n,t,e,s){const{rect:r}=n;rn(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),h=e.measureText("▶",o),l=r.x+(r.width-h)/2,c=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,c,o,4294967244)}}function cs(n,t,e,s){var z,G,j,y,L;const r=n.style,i={family:un(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,h=r.inputType==="password"&&!a,l=a?r.placeholder??"":h?"•".repeat(o.length):o,c=a?r.placeholderColor??2576980479:r.color??255,{rect:f}=n,u=((z=n.padding)==null?void 0:z[0])??0,d=((G=n.padding)==null?void 0:G[1])??0,p=((j=n.padding)==null?void 0:j[2])??0,b=((y=n.padding)==null?void 0:y[3])??0,g=f.x+u,x=f.width-u-p,m=f.y+d,v=f.height-d-b,_=e.fontMetrics(i),M=r.lineHeight,P=r.textAlign??"start",I=n.type==="textarea",F=I?vt(l,x,A=>e.measureText(A,i)).lines:[l],D=A=>P==="center"?g+(x-A)/2:P==="end"?g+x-A:g,R=A=>I?m+A*M+(M-(_.ascent+_.descent))/2+_.ascent:m+(v-(_.ascent+_.descent))/2+_.ascent;t.save(),t.clipRoundRect(f,s);for(let A=0;A<F.length;A++){const H=F[A];H.length>0&&t.fillText(H,D(e.measureText(H,i)),R(A),i,c)}if((L=n.state)!=null&&L.focused){const A=a?[""]:I?vt(h?"•".repeat(o.length):o,x,N=>e.measureText(N,i)).lines:[l],H=A.length-1,Y=e.measureText(A[H],i),J=a?D(0):D(Y)+Y,S=R(H),k=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:S-_.ascent,width:k,height:_.ascent+_.descent},void 0,r.color??255)}t.restore()}function dn(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?ne(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>ne(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function ls(n,t=[],e){return JSON.stringify(dn(n,t,e),null,2)}function ut(n,t){const e=10**t;return Math.round(n*e)/e}function ne(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),r.rect=[ut(s.x,t),ut(s.y,t),ut(s.width,t),ut(s.height,t)],e&&(r.id=n.id);const i=us(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:ut(n.scroll.offset,t),content:ut(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(h=>ne(h,t,e))),r}function hs(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 us(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=lt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=lt(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.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=lt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=lt(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:lt(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=hs(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:lt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const ds=.32,fs=4,Re=new Map;function re(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Re.get(n);return t===void 0&&(t=en(n.slice(4)),Re.set(n,t)),t}return n}class ps{constructor(t,e){w(this,"parent",null);w(this,"children",[]);w(this,"style",{lineHeight:14*1.2});w(this,"name");w(this,"text","");w(this,"src");w(this,"value","");w(this,"sourceRect");w(this,"viewName");w(this,"viewParams");w(this,"playerId",0);w(this,"viewId",0);w(this,"flags",0);w(this,"layoutRect",null);w(this,"scrollOffset",0);w(this,"wrapCache");w(this,"jsNode");w(this,"bgRaw");w(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&Rr)!==0}get imageSrcRaw(){return this.type==="image"?re(this.src):void 0}has(t){return(this.flags&t)!==0}}class gs{constructor(t,e,s={}){w(this,"nodes",new Map);w(this,"root",null);w(this,"leaving",null);w(this,"leavingAbove",!1);w(this,"pagerShown",new Map);w(this,"pagerLeaving",new Map);w(this,"destKind",-1);w(this,"widgetRoots",[]);w(this,"width",0);w(this,"height",0);w(this,"focused",null);w(this,"pressed",new Set);w(this,"gestures",new Map);w(this,"vlists",new Set);w(this,"frameCache",null);w(this,"painted",null);w(this,"fontsPending",0);w(this,"lastToast",null);w(this,"dirty",!0);w(this,"onDestination",null);w(this,"onDropped",null);w(this,"layoutPtr",0);w(this,"padPtr",0);w(this,"lastCreated",0);w(this,"hoverX",0);w(this,"hoverY",0);w(this,"hoverInside",!1);w(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,h)=>{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;qr(i,t)&&(Jr(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?ts(o,this.host,e):r.type==="image"?ns(o,this.host,e,s):r.editable?es(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((h,l)=>h|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.dirty=!0}layoutFrame(){const t=this.M;Qr(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(_e)&&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 h=i[s+a],l=this.nodes.get(h);if(!l)continue;const c=o[r+a*4],f=o[r+a*4+1],u=o[r+a*4+2],d=o[r+a*4+3],p={x:c,y:f,width:u-c,height:d-f},b=l.layoutRect,g=!b||b.x!==p.x||b.y!==p.y||b.width!==p.width||b.height!==p.height;l.layoutRect=p,g&&(this.dirty=!0),g&&l.has(_e)&&e._creatorWebNodeLayout(h,c,f,p.width,p.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.leaving?this.build(this.leaving,e):null;if(s&&!this.leavingAbove&&t.push({tree:s,leaving:!0}),this.root){const r=this.build(this.root,e);r&&t.push({tree:r})}s&&this.leavingAbove&&t.push({tree:s,leaving:!0});for(const r of this.widgetRoots){const i=r.layoutRect??{x:0,y:0,width:this.width,height:this.height},o=this.build(r,i);if(!o)continue;const a=o.style.overlayColor;t.push({tree:o,widget:!0,backdrop:a!==void 0?{color:a,jsNode:r.jsNode}:void 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 dn(this.renderTree(),this.widgetTrees())}toText(){return ls(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();rs(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,h)=>{var x;if(i.style.display==="none")return null;let l,c,f,u;if(h)l=e.x,c=e.y,f=e.width,u=e.height;else{const m=i.layoutRect;if(!m)return null;l=o+m.x,c=a+m.y,f=m.width,u=m.height}const d={id:i.id,type:i.type,rect:{x:l,y:c,width:f,height:u},style:i.style,children:[]};i.name&&(d.name=i.name);const p=i;if(i.type==="text"){const m=te(p),v=ln(m);d.text=i.text;const _=this.padding(i.id);(_[0]||_[1]||_[2]||_[3])&&(d.padding=_);const M=f-_[0]-_[2],P=`${M}|${v.size}|${v.weight}|${v.italic?1:0}|${v.letterSpacing}|${v.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.text}`;if(((x=i.wrapCache)==null?void 0:x.key)===P)d.lines=i.wrapCache.lines;else{const I=D=>this.host.measureText(D,v),F=hn(vt(i.text,M,I).lines,i.style,M,I);i.wrapCache={key:P,lines:F},d.lines=F}d.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==="image"){const m=this.host.resolveSrc(i.imageSrcRaw),v=m?this.host.getImage(m):void 0;d.image=v??(m?{src:m,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(d.sourceRect=i.sourceRect)}else if(i.editable){d.value=i.value;const m=this.padding(i.id);(m[0]||m[1]||m[2]||m[3])&&(d.padding=m);const v=te(p);d.style={...i.style,color:v.color,fontSize:v.fontSize,fontFamily:v.fontFamily,fontWeight:v.fontWeight,fontStyle:v.fontStyle,lineHeight:v.lineHeight,letterSpacing:v.letterSpacing,textAlign:v.textAlign,textDecoration:v.textDecoration}}i.interactive&&(d.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(d.state={...d.state,focused:!0}),i.style.overflow==="hidden"&&(d.clip=!0);let b=l,g=c;if(i.scrollable){const m=i.scrollAxis,v=m==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);d.clip=!0,d.scroll={offset:i.scrollOffset,content:v,axis:m},m==="x"?b=l-i.scrollOffset:g=c-i.scrollOffset}if(i.type==="pager"){const m=s._creatorWebPagerSelectedIndex(i.id),v=s._creatorWebPagerStackLen(i.id,m),_=v>0?s._creatorWebPagerPageNode(i.id,m,v-1):0,M=_?this.nodes.get(_):void 0;M?this.pagerShown.set(i.id,M):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const I of P&&P.page!==M?P.above?[M,P.page]:[P.page,M]:[M]){const F=I?r(I,l,c,!1):null;F&&d.children.push(F)}return d}if(i.type==="vlist"){for(const m of i.children){const v=s._getParentNode(m.id);if(!v)continue;const _=s._vlistItemOffsetOf(i.id,v);if(Number.isNaN(_))continue;const M=m.layoutRect??{x:0,y:0},P=r(m,l-M.x,c+_-i.scrollOffset-M.y,!1);P&&d.children.push(P)}return d}for(const m of i.children){const v=r(m,b,g,!1);v&&d.children.push(v)}return d};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*ds):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 ps(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.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard());const s=this.widgetRoots.indexOf(e);s>=0&&this.widgetRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),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 re(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(re(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)),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 h;this.destKind=t;const a=t===Te?this.nodes.get(e)??null:null;a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,this.focused&&this.blurInput(),this.dirty=!0,(h=this.onDestination)==null||h.call(this,t,s)}dropView(t,e,s){var r;if(t===Te){const i=this.nodes.get(e)??null;i!==null&&this.leaving===i&&(this.leaving=null),i!==null&&this.root===i&&(this.root=null)}this.dirty=!0,(r=this.onDropped)==null||r.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)}widgetOpen(t,e,s,r){const i=this.nodes.get(t);i&&!this.widgetRoots.includes(i)&&this.widgetRoots.push(i),this.dirty=!0}widgetClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.widgetRoots.indexOf(e):-1;s>=0&&this.widgetRoots.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}pagerPageMounted(t,e){this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent;)e=e.parent;return e}emitKeyboard(){var e,s;const t=this.keyboardHeight();(s=(e=this.options).onKeyboard)==null||s.call(e,t),this.M._creatorWebKeyboardEvent(t,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(Ir)&&this.M._creatorWebNodeEvent(t,Er),this.M._creatorWebSetShrunkRoot(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(Fr)&&this.M._creatorWebNodeEvent(t.id,_r),this.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Or)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Sr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Nr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Tr,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(Pr)&&this.M._creatorWebNodeEventNum(t,vr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Lr)&&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=ft(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i)return this.nodes.get(i.id)??null;if(s[r].backdrop)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 h=ft(o[a].tree,e,s,l=>{var c;return((c=this.nodes.get(l.id))==null?void 0:c.editable)??!1});if(h){const l=this.nodes.get(h.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(o[a].backdrop)break}for(let a=o.length-1;a>=0;a--){const h=o[a],l=ft(h.tree,e,s,u=>{var d;return((d=this.nodes.get(u.id))==null?void 0:d.interactive)??!1}),c=ft(h.tree,e,s,u=>!!u.scroll&&u.scroll.content>(u.scroll.axis==="x"?u.rect.width:u.rect.height)+.5),f=c?this.nodes.get(c.id)??null:null;if(l){const u=this.nodes.get(l.id);i.node=u,i.scroll=f,i.dismiss=u.type!=="button",this.setPressed(u,!0),r._creatorWebNodeTouchStart(u.id,t,e,s);return}if(f){i.scroll=f;return}if(h.backdrop){const u=h.tree.rect,d=e>=u.x&&e<u.x+u.width&&s>=u.y&&s<u.y+u.height;i.backdrop=d?null:this.nodes.get(h.tree.id)??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>fs&&(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(Cr)&&i._creatorWebNodeEvent(r.scroll.id,xr),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(Ar)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Ur)&&i._creatorWebNodeEvent(r.backdrop.id,kr):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=ft(i[o].tree,t,e,h=>!!h.scroll&&h.scroll.content>(h.scroll.axis==="x"?h.rect.width:h.rect.height)+.5);if(a){const h=this.nodes.get(a.id);return h?this.scrollBy(h.id,h.scrollAxis==="x"?s:r):!1}if(i[o].backdrop)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Mr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const ms=`
9
+ `+e)})};let be=!1;const Vn=()=>{be||(be=!0,addEventListener("error",n=>we(n.error)),addEventListener("unhandledrejection",n=>we(n.reason)))},B=[null];new TextDecoder("utf-8");const zn=async(n,t,e,s)=>{var d;let r;if(t.body)if(typeof t.body=="object"&&Array.isArray(t.body._entries)){const p=new FormData;for(let[b,g,x]of t.body._entries)typeof g=="object"?p.append(b,new Blob([et(g._id)]),x):p.append(b,g);r=p}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 p=await i.arrayBuffer();B.push(p),e(B.length-1,i.status);return}const a=(d=i.body)==null?void 0:d.getReader();if(!a){const p=await i.arrayBuffer();B.push(p),e(B.length-1,i.status);return}const h=Number(i.headers.get("content-length"))||void 0;let l=0;const c=[];for(;;){const{done:p,value:b}=await a.read();if(p)break;b&&(c.push(b),l+=b.length,o({loaded:l,total:h}))}const f=new Uint8Array(l);let u=0;for(const p of c)f.set(p,u),u+=p.length;B.push(f.buffer),e(B.length-1,i.status)},Xn=n=>{const t=new Blob([B[n]]);return URL.createObjectURL(t)},Ot=n=>new Blob([B[n]]),et=n=>B[n],Yn=n=>{B[n]=null},ot=n=>(B.push(n),B.length-1),oe=new Map,Kn=(n,t)=>{oe.set(n,t);const e=At.get(n);e!==void 0&&(B[e]=t)},qn=n=>oe.has(n),At=new Map,Jn=n=>{for(const[t,e]of At)if(e===n)return t},Qn=n=>{const t=At.get(n);if(t!==void 0)return t;const e=oe.get(n);if(!e)return-1;B.push(e);const s=B.length-1;return At.set(n,s),s},ae=n=>{const t=n.clientWidth;if(!t)return 1;const e=n.getBoundingClientRect().width;return e>0?e/t:1};function tn(n){return typeof n=="object"&&n!==null&&"svg"in n}function Zn(n){return typeof n=="object"&&n!==null&&"_id"in n}function tr(n){return typeof n=="object"&&n!==null&&"canvasSurface"in n}const Jt="lecodes-canvas://";function er(n){return n.startsWith(Jt)?Number(n.slice(Jt.length)):void 0}function nr(n){return typeof File<"u"&&n instanceof File}function en(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 It(n){return!!n&&(n.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(n))}function Qt(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 h=parseFloat(e[1]),l=parseFloat(e[2]);if(h>0&&l>0)return{width:h,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 rr(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 sr(n,t){if(!It(n))return null;const e=rr(n);if(e)return Qt(e);if(!t)return null;const s=await t(n).catch(()=>null);return s?Qt(s):null}function ir(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 tn(s)?i=en(s.svg):tr(s)?i=Jt+s.canvasSurface:Zn(s)?i=(o=n.assetUrl)==null?void 0:o.call(n,s._id):nr(s)&&(i=(a=n.fileUrl)==null?void 0:a.call(n,s)),i!==void 0&&t.set(s,i),i}}function ve(n,t){if(!t)return;const e=er(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 nn=n=>n==="monospaced"?"monospace":n;function xe(n){return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${nn(n.family)}`}class or{constructor(t={}){w(this,"ctx");w(this,"images",new Map);w(this,"pending",new Map);w(this,"resolver");w(this,"canvasSurfaces");w(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=ir({assetUrl:t.resolveAssetUrl,fileUrl:s=>URL.createObjectURL(s)})}resolveSrc(t){return this.resolver(t)}pendingImages(){return this.pending.size}resolveFontFamily(t){return nn(t)}measureText(t,e){return this.ctx.font=xe(e),this.ctx.letterSpacing=`${e.letterSpacing}px`,this.ctx.measureText(t).width}fontMetrics(t){this.ctx.font=xe(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 ve(t,this.canvasSurfaces)??this.images.get(t)}loadImage(t){const e=ve(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,h=o.naturalHeight;if(It(t)){const c=await sr(t,f=>fetch(f).then(u=>u.ok?u.text():null));c&&(a=c.width,h=c.height)}const l={src:t,naturalWidth:a,naturalHeight:h,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 ar(n){const t=n>>>0;return{r:t>>>24&255,g:t>>>16&255,b:t>>>8&255,a:t&255}}function lt(n){return"#"+(n>>>0).toString(16).padStart(8,"0")}function st(n){const{r:t,g:e,b:s,a:r}=ar(n);return`rgba(${t}, ${e}, ${s}, ${(r/255).toFixed(4)})`}function rn(n){return n===void 0||(n>>>0&255)===0}function Zt(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 Se(n){return!!n&&(n.tl>0||n.tr>0||n.br>0||n.bl>0)}function cr(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 h=Math.max(e.width/n,e.height/t),l=e.width/h,c=e.height/h;return{src:{x:(n-l)/2,y:(t-c)/2,width:l,height:c},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 lr(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 hr(n,t){const e=t.x+n.cx*t.width,s=t.y+n.cy*t.height;if(n.extent==="explicit"){const p=n.rxUnit==="fraction"?(n.rx??0)*t.width:n.rx??0,b=n.ryUnit==="fraction"?(n.ry??0)*t.height:n.ry??0;return{cx:e,cy:s,rx:p,ry:b}}const r=n.cx*t.width,i=(1-n.cx)*t.width,o=n.cy*t.height,a=(1-n.cy)*t.height,h=Math.min(r,i),l=Math.max(r,i),c=Math.min(o,a),f=Math.max(o,a);let u,d;if(n.shape==="circle"){let p;switch(n.extent){case"closest-side":p=Math.min(h,c);break;case"farthest-side":p=Math.max(l,f);break;case"closest-corner":p=Math.hypot(h,c);break;default:p=Math.hypot(l,f);break}u=d=p}else switch(n.extent){case"closest-side":u=h,d=c;break;case"farthest-side":u=l,d=f;break;case"closest-corner":u=h*Math.SQRT2,d=c*Math.SQRT2;break;default:u=l*Math.SQRT2,d=f*Math.SQRT2;break}return{cx:e,cy:s,rx:u,ry:d}}class Ee{constructor(t,e=1){w(this,"ctx");w(this,"dpr");w(this,"groups",[]);w(this,"scratch");w(this,"scratchCtx");w(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=st(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}=lr(s.angle,t),h=this.ctx.createLinearGradient(r,i,o,a);for(const l of s.stops)h.addColorStop(Math.max(0,Math.min(1,l.position)),st(l.color));this.path(t,e),this.ctx.fillStyle=h,this.ctx.fill()}fillRadial(t,e,s){const{cx:r,cy:i,rx:o,ry:a}=hr(s,t),h=this.ctx,l=o||1e-6,c=a||1e-6;h.save(),this.path(t,e),h.clip(),h.translate(r,i),h.scale(l,c);const f=h.createRadialGradient(0,0,0,0,0,1);for(const g of s.stops)f.addColorStop(Math.max(0,Math.min(1,g.position)),st(g.color));h.fillStyle=f;const u=(t.x-r)/l,d=(t.x+t.width-r)/l,p=(t.y-i)/c,b=(t.y+t.height-i)/c;h.fillRect(u,p,d-u,b-p),h.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,h=Zt(e,t);r.beginPath(),this.addRectPath(t,h);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 c=h&&Zt({tl:Math.max(0,h.tl-a),tr:Math.max(0,h.tr-a),br:Math.max(0,h.br-a),bl:Math.max(0,h.bl-a)},l);this.addRectPath(l,c||void 0)}r.fillStyle=st(s.top.color),r.fill("evenodd");return}for(const a of i){const{width:h,color:l}=s[a];r.fillStyle=st(l),a==="top"?r.fillRect(t.x,t.y,t.width,h):a==="bottom"?r.fillRect(t.x,t.y+t.height-h,t.width,h):a==="left"?r.fillRect(t.x,t.y,h,t.height):r.fillRect(t.x+t.width-h,t.y,h,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 d=t.naturalWidth,p=t.naturalHeight;if(d<=0||p<=0)return;const b=Math.max(1,Math.ceil(d*this.dpr)),g=Math.max(1,Math.ceil(p*this.dpr)),x=t.rasterize!==void 0||It(t.src),m=x?this.tileCell(t,b,g):t.handle,v=x?d/b:1,_=x?p/g:1,M=this.ctx.createPattern(m,"repeat");if(!M)return;this.ctx.save(),this.ctx.translate(s.x,s.y),this.ctx.scale(v,_),this.ctx.fillStyle=M,this.ctx.fillRect(0,0,s.width/v,s.height/_),this.ctx.restore();return}const i=e?{src:e,dst:s}:cr(t.naturalWidth,t.naturalHeight,s,r.fit),o=i.dst;let a=i.src;const h=Math.max(1,Math.ceil(o.width*this.dpr)),l=Math.max(1,Math.ceil(o.height*this.dpr)),c=!e&&r.fit!=="cover";let f=t.handle;if(t.rasterize)if(c)f=t.rasterize(h,l);else{const d=Math.max(h/a.width,l/a.height),p=Math.max(1,Math.ceil(t.naturalWidth*d)),b=Math.max(1,Math.ceil(t.naturalHeight*d));f=t.rasterize(p,b);const g=p/t.naturalWidth,x=b/t.naturalHeight;a={x:a.x*g,y:a.y*x,width:a.width*g,height:a.height*x}}if(r.tint===void 0){c?this.ctx.drawImage(f,o.x,o.y,o.width,o.height):this.ctx.drawImage(f,a.x,a.y,a.width,a.height,o.x,o.y,o.width,o.height);return}const u=this.getScratch(h,l);u.clearRect(0,0,h,l),u.globalCompositeOperation="source-over",c?u.drawImage(f,0,0,h,l):u.drawImage(f,a.x,a.y,a.width,a.height,0,0,h,l),u.globalCompositeOperation="source-in",u.fillStyle=st(r.tint),u.fillRect(0,0,h,l),u.globalCompositeOperation="source-over",this.ctx.drawImage(u.canvas,0,0,h,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=st(i),o.fillText(t,e,s)}}const $=[null],yt=[!1],sn=(n,t,e)=>{n.addEventListener("ended",()=>{e(),yt[t]&&(n.currentTime=0,n.play())})},ur=(n,t)=>{const e=document.createElement("video");document.body.appendChild(e),e.crossOrigin="anonymous",e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n,e.playsInline=!0,e.controls=!1;const s=$.length;return $.push(e),yt.push(!1),sn(e,s,t),s},dr=(n,t)=>{const e=document.createElement("audio");document.body.appendChild(e),e.style="opacity: 0; position: absolute; top: 0; left: 0; width: 1px; height: 1px",e.src=n;const s=$.length;return $.push(e),yt.push(!1),sn(e,s,t),s},fr=(n,t)=>{const e=$[n];e&&(t===0?e.muted=!0:(e.muted&&(e.muted=!1),e.volume=t))},pr=(n,t)=>{const e=$[n];e&&(t?e.play():e.pause())},gr=(n,t)=>{yt[n]=t},mr=n=>{var t;return((t=$[n])==null?void 0:t.currentTime)??0},yr=(n,t)=>{const e=$[n];e&&(e.currentTime=t)},wr=n=>{var e;const t=((e=$[n])==null?void 0:e.duration)??0;return isNaN(t)?0:t},ce=n=>$[n],on=n=>{n.pause(),n.removeAttribute("src"),n.load(),n.remove()},br=n=>{const t=$[n];t&&(on(t),$[n]=null,yt[n]=!1)},an=()=>{for(let n of $)n&&on(n);$.length=1,yt.length=1},vr=9,xr=10,Sr=12,Er=13,_r=14,Tr=15,kr=16,Rr=1,Ar=2,Mr=4,_e=8,Lr=16,Pr=32,Cr=64,Or=256,Ir=512,Fr=1024,Nr=2048,Ur=4096,Te=0,Ut=1,ke=2,Wt=3;function Wr(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 ft(n,t,e,s){let r=null;const i=o=>{const a=Wr(o,t,e);if(a&&s(o)&&(r=o),!(o.clip&&!a))for(const h of o.children)i(h)};return i(n),r}const Dr=78,Hr={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:46},fontSize:{word:51},fontWeight:{word:52},fontStyle:{word:53},fontFamily:{bit:39,word:54},lineHeight:{word:55},letterSpacing:{word:56},textAlign:{word:57},textDecoration:{word:58},lineClamp:{word:59},textOverflow:{word:60},objectFit:{word:61},placeholder:{word:62},type:{word:63},dim:{word:77}},Br={hidden:1},$r={horizontal:1},Gr={italic:1},ht={display:["flex","none"],backgroundSize:["cover","contain","fill","tile"],textDecoration:["underline","line-through","none"],textOverflow:["ellipsis","clip"],objectFit:["cover","contain","fill"],type:["text","password","tel","email","number","decimal","url","search","date","time"]},jr=(n,t,e)=>e<32?(n>>>e&1)===1:(t>>>e-32&1)===1,Vr=["farthest-corner","closest-side","closest-corner","farthest-side"],zr=52;function Xr(n,t,e,s){const r=[];for(let i=0;i<s;i++)r.push(Yr(n,t,e+i*zr));return r}function Yr(n,t,e){const s=e>>2,r=n[s],i=t[s+1],o=t[s+2],a=t[s+4],h=[];for(let l=0;l<o;l++){const c=a+l*8>>2;h.push({color:t[c]>>>0,position:n[c+1]})}if(i===1){const l=t[s+6],c={type:"radial",shape:t[s+5]===1?"circle":"ellipse",cx:n[s+7],cy:n[s+8],stops:h};return l===4?{...c,extent:"explicit",rx:n[s+9],ry:n[s+10],rxUnit:t[s+11]===1?"fraction":"px",ryUnit:t[s+12]===1?"fraction":"px"}:{...c,extent:Vr[l]??"farthest-corner"}}return{type:"linear",angle:r,stops:h}}const T=Hr,Kr=["start","center","end","start","end"];let _t=0;function cn(n,t,e){const s=n.HEAPU32,r=n.HEAPF32,i=t>>>2,o=s[i],a=s[i+1],h=v=>jr(o,a,v),l=v=>{const _=s[i+v];return _===0?void 0:n.UTF8ToString(n._cuiStringOf(_))};e.backgroundColor=s[i+T.backgroundColor.word]>>>0,e.opacity=r[i+T.opacity.word],e.dim=r[i+T.dim.word],e.display=ht.display[s[i+T.display.word]],e.overflow=s[i+T.overflow.word]===Br.hidden?"hidden":"visible",e.scrollAxis=s[i+T.scrollDirection.word]===$r.horizontal?"x":"y",e.border={top:{width:r[i+T.borderTopWidth.word],color:s[i+T.borderTopColor.word]>>>0},right:{width:r[i+T.borderRightWidth.word],color:s[i+T.borderRightColor.word]>>>0},bottom:{width:r[i+T.borderBottomWidth.word],color:s[i+T.borderBottomColor.word]>>>0},left:{width:r[i+T.borderLeftWidth.word],color:s[i+T.borderLeftColor.word]>>>0}},e.borderRadius={tl:r[i+T.borderTopLeftRadius.word],tr:r[i+T.borderTopRightRadius.word],br:r[i+T.borderBottomRightRadius.word],bl:r[i+T.borderBottomLeftRadius.word]},e.backgroundImage=l(T.backgroundImage.word),e.backgroundSize=ht.backgroundSize[s[i+T.backgroundSize.word]];const c=s[i+T.backgroundGradient.word];if(c===0)e.backgroundGradients=void 0;else{_t===0&&(_t=n._malloc(4));const v=n._cuiGradientOf(c,_t),_=n.HEAPU32[_t>>>2];e.backgroundGradients=v!==0&&_>0?Xr(n.HEAPF32,n.HEAPU32,v,_):void 0}const f=i+T.transform.word,u=r[f],d=r[f+1],p=r[f+3],b=r[f+4],g=r[f+6],x=r[f+7];e.transform=u===1&&d===0&&p===0&&b===1&&g===0&&x===0?void 0:[u,d,p,b,g,x];const m=i+T.transformOrigin.word;e.transformOrigin={x:r[m],y:r[m+1],xPercent:s[m+2]!==0,yPercent:s[m+3]!==0},e.color=h(T.color.bit)?s[i+T.color.word]>>>0:void 0,e.fontFamily=h(T.fontFamily.bit)?l(T.fontFamily.word):void 0,e.fontSize=r[i+T.fontSize.word],e.fontWeight=r[i+T.fontWeight.word],e.fontStyle=s[i+T.fontStyle.word]===Gr.italic?"italic":"normal",e.lineHeight=r[i+T.lineHeight.word],e.letterSpacing=r[i+T.letterSpacing.word],e.textAlign=Kr[s[i+T.textAlign.word]]??"start",e.textDecoration=ht.textDecoration[s[i+T.textDecoration.word]],e.lineClamp=r[i+T.lineClamp.word],e.textOverflow=ht.textOverflow[s[i+T.textOverflow.word]],e.objectFit=ht.objectFit[s[i+T.objectFit.word]],e.tintColor=h(T.tintColor.bit)?s[i+T.tintColor.word]>>>0:void 0,e.placeholder=l(T.placeholder.word),e.placeholderColor=h(T.placeholderColor.bit)?s[i+T.placeholderColor.word]>>>0:void 0,e.inputType=ht.type[s[i+T.type.word]],e.overlayColor=h(T.overlayColor.bit)?s[i+T.overlayColor.word]>>>0:void 0}function qr(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 Jr(n,t,e){const s=n._cuiPaintOf(t);return s===0?!1:(cn(n,s,e),!0)}function Qr(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*Dr*4;t(o,h=>cn(n,a,h))}return e}const Zr=255,Z={color:4294967295,fontSize:14,fontFamily:"Roboto",fontWeight:400,fontStyle:"normal",letterSpacing:0,textAlign:"start",textDecoration:"none"};function te(n){const t=n.style,{color:e,fontSize:s,fontFamily:r,fontWeight:i,fontStyle:o,lineHeight:a,letterSpacing:h,textAlign:l,textDecoration:c}=t,f=s??Z.fontSize;return{color:e??(n.type==="input"||n.type==="textarea"?Zr:Z.color),fontSize:f,fontFamily:r??Z.fontFamily,fontWeight:i??Z.fontWeight,fontStyle:o??Z.fontStyle,lineHeight:a,letterSpacing:h??Z.letterSpacing,textAlign:l??Z.textAlign,textDecoration:c??Z.textDecoration}}function ln(n){return{family:n.fontFamily,size:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic",letterSpacing:n.letterSpacing}}function vt(n,t,e){const s=[];let r=0;for(const i of n.split(`
10
+ `)){if(i.length===0){s.push("");continue}let o=i;for(;o;){if(e(o)<=t){s.push(o),r=Math.max(r,e(o));break}let a=0,h=-1,l=0;for(;(l=o.indexOf(" ",l+1))!==-1&&!(e(o.substring(0,l))>t);)h=l;if(h>0)a=h;else{let f=o.indexOf(" ");f===-1&&(f=o.length);const u=o.substring(0,f);if(e(u)>t){for(let d=1;d<=u.length;d++)if(e(u.substring(0,d))>t){a=d-1;break}}else for(let d=f+1;d<=o.length;d++)if(e(o.substring(0,d))>t){a=d-1;break}}a<=0&&(a=1);const c=o.substring(0,a);s.push(c),r=Math.max(r,e(c)),o=o.substring(a+(h>0?1:0))}}return{lines:s,maxWidth:r}}const Dt="…";function hn(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]=ts(i[r-1],e,s)),i}function ts(n,t,e){if(!isFinite(t))return n+Dt;const s=[...n];let r=s.length;for(;r>0&&e(s.slice(0,r).join("")+Dt)>t;)r--;return s.slice(0,r).join("").trimEnd()+Dt}function es(n,t,e){const s=te(n),r=ln(s),i=isNaN(e)?1/0:e,o=c=>t.measureText(c,r),a=vt(n.text??"",i,o),h=hn(a.lines,n.style,i,o);let l=a.maxWidth;if(h!==a.lines){l=0;for(const c of h)l=Math.max(l,o(c))}return{width:Math.ceil(l),height:Math.ceil(h.length*s.lineHeight)}}function ns(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,h=vt(o,a,l=>t.measureText(l,r));return{width:Math.ceil(h.maxWidth),height:Math.ceil(Math.max(1,h.lines.length)*i)}}function rs(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(tn(r)){const l=Qt(r.svg);if(l)i=l.width,o=l.height;else{const c=t.getImage(t.resolveSrc(r)??"");i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}}else{const l=t.resolveSrc(r),c=l?t.getImage(l):void 0;i=(c==null?void 0:c.naturalWidth)??0,o=(c==null?void 0:c.naturalHeight)??0}if(i===0||o===0)return{width:0,height:0};const a=Math.min(e/i,s/o),h=isNaN(e)&&isNaN(s)?1:isNaN(e)?s/o:isNaN(s)?e/i:Math.min(a,1);return{width:i*h,height:o*h}}function ss(n,t,e,s,r,i,o={}){t.beginFrame(s,r);const a=n.filter(h=>h.widget);for(const h of n)h.widget||ee(h.tree,t,e,o);for(const h of a)h.backdrop&&t.fillRoundRect({x:0,y:0,width:s,height:r},void 0,h.backdrop.color);for(const h of a)ee(h.tree,t,e,o);t.endFrame()}function ee(n,t,e,s){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[c,f,u,d,p,b]=r.transform,g=r.transformOrigin,x=i.x+(g?g.xPercent?i.width*g.x/100:g.x:i.width/2),m=i.y+(g?g.yPercent?i.height*g.y/100:g.y:i.height/2);t.translate(x,m),t.transform(c,f,u,d,p,b),t.translate(-x,-m)}const h=Zt(r.borderRadius,i);if(rn(r.backgroundColor)||t.fillRoundRect(i,h,r.backgroundColor),r.backgroundImage){const c=e.getImage(r.backgroundImage);c&&c.naturalWidth>0&&c.naturalHeight>0&&(t.save(),Se(h)&&t.clipRoundRect(i,h),t.drawImage(c,null,i,{fit:is(r.backgroundSize),tile:r.backgroundSize==="tile"}),t.restore())}if(r.backgroundGradients)for(let c=r.backgroundGradients.length-1;c>=0;c--){const f=r.backgroundGradients[c];f.stops.length>0&&t.fillGradient(i,h,f)}if(n.image&&n.image.naturalWidth>0&&n.image.naturalHeight>0){const c=n.sourceRect;t.save(),Se(h)&&t.clipRoundRect(i,h),t.drawImage(n.image,c?{x:c[0],y:c[1],width:c[2],height:c[3]}:null,i,{fit:c?"fill":r.objectFit??"contain",tint:It(n.image.src)?r.tintColor:void 0,radius:h}),t.restore()}n.type==="text"&&n.lines&&n.lines.length>0&&as(n,t,e),(n.type==="input"||n.type==="textarea")&&n.id!==s.editing&&ls(n,t,e,h),(n.type==="video"||n.type==="native")&&(s.surfaces?t.clearRoundRect(i,h):n.type==="video"&&cs(n,t,e,h)),n.clip&&t.clipRoundRect(i,h);for(const c of n.children)ee(c,t,e,s);r.dim!==void 0&&r.dim>0&&t.fillRoundRect(i,h,Math.round(Math.min(1,r.dim)*255)>>>0);const l=os(r.border);l&&t.strokeBorder(i,h,l),a&&t.endGroup(),t.restore()}function is(n){return n==="contain"||n==="fill"?n:"cover"}function os(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 un=(n,t)=>{var s;const e=t??"Roboto";return((s=n.resolveFontFamily)==null?void 0:s.call(n,e))??e};function as(n,t,e){var g,x,m;const s=n.style,r={family:un(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",h=e.fontMetrics(r),{rect:l,lines:c}=n,f=((g=n.padding)==null?void 0:g[0])??0,u=((x=n.padding)==null?void 0:x[1])??0,d=((m=n.padding)==null?void 0:m[2])??0,p=l.x+f,b=l.width-f-d;for(let v=0;v<c.length;v++){const _=c[v],P=l.y+u+v*o+(o-(h.ascent+h.descent))/2+h.ascent,I=e.measureText(_,r),F=a==="center"?p+(b-I)/2:a==="end"?p+b-I:p;if(t.fillText(_,F,P,r,i),s.textDecoration==="underline"||s.textDecoration==="line-through"){const D=Math.max(1,r.size/14),R=s.textDecoration==="underline"?P+D:P-r.size*.3;t.fillRoundRect({x:F,y:R,width:I,height:D},void 0,i)}}}function cs(n,t,e,s){const{rect:r}=n;rn(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),h=e.measureText("▶",o),l=r.x+(r.width-h)/2,c=r.y+(r.height-(a.ascent+a.descent))/2+a.ascent;t.fillText("▶",l,c,o,4294967244)}}function ls(n,t,e,s){var z,G,j,y,L;const r=n.style,i={family:un(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,h=r.inputType==="password"&&!a,l=a?r.placeholder??"":h?"•".repeat(o.length):o,c=a?r.placeholderColor??2576980479:r.color??255,{rect:f}=n,u=((z=n.padding)==null?void 0:z[0])??0,d=((G=n.padding)==null?void 0:G[1])??0,p=((j=n.padding)==null?void 0:j[2])??0,b=((y=n.padding)==null?void 0:y[3])??0,g=f.x+u,x=f.width-u-p,m=f.y+d,v=f.height-d-b,_=e.fontMetrics(i),M=r.lineHeight,P=r.textAlign??"start",I=n.type==="textarea",F=I?vt(l,x,A=>e.measureText(A,i)).lines:[l],D=A=>P==="center"?g+(x-A)/2:P==="end"?g+x-A:g,R=A=>I?m+A*M+(M-(_.ascent+_.descent))/2+_.ascent:m+(v-(_.ascent+_.descent))/2+_.ascent;t.save(),t.clipRoundRect(f,s);for(let A=0;A<F.length;A++){const H=F[A];H.length>0&&t.fillText(H,D(e.measureText(H,i)),R(A),i,c)}if((L=n.state)!=null&&L.focused){const A=a?[""]:I?vt(h?"•".repeat(o.length):o,x,N=>e.measureText(N,i)).lines:[l],H=A.length-1,Y=e.measureText(A[H],i),J=a?D(0):D(Y)+Y,S=R(H),k=Math.max(1,i.size/14);t.fillRoundRect({x:J,y:S-_.ascent,width:k,height:_.ascent+_.descent},void 0,r.color??255)}t.restore()}function dn(n,t=[],e={}){const s=e.precision??2,r=e.includeIds??!1,i=n?ne(n,s,r):null;if(t.length===0)return i;const o=t.map(a=>ne(a,s,r));return i?(i.overlays=o,i):{type:"frame",overlays:o}}function hs(n,t=[],e){return JSON.stringify(dn(n,t,e),null,2)}function ut(n,t){const e=10**t;return Math.round(n*e)/e}function ne(n,t,e){var o,a;const s=n.rect,r={type:n.type};n.name&&(r.name=n.name),r.rect=[ut(s.x,t),ut(s.y,t),ut(s.width,t),ut(s.height,t)],e&&(r.id=n.id);const i=ds(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:ut(n.scroll.offset,t),content:ut(n.scroll.content,t)}),n.children.length>0&&(r.children=n.children.map(h=>ne(h,t,e))),r}function us(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 ds(n){const t={};if(n.backgroundColor!==void 0&&(t.backgroundColor=lt(n.backgroundColor)),n.opacity!==void 0&&(t.opacity=n.opacity),n.color!==void 0&&(t.color=lt(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.objectFit!==void 0&&(t.objectFit=n.objectFit),n.tintColor!==void 0&&(t.tintColor=lt(n.tintColor)),n.overlayColor!==void 0&&(t.overlayColor=lt(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:lt(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=us(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:lt(r.color)})}Object.keys(e).length>0&&(t.border=e)}return Object.keys(t).length>0?t:void 0}const fs=.32,ps=4,Re=new Map;function re(n){if(!n)return n;if(n.startsWith("canvas:"))return`lecodes-canvas://${n.slice(7)}`;if(n.startsWith("svg:")){let t=Re.get(n);return t===void 0&&(t=en(n.slice(4)),Re.set(n,t)),t}return n}class gs{constructor(t,e){w(this,"parent",null);w(this,"children",[]);w(this,"style",{lineHeight:14*1.2});w(this,"name");w(this,"text","");w(this,"src");w(this,"value","");w(this,"sourceRect");w(this,"viewName");w(this,"viewParams");w(this,"playerId",0);w(this,"viewId",0);w(this,"flags",0);w(this,"layoutRect",null);w(this,"scrollOffset",0);w(this,"wrapCache");w(this,"jsNode");w(this,"bgRaw");w(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&Rr)!==0}get imageSrcRaw(){return this.type==="image"?re(this.src):void 0}has(t){return(this.flags&t)!==0}}class ms{constructor(t,e,s={}){w(this,"nodes",new Map);w(this,"root",null);w(this,"leaving",null);w(this,"leavingAbove",!1);w(this,"pagerShown",new Map);w(this,"pagerLeaving",new Map);w(this,"destKind",-1);w(this,"widgetRoots",[]);w(this,"width",0);w(this,"height",0);w(this,"focused",null);w(this,"pressed",new Set);w(this,"gestures",new Map);w(this,"vlists",new Set);w(this,"frameCache",null);w(this,"painted",null);w(this,"fontsPending",0);w(this,"lastToast",null);w(this,"dirty",!0);w(this,"onDestination",null);w(this,"onDropped",null);w(this,"layoutPtr",0);w(this,"padPtr",0);w(this,"lastCreated",0);w(this,"hoverX",0);w(this,"hoverY",0);w(this,"hoverInside",!1);w(this,"hoverMoved",!1);this.M=t,this.host=e,this.options=s}install(){const t=new DataView(new ArrayBuffer(8)),e=(s,r,i,o,a,h)=>{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;qr(i,t)&&(Jr(i,t,r.style),this.resolveBackground(r));const o=r;return r.type==="text"?es(o,this.host,e):r.type==="image"?rs(o,this.host,e,s):r.editable?ns(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((h,l)=>h|a[l],0)),this.M._setSafePaddings(s,r,i,o,0),this.dirty=!0}layoutFrame(){const t=this.M;Qr(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(_e)&&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 h=i[s+a],l=this.nodes.get(h);if(!l)continue;const c=o[r+a*4],f=o[r+a*4+1],u=o[r+a*4+2],d=o[r+a*4+3],p={x:c,y:f,width:u-c,height:d-f},b=l.layoutRect,g=!b||b.x!==p.x||b.y!==p.y||b.width!==p.width||b.height!==p.height;l.layoutRect=p,g&&(this.dirty=!0),g&&l.has(_e)&&e._creatorWebNodeLayout(h,c,f,p.width,p.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.leaving?this.build(this.leaving,e):null;if(s&&!this.leavingAbove&&t.push({tree:s,leaving:!0}),this.root){const r=this.build(this.root,e);r&&t.push({tree:r})}s&&this.leavingAbove&&t.push({tree:s,leaving:!0});for(const r of this.widgetRoots){const i=r.layoutRect??{x:0,y:0,width:this.width,height:this.height},o=this.build(r,i);if(!o)continue;const a=o.style.overlayColor;t.push({tree:o,widget:!0,backdrop:a!==void 0?{color:a,jsNode:r.jsNode}:void 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 dn(this.renderTree(),this.widgetTrees())}toText(){return hs(this.renderTree(),this.widgetTrees())}paint(t,e){const s=this.frame();ss(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,h)=>{var x;if(i.style.display==="none")return null;let l,c,f,u;if(h)l=e.x,c=e.y,f=e.width,u=e.height;else{const m=i.layoutRect;if(!m)return null;l=o+m.x,c=a+m.y,f=m.width,u=m.height}const d={id:i.id,type:i.type,rect:{x:l,y:c,width:f,height:u},style:i.style,children:[]};i.name&&(d.name=i.name);const p=i;if(i.type==="text"){const m=te(p),v=ln(m);d.text=i.text;const _=this.padding(i.id);(_[0]||_[1]||_[2]||_[3])&&(d.padding=_);const M=f-_[0]-_[2],P=`${M}|${v.size}|${v.weight}|${v.italic?1:0}|${v.letterSpacing}|${v.family}|${i.style.lineClamp??0}|${i.style.textOverflow??""}|${i.text}`;if(((x=i.wrapCache)==null?void 0:x.key)===P)d.lines=i.wrapCache.lines;else{const I=D=>this.host.measureText(D,v),F=hn(vt(i.text,M,I).lines,i.style,M,I);i.wrapCache={key:P,lines:F},d.lines=F}d.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==="image"){const m=this.host.resolveSrc(i.imageSrcRaw),v=m?this.host.getImage(m):void 0;d.image=v??(m?{src:m,naturalWidth:0,naturalHeight:0}:void 0),i.sourceRect&&(d.sourceRect=i.sourceRect)}else if(i.editable){d.value=i.value;const m=this.padding(i.id);(m[0]||m[1]||m[2]||m[3])&&(d.padding=m);const v=te(p);d.style={...i.style,color:v.color,fontSize:v.fontSize,fontFamily:v.fontFamily,fontWeight:v.fontWeight,fontStyle:v.fontStyle,lineHeight:v.lineHeight,letterSpacing:v.letterSpacing,textAlign:v.textAlign,textDecoration:v.textDecoration}}i.interactive&&(d.state={pressed:this.pressed.has(i.id)}),i.editable&&this.focused===i&&(d.state={...d.state,focused:!0}),i.style.overflow==="hidden"&&(d.clip=!0);let b=l,g=c;if(i.scrollable){const m=i.scrollAxis,v=m==="x"?s._getContentWidth(i.id):s._getContentHeight(i.id);d.clip=!0,d.scroll={offset:i.scrollOffset,content:v,axis:m},m==="x"?b=l-i.scrollOffset:g=c-i.scrollOffset}if(i.type==="pager"){const m=s._creatorWebPagerSelectedIndex(i.id),v=s._creatorWebPagerStackLen(i.id,m),_=v>0?s._creatorWebPagerPageNode(i.id,m,v-1):0,M=_?this.nodes.get(_):void 0;M?this.pagerShown.set(i.id,M):this.pagerShown.delete(i.id);const P=this.pagerLeaving.get(i.id);for(const I of P&&P.page!==M?P.above?[M,P.page]:[P.page,M]:[M]){const F=I?r(I,l,c,!1):null;F&&d.children.push(F)}return d}if(i.type==="vlist"){for(const m of i.children){const v=s._getParentNode(m.id);if(!v)continue;const _=s._vlistItemOffsetOf(i.id,v);if(Number.isNaN(_))continue;const M=r(m,l,c+_-i.scrollOffset,!1);M&&d.children.push(M)}return d}for(const m of i.children){const v=r(m,b,g,!1);v&&d.children.push(v)}return d};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 gs(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.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard());const s=this.widgetRoots.indexOf(e);s>=0&&this.widgetRoots.splice(s,1),this.vlists.delete(e),this.pressed.delete(t),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 re(t.src)}resolveBackground(t){const e=t.style.backgroundImage||void 0;if(e!==t.bgRaw){t.bgRaw=e,t.bgSrc=e?this.host.resolveSrc(re(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)),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 h;this.destKind=t;const a=t===Te?this.nodes.get(e)??null:null;a!==this.root&&this.leave(!o||a===null),this.leaving===a&&(this.leaving=null),this.root=a,this.focused&&this.blurInput(),this.dirty=!0,(h=this.onDestination)==null||h.call(this,t,s)}dropView(t,e,s){var r;if(t===Te){const i=this.nodes.get(e)??null;i!==null&&this.leaving===i&&(this.leaving=null),i!==null&&this.root===i&&(this.root=null)}this.dirty=!0,(r=this.onDropped)==null||r.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)}widgetOpen(t,e,s,r){const i=this.nodes.get(t);i&&!this.widgetRoots.includes(i)&&this.widgetRoots.push(i),this.dirty=!0}widgetClose(t){const e=this.nodes.get(t);for(const r of this.gestures.values())r.backdrop===e&&(r.backdrop=null);const s=e?this.widgetRoots.indexOf(e):-1;s>=0&&this.widgetRoots.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}pagerPageMounted(t,e){this.dirty=!0}refreshDone(t){}rootOf(t){let e=t;for(;e.parent;)e=e.parent;return e}emitKeyboard(){var e,s;const t=this.keyboardHeight();(s=(e=this.options).onKeyboard)==null||s.call(e,t),this.M._creatorWebKeyboardEvent(t,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(Ir)&&this.M._creatorWebNodeEvent(t,Er),this.M._creatorWebSetShrunkRoot(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(Fr)&&this.M._creatorWebNodeEvent(t.id,_r),this.M._creatorWebSetShrunkRoot(0,0),this.emitKeyboard(),this.dirty=!0)}setInputValue(t,e){const s=this.nodes.get(t);s&&(s.value=e,s.has(Or)&&this.withStr(e,r=>this.M._creatorWebNodeEventStr(t,Sr,r)),this.M._nodeHasMeasure(t)&&this.M._markNodeDirty(t),this.dirty=!0)}submitInput(){const t=this.focused;return t?(t.has(Nr)&&this.withStr(t.value,e=>this.M._creatorWebNodeEventStr(t.id,Tr,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(Pr)&&this.M._creatorWebNodeEventNum(t,vr,a),o===s.scrollOffset?!1:(s.scrollOffset=o,s.type==="vlist"&&this.M._vlistExists(t)&&this.M._vlistOnScroll(t,o),s.has(Lr)&&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=ft(s[r].tree,t,e,o=>{var a;return((a=this.nodes.get(o.id))==null?void 0:a.interactive)??!1});if(i)return this.nodes.get(i.id)??null;if(s[r].backdrop)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 h=ft(o[a].tree,e,s,l=>{var c;return((c=this.nodes.get(l.id))==null?void 0:c.editable)??!1});if(h){const l=this.nodes.get(h.id);this.focusInput(l.id),i.edit=l,i.dismiss=!1;return}if(o[a].backdrop)break}for(let a=o.length-1;a>=0;a--){const h=o[a],l=ft(h.tree,e,s,u=>{var d;return((d=this.nodes.get(u.id))==null?void 0:d.interactive)??!1}),c=ft(h.tree,e,s,u=>!!u.scroll&&u.scroll.content>(u.scroll.axis==="x"?u.rect.width:u.rect.height)+.5),f=c?this.nodes.get(c.id)??null:null;if(l){const u=this.nodes.get(l.id);i.node=u,i.scroll=f,i.dismiss=u.type!=="button",this.setPressed(u,!0),r._creatorWebNodeTouchStart(u.id,t,e,s);return}if(f){i.scroll=f;return}if(h.backdrop){const u=h.tree.rect,d=e>=u.x&&e<u.x+u.width&&s>=u.y&&s<u.y+u.height;i.backdrop=d?null:this.nodes.get(h.tree.id)??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>ps&&(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(Cr)&&i._creatorWebNodeEvent(r.scroll.id,xr),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(Ar)&&i._creatorWebNodeClick(r.node.id,t,e,s)):r.backdrop?!r.scrolling&&r.backdrop.has(Ur)&&i._creatorWebNodeEvent(r.backdrop.id,kr):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=ft(i[o].tree,t,e,h=>!!h.scroll&&h.scroll.content>(h.scroll.axis==="x"?h.rect.width:h.rect.height)+.5);if(a){const h=this.nodes.get(a.id);return h?this.scrollBy(h.id,h.scrollAxis==="x"?s:r):!1}if(i[o].backdrop)return!1}return!1}longPress(t,e,s){const r=this.gestures.get(t);r!=null&&r.node&&r.node.has(Mr)&&this.M._creatorWebNodeLongPress(r.node.id,t,e,s)}isVlist(t){return this.vlists.has(t)}}const ys=`
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
- `,Ae=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),ys=n=>n.type==="native"||n.type==="video",ws=[1,0,0,1,0,0],Ht=(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]],bs=(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 Mt extends gs{constructor(e,s,r,i,o={}){super(e,s,o);w(this,"doc");w(this,"factories",new Map);w(this,"versions",new Map);w(this,"views",new Map);w(this,"wrappers",new Map);w(this,"shown",new Map);w(this,"destination",null);w(this,"field",null);w(this,"placedFor",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=ms,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 h=o(a,{emit:(l,c)=>this.M.jsb.viewEvent(e,l,c)},this.doc);return h.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:h}),h}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(h=>{h===void 0?i():i(h)},h=>o(h instanceof Error?h.message:String(h)))}catch(h){o(h instanceof Error?h.message:String(h))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==Wt)return;this.dropDestination();const h=this.ensureView(r,i,o);if(!h)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(h.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===Wt&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==Wt&&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)}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,h)=>{let l=a;const c=o.style.transform;if(c){const u=o.style.transformOrigin,d=o.rect.x+(u?u.xPercent?o.rect.width*u.x/100:u.x:o.rect.width/2),p=o.rect.y+(u?u.yPercent?o.rect.height*u.y/100:u.y:o.rect.height/2);l=Ht(Ht(Ht(a,[1,0,0,1,d,p]),c),[1,0,0,1,-d,-p])}(ys(o)||o.id===s)&&e.push({node:o,matrix:l,clip:h});const f=o.clip?bs(h,o.rect):h;for(const u of o.children)r(u,l,f)};for(const o of this.frame())r(o.tree,ws,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=ce(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 f,u;const r=s.style,i=e.style,[o,a,h,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${h}px ${l}px ${o}px`,i.color=Ae(r.color,"#000000ff"),i.caretColor=i.color;const c=r.fontFamily??"Roboto";if(i.fontFamily=((u=(f=this.host).resolveFontFamily)==null?void 0:u.call(f,c))??c,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",Ae(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const d=r.inputType??"text";e.type!==d&&(e.type=d)}}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),Mt.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"),Mt.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=ft(o.tree,e,s,h=>{var l,c;return h.type==="native"||(((l=this.get(h.id))==null?void 0:l.interactive)??!1)||(((c=this.get(h.id))==null?void 0:c.editable)??!1)||!!h.scroll});if(a)return a.type==="native";if(o.backdrop)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 vs(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 xs=500,Me=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],Ss=(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 y=e.createElement("div");return y.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",y},o=i(),a=i();n.insertBefore(o,s),s.after(a);const h=new or({resolveAssetUrl:y=>Xn(y),canvasSurfaces:t.canvasHost}),l=new Mt(t.M,h,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onToast:(y,L)=>vs(e,n,y,L)});let c=1,f=new Ee(r,c),u=!0;const d=()=>{(u||l.needsPaint())&&(u=!1,l.paint(f,l.paintOptions())),l.place()},p=(y,L,A)=>{y<=0||L<=0||(A!==c&&(c=A,f=new Ee(r,c)),u=!0,l.resize(y,L))},b=y=>{l.setSafeArea([y.top,y.right,y.bottom,y.left],y.bars??[])},g=y=>{const L=n.getBoundingClientRect(),A=ae(n);return[(y.clientX-L.left)/A,(y.clientY-L.top)/A]},x=y=>y.target instanceof Node&&a.contains(y.target),m=y=>y.target instanceof Node&&o.contains(y.target),v=y=>{m(y)&&y.stopPropagation()},_=new Set,M=new Map,P=y=>{const L=M.get(y);L!==void 0&&(clearTimeout(L),M.delete(y))},I=y=>{if(x(y))return;const[L,A]=g(y);if(!l.surfaceAt(L,A)){v(y),_.add(y.pointerId);try{n.setPointerCapture(y.pointerId)}catch{}l.pointerDown(y.pointerId,L,A),P(y.pointerId),M.set(y.pointerId,window.setTimeout(()=>{M.delete(y.pointerId),l.longPress(y.pointerId,L,A)},xs))}},F=y=>{const[L,A]=g(y);_.has(y.pointerId)&&(v(y),l.pointerMove(y.pointerId,L,A)),y.pointerType==="mouse"&&(x(y)||!_.has(y.pointerId)&&l.surfaceAt(L,A)?l.pointerLeave():l.pointerHover(L,A))},D=y=>{y.pointerType==="mouse"&&l.pointerLeave()},R=y=>{if(!_.delete(y.pointerId))return;v(y),P(y.pointerId);const[L,A]=g(y);l.pointerUp(y.pointerId,L,A)},z=y=>{_.delete(y.pointerId)&&(P(y.pointerId),l.pointerCancel(y.pointerId))},G=y=>{if(x(y))return;const[L,A]=g(y);if(l.surfaceAt(L,A))return;v(y);const H=y.deltaMode===1?16:y.deltaMode===2?l.height:1;l.wheel(L,A,y.deltaX*H,y.deltaY*H)&&y.preventDefault()},j=y=>{var Y;if(x(y))return;const L="clientX"in y?y:(Y=y.changedTouches)==null?void 0:Y[0];if(!L)return;const[A,H]=g(L);l.surfaceAt(A,H)||(v(y),y.type==="mousedown"&&y.preventDefault())};n.addEventListener("pointerdown",I,!0),n.addEventListener("pointermove",F,!0),n.addEventListener("pointerleave",D),n.addEventListener("pointerup",R,!0),n.addEventListener("pointercancel",z,!0),n.addEventListener("wheel",G,{passive:!1,capture:!0});for(const y of Me)n.addEventListener(y,j,!0);return{ui:l,render:d,resize:p,setSafeArea:b,destroy(){for(const y of M.keys())P(y);n.removeEventListener("pointerdown",I,!0),n.removeEventListener("pointermove",F,!0),n.removeEventListener("pointerleave",D),n.removeEventListener("pointerup",R,!0),n.removeEventListener("pointercancel",z,!0),n.removeEventListener("wheel",G,!0);for(const y of Me)n.removeEventListener(y,j,!0);l.dispose(),o.remove(),a.remove()}}},Es=["miter","round","bevel"],_s=["butt","round","square"],Ts=["left","center","right","start","end"],ks=["alphabetic","top","middle","bottom","hanging","ideographic"],Le=["nonzero","evenodd"],Rs=["pad","reflect","repeat"],Bt={COLOR:0,RADIAL:2},bt={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 As{constructor(t,e){w(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===Bt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Bt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=Rs[this.i()]??"pad",h=this.i(),l=[];for(let c=0;c<h;c++)l.push({offset:this.f(),color:this.color()});return t===Bt.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=Es[this.i()]??"miter",s=_s[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let h=0;h<o;h++)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 bt.MOVE:s.push(["M",this.f(),this.f()]);break;case bt.LINE:s.push(["L",this.f(),this.f()]);break;case bt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case bt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case bt.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 Ms=(n,t)=>{const e=new As(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=Le[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Le[e.i()]??"nonzero",h=e.paint();s.push({cmd:"fillPath",rule:a,paint:h,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),h=e.paint();s.push({cmd:"strokePath",stroke:a,paint:h,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),h=e.f(),l=e.f(),c=e.f(),f=e.font(),u=Ts[e.i()]??"start",d=ks[e.i()]??"alphabetic",p=e.f();if(r===X.STROKE_TEXT){const b=e.stroke();s.push({cmd:"strokeText",text:a,x:h,y:l,maxWidth:c,font:f,align:u,baseline:d,letterSpacing:p,stroke:b,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:h,y:l,maxWidth:c,font:f,align:u,baseline:d,letterSpacing:p,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),h=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:h,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},Ls=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),fn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,pn=(n,t=n.family)=>{const e=Ls.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Tt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],Ps=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,$t=(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}},Pe=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,fn(e.color))},kt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=fn(t.color),s();return}const r=t.matrix;if(Ps(r)){let o;if(t.kind==="linear"){const[a,h]=Tt(r,0,0),[l,c]=Tt(r,1,0);o=n.createLinearGradient(a,h,l,c)}else{const a=Math.hypot(r[0],r[1]),[h,l]=Tt(r,0,0),[c,f]=Tt(r,t.fx,t.fy);o=n.createRadialGradient(c,f,t.r0*a,h,l,a)}Pe(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);Pe(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Ce=(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},Oe=(n,t,e)=>{n.font=pn(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`)},Cs=(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":$t(n,i.path),n.clip(i.rule);break;case"fillPath":$t(n,i.path),kt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":$t(n,i.path),Ce(n,i.stroke),kt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":Oe(n,i,e),kt(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":Oe(n,i,e),Ce(n,i.stroke),kt(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()}},Os=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,c,f)=>{if(!t)return null;let u=e.get(l);return u?(u.width!==c||u.height!==f)&&(u.width=c,u.height=f):(u=new OffscreenCanvas(c,f),e.set(l,u)),u},i={paint:(l,c,f,u,d,p)=>{const b=r(l,Math.max(1,c),Math.max(1,f)),g=b==null?void 0:b.getContext("2d");!b||!g||(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,b.width,b.height),Cs(g,Ms(d,p),{image:x=>e.get(x)??null,fontFamily:n}))},measureText:(l,c,f,u,d,p)=>{if(p[0]=0,p[1]=0,p[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=pn({family:c,size:f,weight:u,italic:d},c);const b=s.measureText(l);p[0]=b.width,p[1]=b.fontBoundingBoxAscent??b.actualBoundingBoxAscent,p[2]=b.fontBoundingBoxDescent??b.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,c)=>{const f=o(l);return f?(c[0]=f.width,c[1]=f.height,new Uint8Array(f.data.buffer,f.data.byteOffset,f.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const c=e.get(l),f=c==null?void 0:c.getContext("2d");return!c||!f?null:{data:f.getImageData(0,0,c.width,c.height).data,width:c.width,height:c.height}};return{table:i,readSurface:o,getSurface:l=>{const c=e.get(l);return c?{canvas:c,width:c.width,height:c.height}:null},surfaceToDataUrl:l=>{var u;const c=e.get(l);if(!c||typeof document>"u")return null;const f=document.createElement("canvas");return f.width=c.width,f.height=c.height,(u=f.getContext("2d"))==null||u.drawImage(c,0,0),f.toDataURL()}}},Is=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,Fs=(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},Ns=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))])},gn="Roboto",Us=[`400 14px ${gn}`],Ie="data-lecodes-fonts",Ws=async(n=Us,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${Ie}]`)){const s=new URL(Is,document.baseURI).href,r=e.createElement("style");r.setAttribute(Ie,""),r.textContent=`@font-face{font-family:"${gn}";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{}}},Fe="2.0.6",Gt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},Ds=(n,t)=>Gt(n)!==null&&Gt(n)===Gt(t),Hs=[171,75,84,88,32,50,48,187,13,10,26,10],Bs=n=>n.length>=12&&Hs.every((t,e)=>n[e]===t),$s=(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=[],h=()=>{const c=r.createTexture();return r.bindTexture(r.TEXTURE_2D,c),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),c},l=(c,f,u,d)=>{const p=c.GL.getNewId(c.GL.textures);return c.GL.textures[p]=f,c._importTexture(p,u,d)>>>0};return{canvas:s,context:r,options:e,table(c){return i=c,{engineCreated(){c._createSwapChainHeadless(s.width,s.height),c._creatorWebSetViewport(s.width,s.height),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(f,u,d,p){const b=et(f);if(!b){p(`createTexture: no buffer behind id ${f}`);return}const g=new Uint8Array(b);if(Bs(g)){const x=c._malloc(g.length);c.HEAPU8.set(g,x);const m=c._createTextureFromKtx2(x,g.length)>>>0;if(c._free(x),m===4294967295){p("KTX2 transcode failed");return}d(m,c._getTextureWidth(m),c._getTextureHeight(m));return}createImageBitmap(Ot(f)).then(x=>{const m=h();r.texStorage2D(r.TEXTURE_2D,1,u&1?r.RGBA8:r.SRGB8_ALPHA8,x.width,x.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,x.width,x.height,r.RGBA,r.UNSIGNED_BYTE,x),d(l(c,m,x.width,x.height),x.width,x.height)},x=>p(x instanceof Error?x.message:String(x)))},createMediaPlayerTexture(f){const u=ce(f);if(!u)return 0;const d=h();return a.push({player:u,texture:d,lastTime:0}),l(c,d,0,0)}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&i._creatorWebSetViewport(s.width,s.height)},frame(){for(const c of a)c.player.readyState<2||c.player.currentTime===c.lastTime||(c.lastTime=c.player.currentTime,r.bindTexture(r.TEXTURE_2D,c.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,c.player))},destroy(){var c;a.length=0,(c=r.getExtension("WEBGL_lose_context"))==null||c.loseContext()}}},Gs=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")},h=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:h}},show:a,hide:h,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ne=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)},Ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mn={};for(let n=0;n<Ue.length;n++)mn[Ue[n]]=n;const js=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 Vs{constructor(t){w(this,"sources");w(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 h of i.split(",")){const l=js(h);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 zs=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 Vs(JSON.parse(e))}catch{return null}};let dt=null;const Xs=()=>{if(dt!==null)return dt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return dt=e?parseInt(e[1],10)-1:2,dt}return dt=2,dt},jt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Xs(),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,h=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,h<0?0:h);if(!l)continue;const c=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:c?c[1]:null,source:l.source,line:l.line,column:l.column})}return r},Ys=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,Ks=(n,t)=>{const e=[],s=(l,c,f,u)=>{var b,g;if(f.length===0&&Ne(c)){const x=typeof c=="number"||typeof c=="bigint"?`code ${c}`:c instanceof Error?c.message||c.name:String(c),m=[u,x].filter(_=>!!_).filter((_,M,P)=>P.indexOf(_)===M).join(`
13
+ `,Ae=(n,t)=>n===void 0?t:"#"+(n>>>0).toString(16).padStart(8,"0"),ws=n=>n.type==="native"||n.type==="video",bs=[1,0,0,1,0,0],Ht=(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 Mt extends ms{constructor(e,s,r,i,o={}){super(e,s,o);w(this,"doc");w(this,"factories",new Map);w(this,"versions",new Map);w(this,"views",new Map);w(this,"wrappers",new Map);w(this,"shown",new Map);w(this,"destination",null);w(this,"field",null);w(this,"placedFor",null);this.under=r,this.over=i,this.doc=r.ownerDocument;const a=this.doc.createElement("style");a.textContent=ys,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 h=o(a,{emit:(l,c)=>this.M.jsb.viewEvent(e,l,c)},this.doc);return h.el.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;",this.views.set(e,{name:s,params:r,handle:h}),h}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(h=>{h===void 0?i():i(h)},h=>o(h instanceof Error?h.message:String(h)))}catch(h){o(h instanceof Error?h.message:String(h))}}openView(e,s,r,i,o,a){if(super.openView(e,s,r,i,o,a),e!==Wt)return;this.dropDestination();const h=this.ensureView(r,i,o);if(!h)return;const l=this.doc.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:auto;",l.appendChild(h.el),this.under.prepend(l),this.destination={viewId:r,el:l}}dropView(e,s,r){var i;super.dropView(e,s,r),e===Wt&&((i=this.destination)==null?void 0:i.viewId)===r&&this.destKind!==Wt&&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)}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,h)=>{let l=a;const c=o.style.transform;if(c){const u=o.style.transformOrigin,d=o.rect.x+(u?u.xPercent?o.rect.width*u.x/100:u.x:o.rect.width/2),p=o.rect.y+(u?u.yPercent?o.rect.height*u.y/100:u.y:o.rect.height/2);l=Ht(Ht(Ht(a,[1,0,0,1,d,p]),c),[1,0,0,1,-d,-p])}(ws(o)||o.id===s)&&e.push({node:o,matrix:l,clip:h});const f=o.clip?vs(h,o.rect):h;for(const u of o.children)r(u,l,f)};for(const o of this.frame())r(o.tree,bs,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=ce(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 f,u;const r=s.style,i=e.style,[o,a,h,l]=s.padding??[0,0,0,0];i.padding=`${a}px ${h}px ${l}px ${o}px`,i.color=Ae(r.color,"#000000ff"),i.caretColor=i.color;const c=r.fontFamily??"Roboto";if(i.fontFamily=((u=(f=this.host).resolveFontFamily)==null?void 0:u.call(f,c))??c,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",Ae(r.placeholderColor,"#999999ff")),e instanceof HTMLInputElement){const d=r.inputType??"text";e.type!==d&&(e.type=d)}}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),Mt.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"),Mt.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=ft(o.tree,e,s,h=>{var l,c;return h.type==="native"||(((l=this.get(h.id))==null?void 0:l.interactive)??!1)||(((c=this.get(h.id))==null?void 0:c.editable)??!1)||!!h.scroll});if(a)return a.type==="native";if(o.backdrop)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 xs(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 Ss=500,Me=["mousedown","mouseup","click","dblclick","contextmenu","touchstart","touchmove","touchend"],Es=(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 y=e.createElement("div");return y.style.cssText="position:absolute;inset:0;overflow:hidden;pointer-events:none;",y},o=i(),a=i();n.insertBefore(o,s),s.after(a);const h=new or({resolveAssetUrl:y=>Xn(y),canvasSurfaces:t.canvasHost}),l=new Mt(t.M,h,o,a,{keyboardHeight:t.keyboardHeight??(()=>0),onToast:(y,L)=>xs(e,n,y,L)});let c=1,f=new Ee(r,c),u=!0;const d=()=>{(u||l.needsPaint())&&(u=!1,l.paint(f,l.paintOptions())),l.place()},p=(y,L,A)=>{y<=0||L<=0||(A!==c&&(c=A,f=new Ee(r,c)),u=!0,l.resize(y,L))},b=y=>{l.setSafeArea([y.top,y.right,y.bottom,y.left],y.bars??[])},g=y=>{const L=n.getBoundingClientRect(),A=ae(n);return[(y.clientX-L.left)/A,(y.clientY-L.top)/A]},x=y=>y.target instanceof Node&&a.contains(y.target),m=y=>y.target instanceof Node&&o.contains(y.target),v=y=>{m(y)&&y.stopPropagation()},_=new Set,M=new Map,P=y=>{const L=M.get(y);L!==void 0&&(clearTimeout(L),M.delete(y))},I=y=>{if(x(y))return;const[L,A]=g(y);if(!l.surfaceAt(L,A)){v(y),_.add(y.pointerId);try{n.setPointerCapture(y.pointerId)}catch{}l.pointerDown(y.pointerId,L,A),P(y.pointerId),M.set(y.pointerId,window.setTimeout(()=>{M.delete(y.pointerId),l.longPress(y.pointerId,L,A)},Ss))}},F=y=>{const[L,A]=g(y);_.has(y.pointerId)&&(v(y),l.pointerMove(y.pointerId,L,A)),y.pointerType==="mouse"&&(x(y)||!_.has(y.pointerId)&&l.surfaceAt(L,A)?l.pointerLeave():l.pointerHover(L,A))},D=y=>{y.pointerType==="mouse"&&l.pointerLeave()},R=y=>{if(!_.delete(y.pointerId))return;v(y),P(y.pointerId);const[L,A]=g(y);l.pointerUp(y.pointerId,L,A)},z=y=>{_.delete(y.pointerId)&&(P(y.pointerId),l.pointerCancel(y.pointerId))},G=y=>{if(x(y))return;const[L,A]=g(y);if(l.surfaceAt(L,A))return;v(y);const H=y.deltaMode===1?16:y.deltaMode===2?l.height:1;l.wheel(L,A,y.deltaX*H,y.deltaY*H)&&y.preventDefault()},j=y=>{var Y;if(x(y))return;const L="clientX"in y?y:(Y=y.changedTouches)==null?void 0:Y[0];if(!L)return;const[A,H]=g(L);l.surfaceAt(A,H)||(v(y),y.type==="mousedown"&&y.preventDefault())};n.addEventListener("pointerdown",I,!0),n.addEventListener("pointermove",F,!0),n.addEventListener("pointerleave",D),n.addEventListener("pointerup",R,!0),n.addEventListener("pointercancel",z,!0),n.addEventListener("wheel",G,{passive:!1,capture:!0});for(const y of Me)n.addEventListener(y,j,!0);return{ui:l,render:d,resize:p,setSafeArea:b,destroy(){for(const y of M.keys())P(y);n.removeEventListener("pointerdown",I,!0),n.removeEventListener("pointermove",F,!0),n.removeEventListener("pointerleave",D),n.removeEventListener("pointerup",R,!0),n.removeEventListener("pointercancel",z,!0),n.removeEventListener("wheel",G,!0);for(const y of Me)n.removeEventListener(y,j,!0);l.dispose(),o.remove(),a.remove()}}},_s=["miter","round","bevel"],Ts=["butt","round","square"],ks=["left","center","right","start","end"],Rs=["alphabetic","top","middle","bottom","hanging","ideographic"],Le=["nonzero","evenodd"],As=["pad","reflect","repeat"],Bt={COLOR:0,RADIAL:2},bt={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 Ms{constructor(t,e){w(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===Bt.COLOR)return{kind:"color",alpha:e,color:this.color()};const s=this.matrix();let r=0,i=0,o=0;t===Bt.RADIAL&&(r=this.f(),i=this.f(),o=this.f());const a=As[this.i()]??"pad",h=this.i(),l=[];for(let c=0;c<h;c++)l.push({offset:this.f(),color:this.color()});return t===Bt.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=_s[this.i()]??"miter",s=Ts[this.i()]??"butt",r=this.f(),i=this.f(),o=this.i(),a=[];for(let h=0;h<o;h++)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 bt.MOVE:s.push(["M",this.f(),this.f()]);break;case bt.LINE:s.push(["L",this.f(),this.f()]);break;case bt.QUAD:s.push(["Q",this.f(),this.f(),this.f(),this.f()]);break;case bt.CUBIC:s.push(["C",this.f(),this.f(),this.f(),this.f(),this.f(),this.f()]);break;case bt.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 Ls=(n,t)=>{const e=new Ms(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=Le[e.i()]??"nonzero";s.push({cmd:"clip",rule:a,path:e.path()});break}case X.FILL_PATH:{const a=Le[e.i()]??"nonzero",h=e.paint();s.push({cmd:"fillPath",rule:a,paint:h,path:e.path()});break}case X.STROKE_PATH:{const a=e.stroke(),h=e.paint();s.push({cmd:"strokePath",stroke:a,paint:h,path:e.path()});break}case X.FILL_TEXT:case X.STROKE_TEXT:{const a=e.str(),h=e.f(),l=e.f(),c=e.f(),f=e.font(),u=ks[e.i()]??"start",d=Rs[e.i()]??"alphabetic",p=e.f();if(r===X.STROKE_TEXT){const b=e.stroke();s.push({cmd:"strokeText",text:a,x:h,y:l,maxWidth:c,font:f,align:u,baseline:d,letterSpacing:p,stroke:b,paint:e.paint()})}else s.push({cmd:"fillText",text:a,x:h,y:l,maxWidth:c,font:f,align:u,baseline:d,letterSpacing:p,paint:e.paint()});break}case X.DRAW_IMAGE:{const a=e.i(),h=e.rect4(),l=e.rect4();s.push({cmd:"drawImage",surface:a,src:h,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},Ps=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]),fn=n=>`rgba(${Math.round(n[0]*255)}, ${Math.round(n[1]*255)}, ${Math.round(n[2]*255)}, ${n[3]})`,pn=(n,t=n.family)=>{const e=Ps.has(t)?t:`"${t.replace(/"/g,"'")}"`;return`${n.italic?"italic ":""}${n.weight} ${n.size}px ${e}`},Tt=(n,t,e)=>[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]],Cs=n=>Math.abs(n[0]-n[3])<1e-6&&Math.abs(n[1]+n[2])<1e-6,$t=(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}},Pe=(n,t)=>{for(const e of t.stops)n.addColorStop(e.offset,fn(e.color))},kt=(n,t,e,s)=>{if(n.globalAlpha=t.alpha,t.kind==="color"){n[e==="fill"?"fillStyle":"strokeStyle"]=fn(t.color),s();return}const r=t.matrix;if(Cs(r)){let o;if(t.kind==="linear"){const[a,h]=Tt(r,0,0),[l,c]=Tt(r,1,0);o=n.createLinearGradient(a,h,l,c)}else{const a=Math.hypot(r[0],r[1]),[h,l]=Tt(r,0,0),[c,f]=Tt(r,t.fx,t.fy);o=n.createRadialGradient(c,f,t.r0*a,h,l,a)}Pe(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);Pe(i,t),n[e==="fill"?"fillStyle":"strokeStyle"]=i,s(),n.restore()},Ce=(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},Oe=(n,t,e)=>{n.font=pn(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`)},Os=(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":$t(n,i.path),n.clip(i.rule);break;case"fillPath":$t(n,i.path),kt(n,i.paint,"fill",()=>n.fill(i.rule));break;case"strokePath":$t(n,i.path),Ce(n,i.stroke),kt(n,i.paint,"stroke",()=>n.stroke());break;case"fillText":Oe(n,i,e),kt(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":Oe(n,i,e),Ce(n,i.stroke),kt(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()}},Is=n=>{const t=typeof OffscreenCanvas<"u",e=new Map;let s=null;const r=(l,c,f)=>{if(!t)return null;let u=e.get(l);return u?(u.width!==c||u.height!==f)&&(u.width=c,u.height=f):(u=new OffscreenCanvas(c,f),e.set(l,u)),u},i={paint:(l,c,f,u,d,p)=>{const b=r(l,Math.max(1,c),Math.max(1,f)),g=b==null?void 0:b.getContext("2d");!b||!g||(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,b.width,b.height),Os(g,Ls(d,p),{image:x=>e.get(x)??null,fontFamily:n}))},measureText:(l,c,f,u,d,p)=>{if(p[0]=0,p[1]=0,p[2]=0,!t||(s||(s=new OffscreenCanvas(1,1).getContext("2d")),!s))return;s.font=pn({family:c,size:f,weight:u,italic:d},c);const b=s.measureText(l);p[0]=b.width,p[1]=b.fontBoundingBoxAscent??b.actualBoundingBoxAscent,p[2]=b.fontBoundingBoxDescent??b.actualBoundingBoxDescent},decodeImage:()=>!1,readPixels:(l,c)=>{const f=o(l);return f?(c[0]=f.width,c[1]=f.height,new Uint8Array(f.data.buffer,f.data.byteOffset,f.data.byteLength)):null},releaseSurface:l=>{e.delete(l)}},o=l=>{const c=e.get(l),f=c==null?void 0:c.getContext("2d");return!c||!f?null:{data:f.getImageData(0,0,c.width,c.height).data,width:c.width,height:c.height}};return{table:i,readSurface:o,getSurface:l=>{const c=e.get(l);return c?{canvas:c,width:c.width,height:c.height}:null},surfaceToDataUrl:l=>{var u;const c=e.get(l);if(!c||typeof document>"u")return null;const f=document.createElement("canvas");return f.width=c.width,f.height=c.height,(u=f.getContext("2d"))==null||u.drawImage(c,0,0),f.toDataURL()}}},Fs=""+new URL("assets/Roboto-Variable-DHm9jpd-.woff2",import.meta.url).href,Ns=(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},Us=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))])},gn="Roboto",Ws=[`400 14px ${gn}`],Ie="data-lecodes-fonts",Ds=async(n=Ws,t)=>{const e=t??(typeof document>"u"?void 0:document);if(!(!e||!e.fonts)){if(!e.head.querySelector(`style[${Ie}]`)){const s=new URL(Fs,document.baseURI).href,r=e.createElement("style");r.setAttribute(Ie,""),r.textContent=`@font-face{font-family:"${gn}";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{}}},Fe="2.0.8",Gt=n=>{const t=n==null?void 0:n.match(/^(\d+)\.\d+\.\d+/);return t?Number(t[1]):null},Hs=(n,t)=>Gt(n)!==null&&Gt(n)===Gt(t),Bs=[171,75,84,88,32,50,48,187,13,10,26,10],$s=n=>n.length>=12&&Bs.every((t,e)=>n[e]===t),Gs=(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=[],h=()=>{const c=r.createTexture();return r.bindTexture(r.TEXTURE_2D,c),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),c},l=(c,f,u,d)=>{const p=c.GL.getNewId(c.GL.textures);return c.GL.textures[p]=f,c._importTexture(p,u,d)>>>0};return{canvas:s,context:r,options:e,table(c){return i=c,{engineCreated(){c._createSwapChainHeadless(s.width,s.height),c._creatorWebSetViewport(s.width,s.height),o=!0},createGLView(){s.style.display="block"},closeScene(){s.style.display="none"},createTexture(f,u,d,p){const b=et(f);if(!b){p(`createTexture: no buffer behind id ${f}`);return}const g=new Uint8Array(b);if($s(g)){const x=c._malloc(g.length);c.HEAPU8.set(g,x);const m=c._createTextureFromKtx2(x,g.length)>>>0;if(c._free(x),m===4294967295){p("KTX2 transcode failed");return}d(m,c._getTextureWidth(m),c._getTextureHeight(m));return}createImageBitmap(Ot(f)).then(x=>{const m=h();r.texStorage2D(r.TEXTURE_2D,1,u&1?r.RGBA8:r.SRGB8_ALPHA8,x.width,x.height),r.texSubImage2D(r.TEXTURE_2D,0,0,0,x.width,x.height,r.RGBA,r.UNSIGNED_BYTE,x),d(l(c,m,x.width,x.height),x.width,x.height)},x=>p(x instanceof Error?x.message:String(x)))},createMediaPlayerTexture(f){const u=ce(f);if(!u)return 0;const d=h();return a.push({player:u,texture:d,lastTime:0}),l(c,d,0,0)}}},show(){s.style.display="block"},hide(){s.style.display="none"},resize(){i&&o&&i._creatorWebSetViewport(s.width,s.height)},frame(){for(const c of a)c.player.readyState<2||c.player.currentTime===c.lastTime||(c.lastTime=c.player.currentTime,r.bindTexture(r.TEXTURE_2D,c.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,c.player))},destroy(){var c;a.length=0,(c=r.getExtension("WEBGL_lose_context"))==null||c.loseContext()}}},js=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")},h=()=>{e.style.display="none"};return{canvas:e,context:s,options:t,table(l){return r=l,{open2DScene:a,close2DScene:h}},show:a,hide:h,resize:o,frame(l){r&&r._creatorWeb2dSceneOpen()&&r._creatorWeb2dRenderFrame(l)},destroy(){var l;(l=s.getExtension("WEBGL_lose_context"))==null||l.loseContext()}}},Ne=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)},Ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mn={};for(let n=0;n<Ue.length;n++)mn[Ue[n]]=n;const Vs=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 zs{constructor(t){w(this,"sources");w(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 h of i.split(",")){const l=Vs(h);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 Xs=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 zs(JSON.parse(e))}catch{return null}};let dt=null;const Ys=()=>{if(dt!==null)return dt;try{new Function("throw new Error('chisel-calibrate')")()}catch(n){const e=(n.stack??"").match(/<anonymous>:(\d+):\d+/);return dt=e?parseInt(e[1],10)-1:2,dt}return dt=2,dt},jt=(n,t)=>{const e=(n instanceof Error?n.stack:"")??"",s=Ys(),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,h=parseInt(o[2],10)-1;if(a<1)continue;const l=t.originalPositionFor(a,h<0?0:h);if(!l)continue;const c=i.match(/at\s+([^\s(]+)\s*\(/);r.push({fn:c?c[1]:null,source:l.source,line:l.line,column:l.column})}return r},Ks=/^\[ERROR\] (run|host callback|JsDispatch|timer|setLoop|animate|tween)\b:? ?([\s\S]*)$/,qs=(n,t)=>{const e=[],s=(l,c,f,u)=>{var b,g;if(f.length===0&&Ne(c)){const x=typeof c=="number"||typeof c=="bigint"?`code ${c}`:c instanceof Error?c.message||c.name:String(c),m=[u,x].filter(_=>!!_).filter((_,M,P)=>P.indexOf(_)===M).join(`
15
15
  `);console.error(`[lecodes] native engine error — ${m||x} (see the console for the engine's message)`);const v={message:"Native engine error",detail:m,frames:[],native:!0,stack:c instanceof Error?c.stack:void 0};(b=l.onError)==null||b.call(l,v),v.stack&&t&&jn(v.stack).then(_=>{var M;_.length>0&&((M=l.onError)==null||M.call(l,{...v,nativeFrames:_}))});return}const d=c instanceof Error?c.message:String(c),p=f[0];console.error(p?`[lecodes] ${d}
16
16
  at ${p.source}:${p.line}:${p.column}${p.fn?` (${p.fn})`:""}`:`[lecodes] ${d}`),(g=l.onError)==null||g.call(l,{message:d,frames:f,stack:c instanceof Error?c.stack:void 0})},r=(l,c)=>{for(let u=e.length-1;u>=0;u--){const d=e[u];if(!d.sourceMap)continue;const p=jt(l,d.sourceMap);if(p.length>0)return s(d,l,p,c)}const f=e[e.length-1];f&&Ne(l)&&s(f,l,[],c)};let i=null;const o=()=>{const l=e[e.length-1],c=i;if(i=null,!c||!l)return;const f=new Error(c.message.replace(/^Error: /,""));f.stack=c.stack.join(`
17
- `),s(l,f,l.sourceMap?jt(f,l.sourceMap):[])},a=l=>r(l.error??l.message,l.message),h=l=>r(l.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",h),{track(l,c){const f={sourceMap:zs(l),onError:c};return e.push(f),{drop(){const u=e.indexOf(f);u>=0&&e.splice(u,1)}}},locate(l){var f;const c=(f=e[e.length-1])==null?void 0:f.sourceMap;return c?jt(l,c):[]},runtimeLine(l){if(i&&/^\s+at /.test(l))return i.stack.push(l),!0;const c=Ys.exec(l);if(!c||e.length===0)return!1;o();const[f,...u]=c[2].split(`
18
- `);return i={message:(f??"").replace(/^JsTask /,""),stack:u},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",h),e.length=0}}},yn=n=>{var h,l,c,f;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const u of s[1].split(";"))e.add(u);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((h=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:h[1])??null,o=((c=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:c.trim())??null,a=new Set((((f=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:f[1])??"").split(";").map(u=>u.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:Fs(t)}},qs=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",Js=n=>{const t=n.ownerDocument,e=t.defaultView??window;let s=1/0;const r=(d,p)=>{const b=Math.min(s,(e.devicePixelRatio||1)*ae(n));return{width:d,height:p,factor:b,pixelWidth:Math.max(1,Math.round(d*b)),pixelHeight:Math.max(1,Math.round(p*b))}};let i=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const o=[],a=d=>{d.width!==i.pixelWidth&&(d.width=i.pixelWidth),d.height!==i.pixelHeight&&(d.height=i.pixelHeight)},h=()=>{const d=t.createElement("canvas");return d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(d),a(d),o.push(d),d},l=new Set,c=d=>{if(!(d.width<=0||d.height<=0)){i=d;for(const p of o)a(p);for(const p of l)p(i)}},f=new ResizeObserver(([d])=>{var v;if(!d)return;const{width:p,height:b}=d.contentRect,g=(v=d.devicePixelContentBoxSize)==null?void 0:v[0],x=r(p,b),m=g&&Math.abs(g.inlineSize-p*x.factor)<=1&&Math.abs(g.blockSize-b*x.factor)<=1;if(!g||!m){c(x);return}c({width:p,height:b,pixelWidth:Math.max(1,g.inlineSize),pixelHeight:Math.max(1,g.blockSize),factor:x.factor})});try{f.observe(n,{box:"device-pixel-content-box"})}catch{f.observe(n)}return{root:n,doc:t,win:e,size:()=>i,newCanvas:h,remeasure:d=>{d!==void 0&&(s=d>0?d:1/0);const p=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==i.pixelWidth||p.pixelHeight!==i.pixelHeight||p.factor!==i.factor)&&c(p)},onResize(d){return l.add(d),()=>{l.delete(d)}},destroy(){f.disconnect(),l.clear();for(const d of o)d.remove();o.length=0}}},Qs=n=>{const t=[],e=new Set;return{has:s=>e.has(s),register(s,r){e.has(s)||(e.add(s),r({registerView:(i,o,a=1)=>{t.push({id:s,version:a,kind:"view",name:i,factory:o})},registerService:(i,o,a=1)=>{t.push({id:s,version:a,kind:"service",name:i,factory:o})},putBuffer:ot,getBuffer:et}))},allow(s){var i,o;const r=new Set(s);for(const a of t){const h=r.has(a.id);a.kind==="view"?h?(i=n.registerView)==null||i.call(n,a.name,a.factory,a.version):(o=n.unregisterView)==null||o.call(n,a.name):h?n.registerService(a.name,a.factory,a.version):n.unregisterService(a.name)}}}},Zs=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()}}},ti={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},We="material:",ei=n=>{const t=new Set;for(const e of n)e.startsWith(We)&&t.add(ti[e.slice(We.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},ni=""+new URL("assets/materials-uri4FvPE.bin",import.meta.url).href,ri=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,si=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,ii=""+new URL("assets/uberarchive-DLH-kBhM.bin",import.meta.url).href,oi={base:ni,world:ri},ai=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},ci=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=ei(n).map(o=>oi[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(si),t(ii),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:ai(i)}:{}}},li=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")},setOrientation(i){var h,l,c,f;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"?(h=a.unlock)==null||h.call(a):(f=(c=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:c.catch)==null||f.call(c,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},hi=(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([ot(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ot(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)}},ui=n=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return window.devicePixelRatio||1},vibrate(){var t;try{(t=navigator.vibrate)==null||t.call(navigator,30)}catch{}},clipboardWrite(t){var e;(e=navigator.clipboard)==null||e.writeText(t).catch(()=>{})},clipboardRead(t,e){const s=navigator.clipboard;if(!(s!=null&&s.readText)){e("Clipboard is not available");return}s.readText().then(t,r=>e(r instanceof Error?r.message:"Clipboard read failed"))},share(t){const e=URL.createObjectURL(Ot(t)),s=document.createElement("a");s.href=e,s.download="image.png",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(e)},openFilePicker:(t,e,s,r)=>hi(t,e,s,r??void 0),requestCamera(t){t()}}),di=(n={})=>({local:t=>Qn(t),dispose:t=>Yn(t),request(t,e,s,r,i,o,a,h){if(t.startsWith("id:")){const f=Number(t.slice(3));o(f,et(f)?200:404);return}const l={};for(let f=0;f+1<s.length;f+=2)l[s[f]]=s[f+1];let c;if(i.length>0){const f=new FormData;for(const u of i)u.key!==null&&(u.bufferId>0?f.append(u.key,Ot(u.bufferId),u.filename??void 0):f.append(u.key,u.value??""));c=f}else r!==null&&(c=r);(async()=>{var f;try{const u=await fetch(t,{method:e,headers:l,body:c,mode:"cors",credentials:"omit"}),d=h?(f=u.body)==null?void 0:f.getReader():void 0;if(!d){o(ot(await u.arrayBuffer()),u.status);return}const p=Number(u.headers.get("content-length"))||void 0,b=[];let g=0;for(;;){const{done:v,value:_}=await d.read();if(v)break;_&&(b.push(_),g+=_.length,h({loaded:g,total:p}))}const x=new Uint8Array(g);let m=0;for(const v of b)x.set(v,m),m+=v.length;o(ot(x.buffer),u.status)}catch(u){a(u instanceof Error?u.message:String(u))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ot(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}}),De=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Vt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Rt=4,zt=16,He=16,fi=.5,pi=n=>{const t=new Set;let e=null;const s=(S,k,N=-1,C=0)=>{e==null||e(S,k,N,C)},r=S=>{if(!S.code)return;const k=t.has(S.code);t.add(S.code),s(0,S.code,-1,k||S.repeat?1:0)},i=S=>{S.code&&t.delete(S.code)&&s(1,S.code)},o=()=>{for(const S of[...t])S.startsWith("Gamepad")||(t.delete(S),s(1,S))},{root:a}=n;let h=0,l=0,c=0,f=0,u=0,d=0,p=0,b=0,g=0,x=0;const m=S=>{if(S.pointerType&&S.pointerType!=="mouse")return;const k=a.getBoundingClientRect();h=S.clientX-k.left,l=S.clientY-k.top,c+=S.movementX||0,f+=S.movementY||0},v=S=>{const k=De[S.button];k&&(t.add(k),s(0,k))},_=S=>{const k=De[S.button];k&&t.delete(k)&&s(1,k)},M=S=>{const k=S.deltaMode===0?.01:1;u+=S.deltaX*k,d+=S.deltaY*k},P=S=>{document.pointerLockElement===a&&S.preventDefault()},I=[],F=[],D=[],R=()=>{var k,N;const S=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let C=0;C<Rt;C++){const Q=S[C]??null,E=!!Q&&Q.connected;if(E!==!!I[C]){if(I[C]=E,!E){for(const K of Vt)t.delete(K+"@"+C)&&(s(1,K,C),z(K));D[C]=[],F[C]=[0,0,0,0,0,0]}s(E?2:3,"",C)}if(!Q||!E)continue;const O=Q.axes,U=Q.buttons,rt=((k=U[6])==null?void 0:k.value)??0,wt=((N=U[7])==null?void 0:N.value)??0;F[C]=[O[0]??0,O[1]??0,O[2]??0,O[3]??0,rt,wt];const de=D[C]??(D[C]=[]);for(let K=0;K<Vt.length;K++){const Ft=U[K],St=!!Ft&&(Ft.pressed||Ft.value>fi);if(St===!!de[K])continue;de[K]=St;const Et=Vt[K];St?t.add(Et+"@"+C):t.delete(Et+"@"+C),z(Et),s(St?0:1,Et,C)}}},z=S=>{let k=!1;for(let N=0;N<Rt&&!k;N++)t.has(S+"@"+N)&&(k=!0);k?t.add(S):t.delete(S)};let G=0;const j=()=>{p=c,b=f,g=u,x=d,c=f=u=d=0,R(),G=requestAnimationFrame(j)},y=n.windows.filter((S,k,N)=>S&&N.indexOf(S)===k);for(const S of y)n.keyboard!==!1&&(S.addEventListener("keydown",r),S.addEventListener("keyup",i)),S.addEventListener("blur",o);return a.addEventListener("pointermove",m,!0),a.addEventListener("mousedown",v,!0),window.addEventListener("mouseup",_,!0),a.addEventListener("wheel",M,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(j)),{inputKey:(S,k)=>k>=0&&S.startsWith("Gamepad")?t.has(S+"@"+k):t.has(S),inputRead:S=>{var k;switch(S){case 0:return h;case 1:return l;case 2:return p;case 3:return b;case 4:return g;case 5:return x;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let C=0;C<Rt;C++)I[C]&&N++;return N}}if(S>=zt){const N=Math.floor((S-zt)/He),C=(S-zt)%He;return N>=Rt||!I[N]?0:C===0?1:((k=F[N])==null?void 0:k[C-1])??0}return 0},inputSetPointerLock:S=>{if(!S)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const k=a.requestPointerLock({unadjustedMovement:!0});return k&&typeof k.catch=="function"&&k.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:S=>{e=S},dispose:()=>{for(const S of y)S.removeEventListener("keydown",r),S.removeEventListener("keyup",i),S.removeEventListener("blur",o);a.removeEventListener("pointermove",m,!0),a.removeEventListener("mousedown",v,!0),window.removeEventListener("mouseup",_,!0),a.removeEventListener("wheel",M,!0),a.removeEventListener("contextmenu",P,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},gi=n=>{const t=pi(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},mi={createVideo:ur,createAudio:dr,setVolume:fr,setPlaying:pr,setLoop:gr,time:mr,setTime:yr,duration:wr,remove:br},yi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(u,d,p=1)=>{n.set(u,d),t.set(u,p)},unregisterService:u=>{n.delete(u),t.delete(u)},isServiceSupported:u=>n.has(u),serviceVersion:u=>t.get(u)??0,serviceOpen:(u,d,p)=>{const b=n.get(u);if(!b)return-1;const g=s++,x=b(d?JSON.parse(d):{},{emit:(m,v)=>{v===void 0?p(m):p(m,v)}});return e.set(g,x),g},serviceCall:(u,d,p,b,g)=>{const x=e.get(u);if(!(x!=null&&x.call)){g(`Service call "${d}": no live session or no call handler (serviceId ${u})`);return}try{Promise.resolve(x.call(d,Array.isArray(p)?p:[])).then(m=>{m===void 0?b():b(m)},m=>g(m instanceof Error?m.message:String(m)))}catch(m){g(m instanceof Error?m.message:String(m))}},serviceClose:u=>{var d,p;(p=(d=e.get(u))==null?void 0:d.close)==null||p.call(d),e.delete(u)},destroy:()=>{var u;for(const d of e.values())(u=d.close)==null||u.call(d);e.clear()}}},wi=()=>{const n=yi();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}},bi=()=>{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}}},vi=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{}}}},Be=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},xi={fetch:zn,getBuffer:et,getBlob:Ot,putBuffer:ot,putLocalBuffer:Kn,hasLocalBuffer:qn,getLocalName:Jn,getPlayer:ce,removePlayers:an},Si=(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)},widgetOpen(){},widgetClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),Ei=async(n,t={})=>{var Q;const e=t.header,s=t.profile??(e?qs(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),h=Js(n),{doc:l,win:c}=h,f=i?Promise.all([Ws(void 0,l),Ns((e==null?void 0:e.bootFonts)??[],l)]):null,u=o?$s(h,r.has("capture")):null,d=a?Gs(h):null,p=i?h.newCanvas():null,b=Ks(c,o);o&&Vn();const[g,x]=await Promise.all([Pn(s,{glContext:u==null?void 0:u.context,glOptions:u==null?void 0:u.options,gl2dContext:d==null?void 0:d.context,gl2dOptions:d==null?void 0:d.options,moduleArgs:{print:E=>{b.runtimeLine(E)?console.debug(E):console.log(E)},printErr:E=>{console.error(E)}}}),o?ci(r):Promise.resolve({})]),m=(E,O)=>{const U=g.stringToNewUTF8(E);try{return O(U)}finally{g._free(U)}};let v=null,_=-1,M=-1;const P=(E,O)=>{M=E,E===Ut&&(u==null||u.show()),E===ke&&(d==null||d.show()),v&&E===Ut&&O!==_&&(_=O,v.openScene(O))},I=E=>{E!==M&&(E===Ut&&(u==null||u.hide(),v&&_>=0&&(_=-1,v.closeScene())),E===ke&&(d==null||d.hide()))},F=Os(),R=p?Ss(n,{M:g,canvas:p,canvasHost:F,keyboardHeight:()=>{const E=c.visualViewport;return E?Math.max(0,Math.round((c.innerHeight-E.height-E.offsetTop)/ae(n))):0}}):null;R&&(R.ui.onDestination=P,R.ui.onDropped=I);const z=li({onOrientation:t.onOrientation,push:(E,O)=>{E==="url"&&O!==void 0&&m(O,U=>g._creatorWebSetLaunchUrl(U)),m(E,U=>{O===void 0?g._creatorWebAppEvent(U,0):m(O,rt=>g._creatorWebAppEvent(U,rt))})}}),G=bi(),j=wi(),y=gi({windows:[...new Set([c,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(E,O,U,rt)=>m(O,wt=>g._creatorWebInputEvent(E,wt,U,rt)),keyboardHeight:()=>(R==null?void 0:R.ui.keyboardHeight())??0}),L={ui:(R==null?void 0:R.ui)??Si(P,I),app:z.table,device:ui(t.language??(()=>(c.navigator.language||"en").slice(0,2))),fetch:di(x),storage:vi(t.project??(e==null?void 0:e.name)??"app"),socket:G.table,service:j.table,input:y.table,media:mi,canvas:F.table,...u?{gl:u.table(g)}:{},...d?{scene2d:d.table(g)}:{}},A=Be(),H=A.global;Hn(g,{host:L,world:A,newWorld:Be});const Y=Qs({...R?{registerView:(E,O,U)=>R.ui.registerView(E,O,U),unregisterView:E=>R.ui.unregisterView(E)}:{},registerService:j.registerService,unregisterService:j.unregisterService});g._creatorWebInit(),t.launchUrl&&m(t.launchUrl,E=>g._creatorWebSetLaunchUrl(E)),R==null||R.ui.install(),!o&&t.engine3d&&(v=await t.engine3d({newCanvas:h.newCanvas,preloads:r,canvasHost:F,stores:xi}),Object.defineProperty(H,"_creator",{value:v,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Q=H._creator)==null||Q.createEngine());const J=Zs(n);t.safeArea&&J.set(t.safeArea);const S=E=>{var O;u==null||u.resize(),d==null||d.resize(),(O=v==null?void 0:v._onResize)==null||O.call(v,E.width,E.height,E.factor),R?(R.resize(E.width,E.height,E.factor),R.setSafeArea(J.current())):g._creatorWebResize(E.width,E.height)};h.onResize(S),S(h.size());let k=0;const N=E=>{k=c.requestAnimationFrame(N),u==null||u.frame(),g._creatorWebTick(E),d==null||d.frame(E),R&&(R.ui.layoutFrame(),R.ui.tickHover(),R.render())};k=c.requestAnimationFrame(N),await f;let C=!1;return{profile:s,M:g,world:H,ui:(R==null?void 0:R.ui)??null,engine3d:()=>v,getBuffer:E=>et(E),run(E,O={}){const U=O.header??yn(E);if(!Ds(U.sdk,Fe))throw new Error(`This app was built with LeCodes SDK ${U.sdk??"older than 2.0"}; this host runs SDK ${Fe}. It needs a new build.`);const rt=b.track(E,O.onError);return Y.allow(U.plugins),m(E,wt=>g._creatorWebRun(wt)),{dispose:rt.drop}},registerPlugin:(E,O)=>Y.register(E,O),hasPlugin:Y.has,locate:b.locate,safeArea:()=>J.current(),setSafeArea(E){J.set(E),R==null||R.setSafeArea(J.current())},remeasure:h.remeasure,emitAppEvent:z.emit,destroy(){var E;C||(C=!0,c.cancelAnimationFrame(k),b.dispose(),R==null||R.destroy(),y.dispose(),G.dispose(),j.dispose(),z.dispose(),an(),J.destroy(),(E=v==null?void 0:v._dispose)==null||E.call(v),u==null||u.destroy(),d==null||d.destroy(),h.destroy())}}},_i=(n,t)=>new Promise(e=>{const s=n.ownerDocument.defaultView??window;s.requestAnimationFrame(()=>{try{const r=[...n.querySelectorAll("canvas")].filter(l=>l.width>0&&l.height>0&&s.getComputedStyle(l).display!=="none");if(r.length===0){e(null);return}const i=n.getBoundingClientRect(),o=t??Math.max(...r.map(l=>l.width))/Math.max(1,i.width),a=n.ownerDocument.createElement("canvas");a.width=Math.max(1,Math.round(i.width*o)),a.height=Math.max(1,Math.round(i.height*o));const h=a.getContext("2d");if(!h){e(null);return}h.fillStyle="#000000",h.fillRect(0,0,a.width,a.height);for(const l of r)h.drawImage(l,0,0,l.width,l.height,0,0,a.width,a.height);e(a.toDataURL("image/png"))}catch{e(null)}})}),Ti=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)}},ki=(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 h={};try{h=JSON.parse(String(a.data))}catch{return}h.type==="reload"&&typeof h.v=="number"&&t(h.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const h=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(h)?h:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(Ti).join(" ")}),error:o=>e({type:"error",text:o})}},Ri={camera:()=>q(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>q(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>q(()=>import("./assets/map-XzoOFt0E.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>q(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>q(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t))},Ai=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=Ri[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)}`)}}))},le=n=>typeof n=="object"&&n!==null,gt=n=>typeof n=="number"&&Number.isFinite(n),Mi=n=>{if(!le(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return gt(n.x)&&gt(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return gt(n.node)?{ask:"node",node:n.node}:null;default:return null}},wn=n=>{if(!le(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}:{}}},Li=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return wn({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},Pi=n=>{if(!le(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:wn(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:inspect":{const t=Mi(n.question);return t&&gt(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!gt(n.request))return null;const t=gt(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}},Ci=(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}},Oi=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=Pi(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)}}},he=window.lecodesPlayerConfig??{},mt=document.getElementById("app"),Xt=document.getElementById("loader"),$e=document.getElementById("error"),at=new URLSearchParams(location.search),bn=n=>Xt==null?void 0:Xt.classList.toggle("on",n),vn=n=>{$e&&($e.textContent=window.parent===window?n:"")};let se=he.language||at.get("lang")||(navigator.language||"en").slice(0,2),Lt=he.safeArea??Li(at),W=null;const Ge=()=>{var n;return(n=W==null?void 0:W.world)==null?void 0:n._creatorTree},Pt=at.has("test")?{ready:!1,dump:()=>{var n;return((n=Ge())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Ge())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=mt.getBoundingClientRect();return[e.left+t[0],e.top+t[1],t[2],t[3]]}}:null;Pt&&(window.lecodesTest=Pt);const Ii=at.has("inspect"),ie=Ii?q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url):null;let pt=null;const Fi=async(n,t)=>{const{createInspector:e}=await(ie??q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url));W&&pt===null&&(pt=e(W)),nt.post({type:"lecodes:inspected",request:n,answer:(pt==null?void 0:pt.answer(t))??null})},je=at.has("dev")?new URL(at.get("dev")||"..",location.href).href.replace(/\/$/,""):null,Ve=n=>{var s;const t=n.frames[0],e=t?`
17
+ `),s(l,f,l.sourceMap?jt(f,l.sourceMap):[])},a=l=>r(l.error??l.message,l.message),h=l=>r(l.reason);return n.addEventListener("error",a),n.addEventListener("unhandledrejection",h),{track(l,c){const f={sourceMap:Xs(l),onError:c};return e.push(f),{drop(){const u=e.indexOf(f);u>=0&&e.splice(u,1)}}},locate(l){var f;const c=(f=e[e.length-1])==null?void 0:f.sourceMap;return c?jt(l,c):[]},runtimeLine(l){if(i&&/^\s+at /.test(l))return i.stack.push(l),!0;const c=Ks.exec(l);if(!c||e.length===0)return!1;o();const[f,...u]=c[2].split(`
18
+ `);return i={message:(f??"").replace(/^JsTask /,""),stack:u},n.setTimeout(o,0),!0},dispose(){n.removeEventListener("error",a),n.removeEventListener("unhandledrejection",h),e.length=0}}},yn=n=>{var h,l,c,f;const t=n.slice(0,2e3),e=new Set,s=t.match(/\/\/ preload: (.+)/);if(s)for(const u of s[1].split(";"))e.add(u);const r=t.includes("// gl: disable")?"off":t.includes("// gl: defer")?"defer":"on",i=((h=t.match(/^\/\/ sdk: (\d+\.\d+\.\d+\S*)/m))==null?void 0:h[1])??null,o=((c=(l=t.match(/^\/\/ name: (.+)$/m))==null?void 0:l[1])==null?void 0:c.trim())??null,a=new Set((((f=t.match(/^\/\/ plugins: (.+)$/m))==null?void 0:f[1])??"").split(";").map(u=>u.trim()).filter(Boolean));return{sdk:i,name:o,preloads:e,gl:r,is2d:t.includes("// 2d: enable"),plugins:a,bootFonts:Ns(t)}},Js=n=>n.gl!=="off"?"full":n.is2d?"2d":"ui",Qs=n=>{const t=n.ownerDocument,e=t.defaultView??window;let s=1/0;const r=(d,p)=>{const b=Math.min(s,(e.devicePixelRatio||1)*ae(n));return{width:d,height:p,factor:b,pixelWidth:Math.max(1,Math.round(d*b)),pixelHeight:Math.max(1,Math.round(p*b))}};let i=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));const o=[],a=d=>{d.width!==i.pixelWidth&&(d.width=i.pixelWidth),d.height!==i.pixelHeight&&(d.height=i.pixelHeight)},h=()=>{const d=t.createElement("canvas");return d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:none;",n.appendChild(d),a(d),o.push(d),d},l=new Set,c=d=>{if(!(d.width<=0||d.height<=0)){i=d;for(const p of o)a(p);for(const p of l)p(i)}},f=new ResizeObserver(([d])=>{var v;if(!d)return;const{width:p,height:b}=d.contentRect,g=(v=d.devicePixelContentBoxSize)==null?void 0:v[0],x=r(p,b),m=g&&Math.abs(g.inlineSize-p*x.factor)<=1&&Math.abs(g.blockSize-b*x.factor)<=1;if(!g||!m){c(x);return}c({width:p,height:b,pixelWidth:Math.max(1,g.inlineSize),pixelHeight:Math.max(1,g.blockSize),factor:x.factor})});try{f.observe(n,{box:"device-pixel-content-box"})}catch{f.observe(n)}return{root:n,doc:t,win:e,size:()=>i,newCanvas:h,remeasure:d=>{d!==void 0&&(s=d>0?d:1/0);const p=r(Math.max(1,n.clientWidth),Math.max(1,n.clientHeight));(p.pixelWidth!==i.pixelWidth||p.pixelHeight!==i.pixelHeight||p.factor!==i.factor)&&c(p)},onResize(d){return l.add(d),()=>{l.delete(d)}},destroy(){f.disconnect(),l.clear();for(const d of o)d.remove();o.length=0}}},Zs=n=>{const t=[],e=new Set;return{has:s=>e.has(s),register(s,r){e.has(s)||(e.add(s),r({registerView:(i,o,a=1)=>{t.push({id:s,version:a,kind:"view",name:i,factory:o})},registerService:(i,o,a=1)=>{t.push({id:s,version:a,kind:"service",name:i,factory:o})},putBuffer:ot,getBuffer:et}))},allow(s){var i,o;const r=new Set(s);for(const a of t){const h=r.has(a.id);a.kind==="view"?h?(i=n.registerView)==null||i.call(n,a.name,a.factory,a.version):(o=n.unregisterView)==null||o.call(n,a.name):h?n.registerService(a.name,a.factory,a.version):n.unregisterService(a.name)}}}},ti=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()}}},ei={lightmap:"world","lightmap-masked":"world","lightmap-lite":"world","lightmap-masked-lite":"world",terrain:"world","terrain-lightmap":"world",foliage:"world","foliage-masked":"world"},We="material:",ni=n=>{const t=new Set;for(const e of n)e.startsWith(We)&&t.add(ei[e.slice(We.length)]??"base");return[...t].sort((e,s)=>e==="base"?-1:s==="base"?1:e.localeCompare(s))},ri=""+new URL("assets/materials-uri4FvPE.bin",import.meta.url).href,si=""+new URL("assets/materials-world-CQWt8TAm.bin",import.meta.url).href,ii=""+new URL("assets/neutral_ibl128-D-lzdkLN.ktx",import.meta.url).href,oi=""+new URL("assets/uberarchive-DLH-kBhM.bin",import.meta.url).href,ai={base:ri,world:si},ci=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},li=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=ni(n).map(o=>ai[o]).filter(o=>!!o),[s,r,...i]=await Promise.all([t(ii),t(oi),...e.map(t)]);return{1:s,2:r,...i.length>0?{3:ci(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")},setOrientation(i){var h,l,c,f;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"?(h=a.unlock)==null||h.call(a):(f=(c=(l=a.lock)==null?void 0:l.call(a,o))==null?void 0:c.catch)==null||f.call(c,()=>{})}catch{}}},emit:(i,o)=>n.push(i,o),dispose(){document.removeEventListener("visibilitychange",t),window.removeEventListener("online",e),window.removeEventListener("offline",s)}}},ui=(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([ot(await a.arrayBuffer()),a.name,a.size]);n(o)}else{if(!i||i.length===0)return n(null);n([[ot(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)}},di=n=>({get platform(){return"web"},get language(){return n()},get pixelRatio(){return window.devicePixelRatio||1},vibrate(){var t;try{(t=navigator.vibrate)==null||t.call(navigator,30)}catch{}},clipboardWrite(t){var e;(e=navigator.clipboard)==null||e.writeText(t).catch(()=>{})},clipboardRead(t,e){const s=navigator.clipboard;if(!(s!=null&&s.readText)){e("Clipboard is not available");return}s.readText().then(t,r=>e(r instanceof Error?r.message:"Clipboard read failed"))},share(t){const e=URL.createObjectURL(Ot(t)),s=document.createElement("a");s.href=e,s.download="image.png",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(e)},openFilePicker:(t,e,s,r)=>ui(t,e,s,r??void 0),requestCamera(t){t()}}),fi=(n={})=>({local:t=>Qn(t),dispose:t=>Yn(t),request(t,e,s,r,i,o,a,h){if(t.startsWith("id:")){const f=Number(t.slice(3));o(f,et(f)?200:404);return}const l={};for(let f=0;f+1<s.length;f+=2)l[s[f]]=s[f+1];let c;if(i.length>0){const f=new FormData;for(const u of i)u.key!==null&&(u.bufferId>0?f.append(u.key,Ot(u.bufferId),u.filename??void 0):f.append(u.key,u.value??""));c=f}else r!==null&&(c=r);(async()=>{var f;try{const u=await fetch(t,{method:e,headers:l,body:c,mode:"cors",credentials:"omit"}),d=h?(f=u.body)==null?void 0:f.getReader():void 0;if(!d){o(ot(await u.arrayBuffer()),u.status);return}const p=Number(u.headers.get("content-length"))||void 0,b=[];let g=0;for(;;){const{done:v,value:_}=await d.read();if(v)break;_&&(b.push(_),g+=_.length,h({loaded:g,total:p}))}const x=new Uint8Array(g);let m=0;for(const v of b)x.set(v,m),m+=v.length;o(ot(x.buffer),u.status)}catch(u){a(u instanceof Error?u.message:String(u))}})()},buffer:t=>{const e=et(t);return e?new Uint8Array(e):null},putBuffer:t=>ot(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}}),De=["MouseLeft","MouseMiddle","MouseRight","MouseBack","MouseForward"],Vt=["GamepadSouth","GamepadEast","GamepadWest","GamepadNorth","GamepadL1","GamepadR1","GamepadL2","GamepadR2","GamepadSelect","GamepadStart","GamepadL3","GamepadR3","GamepadUp","GamepadDown","GamepadLeft","GamepadRight"],Rt=4,zt=16,He=16,pi=.5,gi=n=>{const t=new Set;let e=null;const s=(S,k,N=-1,C=0)=>{e==null||e(S,k,N,C)},r=S=>{if(!S.code)return;const k=t.has(S.code);t.add(S.code),s(0,S.code,-1,k||S.repeat?1:0)},i=S=>{S.code&&t.delete(S.code)&&s(1,S.code)},o=()=>{for(const S of[...t])S.startsWith("Gamepad")||(t.delete(S),s(1,S))},{root:a}=n;let h=0,l=0,c=0,f=0,u=0,d=0,p=0,b=0,g=0,x=0;const m=S=>{if(S.pointerType&&S.pointerType!=="mouse")return;const k=a.getBoundingClientRect();h=S.clientX-k.left,l=S.clientY-k.top,c+=S.movementX||0,f+=S.movementY||0},v=S=>{const k=De[S.button];k&&(t.add(k),s(0,k))},_=S=>{const k=De[S.button];k&&t.delete(k)&&s(1,k)},M=S=>{const k=S.deltaMode===0?.01:1;u+=S.deltaX*k,d+=S.deltaY*k},P=S=>{document.pointerLockElement===a&&S.preventDefault()},I=[],F=[],D=[],R=()=>{var k,N;const S=typeof navigator<"u"&&navigator.getGamepads?Array.from(navigator.getGamepads()):[];for(let C=0;C<Rt;C++){const Q=S[C]??null,E=!!Q&&Q.connected;if(E!==!!I[C]){if(I[C]=E,!E){for(const K of Vt)t.delete(K+"@"+C)&&(s(1,K,C),z(K));D[C]=[],F[C]=[0,0,0,0,0,0]}s(E?2:3,"",C)}if(!Q||!E)continue;const O=Q.axes,U=Q.buttons,rt=((k=U[6])==null?void 0:k.value)??0,wt=((N=U[7])==null?void 0:N.value)??0;F[C]=[O[0]??0,O[1]??0,O[2]??0,O[3]??0,rt,wt];const de=D[C]??(D[C]=[]);for(let K=0;K<Vt.length;K++){const Ft=U[K],St=!!Ft&&(Ft.pressed||Ft.value>pi);if(St===!!de[K])continue;de[K]=St;const Et=Vt[K];St?t.add(Et+"@"+C):t.delete(Et+"@"+C),z(Et),s(St?0:1,Et,C)}}},z=S=>{let k=!1;for(let N=0;N<Rt&&!k;N++)t.has(S+"@"+N)&&(k=!0);k?t.add(S):t.delete(S)};let G=0;const j=()=>{p=c,b=f,g=u,x=d,c=f=u=d=0,R(),G=requestAnimationFrame(j)},y=n.windows.filter((S,k,N)=>S&&N.indexOf(S)===k);for(const S of y)n.keyboard!==!1&&(S.addEventListener("keydown",r),S.addEventListener("keyup",i)),S.addEventListener("blur",o);return a.addEventListener("pointermove",m,!0),a.addEventListener("mousedown",v,!0),window.addEventListener("mouseup",_,!0),a.addEventListener("wheel",M,{passive:!0,capture:!0}),a.addEventListener("contextmenu",P,!0),typeof requestAnimationFrame=="function"&&(G=requestAnimationFrame(j)),{inputKey:(S,k)=>k>=0&&S.startsWith("Gamepad")?t.has(S+"@"+k):t.has(S),inputRead:S=>{var k;switch(S){case 0:return h;case 1:return l;case 2:return p;case 3:return b;case 4:return g;case 5:return x;case 6:return document.pointerLockElement===a?1:0;case 7:{let N=0;for(let C=0;C<Rt;C++)I[C]&&N++;return N}}if(S>=zt){const N=Math.floor((S-zt)/He),C=(S-zt)%He;return N>=Rt||!I[N]?0:C===0?1:((k=F[N])==null?void 0:k[C-1])??0}return 0},inputSetPointerLock:S=>{if(!S)return document.pointerLockElement===a&&document.exitPointerLock(),!0;if(document.pointerLockElement===a)return!0;if(typeof a.requestPointerLock!="function")return!1;try{const k=a.requestPointerLock({unadjustedMovement:!0});return k&&typeof k.catch=="function"&&k.catch(()=>{try{a.requestPointerLock()}catch{}}),!0}catch{return!1}},registerInputEvent:S=>{e=S},dispose:()=>{for(const S of y)S.removeEventListener("keydown",r),S.removeEventListener("keyup",i),S.removeEventListener("blur",o);a.removeEventListener("pointermove",m,!0),a.removeEventListener("mousedown",v,!0),window.removeEventListener("mouseup",_,!0),a.removeEventListener("wheel",M,!0),a.removeEventListener("contextmenu",P,!0),G&&cancelAnimationFrame(G),document.pointerLockElement===a&&document.exitPointerLock(),t.clear(),e=null}}},mi=n=>{const t=gi(n);return t.registerInputEvent(n.push),{table:{key:t.inputKey,read:t.inputRead,setPointerLock:t.inputSetPointerLock,keyboardHeight:n.keyboardHeight},dispose:t.dispose}},yi={createVideo:ur,createAudio:dr,setVolume:fr,setPlaying:pr,setLoop:gr,time:mr,setTime:yr,duration:wr,remove:br},wi=()=>{const n=new Map,t=new Map,e=new Map;let s=1;return{registerService:(u,d,p=1)=>{n.set(u,d),t.set(u,p)},unregisterService:u=>{n.delete(u),t.delete(u)},isServiceSupported:u=>n.has(u),serviceVersion:u=>t.get(u)??0,serviceOpen:(u,d,p)=>{const b=n.get(u);if(!b)return-1;const g=s++,x=b(d?JSON.parse(d):{},{emit:(m,v)=>{v===void 0?p(m):p(m,v)}});return e.set(g,x),g},serviceCall:(u,d,p,b,g)=>{const x=e.get(u);if(!(x!=null&&x.call)){g(`Service call "${d}": no live session or no call handler (serviceId ${u})`);return}try{Promise.resolve(x.call(d,Array.isArray(p)?p:[])).then(m=>{m===void 0?b():b(m)},m=>g(m instanceof Error?m.message:String(m)))}catch(m){g(m instanceof Error?m.message:String(m))}},serviceClose:u=>{var d,p;(p=(d=e.get(u))==null?void 0:d.close)==null||p.call(d),e.delete(u)},destroy:()=>{var u;for(const d of e.values())(u=d.close)==null||u.call(d);e.clear()}}},bi=()=>{const n=wi();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}},vi=()=>{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}}},xi=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{}}}},Be=()=>{const n={};return{global:n,evaluate:e=>{const s=Object.getOwnPropertyNames(n);return new Function(...s,e)(...s.map(r=>n[r]))}}},Si={fetch:zn,getBuffer:et,getBlob:Ot,putBuffer:ot,putLocalBuffer:Kn,hasLocalBuffer:qn,getLocalName:Jn,getPlayer:ce,removePlayers:an},Ei=(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)},widgetOpen(){},widgetClose(){},registerFont(e,s,r,i,o){o()},showToast(){},getButtonPressed:()=>!1,getTextValue:()=>"",vlistScroll(){}}),_i=async(n,t={})=>{var Q;const e=t.header,s=t.profile??(e?Js(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),h=Qs(n),{doc:l,win:c}=h,f=i?Promise.all([Ds(void 0,l),Us((e==null?void 0:e.bootFonts)??[],l)]):null,u=o?Gs(h,r.has("capture")):null,d=a?js(h):null,p=i?h.newCanvas():null,b=qs(c,o);o&&Vn();const[g,x]=await Promise.all([Pn(s,{glContext:u==null?void 0:u.context,glOptions:u==null?void 0:u.options,gl2dContext:d==null?void 0:d.context,gl2dOptions:d==null?void 0:d.options,moduleArgs:{print:E=>{b.runtimeLine(E)?console.debug(E):console.log(E)},printErr:E=>{console.error(E)}}}),o?li(r):Promise.resolve({})]),m=(E,O)=>{const U=g.stringToNewUTF8(E);try{return O(U)}finally{g._free(U)}};let v=null,_=-1,M=-1;const P=(E,O)=>{M=E,E===Ut&&(u==null||u.show()),E===ke&&(d==null||d.show()),v&&E===Ut&&O!==_&&(_=O,v.openScene(O))},I=E=>{E!==M&&(E===Ut&&(u==null||u.hide(),v&&_>=0&&(_=-1,v.closeScene())),E===ke&&(d==null||d.hide()))},F=Is(),R=p?Es(n,{M:g,canvas:p,canvasHost:F,keyboardHeight:()=>{const E=c.visualViewport;return E?Math.max(0,Math.round((c.innerHeight-E.height-E.offsetTop)/ae(n))):0}}):null;R&&(R.ui.onDestination=P,R.ui.onDropped=I);const z=hi({onOrientation:t.onOrientation,push:(E,O)=>{E==="url"&&O!==void 0&&m(O,U=>g._creatorWebSetLaunchUrl(U)),m(E,U=>{O===void 0?g._creatorWebAppEvent(U,0):m(O,rt=>g._creatorWebAppEvent(U,rt))})}}),G=vi(),j=bi(),y=mi({windows:[...new Set([c,...t.keyboardTargets??[]])],root:n,keyboard:t.keyboard!==!1,push:(E,O,U,rt)=>m(O,wt=>g._creatorWebInputEvent(E,wt,U,rt)),keyboardHeight:()=>(R==null?void 0:R.ui.keyboardHeight())??0}),L={ui:(R==null?void 0:R.ui)??Ei(P,I),app:z.table,device:di(t.language??(()=>(c.navigator.language||"en").slice(0,2))),fetch:fi(x),storage:xi(t.project??(e==null?void 0:e.name)??"app"),socket:G.table,service:j.table,input:y.table,media:yi,canvas:F.table,...u?{gl:u.table(g)}:{},...d?{scene2d:d.table(g)}:{}},A=Be(),H=A.global;Hn(g,{host:L,world:A,newWorld:Be});const Y=Zs({...R?{registerView:(E,O,U)=>R.ui.registerView(E,O,U),unregisterView:E=>R.ui.unregisterView(E)}:{},registerService:j.registerService,unregisterService:j.unregisterService});g._creatorWebInit(),t.launchUrl&&m(t.launchUrl,E=>g._creatorWebSetLaunchUrl(E)),R==null||R.ui.install(),!o&&t.engine3d&&(v=await t.engine3d({newCanvas:h.newCanvas,preloads:r,canvasHost:F,stores:Si}),Object.defineProperty(H,"_creator",{value:v,configurable:!0,writable:!0,enumerable:!1})),o&&(e==null?void 0:e.gl)!=="defer"&&((Q=H._creator)==null||Q.createEngine());const J=ti(n);t.safeArea&&J.set(t.safeArea);const S=E=>{var O;u==null||u.resize(),d==null||d.resize(),(O=v==null?void 0:v._onResize)==null||O.call(v,E.width,E.height,E.factor),R?(R.resize(E.width,E.height,E.factor),R.setSafeArea(J.current())):g._creatorWebResize(E.width,E.height)};h.onResize(S),S(h.size());let k=0;const N=E=>{k=c.requestAnimationFrame(N),u==null||u.frame(),g._creatorWebTick(E),d==null||d.frame(E),R&&(R.ui.layoutFrame(),R.ui.tickHover(),R.render())};k=c.requestAnimationFrame(N),await f;let C=!1;return{profile:s,M:g,world:H,ui:(R==null?void 0:R.ui)??null,engine3d:()=>v,getBuffer:E=>et(E),run(E,O={}){const U=O.header??yn(E);if(!Hs(U.sdk,Fe))throw new Error(`This app was built with LeCodes SDK ${U.sdk??"older than 2.0"}; this host runs SDK ${Fe}. It needs a new build.`);const rt=b.track(E,O.onError);return Y.allow(U.plugins),m(E,wt=>g._creatorWebRun(wt)),{dispose:rt.drop}},registerPlugin:(E,O)=>Y.register(E,O),hasPlugin:Y.has,locate:b.locate,safeArea:()=>J.current(),setSafeArea(E){J.set(E),R==null||R.setSafeArea(J.current())},remeasure:h.remeasure,emitAppEvent:z.emit,destroy(){var E;C||(C=!0,c.cancelAnimationFrame(k),b.dispose(),R==null||R.destroy(),y.dispose(),G.dispose(),j.dispose(),z.dispose(),an(),J.destroy(),(E=v==null?void 0:v._dispose)==null||E.call(v),u==null||u.destroy(),d==null||d.destroy(),h.destroy())}}},Ti=(n,t)=>new Promise(e=>{const s=n.ownerDocument.defaultView??window;s.requestAnimationFrame(()=>{try{const r=[...n.querySelectorAll("canvas")].filter(l=>l.width>0&&l.height>0&&s.getComputedStyle(l).display!=="none");if(r.length===0){e(null);return}const i=n.getBoundingClientRect(),o=t??Math.max(...r.map(l=>l.width))/Math.max(1,i.width),a=n.ownerDocument.createElement("canvas");a.width=Math.max(1,Math.round(i.width*o)),a.height=Math.max(1,Math.round(i.height*o));const h=a.getContext("2d");if(!h){e(null);return}h.fillStyle="#000000",h.fillRect(0,0,a.width,a.height);for(const l of r)h.drawImage(l,0,0,l.width,l.height,0,0,a.width,a.height);e(a.toDataURL("image/png"))}catch{e(null)}})}),ki=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)}},Ri=(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 h={};try{h=JSON.parse(String(a.data))}catch{return}h.type==="reload"&&typeof h.v=="number"&&t(h.v)},o.onclose=()=>{setTimeout(i,2e3)}};return i(),{bundleUrl:o=>`${n}/bundle.js?t=web&v=${o}`,versionOf(o,a){const h=Number(o.headers.get("x-lecodes-v"));return o.headers.has("x-lecodes-v")&&Number.isFinite(h)?h:a},ran(o){s=o},log:(o,a)=>e({type:"log",level:o,text:a.map(ki).join(" ")}),error:o=>e({type:"error",text:o})}},Ai={camera:()=>q(()=>import("./assets/camera-5XOM8eHl.js"),[],import.meta.url).then(n=>t=>n.register(t)),geolocation:()=>q(()=>import("./assets/geolocation-BjTKN9_P.js"),[],import.meta.url).then(n=>t=>n.register(t)),map:()=>q(()=>import("./assets/map-XzoOFt0E.js").then(n=>n.m),[],import.meta.url).then(n=>t=>n.register(t,()=>q(()=>import("./assets/map-CyBxOSV0.js"),[],import.meta.url).then(e=>e.resources))),"qr-scanner":()=>q(()=>import("./assets/qr-scanner-CK_cYoJR.js"),[],import.meta.url).then(n=>t=>n.register(t))},Mi=async(n,t)=>{await Promise.all([...t].map(async e=>{const s=Ai[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)}`)}}))},le=n=>typeof n=="object"&&n!==null,gt=n=>typeof n=="number"&&Number.isFinite(n),Li=n=>{if(!le(n))return null;switch(n.ask){case"tree":return{ask:"tree"};case"text":return{ask:"text"};case"at":return gt(n.x)&&gt(n.y)?{ask:"at",x:n.x,y:n.y}:null;case"node":return gt(n.node)?{ask:"node",node:n.node}:null;default:return null}},wn=n=>{if(!le(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}:{}}},Pi=n=>{const t=n.get("safe-area");if(!t)return null;const[e,s,r,i]=t.split(",").map(Number);return wn({top:e,right:s,bottom:r,left:i,bars:(n.get("bars")??"").split(",")})},Ci=n=>{if(!le(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:wn(n.insets)};case"lecodes:language":return typeof n.language=="string"&&n.language?{type:"lecodes:language",language:n.language}:null;case"lecodes:inspect":{const t=Li(n.question);return t&&gt(n.request)?{type:"lecodes:inspect",request:n.request,question:t}:null}case"lecodes:capture":{if(!gt(n.request))return null;const t=gt(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}},Oi=(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}},Ii=(n,t)=>{const e=n.parent!==n?n.parent:null,s=r=>{if(!e||r.source!==e)return;const i=Ci(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)}}},he=window.lecodesPlayerConfig??{},mt=document.getElementById("app"),Xt=document.getElementById("loader"),$e=document.getElementById("error"),at=new URLSearchParams(location.search),bn=n=>Xt==null?void 0:Xt.classList.toggle("on",n),vn=n=>{$e&&($e.textContent=window.parent===window?n:"")};let se=he.language||at.get("lang")||(navigator.language||"en").slice(0,2),Lt=he.safeArea??Pi(at),W=null;const Ge=()=>{var n;return(n=W==null?void 0:W.world)==null?void 0:n._creatorTree},Pt=at.has("test")?{ready:!1,dump:()=>{var n;return((n=Ge())==null?void 0:n.debugDump())??'{"roots":[]}'},rect:n=>{var s;const t=(s=Ge())==null?void 0:s.getBoundingClientRect(n);if(!t)return null;const e=mt.getBoundingClientRect();return[e.left+t[0],e.top+t[1],t[2],t[3]]}}:null;Pt&&(window.lecodesTest=Pt);const Fi=at.has("inspect"),ie=Fi?q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url):null;let pt=null;const Ni=async(n,t)=>{const{createInspector:e}=await(ie??q(()=>import("./assets/inspect-DdJ50Kun.js"),[],import.meta.url));W&&pt===null&&(pt=e(W)),nt.post({type:"lecodes:inspected",request:n,answer:(pt==null?void 0:pt.answer(t))??null})},je=at.has("dev")?new URL(at.get("dev")||"..",location.href).href.replace(/\/$/,""):null,Ve=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}`},xn=n=>{vn(Ve(n)),nt.post({type:"lecodes:error",error:n}),V==null||V.error(Ve(n))},Sn=n=>xn({message:n,frames:[]});let it=null,Yt=!1,Kt=null;const Ni=async n=>{bn(!0),vn(""),W==null||W.destroy(),W=null,pt=null,mt.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=yn(e);W=await Ei(mt,{header:s,language:()=>se,launchUrl:location.href,...Lt?{safeArea:Lt}:{},...nt.embedded?{onOrientation:r=>nt.post({type:"lecodes:orientation",mode:r})}:{}}),await Ai(W,s.plugins),ie&&(await ie).recordSites(W),W.run(e,{onError:xn}),Pt&&(Pt.ready=!0),V&&n.version!==void 0&&(Ct=V.versionOf(t,n.version),V.ran(Ct)),nt.post({type:"lecodes:ready",src:n.src})},ct=n=>{if(Yt){Kt=n;return}Yt=!0,it=n,Ni(n).catch(t=>Sn(t instanceof Error?t.message:String(t))).finally(()=>{bn(!1),Yt=!1;const t=Kt;Kt=null,t&&ct(t)})},ue=n=>{const t=Ci(n,location.href);t?ct({src:t}):Sn(`The player runs bundles of its own origin only: ${n}`)},En=n=>{Lt=n,W==null||W.setSafeArea(Lt)},_n=async n=>({image:W?await _i(mt,n):null,width:mt.clientWidth,height:mt.clientHeight}),nt=Oi(window,n=>{switch(n.type){case"lecodes:run":ue(n.src);break;case"lecodes:reload":it&&ct(it);break;case"lecodes:safe-area":En(n.insets);break;case"lecodes:inspect":Fi(n.request,n.question);break;case"lecodes:capture":_n(n.pixelRatio).then(t=>nt.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===se)break;se=n.language,it&&ct(it);break}});let Ct=-1;const V=je?ki(je,n=>{Ct>=0&&n!==Ct&&ct({src:V.bundleUrl(n),version:n})}):null;if(V||nt.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{V==null||V.log(t,s),nt.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:"8895e4e-2026-10-04",get host(){return W},run:ue,reload(){it&&ct(it)},setSafeArea:En,capture:async n=>(await _n(n)).image};const ze=he.src??at.get("src");V?ct({src:V.bundleUrl(0),version:0}):ze&&ue(ze);export{q as _};
21
+ in ${n.nativeFrames[0]}`:"";return`${n.detail?`${n.message}: ${n.detail}`:n.message}${e}`},xn=n=>{vn(Ve(n)),nt.post({type:"lecodes:error",error:n}),V==null||V.error(Ve(n))},Sn=n=>xn({message:n,frames:[]});let it=null,Yt=!1,Kt=null;const Ui=async n=>{bn(!0),vn(""),W==null||W.destroy(),W=null,pt=null,mt.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=yn(e);W=await _i(mt,{header:s,language:()=>se,launchUrl:location.href,...Lt?{safeArea:Lt}:{},...nt.embedded?{onOrientation:r=>nt.post({type:"lecodes:orientation",mode:r})}:{}}),await Mi(W,s.plugins),ie&&(await ie).recordSites(W),W.run(e,{onError:xn}),Pt&&(Pt.ready=!0),V&&n.version!==void 0&&(Ct=V.versionOf(t,n.version),V.ran(Ct)),nt.post({type:"lecodes:ready",src:n.src})},ct=n=>{if(Yt){Kt=n;return}Yt=!0,it=n,Ui(n).catch(t=>Sn(t instanceof Error?t.message:String(t))).finally(()=>{bn(!1),Yt=!1;const t=Kt;Kt=null,t&&ct(t)})},ue=n=>{const t=Oi(n,location.href);t?ct({src:t}):Sn(`The player runs bundles of its own origin only: ${n}`)},En=n=>{Lt=n,W==null||W.setSafeArea(Lt)},_n=async n=>({image:W?await Ti(mt,n):null,width:mt.clientWidth,height:mt.clientHeight}),nt=Ii(window,n=>{switch(n.type){case"lecodes:run":ue(n.src);break;case"lecodes:reload":it&&ct(it);break;case"lecodes:safe-area":En(n.insets);break;case"lecodes:inspect":Ni(n.request,n.question);break;case"lecodes:capture":_n(n.pixelRatio).then(t=>nt.post({type:"lecodes:captured",request:n.request,...t}));break;case"lecodes:language":if(n.language===se)break;se=n.language,it&&ct(it);break}});let Ct=-1;const V=je?Ri(je,n=>{Ct>=0&&n!==Ct&&ct({src:V.bundleUrl(n),version:n})}):null;if(V||nt.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{V==null||V.log(t,s),nt.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:"3caa7cd-2026-10-06",get host(){return W},run:ue,reload(){it&&ct(it)},setSafeArea:En,capture:async n=>(await _n(n)).image};const ze=he.src??at.get("src");V?ct({src:V.bundleUrl(0),version:0}):ze&&ue(ze);export{q as _};
@@ -0,0 +1 @@
1
+ import{u as W,w as B}from"../lite.js";const F=(m,c)=>{let d=[],l=[];const r=new Map,f=new Map,a=new Set;let e=[0],o=0,t=0,i=0,y=0,w=!0,O=!1,v=!1,p=!1,M=!1,K=!0;const I=n=>f.get(d[n])??l[n],E=n=>{o=Math.min(o,n)},N=()=>{const n=d.length;e.length=n+1,o>n&&(o=n),o===0&&(e[0]=0);for(let s=o;s<n;s++)e[s+1]=e[s]+I(s);o=n},L=()=>(N(),e[d.length]??0),k=n=>{for(let s=n;s<d.length;s++)r.set(d[s],s)},C=()=>m.inverted?Math.max(0,y-L()):0,_=()=>Math.max(0,L()-y),R=()=>{N();const n=d.length;if(n===0||y<=0)return[-1,-2];const s=m.overscan<0?y:m.overscan,u=t-s,h=t+y+s;let T=0,g=n;for(;T<g;){const S=T+g>>1;e[S+1]>u?g=S:T=S+1}const x=Math.min(T,n-1);for(T=0,g=n;T<g;){const S=T+g>>1;e[S]<h?T=S+1:g=S}return[Math.max(x,0),Math.min(T-1,n-1)]},H=()=>{m.endThreshold>0&&(L()-(t+y)<=m.endThreshold?O||(O=!0,c.edge(!0)):O=!1),m.startThreshold>0&&(t<=m.startThreshold?v||(v=!0,c.edge(!1)):v=!1)},z=()=>{if(p){M=!0;return}p=!0;try{for(let n=0;n<4;n++){M=!1;const[s,u]=R(),h=[],T=[];for(const g of a){const x=r.get(g);(x===void 0||x<s||x>u)&&h.push(g)}for(let g=s;g<=u;g++)a.has(d[g])||T.push(d[g]);if(h.length===0&&T.length===0||(c.sync(h,T),!M))break}}finally{p=!1}},b=n=>{t=Math.max(0,Math.min(n,_())),c.adjust(t)},D=(n,s,u)=>{const h=I(s);if(f.set(n,u),Math.abs(u-h)<=.5)return;N();const T=e[s];E(s),T<t?b(t+(u-h)):m.inverted&&w&&b(_()),M=!0};return{setKeys(n,s){d=n.slice(),l=d.map((u,h)=>s[h]??0),r.clear(),k(0),E(0),b(t),z(),H()},insertKeys(n,s,u){if(s.length===0)return;const h=d.length;(n<0||n>h)&&(n=h);const T=h>0,g=n===h;let x=0;s.forEach((V,A)=>{x+=f.get(V)??u[A]??0}),d.splice(n,0,...s),l.splice(n,0,...s.map((V,A)=>u[A]??0)),k(n),E(n);const S=w;N(),T&&!g&&e[n]<=t+.5&&b(t+x),m.inverted&&S&&g&&(b(_()),w=!0),z(),H()},removeKeys(n){let s=0;N();for(const u of n){const h=r.get(u);h!==void 0&&(e[h+1]<=t&&(s+=I(h)),d.splice(h,1),l.splice(h,1),r.delete(u),f.delete(u),k(h),E(h),N())}b(s>0?t-s:t),z(),H()},invalidate(n){if(!(!a.has(n)||p)){p=!0;try{c.sync([n],[n])}finally{p=!1}M&&(M=!1,z())}},mounted(n,s){const u=r.get(n);u!==void 0&&(a.add(n),D(n,u,s))},unmounted(n){a.delete(n)},isMounted:n=>a.has(n),resized(n,s){const u=r.get(n);u===void 0||!a.has(n)||(D(n,u,s),M&&!p&&(M=!1,z()))},scrolled(n){t=Math.max(0,n),w=t+y>=L()-2,z(),H()},viewport(n,s,u){if(!(n>0)||!(s>0))return;const h=Math.abs(n-i)>.5,T=Math.abs(s-y)>.5;if(i=n,y=s,L()<=y&&(w=!0),h){E(0);for(const g of a)f.set(g,u(g))}K?(K=!1,m.inverted&&(b(_()),w=!0)):m.inverted&&w&&T?b(_()):h&&b(t),z()},offsetOf(n){const s=r.get(n);return s===void 0?NaN:(N(),C()+e[s])},mountedTop(){let n=-1;for(const s of a){const u=r.get(s);u!==void 0&&(n<0||u<n)&&(n=u)}return N(),C()+(n<0?0:e[n])},indexOf:n=>r.get(n)??-1,contentHeight:()=>m.inverted?Math.max(L(),y):L(),maxScroll:_,scrollY:()=>t,mountedKeys:()=>[...a]}},$=m=>{const c=new Map,d=new Map,l=e=>{e.content.style.minHeight=`${e.window.contentHeight()}px`,e.content.style.paddingTop=`${e.window.mountedTop()}px`},r=(e,o)=>{const t=e.items.get(o);e.window.unmounted(o),t&&(e.items.delete(o),e.keyOf.delete(t),d.delete(t),e.sizes.unobserve(t.el),t.el.remove(),m.rootOwned(t,!1))},f=(e,o,t)=>{if(Number.isNaN(o))return;l(e);const i=Math.max(0,Math.min(o,e.window.maxScroll()));e.node.el.scrollTo({top:i,behavior:t?"smooth":"instant"})},a=e=>{for(const o of[...e.items.keys()])r(e,o);e.sizes.disconnect(),e.node.el.removeEventListener("scroll",e.onScroll),e.content.remove(),c.delete(e.node)};return{init(e,o,t,i,y){if(c.has(e))return;const w=e.el,O=w.ownerDocument.createElement("div");O.className="lc-vlist-content",w.appendChild(O);const v={node:e,content:O,items:new Map,keyOf:new Map,onScroll:()=>{v.window.scrolled(w.scrollTop),l(v)}};v.window=F({overscan:o,inverted:t,startThreshold:i,endThreshold:y},{sync(p,M){for(const K of p)r(v,K);m.emit(e.id,B,p,M),l(v)},adjust(p){l(v),Math.abs(w.scrollTop-p)>=.5&&(w.scrollTop=p)},edge:p=>{m.emitLater(e.id,W,p)}}),v.sizes=new ResizeObserver(p=>{for(const M of p){const K=M.target;if(K===w){v.window.viewport(w.clientWidth,w.clientHeight,I=>{var E;return((E=v.items.get(I))==null?void 0:E.el.offsetHeight)??0});continue}for(const[I,E]of v.keyOf)if(I.el===K){v.window.resized(E,K.offsetHeight);break}}l(v)}),v.sizes.observe(w),w.addEventListener("scroll",v.onScroll,{passive:!0}),c.set(e,v)},setKeys(e,o,t){const i=c.get(e);i&&(i.window.setKeys(o,Array.from(t)),l(i))},insertKeys(e,o,t,i){const y=c.get(e);y&&(y.window.insertKeys(o,t,Array.from(i)),l(y))},removeKeys(e,o){const t=c.get(e);t&&(t.window.removeKeys(o),l(t))},invalidate(e,o){const t=c.get(e);t&&(t.window.invalidate(o),l(t))},mount(e,o,t){const i=c.get(e);if(!i||!t)return;if(t.parent!==null||t.rooted){m.warn(`vlist: the item for key '${o}' is attached elsewhere`);return}const y=i.window.indexOf(o);if(y<0)return;i.items.has(o)&&r(i,o);let w=null,O=1/0;for(const[v,p]of i.items){const M=i.window.indexOf(v);M>y&&M<O&&(w=p,O=M)}i.items.set(o,t),i.keyOf.set(t,o),d.set(t,i),m.rootOwned(t,!0),i.content.insertBefore(t.el,(w==null?void 0:w.el)??null),m.flush(),i.sizes.observe(t.el),i.window.mounted(o,t.el.offsetHeight)},scrollTo(e,o,t){const i=c.get(e);i&&f(i,o,t)},scrollToKey(e,o,t){const i=c.get(e);i&&f(i,i.window.offsetOf(o),t)},scrollToEnd(e,o){const t=c.get(e);t&&f(t,t.window.maxScroll(),o)},mounted(e){const o=c.get(e);return o?[...o.items.values()].sort((t,i)=>t.el.compareDocumentPosition(i.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1):null},ownerOf:e=>{var o;return((o=d.get(e))==null?void 0:o.node)??null},forget(e){const o=c.get(e);o&&a(o);const t=d.get(e),i=t==null?void 0:t.keyOf.get(e);t&&i!==void 0&&(t.window.unmounted(i),t.items.delete(i),t.keyOf.delete(e),t.sizes.unobserve(e.el),d.delete(e))},destroy(){for(const e of c.values())e.sizes.disconnect(),e.content.remove();c.clear(),d.clear()}}},G={name:"vlist",install(m){const c=$({emit:m.emit,emitLater:m.emitLater,warn:m.warn,rootOwned:m.rootOwned,flush:m.flush}),d=l=>{const r=m.node(l);return(r==null?void 0:r.type)==="vlist"?r:void 0};return{bridge:{vlistInit(l,r,f,a,e){const o=d(l);o&&c.init(o,r,f,a,e)},vlistSetKeys(l,r,f){const a=d(l);a&&c.setKeys(a,r,f)},vlistInsertKeys(l,r,f,a){const e=d(l);e&&c.insertKeys(e,r,f,a)},vlistRemoveKeys(l,r){const f=d(l);f&&c.removeKeys(f,r)},vlistInvalidate(l,r){const f=d(l);f&&c.invalidate(f,r)},vlistMount(l,r,f){const a=d(l);a&&c.mount(a,r,m.node(f))},vlistScrollTo(l,r,f){const a=d(l);a&&c.scrollTo(a,r,f)},vlistScrollToKey(l,r,f){const a=d(l);a&&c.scrollToKey(a,r,f)},vlistScrollToEnd(l,r){const f=d(l);f&&c.scrollToEnd(f,r)}},forget:c.forget,destroy:c.destroy,dump(l,r,f){const a=c.mounted(l);a&&(r.items=a.map(f))}}}};export{$ as createVLists,G as vlist};
@@ -78,7 +78,7 @@
78
78
  "vlistInit"
79
79
  ],
80
80
  "files": [
81
- "assets/vlist-DrV2Q7P5.js"
81
+ "assets/vlist-CwSYpLz-.js"
82
82
  ]
83
83
  },
84
84
  {