@layoutit/polycss 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{PolyShapeElements-BNHvErQF.d.cts → PolyShapeElements-CoKhApyN.d.cts} +5 -0
- package/dist/{PolyShapeElements-BNHvErQF.d.ts → PolyShapeElements-CoKhApyN.d.ts} +5 -0
- package/dist/elements.cjs +2 -2
- package/dist/elements.d.cts +1 -1
- package/dist/elements.d.ts +1 -1
- package/dist/elements.js +2 -2
- package/dist/index.cjs +13 -13
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/package.json +2 -2
package/dist/elements.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var yo=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var cs=Object.prototype.hasOwnProperty;var ds=(e,n)=>{for(var t in n)yo(e,t,{get:n[t],enumerable:!0})},us=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ls(n))!cs.call(e,r)&&r!==t&&yo(e,r,{get:()=>n[r],enumerable:!(o=as(n,r))||o.enumerable});return e};var ps=e=>us(yo({},"__esModule",{value:!0}),e);var Bl={};ds(Bl,{PolyAxesHelperElement:()=>dn,PolyBoxElement:()=>xn,PolyCameraElement:()=>yn,PolyConeElement:()=>Ln,PolyCylinderElement:()=>wn,PolyDirectionalLightHelperElement:()=>un,PolyDodecahedronElement:()=>An,PolyFirstPersonControlsElement:()=>hn,PolyIcosahedronElement:()=>Tn,PolyIframeElement:()=>ln,PolyMapControlsElement:()=>fn,PolyMeshElement:()=>xt,PolyOctahedronElement:()=>Cn,PolyOrbitControlsElement:()=>mn,PolyOrthographicCameraElement:()=>Pt,PolyPerspectiveCameraElement:()=>gn,PolyPlaneElement:()=>Pn,PolyPolygonElement:()=>cn,PolyRingElement:()=>Sn,PolySceneElement:()=>_e,PolySelectElement:()=>vn,PolySphereElement:()=>Mn,PolyTetrahedronElement:()=>En,PolyTorusElement:()=>_n,PolyTransformControlsElement:()=>bn});module.exports=ps(Bl);var ne=require("@layoutit/polycss-core");var or=require("@layoutit/polycss-core");function ms(e){if(!e)return!1;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return t?t("(pointer: coarse)").matches||t("(hover: none)").matches:!1}function Qt(e,n,t){return(0,or.packTextureAtlasPlansWithScaleCore)(e,n,ms(t))}var It=require("@layoutit/polycss-core");var rt=require("@layoutit/polycss-core"),cr=require("@layoutit/polycss-core"),dr=require("@layoutit/polycss-core"),Tt=new Map;function fs(e){let n=Tt.get(e);return n||(n=new Promise((t,o)=>{let r=new Image;r.decoding="async",r.crossOrigin="anonymous",r.onload=()=>t(r),r.onerror=()=>o(new Error(`texture load failed: ${e}`)),r.src=e}),Tt.set(e,n),n.then(()=>{Tt.get(e)===n&&Tt.delete(e)},()=>{Tt.get(e)===n&&Tt.delete(e)})),n}function Ie(e,n,t=1,o=0,r=0,i=1,s=0,c=0){e.setTransform(t*n,o*n,r*n,i*n,s*n,c*n)}function bo(e){let n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function vo(e){let n=e<=.0031308?e*12.92:1.055*Math.pow(e,.4166666666666667)-.055;return Math.max(0,Math.min(255,Math.round(n*255)))}function hs(e,n,t,o,r,i,s){let c=Math.round(n*s),l=Math.round(t*s),p=Math.max(1,Math.round(o*s)),g=Math.max(1,Math.round(r*s)),x=e.getImageData(c,l,p,g),f=x.data,b=i.r,y=i.g,P=i.b;for(let v=0;v<f.length;v+=4)f[v+3]!==0&&(f[v]=vo(bo(f[v])*b),f[v+1]=vo(bo(f[v+1])*y),f[v+2]=vo(bo(f[v+2])*P));e.putImageData(x,c,l)}function gs(e,n,t,o,r,i,s){let c=n.naturalWidth||n.width||1,l=n.naturalHeight||n.height||1,p=Math.max(r/c,i/l),g=c*p,x=l*p;Ie(e,s),e.drawImage(n,t+(r-g)/2,o+(i-x)/2,g,x)}function At(e,n){return Math.max(0,Math.min(n,e))}function rr(e,n,t,o,r,i,s,c){let l=n.naturalWidth||n.width||1,p=n.naturalHeight||n.height||1,g=At(Math.min(t.minU,t.maxU)*l,l),x=At(Math.max(t.minU,t.maxU)*l,l),f=At(Math.min(t.minV,t.maxV)*p,p),b=At(Math.max(t.minV,t.maxV)*p,p),y=Math.floor(g),P=Math.floor(f),v=Math.ceil(x)-y,C=Math.ceil(b)-P;v<1&&(y=Math.floor(At((t.minU+t.maxU)/2*l,l-1)),v=1),C<1&&(P=Math.floor(At((t.minV+t.maxV)/2*p,p-1)),C=1),y=Math.max(0,Math.min(l-1,y)),P=Math.max(0,Math.min(p-1,P)),v=Math.max(1,Math.min(l-y,v)),C=Math.max(1,Math.min(p-P,C)),Ie(e,c),e.drawImage(n,y,P,v,C,o,r,i,s)}function ur(e){return e==="repeat"||e==="mirrored-repeat"}function ir(e,n){return ur(e)?Math.floor(n):0}function sr(e,n){return ur(e)?Math.ceil(n)-1:0}function ar(e,n){return e==="mirrored-repeat"&&Math.abs(n%2)===1}function lr(e,n,t,o,r,i,s){let c=r?ir(i,r.minU):0,l=r?sr(i,r.maxU):0,p=r?ir(s,r.minV):0,g=r?sr(s,r.maxV):0;for(let x=c;x<=l;x++)for(let f=p;f<=g;f++){let b=ar(i,x),y=ar(s,f);if(!b&&!y){e.drawImage(n,x*t,f*o);continue}e.save(),e.translate((b?x+1:x)*t,(y?f+1:f)*o),e.scale(b?-1:1,y?-1:1),e.drawImage(n,0,0),e.restore()}}function xo(e,n,t,o){for(let r=0;r<o.length;r+=2){let i=n+o[r],s=t+o[r+1];r===0?e.moveTo(i,s):e.lineTo(i,s)}e.closePath()}function Dn(e,n,t,o,r,i){for(let s=0;s<o.length;s+=2){let c=n+o[s]+r,l=t+o[s+1]+i;s===0?e.moveTo(c,l):e.lineTo(c,l)}e.closePath()}function ys(e,n,t,o){Ie(e,o),e.beginPath(),xo(e,n.x,n.y,n.screenPts),e.clip(),Ie(e,o),e.fillStyle=t==="dynamic"?n.polygon.color??"#cccccc":n.shadedColor,e.fillRect(n.x,n.y,n.canvasW,n.canvasH)}function On(e,n,t,o,r){n.polygon.textureAlphaMode==="opaque"&&(Ie(e,t),e.fillStyle=n.polygon.color??"#cccccc",e.fillRect(n.x+o,n.y+r,n.canvasW,n.canvasH))}function bs(e,n,t,o,r=0,i=0){if(n.textureTriangles?.length){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1;for(let l of n.textureTriangles){let p=(0,cr.expandClipPoints)(l.screenPts,rt.TEXTURE_TRIANGLE_BLEED*(n.bleedRatio??1));e.save(),Ie(e,o),e.beginPath(),Dn(e,n.x,n.y,p,r,i),e.clip(),On(e,n,o,r,i),l.uvAffine?(Ie(e,o,l.uvAffine.a/s,l.uvAffine.c/s,l.uvAffine.b/c,l.uvAffine.d/c,n.x+l.uvAffine.e+r,n.y+l.uvAffine.f+i),lr(e,t,s,c,l.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t)):l.uvSampleRect&&rr(e,t,l.uvSampleRect,n.x+r,n.y+i,n.canvasW,n.canvasH,o),e.restore()}}else if(n.uvAffine){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1,l=n.polygon.textureAlphaMode==="opaque";l&&(e.save(),Ie(e,o),e.beginPath(),Dn(e,n.x,n.y,n.screenPts,r,i),e.clip(),On(e,n,o,r,i)),Ie(e,o,n.uvAffine.a/s,n.uvAffine.c/s,n.uvAffine.b/c,n.uvAffine.d/c,n.x+n.uvAffine.e+r,n.y+n.uvAffine.f+i),lr(e,t,s,c,n.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t),l&&e.restore()}else if(n.uvSampleRect){let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Ie(e,o),e.beginPath(),Dn(e,n.x,n.y,n.screenPts,r,i),e.clip(),On(e,n,o,r,i)),rr(e,t,n.uvSampleRect,n.x+r,n.y+i,n.canvasW,n.canvasH,o),s&&e.restore()}else{let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Ie(e,o),e.beginPath(),Dn(e,n.x,n.y,n.screenPts,r,i),e.clip(),On(e,n,o,r,i)),gs(e,t,n.x+r,n.y+i,n.canvasW,n.canvasH,o),s&&e.restore()}}function vs(e,n,t,o,r,i){let s=r-t,c=i-o,l=s*s+c*c;if(l<=dr.BASIS_EPS)return Math.hypot(e-t,n-o);let p=Math.max(0,Math.min(1,((e-t)*s+(n-o)*c)/l));return Math.hypot(e-(t+s*p),n-(o+c*p))}function xs(e,n,t,o){let r=1/0,i=t.length/2;for(let s of o){if(s<0||s>=i)continue;let c=s*2,l=(s+1)%i*2;r=Math.min(r,vs(e,n,t[c],t[c+1],t[l],t[l+1]))}return r}function Ps(e,n,t,o,r,i){let s=Math.max(0,o-i),c=Math.min(n-1,o+i),l=Math.max(0,r-i),p=Math.min(t-1,r+i),g=null,x=1/0;for(let f=l;f<=p;f++)for(let b=s;b<=c;b++){if(b===o&&f===r)continue;let y=b-o,P=f-r,v=y*y+P*P;if(v>i*i||v>=x)continue;let C=(f*n+b)*4;e[C+3]<rt.TEXTURE_EDGE_REPAIR_SOURCE_ALPHA_MIN||(g=C,x=v)}return g}function Ss(e,n,t){if(!n.textureEdgeRepair||!n.texture||!n.textureEdgeRepairEdges||n.textureEdgeRepairEdges.size===0)return;let o=e.canvas;if(!o)return;let r=Math.max(0,Math.floor(n.x*t)),i=Math.max(0,Math.floor(n.y*t)),s=Math.max(1,Math.min(o.width-r,Math.ceil(n.canvasW*t))),c=Math.max(1,Math.min(o.height-i,Math.ceil(n.canvasH*t)));if(s<=0||c<=0)return;let l;try{l=e.getImageData(r,i,s,c)}catch{return}let p=l.data,g=new Uint8ClampedArray(p),x=Math.max(rt.TEXTURE_EDGE_REPAIR_RADIUS,rt.TEXTURE_EDGE_REPAIR_RADIUS/t),f=Math.max(2,Math.ceil(x*t)+1),b=!1;for(let y=0;y<c;y++)for(let P=0;P<s;P++){let v=(y*s+P)*4,C=p[v+3];if(C<rt.TEXTURE_EDGE_REPAIR_ALPHA_MIN||C===255)continue;let F=(r+P+.5)/t-n.x,k=(i+y+.5)/t-n.y;if(xs(F,k,n.screenPts,n.textureEdgeRepairEdges)>x)continue;let z=Ps(g,s,c,P,y,f);z!==null&&(p[v]=g[z],p[v+1]=g[z+1],p[v+2]=g[z+2],p[v+3]=255,b=!0)}b&&e.putImageData(l,r,i)}function Cs(e){if(typeof e.toBlob=="function")return new Promise(n=>{e.toBlob(t=>{n(t?URL.createObjectURL(t):null)},"image/png")});try{return Promise.resolve(e.toDataURL("image/png"))}catch{return Promise.resolve(null)}}async function Es(e,n,t,o){let r=t.createElement("canvas");r.width=Math.max(1,Math.ceil(e.width*o)),r.height=Math.max(1,Math.ceil(e.height*o));let i=e.entries.some(g=>g.textureEdgeRepair&&g.texture&&g.textureEdgeRepairEdges&&g.textureEdgeRepairEdges.size>0),s=r.getContext("2d",i?{willReadFrequently:!0}:void 0);if(!s)return{width:e.width,height:e.height,url:null};let c=Array.from(new Set(e.entries.flatMap(g=>g.texture?[g.texture]:[]))),l=new Map;await Promise.all(c.map(async g=>{l.set(g,await fs(g))}));for(let g of e.entries){let x=g.texture?l.get(g.texture):null;if(!g.texture){s.save(),ys(s,g,n,o),s.restore();continue}x&&(s.save(),Ie(s,o),s.beginPath(),xo(s,g.x,g.y,g.screenPts),s.clip(),bs(s,g,x,o),s.restore()),g.texture&&n==="baked"&&(s.save(),Ie(s,o),s.beginPath(),xo(s,g.x,g.y,g.screenPts),s.clip(),hs(s,g.x,g.y,g.canvasW,g.canvasH,g.textureTint,o),s.restore()),Ss(s,g,o)}let p=await Cs(r);return r.width=1,r.height=1,{width:e.width,height:e.height,url:p}}async function qt(e,n,t,o,r){let i=[];for(let s of e){if(r())break;i.push(await Es(s,n,t,o))}return i}var J=require("@layoutit/polycss-core"),Hn=require("@layoutit/polycss-core"),mr=require("@layoutit/polycss-core");var pr=require("@layoutit/polycss-core");function Mt(e,n){let o=e?.defaultView?.__polycssProjectiveQuadGuards,r=n&&o?{...n,...o}:o??n;return(0,pr.resolveProjectiveQuadGuards)(r)}function Kt(e){if(!!!(e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0))?.supports?.("border-shape","polygon(0 0, 100% 0, 0 100%) circle(0)"))return!1;let r=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return r?r("(pointer: fine)").matches&&r("(hover: hover)").matches:!0}function fr(e){if(hr(e))return!0;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,J.safariCssProjectiveUnsupported)(t):!0}function Jt(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")&&!!n.supports("corner-bottom-right-shape","bevel")&&!!n.supports("corner-bottom-left-shape","bevel")}function hr(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")}function Ts(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return/\bFirefox\//.test(t)}function Je(e,n){return n?.disable?.includes("u")?null:hr(e)?"corner-bevel":fr(e)?Ts(e)?"border-large":"border":null}function en(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,J.safariCssProjectiveUnsupported)(t):!0}function In(e,n,t,o,r){let i=new Set(o?.disable??[]);return(0,J.getSolidPaintDefaultsForPlansCore)(e,n,i,{solidTriangleSupported:fr(t),projectiveQuadSupported:en(t),cornerShapeSupported:Jt(t),borderShapeSupported:Kt(t)},Hn.parseHex,Hn.rgbKey,r)}var Te=require("@layoutit/polycss-core"),Ue=require("@layoutit/polycss-core");var Dt=require("@layoutit/polycss-core");var st=require("@layoutit/polycss-core"),gr=require("@layoutit/polycss-core");var wt=require("@layoutit/polycss-core");function Ee(e,n,t){let o=e.getAttribute("style")??"",r=`${n}:${t}`,i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`(^|;)\\s*${i}\\s*:[^;]*`,"i"),c=s.test(o)?o.replace(s,(l,p)=>`${p}${r}`):`${o}${o.trim()&&!o.trim().endsWith(";")?";":""}${r}`;c!==o&&e.setAttribute("style",c)}function ct(e,n){let t=e.getAttribute("style")??"";if(!t||!t.toLowerCase().includes(n.toLowerCase()))return;let o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`^\\s*${o}\\s*:`,"i"),i=t.split(";").map(s=>s.trim()).filter(s=>s&&!r.test(s)).join(";");i?e.setAttribute("style",i):e.removeAttribute("style")}function tn(e,n,t,o=!1){if(n==="dynamic"){let r=(0,wt.parseHex)(e.polygon.color??"#cccccc"),i=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return(0,wt.rgbKey)(r)!==t?.dynamicColorKey&&(i+=`;--psr:${(r.r/255).toFixed(4)};--psg:${(r.g/255).toFixed(4)};--psb:${(r.b/255).toFixed(4)}`),i}return e.shadedColor?`;color:${e.shadedColor}`:""}function As(e,n){Ee(e,"--pnx",n.normal[0].toFixed(4)),Ee(e,"--pny",n.normal[1].toFixed(4)),Ee(e,"--pnz",n.normal[2].toFixed(4))}function Lt(e,n,t,o){if(t==="dynamic"){ct(e,"color"),ct(e,"background"),As(e,n);let r=(0,wt.parseHex)(n.polygon.color??"#cccccc");(0,wt.rgbKey)(r)===o?.dynamicColorKey?(ct(e,"--psr"),ct(e,"--psg"),ct(e,"--psb")):(Ee(e,"--psr",(r.r/255).toFixed(4)),Ee(e,"--psg",(r.g/255).toFixed(4)),Ee(e,"--psb",(r.b/255).toFixed(4)))}else n.shadedColor!==o?.paintColor?(ct(e,"background"),Ee(e,"color",n.shadedColor)):(ct(e,"background"),ct(e,"color"))}var _t=require("@layoutit/polycss-core"),it=require("@layoutit/polycss-core"),Fn=require("@layoutit/polycss-core"),ot=require("@layoutit/polycss-core"),yr="polycss-corner-shape-solid",Po=new WeakMap,So=new WeakMap;function Pe(e,n,t){let o=Po.get(e),r=So.get(e),i=typeof t=="number";if(!n.data&&!i&&(!o||o.length===0)){e.__polycssHasDataAttrs=!1;return}let s=new Map;if(n.data)for(let[l,p]of Object.entries(n.data))s.set(l,String(p));if(i&&s.set("poly-index",String(t)),o)for(let l of o)s.has(l)||e.removeAttribute(`data-${l}`);for(let[l,p]of s)r?.get(l)!==p&&e.setAttribute(`data-${l}`,p);let c=Array.from(s.keys());c.length>0?Po.set(e,c):Po.delete(e),s.size>0?So.set(e,s):So.delete(e),e.__polycssHasDataAttrs=c.length>0}function Rt(e){return e.__polycssHasDataAttrs===!0}function Co(e,n,t,o,r=t==="dynamic"){if(!n.url)return;let i=`url(${n.url})`,s=o.canvasW||1,c=o.canvasH||1,l=(0,it.atlasCanonicalSizeForEntry)(o),p=`${(0,st.formatCssLength)(-o.x/s*l)} ${(0,st.formatCssLength)(-o.y/c*l)}`,g=`${(0,st.formatCssLength)(n.width/s*l)} ${(0,st.formatCssLength)(n.height/c*l)}`,x=`transform:matrix3d(${o.atlasMatrix});--polycss-atlas-size:${l}px`,f=`${x};--polycss-atlas-position:${p};--polycss-atlas-image-size:${g}`;if(t==="dynamic"){let b=r?`;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`:"";e.setAttribute("style",f+`;--polycss-atlas-url:${i}`+b)}else e.setAttribute("style",x+`;background-image:${i};background-position:${p};background-size:${g};background-repeat:no-repeat;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`)}function br(e,n,t,o){if(n.texture){if(!t.texture||n.texture!==t.texture)return!1}else if(t.texture)return!1;let r=vr(n,t);return r?(e.style.visibility="",Ee(e,"transform",`matrix3d(${r.matrix})`),o==="dynamic"&&(Ee(e,"--pnx",r.normal[0].toFixed(4)),Ee(e,"--pny",r.normal[1].toFixed(4)),Ee(e,"--pnz",r.normal[2].toFixed(4))),Pe(e,t,n.index),!0):(e.style.visibility="hidden",Pe(e,t,n.index),!0)}function Eo(e,n,t,o,r){if(o!=="baked")return{...e,polygon:n,normal:t};let i=r.directionalLight,s=r.ambientLight,c=i?.direction??ot.DEFAULT_LIGHT_DIR,l=i?.color??ot.DEFAULT_LIGHT_COLOR,p=Math.max(0,i?.intensity??ot.DEFAULT_LIGHT_INTENSITY),g=s?.color??ot.DEFAULT_AMBIENT_COLOR,x=Math.max(0,s?.intensity??ot.DEFAULT_AMBIENT_INTENSITY),f=Math.hypot(c[0],c[1],c[2])||1,b=c[0]/f,y=c[1]/f,P=c[2]/f,C=r.lightOccludedPolyIndices?.has(e.index)??!1?0:p*Math.max(0,t[0]*b+t[1]*y+t[2]*P);return{...e,polygon:n,normal:t,shadedColor:(0,gr.shadePolygon)(n.color??"#cccccc",C,l,g,x)}}function vr(e,n){let t=xr(e,n);if(!t)return null;let{normal:o,xAxis:r,yAxis:i,tx:s,ty:c,tz:l}=t;return{normal:o,matrix:(0,st.formatMatrix3dValues)([r[0]*e.canvasW/(0,it.atlasCanonicalSizeForEntry)(e),r[1]*e.canvasW/(0,it.atlasCanonicalSizeForEntry)(e),r[2]*e.canvasW/(0,it.atlasCanonicalSizeForEntry)(e),0,i[0]*e.canvasH/(0,it.atlasCanonicalSizeForEntry)(e),i[1]*e.canvasH/(0,it.atlasCanonicalSizeForEntry)(e),i[2]*e.canvasH/(0,it.atlasCanonicalSizeForEntry)(e),0,o[0],o[1],o[2],0,s,c,l,1])}}var xr=Fn.stableBasisFromPlan;function Ms(e,n,t){if(e.screenPts.length!==8||n.vertices.length!==4)return null;let o=xr(e,n);if(!o)return null;let r=(0,Fn.computeProjectiveQuadMatrix)(e.screenPts,o.xAxis,o.yAxis,o.normal,o.tx,o.ty,o.tz,t);return r?{matrix:r,normal:o.normal}:null}function To(e,n,t,o,r=!1){let i=t.createElement("b");return i.setAttribute("style",`transform:matrix3d(${(0,st.formatSolidQuadMatrix)(e)})`+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function Ao(e,n,t,o,r=!1){let i=t.createElement("i");return i.setAttribute("style",(0,_t.formatBorderShapeElementStyle)(e)+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function Mo(e,n,t,o,r,i=!1){let s=o.createElement("u");return s.className=yr,s.setAttribute("style",(0,_t.formatCornerShapeElementStyle)(e,n)+tn(e,t,r,i)),Pe(s,e.polygon,e.index),s}function wo(e,n,t,o,r=!1){let i=t.createElement("b");return i.setAttribute("style",`transform:matrix3d(${e.projectiveMatrix})`+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function Pr(e,n,t,o,r,i,s){let c=n.projectiveMatrix?Ms(n,t,i):vr(n,t);if(!c)return!1;let l=Eo(n,t,c.normal,o,r);return e.style.visibility="",e.style.transform=`matrix3d(${c.matrix})`,Lt(e,l,o,s),Pe(e,l.polygon,l.index),!0}function Sr(e,n,t,o){e.style.visibility="",e.setAttribute("style",(0,_t.formatBorderShapeElementStyle)(n)),Lt(e,n,t,o),Pe(e,n.polygon,n.index)}function Cr(e,n,t,o,r){e.style.visibility="",e.className=yr,e.setAttribute("style",(0,_t.formatCornerShapeElementStyle)(n,t)),Lt(e,n,o,r),Ee(e,"background","currentColor"),Pe(e,n.polygon,n.index)}function Lo(e,n,t,o=!1){let r=t.createElement("s"),i=(0,it.atlasCanonicalSizeForEntry)(e),s=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return r.setAttribute("style",`transform:matrix3d(${e.atlasMatrix});--polycss-atlas-size:${i}px;opacity:0`+s),Pe(r,e.polygon,e.index),r}var Rr=require("@layoutit/polycss-core");var Vn=require("@layoutit/polycss-core");function gt(e,n,t,o={}){let r=o.primitive!=null?void 0:(()=>{let i=t.doc??(typeof document<"u"?document:null);return i?Je(i,t.strategies)??"border":"border"})();return(0,Vn.computeSolidTrianglePlan)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??r})}function _o(e,n,t,o,r,i,s,c,l,p,g,x,f){let b=o.primitive!=null?void 0:(()=>{let y=t.doc??(typeof document<"u"?document:null);return y?Je(y,t.strategies)??"border":"border"})();return(0,Vn.computeSolidTrianglePlanFromCssPoints)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??b},r,i,s,c,l,p,g,x,f)}var yt=require("@layoutit/polycss-core"),dt=require("@layoutit/polycss-core"),Er=require("@layoutit/polycss-core");var Ro=require("@layoutit/polycss-core");var ws="0 48px 96px 48px";function Tr(e,n){return(0,yt.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Ar(e,n,t){let o=(0,yt.resolveBleedRatio)(t.seamBleed),r=yt.DEFAULT_SEAM_BLEED*o,i={...t,bleedRatio:o};return n&&r>0?{...i,seamBleed:n.has(e)?r:void 0,seamEdges:n.get(e)}:i}function ko(e){return{updatesDisabled:e.stableTriangleColorFreezeFrames===0,freezeFrames:Math.max(1,Math.floor(e.stableTriangleColorFreezeFrames??1)),colorFrame:Math.max(0,Math.floor(e.stableTriangleColorFrame??0)),maxStep:Math.max(0,Math.floor(e.stableTriangleColorMaxStep??0))}}function Mr(e,n){return!n.updatesDisabled&&(n.freezeFrames<=1||(n.colorFrame+e)%n.freezeFrames===0)}function kt(e,n,t,o,r,i){return t?i.updatesDisabled||o==="plan-only"||o==="transform-only"?!1:r==="adaptive"||e.__polycssSolidTriangleColor===void 0?!0:Mr(n,i):!0}function Do(e,n){let t=e;t.__polycssSolidTrianglePrimitive!==n&&(n==="corner-bevel"?(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderWidth="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape")):(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape"),e.style.borderWidth=n==="border-large"?ws:""),t.__polycssSolidTrianglePrimitive=n)}function Oo(e){let n=e;n.__polycssSolidTriangleHidden&&(e.style.visibility="",n.__polycssSolidTriangleHidden=!1)}function nn(e){let n=e;n.__polycssSolidTriangleHidden||(e.style.visibility="hidden",n.__polycssSolidTriangleHidden=!0)}function Bn(e,n){e.setAttribute("style",n.styleText),Do(e,n.primitive);let t=e;t.__polycssSolidTriangleBasis=n.basis,t.__polycssSolidTriangleHidden=!1,n.colorComputed&&(t.__polycssSolidTriangleColor=n.bakedColor??"",t.__polycssSolidTriangleColorRgb=n.bakedRgb,t.__polycssSolidTriangleColorAlpha=n.bakedAlpha),t.__polycssSolidTriangleColorFrame=void 0,(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function wr(e,n,t,o){if(!n.colorComputed){(n.polygon.data||Rt(e))&&Pe(e,n.polygon);return}let r=e,i=n.bakedColor??"",s=n.bakedRgb,c=n.bakedAlpha??1,l=r.__polycssSolidTriangleColor,p=r.__polycssSolidTriangleColorRgb,g=r.__polycssSolidTriangleColorAlpha??1,x=o??Mr(n.index,t);if(!t.updatesDisabled&&l!==i&&(l===void 0||x)){let f=i,b=s;if(t.maxStep>0&&p&&s&&g===c){let y=(0,dt.stepRgbToward)(p,s,t.maxStep);b=y,f=(0,dt.rgbToCss)(y,c)}(f!==l||!(0,dt.rgbEqual)(b,p))&&(e.style.color=f),r.__polycssSolidTriangleColor=f,r.__polycssSolidTriangleColorRgb=b,r.__polycssSolidTriangleColorAlpha=c,r.__polycssSolidTriangleColorFrame=t.colorFrame}(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function zn(e,n,t,o){let r=e;Do(e,n.primitive),r.__polycssSolidTriangleBasis!==n.basis&&(r.__polycssSolidTriangleBasis=n.basis),Oo(e),e.style.transform=n.transformText,(n.colorComputed||n.polygon.data||Rt(e))&&wr(e,n,t,o)}function Ho(e,n,t,o){Oo(e),wr(e,n,t,o)}function Nn(e,n){let t=e;Do(e,n.primitive),t.__polycssSolidTriangleBasis!==n.basis&&(t.__polycssSolidTriangleBasis=n.basis),Oo(e),e.style.transform=n.transformText,(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function Ls(e,n){let t=n.stableTriangleColorBudget;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t<=1?Math.max(1,Math.ceil(e*t)):Math.max(1,Math.floor(t));let o=Math.max(1,Math.floor(n.stableTriangleColorFreezeFrames??1));return Math.max(1,Math.ceil(e/o))}function Lr(e,n,t){if(t.stableTriangleColorPolicy!=="adaptive")return null;if(t.stableTriangleColorFreezeFrames===0)return new Set;let o=Math.max(0,Math.floor(t.stableTriangleColorFrame??0)),r=Math.max(1,Math.floor(t.stableTriangleColorFreezeFrames??1));if(r<=1&&!Number.isFinite(t.stableTriangleColorBudget))return null;let i=Ls(e.length,t),s=Math.max(1,Math.floor(t.stableTriangleColorMaxAge??Math.max(2,r*2))),c=[];for(let l=0;l<e.length;l++){let p=e[l],g=n[l];if(p.kind!=="triangle"||!g)continue;let x=p.element,f=x.__polycssSolidTriangleColor,b=g.bakedColor??"";if(f===b)continue;let y=x.__polycssSolidTriangleColorFrame??0,P=Math.max(0,o-y),v=(0,dt.colorErrorScore)(f,b);c.push({index:l,score:(P>=s?1e6:0)+v*1e4+P})}return c.length===0?new Set:(c.sort((l,p)=>p.score-l.score),new Set(c.slice(0,i).map(l=>l.index)))}function Gn(e,n){let t=n.createElement("u");return Bn(t,e),Pe(t,e.polygon,e.index),t}function _s(e,n,t){let o=t.createElement("u");return nn(o),Pe(o,e,n),o}function _r(e,n,t,o,r,i){let s=t,c=s.stableTriangleDebug,l=o&&r==="color-only";if(s.stableTriangleColorPolicy==="adaptive"||e.length!==n.length)return!1;let p=(0,Ro.stableTriangleMatrixDecimals)(s.stableTriangleMatrixDecimals),g=t.doc??(typeof document<"u"?document:null),x=g?Je(g,t.strategies)??"border":"border";for(let b=0;b<e.length;b++){let y=e[b];if(y.kind!=="triangle"||y.polygonIndex!==b||!n[b])return!1}let f=Tr(n,t);for(let b=0;b<e.length;b++){let y=e[b].element,P=n[b];if(l){if(kt(y,b,o,c,s.stableTriangleColorPolicy,i)){let C=(0,Er.computeSolidTriangleColorPlan)(P,b,t);if(!C)continue;Ho(y,C,i)}continue}let v=gt(P,b,Ar(b,f,t),{basis:y.__polycssSolidTriangleBasis,matrixDecimals:p,primitive:x,includeColor:r!=="plan-only"&&r!=="transform-only"&&kt(y,b,o,c,s.stableTriangleColorPolicy,i)});if(!v){nn(y);continue}o&&r==="plan-only"||(o&&r==="transform-only"?Nn(y,v):o?zn(y,v,i):Bn(y,v))}return!0}function on(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=Je(t,n.strategies);if(!o||e.some(c=>c.texture||c.vertices.length!==3))return null;let r=(0,Ro.stableTriangleMatrixDecimals)(n.stableTriangleMatrixDecimals),i=[],s=Tr(e,n);for(let c=0;c<e.length;c+=1){let l=e[c],p=gt(l,c,Ar(c,s,n),{matrixDecimals:r,primitive:o}),g=p?Gn(p,t):_s(l,c,t);i.push({polygonIndex:c,element:g,kind:"triangle",dispose:()=>{}})}return{rendered:i,dispose(){}}}var Fo=require("@layoutit/polycss-core");function kr(){return new Promise(e=>setTimeout(e,0))}async function Io(e){return performance.now()-e<Te.ASYNC_RENDER_BUDGET_MS?e:(await kr(),performance.now())}function Dr(e,n){let t=(0,Te.resolveBleedRatio)(n.seamBleed),o=Te.DEFAULT_SEAM_BLEED*t,r={...n,bleedRatio:t};return e.seamBleedEdges?.size&&o>0?{...r,seamBleed:o,seamEdges:e.seamBleedEdges}:{...r,seamBleed:void 0,seamEdges:void 0}}function Or(e,n){return(0,Ue.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Hr(e,n,t){let o=(0,Te.resolveBleedRatio)(t.seamBleed),r=Te.DEFAULT_SEAM_BLEED*o,i={...t,bleedRatio:o};return n&&r>0?{...i,seamBleed:n.has(e)?r:void 0,seamEdges:n.get(e)}:i}function Ot(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{};let o=(0,Ue.buildBasisHints)(e,n),r=Mt(t),i=e.map((s,c)=>(0,Ue.computeTextureAtlasPlan)(s,c,n,r,o[c]));return In(i,n.textureLighting??"baked",t,n.strategies)}function Ht(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=n.textureLighting??"baked",r=n,i=o==="dynamic"&&r.skipDynamicNormalVars===!0,s=new Set(n.strategies?.disable??[]),c=!s.has("b"),l=c&&en(t),p=Je(t,n.strategies),g=p!==null,x=!s.has("i")&&Jt(t),f=!s.has("i")&&Kt(t),b=(0,Ue.buildBasisHints)(e,n),y=Mt(t),P=Or(e,n),v=e.map((u,d)=>(0,Ue.computeTextureAtlasPlan)(u,d,Hr(d,P,n),y,b[d]));if(typeof window<"u"){let u=window,d=v[1];u.__vanillaPlan1={matrix:d?.matrix,canvasW:d?.canvasW,canvasH:d?.canvasH,vertexCount:e[1]?.vertices.length}}let C=n.solidPaintDefaults??(r.computeSolidPaintDefaults?In(v,o,t,n.strategies):void 0),F=C?{...n,solidPaintDefaults:C}:n,k=v.map(u=>u&&g&&(0,J.isSolidTrianglePlan)(u)?gt(u.polygon,u.index,Dr(u,F),{primitive:p??void 0}):null),z=v.map(u=>u&&x&&!(0,J.isSolidTrianglePlan)(u)&&!(c&&(0,J.isFullRectSolid)(u))&&!(l&&(0,J.isProjectiveQuadPlan)(u))?(0,Dt.cornerShapeGeometryForPlan)(u):null),O=v.map((u,d)=>u&&(u.texture||!(c&&(0,J.isFullRectSolid)(u))&&!k[d]&&!(l&&(0,J.isProjectiveQuadPlan)(u))&&!z[d]&&!f?u:null)),{packed:Z,atlasScale:q}=Qt(O,n.textureQuality,t),D=new Map,H=[],V=!1,G=[];for(let u=0;u<e.length;u++){let d=v[u],T=k[u],w=z[u];if(!d)continue;let R=Z.entries[u];if(R){let L=Lo(R,o,t,i);D.set(u,L),H.push({polygonIndex:u,element:L,kind:"atlas",plan:R,dispose:()=>{}})}else if(!d.texture&&c&&(0,J.isFullRectSolid)(d)){let L=To(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&T){let L=Gn(T,t);H.push({polygonIndex:u,element:L,kind:"triangle",plan:d,dispose:()=>{}})}else if(!d.texture&&l&&(0,J.isProjectiveQuadPlan)(d)){let L=wo(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&w){let L=Mo(d,w,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"corner",plan:d,dispose:()=>{}})}else if(!d.texture&&f){let L=Ao(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"border",plan:d,dispose:()=>{}})}}H.sort((u,d)=>u.polygonIndex-d.polygonIndex);let A=qt(Z.pages,o,t,q,()=>V).then(u=>{if(V){for(let d of u)d.url?.startsWith("blob:")&&URL.revokeObjectURL(d.url);return}G=u.flatMap(d=>d.url?.startsWith("blob:")?[d.url]:[]);for(let d=0;d<Z.pages.length;d++){let T=Z.pages[d],w=u[d];if(w)for(let R of T.entries){let L=D.get(R.index);!L||!w.url||Co(L,w,o,R,!0)}}}).catch(()=>{if(!V)for(let u of D.values())Ee(u,"opacity","0.5"),Ee(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:H,solidPaintDefaults:C??{},pagesReady:A,dispose(){V=!0;for(let u of G)URL.revokeObjectURL(u);G=[]}}}async function $n(e,n={},t=()=>!1){let o=n.doc??(typeof document<"u"?document:null);if(!o||t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let r=n.textureLighting??"baked",s=r==="dynamic"&&n.skipDynamicNormalVars===!0,c=new Set(n.strategies?.disable??[]),l=!c.has("b"),p=l&&en(o),g=Je(o,n.strategies),x=g!==null,f=!c.has("i")&&Jt(o),b=!c.has("i")&&Kt(o);if(await kr(),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let y=(0,Ue.buildBasisHints)(e,n),P=Mt(o),v=Or(e,n),C=performance.now(),F=new Array(e.length);for(let u=0;u<e.length;u++)if(F[u]=(0,Ue.computeTextureAtlasPlan)(e[u],u,Hr(u,v,n),P,y[u]),C=await Io(C),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let k=n.solidPaintDefaults??In(F,r,o,n.strategies),z=new Array(F.length),O=new Array(F.length),Z=new Array(F.length);for(let u=0;u<F.length;u++){let d=F[u],T=d&&x&&(0,J.isSolidTrianglePlan)(d)?gt(d.polygon,d.index,Dr(d,{...n,solidPaintDefaults:k}),{primitive:g??void 0}):null;z[u]=T;let w=d&&f&&!(0,J.isSolidTrianglePlan)(d)&&!(l&&(0,J.isFullRectSolid)(d))&&!(p&&(0,J.isProjectiveQuadPlan)(d))?(0,Dt.cornerShapeGeometryForPlan)(d):null;if(O[u]=w,Z[u]=d&&(d.texture||!(l&&(0,J.isFullRectSolid)(d))&&!T&&!(p&&(0,J.isProjectiveQuadPlan)(d))&&!w&&!b?d:null),C=await Io(C),t())return{rendered:[],solidPaintDefaults:k,dispose:()=>{}}}let{packed:q,atlasScale:D}=Qt(Z,n.textureQuality,o),H=new Map,V=[],G=!1,A=[];for(let u=0;u<e.length;u++){let d=F[u],T=z[u],w=O[u];if(!d)continue;let R=q.entries[u];if(R){let L=Lo(R,r,o,s);H.set(u,L),V.push({polygonIndex:u,element:L,kind:"atlas",plan:R,dispose:()=>{}})}else if(!d.texture&&l&&(0,J.isFullRectSolid)(d)){let L=To(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&T){let L=Gn(T,o);V.push({polygonIndex:u,element:L,kind:"triangle",plan:d,dispose:()=>{}})}else if(!d.texture&&p&&(0,J.isProjectiveQuadPlan)(d)){let L=wo(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&w){let L=Mo(d,w,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"corner",plan:d,dispose:()=>{}})}else if(!d.texture&&b){let L=Ao(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"border",plan:d,dispose:()=>{}})}if(C=await Io(C),t()){for(let L of V)L.dispose();return{rendered:[],solidPaintDefaults:k,dispose:()=>{}}}}V.sort((u,d)=>u.polygonIndex-d.polygonIndex);let h=qt(q.pages,r,o,D,()=>G||t()).then(u=>{if(G||t()){for(let d of u)d.url?.startsWith("blob:")&&URL.revokeObjectURL(d.url);return}A=u.flatMap(d=>d.url?.startsWith("blob:")?[d.url]:[]);for(let d=0;d<q.pages.length;d++){let T=q.pages[d],w=u[d];if(w)for(let R of T.entries){let L=H.get(R.index);!L||!w.url||Co(L,w,r,R,!0)}}}).catch(()=>{if(!(G||t()))for(let u of H.values())Ee(u,"opacity","0.5"),Ee(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:V,solidPaintDefaults:k,pagesReady:h,dispose(){G=!0;for(let u of A)URL.revokeObjectURL(u);A=[]}}}function Un(e,n,t,o={}){let r=o.textureLighting??"baked",i=o,s=i.optimizeStableTriangleStyle===!0&&r==="baked";if(!s||i.stableTriangleColorPolicy==="adaptive"||e.length!==t.polygonCount||n.length!==t.polygonCount||t.vertices.length<t.polygonCount*9)return!1;let c=i.stableTriangleDebug,l=i.stableTriangleUpdateMode??(c==="plan-only"||c==="transform-only"?c:"full");if(l==="color-only")return!1;let p=(0,Fo.stableTriangleMatrixDecimals)(i.stableTriangleMatrixDecimals),g=ko(i),x=o.tileSize??Te.DEFAULT_TILE,f=o.layerElevation??x,b=o.doc??(typeof document<"u"?document:null),y=b?Je(b,o.strategies)??"border":"border";for(let v=0;v<e.length;v++){let C=e[v],F=n[v];if(C.kind!=="triangle"||C.polygonIndex!==v||!F||F.vertices.length!==3||F.texture||F.material?.texture)return!1}let P=t.vertices;for(let v=0;v<e.length;v++){let C=e[v].element,F=n[v],k=v*9,z=P[k+1]*x,O=P[k]*x,Z=P[k+2]*f,q=P[k+4]*x,D=P[k+3]*x,H=P[k+5]*f,V=P[k+7]*x,G=P[k+6]*x,A=P[k+8]*f,h=_o(F,v,o,{basis:C.__polycssSolidTriangleBasis,matrixDecimals:p,primitive:y,color:t.colors?.[v],includeColor:l!=="plan-only"&&l!=="transform-only"&&kt(C,v,s,c,i.stableTriangleColorPolicy,g)},z,O,Z,q,D,H,V,G,A);if(!h){nn(C);continue}l!=="plan-only"&&(l==="transform-only"?Nn(C,h):zn(C,h,g))}return!0}function jn(e,n,t={}){if(e.length!==n.length)return!1;let o=t,r=t.doc??(typeof document<"u"?document:null),i=t.textureLighting??"baked",s=new Set(t.strategies?.disable??[]),c=!s.has("b"),l=!!r&&c&&en(r),p=!!r&&!s.has("i")&&Jt(r),g=!!r&&!s.has("i")&&Kt(r),x=(0,Te.resolveBleedRatio)(o.seamBleed),f=r?Mt(r,{bleed:Te.PROJECTIVE_QUAD_BLEED*x}):{denomEps:Te.PROJECTIVE_QUAD_DENOM_EPS,maxWeightRatio:Te.PROJECTIVE_QUAD_MAX_WEIGHT_RATIO,bleed:Te.PROJECTIVE_QUAD_BLEED*x,disableGuards:!1},b=o.optimizeStableTriangleStyle===!0&&i==="baked",y=o.stableTriangleDebug,P=o.stableTriangleUpdateMode??(y==="plan-only"||y==="transform-only"?y:"full"),v=b&&P==="color-only",C=ko(o),F=(0,Fo.stableTriangleMatrixDecimals)(o.stableTriangleMatrixDecimals),k=r?Je(r,t.strategies)??"border":"border";if(_r(e,n,t,b,P,C))return!0;let z=[],O=[],Z=[];for(let D=0;D<e.length;D++){let H=e[D];if(H.polygonIndex!==D)return!1;let V=n[D];if(!V||v&&H.kind!=="triangle")return!1;if(H.kind==="atlas"){if(!H.plan||!br(H.element,H.plan,V,i))return!1;continue}if(H.kind==="triangle"){let G=H.element;if(v){let h=o.stableTriangleColorPolicy==="adaptive"||kt(G,D,b,y,o.stableTriangleColorPolicy,C);O[D]=h?(0,Rr.computeSolidTriangleColorPlan)(V,D,t):null;continue}let A=gt(V,D,t,{basis:G.__polycssSolidTriangleBasis,matrixDecimals:F,primitive:k,includeColor:P!=="plan-only"&&P!=="transform-only"&&kt(G,D,b,y,o.stableTriangleColorPolicy,C)});if(!A){z[D]=null;continue}z[D]=A;continue}if(H.kind==="solid"){if(!H.plan||V.texture||V.vertices.length!==H.plan.polygon.vertices.length)return!1;Z[D]=H.plan;continue}if(H.kind==="border"){let G=(0,Ue.computeTextureAtlasPlan)(V,D,t,f);if(!G||G.texture||!g||c&&(0,J.isFullRectSolid)(G)||l&&(0,J.isProjectiveQuadPlan)(G)||p&&(0,Dt.cornerShapeGeometryForPlan)(G))return!1;Z[D]=G;continue}if(H.kind==="corner"){let G=(0,Ue.computeTextureAtlasPlan)(V,D,t,f);if(!G||G.texture||!p||(0,J.isSolidTrianglePlan)(G)||c&&(0,J.isFullRectSolid)(G)||l&&(0,J.isProjectiveQuadPlan)(G)||!(0,Dt.cornerShapeGeometryForPlan)(G))return!1;Z[D]=G;continue}return!1}let q=b&&P!=="plan-only"&&P!=="transform-only"?Lr(e,v?O:z,o):null;for(let D=0;D<e.length;D++){let H=e[D];if(H.kind==="triangle"){if(v){let G=O[D];G&&Ho(H.element,G,C,q?.has(D));continue}let V=z[D];if(!V){nn(H.element);continue}if(b&&P==="plan-only")continue;b&&P==="transform-only"?Nn(H.element,V):b?zn(H.element,V,C,q?.has(D)):Bn(H.element,V)}else if(H.kind==="solid"){let V=Z[D];if(!V||!Pr(H.element,V,n[D],i,t,f,o.solidPaintDefaults))return!1}else if(H.kind==="border"){let V=Z[D];if(!V)return!1;Sr(H.element,V,i,o.solidPaintDefaults)}else if(H.kind==="corner"){let V=Z[D],G=V?(0,Dt.cornerShapeGeometryForPlan)(V):null;if(!V||!G)return!1;Cr(H.element,V,G,i,o.solidPaintDefaults)}}return!0}var Ir=require("@layoutit/polycss-core"),Ft=require("@layoutit/polycss-core"),Wn=require("@layoutit/polycss-core");var ee=require("@layoutit/polycss-core"),Is=[.4,-.7,.59],Fs="#ffffff",Vs=1,Bs="#ffffff",zs=.4,Gr=1,Ns=8,Gs=ee.PROJECTIVE_QUAD_BLEED,at=1e-6,$s=(0,ee.resolveProjectiveQuadGuards)({bleed:0}),$r={t:[0,0,1],b:[0,0,-1],fl:[0,1,0],br:[0,-1,0],fr:[1,0,0],bl:[-1,0,0]},zo=["t","b","bl","br","fr","fl"],Us=new Map([["0,0,1","t"],["0,0,-1","b"],["0,1,0","fl"],["0,-1,0","br"],["1,0,0","fr"],["-1,0,0","bl"]]);function Fr(e){let n=[];for(let t of zo)(0,ee.normalFacesCamera)($r[t],e)&&n.push(t);return n.join("|")}function js(e,n,t){let o=e.__polycssVoxelBrushState??(e.__polycssVoxelBrushState={});o.color!==n&&(e.style.color=n,o.color=n),o.transform!==t&&(e.style.transform=t,o.transform=t)}function Ws(e){let n=e.vertices;if(n.length<3)return null;let t=n[0],o=0,r=0,i=0;for(let c=1;c+1<n.length;c+=1){let l=n[c],p=n[c+1],g=l[1]-t[1],x=l[0]-t[0],f=l[2]-t[2],b=p[1]-t[1],y=p[0]-t[0],P=p[2]-t[2];o-=x*P-f*y,r-=f*b-g*P,i-=g*y-x*b}let s=Math.hypot(o,r,i);return s<=1e-9?null:[Math.round(o/s),Math.round(r/s),Math.round(i/s)]}function Ys(e){if(e.texture||e.material||e.uvs||e.textureTriangles||e.vertices.length!==4)return null;let n=Ws(e),t=n?Us.get(n.join(",")):void 0;if(!t)return null;let o=1/0,r=1/0,i=1/0,s=-1/0,c=-1/0,l=-1/0;for(let x of e.vertices)o=Math.min(o,x[0]),r=Math.min(r,x[1]),i=Math.min(i,x[2]),s=Math.max(s,x[0]),c=Math.max(c,x[1]),l=Math.max(l,x[2]);let p=1e-6,g=ea(e.color);return Math.abs(l-i)<=p?{axis:"z",face:t,left:r*ee.BASE_TILE,top:o*ee.BASE_TILE,width:Math.max(0,(c-r)*ee.BASE_TILE),height:Math.max(0,(s-o)*ee.BASE_TILE),z:i*ee.BASE_TILE,baseColor:g,bleed:Vo()}:Math.abs(s-o)<=p?{axis:"x",face:t,left:r*ee.BASE_TILE,top:i*ee.BASE_TILE,width:Math.max(0,(c-r)*ee.BASE_TILE),height:Math.max(0,(l-i)*ee.BASE_TILE),z:-o*ee.BASE_TILE,baseColor:g,bleed:Vo()}:Math.abs(c-r)<=p?{axis:"y",face:t,left:i*ee.BASE_TILE,top:o*ee.BASE_TILE,width:Math.max(0,(l-i)*ee.BASE_TILE),height:Math.max(0,(s-o)*ee.BASE_TILE),z:-r*ee.BASE_TILE,baseColor:g,bleed:Vo()}:null}function Vo(){return{left:0,right:0,top:0,bottom:0}}function Xs(e){let n=o=>String(Number(o.toFixed(6))),t=`${e.item.baseColor}|${e.variableAxis}`;for(let o=0;o<3;o+=1)o!==e.variableAxis&&(t+=`|${o}:${n(e.fixed[o])}`);return t}function Vr(e){return[e[1]*ee.BASE_TILE,e[0]*ee.BASE_TILE,e[2]*ee.BASE_TILE]}function Br(e,n){return e.axis==="x"?[n[0],n[2]]:e.axis==="y"?[n[2],n[1]]:[n[0],n[1]]}function Zs(e,n,t){let o=e.left,r=e.left+e.width,i=e.top,s=e.top+e.height;if(Math.abs(n[0]-t[0])<=at){if(Math.abs(n[0]-o)<=at)return"left";if(Math.abs(n[0]-r)<=at)return"right"}if(Math.abs(n[1]-t[1])<=at){if(Math.abs(n[1]-i)<=at)return"top";if(Math.abs(n[1]-s)<=at)return"bottom"}return null}function Qs(e,n){let t=null;for(let o=0;o<3;o+=1)if(!(Math.abs(e[o]-n[o])<=at)){if(t!==null)return null;t=o}return t}function qs(e,n,t){let o=n.vertices,r=Vr(o[t]),i=Vr(o[(t+1)%o.length]),s=Zs(e,Br(e,r),Br(e,i));if(!s)return null;let c=Qs(r,i);if(c===null)return null;let l=Math.min(r[c],i[c]),p=Math.max(r[c],i[c]);return p-l>at?{item:e,side:s,variableAxis:c,fixed:r,start:l,end:p}:null}function zr(e){e.item.bleed[e.side]=Math.max(e.item.bleed[e.side],Gs)}function Ks(e,n){let t=new Map;for(let o of n){let r=e[o.sourceIndex];if(r)for(let i=0;i<r.vertices.length;i+=1){let s=qs(o,r,i);if(!s)continue;let c=Xs(s),l=t.get(c);l?l.push(s):t.set(c,[s])}}for(let o of t.values()){if(o.length<2)continue;o.sort((i,s)=>i.start-s.start||i.end-s.end);let r=[];for(let i of o){r=r.filter(s=>s.end>i.start+at);for(let s of r)s.item.sourceIndex!==i.item.sourceIndex&&(zr(s),zr(i));r.push(i)}}}function Js(e){let n=(0,ee.parsePureColor)(e);return n?{r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha}:{r:255,g:255,b:255,alpha:1}}function ea(e){if(!e)return"#cccccc";let n=(0,ee.parsePureColor)(e);if(!n)return e;let t={r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha};if(t.alpha<1){let o=Math.round(Math.max(0,t.alpha)*1e3)/1e3;return`rgba(${Bo(t.r)}, ${Bo(t.g)}, ${Bo(t.b)}, ${o})`}return ta(t)}function ta({r:e,g:n,b:t}){let o=r=>Math.round(Math.max(0,Math.min(255,r))).toString(16).padStart(2,"0");return`#${o(e)}${o(n)}${o(t)}`}function Bo(e){return Math.round(Math.max(0,Math.min(255,e)))}function na(e,n,t,o){let r=t?.direction??Is,i=Math.hypot(r[0],r[1],r[2])||1,s=r[0]/i,c=r[1]/i,l=r[2]/i,p=Math.max(0,t?.intensity??Vs)*Math.max(0,e[0]*s+e[1]*c+e[2]*l),g=Math.max(0,o?.intensity??zs),x=t?.color??Fs,f=o?.color??Bs,b=(0,ee.shadePolygon)(n,p,x,f,g),y=Js(n);if(y.alpha>=1)return b;let P=parseInt(b.slice(1,3),16),v=parseInt(b.slice(3,5),16),C=parseInt(b.slice(5,7),16);return`rgba(${P}, ${v}, ${C}, ${y.alpha})`}function oa(e){if(!e?.length)return[];let n=[];for(let t=0;t<e.length;t+=1){let o=e[t],r=Ys(o);if(!r||r.width<=0||r.height<=0)return[];n.push({...r,sourceIndex:t})}return Ks(e,n),n}function ra(e){return e.axis==="x"?{xAxis:[1,0,0],yAxis:[0,0,1],normal:[0,-1,0],tx:0,ty:-e.z,tz:0}:e.axis==="y"?{xAxis:[0,0,1],yAxis:[0,1,0],normal:[-1,0,0],tx:-e.z,ty:0,tz:0}:{xAxis:[1,0,0],yAxis:[0,1,0],normal:[0,0,1],tx:0,ty:0,tz:e.z}}function ia(e){let n=e.left,t=e.top,o=e.left+e.width,r=e.top+e.height;return[n,t,o,t,o,r,n,r]}function sa(e){return new Map([[0,e.bleed.top],[1,e.bleed.right],[2,e.bleed.bottom],[3,e.bleed.left]])}function aa(e,n){let t=e.split(",").map(Number);if(t.length!==16||t.some(r=>!Number.isFinite(r)))return null;let o=ee.SOLID_QUAD_CANONICAL_SIZE/n;for(let r=0;r<8;r+=1)t[r]*=o;return`matrix3d(${t.map(r=>Number(r.toFixed(6))).join(",")})`}function Nr(e,n){let t=e.left-e.bleed.left,o=e.top-e.bleed.top,r=e.width+e.bleed.left+e.bleed.right,i=e.height+e.bleed.top+e.bleed.bottom,s=e.z,c=r/n,l=i/n;return`matrix3d(${(e.axis==="x"?[c,0,0,0,0,0,l,0,0,-1,0,0,t,-s,o,1]:e.axis==="y"?[0,0,c,0,0,l,0,0,-1,0,0,0,-s,o,t,1]:[c,0,0,0,0,l,0,0,0,0,1,0,t,o,s,1]).map(g=>Number(g.toFixed(6))).join(",")})`}function la(e,n){let{xAxis:t,yAxis:o,normal:r,tx:i,ty:s,tz:c}=ra(e),l=(0,ee.computeProjectiveQuadMatrix)(ia(e),t,o,r,i,s,c,$s,sa(e));return l?aa(l,n)??Nr(e,n):Nr(e,n)}function ca(e){let n=e.defaultView?.matchMedia;return n?n("(pointer: coarse)").matches||n("(hover: none)").matches:!1}function da(e){return ca(e)?Ns:Gr}function ua(e){return e.axis==="x"?[e.left+e.width/2,-e.z,e.top+e.height/2]:e.axis==="y"?[-e.z,e.top+e.height/2,e.left+e.width/2]:[e.left+e.width/2,e.top+e.height/2,e.z]}function pa(e,n){let t=ua(e),o=n.meshRotation;o&&(t=(0,ee.rotateVec3InWrapperCssFrame)(t,o));let[r,i]=(0,ee.rotateVec3)(t,n.rotX,0,n.rotY);return{x:r,y:i}}function ma(e,n,t){let o=e.filter(f=>n.has(f.face)).map(f=>({item:f,...pa(f,t)}));if(o.length===0)return[];let r=1/0,i=-1/0,s=1/0,c=-1/0;for(let f of o)r=Math.min(r,f.x),i=Math.max(i,f.x),s=Math.min(s,f.y),c=Math.max(c,f.y);let l=4,p=Math.max(1e-6,i-r),g=Math.max(1e-6,c-s),x=new Map;for(let f of o){let b=Math.min(l-1,Math.max(0,Math.floor((f.x-r)/p*l))),y=Math.min(l-1,Math.max(0,Math.floor((f.y-s)/g*l))),P=`${b}:${y}`,v=x.get(P);v||(v={tx:b,ty:y,sourceIndex:f.item.sourceIndex,items:[]},x.set(P,v)),v.items.push(f.item),v.sourceIndex=Math.min(v.sourceIndex,f.item.sourceIndex)}return Array.from(x.values()).sort((f,b)=>f.ty-b.ty||f.tx-b.tx||f.sourceIndex-b.sourceIndex).flatMap(f=>f.items)}function Ur(e){let{doc:n,wrapper:t,polygons:o,directionalLight:r,ambientLight:i}=e,s=oa(o);if(s.length===0)return null;let c=new Set(s.map(h=>h.face));t.classList.add("polycss-voxel-mesh");let l=da(n);l!==Gr&&t.style.setProperty("--polycss-voxel-primitive",`${l}px`);let p=new Map,g=(h,u)=>{let d=`${h}|${u}`,T=p.get(d);if(T)return T;let w=na($r[h],u,r,i);return p.set(d,w),w},x=new Map,f=new Map,b=new Map,y=new Map;for(let h of s){let u=y.get(h.face);u||(u=[],y.set(h.face,u)),u.push(h)}let P="",v=0,C=new Set,F=h=>{let u=x.get(h.sourceIndex);return u||(u=n.createElement("b"),x.set(h.sourceIndex,u),js(u,g(h.face,h.baseColor),la(h,l))),u},k=h=>{let u=f.get(h);return u||(u=n.createElement("span"),u.className=`polycss-voxel-face polycss-voxel-face-${h}`,u.dataset.polycssVoxelFace=h,u.__polycssVoxelFaceHost=!0,f.set(h,u)),u},z=()=>{for(let h of Array.from(t.childNodes))if(!h.__polycssVoxelFaceHost)return h;return null},O=(h,u)=>{let d=u.map(R=>R.sourceIndex).join(",");if(b.get(h)===d)return;let T=k(h),w=n.createDocumentFragment();for(let R of u)w.appendChild(F(R));T.replaceChildren(w),b.set(h,d)},Z=()=>{for(let h of zo)c.has(h)&&O(h,y.get(h)??[])},q=h=>new Set(h.split("|").filter(Boolean)),D=h=>{let u=q(h);return zo.filter(d=>u.has(d)&&c.has(d))},H=h=>{let u=0;for(let d of h)u+=y.get(d)?.length??0;return u},V=h=>{let u=new Set,d=[],T=new Map;for(let w of h){u.has(w.face)||(u.add(w.face),d.push(w.face));let R=T.get(w.face);R||(R=[],T.set(w.face,R)),R.push(w)}return{orderedFaces:d,itemsByFace:T}},G=(h,u)=>{let d=new Set(h);for(let T of C){if(d.has(T))continue;let w=f.get(T);w?.parentNode===t&&t.removeChild(w)}if(u){let T=n.createDocumentFragment();for(let w of h)T.appendChild(k(w));t.insertBefore(T,z()),C=d;return}for(let T=0;T<h.length;T+=1){let w=h[T],R=k(w);if(R.parentNode===t)continue;let L=null;for(let re=T+1;re<h.length;re+=1){let _=f.get(h[re]);if(_?.parentNode===t){L=_;break}}t.insertBefore(R,L??z())}C=d},A=(h,u,d)=>{if(!d){let re=D(h);G(re,!1),v=H(re);return}let T=new Set(h.split("|").filter(Boolean)),w=ma(s,T,u),{orderedFaces:R,itemsByFace:L}=V(w);for(let re of R)O(re,L.get(re)??[]);G(R,!0),v=w.length};return Z(),{get brushCount(){return v},render(h){P=Fr(h),A(P,h,!0)},syncCamera(h){let u=Fr(h);u!==P&&(P=u,A(u,h,!1))},dispose(){for(let h of f.values())h.remove();t.classList.remove("polycss-voxel-mesh"),t.style.removeProperty("--polycss-voxel-primitive"),x.clear(),f.clear(),b.clear(),v=0,C=new Set,P=""}}}var jr="polycss-styles";function Wr(e){let n=e??(typeof document<"u"?document:void 0);if(!n||n.getElementById(jr))return;let t=n.createElement("style");t.id=jr,t.textContent=fa,n.head.appendChild(t)}var fa=`
|
|
1
|
+
"use strict";var bo=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var cs=Object.prototype.hasOwnProperty;var ds=(e,n)=>{for(var t in n)bo(e,t,{get:n[t],enumerable:!0})},us=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ls(n))!cs.call(e,r)&&r!==t&&bo(e,r,{get:()=>n[r],enumerable:!(o=as(n,r))||o.enumerable});return e};var ps=e=>us(bo({},"__esModule",{value:!0}),e);var Vl={};ds(Vl,{PolyAxesHelperElement:()=>cn,PolyBoxElement:()=>vn,PolyCameraElement:()=>gn,PolyConeElement:()=>wn,PolyCylinderElement:()=>Mn,PolyDirectionalLightHelperElement:()=>dn,PolyDodecahedronElement:()=>Tn,PolyFirstPersonControlsElement:()=>fn,PolyIcosahedronElement:()=>En,PolyIframeElement:()=>an,PolyMapControlsElement:()=>mn,PolyMeshElement:()=>xt,PolyOctahedronElement:()=>Sn,PolyOrbitControlsElement:()=>pn,PolyOrthographicCameraElement:()=>Pt,PolyPerspectiveCameraElement:()=>hn,PolyPlaneElement:()=>xn,PolyPolygonElement:()=>ln,PolyRingElement:()=>Pn,PolySceneElement:()=>_e,PolySelectElement:()=>bn,PolySphereElement:()=>An,PolyTetrahedronElement:()=>Cn,PolyTorusElement:()=>Ln,PolyTransformControlsElement:()=>yn});module.exports=ps(Vl);var ne=require("@layoutit/polycss-core");var rr=require("@layoutit/polycss-core");function ms(e){if(!e)return!1;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return t?t("(pointer: coarse)").matches||t("(hover: none)").matches:!1}function Qt(e,n,t){return(0,rr.packTextureAtlasPlansWithScaleCore)(e,n,ms(t))}var It=require("@layoutit/polycss-core");var ot=require("@layoutit/polycss-core"),dr=require("@layoutit/polycss-core"),ur=require("@layoutit/polycss-core"),Tt=new Map;function fs(e){let n=Tt.get(e);return n||(n=new Promise((t,o)=>{let r=new Image;r.decoding="async",r.crossOrigin="anonymous",r.onload=()=>t(r),r.onerror=()=>o(new Error(`texture load failed: ${e}`)),r.src=e}),Tt.set(e,n),n.then(()=>{Tt.get(e)===n&&Tt.delete(e)},()=>{Tt.get(e)===n&&Tt.delete(e)})),n}function Ie(e,n,t=1,o=0,r=0,i=1,s=0,c=0){e.setTransform(t*n,o*n,r*n,i*n,s*n,c*n)}function vo(e){let n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function xo(e){let n=e<=.0031308?e*12.92:1.055*Math.pow(e,.4166666666666667)-.055;return Math.max(0,Math.min(255,Math.round(n*255)))}function hs(e,n,t,o,r,i,s){let c=Math.round(n*s),l=Math.round(t*s),p=Math.max(1,Math.round(o*s)),h=Math.max(1,Math.round(r*s)),x=e.getImageData(c,l,p,h),f=x.data,b=i.r,y=i.g,P=i.b;for(let v=0;v<f.length;v+=4)f[v+3]!==0&&(f[v]=xo(vo(f[v])*b),f[v+1]=xo(vo(f[v+1])*y),f[v+2]=xo(vo(f[v+2])*P));e.putImageData(x,c,l)}function gs(e,n,t,o,r,i,s){let c=n.naturalWidth||n.width||1,l=n.naturalHeight||n.height||1,p=Math.max(r/c,i/l),h=c*p,x=l*p;Ie(e,s),e.drawImage(n,t+(r-h)/2,o+(i-x)/2,h,x)}function At(e,n){return Math.max(0,Math.min(n,e))}function ir(e,n,t,o,r,i,s,c){let l=n.naturalWidth||n.width||1,p=n.naturalHeight||n.height||1,h=At(Math.min(t.minU,t.maxU)*l,l),x=At(Math.max(t.minU,t.maxU)*l,l),f=At(Math.min(t.minV,t.maxV)*p,p),b=At(Math.max(t.minV,t.maxV)*p,p),y=Math.floor(h),P=Math.floor(f),v=Math.ceil(x)-y,C=Math.ceil(b)-P;v<1&&(y=Math.floor(At((t.minU+t.maxU)/2*l,l-1)),v=1),C<1&&(P=Math.floor(At((t.minV+t.maxV)/2*p,p-1)),C=1),y=Math.max(0,Math.min(l-1,y)),P=Math.max(0,Math.min(p-1,P)),v=Math.max(1,Math.min(l-y,v)),C=Math.max(1,Math.min(p-P,C)),Ie(e,c),e.drawImage(n,y,P,v,C,o,r,i,s)}function pr(e){return e==="repeat"||e==="mirrored-repeat"}function sr(e,n){return pr(e)?Math.floor(n):0}function ar(e,n){return pr(e)?Math.ceil(n)-1:0}function lr(e,n){return e==="mirrored-repeat"&&Math.abs(n%2)===1}function cr(e,n,t,o,r,i,s){let c=r?sr(i,r.minU):0,l=r?ar(i,r.maxU):0,p=r?sr(s,r.minV):0,h=r?ar(s,r.maxV):0;for(let x=c;x<=l;x++)for(let f=p;f<=h;f++){let b=lr(i,x),y=lr(s,f);if(!b&&!y){e.drawImage(n,x*t,f*o);continue}e.save(),e.translate((b?x+1:x)*t,(y?f+1:f)*o),e.scale(b?-1:1,y?-1:1),e.drawImage(n,0,0),e.restore()}}function Po(e,n,t,o){for(let r=0;r<o.length;r+=2){let i=n+o[r],s=t+o[r+1];r===0?e.moveTo(i,s):e.lineTo(i,s)}e.closePath()}function kn(e,n,t,o,r,i){for(let s=0;s<o.length;s+=2){let c=n+o[s]+r,l=t+o[s+1]+i;s===0?e.moveTo(c,l):e.lineTo(c,l)}e.closePath()}function ys(e,n,t,o){Ie(e,o),e.beginPath(),Po(e,n.x,n.y,n.screenPts),e.clip(),Ie(e,o),e.fillStyle=t==="dynamic"?n.polygon.color??"#cccccc":n.shadedColor,e.fillRect(n.x,n.y,n.canvasW,n.canvasH)}function Dn(e,n,t,o,r){n.polygon.textureAlphaMode==="opaque"&&(Ie(e,t),e.fillStyle=n.polygon.color??"#cccccc",e.fillRect(n.x+o,n.y+r,n.canvasW,n.canvasH))}function bs(e,n,t,o,r=0,i=0){if(n.textureTriangles?.length){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1;for(let l of n.textureTriangles){let p=(0,dr.expandClipPoints)(l.screenPts,ot.TEXTURE_TRIANGLE_BLEED*(n.bleedRatio??1));e.save(),Ie(e,o),e.beginPath(),kn(e,n.x,n.y,p,r,i),e.clip(),Dn(e,n,o,r,i),l.uvAffine?(Ie(e,o,l.uvAffine.a/s,l.uvAffine.c/s,l.uvAffine.b/c,l.uvAffine.d/c,n.x+l.uvAffine.e+r,n.y+l.uvAffine.f+i),cr(e,t,s,c,l.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t)):l.uvSampleRect&&ir(e,t,l.uvSampleRect,n.x+r,n.y+i,n.canvasW,n.canvasH,o),e.restore()}}else if(n.uvAffine){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1,l=n.polygon.textureAlphaMode==="opaque";l&&(e.save(),Ie(e,o),e.beginPath(),kn(e,n.x,n.y,n.screenPts,r,i),e.clip(),Dn(e,n,o,r,i)),Ie(e,o,n.uvAffine.a/s,n.uvAffine.c/s,n.uvAffine.b/c,n.uvAffine.d/c,n.x+n.uvAffine.e+r,n.y+n.uvAffine.f+i),cr(e,t,s,c,n.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t),l&&e.restore()}else if(n.uvSampleRect){let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Ie(e,o),e.beginPath(),kn(e,n.x,n.y,n.screenPts,r,i),e.clip(),Dn(e,n,o,r,i)),ir(e,t,n.uvSampleRect,n.x+r,n.y+i,n.canvasW,n.canvasH,o),s&&e.restore()}else{let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Ie(e,o),e.beginPath(),kn(e,n.x,n.y,n.screenPts,r,i),e.clip(),Dn(e,n,o,r,i)),gs(e,t,n.x+r,n.y+i,n.canvasW,n.canvasH,o),s&&e.restore()}}function vs(e,n,t,o,r,i){let s=r-t,c=i-o,l=s*s+c*c;if(l<=ur.BASIS_EPS)return Math.hypot(e-t,n-o);let p=Math.max(0,Math.min(1,((e-t)*s+(n-o)*c)/l));return Math.hypot(e-(t+s*p),n-(o+c*p))}function xs(e,n,t,o){let r=1/0,i=t.length/2;for(let s of o){if(s<0||s>=i)continue;let c=s*2,l=(s+1)%i*2;r=Math.min(r,vs(e,n,t[c],t[c+1],t[l],t[l+1]))}return r}function Ps(e,n,t,o,r,i){let s=Math.max(0,o-i),c=Math.min(n-1,o+i),l=Math.max(0,r-i),p=Math.min(t-1,r+i),h=null,x=1/0;for(let f=l;f<=p;f++)for(let b=s;b<=c;b++){if(b===o&&f===r)continue;let y=b-o,P=f-r,v=y*y+P*P;if(v>i*i||v>=x)continue;let C=(f*n+b)*4;e[C+3]<ot.TEXTURE_EDGE_REPAIR_SOURCE_ALPHA_MIN||(h=C,x=v)}return h}function Ss(e,n,t){if(!n.textureEdgeRepair||!n.texture||!n.textureEdgeRepairEdges||n.textureEdgeRepairEdges.size===0)return;let o=e.canvas;if(!o)return;let r=Math.max(0,Math.floor(n.x*t)),i=Math.max(0,Math.floor(n.y*t)),s=Math.max(1,Math.min(o.width-r,Math.ceil(n.canvasW*t))),c=Math.max(1,Math.min(o.height-i,Math.ceil(n.canvasH*t)));if(s<=0||c<=0)return;let l;try{l=e.getImageData(r,i,s,c)}catch{return}let p=l.data,h=new Uint8ClampedArray(p),x=Math.max(ot.TEXTURE_EDGE_REPAIR_RADIUS,ot.TEXTURE_EDGE_REPAIR_RADIUS/t),f=Math.max(2,Math.ceil(x*t)+1),b=!1;for(let y=0;y<c;y++)for(let P=0;P<s;P++){let v=(y*s+P)*4,C=p[v+3];if(C<ot.TEXTURE_EDGE_REPAIR_ALPHA_MIN||C===255)continue;let F=(r+P+.5)/t-n.x,k=(i+y+.5)/t-n.y;if(xs(F,k,n.screenPts,n.textureEdgeRepairEdges)>x)continue;let z=Ps(h,s,c,P,y,f);z!==null&&(p[v]=h[z],p[v+1]=h[z+1],p[v+2]=h[z+2],p[v+3]=255,b=!0)}b&&e.putImageData(l,r,i)}function Cs(e){if(typeof e.toBlob=="function")return new Promise(n=>{e.toBlob(t=>{n(t?URL.createObjectURL(t):null)},"image/png")});try{return Promise.resolve(e.toDataURL("image/png"))}catch{return Promise.resolve(null)}}async function Es(e,n,t,o){let r=t.createElement("canvas");r.width=Math.max(1,Math.ceil(e.width*o)),r.height=Math.max(1,Math.ceil(e.height*o));let i=e.entries.some(h=>h.textureEdgeRepair&&h.texture&&h.textureEdgeRepairEdges&&h.textureEdgeRepairEdges.size>0),s=r.getContext("2d",i?{willReadFrequently:!0}:void 0);if(!s)return{width:e.width,height:e.height,url:null};let c=Array.from(new Set(e.entries.flatMap(h=>h.texture?[h.texture]:[]))),l=new Map;await Promise.all(c.map(async h=>{l.set(h,await fs(h))}));for(let h of e.entries){let x=h.texture?l.get(h.texture):null;if(!h.texture){s.save(),ys(s,h,n,o),s.restore();continue}x&&(s.save(),Ie(s,o),s.beginPath(),Po(s,h.x,h.y,h.screenPts),s.clip(),bs(s,h,x,o),s.restore()),h.texture&&n==="baked"&&(s.save(),Ie(s,o),s.beginPath(),Po(s,h.x,h.y,h.screenPts),s.clip(),hs(s,h.x,h.y,h.canvasW,h.canvasH,h.textureTint,o),s.restore()),Ss(s,h,o)}let p=await Cs(r);return r.width=1,r.height=1,{width:e.width,height:e.height,url:p}}async function qt(e,n,t,o,r){let i=[];for(let s of e){if(r())break;i.push(await Es(s,n,t,o))}return i}var J=require("@layoutit/polycss-core"),On=require("@layoutit/polycss-core"),fr=require("@layoutit/polycss-core");var mr=require("@layoutit/polycss-core");function Mt(e,n){let o=e?.defaultView?.__polycssProjectiveQuadGuards,r=n&&o?{...n,...o}:o??n;return(0,mr.resolveProjectiveQuadGuards)(r)}function Kt(e){if(!!!(e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0))?.supports?.("border-shape","polygon(0 0, 100% 0, 0 100%) circle(0)"))return!1;let r=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return r?r("(pointer: fine)").matches&&r("(hover: hover)").matches:!0}function hr(e){if(gr(e))return!0;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,J.safariCssProjectiveUnsupported)(t):!0}function Jt(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")&&!!n.supports("corner-bottom-right-shape","bevel")&&!!n.supports("corner-bottom-left-shape","bevel")}function gr(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")}function Ts(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return/\bFirefox\//.test(t)}function Ke(e,n){return n?.disable?.includes("u")?null:gr(e)?"corner-bevel":hr(e)?Ts(e)?"border-large":"border":null}function en(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,J.safariCssProjectiveUnsupported)(t):!0}function Hn(e,n,t,o,r){let i=new Set(o?.disable??[]);return(0,J.getSolidPaintDefaultsForPlansCore)(e,n,i,{solidTriangleSupported:hr(t),projectiveQuadSupported:en(t),cornerShapeSupported:Jt(t),borderShapeSupported:Kt(t)},On.parseHex,On.rgbKey,r)}var Te=require("@layoutit/polycss-core"),Ue=require("@layoutit/polycss-core");var Dt=require("@layoutit/polycss-core");var it=require("@layoutit/polycss-core"),yr=require("@layoutit/polycss-core");var wt=require("@layoutit/polycss-core");function Ee(e,n,t){let o=e.getAttribute("style")??"",r=`${n}:${t}`,i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`(^|;)\\s*${i}\\s*:[^;]*`,"i"),c=s.test(o)?o.replace(s,(l,p)=>`${p}${r}`):`${o}${o.trim()&&!o.trim().endsWith(";")?";":""}${r}`;c!==o&&e.setAttribute("style",c)}function ct(e,n){let t=e.getAttribute("style")??"";if(!t||!t.toLowerCase().includes(n.toLowerCase()))return;let o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`^\\s*${o}\\s*:`,"i"),i=t.split(";").map(s=>s.trim()).filter(s=>s&&!r.test(s)).join(";");i?e.setAttribute("style",i):e.removeAttribute("style")}function tn(e,n,t,o=!1){if(n==="dynamic"){let r=(0,wt.parseHex)(e.polygon.color??"#cccccc"),i=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return(0,wt.rgbKey)(r)!==t?.dynamicColorKey&&(i+=`;--psr:${(r.r/255).toFixed(4)};--psg:${(r.g/255).toFixed(4)};--psb:${(r.b/255).toFixed(4)}`),i}return e.shadedColor?`;color:${e.shadedColor}`:""}function As(e,n){Ee(e,"--pnx",n.normal[0].toFixed(4)),Ee(e,"--pny",n.normal[1].toFixed(4)),Ee(e,"--pnz",n.normal[2].toFixed(4))}function Lt(e,n,t,o){if(t==="dynamic"){ct(e,"color"),ct(e,"background"),As(e,n);let r=(0,wt.parseHex)(n.polygon.color??"#cccccc");(0,wt.rgbKey)(r)===o?.dynamicColorKey?(ct(e,"--psr"),ct(e,"--psg"),ct(e,"--psb")):(Ee(e,"--psr",(r.r/255).toFixed(4)),Ee(e,"--psg",(r.g/255).toFixed(4)),Ee(e,"--psb",(r.b/255).toFixed(4)))}else n.shadedColor!==o?.paintColor?(ct(e,"background"),Ee(e,"color",n.shadedColor)):(ct(e,"background"),ct(e,"color"))}var _t=require("@layoutit/polycss-core"),rt=require("@layoutit/polycss-core"),In=require("@layoutit/polycss-core"),nt=require("@layoutit/polycss-core"),br="polycss-corner-shape-solid",So=new WeakMap,Co=new WeakMap;function Pe(e,n,t){let o=So.get(e),r=Co.get(e),i=typeof t=="number";if(!n.data&&!i&&(!o||o.length===0)){e.__polycssHasDataAttrs=!1;return}let s=new Map;if(n.data)for(let[l,p]of Object.entries(n.data))s.set(l,String(p));if(i&&s.set("poly-index",String(t)),o)for(let l of o)s.has(l)||e.removeAttribute(`data-${l}`);for(let[l,p]of s)r?.get(l)!==p&&e.setAttribute(`data-${l}`,p);let c=Array.from(s.keys());c.length>0?So.set(e,c):So.delete(e),s.size>0?Co.set(e,s):Co.delete(e),e.__polycssHasDataAttrs=c.length>0}function Rt(e){return e.__polycssHasDataAttrs===!0}function Eo(e,n,t,o,r=t==="dynamic"){if(!n.url)return;let i=`url(${n.url})`,s=o.canvasW||1,c=o.canvasH||1,l=(0,rt.atlasCanonicalSizeForEntry)(o),p=`${(0,it.formatCssLength)(-o.x/s*l)} ${(0,it.formatCssLength)(-o.y/c*l)}`,h=`${(0,it.formatCssLength)(n.width/s*l)} ${(0,it.formatCssLength)(n.height/c*l)}`,x=`transform:matrix3d(${o.atlasMatrix});--polycss-atlas-size:${l}px`,f=`${x};--polycss-atlas-position:${p};--polycss-atlas-image-size:${h}`;if(t==="dynamic"){let b=r?`;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`:"";e.setAttribute("style",f+`;--polycss-atlas-url:${i}`+b)}else e.setAttribute("style",x+`;background-image:${i};background-position:${p};background-size:${h};background-repeat:no-repeat;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`)}function vr(e,n,t,o){if(n.texture){if(!t.texture||n.texture!==t.texture)return!1}else if(t.texture)return!1;let r=xr(n,t);return r?(e.style.visibility="",Ee(e,"transform",`matrix3d(${r.matrix})`),o==="dynamic"&&(Ee(e,"--pnx",r.normal[0].toFixed(4)),Ee(e,"--pny",r.normal[1].toFixed(4)),Ee(e,"--pnz",r.normal[2].toFixed(4))),Pe(e,t,n.index),!0):(e.style.visibility="hidden",Pe(e,t,n.index),!0)}function To(e,n,t,o,r){if(o!=="baked")return{...e,polygon:n,normal:t};let i=r.directionalLight,s=r.ambientLight,c=i?.direction??nt.DEFAULT_LIGHT_DIR,l=i?.color??nt.DEFAULT_LIGHT_COLOR,p=Math.max(0,i?.intensity??nt.DEFAULT_LIGHT_INTENSITY),h=s?.color??nt.DEFAULT_AMBIENT_COLOR,x=Math.max(0,s?.intensity??nt.DEFAULT_AMBIENT_INTENSITY),f=Math.hypot(c[0],c[1],c[2])||1,b=c[0]/f,y=c[1]/f,P=c[2]/f,C=r.lightOccludedPolyIndices?.has(e.index)??!1?0:p*Math.max(0,t[0]*b+t[1]*y+t[2]*P);return{...e,polygon:n,normal:t,shadedColor:(0,yr.shadePolygon)(n.color??"#cccccc",C,l,h,x)}}function xr(e,n){let t=Pr(e,n);if(!t)return null;let{normal:o,xAxis:r,yAxis:i,tx:s,ty:c,tz:l}=t;return{normal:o,matrix:(0,it.formatMatrix3dValues)([r[0]*e.canvasW/(0,rt.atlasCanonicalSizeForEntry)(e),r[1]*e.canvasW/(0,rt.atlasCanonicalSizeForEntry)(e),r[2]*e.canvasW/(0,rt.atlasCanonicalSizeForEntry)(e),0,i[0]*e.canvasH/(0,rt.atlasCanonicalSizeForEntry)(e),i[1]*e.canvasH/(0,rt.atlasCanonicalSizeForEntry)(e),i[2]*e.canvasH/(0,rt.atlasCanonicalSizeForEntry)(e),0,o[0],o[1],o[2],0,s,c,l,1])}}var Pr=In.stableBasisFromPlan;function Ms(e,n,t){if(e.screenPts.length!==8||n.vertices.length!==4)return null;let o=Pr(e,n);if(!o)return null;let r=(0,In.computeProjectiveQuadMatrix)(e.screenPts,o.xAxis,o.yAxis,o.normal,o.tx,o.ty,o.tz,t);return r?{matrix:r,normal:o.normal}:null}function Ao(e,n,t,o,r=!1){let i=t.createElement("b");return i.setAttribute("style",`transform:matrix3d(${(0,it.formatSolidQuadMatrix)(e)})`+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function Mo(e,n,t,o,r=!1){let i=t.createElement("i");return i.setAttribute("style",(0,_t.formatBorderShapeElementStyle)(e)+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function wo(e,n,t,o,r,i=!1){let s=o.createElement("u");return s.className=br,s.setAttribute("style",(0,_t.formatCornerShapeElementStyle)(e,n)+tn(e,t,r,i)),Pe(s,e.polygon,e.index),s}function Lo(e,n,t,o,r=!1){let i=t.createElement("b");return i.setAttribute("style",`transform:matrix3d(${e.projectiveMatrix})`+tn(e,n,o,r)),Pe(i,e.polygon,e.index),i}function Sr(e,n,t,o,r,i,s){let c=n.projectiveMatrix?Ms(n,t,i):xr(n,t);if(!c)return!1;let l=To(n,t,c.normal,o,r);return e.style.visibility="",e.style.transform=`matrix3d(${c.matrix})`,Lt(e,l,o,s),Pe(e,l.polygon,l.index),!0}function Cr(e,n,t,o){e.style.visibility="",e.setAttribute("style",(0,_t.formatBorderShapeElementStyle)(n)),Lt(e,n,t,o),Pe(e,n.polygon,n.index)}function Er(e,n,t,o,r){e.style.visibility="",e.className=br,e.setAttribute("style",(0,_t.formatCornerShapeElementStyle)(n,t)),Lt(e,n,o,r),Ee(e,"background","currentColor"),Pe(e,n.polygon,n.index)}function _o(e,n,t,o=!1){let r=t.createElement("s"),i=(0,rt.atlasCanonicalSizeForEntry)(e),s=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return r.setAttribute("style",`transform:matrix3d(${e.atlasMatrix});--polycss-atlas-size:${i}px;opacity:0`+s),Pe(r,e.polygon,e.index),r}var kr=require("@layoutit/polycss-core");var Fn=require("@layoutit/polycss-core");function gt(e,n,t,o={}){let r=o.primitive!=null?void 0:(()=>{let i=t.doc??(typeof document<"u"?document:null);return i?Ke(i,t.strategies)??"border":"border"})();return(0,Fn.computeSolidTrianglePlan)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??r})}function Ro(e,n,t,o,r,i,s,c,l,p,h,x,f){let b=o.primitive!=null?void 0:(()=>{let y=t.doc??(typeof document<"u"?document:null);return y?Ke(y,t.strategies)??"border":"border"})();return(0,Fn.computeSolidTrianglePlanFromCssPoints)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??b},r,i,s,c,l,p,h,x,f)}var yt=require("@layoutit/polycss-core"),dt=require("@layoutit/polycss-core"),Tr=require("@layoutit/polycss-core");var ko=require("@layoutit/polycss-core");var ws="0 48px 96px 48px";function Ar(e,n){return(0,yt.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Mr(e,n,t){let o=(0,yt.resolveBleedRatio)(t.seamBleed),r=yt.DEFAULT_SEAM_BLEED*o,i={...t,bleedRatio:o};return n&&r>0?{...i,seamBleed:n.has(e)?r:void 0,seamEdges:n.get(e)}:i}function Do(e){return{updatesDisabled:e.stableTriangleColorFreezeFrames===0,freezeFrames:Math.max(1,Math.floor(e.stableTriangleColorFreezeFrames??1)),colorFrame:Math.max(0,Math.floor(e.stableTriangleColorFrame??0)),maxStep:Math.max(0,Math.floor(e.stableTriangleColorMaxStep??0))}}function wr(e,n){return!n.updatesDisabled&&(n.freezeFrames<=1||(n.colorFrame+e)%n.freezeFrames===0)}function kt(e,n,t,o,r,i){return t?i.updatesDisabled||o==="plan-only"||o==="transform-only"?!1:r==="adaptive"||e.__polycssSolidTriangleColor===void 0?!0:wr(n,i):!0}function Oo(e,n){let t=e;t.__polycssSolidTrianglePrimitive!==n&&(n==="corner-bevel"?(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderWidth="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape")):(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape"),e.style.borderWidth=n==="border-large"?ws:""),t.__polycssSolidTrianglePrimitive=n)}function Ho(e){let n=e;n.__polycssSolidTriangleHidden&&(e.style.visibility="",n.__polycssSolidTriangleHidden=!1)}function nn(e){let n=e;n.__polycssSolidTriangleHidden||(e.style.visibility="hidden",n.__polycssSolidTriangleHidden=!0)}function Vn(e,n){e.setAttribute("style",n.styleText),Oo(e,n.primitive);let t=e;t.__polycssSolidTriangleBasis=n.basis,t.__polycssSolidTriangleHidden=!1,n.colorComputed&&(t.__polycssSolidTriangleColor=n.bakedColor??"",t.__polycssSolidTriangleColorRgb=n.bakedRgb,t.__polycssSolidTriangleColorAlpha=n.bakedAlpha),t.__polycssSolidTriangleColorFrame=void 0,(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function Lr(e,n,t,o){if(!n.colorComputed){(n.polygon.data||Rt(e))&&Pe(e,n.polygon);return}let r=e,i=n.bakedColor??"",s=n.bakedRgb,c=n.bakedAlpha??1,l=r.__polycssSolidTriangleColor,p=r.__polycssSolidTriangleColorRgb,h=r.__polycssSolidTriangleColorAlpha??1,x=o??wr(n.index,t);if(!t.updatesDisabled&&l!==i&&(l===void 0||x)){let f=i,b=s;if(t.maxStep>0&&p&&s&&h===c){let y=(0,dt.stepRgbToward)(p,s,t.maxStep);b=y,f=(0,dt.rgbToCss)(y,c)}(f!==l||!(0,dt.rgbEqual)(b,p))&&(e.style.color=f),r.__polycssSolidTriangleColor=f,r.__polycssSolidTriangleColorRgb=b,r.__polycssSolidTriangleColorAlpha=c,r.__polycssSolidTriangleColorFrame=t.colorFrame}(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function Bn(e,n,t,o){let r=e;Oo(e,n.primitive),r.__polycssSolidTriangleBasis!==n.basis&&(r.__polycssSolidTriangleBasis=n.basis),Ho(e),e.style.transform=n.transformText,(n.colorComputed||n.polygon.data||Rt(e))&&Lr(e,n,t,o)}function Io(e,n,t,o){Ho(e),Lr(e,n,t,o)}function zn(e,n){let t=e;Oo(e,n.primitive),t.__polycssSolidTriangleBasis!==n.basis&&(t.__polycssSolidTriangleBasis=n.basis),Ho(e),e.style.transform=n.transformText,(n.polygon.data||Rt(e))&&Pe(e,n.polygon)}function Ls(e,n){let t=n.stableTriangleColorBudget;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t<=1?Math.max(1,Math.ceil(e*t)):Math.max(1,Math.floor(t));let o=Math.max(1,Math.floor(n.stableTriangleColorFreezeFrames??1));return Math.max(1,Math.ceil(e/o))}function _r(e,n,t){if(t.stableTriangleColorPolicy!=="adaptive")return null;if(t.stableTriangleColorFreezeFrames===0)return new Set;let o=Math.max(0,Math.floor(t.stableTriangleColorFrame??0)),r=Math.max(1,Math.floor(t.stableTriangleColorFreezeFrames??1));if(r<=1&&!Number.isFinite(t.stableTriangleColorBudget))return null;let i=Ls(e.length,t),s=Math.max(1,Math.floor(t.stableTriangleColorMaxAge??Math.max(2,r*2))),c=[];for(let l=0;l<e.length;l++){let p=e[l],h=n[l];if(p.kind!=="triangle"||!h)continue;let x=p.element,f=x.__polycssSolidTriangleColor,b=h.bakedColor??"";if(f===b)continue;let y=x.__polycssSolidTriangleColorFrame??0,P=Math.max(0,o-y),v=(0,dt.colorErrorScore)(f,b);c.push({index:l,score:(P>=s?1e6:0)+v*1e4+P})}return c.length===0?new Set:(c.sort((l,p)=>p.score-l.score),new Set(c.slice(0,i).map(l=>l.index)))}function Nn(e,n){let t=n.createElement("u");return Vn(t,e),Pe(t,e.polygon,e.index),t}function _s(e,n,t){let o=t.createElement("u");return nn(o),Pe(o,e,n),o}function Rr(e,n,t,o,r,i){let s=t,c=s.stableTriangleDebug,l=o&&r==="color-only";if(s.stableTriangleColorPolicy==="adaptive"||e.length!==n.length)return!1;let p=(0,ko.stableTriangleMatrixDecimals)(s.stableTriangleMatrixDecimals),h=t.doc??(typeof document<"u"?document:null),x=h?Ke(h,t.strategies)??"border":"border";for(let b=0;b<e.length;b++){let y=e[b];if(y.kind!=="triangle"||y.polygonIndex!==b||!n[b])return!1}let f=Ar(n,t);for(let b=0;b<e.length;b++){let y=e[b].element,P=n[b];if(l){if(kt(y,b,o,c,s.stableTriangleColorPolicy,i)){let C=(0,Tr.computeSolidTriangleColorPlan)(P,b,t);if(!C)continue;Io(y,C,i)}continue}let v=gt(P,b,Mr(b,f,t),{basis:y.__polycssSolidTriangleBasis,matrixDecimals:p,primitive:x,includeColor:r!=="plan-only"&&r!=="transform-only"&&kt(y,b,o,c,s.stableTriangleColorPolicy,i)});if(!v){nn(y);continue}o&&r==="plan-only"||(o&&r==="transform-only"?zn(y,v):o?Bn(y,v,i):Vn(y,v))}return!0}function on(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=Ke(t,n.strategies);if(!o||e.some(c=>c.texture||c.vertices.length!==3))return null;let r=(0,ko.stableTriangleMatrixDecimals)(n.stableTriangleMatrixDecimals),i=[],s=Ar(e,n);for(let c=0;c<e.length;c+=1){let l=e[c],p=gt(l,c,Mr(c,s,n),{matrixDecimals:r,primitive:o}),h=p?Nn(p,t):_s(l,c,t);i.push({polygonIndex:c,element:h,kind:"triangle",dispose:()=>{}})}return{rendered:i,dispose(){}}}var Vo=require("@layoutit/polycss-core");function Dr(){return new Promise(e=>setTimeout(e,0))}async function Fo(e){return performance.now()-e<Te.ASYNC_RENDER_BUDGET_MS?e:(await Dr(),performance.now())}function Or(e,n){let t=(0,Te.resolveBleedRatio)(n.seamBleed),o=Te.DEFAULT_SEAM_BLEED*t,r={...n,bleedRatio:t};return e.seamBleedEdges?.size&&o>0?{...r,seamBleed:o,seamEdges:e.seamBleedEdges}:{...r,seamBleed:void 0,seamEdges:void 0}}function Hr(e,n){return(0,Ue.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Ir(e,n,t){let o=(0,Te.resolveBleedRatio)(t.seamBleed),r=Te.DEFAULT_SEAM_BLEED*o,i={...t,bleedRatio:o};return n&&r>0?{...i,seamBleed:n.has(e)?r:void 0,seamEdges:n.get(e)}:i}function Ot(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{};let o=(0,Ue.buildBasisHints)(e,n),r=Mt(t),i=e.map((s,c)=>(0,Ue.computeTextureAtlasPlan)(s,c,n,r,o[c]));return Hn(i,n.textureLighting??"baked",t,n.strategies)}function Ht(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=n.textureLighting??"baked",r=n,i=o==="dynamic"&&r.skipDynamicNormalVars===!0,s=new Set(n.strategies?.disable??[]),c=!s.has("b"),l=c&&en(t),p=Ke(t,n.strategies),h=p!==null,x=!s.has("i")&&Jt(t),f=!s.has("i")&&Kt(t),b=(0,Ue.buildBasisHints)(e,n),y=Mt(t),P=Hr(e,n),v=e.map((u,d)=>(0,Ue.computeTextureAtlasPlan)(u,d,Ir(d,P,n),y,b[d]));if(typeof window<"u"){let u=window,d=v[1];u.__vanillaPlan1={matrix:d?.matrix,canvasW:d?.canvasW,canvasH:d?.canvasH,vertexCount:e[1]?.vertices.length}}let C=n.solidPaintDefaults??(r.computeSolidPaintDefaults?Hn(v,o,t,n.strategies):void 0),F=C?{...n,solidPaintDefaults:C}:n,k=v.map(u=>u&&h&&(0,J.isSolidTrianglePlan)(u)?gt(u.polygon,u.index,Or(u,F),{primitive:p??void 0}):null),z=v.map(u=>u&&x&&!(0,J.isSolidTrianglePlan)(u)&&!(c&&(0,J.isFullRectSolid)(u))&&!(l&&(0,J.isProjectiveQuadPlan)(u))?(0,Dt.cornerShapeGeometryForPlan)(u):null),O=v.map((u,d)=>u&&(u.texture||!(c&&(0,J.isFullRectSolid)(u))&&!k[d]&&!(l&&(0,J.isProjectiveQuadPlan)(u))&&!z[d]&&!f?u:null)),{packed:Z,atlasScale:q}=Qt(O,n.textureQuality,t),D=new Map,H=[],V=!1,G=[];for(let u=0;u<e.length;u++){let d=v[u],T=k[u],w=z[u];if(!d)continue;let R=Z.entries[u];if(R){let L=_o(R,o,t,i);D.set(u,L),H.push({polygonIndex:u,element:L,kind:"atlas",plan:R,dispose:()=>{}})}else if(!d.texture&&c&&(0,J.isFullRectSolid)(d)){let L=Ao(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&T){let L=Nn(T,t);H.push({polygonIndex:u,element:L,kind:"triangle",plan:d,dispose:()=>{}})}else if(!d.texture&&l&&(0,J.isProjectiveQuadPlan)(d)){let L=Lo(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&w){let L=wo(d,w,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"corner",plan:d,dispose:()=>{}})}else if(!d.texture&&f){let L=Mo(d,o,t,C,i);H.push({polygonIndex:u,element:L,kind:"border",plan:d,dispose:()=>{}})}}H.sort((u,d)=>u.polygonIndex-d.polygonIndex);let A=qt(Z.pages,o,t,q,()=>V).then(u=>{if(V){for(let d of u)d.url?.startsWith("blob:")&&URL.revokeObjectURL(d.url);return}G=u.flatMap(d=>d.url?.startsWith("blob:")?[d.url]:[]);for(let d=0;d<Z.pages.length;d++){let T=Z.pages[d],w=u[d];if(w)for(let R of T.entries){let L=D.get(R.index);!L||!w.url||Eo(L,w,o,R,!0)}}}).catch(()=>{if(!V)for(let u of D.values())Ee(u,"opacity","0.5"),Ee(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:H,solidPaintDefaults:C??{},pagesReady:A,dispose(){V=!0;for(let u of G)URL.revokeObjectURL(u);G=[]}}}async function Gn(e,n={},t=()=>!1){let o=n.doc??(typeof document<"u"?document:null);if(!o||t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let r=n.textureLighting??"baked",s=r==="dynamic"&&n.skipDynamicNormalVars===!0,c=new Set(n.strategies?.disable??[]),l=!c.has("b"),p=l&&en(o),h=Ke(o,n.strategies),x=h!==null,f=!c.has("i")&&Jt(o),b=!c.has("i")&&Kt(o);if(await Dr(),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let y=(0,Ue.buildBasisHints)(e,n),P=Mt(o),v=Hr(e,n),C=performance.now(),F=new Array(e.length);for(let u=0;u<e.length;u++)if(F[u]=(0,Ue.computeTextureAtlasPlan)(e[u],u,Ir(u,v,n),P,y[u]),C=await Fo(C),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let k=n.solidPaintDefaults??Hn(F,r,o,n.strategies),z=new Array(F.length),O=new Array(F.length),Z=new Array(F.length);for(let u=0;u<F.length;u++){let d=F[u],T=d&&x&&(0,J.isSolidTrianglePlan)(d)?gt(d.polygon,d.index,Or(d,{...n,solidPaintDefaults:k}),{primitive:h??void 0}):null;z[u]=T;let w=d&&f&&!(0,J.isSolidTrianglePlan)(d)&&!(l&&(0,J.isFullRectSolid)(d))&&!(p&&(0,J.isProjectiveQuadPlan)(d))?(0,Dt.cornerShapeGeometryForPlan)(d):null;if(O[u]=w,Z[u]=d&&(d.texture||!(l&&(0,J.isFullRectSolid)(d))&&!T&&!(p&&(0,J.isProjectiveQuadPlan)(d))&&!w&&!b?d:null),C=await Fo(C),t())return{rendered:[],solidPaintDefaults:k,dispose:()=>{}}}let{packed:q,atlasScale:D}=Qt(Z,n.textureQuality,o),H=new Map,V=[],G=!1,A=[];for(let u=0;u<e.length;u++){let d=F[u],T=z[u],w=O[u];if(!d)continue;let R=q.entries[u];if(R){let L=_o(R,r,o,s);H.set(u,L),V.push({polygonIndex:u,element:L,kind:"atlas",plan:R,dispose:()=>{}})}else if(!d.texture&&l&&(0,J.isFullRectSolid)(d)){let L=Ao(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&T){let L=Nn(T,o);V.push({polygonIndex:u,element:L,kind:"triangle",plan:d,dispose:()=>{}})}else if(!d.texture&&p&&(0,J.isProjectiveQuadPlan)(d)){let L=Lo(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"solid",plan:d,dispose:()=>{}})}else if(!d.texture&&w){let L=wo(d,w,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"corner",plan:d,dispose:()=>{}})}else if(!d.texture&&b){let L=Mo(d,r,o,k,s);V.push({polygonIndex:u,element:L,kind:"border",plan:d,dispose:()=>{}})}if(C=await Fo(C),t()){for(let L of V)L.dispose();return{rendered:[],solidPaintDefaults:k,dispose:()=>{}}}}V.sort((u,d)=>u.polygonIndex-d.polygonIndex);let g=qt(q.pages,r,o,D,()=>G||t()).then(u=>{if(G||t()){for(let d of u)d.url?.startsWith("blob:")&&URL.revokeObjectURL(d.url);return}A=u.flatMap(d=>d.url?.startsWith("blob:")?[d.url]:[]);for(let d=0;d<q.pages.length;d++){let T=q.pages[d],w=u[d];if(w)for(let R of T.entries){let L=H.get(R.index);!L||!w.url||Eo(L,w,r,R,!0)}}}).catch(()=>{if(!(G||t()))for(let u of H.values())Ee(u,"opacity","0.5"),Ee(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:V,solidPaintDefaults:k,pagesReady:g,dispose(){G=!0;for(let u of A)URL.revokeObjectURL(u);A=[]}}}function $n(e,n,t,o={}){let r=o.textureLighting??"baked",i=o,s=i.optimizeStableTriangleStyle===!0&&r==="baked";if(!s||i.stableTriangleColorPolicy==="adaptive"||e.length!==t.polygonCount||n.length!==t.polygonCount||t.vertices.length<t.polygonCount*9)return!1;let c=i.stableTriangleDebug,l=i.stableTriangleUpdateMode??(c==="plan-only"||c==="transform-only"?c:"full");if(l==="color-only")return!1;let p=(0,Vo.stableTriangleMatrixDecimals)(i.stableTriangleMatrixDecimals),h=Do(i),x=o.tileSize??Te.DEFAULT_TILE,f=o.layerElevation??x,b=o.doc??(typeof document<"u"?document:null),y=b?Ke(b,o.strategies)??"border":"border";for(let v=0;v<e.length;v++){let C=e[v],F=n[v];if(C.kind!=="triangle"||C.polygonIndex!==v||!F||F.vertices.length!==3||F.texture||F.material?.texture)return!1}let P=t.vertices;for(let v=0;v<e.length;v++){let C=e[v].element,F=n[v],k=v*9,z=P[k+1]*x,O=P[k]*x,Z=P[k+2]*f,q=P[k+4]*x,D=P[k+3]*x,H=P[k+5]*f,V=P[k+7]*x,G=P[k+6]*x,A=P[k+8]*f,g=Ro(F,v,o,{basis:C.__polycssSolidTriangleBasis,matrixDecimals:p,primitive:y,color:t.colors?.[v],includeColor:l!=="plan-only"&&l!=="transform-only"&&kt(C,v,s,c,i.stableTriangleColorPolicy,h)},z,O,Z,q,D,H,V,G,A);if(!g){nn(C);continue}l!=="plan-only"&&(l==="transform-only"?zn(C,g):Bn(C,g,h))}return!0}function Un(e,n,t={}){if(e.length!==n.length)return!1;let o=t,r=t.doc??(typeof document<"u"?document:null),i=t.textureLighting??"baked",s=new Set(t.strategies?.disable??[]),c=!s.has("b"),l=!!r&&c&&en(r),p=!!r&&!s.has("i")&&Jt(r),h=!!r&&!s.has("i")&&Kt(r),x=(0,Te.resolveBleedRatio)(o.seamBleed),f=r?Mt(r,{bleed:Te.PROJECTIVE_QUAD_BLEED*x}):{denomEps:Te.PROJECTIVE_QUAD_DENOM_EPS,maxWeightRatio:Te.PROJECTIVE_QUAD_MAX_WEIGHT_RATIO,bleed:Te.PROJECTIVE_QUAD_BLEED*x,disableGuards:!1},b=o.optimizeStableTriangleStyle===!0&&i==="baked",y=o.stableTriangleDebug,P=o.stableTriangleUpdateMode??(y==="plan-only"||y==="transform-only"?y:"full"),v=b&&P==="color-only",C=Do(o),F=(0,Vo.stableTriangleMatrixDecimals)(o.stableTriangleMatrixDecimals),k=r?Ke(r,t.strategies)??"border":"border";if(Rr(e,n,t,b,P,C))return!0;let z=[],O=[],Z=[];for(let D=0;D<e.length;D++){let H=e[D];if(H.polygonIndex!==D)return!1;let V=n[D];if(!V||v&&H.kind!=="triangle")return!1;if(H.kind==="atlas"){if(!H.plan||!vr(H.element,H.plan,V,i))return!1;continue}if(H.kind==="triangle"){let G=H.element;if(v){let g=o.stableTriangleColorPolicy==="adaptive"||kt(G,D,b,y,o.stableTriangleColorPolicy,C);O[D]=g?(0,kr.computeSolidTriangleColorPlan)(V,D,t):null;continue}let A=gt(V,D,t,{basis:G.__polycssSolidTriangleBasis,matrixDecimals:F,primitive:k,includeColor:P!=="plan-only"&&P!=="transform-only"&&kt(G,D,b,y,o.stableTriangleColorPolicy,C)});if(!A){z[D]=null;continue}z[D]=A;continue}if(H.kind==="solid"){if(!H.plan||V.texture||V.vertices.length!==H.plan.polygon.vertices.length)return!1;Z[D]=H.plan;continue}if(H.kind==="border"){let G=(0,Ue.computeTextureAtlasPlan)(V,D,t,f);if(!G||G.texture||!h||c&&(0,J.isFullRectSolid)(G)||l&&(0,J.isProjectiveQuadPlan)(G)||p&&(0,Dt.cornerShapeGeometryForPlan)(G))return!1;Z[D]=G;continue}if(H.kind==="corner"){let G=(0,Ue.computeTextureAtlasPlan)(V,D,t,f);if(!G||G.texture||!p||(0,J.isSolidTrianglePlan)(G)||c&&(0,J.isFullRectSolid)(G)||l&&(0,J.isProjectiveQuadPlan)(G)||!(0,Dt.cornerShapeGeometryForPlan)(G))return!1;Z[D]=G;continue}return!1}let q=b&&P!=="plan-only"&&P!=="transform-only"?_r(e,v?O:z,o):null;for(let D=0;D<e.length;D++){let H=e[D];if(H.kind==="triangle"){if(v){let G=O[D];G&&Io(H.element,G,C,q?.has(D));continue}let V=z[D];if(!V){nn(H.element);continue}if(b&&P==="plan-only")continue;b&&P==="transform-only"?zn(H.element,V):b?Bn(H.element,V,C,q?.has(D)):Vn(H.element,V)}else if(H.kind==="solid"){let V=Z[D];if(!V||!Sr(H.element,V,n[D],i,t,f,o.solidPaintDefaults))return!1}else if(H.kind==="border"){let V=Z[D];if(!V)return!1;Cr(H.element,V,i,o.solidPaintDefaults)}else if(H.kind==="corner"){let V=Z[D],G=V?(0,Dt.cornerShapeGeometryForPlan)(V):null;if(!V||!G)return!1;Er(H.element,V,G,i,o.solidPaintDefaults)}}return!0}var Fr=require("@layoutit/polycss-core"),Ft=require("@layoutit/polycss-core"),jn=require("@layoutit/polycss-core");var ee=require("@layoutit/polycss-core"),Is=[.4,-.7,.59],Fs="#ffffff",Vs=1,Bs="#ffffff",zs=.4,$r=1,Ns=8,Gs=ee.PROJECTIVE_QUAD_BLEED,st=1e-6,$s=(0,ee.resolveProjectiveQuadGuards)({bleed:0}),Ur={t:[0,0,1],b:[0,0,-1],fl:[0,1,0],br:[0,-1,0],fr:[1,0,0],bl:[-1,0,0]},No=["t","b","bl","br","fr","fl"],Us=new Map([["0,0,1","t"],["0,0,-1","b"],["0,1,0","fl"],["0,-1,0","br"],["1,0,0","fr"],["-1,0,0","bl"]]);function Vr(e){let n=[];for(let t of No)(0,ee.normalFacesCamera)(Ur[t],e)&&n.push(t);return n.join("|")}function js(e,n,t){let o=e.__polycssVoxelBrushState??(e.__polycssVoxelBrushState={});o.color!==n&&(e.style.color=n,o.color=n),o.transform!==t&&(e.style.transform=t,o.transform=t)}function Ws(e){let n=e.vertices;if(n.length<3)return null;let t=n[0],o=0,r=0,i=0;for(let c=1;c+1<n.length;c+=1){let l=n[c],p=n[c+1],h=l[1]-t[1],x=l[0]-t[0],f=l[2]-t[2],b=p[1]-t[1],y=p[0]-t[0],P=p[2]-t[2];o-=x*P-f*y,r-=f*b-h*P,i-=h*y-x*b}let s=Math.hypot(o,r,i);return s<=1e-9?null:[Math.round(o/s),Math.round(r/s),Math.round(i/s)]}function Ys(e){if(e.texture||e.material||e.uvs||e.textureTriangles||e.vertices.length!==4)return null;let n=Ws(e),t=n?Us.get(n.join(",")):void 0;if(!t)return null;let o=1/0,r=1/0,i=1/0,s=-1/0,c=-1/0,l=-1/0;for(let x of e.vertices)o=Math.min(o,x[0]),r=Math.min(r,x[1]),i=Math.min(i,x[2]),s=Math.max(s,x[0]),c=Math.max(c,x[1]),l=Math.max(l,x[2]);let p=1e-6,h=ea(e.color);return Math.abs(l-i)<=p?{axis:"z",face:t,left:r*ee.BASE_TILE,top:o*ee.BASE_TILE,width:Math.max(0,(c-r)*ee.BASE_TILE),height:Math.max(0,(s-o)*ee.BASE_TILE),z:i*ee.BASE_TILE,baseColor:h,bleed:Bo()}:Math.abs(s-o)<=p?{axis:"x",face:t,left:r*ee.BASE_TILE,top:i*ee.BASE_TILE,width:Math.max(0,(c-r)*ee.BASE_TILE),height:Math.max(0,(l-i)*ee.BASE_TILE),z:-o*ee.BASE_TILE,baseColor:h,bleed:Bo()}:Math.abs(c-r)<=p?{axis:"y",face:t,left:i*ee.BASE_TILE,top:o*ee.BASE_TILE,width:Math.max(0,(l-i)*ee.BASE_TILE),height:Math.max(0,(s-o)*ee.BASE_TILE),z:-r*ee.BASE_TILE,baseColor:h,bleed:Bo()}:null}function Bo(){return{left:0,right:0,top:0,bottom:0}}function Xs(e){let n=o=>String(Number(o.toFixed(6))),t=`${e.item.baseColor}|${e.variableAxis}`;for(let o=0;o<3;o+=1)o!==e.variableAxis&&(t+=`|${o}:${n(e.fixed[o])}`);return t}function Br(e){return[e[1]*ee.BASE_TILE,e[0]*ee.BASE_TILE,e[2]*ee.BASE_TILE]}function zr(e,n){return e.axis==="x"?[n[0],n[2]]:e.axis==="y"?[n[2],n[1]]:[n[0],n[1]]}function Zs(e,n,t){let o=e.left,r=e.left+e.width,i=e.top,s=e.top+e.height;if(Math.abs(n[0]-t[0])<=st){if(Math.abs(n[0]-o)<=st)return"left";if(Math.abs(n[0]-r)<=st)return"right"}if(Math.abs(n[1]-t[1])<=st){if(Math.abs(n[1]-i)<=st)return"top";if(Math.abs(n[1]-s)<=st)return"bottom"}return null}function Qs(e,n){let t=null;for(let o=0;o<3;o+=1)if(!(Math.abs(e[o]-n[o])<=st)){if(t!==null)return null;t=o}return t}function qs(e,n,t){let o=n.vertices,r=Br(o[t]),i=Br(o[(t+1)%o.length]),s=Zs(e,zr(e,r),zr(e,i));if(!s)return null;let c=Qs(r,i);if(c===null)return null;let l=Math.min(r[c],i[c]),p=Math.max(r[c],i[c]);return p-l>st?{item:e,side:s,variableAxis:c,fixed:r,start:l,end:p}:null}function Nr(e){e.item.bleed[e.side]=Math.max(e.item.bleed[e.side],Gs)}function Ks(e,n){let t=new Map;for(let o of n){let r=e[o.sourceIndex];if(r)for(let i=0;i<r.vertices.length;i+=1){let s=qs(o,r,i);if(!s)continue;let c=Xs(s),l=t.get(c);l?l.push(s):t.set(c,[s])}}for(let o of t.values()){if(o.length<2)continue;o.sort((i,s)=>i.start-s.start||i.end-s.end);let r=[];for(let i of o){r=r.filter(s=>s.end>i.start+st);for(let s of r)s.item.sourceIndex!==i.item.sourceIndex&&(Nr(s),Nr(i));r.push(i)}}}function Js(e){let n=(0,ee.parsePureColor)(e);return n?{r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha}:{r:255,g:255,b:255,alpha:1}}function ea(e){if(!e)return"#cccccc";let n=(0,ee.parsePureColor)(e);if(!n)return e;let t={r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha};if(t.alpha<1){let o=Math.round(Math.max(0,t.alpha)*1e3)/1e3;return`rgba(${zo(t.r)}, ${zo(t.g)}, ${zo(t.b)}, ${o})`}return ta(t)}function ta({r:e,g:n,b:t}){let o=r=>Math.round(Math.max(0,Math.min(255,r))).toString(16).padStart(2,"0");return`#${o(e)}${o(n)}${o(t)}`}function zo(e){return Math.round(Math.max(0,Math.min(255,e)))}function na(e,n,t,o){let r=t?.direction??Is,i=Math.hypot(r[0],r[1],r[2])||1,s=r[0]/i,c=r[1]/i,l=r[2]/i,p=Math.max(0,t?.intensity??Vs)*Math.max(0,e[0]*s+e[1]*c+e[2]*l),h=Math.max(0,o?.intensity??zs),x=t?.color??Fs,f=o?.color??Bs,b=(0,ee.shadePolygon)(n,p,x,f,h),y=Js(n);if(y.alpha>=1)return b;let P=parseInt(b.slice(1,3),16),v=parseInt(b.slice(3,5),16),C=parseInt(b.slice(5,7),16);return`rgba(${P}, ${v}, ${C}, ${y.alpha})`}function oa(e){if(!e?.length)return[];let n=[];for(let t=0;t<e.length;t+=1){let o=e[t],r=Ys(o);if(!r||r.width<=0||r.height<=0)return[];n.push({...r,sourceIndex:t})}return Ks(e,n),n}function ra(e){return e.axis==="x"?{xAxis:[1,0,0],yAxis:[0,0,1],normal:[0,-1,0],tx:0,ty:-e.z,tz:0}:e.axis==="y"?{xAxis:[0,0,1],yAxis:[0,1,0],normal:[-1,0,0],tx:-e.z,ty:0,tz:0}:{xAxis:[1,0,0],yAxis:[0,1,0],normal:[0,0,1],tx:0,ty:0,tz:e.z}}function ia(e){let n=e.left,t=e.top,o=e.left+e.width,r=e.top+e.height;return[n,t,o,t,o,r,n,r]}function sa(e){return new Map([[0,e.bleed.top],[1,e.bleed.right],[2,e.bleed.bottom],[3,e.bleed.left]])}function aa(e,n){let t=e.split(",").map(Number);if(t.length!==16||t.some(r=>!Number.isFinite(r)))return null;let o=ee.SOLID_QUAD_CANONICAL_SIZE/n;for(let r=0;r<8;r+=1)t[r]*=o;return`matrix3d(${t.map(r=>Number(r.toFixed(6))).join(",")})`}function Gr(e,n){let t=e.left-e.bleed.left,o=e.top-e.bleed.top,r=e.width+e.bleed.left+e.bleed.right,i=e.height+e.bleed.top+e.bleed.bottom,s=e.z,c=r/n,l=i/n;return`matrix3d(${(e.axis==="x"?[c,0,0,0,0,0,l,0,0,-1,0,0,t,-s,o,1]:e.axis==="y"?[0,0,c,0,0,l,0,0,-1,0,0,0,-s,o,t,1]:[c,0,0,0,0,l,0,0,0,0,1,0,t,o,s,1]).map(h=>Number(h.toFixed(6))).join(",")})`}function la(e,n){let{xAxis:t,yAxis:o,normal:r,tx:i,ty:s,tz:c}=ra(e),l=(0,ee.computeProjectiveQuadMatrix)(ia(e),t,o,r,i,s,c,$s,sa(e));return l?aa(l,n)??Gr(e,n):Gr(e,n)}function ca(e){let n=e.defaultView?.matchMedia;return n?n("(pointer: coarse)").matches||n("(hover: none)").matches:!1}function da(e){return ca(e)?Ns:$r}function ua(e){return e.axis==="x"?[e.left+e.width/2,-e.z,e.top+e.height/2]:e.axis==="y"?[-e.z,e.top+e.height/2,e.left+e.width/2]:[e.left+e.width/2,e.top+e.height/2,e.z]}function pa(e,n){let t=ua(e),o=n.meshRotation;o&&(t=(0,ee.rotateVec3InWrapperCssFrame)(t,o));let[r,i]=(0,ee.rotateVec3)(t,n.rotX,0,n.rotY);return{x:r,y:i}}function ma(e,n,t){let o=e.filter(f=>n.has(f.face)).map(f=>({item:f,...pa(f,t)}));if(o.length===0)return[];let r=1/0,i=-1/0,s=1/0,c=-1/0;for(let f of o)r=Math.min(r,f.x),i=Math.max(i,f.x),s=Math.min(s,f.y),c=Math.max(c,f.y);let l=4,p=Math.max(1e-6,i-r),h=Math.max(1e-6,c-s),x=new Map;for(let f of o){let b=Math.min(l-1,Math.max(0,Math.floor((f.x-r)/p*l))),y=Math.min(l-1,Math.max(0,Math.floor((f.y-s)/h*l))),P=`${b}:${y}`,v=x.get(P);v||(v={tx:b,ty:y,sourceIndex:f.item.sourceIndex,items:[]},x.set(P,v)),v.items.push(f.item),v.sourceIndex=Math.min(v.sourceIndex,f.item.sourceIndex)}return Array.from(x.values()).sort((f,b)=>f.ty-b.ty||f.tx-b.tx||f.sourceIndex-b.sourceIndex).flatMap(f=>f.items)}function jr(e){let{doc:n,wrapper:t,polygons:o,directionalLight:r,ambientLight:i}=e,s=oa(o);if(s.length===0)return null;let c=new Set(s.map(g=>g.face));t.classList.add("polycss-voxel-mesh");let l=da(n);l!==$r&&t.style.setProperty("--polycss-voxel-primitive",`${l}px`);let p=new Map,h=(g,u)=>{let d=`${g}|${u}`,T=p.get(d);if(T)return T;let w=na(Ur[g],u,r,i);return p.set(d,w),w},x=new Map,f=new Map,b=new Map,y=new Map;for(let g of s){let u=y.get(g.face);u||(u=[],y.set(g.face,u)),u.push(g)}let P="",v=0,C=new Set,F=g=>{let u=x.get(g.sourceIndex);return u||(u=n.createElement("b"),x.set(g.sourceIndex,u),js(u,h(g.face,g.baseColor),la(g,l))),u},k=g=>{let u=f.get(g);return u||(u=n.createElement("span"),u.className=`polycss-voxel-face polycss-voxel-face-${g}`,u.dataset.polycssVoxelFace=g,u.__polycssVoxelFaceHost=!0,f.set(g,u)),u},z=()=>{for(let g of Array.from(t.childNodes))if(!g.__polycssVoxelFaceHost)return g;return null},O=(g,u)=>{let d=u.map(R=>R.sourceIndex).join(",");if(b.get(g)===d)return;let T=k(g),w=n.createDocumentFragment();for(let R of u)w.appendChild(F(R));T.replaceChildren(w),b.set(g,d)},Z=()=>{for(let g of No)c.has(g)&&O(g,y.get(g)??[])},q=g=>new Set(g.split("|").filter(Boolean)),D=g=>{let u=q(g);return No.filter(d=>u.has(d)&&c.has(d))},H=g=>{let u=0;for(let d of g)u+=y.get(d)?.length??0;return u},V=g=>{let u=new Set,d=[],T=new Map;for(let w of g){u.has(w.face)||(u.add(w.face),d.push(w.face));let R=T.get(w.face);R||(R=[],T.set(w.face,R)),R.push(w)}return{orderedFaces:d,itemsByFace:T}},G=(g,u)=>{let d=new Set(g);for(let T of C){if(d.has(T))continue;let w=f.get(T);w?.parentNode===t&&t.removeChild(w)}if(u){let T=n.createDocumentFragment();for(let w of g)T.appendChild(k(w));t.insertBefore(T,z()),C=d;return}for(let T=0;T<g.length;T+=1){let w=g[T],R=k(w);if(R.parentNode===t)continue;let L=null;for(let re=T+1;re<g.length;re+=1){let _=f.get(g[re]);if(_?.parentNode===t){L=_;break}}t.insertBefore(R,L??z())}C=d},A=(g,u,d)=>{if(!d){let re=D(g);G(re,!1),v=H(re);return}let T=new Set(g.split("|").filter(Boolean)),w=ma(s,T,u),{orderedFaces:R,itemsByFace:L}=V(w);for(let re of R)O(re,L.get(re)??[]);G(R,!0),v=w.length};return Z(),{get brushCount(){return v},render(g){P=Vr(g),A(P,g,!0)},syncCamera(g){let u=Vr(g);u!==P&&(P=u,A(u,g,!1))},dispose(){for(let g of f.values())g.remove();t.classList.remove("polycss-voxel-mesh"),t.style.removeProperty("--polycss-voxel-primitive"),x.clear(),f.clear(),b.clear(),v=0,C=new Set,P=""}}}var Wr="polycss-styles";function Yr(e){let n=e??(typeof document<"u"?document:void 0);if(!n||n.getElementById(Wr))return;let t=n.createElement("style");t.id=Wr,t.textContent=fa,n.head.appendChild(t)}var fa=`
|
|
2
2
|
/* \u2500\u2500 Scene container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
3
3
|
|
|
4
4
|
.polycss-scene,
|
|
@@ -516,4 +516,4 @@
|
|
|
516
516
|
.polycss-scene[data-polycss-lighting="dynamic"] q {
|
|
517
517
|
opacity: clamp(0, calc((var(--pnx) * var(--clx) + var(--pny) * var(--cly) + var(--pnz) * var(--clz)) * 10), 1);
|
|
518
518
|
}
|
|
519
|
-
`;var Yr=require("@layoutit/polycss-core"),ha=1,je=Yr.BASE_TILE,ga=.1;function ya(e){return[e[1]*je,e[0]*je,e[2]*je]}function Vt(e){return[e[1],e[0],e[2]]}function ut(e){return e?.direction?{...e,direction:Vt(e.direction)}:e}function Yn(e){let n=typeof e.scale=="number"?e.scale:e.scale?.[0]??1,t=typeof e.scale=="number"?e.scale:e.scale?.[1]??1,o=typeof e.scale=="number"?e.scale:e.scale?.[2]??1,r=n!==1||t!==1||o!==1,i=!!e.rotation&&(!!e.rotation[0]||!!e.rotation[1]||!!e.rotation[2]),s=e.position?ya(e.position):[0,0,0],c=[];return(s[0]!==0||s[1]!==0||s[2]!==0)&&c.push(`translate3d(${s[0]}px, ${s[1]}px, ${s[2]}px)`),i&&(e.rotation[0]&&c.push(`rotateY(${-e.rotation[0]}deg)`),e.rotation[1]&&c.push(`rotateX(${-e.rotation[1]}deg)`),e.rotation[2]&&c.push(`rotateZ(${-e.rotation[2]}deg)`)),r&&c.push(`scale3d(${n}, ${t}, ${o})`),c.length>0?c.join(" "):void 0}function No(e,n=[0,0,0],t=1){let o=e.state,r=o.rotX,i=o.rotY,c=(o.zoom??ha)/je*t,l=(o.distance??0)*t,p=o.target??[0,0,0],g=p[0]+n[0],x=p[1]+n[1],f=p[2]+n[2],b=x*je,y=g*je,P=f*je;return`${l!==0?`translateZ(${-l}px) `:""}scale(${c}) rotateX(${r}deg) rotate(${i}deg) translate3d(${-b}px, ${-y}px, ${-P}px)`}function ba(e){let n=e.trim();if(!n||n==="normal")return 1;let t=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Number.isFinite(t)&&t>0?t:1}function Xr(e){let n=e.ownerDocument?.defaultView;if(!n)return 1;let t=1;for(let o=e;o;o=o.parentElement)t*=ba(n.getComputedStyle(o).getPropertyValue("zoom"));return Number.isFinite(t)&&t>0?t:1}function Zr(e,n){Math.abs(n-1)<1e-6?e.style.removeProperty("zoom"):e.style.setProperty("zoom",String(1/n))}function Qr(e){if(e.vertices.length<3)return null;let n=e.vertices[0],t=0,o=0,r=0;for(let x=1;x+1<e.vertices.length;x++){let f=e.vertices[x],b=e.vertices[x+1],y=f[1]-n[1],P=f[0]-n[0],v=f[2]-n[2],C=b[1]-n[1],F=b[0]-n[0],k=b[2]-n[2];t-=P*k-v*F,o-=v*C-y*k,r-=y*F-P*C}let i=Math.hypot(t,o,r);if(i<1e-9)return null;t/=i,o/=i,r/=i;let s=1/ga,c=Math.round(t*s)/s,l=Math.round(o*s)/s,p=Math.round(r*s)/s,g=Math.hypot(c,l,p);return g<1e-9?null:{key:c+","+l+","+p,vec:[c/g,l/g,p/g]}}function qr(e,n){let t=e?.disable??[],o=n?.disable??[];if(t.length!==o.length)return!1;for(let r of t)if(!o.includes(r))return!1;return!0}function Kr(e,n){return e===n?!0:!e||!n?!1:e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}function Jr(e,n){return e===n?!0:(e?.color??"#000000")===(n?.color??"#000000")&&(e?.opacity??.25)===(n?.opacity??.25)&&(e?.lift??.05)===(n?.lift??.05)&&(e?.maxExtend??2e3)===(n?.maxExtend??2e3)}var pt=require("@layoutit/polycss-core");var va=["--plx","--ply","--plz","--plr","--plg","--plb","--pli","--par","--pag","--pab","--pai","--clx","--cly","--clz"],Bt="--polycss-light-preview-active",ei=`var(${Bt}, 0)`,xa="max(0, calc(var(--pnx, 0) * var(--plx, 0) + var(--pny, 0) * var(--ply, 0) + var(--pnz, 1) * var(--plz, 1)))",Go=(e,n,t)=>`calc(255 * max(0, 1.055 * pow(min(1, pow((var(${e}, 1) + 0.055) / 1.055, 2.4) * (pow((var(${n}, 1) + 0.055) / 1.055, 2.4) * var(--pai, 0.4) + pow((var(${t}, 1) + 0.055) / 1.055, 2.4) * var(--pli, 1) * var(--plam, 0)) / 3.14159265), 0.4167) - 0.055))`,Pa=Go("--psr","--par","--plr"),Sa=Go("--psg","--pag","--plg"),Ca=Go("--psb","--pab","--plb");function me(e,n,t){return e.style.getPropertyValue(n)===t?!1:(e.style.setProperty(n,t),!0)}function bt(e){for(let n of va)e.style.getPropertyValue(n)&&e.style.removeProperty(n)}function Xn(e,n){let t=n.directionalLight?.direction??[.4,-.7,.59],o=Vt(t),r=Math.hypot(o[0],o[1],o[2])||1,i=o[0]/r,s=o[1]/r,c=o[2]/r,l=(0,pt.parseHexColor)(n.directionalLight?.color??"#ffffff")?.rgb??[255,255,255],p=(0,pt.parseHexColor)(n.ambientLight?.color??"#ffffff")?.rgb??[255,255,255],g=n.directionalLight?.intensity??1,x=n.ambientLight?.intensity??.4,f=P=>(P/255).toFixed(4);me(e,"--plx",i.toFixed(2)),me(e,"--ply",s.toFixed(2)),me(e,"--plz",c.toFixed(2)),me(e,"--plr",f(l[0])),me(e,"--plg",f(l[1])),me(e,"--plb",f(l[2])),me(e,"--pli",g.toFixed(4)),me(e,"--par",f(p[0])),me(e,"--pag",f(p[1])),me(e,"--pab",f(p[2])),me(e,"--pai",x.toFixed(4));let b=c,y=Math.sign(b||1)*Math.max(Math.abs(b),.01);me(e,"--clx",i.toFixed(2)),me(e,"--cly",s.toFixed(2)),me(e,"--clz",y.toFixed(2))}function ti(e,n){let t=n.textureLighting==="dynamic";if(e.dataset.polycssLighting=n.textureLighting??"baked",!t){bt(e);return}Xn(e,n)}function vt(e,n){n.paintColor?e.style.setProperty("--polycss-paint",n.paintColor):e.style.getPropertyValue("--polycss-paint")&&e.style.removeProperty("--polycss-paint"),n.dynamicColor?(e.style.setProperty("--psr",(n.dynamicColor.r/255).toFixed(4)),e.style.setProperty("--psg",(n.dynamicColor.g/255).toFixed(4)),e.style.setProperty("--psb",(n.dynamicColor.b/255).toFixed(4))):(e.style.getPropertyValue("--psr")||e.style.getPropertyValue("--psg")||e.style.getPropertyValue("--psb"))&&(e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"))}function ni(e,n){let t=(0,pt.parseHex)(n??"#cccccc");e.style.setProperty("--psr",(t.r/255).toFixed(4)),e.style.setProperty("--psg",(t.g/255).toFixed(4)),e.style.setProperty("--psb",(t.b/255).toFixed(4))}function $o(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=t.textureLighting??"baked",r={directionalLight:ut(t.directionalLight),ambientLight:t.ambientLight,textureLighting:o,textureQuality:t.textureQuality,seamBleed:t.seamBleed,strategies:t.strategies},i=Eo(e.plan,n,e.plan.normal,o,r);return Lt(e.element,i,o),o==="baked"&&Ta(e.element),!0}function Ea(e){let n=(0,pt.parsePureColor)(e)??{rgb:[255,255,255],alpha:1},[t,o,r]=n.rgb,i=(c,l)=>`calc(${c} * (1 - ${ei}) + var(${l}, ${c}) * ${ei})`,s=n.alpha<1?` / ${n.alpha}`:"";return`rgb(${i(t,"--polycss-preview-r")} ${i(o,"--polycss-preview-g")} ${i(r,"--polycss-preview-b")}${s})`}function oi(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=e.element,r=e.plan.normal,i=(0,pt.parseHex)(n.color??"#cccccc"),s=!1;return s=me(o,"--pnx",r[0].toFixed(4))||s,s=me(o,"--pny",r[1].toFixed(4))||s,s=me(o,"--pnz",r[2].toFixed(4))||s,s=me(o,"--psr",(i.r/255).toFixed(4))||s,s=me(o,"--psg",(i.g/255).toFixed(4))||s,s=me(o,"--psb",(i.b/255).toFixed(4))||s,s=me(o,"--plam",xa)||s,s=me(o,"--polycss-preview-r",Pa)||s,s=me(o,"--polycss-preview-g",Sa)||s,s=me(o,"--polycss-preview-b",Ca)||s,s=me(o,"--polycss-paint",Ea(t))||s,o.style.getPropertyValue("color")&&(o.style.removeProperty("color"),s=!0),s}function Ta(e){e.style.removeProperty("--pnx"),e.style.removeProperty("--pny"),e.style.removeProperty("--pnz"),e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"),e.style.removeProperty("--plam"),e.style.removeProperty("--polycss-preview-r"),e.style.removeProperty("--polycss-preview-g"),e.style.removeProperty("--polycss-preview-b"),e.style.removeProperty("--polycss-paint")}var Aa="http://www.w3.org/2000/svg",Zn=class{constructor(){this.groundSvg=null;this.groundVisible=!1;this.currentGroundCssZ=null;this.shadowRoot=null}};function ri(e,n,t){let o=e.shadowRoot;if(o||(o=n.createElement("div"),o.setAttribute("class","polycss-shadows"),o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.width="0",o.style.height="0",o.style.transformStyle="preserve-3d",o.style.pointerEvents="none",e.shadowRoot=o),o.parentNode!==t){let r=t.firstChild;r?t.insertBefore(o,r):t.appendChild(o)}return o}function ii(e){e.groundSvg?.parentNode&&e.groundSvg.parentNode.removeChild(e.groundSvg),e.groundSvg=null,e.groundVisible=!1}function si(e){e.groundSvg&&e.groundVisible&&(e.groundSvg.style.display="none",e.groundVisible=!1)}function ai(e,n,t,o){let r=[],i=e.firstChild;for(let s=0;s<t;s++){let c=i;c&&c.tagName==="path"?i=c.nextSibling:(c=n.createElementNS(Aa,"path"),c.setAttribute("fill-rule","nonzero"),o&&(c.setAttribute("stroke-width","0.5"),c.setAttribute("stroke-linejoin","round")),e.insertBefore(c,i)),r.push(c)}for(;i;){let s=i.nextSibling;e.removeChild(i),i=s}return r}function li(e){return{host:e.host,doc:e.doc,cameraEl:e.cameraEl,sceneEl:e.sceneEl,camera:e.camera,layoutScale:e.layoutScale,options:{current:e.options},meshes:new Set,meshAutoCounter:{next:0},autoCenter:{offset:[0,0,0]},bboxCenterCssCache:{value:null},shadowSvgState:new Zn,receiverShadowCache:new Map,receiverShadowCacheKey:new Map,casterItemsCache:new Map,casterItemsCacheKey:new Map}}var Fe=require("@layoutit/polycss-core");function ci(e){for(let n of e)n.svg&&n.svg.parentNode&&n.svg.parentNode.removeChild(n.svg),n.svg=null}function di(e,n){if(n){let t=e.receiverShadowCache.get(n);t&&ci(t),e.receiverShadowCache.delete(n),e.receiverShadowCacheKey.delete(n)}else{for(let t of e.receiverShadowCache.values())ci(t);e.receiverShadowCache.clear(),e.receiverShadowCacheKey.clear()}}function ui(e,n){n?(e.casterItemsCache.delete(n),e.casterItemsCacheKey.delete(n)):(e.casterItemsCache.clear(),e.casterItemsCacheKey.clear())}function pi(e){ii(e.shadowSvgState),mi(e)}function Uo(e){return e.handle.id??e.autoMeshId}var Ma="http://www.w3.org/2000/svg",Qn=new WeakMap,fi=new WeakMap,hi=new WeakMap,gi=new WeakMap,yi=new WeakMap;function bi(e){let n=Qn.get(e);return n||(n=new Map,Qn.set(e,n)),n}function jo(e){let n=Qn.get(e);if(n){for(let t of n.values())t.svg&&t.svg.parentNode&&t.svg.parentNode.removeChild(t.svg);n.clear(),Qn.delete(e)}}function mi(e){for(let n of e.meshes)jo(n)}function vi(e,n,t,o,r,i,s,c,l,p){let g=e.options.current,{receiverShadowCache:x,receiverShadowCacheKey:f,casterItemsCache:b,casterItemsCacheKey:y}=e,P=o.handle.transform.position??[0,0,0],v=o.handle.transform.rotation??[0,0,0],C=o.polygons.some(A=>A.texture!==void 0),F=(0,Fe.meshScaleVec3)(o.handle.transform.scale),k=o.bboxCenterCss,z=g.shadow?.lift??.001,O=`${o.polygons.length}|${r.size}|${P.join(",")}|${v.join(",")}|${F.join(",")}|${k?k.join(","):"n"}|${z}`,Z=x.get(o);if(Z===void 0||f.get(o)!==O){Z=(0,Fe.prepareReceiverFacePlanes)(o.polygons,P,o.handle.transform.scale,r,z,v),x.set(o,Z),f.set(o,O);let A=bi(o);for(let h of A.values())h.svg&&h.svg.parentNode&&h.svg.parentNode.removeChild(h.svg);A.clear()}let q=[];for(let A of n){let h=A.handle.transform.position??[0,0,0],u=A.handle.transform.rotation??[0,0,0],d=(0,Fe.meshScaleVec3)(A.handle.transform.scale),T=A.bboxCenterCss,w=`${A.polygons.length}|${h.join(",")}|${u.join(",")}|${d.join(",")}|${T?T.join(","):"n"}`,R=b.get(A);if(R===void 0||y.get(A)!==w){let _=t.get(A),j=new Set;for(let Q of A.rendered)Q.plan&&!_.has(Q.polygonIndex)&&j.add(Q.polygonIndex);R=(0,Fe.prepareCasterPolyItems)(A.polygons,h,A.handle.transform.scale,Q=>j.has(Q),u),b.set(A,R),y.set(A,w)}let L;if(A===o){let _=fi.get(A);(_===void 0||hi.get(A)!==A.polygons)&&(_=(0,Fe.buildSharedEdgeMap)(A.polygons),fi.set(A,_),hi.set(A,A.polygons)),L=_}let re;if(A!==o&&A.polygons.length>=40){let _=gi.get(A);(_===void 0||yi.get(A)!==w)&&(_=(0,Fe.prepareCasterEdgeOwners)(A.polygons,h,A.handle.transform.scale,u),gi.set(A,_),yi.set(A,w)),re=_}q.push({id:A,items:R,selfShadowEdgeMap:L,edgeOwners:re,casterPolygonCount:A.polygons.length})}let D={rotX:e.camera.state.rotX,rotY:e.camera.state.rotY,meshRotation:o.handle.transform.rotation},H=(0,Fe.computeReceiverShadowFaces)({receiverPlanes:Z,receiverPolygons:o.polygons,receiverHasTexture:C,casters:q,lightDir:i,cameraRot:D,ambientLight:g.ambientLight,directionalLight:g.directionalLight,shadow:{color:g.shadow?.color,opacity:p,maxExtend:g.shadow?.maxExtend}}),V=bi(o),G=new Set;for(let A of H){G.add(A.faceIndex);let h=V.get(A.faceIndex);h||(h={svg:null,visible:!1,width:-1,height:-1,matrixCss:""},V.set(A.faceIndex,h));let u=h.svg;u?(h.visible||(u.style.display="block"),(h.width!==A.width||h.height!==A.height)&&(u.setAttribute("width",String(A.width)),u.setAttribute("height",String(A.height)),u.setAttribute("viewBox",`0 0 ${A.width} ${A.height}`),h.width=A.width,h.height=A.height),h.matrixCss!==A.matrixCss&&(u.style.transform=A.matrixCss,h.matrixCss=A.matrixCss)):(u=e.doc.createElementNS(Ma,"svg"),u.setAttribute("class","polycss-shadow polycss-shadow-svg polycss-shadow-receiver"),g.debugShadowAttrs&&(u.setAttribute("data-poly-shadow-type","receiver"),u.setAttribute("data-poly-shadow-receiver",Uo(o)),u.setAttribute("data-poly-shadow-receiver-face",String(A.faceIndex)),u.setAttribute("data-poly-shadow-receiver-polys",JSON.stringify(A.memberPolyIndices))),u.setAttribute("width",String(A.width)),u.setAttribute("height",String(A.height)),u.setAttribute("viewBox",`0 0 ${A.width} ${A.height}`),u.setAttribute("style",`position:absolute;top:0;left:0;display:block;overflow:hidden;transform-origin:0 0;pointer-events:none;will-change:transform;transform:${A.matrixCss}`),ri(e.shadowSvgState,e.doc,e.sceneEl).appendChild(u),h.svg=u,h.width=A.width,h.height=A.height,h.matrixCss=A.matrixCss),h.visible=!0;let d=ai(u,e.doc,A.paths.length,!0),T=A.opacity.toFixed(4),w=[],R=!!g.debugShadowAttrs;for(let L=0;L<A.paths.length;L++){let re=A.paths[L],_=R?Uo(re.casterId):"";R&&w.push(_);let j=d[L];if(j.setAttribute("d",re.d),j.getAttribute("fill")!==A.fill&&j.setAttribute("fill",A.fill),j.getAttribute("stroke")!==A.fill&&j.setAttribute("stroke",A.fill),j.getAttribute("opacity")!==T&&j.setAttribute("opacity",T),R){j.getAttribute("data-poly-shadow-caster")!==_&&j.setAttribute("data-poly-shadow-caster",_);let Q=JSON.stringify(re.casterPolygonIndices);j.getAttribute("data-poly-shadow-caster-polys")!==Q&&j.setAttribute("data-poly-shadow-caster-polys",Q)}}if(R){let L=w.join(" ");u.getAttribute("data-poly-shadow-casters")!==L&&u.setAttribute("data-poly-shadow-casters",L)}}for(let[A,h]of V)G.has(A)||h.svg&&h.visible&&(h.svg.style.display="none",h.visible=!1)}var xi=Symbol.for("polycss.animation.triangleFrameTarget");var wa=750;function Pi(e){return!Object.prototype.hasOwnProperty.call(e,"seamBleed")||e.seamBleed!==void 0?e:{...e,seamBleed:ne.DEFAULT_SEAM_BLEED}}var La={key:"non-cullable",normal:[1,1,0]};function Si(){return[La]}function Ci(e,n){if(!e||typeof e.appendChild!="function")throw new Error("createPolyScene: host must be an HTMLElement");if(!n?.camera)throw new Error("createPolyScene: a camera handle is required. Use createPolyCamera({...}) or createPolyPerspectiveCamera({...}) and pass as { camera }.");let t=n.camera;e.ownerDocument&&Wr(e.ownerDocument),e.ownerDocument?.defaultView&&e.ownerDocument.defaultView.getComputedStyle(e).position==="static"&&(e.style.position="relative");let{camera:o,...r}=n,i=Pi({seamBleed:ne.DEFAULT_SEAM_BLEED,...r}),s=Xr(e),c=[0,0,0],l=e.ownerDocument??document,p=l.createElement("div");p.className="polycss-camera",Z(p,i),e.appendChild(p);let g=l.createElement("div");g.className="polycss-scene",g.setAttribute("aria-hidden","true"),q(g,i),p.appendChild(g);let x=li({host:e,doc:l,cameraEl:p,sceneEl:g,camera:t,layoutScale:s,options:i}),f=x.meshes,b=new WeakMap,y=x.shadowSvgState,P=()=>si(y),v=()=>pi(x),C=null;function F(a){if(!a)return null;let m=Math.hypot(a[0],a[1],a[2]);if(!Number.isFinite(m)||m<=0)return null;let S=Math.round(a[0]/m*100)/100,E=Math.round(a[1]/m*100)/100,W=Math.round(a[2]/m*100)/100;return`${S}|${E}|${W}`}function k(){C=null}let z=a=>di(x,a),O=a=>ui(x,a);function Z(a,m){let S=t.perspectiveStyle;if(S==="none")a.style.perspective="1000000px";else{let E=parseFloat(S);Number.isFinite(E)&&(a.style.perspective=`${E}px`)}}function q(a,m){Zr(a,s),a.style.transform=No(t,c,s),ti(a,m)}function D(a){a.style.transform=No(t,c,s)}function H(a){a.voxelRenderer?.dispose(),a.voxelRenderer=void 0,h(a.rendered,a.disposeAtlas),a.disposeAtlas=void 0,a.rendered.length=0,a.renderedByPolygonIndex=[],a.cameraCullGroups=[],a.cameraCullSignature="",a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,A(a);for(let m of Array.from(a.wrapper.children))m instanceof HTMLElement&&m.classList.contains("polycss-bucket")&&m.remove();a.hasBuckets=!1}function V(a){for(let m of Array.from(a.wrapper.childNodes)){if(!(m instanceof HTMLElement))return m;if(m.classList.contains("polycss-bucket")||m.classList.contains("polycss-shadow"))continue;let S=m.tagName.toLowerCase();if(!(S==="b"||S==="i"||S==="s"||S==="u"||S==="q"))return m}return null}function G(a,m,S){S?.parentNode===a.wrapper?a.wrapper.insertBefore(m,S):a.wrapper.appendChild(m)}function A(a){for(let m of a.shadowRendered)m.parentNode&&m.parentNode.removeChild(m);a.shadowRendered.length=0,v()}function h(a,m){m?.();for(let S of a){try{S.dispose()}catch{}S.element.parentNode&&S.element.parentNode.removeChild(S.element)}}function u(a,m,S){a.rendered=m,a.renderedByPolygonIndex=[];for(let E of m)a.renderedByPolygonIndex[E.polygonIndex]=E;a.disposeAtlas=S,a.solidLightingPreviewPrepared=!1}function d(a,m){let S=a.renderedByPolygonIndex[m];return S?.polygonIndex===m?S:void 0}function T(a){for(let m of Array.from(a.wrapper.children))m instanceof HTMLElement&&m.classList.contains("polycss-bucket")&&m.remove();a.hasBuckets=!1;for(let m of a.rendered)m.element.parentNode&&m.element.parentNode.removeChild(m.element)}function w(a,m){let S=a.polygons[m.polygonIndex];return a.stableDom&&S?(0,ne.polygonCssSurfaceNormal)(S):m.plan?.normal??(S?(0,ne.polygonCssSurfaceNormal)(S):null)}function R(a){if(!Q(a))return a.rendered;let m=L(a);return a.rendered.filter(S=>re(a,S,ne.CAMERA_BACKFACE_CULL_EPS,m))}function L(a){return{rotX:t.state.rotX,rotY:t.state.rotY,meshRotation:a.handle.transform.rotation}}function re(a,m,S=ne.CAMERA_BACKFACE_CULL_EPS,E=L(a)){let W=w(a,m);return W===null||(0,ne.normalFacesCamera)(W,E,S)}function _(a){if(a.excludeFromAutoCenter){a.cameraCullGroups=[];return}let m=new Map;for(let S of a.rendered){let E=w(a,S);if(!E)continue;if(!(0,ne.isAxisAlignedSurfaceNormal)(E)){a.cameraCullGroups=Si();return}let W=(0,ne.cameraCullNormalKey)(E);if(!m.has(W)&&(m.set(W,E),m.size>ne.VOXEL_CAMERA_CULL_NORMAL_LIMIT)){a.cameraCullGroups=Si();return}}a.cameraCullGroups=Array.from(m,([S,E])=>({key:S,normal:E}))}function j(a){return Q(a)?(0,ne.cameraCullVisibleSignature)(a.cameraCullGroups,L(a)):"all"}function Q(a){return!a.excludeFromAutoCenter&&(0,ne.isVoxelCameraCullableNormalGroups)(a.cameraCullGroups)}function ae(a){a.cameraCullSignature=Q(a)?j(a):"all"}function be(a,m){let S=new Array(a.rendered.length),E=!1,W=L(a);for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K],te=re(a,se,m,W);S[K]=te}let B=null,I=null,U=()=>{if(!(!B||!I)){if(B===I)B.remove();else{let K=l.createRange();K.setStartBefore(B),K.setEndAfter(I),K.deleteContents(),K.detach()}B=null,I=null,E=!0}};for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K];!S[K]&&se.element.parentNode===a.wrapper?(I&&I.nextSibling===se.element||(U(),B=se.element),I=se.element):U()}U();let Y=K=>{for(let se=K;se<a.rendered.length;se+=1){let te=a.rendered[se].element;if(te.parentNode===a.wrapper)return te}return V(a)},de=-1,ie=K=>{if(de<0)return;let se=l.createDocumentFragment();for(let te=de;te<K;te+=1){let Ne=a.rendered[te];Se(a,Ne),se.appendChild(Ne.element)}G(a,se,Y(K)),de=-1,E=!0};for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K];S[K]&&se.element.parentNode!==a.wrapper?de<0&&(de=K):ie(K)}return ie(a.rendered.length),E}function fe(a,m=!1){if(a.voxelRenderer){m?a.voxelRenderer.render(L(a)):a.voxelRenderer.syncCamera(L(a)),a.cameraCullSignature="voxel-direct";return}if(!Q(a)){let W=a.cameraCullSignature!=="all";a.cameraCullSignature="all",W&&Ce(a);return}if(a.hasBuckets){ge(a,m);return}let S=j(a);if(!m&&S===a.cameraCullSignature)return;let E=be(a,ne.CAMERA_BACKFACE_CULL_EPS);a.cameraCullSignature=S,E&&Xe(a)}function ge(a,m=!1){let S=Q(a)?j(a):"all";!m&&S===a.cameraCullSignature||Ce(a)}function we(a,m){return w(a,m)}function Se(a,m){if(i.textureLighting!=="dynamic")return;let S=we(a,m);S&&(m.element.style.setProperty("--pnx",S[0].toFixed(4)),m.element.style.setProperty("--pny",S[1].toFixed(4)),m.element.style.setProperty("--pnz",S[2].toFixed(4)))}function ke(a){T(a),a.hasBuckets=!1;let m=a.skipBucketNormalCleanupOnce;a.skipBucketNormalCleanupOnce=!1;let S=l.createDocumentFragment(),E=i.textureLighting==="dynamic"&&!a.stableDom,W=new Map,B=[];for(let I of R(a)){let U=a.polygons[I.polygonIndex],Y=E&&U?Qr(U):null;if(!Y){B.push(I);continue}let de=Y.key+"|"+(U.color??""),ie=W.get(de);ie||(ie={vec:Y.vec,items:[]},W.set(de,ie)),ie.items.push(I)}for(let I of B)Se(a,I),S.appendChild(I.element);for(let I of W.values()){if(I.items.length<2){for(let Y of I.items)Se(a,Y),S.appendChild(Y.element);continue}let U=l.createElement("div");U.className="polycss-bucket",a.hasBuckets=!0,U.style.setProperty("--pnx",String(I.vec[0])),U.style.setProperty("--pny",String(I.vec[1])),U.style.setProperty("--pnz",String(I.vec[2]));for(let Y of I.items)U.appendChild(Y.element),(!m||Y.kind==="triangle")&&(Y.element.style.removeProperty("--pnx"),Y.element.style.removeProperty("--pny"),Y.element.style.removeProperty("--pnz"));S.appendChild(U)}G(a,S,V(a)),ae(a)}function Ye(){return new Promise(a=>setTimeout(a,0))}async function tt(a,m){if(i.textureLighting==="dynamic"&&!a.stableDom)return ke(a),!m();T(a);let E=l.createDocumentFragment(),W=V(a),B=0;for(let I of R(a)){if(m())return!1;Se(a,I),E.appendChild(I.element),B++,B%wa===0&&(G(a,E,W),E=l.createDocumentFragment(),await Ye())}return E.childNodes.length>0&&G(a,E,W),ae(a),!m()}function mt(a,m){let S=i.textureLighting==="dynamic",E=i.directionalLight?.direction,W=m&&(m[0]!==0||m[1]!==0||m[2]!==0);if(!S||!W||!E){if(a.lightOverrideSignature==="clear")return;a.wrapper.style.removeProperty("--plx"),a.wrapper.style.removeProperty("--ply"),a.wrapper.style.removeProperty("--plz"),a.lightOverrideSignature="clear";return}let B=(0,ne.inverseRotateVec3)(E,m),I=Vt(B),U=Math.hypot(I[0],I[1],I[2])||1,Y=(I[0]/U).toFixed(2),de=(I[1]/U).toFixed(2),ie=(I[2]/U).toFixed(2),K=`${Y}|${de}|${ie}`;a.lightOverrideSignature!==K&&(a.wrapper.style.setProperty("--plx",Y),a.wrapper.style.setProperty("--ply",de),a.wrapper.style.setProperty("--plz",ie),a.lightOverrideSignature=K)}function Ct(a){let m=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(m=$o(S,E,i)||m)}return a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,m}function ft(a){if((i.textureLighting??"baked")!=="baked")return!1;let m=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(oi(S,E,S.plan.shadedColor),m=!0)}return a.solidLightingPreviewPrepared=m,m}function lo(a){return(i.textureLighting??"baked")!=="baked"||!a.solidLightingPreviewPrepared&&!ft(a)?!1:(a.solidLightingPreviewActive=!0,!0)}function co(a){return a.kind==="atlas"||!!a.plan?.texture}function uo(){if((i.textureLighting??"baked")!=="baked")return!1;let a=!1;for(let m of f)a=Ct(m)||a,m.rendered.some(co)&&(Yt(m),a=!0);g.style.removeProperty(Bt);for(let m of f)bt(m.wrapper),m.solidLightingPreviewActive=!1;return bt(g),a}function po(){g.style.removeProperty(Bt);for(let a of f)a.solidLightingPreviewActive&&(Ct(a),bt(a.wrapper));(i.textureLighting??"baked")!=="dynamic"&&(bt(g),k(),Le())}function $(a,m){let S=a.handle.transform.rotation,E=m.directionalLight?.direction??i.directionalLight?.direction;if(!(S&&(S[0]!==0||S[1]!==0||S[2]!==0))||!E){bt(a.wrapper);return}let B=(0,ne.inverseRotateVec3)(E,S);Xn(a.wrapper,{...i,...m,directionalLight:{...i.directionalLight,...m.directionalLight,direction:B}})}function le(a){if((i.textureLighting??"baked")!=="baked")return!1;Xn(g,{...i,...a}),!a.skipShadows&&a.directionalLight?.direction&&Le(a.directionalLight.direction);let m=!1;for(let S of f)$(S,a),m=lo(S)||m;return m?me(g,Bt,"1"):g.style.removeProperty(Bt),m}function ce(a,m,S){let E=a.polygons[m];if(!E)return!1;let W=d(a,m);if(!W)return!1;let B=i.textureLighting??"baked";return B==="dynamic"?(ni(W.element,S),!0):B==="baked"?$o(W,E,i):!1}function De(a,m){let S=a.polygons[m];if(!S)return!1;let E=d(a,m);return E?(Pe(E.element,S,m),!0):!1}function Wt(a,m,S){return!(S.length===0||!S.every(E=>E==="color"||E==="data")||S.includes("color")&&!ce(a,m,a.polygons[m]?.color)||S.includes("data")&&!De(a,m))}function Xe(a){k(),Le()}function Le(a){let m=[];for(let te of f)!te.disposed&&te.castShadow&&m.push(te);if(m.length===0){v(),C=null;return}let S=i.shadow?.color??"#000000",E=i.shadow?.opacity??.25,W=(0,ne.parseHexColor)(S)?.rgb??[0,0,0],B=W[0],I=W[1],U=W[2],Y=a??i.directionalLight?.direction??[.4,-.7,.59],de=Vt(Y),ie=F(de);if(ie!==null&&ie===C)return;let K=new Map;for(let te of m)K.set(te,(0,ne.findOverlappingPolygonDuplicates)(te.polygons,{normalTolerance:.1,distanceTolerance:.5,overlapFraction:.95,preserveDoubleSidedBackfaces:!1}));let se=new Map;for(let te of f)te.disposed||!te.receiveShadow||se.set(te,new Set);P();for(let te of f)te.disposed||!te.receiveShadow||vi(x,m,K,te,se.get(te)??new Set,de,B,I,U,E);C=ie}function Ce(a){if(a.voxelRenderer){a.voxelRenderer.render(L(a)),a.cameraCullSignature="voxel-direct";return}A(a),ke(a),Xe(a)}function Be(a,m){if(!m||!a.polygons||a.polygons.length<2)return;let S=Math.hypot(m[0],m[1],m[2]);if(!Number.isFinite(S)||S<=0)return;let E=m[0]/S,W=m[1]/S,B=m[2]/S,I=K=>Math.round(K*1e3)/1e3,U=`${I(E)},${I(W)},${I(B)}`,Y=a.lightOcclusionCache;if(Y&&Y.polygons===a.polygons&&Y.lightDirKey===U)return Y.occluded;let de=Y&&Y.polygons===a.polygons?Y.dedupDropped:(0,ne.findOverlappingPolygonDuplicates)(a.polygons,{normalTolerance:.1,distanceTolerance:.12,overlapFraction:.98,preserveDoubleSidedBackfaces:!1}),ie=(0,ne.computeLightVisibility)(a.polygons,[E,W,B],de);return a.lightOcclusionCache={polygons:a.polygons,lightDirKey:U,occluded:ie,dedupDropped:de},ie}function ze(a){return!!a.voxelSource&&i.textureLighting!=="dynamic"&&!a.stableDom&&!a.castShadow}function Me(a,m){H(a);let S=i.directionalLight,E=m?{...S,direction:m}:S,W=ut(E),B=void 0;if(ze(a)){let Y=Ur({doc:l,wrapper:a.wrapper,polygons:a.parseResult.polygons,directionalLight:W,ambientLight:i.ambientLight});if(Y){a.voxelRenderer=Y,Y.render(L(a)),a.cameraCullSignature="voxel-direct";return}}let I={doc:l,directionalLight:W,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,lightOccludedPolyIndices:B},U=a.stableDom?(()=>{let Y=Ot(a.polygons,I);return vt(a.wrapper,Y),on(a.polygons,{...I,solidPaintDefaults:Y})??Ht(a.polygons,{...I,solidPaintDefaults:Y})})():Ht(a.polygons,{...I,computeSolidPaintDefaults:!0,skipDynamicNormalVars:i.textureLighting==="dynamic"});a.stableDom||vt(a.wrapper,U.solidPaintDefaults??{}),u(a,U.rendered,U.dispose),a.skipBucketNormalCleanupOnce=i.textureLighting==="dynamic"&&!a.stableDom,_(a),ke(a),Xe(a)}function Yt(a,m){if(a.rendered.length===0||a.voxelRenderer||a.stableDom||ze(a)){Me(a,m);return}if(a.rendered[0]?.element.parentNode===null){Me(a,m);return}let S=i.directionalLight,E=m?{...S,direction:m}:S,W=ut(E),B={doc:l,directionalLight:W,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,computeSolidPaintDefaults:!0,skipDynamicNormalVars:i.textureLighting==="dynamic"},I=Ht(a.polygons,B),U=()=>{a.rebakeInFlight=!1;let ie=a.rebakeQueuedLightDir;ie!==null&&(a.rebakeQueuedLightDir=null,Yt(a,ie))},Y=()=>{if(a.disposed){I.dispose(),U();return}if(I.rendered.length!==a.rendered.length){I.dispose(),Me(a,m),U();return}for(let se of I.rendered){let te=a.renderedByPolygonIndex[se.polygonIndex];if(!te)continue;let Ne=se.element.getAttribute("style");Ne!==null&&te.element.setAttribute("style",Ne)}let ie=I.solidPaintDefaults;ie&&vt(a.wrapper,ie);let K=a.disposeAtlas;a.disposeAtlas=I.dispose,K&&(typeof requestAnimationFrame=="function"?te=>{requestAnimationFrame(te)}:te=>{setTimeout(te,0)})(K),Xe(a),U()},de=I.pagesReady;de&&typeof de.then=="function"?de.then(()=>fo(I.rendered)).then(ho).then(Y,()=>{I.dispose(),a.disposed||Me(a,m),U()}):Y()}function mo(a,m){if(a.rebakeInFlight){a.rebakeQueuedLightDir=m;return}a.rebakeInFlight=!0,Yt(a,m)}function fo(a){let m=new Set;for(let S of a){let E=S.element.getAttribute("style")??"",W=/url\((blob:[^)]+)\)/g,B;for(;(B=W.exec(E))!==null;)m.add(B[1])}return Array.from(m)}function ho(a){return a.length===0||typeof Image>"u"?Promise.resolve():Promise.all(a.map(m=>{let S=new Image;S.src=m;let E=S.decode?.();return E?E.catch(()=>{}):Promise.resolve()})).then(()=>{})}function nt(){let a=1/0,m=!1;for(let B of f)if(!B.disposed&&B.receiveShadow){m=!0;break}for(let B of f){if(B.disposed||!(m?B.receiveShadow:B.castShadow))continue;let U=B.handle.transform.position?.[2]??0;for(let Y of B.polygons)for(let de of Y.vertices){let ie=de[2]+U;ie<a&&(a=ie)}}if(!Number.isFinite(a)){let B=y.currentGroundCssZ!==null;y.currentGroundCssZ=null,B&&(v(),k());return}let S=i.shadow?.lift??.05,E=(a+S)*je,W=y.currentGroundCssZ;y.currentGroundCssZ=E,W!==E&&(k(),Le())}async function Rn(a,m){H(a);let S=ut(i.directionalLight),E={doc:l,directionalLight:S,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,lightOccludedPolyIndices:void 0},W=a.stableDom?on(a.polygons,E):null;if(W){let U=Ot(a.polygons,E);return vt(a.wrapper,U),u(a,W.rendered,W.dispose),_(a),ke(a),Xe(a),!m()}let B=await $n(a.polygons,{...E,skipDynamicNormalVars:i.textureLighting==="dynamic"},m);if(m())return B.dispose(),!1;vt(a.wrapper,B.solidPaintDefaults),u(a,B.rendered,B.dispose),a.skipBucketNormalCleanupOnce=i.textureLighting==="dynamic"&&!a.stableDom,_(a);let I=await tt(a,m);return I&&Xe(a),I}function ht(){let a=c,m=[0,0,0];if(i.autoCenter){let S=[];for(let E of f)!E.disposed&&!E.excludeFromAutoCenter&&S.push(...E.polygons);if(S.length>0){let E=(0,ne.computeSceneBbox)(S);m=[(E.min[0]+E.max[0])/2,(E.min[1]+E.max[1])/2,(E.min[2]+E.max[2])/2]}}a[0]===m[0]&&a[1]===m[1]&&a[2]===m[2]||(c=m,x.autoCenter.offset=m,q(g,i))}function es(a,m={}){let E=(g.ownerDocument??document).createElement("div");E.className="polycss-mesh",m.id&&E.setAttribute("data-poly-mesh-id",m.id);let W=`polycss-mesh-${x.meshAutoCounter.next++}`;E.setAttribute("data-poly-mesh-index",W);let B={...m},I=m.merge!==!1,U=!!m.stableDom,Y=0,de=Yn(B);de&&(E.style.transform=de);let ie=(N,X)=>a.voxelSource?N:X?(0,ne.optimizeMeshPolygons)(N,{meshResolution:m.meshResolution}):(U||m.excludeFromAutoCenter,N),K=ie(a.polygons,I),se=null;function te(){let N=Yn(B);E.style.transform=N??""}function Ne(N){if(N.length===0){se=null,Ze&&(Ze.bboxCenterCss=null),te();return}let X=1/0,ue=1/0,ye=1/0,Oe=-1/0,pe=-1/0,xe=-1/0;for(let Ke of N)for(let $e of Ke.vertices)$e[0]<X&&(X=$e[0]),$e[0]>Oe&&(Oe=$e[0]),$e[1]<ue&&(ue=$e[1]),$e[1]>pe&&(pe=$e[1]),$e[2]<ye&&(ye=$e[2]),$e[2]>xe&&(xe=$e[2]);if(!Number.isFinite(X)){se=null,Ze&&(Ze.bboxCenterCss=null),te();return}let Ge=(ue+pe)/2*je,qe=(X+Oe)/2*je,He=(ye+xe)/2*je;se=[Ge,qe,He],Ze&&(Ze.bboxCenterCss=se),te()}let Ze=null;Ne(K),g.appendChild(E);let M={handle:void 0,wrapper:E,parseResult:a,rendered:[],renderedByPolygonIndex:[],shadowRendered:[],polygons:K,voxelSource:a.voxelSource,disposed:!1,stableDom:U,hasBuckets:!1,skipBucketNormalCleanupOnce:!1,excludeFromAutoCenter:!!m.excludeFromAutoCenter,castShadow:!!m.castShadow,bboxCenterCss:se,receiveShadow:!!m.receiveShadow,cameraCullGroups:[],cameraCullSignature:"",lightOverrideSignature:"clear",stableTriangleColorFrame:0,solidLightingPreviewPrepared:!1,solidLightingPreviewActive:!1,bakedRotation:m.rotation?[...m.rotation]:[0,0,0],autoMeshId:W,rebakeInFlight:!1,rebakeQueuedLightDir:null},Qe=null,go=0,kn=-1,Xt=null;function Zt(){Qe=null,Xt=null,kn=-1}function tr(){let N=Qe;if(!N||N.polygonCount!==M.polygons.length)return M.polygons;if(Xt&&kn===go)return Xt;let X=N.vertices,ue=new Array(N.polygonCount);for(let ye=0;ye<N.polygonCount;ye++){let Oe=M.polygons[ye],pe=ye*9;ue[ye]={...Oe,color:N.colors?.[ye]??Oe.color,vertices:[[X[pe],X[pe+1],X[pe+2]],[X[pe+3],X[pe+4],X[pe+5]],[X[pe+6],X[pe+7],X[pe+8]]]}}return Xt=ue,kn=go,ue}function nr(N,X){let ue=N?.stableTriangleUpdateMode==="color-only";M.stableTriangleColorFrame++;let ye=M.stableDom&&!X;if(ye||Ne(M.polygons),M.stableDom&&!M.hasBuckets){let Oe={doc:l,directionalLight:ut(i.directionalLight),ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed},pe=M.rendered.length===M.polygons.length&&M.rendered.every(He=>He.kind==="triangle"),xe=M.stableDom&&!X,Ge=pe||xe?{}:Ot(M.polygons,Oe);pe||vt(M.wrapper,Ge);let qe={...Oe,solidPaintDefaults:Ge,optimizeStableTriangleStyle:!0,stableTriangleDebug:N?.stableTriangleDebug,stableTriangleUpdateMode:N?.stableTriangleUpdateMode,stableTriangleColorPolicy:N?.stableTriangleColorPolicy,stableTriangleColorSteps:N?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:N?.stableTriangleColorFreezeFrames,stableTriangleColorBudget:N?.stableTriangleColorBudget,stableTriangleColorMaxAge:N?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:N?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:N?.stableTriangleMatrixDecimals,stableTriangleColorFrame:M.stableTriangleColorFrame};if(jn(M.rendered,M.polygons,qe))return ue||(_(M),fe(M,!0),X&&ht()),!0}return ye&&Ne(M.polygons),!1}let Et={get polygons(){return tr()},set polygons(N){Zt(),M.polygons=N},element:E,id:m.id,get transform(){return B},remove(){Y++,E.parentNode&&E.parentNode.removeChild(E),H(M),f.delete(M),b.delete(E),z(M),O(M),ht(),nt()},setPolygons(N,X){Y++,I=X?.merge??I,U=X?.stableDom??U,M.stableDom=U,M.voxelSource=void 0,M.polygons=ie(N,I),O(M),z(M),Zt(),Et.polygons=M.polygons;let ue=X?.recomputeAutoCenter??!0;nr(X,ue)||(Me(M),ue&&ht())},[xi](N,X){let ue=X?.merge??I,ye=X?.stableDom??U;if(!N.solidTriangles||!ye||ue||m.meshResolution!==void 0||M.hasBuckets||N.polygonCount!==M.polygons.length||N.vertices.length<N.polygonCount*9||M.rendered.length!==N.polygonCount)return!1;for(let xe=0;xe<M.rendered.length;xe++){let Ge=M.rendered[xe],qe=M.polygons[xe];if(Ge?.kind!=="triangle"||Ge.polygonIndex!==xe||!qe||qe.vertices.length!==3||qe.texture||qe.material?.texture)return!1}let Oe=X?.recomputeAutoCenter??!0;if(!Oe){let xe=M.stableTriangleColorFrame+1,Ge={doc:l,directionalLight:ut(i.directionalLight),ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,solidPaintDefaults:{},optimizeStableTriangleStyle:!0,stableTriangleDebug:X?.stableTriangleDebug,stableTriangleUpdateMode:X?.stableTriangleUpdateMode,stableTriangleColorPolicy:X?.stableTriangleColorPolicy,stableTriangleColorSteps:X?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:X?.stableTriangleColorFreezeFrames??0,stableTriangleColorBudget:X?.stableTriangleColorBudget,stableTriangleColorMaxAge:X?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:X?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:X?.stableTriangleMatrixDecimals,stableTriangleColorFrame:xe};if(Un(M.rendered,M.polygons,N,Ge))return Y++,I=ue,U=ye,M.stableDom=U,M.voxelSource=void 0,M.stableTriangleColorFrame=xe,Qe=N,go++,Xt=null,kn=-1,Q(M)?(_(M),fe(M,!0)):ae(M),!0}Y++,I=ue,U=ye,M.stableDom=U,M.voxelSource=void 0;let pe=N.vertices;for(let xe=0;xe<N.polygonCount;xe++){let Ge=M.polygons[xe],qe=N.colors?.[xe];qe&&(Ge.color=qe);let He=Ge.vertices,Ke=xe*9;He[0][0]=pe[Ke],He[0][1]=pe[Ke+1],He[0][2]=pe[Ke+2],He[1][0]=pe[Ke+3],He[1][1]=pe[Ke+4],He[1][2]=pe[Ke+5],He[2][0]=pe[Ke+6],He[2][1]=pe[Ke+7],He[2][2]=pe[Ke+8]}return Zt(),Et.polygons=M.polygons,nr(X,Oe)},updatePolygon(N,X){let ue=typeof N=="number"?N:M.polygons.indexOf(N);if(ue<0&&typeof N!="number"&&Qe&&(ue=tr().indexOf(N)),ue<0||ue>=M.polygons.length)return;Zt(),M.voxelSource=void 0,Object.assign(M.polygons[ue],X);let ye=Object.keys(X);Wt(M,ue,ye)||Me(M)},async setPolygonsChunked(N,X){let ue=++Y;I=X?.merge??I,U=X?.stableDom??U,M.stableDom=U,M.voxelSource=void 0,M.polygons=ie(N,I),Zt(),Et.polygons=M.polygons,Ne(M.polygons);let ye=X?.recomputeAutoCenter??!0;if(!await Rn(M,()=>M.disposed||ue!==Y)){H(M);return}ye&&ht()},setTransform(N){let X=M.castShadow,ue=M.receiveShadow;N.castShadow!==void 0&&(M.castShadow=!!N.castShadow),N.receiveShadow!==void 0&&(M.receiveShadow=!!N.receiveShadow),B={...B,...N};let ye=Yn(B);E.style.transform=ye??"",mt(M,B.rotation),N.rotation!==void 0&&fe(M,!0),M.castShadow!==X&&(M.voxelSource&&Me(M),Xe(M),nt()),M.receiveShadow!==ue&&(M.receiveShadow||jo(M),k(),Le()),(N.position!==void 0||N.scale!==void 0)&&(M.castShadow||M.receiveShadow)&&(nt(),k(),Le())},dispose(){if(!M.disposed){M.disposed=!0,Y++,E.parentNode&&E.parentNode.removeChild(E),H(M);try{a.dispose()}catch{}f.delete(M),b.delete(E),ht(),nt()}},rebakeAtlas(){M.bakedRotation=B.rotation?[...B.rotation]:[0,0,0];let N=i.directionalLight?.direction??[.4,-.7,.59],X=(0,ne.inverseRotateVec3)(N,M.bakedRotation);mo(M,X)},getPosition(){return B.position},getRotation(){return B.rotation},getScale(){return B.scale},getPolygons(){return Et.polygons}};return M.handle=Et,Ze=M,b.set(E,M),f.add(M),Me(M),mt(M,B.rotation),ht(),nt(),M.receiveShadow&&(k(),Le()),Et}function ts(a){let m=!!i.autoCenter,S=i.strategies,E=i.seamBleed,W=i.textureLighting,B=i.directionalLight?.direction,I=i.shadow,U=Pi(a);i={...i,...U},x.options.current=i,q(g,i);let Y=!!i.autoCenter;for(let Qe of f)mt(Qe,Qe.handle.transform.rotation);let de=a.strategies!==void 0&&!qr(a.strategies,S),ie=Object.prototype.hasOwnProperty.call(a,"seamBleed")&&U.seamBleed!==E;if(de||ie)for(let Qe of f)Me(Qe);m!==Y&&ht();let K=a.textureLighting!==void 0&&W!==i.textureLighting,se=i.directionalLight?.direction,te=a.directionalLight!==void 0&&!Kr(B,se),Ne=i.shadow,Ze=a.shadow!==void 0&&!Jr(I,Ne),M=te||Ze;if(K){if(!de&&!ie)for(let Qe of f)Me(Qe);nt(),k(),Le()}else M&&(Ze&&k(),Le());Ze&&a.shadow?.lift!==I?.lift&&nt()}function ns(){return i}function os(){D(g);for(let a of f)fe(a)}function rs(){let a=[];for(let m of f)a.push(m.handle);return a}function is(a){let m=a;for(;m;){if(m instanceof HTMLElement){let S=b.get(m);if(S&&!S.disposed)return S.handle;if(m.classList.contains("polycss-mesh"))return null}m=m.parentElement}return null}function ss(){let a=Array.from(f);for(let m of a)try{m.handle.dispose()}catch{}p.parentNode&&p.parentNode.removeChild(p)}return{add:es,setOptions:ts,destroy:ss,host:e,camera:t,cameraEl:p,applyCamera:os,getOptions:ns,meshes:rs,findMeshByElement:is,previewBakedSolidLighting:le,commitBakedSolidLighting:uo,clearBakedSolidLightingPreview:po}}var Wo=require("@layoutit/polycss-core"),_a=32e3;function rn(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Wo.createIsometricCamera)(n),o=`${e.perspective??_a}px`;return{get state(){return t.state},update(r){t.update(r)},getStyle(r){return t.getStyle(r)},type:"perspective",perspectiveStyle:o}}function sn(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Wo.createIsometricCamera)(n);return{get state(){return t.state},update(o){t.update(o)},getStyle(o){return t.getStyle(o)},type:"orthographic",perspectiveStyle:"none"}}var Ra=typeof HTMLElement<"u"?HTMLElement:class{},ka=["perspective","rot-x","rot-y","zoom","directional-direction","directional-color","directional-intensity","ambient-color","ambient-intensity","texture-lighting","texture-quality","auto-center"];function We(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function Da(e){return e==="false"?!1:We(e)}function Yo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Oa(e){if(e==="baked"||e==="dynamic")return e}function Ha(e){return e==="auto"?"auto":We(e)}function Ia(e){return typeof e.getCamera=="function"}var _e=class extends Ra{constructor(){super(...arguments);this._scene=null;this._implicitCamera=null}static get observedAttributes(){return[...ka]}getScene(){return this._scene}_findAncestorCamera(){let t=this.parentElement;for(;t;){if(Ia(t)){let o=t.getCamera();if(o)return o}t=t.parentElement}return null}_buildImplicitCamera(){let t=Da(this.getAttribute("perspective")),o=We(this.getAttribute("rot-x")),r=We(this.getAttribute("rot-y")),i=We(this.getAttribute("zoom")),s=We(this.getAttribute("distance")),c=Yo(this.getAttribute("target")),l={...o!==void 0?{rotX:o}:{},...r!==void 0?{rotY:r}:{},...i!==void 0?{zoom:i}:{},...s!==void 0?{distance:s}:{},...c!==void 0?{target:c}:{}};return t===!1?sn(l):t!==void 0?rn({...l,perspective:t}):sn(l)}_readNonCameraOptions(){let t=this._readDirectionalLight(),o=this._readAmbientLight(),r={};r.textureLighting=Oa(this.getAttribute("texture-lighting"))??"baked";let i=Ha(this.getAttribute("texture-quality"));return i!==void 0&&(r.textureQuality=i),r.autoCenter=this.hasAttribute("auto-center"),t&&(r.directionalLight=t),o&&(r.ambientLight=o),r}_readDirectionalLight(){let t=Yo(this.getAttribute("directional-direction")),o=this.getAttribute("directional-color")||void 0,r=We(this.getAttribute("directional-intensity"));if(!t&&!o&&r===void 0)return;let i={direction:t??[.4,-.7,.59]};return o&&(i.color=o),r!==void 0&&(i.intensity=r),i}_readAmbientLight(){let t=this.getAttribute("ambient-color")||void 0,o=We(this.getAttribute("ambient-intensity"));if(!t&&o===void 0)return;let r={};return t&&(r.color=t),o!==void 0&&(r.intensity=o),r}connectedCallback(){if(this._scene)return;let t=this._findAncestorCamera(),o;t?(o=t,this._implicitCamera=null):(this._implicitCamera=this._buildImplicitCamera(),o=this._implicitCamera),this._scene=Ci(this,{camera:o,...this._readNonCameraOptions()}),this.dispatchEvent(new CustomEvent("polycss:scene-ready",{bubbles:!1}))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null),this._implicitCamera=null}attributeChangedCallback(t,o,r){if(o!==r&&this._scene){if(this._implicitCamera&&["rot-x","rot-y","zoom","distance","target"].includes(t)){let s=We(this.getAttribute("rot-x")),c=We(this.getAttribute("rot-y")),l=We(this.getAttribute("zoom")),p=We(this.getAttribute("distance")),g=Yo(this.getAttribute("target"));s!==void 0&&this._implicitCamera.update({rotX:s}),c!==void 0&&this._implicitCamera.update({rotY:c}),l!==void 0&&this._implicitCamera.update({zoom:l}),p!==void 0&&this._implicitCamera.update({distance:p}),g!==void 0&&this._implicitCamera.update({target:g}),this._scene.applyCamera();return}this._scene.setOptions(this._readNonCameraOptions())}}};var qn=require("@layoutit/polycss-core"),Fa=typeof HTMLElement<"u"?HTMLElement:class{},Va=["src","mtl","mesh-resolution","position","scale","rotation","auto-center","cast-shadow","receive-shadow","target-size","default-color","palette","include-objects","exclude-objects"];function an(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Ei(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return an(e)}}function Xo(e){if(!e)return;let n=e.split(",").map(t=>t.trim()).filter(t=>t.length>0);return n.length>0?n:void 0}function Ba(e){let n=e.getAttribute("target-size"),t=e.getAttribute("default-color"),o=Xo(e.getAttribute("palette")),r=Xo(e.getAttribute("include-objects")),i=Xo(e.getAttribute("exclude-objects")),s=n!==null?parseFloat(n):NaN,c={};return Number.isFinite(s)&&(c.targetSize=s),t&&(c.defaultColor=t),o&&(c.palette=o),r&&(c.includeObjects=r),i&&(c.excludeObjects=i),Object.keys(c).length>0?c:void 0}function za(e){return e.closest("poly-scene")??null}function Na(e){if(e.length===0)return e;let n=(0,qn.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,r=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&r===0)return e;let i=s=>[s[0]-t,s[1]-o,s[2]-r];return e.map(s=>({...s,vertices:s.vertices.map(i),...s.textureTriangles?.length?{textureTriangles:s.textureTriangles.map(c=>({...c,vertices:c.vertices.map(i)}))}:null}))}var xt=class extends Fa{constructor(){super(...arguments);this._handle=null;this._parseResult=null;this._loadToken=0}static get observedAttributes(){return[...Va]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r){if(t==="src"||t==="mtl"||t==="mesh-resolution"||t==="target-size"||t==="default-color"||t==="palette"||t==="include-objects"||t==="exclude-objects"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform({position:an(this.getAttribute("position")),scale:Ei(this.getAttribute("scale")),rotation:an(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")})}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}this._parseResult=null}async _maybeLoad(){let t=this.getAttribute("src");if(!t)return;let o=za(this);if(!o)return;let r=++this._loadToken,i=this.getAttribute("mtl")||void 0,c=this.getAttribute("mesh-resolution")==="lossless"?"lossless":void 0,l=Ba(this),p;try{let f=i||c!==void 0||l?{...i?{mtlUrl:i}:{},...c!==void 0?{meshResolution:c}:{},...l?{objOptions:l}:{}}:void 0;p=await(0,qn.loadMesh)(t,f)}catch(f){this.dispatchEvent(new CustomEvent("polycss:error",{detail:f,bubbles:!0}));return}if(r!==this._loadToken){try{p.dispose()}catch{}return}let g=o.getScene();if(!g){try{p.dispose()}catch{}return}this.hasAttribute("auto-center")&&(p={...p,polygons:Na(p.polygons)}),this._parseResult=p,this._handle=g.add(p,{position:an(this.getAttribute("position")),scale:Ei(this.getAttribute("scale")),rotation:an(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}),this.dispatchEvent(new CustomEvent("polycss:loaded",{detail:{polygons:this._handle.polygons},bubbles:!0}))}};var zt=require("@layoutit/polycss-core"),Ga=typeof HTMLElement<"u"?HTMLElement:class{},$a=["src","width","height","position","rotation","scale","allow","loading","referrerpolicy","sandbox","title"];function Zo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Ua(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Zo(e)}}function Ti(e,n){if(e===null)return n;let t=parseFloat(e);return Number.isFinite(t)?t:n}function ja(e){let n=e.closest("poly-scene");return n?n.querySelector(".polycss-scene"):null}function Wa(e,n,t,o,r){let i=typeof t=="number"?t:t?.[0]??1,s=typeof t=="number"?t:t?.[1]??1,c=typeof t=="number"?t:t?.[2]??1,l=i!==1||s!==1||c!==1,p=!!n&&(!!n[0]||!!n[1]||!!n[2]),g=(e?.[1]??0)*zt.BASE_TILE,x=(e?.[0]??0)*zt.BASE_TILE,f=(e?.[2]??0)*zt.BASE_TILE,b=[];return b.push(`translate3d(${g}px, ${x}px, ${f}px)`),p&&(n[0]&&b.push(`rotateY(${-n[0]}deg)`),n[1]&&b.push(`rotateX(${-n[1]}deg)`),n[2]&&b.push(`rotateZ(${-n[2]}deg)`)),l&&b.push(`scale3d(${i}, ${s}, ${c})`),b.push(`translate(${-o/2}px, ${-r/2}px)`),b.join(" ")}var ln=class extends Ga{constructor(){super(...arguments);this._wrapper=null;this._iframe=null}static get observedAttributes(){return[...$a]}getIframeElement(){return this._iframe}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o!==r&&!(!this._wrapper||!this._iframe)){if(t==="src"){this._iframe.src=this.getAttribute("src")??"";return}if(t==="allow"||t==="loading"||t==="referrerpolicy"||t==="sandbox"||t==="title"){let i=this.getAttribute(t);i===null?this._iframe.removeAttribute(t):this._iframe.setAttribute(t,i);return}this._applyGeometry()}}_mount(){let t=ja(this);if(!t)return;let o=this.ownerDocument;if(!o)return;let r=o.createElement("div");r.className="polycss-iframe",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.transformOrigin="0 0",r.style.transformStyle="preserve-3d";let i=o.createElement("iframe");i.style.display="block",i.style.border="0",i.style.background="#000";let s=this.getAttribute("src");s&&(i.src=s);let c=this.getAttribute("allow");c&&i.setAttribute("allow",c);for(let l of["loading","referrerpolicy","sandbox","title"]){let p=this.getAttribute(l);p!==null&&i.setAttribute(l,p)}r.appendChild(i),t.appendChild(r),this._wrapper=r,this._iframe=i,this._applyGeometry()}_applyGeometry(){if(!this._wrapper||!this._iframe)return;let t=Ti(this.getAttribute("width"),16),o=Ti(this.getAttribute("height"),9),r=t*zt.BASE_TILE,i=o*zt.BASE_TILE;this._iframe.style.width=`${r}px`,this._iframe.style.height=`${i}px`;let s=Zo(this.getAttribute("position")),c=Zo(this.getAttribute("rotation")),l=Ua(this.getAttribute("scale"));this._wrapper.style.transform=Wa(s,c,l,r,i)}_teardown(){this._wrapper?.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null,this._iframe=null}};var Ya=typeof HTMLElement<"u"?HTMLElement:class{},Xa=["vertices","color","texture","uvs","position","scale","rotation"];function Ai(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Qo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Za(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Qo(e)}}function Qa(e){return e.closest("poly-scene")??null}var cn=class extends Ya{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...Xa]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){o!==r&&(this._tearDown(),this.isConnected&&this._mount())}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=Qa(this);if(!t)return;let o=t.getScene();if(!o)return;let r=Ai(this.getAttribute("vertices"));if(!r||!Array.isArray(r)||r.length<3)return;let i=this.getAttribute("color")||void 0,s=this.getAttribute("texture")||void 0,c=Ai(this.getAttribute("uvs"))??void 0,l={};for(let x of Array.from(this.attributes))x.name.startsWith("data-")&&(l[x.name.slice(5)]=x.value);let g={polygons:[{vertices:r,...i!==void 0?{color:i}:{},...s!==void 0?{texture:s}:{},...c!==void 0?{uvs:c}:{},...Object.keys(l).length>0?{data:l}:{}}],objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(g,{position:Qo(this.getAttribute("position")),scale:Za(this.getAttribute("scale")),rotation:Qo(this.getAttribute("rotation"))})}};var wi=require("@layoutit/polycss-core"),qa=typeof HTMLElement<"u"?HTMLElement:class{},Ka=["size","thickness","negative","x-color","y-color","z-color"];function Ja(e){return e.closest("poly-scene")??null}function Mi(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}var dn=class extends qa{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...Ka]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){o!==r&&this._handle&&this._remount()}_polygons(){return(0,wi.axesHelperPolygons)({size:Mi(this.getAttribute("size")),thickness:Mi(this.getAttribute("thickness")),negative:this.hasAttribute("negative"),xColor:this.getAttribute("x-color")??void 0,yColor:this.getAttribute("y-color")??void 0,zColor:this.getAttribute("z-color")??void 0})}_mount(){let t=Ja(this);if(!t)return;let o=t.getScene();if(!o)return;let r={polygons:this._polygons(),objectUrls:[],dispose:()=>{},warnings:[]};this._handle=o.add(r,{excludeFromAutoCenter:!0,merge:!1})}_remount(){this._tearDown(),this._mount()}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}};var Ri=require("@layoutit/polycss-core"),el=typeof HTMLElement<"u"?HTMLElement:class{},tl=["direction","target","distance","size","color"],nl=5,ol=.35,rl="#ffd54a";function il(e){return e.closest("poly-scene")??null}function Li(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function _i(e,n){if(e==null)return n;let t=parseFloat(e);return Number.isFinite(t)?t:n}var un=class extends el{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...tl]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r&&this._handle){if(t==="size"||t==="color"){this._remount();return}this._handle.setTransform({position:this._meshPosition()})}}_meshPosition(){let t=Li(this.getAttribute("direction"));if(!t)return;let o=Li(this.getAttribute("target"))??[0,0,0],r=_i(this.getAttribute("distance"),nl),[i,s,c]=t,l=Math.hypot(i,s,c)||1;return[o[0]+i/l*r,o[1]+s/l*r,o[2]+c/l*r]}_mount(){let t=il(this);if(!t)return;let o=t.getScene();if(!o)return;let r=_i(this.getAttribute("size"),ol),i=this.getAttribute("color")??rl,s={polygons:(0,Ri.octahedronPolygons)({center:[0,0,0],size:r,color:i}),objectUrls:[],dispose:()=>{},warnings:[]};this._handle=o.add(s,{position:this._meshPosition(),excludeFromAutoCenter:!0,merge:!1})}_remount(){this._tearDown(),this._mount()}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}};var ki=require("@layoutit/polycss-core");var Kn={drag:!0,wheel:!0,dolly:!1,invert:!1,minZoom:.1,maxZoom:10,minDistance:0,maxDistance:1/0,animate:!1};function Nt(e,n){let t;return n.animate===!1?t=!1:n.animate?t={speed:n.animate.speed??.3,axis:n.animate.axis??"y",pauseOnInteraction:n.animate.pauseOnInteraction??!0}:t=e.animate,{drag:n.drag??e.drag,wheel:n.wheel??e.wheel,dolly:n.dolly??e.dolly,invert:n.invert??e.invert,minZoom:n.minZoom??e.minZoom,maxZoom:n.maxZoom??e.maxZoom,minDistance:n.minDistance??e.minDistance,maxDistance:n.maxDistance??e.maxDistance,animate:t}}function pn(e){return e===!0?-1:e===!1?1:e}function Gt(){let e=[],n=[],t=[];function o(s){return s==="change"?e:s==="start"?n:t}function r(s){if(e.length===0)return;let c={type:"change",camera:s()},l=e.slice();for(let p of l)try{p(c)}catch(g){console.error("[polycss] controls 'change' listener threw:",g)}}function i(s,c){let l=s==="start"?n:t;if(l.length===0)return;let p={type:s,camera:c()},g=l.slice();for(let x of g)try{x(p)}catch(f){console.error(`[polycss] controls '${s}' listener threw:`,f)}}return{changeListeners:e,startListeners:n,endListeners:t,listenerArray:o,emitChange:r,emitInteraction:i}}function $t(e){return()=>{let n=e.camera.state,t=n.target??[0,0,0];return{rotX:n.rotX??0,rotY:n.rotY??0,zoom:n.zoom??1,target:[t[0],t[1],t[2]],distance:n.distance??0}}}function Jn(e,n,t,o,r,i){let s=!1,c=null;return{onWheel:g=>{let x=n();if(!x.wheel||t())return;g.preventDefault();let f=g.deltaMode===1?16:g.deltaMode===2?100:1,b=g.deltaY*f;g.ctrlKey?b*=10:b*=3;let y=e.camera.state;if(x.dolly){let P=y.distance??0,v=Math.max(x.minDistance,Math.min(x.maxDistance,P+b*.05));e.camera.update({distance:v})}else{let P=Math.exp(-b*513e-6),v=y.zoom??1,C=Math.max(x.minZoom,Math.min(x.maxZoom,v*P));e.camera.update({zoom:C})}e.applyCamera(),s||(s=!0,i("start",o)),r(o),c!==null&&clearTimeout(c),c=setTimeout(()=>{c=null,s=!1,i("end",o)},150)},teardown:()=>{c!==null&&(clearTimeout(c),c=null),s=!1}}}function eo(e,n,t,o,r,i,s){let c=null,l=0,p=b=>{if(c===null||o())return;let y=t();if(!y.animate){c=null;return}if(r())l=b;else{let P=Math.min(50,l?b-l:16.67);l=b;let v=y.animate.speed*(P/16.67),C=n.camera.state;if(y.animate.axis==="x"){let F=(((C.rotX??65)+v)%360+360)%360;n.camera.update({rotX:F})}else{let F=(((C.rotY??45)+v)%360+360)%360;n.camera.update({rotY:F})}n.applyCamera(),s(i)}c=e.requestAnimationFrame(p)};return{start:()=>{c!==null||!t().animate||o()||(l=0,c=e.requestAnimationFrame(p))},stop:()=>{c!==null&&(e.cancelAnimationFrame(c),c=null)},isRunning:()=>c!==null}}function Di(e,n={}){let t=Nt(Kn,n),o=e.host,r=o.ownerDocument?.defaultView??globalThis,i=null,s={x:0,y:0},c=!1,l=!1,p=Gt(),g=$t(e),{changeListeners:x,startListeners:f,endListeners:b,listenerArray:y,emitChange:P,emitInteraction:v}=p,C=eo(r,e,()=>t,()=>l,()=>c,g,P),F=d=>{if(!(!t.drag||l)&&i===null&&d.isPrimary!==!1){d.preventDefault(),i=d.pointerId,s={x:d.clientX,y:d.clientY},o.style.cursor="grabbing";try{d.target.setPointerCapture(d.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),v("start",g)}},k=d=>{if(i===null||d.pointerId!==i||!t.drag||l)return;d.preventDefault();let T=d.clientX-s.x,w=d.clientY-s.y;s={x:d.clientX,y:d.clientY};let R=pn(t.invert),L=T/4*R,re=w/4*R,_=e.camera.state;if(d.shiftKey){let j=_.rotX??65,Q=_.rotY??45,ae=Math.max(.01,_.zoom??1),be=Math.cos(j*Math.PI/180),fe=be>=0?Math.max(.1,be):Math.min(-.1,be),ge=Math.cos(Q*Math.PI/180),we=Math.sin(Q*Math.PI/180),Se=ae*ki.BASE_TILE,ke=(T*we-w*ge/fe)/Se,Ye=-(T*ge+w*we/fe)/Se,tt=_.target??[0,0,0];e.camera.update({target:[tt[0]+ke,tt[1]+Ye,tt[2]]})}else{let j=Math.max(0,Math.min(89,(_.rotX??65)-re)),Q=(((_.rotY??45)-L)%360+360)%360;e.camera.update({rotX:j,rotY:Q})}e.applyCamera(),P(g)},z=d=>{if(i===d.pointerId){i=null,o.style.cursor=t.drag&&!l?"grab":"";try{d.target.releasePointerCapture(d.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),v("end",g)}},O=Jn(e,()=>t,()=>l,g,P,v);function Z(){o.addEventListener("pointerdown",F),o.addEventListener("pointermove",k),o.addEventListener("pointerup",z),o.addEventListener("pointercancel",z),o.addEventListener("wheel",O.onWheel,{passive:!1}),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function q(){o.removeEventListener("pointerdown",F),o.removeEventListener("pointermove",k),o.removeEventListener("pointerup",z),o.removeEventListener("pointercancel",z),o.removeEventListener("wheel",O.onWheel),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",O.teardown()}Z(),C.start();function D(d){let T=!!t.animate;t=Nt(t,d),!l&&i===null&&(o.style.cursor=t.drag?"grab":"");let w=!!t.animate;T&&!w?C.stop():!T&&w&&C.start()}function H(){l&&(l=!1,Z(),C.start())}function V(){l||(l=!0,q(),C.stop(),i=null,c=!1,O.teardown())}function G(){V(),x.length=0,f.length=0,b.length=0}function A(d,T){let w=y(d);w.includes(T)||w.push(T)}function h(d,T){let w=y(d),R=w.indexOf(T);R>=0&&w.splice(R,1)}function u(d,T){return y(d).includes(T)}return{update:D,resume:H,pause:V,destroy:G,addEventListener:A,removeEventListener:h,hasEventListener:u}}function oe(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function to(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Re(e){if(e!==null)return!(e==="false"||e==="0")}function no(e){if(e===null)return;if(e==="true")return!0;if(e==="false")return!1;let n=parseFloat(e);return Number.isFinite(n)?n:!0}function oo(e){if(e==="x"||e==="y")return e}var sl=typeof HTMLElement<"u"?HTMLElement:class{},al=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],mn=class extends sl{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...al]}getControls(){return this._controls}_readAnimate(){let t=oe(this.getAttribute("animate-speed")),o=oo(this.getAttribute("animate-axis")),r=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...r!==null?{pauseOnInteraction:Re(r)}:{}}}_readOptions(){let t={},o=Re(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let r=Re(this.getAttribute("wheel"));r!==void 0&&(t.wheel=r),this.hasAttribute("dolly")&&(t.dolly=!0);let i=oe(this.getAttribute("min-distance"));i!==void 0&&(t.minDistance=i);let s=oe(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=no(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=oe(this.getAttribute("zoom-min")),p=oe(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),p!==void 0&&(t.maxZoom=p),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=Di(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var Oi=require("@layoutit/polycss-core");function Hi(e,n={}){let t=Nt(Kn,n),o=e.host,r=o.ownerDocument?.defaultView??globalThis,i=null,s={x:0,y:0},c=!1,l=!1,p=!1,g={x:0,y:0},x=Gt(),f=$t(e),{changeListeners:b,startListeners:y,endListeners:P,listenerArray:v,emitChange:C,emitInteraction:F}=x,k=eo(r,e,()=>t,()=>l,()=>c,f,C),z=_=>{if(!(!t.drag||l)&&i===null&&_.isPrimary!==!1){_.preventDefault(),i=_.pointerId,s={x:_.clientX,y:_.clientY},o.style.cursor="grabbing";try{_.target.setPointerCapture(_.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),F("start",f)}},O=_=>{if(i===null||_.pointerId!==i||!t.drag||l)return;_.preventDefault();let j=_.clientX-s.x,Q=_.clientY-s.y;s={x:_.clientX,y:_.clientY};let ae=e.camera.state;if(_.shiftKey){let be=pn(t.invert),fe=j/4*be,ge=Q/4*be,we=(ae.rotX??65)-ge,Se=(((ae.rotY??45)-fe)%360+360)%360;e.camera.update({rotX:we,rotY:Se})}else{let be=ae.rotX??65,fe=ae.rotY??45,ge=Math.max(.01,ae.zoom??1),we=Math.cos(be*Math.PI/180),Se=we>=0?Math.max(.1,we):Math.min(-.1,we),ke=Math.cos(fe*Math.PI/180),Ye=Math.sin(fe*Math.PI/180),tt=ge*Oi.BASE_TILE,mt=(j*Ye-Q*ke/Se)/tt,Ct=-(j*ke+Q*Ye/Se)/tt,ft=ae.target??[0,0,0];e.camera.update({target:[ft[0]+mt,ft[1]+Ct,ft[2]]})}e.applyCamera(),C(f)},Z=_=>{if(i===_.pointerId){i=null,o.style.cursor=t.drag&&!l?"grab":"";try{_.target.releasePointerCapture(_.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),F("end",f)}},q=_=>{_.preventDefault()},D=_=>{_.button===2&&(p=!0,g={x:_.clientX,y:_.clientY},t.animate&&t.animate.pauseOnInteraction&&(c=!0),F("start",f))},H=_=>{if(!p||!t.drag)return;let j=_.clientX-g.x,Q=_.clientY-g.y;g={x:_.clientX,y:_.clientY};let ae=pn(t.invert),be=j/4*ae,fe=Q/4*ae,ge=e.camera.state,we=(ge.rotX??65)-fe,Se=(((ge.rotY??45)-be)%360+360)%360;e.camera.update({rotX:we,rotY:Se}),e.applyCamera(),C(f)},V=_=>{_.button===2&&p&&(p=!1,F("end",f))},G=Jn(e,()=>t,()=>l,f,C,F);function A(){o.addEventListener("pointerdown",z),o.addEventListener("pointermove",O),o.addEventListener("pointerup",Z),o.addEventListener("pointercancel",Z),o.addEventListener("wheel",G.onWheel,{passive:!1}),o.addEventListener("contextmenu",q),o.addEventListener("mousedown",D),o.addEventListener("mousemove",H),o.addEventListener("mouseup",V),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function h(){o.removeEventListener("pointerdown",z),o.removeEventListener("pointermove",O),o.removeEventListener("pointerup",Z),o.removeEventListener("pointercancel",Z),o.removeEventListener("wheel",G.onWheel),o.removeEventListener("contextmenu",q),o.removeEventListener("mousedown",D),o.removeEventListener("mousemove",H),o.removeEventListener("mouseup",V),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",G.teardown()}A(),k.start();function u(_){let j=!!t.animate;t=Nt(t,_),!l&&i===null&&(o.style.cursor=t.drag?"grab":"");let Q=!!t.animate;j&&!Q?k.stop():!j&&Q&&k.start()}function d(){l&&(l=!1,A(),k.start())}function T(){l||(l=!0,h(),k.stop(),i=null,c=!1,p=!1,G.teardown())}function w(){T(),b.length=0,y.length=0,P.length=0}function R(_,j){let Q=v(_);Q.includes(j)||Q.push(j)}function L(_,j){let Q=v(_),ae=Q.indexOf(j);ae>=0&&Q.splice(ae,1)}function re(_,j){return v(_).includes(j)}return{update:u,resume:d,pause:T,destroy:w,addEventListener:R,removeEventListener:L,hasEventListener:re}}var ll=typeof HTMLElement<"u"?HTMLElement:class{},cl=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],fn=class extends ll{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...cl]}_readAnimate(){let t=oe(this.getAttribute("animate-speed")),o=oo(this.getAttribute("animate-axis")),r=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...r!==null?{pauseOnInteraction:Re(r)}:{}}}_readOptions(){let t={},o=Re(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let r=Re(this.getAttribute("wheel"));r!==void 0&&(t.wheel=r),this.hasAttribute("dolly")&&(t.dolly=!0);let i=oe(this.getAttribute("min-distance"));i!==void 0&&(t.minDistance=i);let s=oe(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=no(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=oe(this.getAttribute("zoom-min")),p=oe(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),p!==void 0&&(t.maxZoom=p),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=Hi(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var Gi=require("@layoutit/polycss-core");var dl={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function Ii(e,n){return{enabled:n.enabled??e.enabled,lookEnabled:n.lookEnabled??e.lookEnabled,moveEnabled:n.moveEnabled??e.moveEnabled,jumpEnabled:n.jumpEnabled??e.jumpEnabled,crouchEnabled:n.crouchEnabled??e.crouchEnabled,lookSensitivity:n.lookSensitivity??e.lookSensitivity,invertY:n.invertY??e.invertY,moveSpeed:n.moveSpeed??e.moveSpeed,jumpVelocity:n.jumpVelocity??e.jumpVelocity,gravity:n.gravity??e.gravity,eyeHeight:n.eyeHeight??e.eyeHeight,crouchHeight:n.crouchHeight??e.crouchHeight,groundZ:n.groundZ??e.groundZ,minPitch:n.minPitch??e.minPitch,maxPitch:n.maxPitch??e.maxPitch}}var Fi=new Set(["KeyW","ArrowUp"]),Vi=new Set(["KeyS","ArrowDown"]),Bi=new Set(["KeyA","ArrowLeft"]),zi=new Set(["KeyD","ArrowRight"]),Ni=new Set(["Space"]),qo=new Set(["ControlLeft","ControlRight"]);function $i(e,n={}){let t=Ii(dl,n),o=e.host,r=e.cameraEl,i=o.ownerDocument??document,s=i.defaultView??globalThis,c=Gt(),l=$t(e),{changeListeners:p,startListeners:g,endListeners:x,listenerArray:f,emitChange:b,emitInteraction:y}=c,P=new Set,v=!1,C=!1,F=0,k=0,z=!1,O=[0,0,t.groundZ+t.eyeHeight];function Z($,le){let ce=$*Math.PI/180,De=le*Math.PI/180;return[-Math.sin(ce)*Math.cos(De),-Math.sin(ce)*Math.sin(De),-Math.cos(ce)]}function q(){let $=e.camera.perspectiveStyle,le=$==="none"?0:parseFloat($);return(Number.isFinite(le)&&le>0?le:2e3)/Gi.BASE_TILE}function D(){let $=e.camera.state,le=Z($.rotX??90,$.rotY??0),ce=q();return[O[0]+le[0]*ce,O[1]+le[1]*ce,O[2]+le[2]*ce]}function H(){let $=D();e.camera.update({target:$}),e.applyCamera()}function V(){let $=e.camera.state.target??[0,0,0];O=[$[0],$[1],t.groundZ+t.eyeHeight],H()}let G=()=>{if(!(!t.enabled||!t.lookEnabled||C||v))try{o.requestPointerLock()}catch{}},A=()=>{let $=i.pointerLockElement===o;$!==v&&(v=$,v?(z=!0,y("start",l)):z&&(z=!1,y("end",l)))},h=$=>{if(!v||!t.enabled||!t.lookEnabled||C)return;let le=$.movementX??0,ce=$.movementY??0;if(le===0&&ce===0)return;let De=e.camera.state,Wt=t.lookSensitivity,Xe=t.invertY?-1:1,Le=(((De.rotY??0)-le*Wt)%360+360)%360,Ce=(De.rotX??90)-ce*Wt*Xe;Ce<t.minPitch?Ce=t.minPitch:Ce>t.maxPitch&&(Ce=t.maxPitch);let Be=Z(Ce,Le),ze=q(),Me=[O[0]+Be[0]*ze,O[1]+Be[1]*ze,O[2]+Be[2]*ze];e.camera.update({rotX:Ce,rotY:Le,target:Me}),e.applyCamera(),b(l)},u=$=>Fi.has($)||Vi.has($)||Bi.has($)||zi.has($)||Ni.has($)||qo.has($),d=$=>{if(!(!t.enabled||C)&&u($.code)&&!(!v&&!t.moveEnabled)){if(Ni.has($.code)){if(!t.jumpEnabled)return;$.preventDefault(),!P.has($.code)&&F===0&&k===0&&(F=t.jumpVelocity),P.add($.code);return}qo.has($.code)&&!t.crouchEnabled||!t.moveEnabled&&!qo.has($.code)||($.preventDefault(),P.add($.code))}},T=$=>{u($.code)&&P.delete($.code)},w=()=>{P.clear()},R=null,L=0,re=.05,_=$=>{if(R===null||C)return;let le=Math.min(re,L?($-L)/1e3:.0167);if(L=$,t.enabled){let ce=!1,De=e.camera.state;if(t.moveEnabled){let Ce=0,Be=0;for(let ze of P)Fi.has(ze)?Ce+=1:Vi.has(ze)?Ce-=1:zi.has(ze)?Be+=1:Bi.has(ze)&&(Be-=1);if(Ce!==0||Be!==0){let Me=(De.rotY??0)*Math.PI/180,Yt=-Math.cos(Me),mo=-Math.sin(Me),fo=-Math.sin(Me),ho=Math.cos(Me),nt=Math.hypot(Ce,Be)||1,Rn=t.moveSpeed*le;O[0]+=(Yt*Ce+fo*Be)/nt*Rn,O[1]+=(mo*Ce+ho*Be)/nt*Rn,ce=!0}}let Xe=t.crouchEnabled&&(P.has("ControlLeft")||P.has("ControlRight"))?t.crouchHeight:t.eyeHeight;t.jumpEnabled&&(F!==0||k>0)?(F-=t.gravity*le,k+=F*le,k<=0&&(k=0,F=0)):t.jumpEnabled||(k=0,F=0);let Le=t.groundZ+Xe+k;if(Math.abs(O[2]-Le)>1e-4&&(O[2]=Le,ce=!0),ce){let Ce=D();e.camera.update({target:Ce}),e.applyCamera(),b(l)}}R=s.requestAnimationFrame(_)};function j(){R!==null||C||(L=0,R=s.requestAnimationFrame(_))}function Q(){R!==null&&(s.cancelAnimationFrame(R),R=null)}function ae(){let le=r.ownerDocument?.defaultView?.getComputedStyle(r).perspective??"",ce=parseFloat(le),De=Number.isFinite(ce)&&ce>0?ce:2e3;r.style.setProperty("--polycss-fpv-perspective",`${De}px`),r.classList.add("polycss-fpv-host")}function be(){r.classList.remove("polycss-fpv-host"),r.style.removeProperty("--polycss-fpv-perspective")}function fe(){o.addEventListener("click",G),i.addEventListener("pointerlockchange",A),i.addEventListener("mousemove",h),s.addEventListener("keydown",d),s.addEventListener("keyup",T),s.addEventListener("blur",w),o.style.cursor=t.lookEnabled?"crosshair":"",ae()}function ge(){if(o.removeEventListener("click",G),i.removeEventListener("pointerlockchange",A),i.removeEventListener("mousemove",h),s.removeEventListener("keydown",d),s.removeEventListener("keyup",T),s.removeEventListener("blur",w),o.style.cursor="",P.clear(),v)try{i.exitPointerLock()}catch{}be()}V(),fe(),j();function we($){let le=t.eyeHeight,ce=t.groundZ;t=Ii(t,$),C||(o.style.cursor=t.lookEnabled?"crosshair":""),(t.eyeHeight!==le||t.groundZ!==ce)&&(O[2]=t.groundZ+t.eyeHeight,H(),b(l))}function Se(){C&&(C=!1,fe(),j())}function ke(){C||(C=!0,ge(),Q(),z&&(z=!1,y("end",l)))}function Ye(){ke(),p.length=0,g.length=0,x.length=0}function tt(){if(!(!t.enabled||!t.lookEnabled||C))try{o.requestPointerLock()}catch{}}function mt(){if(v)try{i.exitPointerLock()}catch{}}function Ct(){return v}function ft($,le){let ce=f($);ce.includes(le)||ce.push(le)}function lo($,le){let ce=f($),De=ce.indexOf(le);De>=0&&ce.splice(De,1)}function co($,le){return f($).includes(le)}function uo(){return[O[0],O[1],O[2]]}function po($){O[0]=$[0],O[1]=$[1],O[2]=$[2],H(),b(l)}return{update:we,resume:Se,pause:ke,destroy:Ye,lock:tt,unlock:mt,isLocked:Ct,getOrigin:uo,setOrigin:po,addEventListener:ft,removeEventListener:lo,hasEventListener:co}}var ul=typeof HTMLElement<"u"?HTMLElement:class{},pl=["enabled","look-enabled","move-enabled","jump-enabled","crouch-enabled","look-sensitivity","invert-y","move-speed","jump-velocity","gravity","eye-height","crouch-height","ground-z","min-pitch","max-pitch"],hn=class extends ul{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...pl]}_readOptions(){let t={},o=Re(this.getAttribute("enabled"));o!==void 0&&(t.enabled=o);let r=Re(this.getAttribute("look-enabled"));r!==void 0&&(t.lookEnabled=r);let i=Re(this.getAttribute("move-enabled"));i!==void 0&&(t.moveEnabled=i);let s=Re(this.getAttribute("jump-enabled"));s!==void 0&&(t.jumpEnabled=s);let c=Re(this.getAttribute("crouch-enabled"));c!==void 0&&(t.crouchEnabled=c);let l=oe(this.getAttribute("look-sensitivity"));if(l!==void 0&&(t.lookSensitivity=l),this.hasAttribute("invert-y")){let C=Re(this.getAttribute("invert-y"));C!==void 0&&(t.invertY=C)}let p=oe(this.getAttribute("move-speed"));p!==void 0&&(t.moveSpeed=p);let g=oe(this.getAttribute("jump-velocity"));g!==void 0&&(t.jumpVelocity=g);let x=oe(this.getAttribute("gravity"));x!==void 0&&(t.gravity=x);let f=oe(this.getAttribute("eye-height"));f!==void 0&&(t.eyeHeight=f);let b=oe(this.getAttribute("crouch-height"));b!==void 0&&(t.crouchHeight=b);let y=oe(this.getAttribute("ground-z"));y!==void 0&&(t.groundZ=y);let P=oe(this.getAttribute("min-pitch"));P!==void 0&&(t.minPitch=P);let v=oe(this.getAttribute("max-pitch"));return v!==void 0&&(t.maxPitch=v),t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=$i(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var ml=typeof HTMLElement<"u"?HTMLElement:class{},fl=["perspective","zoom","rot-x","rot-y","target","distance"],gn=class extends ml{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...fl]}getCamera(){return this._camera}_readOptions(){return{perspective:oe(this.getAttribute("perspective")),zoom:oe(this.getAttribute("zoom")),rotX:oe(this.getAttribute("rot-x")),rotY:oe(this.getAttribute("rot-y")),target:to(this.getAttribute("target")),distance:oe(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=rn(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o===r||!this._camera||!this._wrapper)return;let i=this._readOptions();if(t==="perspective"){this._camera=rn(i),this._wrapper.style.perspective=this._camera.perspectiveStyle;return}this._camera.update({rotX:i.rotX,rotY:i.rotY,zoom:i.zoom,target:i.target,distance:i.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var hl=typeof HTMLElement<"u"?HTMLElement:class{},gl=["zoom","rot-x","rot-y","target","distance"],Pt=class extends hl{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...gl]}getCamera(){return this._camera}_readOptions(){return{zoom:oe(this.getAttribute("zoom")),rotX:oe(this.getAttribute("rot-x")),rotY:oe(this.getAttribute("rot-y")),target:to(this.getAttribute("target")),distance:oe(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=sn(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o===r||!this._camera)return;let i=this._readOptions();i.zoom!==void 0&&this._camera.update({zoom:i.zoom}),i.rotX!==void 0&&this._camera.update({rotX:i.rotX}),i.rotY!==void 0&&this._camera.update({rotY:i.rotY}),i.target!==void 0&&this._camera.update({target:i.target}),i.distance!==void 0&&this._camera.update({distance:i.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var yn=class extends Pt{};var Ae=require("@layoutit/polycss-core");function Ut(e,n,t){let o=Array.from(e.querySelectorAll("i,b,s,u"));for(let r of o){let i=r.getBoundingClientRect();if(!(i.width<=0||i.height<=0)&&n>=i.left&&n<=i.right&&t>=i.top&&t<=i.bottom)return!0}return!1}function Ui(e,n,t,o){for(let r of e)if(!(o&&!o(r))&&Ut(r.element,n,t))return r;return null}var ro="#ff3653",io="#8adb00",so="#2c8fff",jt=50,ji=60,yl=.6,bl=.0125,vl=.15,xl=.04,Pl=1,Wi=.02,Ko=1.04,Sl=.1,Cl=.25,Qi=1e-4,El=.6,Tl=.8,Al=1,lt={0:1,1:0,2:2},Yi=[{cssAxis:0,sign:1,key:"x",color:ro},{cssAxis:0,sign:-1,key:"-x",color:ro},{cssAxis:1,sign:1,key:"y",color:io},{cssAxis:1,sign:-1,key:"-y",color:io},{cssAxis:2,sign:1,key:"z",color:so},{cssAxis:2,sign:-1,key:"-z",color:so}],Xi=[{cssAxis:0,key:"x",color:ro},{cssAxis:1,key:"y",color:io},{cssAxis:2,key:"z",color:so}],Zi=[{perpAxis:2,axisA:0,axisB:1,key:"xy",color:so},{perpAxis:1,axisA:0,axisB:2,key:"xz",color:io},{perpAxis:0,axisA:1,axisB:2,key:"yz",color:ro}];function Jo(e,n,t,o){let r=t*Math.PI/180,i=o*Math.PI/180,s=[0,0,0];s[e]=n;let c=s[0]*Math.cos(i)-s[1]*Math.sin(i),l=s[0]*Math.sin(i)+s[1]*Math.cos(i),p=s[2];return l*Math.sin(r)+p*Math.cos(r)<0}function Ml(e,n){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return e;let o=parseInt(t[1],16),r=parseInt(t[2],16),i=parseInt(t[3],16);return`rgba(${o}, ${r}, ${i}, ${n})`}function ao(e,n){return!n||n<=0?e:Math.round(e/n)*n}function wl(e){if(e.length===0)return[0,0,0];let n=1/0,t=1/0,o=1/0,r=-1/0,i=-1/0,s=-1/0;for(let c of e)for(let l of c.vertices)l[0]<n&&(n=l[0]),l[0]>r&&(r=l[0]),l[1]<t&&(t=l[1]),l[1]>i&&(i=l[1]),l[2]<o&&(o=l[2]),l[2]>s&&(s=l[2]);return Number.isFinite(n)?[(n+r)/2,(t+i)/2,(o+s)/2]:[0,0,0]}function er(e){if(e.length===0)return ji;let n=1/0,t=1/0,o=1/0,r=-1/0,i=-1/0,s=-1/0;for(let l of e)for(let p of l.vertices)p[0]<n&&(n=p[0]),p[0]>r&&(r=p[0]),p[1]<t&&(t=p[1]),p[1]>i&&(i=p[1]),p[2]<o&&(o=p[2]),p[2]>s&&(s=p[2]);return Number.isFinite(n)?Math.max(r-n,i-t,s-o)*jt*yl:ji}function Ll(e){let{cssAxis:n,sign:t,shaftLengthCss:o,wrapper:r,target:i,startClientX:s,startClientY:c,translationSnap:l,onAxisDelta:p,onMouseDown:g,onMouseUp:x,onDraggingChanged:f}=e,b=o,y=[0,0,0];y[n]=t;let P=r.ownerDocument.createElement("div");P.style.position="absolute",P.style.left="0",P.style.top="0",P.style.width="0",P.style.height="0",P.style.transform=`translate3d(${y[0]*b}px, ${y[1]*b}px, ${y[2]*b}px)`,r.appendChild(P);let v=r.getBoundingClientRect(),C=P.getBoundingClientRect();r.removeChild(P);let F=(C.left-v.left)/b,k=(C.top-v.top)/b,z=F*F+k*k;if(z<Qi)return;g?.(),f?.(!0);let O=q=>{let D=q.clientX-s,H=q.clientY-c,V=(D*F+H*k)/z;V=ao(V,l),p(V,y)},Z=()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Z),window.removeEventListener("pointercancel",Z);let q=D=>{D.stopPropagation(),D.stopImmediatePropagation()};window.addEventListener("click",q,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",q,!0),0),x?.(),f?.(!1)};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Z),window.addEventListener("pointercancel",Z)}function _l(e){let{axisA:n,axisB:t,probeDistanceCss:o,wrapper:r,startClientX:i,startClientY:s,translationSnap:c,onPlaneDelta:l,onMouseDown:p,onMouseUp:g,onDraggingChanged:x}=e,f=[0,0,0];f[n]=1;let b=[0,0,0];b[t]=1;function y(z){let O=r.ownerDocument.createElement("div");O.style.position="absolute",O.style.left="0",O.style.top="0",O.style.width="0",O.style.height="0",O.style.transform=`translate3d(${z[0]*o}px, ${z[1]*o}px, ${z[2]*o}px)`,r.appendChild(O);let Z=r.getBoundingClientRect(),q=O.getBoundingClientRect();return r.removeChild(O),{x:(q.left-Z.left)/o,y:(q.top-Z.top)/o}}let P=y(f),v=y(b),C=P.x*v.y-v.x*P.y;if(Math.abs(C)<Qi)return;p?.(),x?.(!0);let F=z=>{let O=z.clientX-i,Z=z.clientY-s,q=(v.y*O-v.x*Z)/C,D=(-P.y*O+P.x*Z)/C;q=ao(q,c),D=ao(D,c),l(q,D,f,b)},k=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k);let z=O=>{O.stopPropagation(),O.stopImmediatePropagation()};window.addEventListener("click",z,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",z,!0),0),g?.(),x?.(!1)};window.addEventListener("pointermove",F),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)}function Rl(e){let{cssAxis:n,wrapper:t,target:o,startClientX:r,startClientY:i,rotationSnap:s,onAngleDelta:c,onMouseDown:l,onMouseUp:p,onDraggingChanged:g}=e,x=t.getBoundingClientRect(),f=x.left,b=x.top,y=Math.atan2(i-b,r-f),P=0;l?.(),g?.(!0);let v=F=>{let k=Math.atan2(F.clientY-b,F.clientX-f),z=k-y;z>Math.PI?z-=2*Math.PI:z<-Math.PI&&(z+=2*Math.PI),P+=z,y=k;let O=P*180/Math.PI;O=ao(O,s),c(O)},C=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C);let F=k=>{k.stopPropagation(),k.stopImmediatePropagation()};window.addEventListener("click",F,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",F,!0),0),p?.(),g?.(!1)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C)}function qi(e,n={}){let t=null,o=n.mode??"translate",r=n.size??1,i={...n},s=new Map,c=null,l=null,p=[0,0,0];function g(){if(!t)return[0,0,0];let h=t.transform.position??[0,0,0],u=t.transform.rotation??[0,0,0],d=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,T=(0,Ae.rotateVec3)(p,u[0],u[1],u[2]);return[h[0]+d*T[0],h[1]+d*T[1],h[2]+d*T[2]]}function x(h){return l===h?Al:c===h?Tl:El}function f(){for(let[h,u]of s){let d=b(u.spec,x(h));u.handle.setPolygons(d,{recomputeAutoCenter:!1})}}function b(h,u){let T=er(t?.polygons??[])*r,w=T/jt,R=Ml(h.color,u);if(h.kind==="arrow"){let _=e.camera.state,j=Jo(h.cssAxis,h.sign,_.rotX??65,_.rotY??45);return(0,Ae.arrowPolygons)({axis:lt[h.cssAxis],sign:h.sign,shaftLength:w,shaftHalfThickness:w*bl,headLength:w*vl,headHalfThickness:w*xl,color:R,shaft:!j})}if(h.kind==="plane"){let _=e.camera.state,j=_.rotX??65,Q=_.rotY??45,ae=lt[h.perpAxis],be=(ae+1)%3,fe=(ae+2)%3,ge=lt[be],we=lt[fe],Se=Jo(ge,1,j,Q)?-1:1,ke=Jo(we,1,j,Q)?-1:1,Ye=w*Cl;return(0,Ae.planePolygons)({axis:ae,size:w*Sl,offset:[Se*Ye,ke*Ye],color:R})}let re=T*Pl/jt*Ko;return(0,Ae.ringQuadPolygons)({axis:lt[h.cssAxis],outerRadius:re,color:R})}function y(h){return h.kind==="arrow"?"polycss-transform-arrow":h.kind==="plane"?"polycss-transform-plane":"polycss-transform-ring"}function P(){if(o==="translate"){let h=Yi.map(d=>({kind:"arrow",key:d.key,cssAxis:d.cssAxis,sign:d.sign,color:d.color})),u=Zi.map(d=>({kind:"plane",key:d.key,perpAxis:d.perpAxis,axisA:d.axisA,axisB:d.axisB,color:d.color}));return[...h,...u]}return o==="rotate"?Xi.map(h=>({kind:"ring",key:h.key,cssAxis:h.cssAxis,color:h.color})):[]}function v(){if(C(),!t)return;let h={x:i.showX!==!1,y:i.showY!==!1,z:i.showZ!==!1};function u(T){if(T.kind==="arrow"){let L=T.key.replace("-","")[0];return h[L]}if(T.kind==="ring")return h[T.key];let w=["x","y","z"][T.axisA],R=["x","y","z"][T.axisB];return h[w]&&h[R]}let d=g();for(let T of P()){if(!u(T))continue;let w=b(T,x(T.key)),R=e.add({polygons:w,objectUrls:[],warnings:[],dispose:()=>{}},{excludeFromAutoCenter:!0,id:`__poly-gizmo-${T.key}`,position:d}),L=y(T);if(R.element.classList.add("polycss-transform-gizmo",L,`${L}--${T.key}`),T.kind==="ring"){let re=(1-Wi)/Ko,_=(1+Wi)/Ko;R.element.style.setProperty("--ring-inner-ratio",`${re}`),R.element.style.setProperty("--ring-outer-ratio",`${_}`)}s.set(T.key,{handle:R,spec:T})}}function C(){for(let{handle:h}of s.values())h.remove();s.clear(),c=null,l=null}function F(){if(!t)return;let h=g();for(let{handle:u}of s.values())u.setTransform({position:h})}function k(){t&&(s.size===0?v():F())}function z(h){if(t=h,!h){p=[0,0,0],C();return}p=wl(h.polygons),C(),v()}function O(){z(null)}function Z(h){h!==o&&(o=h,t&&(C(),v()))}function q(h,u,d){if(!t||!D)return;let T=d[h.cssAxis],w=lt[h.cssAxis],R=u*T/jt,L=D.slice();L[w]=D[w]+R,t.setTransform({position:L}),F(),i.onObjectChange?.({object:t,position:L}),i.onChange?.()}let D=null,H=null,V=h=>{if(!t||i.enabled===!1)return;let u={x:i.showX!==!1,y:i.showY!==!1,z:i.showZ!==!1};if(o==="translate"){for(let d of Zi){let T=["x","y","z"][d.axisA],w=["x","y","z"][d.axisB];if(!u[T]||!u[w])continue;let R=s.get(d.key);if(R&&Ut(R.handle.element,h.clientX,h.clientY)){h.preventDefault(),h.stopPropagation(),l=d.key,f(),D=(t.transform.position??[0,0,0]).slice(),_l({axisA:d.axisA,axisB:d.axisB,probeDistanceCss:er(t.polygons)*r,wrapper:R.handle.element,target:t,startClientX:h.clientX,startClientY:h.clientY,translationSnap:i.translationSnap??null,onPlaneDelta:(L,re,_,j)=>{if(!t||!D)return;let Q=_[d.axisA],ae=j[d.axisB],be=lt[d.axisA],fe=lt[d.axisB],ge=D.slice();ge[be]+=L*Q/jt,ge[fe]+=re*ae/jt,t.setTransform({position:ge}),F(),i.onObjectChange?.({object:t,position:ge}),i.onChange?.()},onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:L=>{L||(l=null,D=null,f()),i.onDraggingChanged?.(L)}});return}}for(let d of Yi){let T=d.key.replace("-","")[0];if(!u[T])continue;let w=s.get(d.key);if(w&&Ut(w.handle.element,h.clientX,h.clientY)){h.preventDefault(),h.stopPropagation(),l=d.key,f(),D=(t.transform.position??[0,0,0]).slice(),Ll({cssAxis:d.cssAxis,sign:d.sign,shaftLengthCss:er(t.polygons)*r,wrapper:w.handle.element,target:t,startClientX:h.clientX,startClientY:h.clientY,translationSnap:i.translationSnap??null,onAxisDelta:(R,L)=>q(d,R,L),onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:R=>{R||(l=null,D=null,f()),i.onDraggingChanged?.(R)}});return}}}else if(o==="rotate")for(let d of Xi){if(!u[d.key])continue;let T=s.get(d.key);if(T&&Ut(T.handle.element,h.clientX,h.clientY)){h.preventDefault(),h.stopPropagation(),l=d.key,f(),H=(t.transform.rotation??[0,0,0]).slice(),D=(t.transform.position??[0,0,0]).slice(),Rl({cssAxis:d.cssAxis,wrapper:T.handle.element,target:t,startClientX:h.clientX,startClientY:h.clientY,rotationSnap:i.rotationSnap??null,onAngleDelta:w=>{if(!t||!H||!D)return;let R=lt[d.cssAxis],L=[0,0,0];L[R]=1;let re=-w*Math.PI/180,_=(0,Ae.quatFromEulerXYZ)(H),j=(0,Ae.quatFromAxisAngle)(L,re),Q=(0,Ae.eulerXYZFromQuat)((0,Ae.quatMultiply)(j,_)),ae=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,be=(0,Ae.rotateVec3)(p,H[0],H[1],H[2]),fe=(0,Ae.rotateVec3)(p,Q[0],Q[1],Q[2]),ge=[D[0]+ae*(be[0]-fe[0]),D[1]+ae*(be[1]-fe[1]),D[2]+ae*(be[2]-fe[2])];t.setTransform({rotation:Q,position:ge}),F(),i.onObjectChange?.({object:t,rotation:Q,position:ge}),i.onChange?.()},onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:w=>{w||(l=null,H=null,D=null,f(),t?.rebakeAtlas()),i.onDraggingChanged?.(w)}});return}}};e.host.addEventListener("pointerdown",V,{capture:!0});let G=h=>{if(!t||l||i.enabled===!1)return;let u=null;for(let[d,T]of s)if(Ut(T.handle.element,h.clientX,h.clientY)){u=d;break}u!==c&&(c=u,f())};e.host.addEventListener("pointermove",G);function A(){e.host.removeEventListener("pointerdown",V,{capture:!0}),e.host.removeEventListener("pointermove",G),C()}return{attach:z,detach:O,setMode:Z,update:k,destroy:A}}var kl=typeof HTMLElement<"u"?HTMLElement:class{},Dl=["mode","target","size","enabled"];function Ki(e){if(e==="translate"||e==="rotate")return e}var bn=class extends kl{constructor(){super(...arguments);this._tc=null}static get observedAttributes(){return[...Dl]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_findTargetMesh(){let t=this.getAttribute("target");if(!t)return null;let o=this._findScene();if(!o)return null;let r=null;try{r=o.querySelector(`#${t}`)??o.querySelector(t)}catch{r=o.querySelector(`[id="${t}"]`)}return r instanceof xt?r:null}_readOptions(){let t={},o=Ki(this.getAttribute("mode"));o!==void 0&&(t.mode=o);let r=oe(this.getAttribute("size"));r!==void 0&&(t.size=r);let i=this.getAttribute("enabled");return i!==null&&(t.enabled=i!=="false"&&i!=="0"),t.onObjectChange=s=>{this.dispatchEvent(new CustomEvent("polycss:object-change",{bubbles:!0,detail:{position:s.position,rotation:s.rotation}}))},t}_attach(){if(this._tc)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._tc=qi(o,this._readOptions());let r=this._findTargetMesh();if(r){let i=r.getMeshHandle();i&&this._tc.attach(i)}}connectedCallback(){this._attach()}disconnectedCallback(){this._tc&&(this._tc.destroy(),this._tc=null)}attributeChangedCallback(t,o,r){if(o!==r&&this._tc){if(t==="mode"){let i=Ki(r);i&&this._tc.setMode(i)}else if(t==="target"){let i=this._findTargetMesh();this._tc.attach(i?i.getMeshHandle()??null:null)}}}};function Ji(e,n={}){let t=[],o=new Set;n.onChange&&o.add(n.onChange);function r(){t=n.filter?n.filter(t):t;for(let P of o)try{P(t)}catch(v){console.error("[polycss/createSelect] onChange threw:",v)}}function i(y){t=y,r()}function s(y){n.multiple?t.includes(y)||(t=[...t,y]):t=[y],r()}function c(y){t.includes(y)&&(t=t.filter(P=>P!==y),r())}function l(y){t.includes(y)?t=t.filter(P=>P!==y):n.multiple?t=[...t,y]:t=[y],r()}function p(){t.length!==0&&(t=[],r())}function g(y){return t.includes(y)}function x(y,P){return Ui(e.meshes(),y,P,v=>!v.element.classList.contains("polycss-transform-gizmo"))}let f=y=>{let P=y.target;if(P?.closest(".polycss-transform-gizmo"))return;let v=e.findMeshByElement(P)??x(y.clientX,y.clientY);if(!v){n.onPointerMissed&&n.onPointerMissed(y),n.clearOnMiss!==!1&&p();return}n.multiple&&(y.shiftKey||y.metaKey||y.ctrlKey)?l(v):t.length===1&&t[0]===v?p():i([v])};e.host.addEventListener("click",f);function b(){e.host.removeEventListener("click",f),o.clear()}return{get selected(){return t},set:i,add:s,remove:c,toggle:l,clear:p,has:g,destroy:b}}var Ol=typeof HTMLElement<"u"?HTMLElement:class{},Hl=["multiple","clear-on-miss"],vn=class extends Ol{constructor(){super(...arguments);this._selection=null}static get observedAttributes(){return[...Hl]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_readOptions(){return{multiple:this.hasAttribute("multiple"),clearOnMiss:!this.hasAttribute("clear-on-miss")||this.getAttribute("clear-on-miss")!=="false",onChange:t=>{this.dispatchEvent(new CustomEvent("polycss:select",{bubbles:!0,detail:{selected:t}}))}}}_attach(){if(this._selection)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._selection=Ji(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._selection&&(this._selection.destroy(),this._selection=null)}attributeChangedCallback(t,o,r){o!==r&&(this._selection&&(this._selection.destroy(),this._selection=null),this._attach())}};var he=require("@layoutit/polycss-core"),Il=typeof HTMLElement<"u"?HTMLElement:class{};function Fl(e){return e.closest("poly-scene")??null}function ve(e,n,t){let o=e.getAttribute(n);if(!o)return t;let r=parseFloat(o);return Number.isFinite(r)?r:t}function et(e,n,t){return e.getAttribute(n)??t}function St(e,n){let t=e.getAttribute(n);if(!t)return;let o=t.split(",").map(r=>parseFloat(r.trim()));if(!(o.length!==3||o.some(r=>!Number.isFinite(r))))return[o[0],o[1],o[2]]}function Vl(e){if(e.length===0)return e;let n=(0,he.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,r=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&r===0)return e;let i=s=>[s[0]-t,s[1]-o,s[2]-r];return e.map(s=>({...s,vertices:s.vertices.map(i)}))}var Ve=class extends Il{constructor(){super(...arguments);this._handle=null}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r&&this._handle){if(t==="position"||t==="scale"||t==="rotation"||t==="cast-shadow"||t==="receive-shadow"){this._handle.setTransform({position:St(this,"position"),scale:(()=>{let i=this.getAttribute("scale");if(!i)return;if(i.includes(","))return St(this,"scale");let s=parseFloat(i);return Number.isFinite(s)?s:void 0})(),rotation:St(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")});return}this._tearDown(),this._mount()}}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=Fl(this);if(!t)return;let o=t.getScene?.();if(!o)return;let r=this.buildPolygons();this.hasAttribute("auto-center")&&(r=Vl(r));let i={polygons:r,objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(i,{position:St(this,"position"),scale:(()=>{let s=this.getAttribute("scale");if(!s)return;if(s.includes(","))return St(this,"scale");let c=parseFloat(s);return Number.isFinite(c)?c:void 0})(),rotation:St(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow"),excludeFromAutoCenter:this.hasAttribute("exclude-from-auto-center"),merge:!1})}},xn=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("size"),t=n?parseFloat(n):void 0;return(0,he.boxPolygons)({size:t!==void 0&&Number.isFinite(t)?t:void 0,color:et(this,"color")})}},Pn=class extends Ve{static get observedAttributes(){return["axis","size","offset","color","auto-center","position","scale","rotation","cast-shadow","receive-shadow"]}buildPolygons(){let n=ve(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("offset"),r=o===null?0:parseFloat(o);return(0,he.planePolygons)({axis:t,size:ve(this,"size",.4),offset:Number.isFinite(r)?r:0,color:et(this,"color")})}},Sn=class extends Ve{static get observedAttributes(){return["axis","radius","segments","half-thickness","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=ve(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("half-thickness");return(0,he.ringPolygons)({axis:t,radius:ve(this,"radius",50),segments:ve(this,"segments",32),halfThickness:o?parseFloat(o):void 0,color:et(this,"color")})}},Cn=class extends Ve{static get observedAttributes(){return["size","color","center","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.octahedronPolygons)({center:St(this,"center")??[0,0,0],size:ve(this,"size",50),color:et(this,"color")})}},En=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.tetrahedronPolygons)({size:ve(this,"size",100),color:et(this,"color")})}},Tn=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.icosahedronPolygons)({size:ve(this,"size",100),color:et(this,"color")})}},An=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.dodecahedronPolygons)({size:ve(this,"size",100),color:et(this,"color")})}},Mn=class extends Ve{static get observedAttributes(){return["radius","subdivisions","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.spherePolygons)({radius:ve(this,"radius",50),subdivisions:ve(this,"subdivisions",1),color:et(this,"color")})}},wn=class extends Ve{static get observedAttributes(){return["radius","radius-top","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("radius-top");return(0,he.cylinderPolygons)({radius:ve(this,"radius",50),radiusTop:n?parseFloat(n):void 0,height:ve(this,"height",100),radialSegments:ve(this,"radial-segments",12),color:et(this,"color")})}},Ln=class extends Ve{static get observedAttributes(){return["radius","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.conePolygons)({radius:ve(this,"radius",50),height:ve(this,"height",100),radialSegments:ve(this,"radial-segments",12),color:et(this,"color")})}},_n=class extends Ve{static get observedAttributes(){return["radius","tube","radial-segments","tubular-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.torusPolygons)({radius:ve(this,"radius",50),tube:ve(this,"tube",15),radialSegments:ve(this,"radial-segments",12),tubularSegments:ve(this,"tubular-segments",16),color:et(this,"color")})}};typeof customElements<"u"&&(customElements.get("poly-scene")||customElements.define("poly-scene",_e),customElements.get("poly-mesh")||customElements.define("poly-mesh",xt),customElements.get("poly-iframe")||customElements.define("poly-iframe",ln),customElements.get("poly-polygon")||customElements.define("poly-polygon",cn),customElements.get("poly-axes-helper")||customElements.define("poly-axes-helper",dn),customElements.get("poly-directional-light-helper")||customElements.define("poly-directional-light-helper",un),customElements.get("poly-orbit-controls")||customElements.define("poly-orbit-controls",mn),customElements.get("poly-map-controls")||customElements.define("poly-map-controls",fn),customElements.get("poly-first-person-controls")||customElements.define("poly-first-person-controls",hn),customElements.get("poly-perspective-camera")||customElements.define("poly-perspective-camera",gn),customElements.get("poly-orthographic-camera")||customElements.define("poly-orthographic-camera",Pt),customElements.get("poly-camera")||customElements.define("poly-camera",yn),customElements.get("poly-transform-controls")||customElements.define("poly-transform-controls",bn),customElements.get("poly-select")||customElements.define("poly-select",vn),customElements.get("poly-box")||customElements.define("poly-box",xn),customElements.get("poly-plane")||customElements.define("poly-plane",Pn),customElements.get("poly-ring")||customElements.define("poly-ring",Sn),customElements.get("poly-octahedron")||customElements.define("poly-octahedron",Cn),customElements.get("poly-tetrahedron")||customElements.define("poly-tetrahedron",En),customElements.get("poly-sphere")||customElements.define("poly-sphere",Mn),customElements.get("poly-icosahedron")||customElements.define("poly-icosahedron",Tn),customElements.get("poly-dodecahedron")||customElements.define("poly-dodecahedron",An),customElements.get("poly-cylinder")||customElements.define("poly-cylinder",wn),customElements.get("poly-cone")||customElements.define("poly-cone",Ln),customElements.get("poly-torus")||customElements.define("poly-torus",_n));0&&(module.exports={PolyAxesHelperElement,PolyBoxElement,PolyCameraElement,PolyConeElement,PolyCylinderElement,PolyDirectionalLightHelperElement,PolyDodecahedronElement,PolyFirstPersonControlsElement,PolyIcosahedronElement,PolyIframeElement,PolyMapControlsElement,PolyMeshElement,PolyOctahedronElement,PolyOrbitControlsElement,PolyOrthographicCameraElement,PolyPerspectiveCameraElement,PolyPlaneElement,PolyPolygonElement,PolyRingElement,PolySceneElement,PolySelectElement,PolySphereElement,PolyTetrahedronElement,PolyTorusElement,PolyTransformControlsElement});
|
|
519
|
+
`;var Wn=require("@layoutit/polycss-core"),ha=1,at=Wn.BASE_TILE,ga=.1;function Vt(e){return[e[1],e[0],e[2]]}function ut(e){return e?.direction?{...e,direction:Vt(e.direction)}:e}function Yn(e){return(0,Wn.buildPolyMeshTransform)(e)}function Go(e,n=[0,0,0],t=1){let o=e.state,r=o.rotX,i=o.rotY,c=(o.zoom??ha)/at*t,l=(o.distance??0)*t,p=o.target??[0,0,0],h=p[0]+n[0],x=p[1]+n[1],f=p[2]+n[2],b=x*at,y=h*at,P=f*at;return`${l!==0?`translateZ(${-l}px) `:""}scale(${c}) rotateX(${r}deg) rotate(${i}deg) translate3d(${-b}px, ${-y}px, ${-P}px)`}function ya(e){let n=e.trim();if(!n||n==="normal")return 1;let t=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Number.isFinite(t)&&t>0?t:1}function Xr(e){let n=e.ownerDocument?.defaultView;if(!n)return 1;let t=1;for(let o=e;o;o=o.parentElement)t*=ya(n.getComputedStyle(o).getPropertyValue("zoom"));return Number.isFinite(t)&&t>0?t:1}function Zr(e,n){Math.abs(n-1)<1e-6?e.style.removeProperty("zoom"):e.style.setProperty("zoom",String(1/n))}function Qr(e){if(e.vertices.length<3)return null;let n=e.vertices[0],t=0,o=0,r=0;for(let x=1;x+1<e.vertices.length;x++){let f=e.vertices[x],b=e.vertices[x+1],y=f[1]-n[1],P=f[0]-n[0],v=f[2]-n[2],C=b[1]-n[1],F=b[0]-n[0],k=b[2]-n[2];t-=P*k-v*F,o-=v*C-y*k,r-=y*F-P*C}let i=Math.hypot(t,o,r);if(i<1e-9)return null;t/=i,o/=i,r/=i;let s=1/ga,c=Math.round(t*s)/s,l=Math.round(o*s)/s,p=Math.round(r*s)/s,h=Math.hypot(c,l,p);return h<1e-9?null:{key:c+","+l+","+p,vec:[c/h,l/h,p/h]}}function qr(e,n){let t=e?.disable??[],o=n?.disable??[];if(t.length!==o.length)return!1;for(let r of t)if(!o.includes(r))return!1;return!0}function Kr(e,n){return e===n?!0:!e||!n?!1:e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}function Jr(e,n){return e===n?!0:(e?.color??"#000000")===(n?.color??"#000000")&&(e?.opacity??.25)===(n?.opacity??.25)&&(e?.lift??.05)===(n?.lift??.05)&&(e?.maxExtend??2e3)===(n?.maxExtend??2e3)}var pt=require("@layoutit/polycss-core");var ba=["--plx","--ply","--plz","--plr","--plg","--plb","--pli","--par","--pag","--pab","--pai","--clx","--cly","--clz"],Bt="--polycss-light-preview-active",ei=`var(${Bt}, 0)`,va="max(0, calc(var(--pnx, 0) * var(--plx, 0) + var(--pny, 0) * var(--ply, 0) + var(--pnz, 1) * var(--plz, 1)))",$o=(e,n,t)=>`calc(255 * max(0, 1.055 * pow(min(1, pow((var(${e}, 1) + 0.055) / 1.055, 2.4) * (pow((var(${n}, 1) + 0.055) / 1.055, 2.4) * var(--pai, 0.4) + pow((var(${t}, 1) + 0.055) / 1.055, 2.4) * var(--pli, 1) * var(--plam, 0)) / 3.14159265), 0.4167) - 0.055))`,xa=$o("--psr","--par","--plr"),Pa=$o("--psg","--pag","--plg"),Sa=$o("--psb","--pab","--plb");function me(e,n,t){return e.style.getPropertyValue(n)===t?!1:(e.style.setProperty(n,t),!0)}function bt(e){for(let n of ba)e.style.getPropertyValue(n)&&e.style.removeProperty(n)}function Xn(e,n){let t=n.directionalLight?.direction??[.4,-.7,.59],o=Vt(t),r=Math.hypot(o[0],o[1],o[2])||1,i=o[0]/r,s=o[1]/r,c=o[2]/r,l=(0,pt.parseHexColor)(n.directionalLight?.color??"#ffffff")?.rgb??[255,255,255],p=(0,pt.parseHexColor)(n.ambientLight?.color??"#ffffff")?.rgb??[255,255,255],h=n.directionalLight?.intensity??1,x=n.ambientLight?.intensity??.4,f=P=>(P/255).toFixed(4);me(e,"--plx",i.toFixed(2)),me(e,"--ply",s.toFixed(2)),me(e,"--plz",c.toFixed(2)),me(e,"--plr",f(l[0])),me(e,"--plg",f(l[1])),me(e,"--plb",f(l[2])),me(e,"--pli",h.toFixed(4)),me(e,"--par",f(p[0])),me(e,"--pag",f(p[1])),me(e,"--pab",f(p[2])),me(e,"--pai",x.toFixed(4));let b=c,y=Math.sign(b||1)*Math.max(Math.abs(b),.01);me(e,"--clx",i.toFixed(2)),me(e,"--cly",s.toFixed(2)),me(e,"--clz",y.toFixed(2))}function ti(e,n){let t=n.textureLighting==="dynamic";if(e.dataset.polycssLighting=n.textureLighting??"baked",!t){bt(e);return}Xn(e,n)}function vt(e,n){n.paintColor?e.style.setProperty("--polycss-paint",n.paintColor):e.style.getPropertyValue("--polycss-paint")&&e.style.removeProperty("--polycss-paint"),n.dynamicColor?(e.style.setProperty("--psr",(n.dynamicColor.r/255).toFixed(4)),e.style.setProperty("--psg",(n.dynamicColor.g/255).toFixed(4)),e.style.setProperty("--psb",(n.dynamicColor.b/255).toFixed(4))):(e.style.getPropertyValue("--psr")||e.style.getPropertyValue("--psg")||e.style.getPropertyValue("--psb"))&&(e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"))}function ni(e,n){let t=(0,pt.parseHex)(n??"#cccccc");e.style.setProperty("--psr",(t.r/255).toFixed(4)),e.style.setProperty("--psg",(t.g/255).toFixed(4)),e.style.setProperty("--psb",(t.b/255).toFixed(4))}function Uo(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=t.textureLighting??"baked",r={directionalLight:ut(t.directionalLight),ambientLight:t.ambientLight,textureLighting:o,textureQuality:t.textureQuality,seamBleed:t.seamBleed,strategies:t.strategies},i=To(e.plan,n,e.plan.normal,o,r);return Lt(e.element,i,o),o==="baked"&&Ea(e.element),!0}function Ca(e){let n=(0,pt.parsePureColor)(e)??{rgb:[255,255,255],alpha:1},[t,o,r]=n.rgb,i=(c,l)=>`calc(${c} * (1 - ${ei}) + var(${l}, ${c}) * ${ei})`,s=n.alpha<1?` / ${n.alpha}`:"";return`rgb(${i(t,"--polycss-preview-r")} ${i(o,"--polycss-preview-g")} ${i(r,"--polycss-preview-b")}${s})`}function oi(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=e.element,r=e.plan.normal,i=(0,pt.parseHex)(n.color??"#cccccc"),s=!1;return s=me(o,"--pnx",r[0].toFixed(4))||s,s=me(o,"--pny",r[1].toFixed(4))||s,s=me(o,"--pnz",r[2].toFixed(4))||s,s=me(o,"--psr",(i.r/255).toFixed(4))||s,s=me(o,"--psg",(i.g/255).toFixed(4))||s,s=me(o,"--psb",(i.b/255).toFixed(4))||s,s=me(o,"--plam",va)||s,s=me(o,"--polycss-preview-r",xa)||s,s=me(o,"--polycss-preview-g",Pa)||s,s=me(o,"--polycss-preview-b",Sa)||s,s=me(o,"--polycss-paint",Ca(t))||s,o.style.getPropertyValue("color")&&(o.style.removeProperty("color"),s=!0),s}function Ea(e){e.style.removeProperty("--pnx"),e.style.removeProperty("--pny"),e.style.removeProperty("--pnz"),e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"),e.style.removeProperty("--plam"),e.style.removeProperty("--polycss-preview-r"),e.style.removeProperty("--polycss-preview-g"),e.style.removeProperty("--polycss-preview-b"),e.style.removeProperty("--polycss-paint")}var Ta="http://www.w3.org/2000/svg",Zn=class{constructor(){this.groundSvg=null;this.groundVisible=!1;this.currentGroundCssZ=null;this.shadowRoot=null}};function ri(e,n,t){let o=e.shadowRoot;if(o||(o=n.createElement("div"),o.setAttribute("class","polycss-shadows"),o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.width="0",o.style.height="0",o.style.transformStyle="preserve-3d",o.style.pointerEvents="none",e.shadowRoot=o),o.parentNode!==t){let r=t.firstChild;r?t.insertBefore(o,r):t.appendChild(o)}return o}function ii(e){e.groundSvg?.parentNode&&e.groundSvg.parentNode.removeChild(e.groundSvg),e.groundSvg=null,e.groundVisible=!1}function si(e){e.groundSvg&&e.groundVisible&&(e.groundSvg.style.display="none",e.groundVisible=!1)}function ai(e,n,t,o){let r=[],i=e.firstChild;for(let s=0;s<t;s++){let c=i;c&&c.tagName==="path"?i=c.nextSibling:(c=n.createElementNS(Ta,"path"),c.setAttribute("fill-rule","nonzero"),o&&(c.setAttribute("stroke-width","0.5"),c.setAttribute("stroke-linejoin","round")),e.insertBefore(c,i)),r.push(c)}for(;i;){let s=i.nextSibling;e.removeChild(i),i=s}return r}function li(e){return{host:e.host,doc:e.doc,cameraEl:e.cameraEl,sceneEl:e.sceneEl,camera:e.camera,layoutScale:e.layoutScale,options:{current:e.options},meshes:new Set,meshAutoCounter:{next:0},autoCenter:{offset:[0,0,0]},bboxCenterCssCache:{value:null},shadowSvgState:new Zn,receiverShadowCache:new Map,receiverShadowCacheKey:new Map,casterItemsCache:new Map,casterItemsCacheKey:new Map}}var Fe=require("@layoutit/polycss-core");function ci(e){for(let n of e)n.svg&&n.svg.parentNode&&n.svg.parentNode.removeChild(n.svg),n.svg=null}function di(e,n){if(n){let t=e.receiverShadowCache.get(n);t&&ci(t),e.receiverShadowCache.delete(n),e.receiverShadowCacheKey.delete(n)}else{for(let t of e.receiverShadowCache.values())ci(t);e.receiverShadowCache.clear(),e.receiverShadowCacheKey.clear()}}function ui(e,n){n?(e.casterItemsCache.delete(n),e.casterItemsCacheKey.delete(n)):(e.casterItemsCache.clear(),e.casterItemsCacheKey.clear())}function pi(e){ii(e.shadowSvgState),mi(e)}function jo(e){return e.handle.id??e.autoMeshId}var Aa="http://www.w3.org/2000/svg",Qn=new WeakMap,fi=new WeakMap,hi=new WeakMap,gi=new WeakMap,yi=new WeakMap;function bi(e){let n=Qn.get(e);return n||(n=new Map,Qn.set(e,n)),n}function Wo(e){let n=Qn.get(e);if(n){for(let t of n.values())t.svg&&t.svg.parentNode&&t.svg.parentNode.removeChild(t.svg);n.clear(),Qn.delete(e)}}function mi(e){for(let n of e.meshes)Wo(n)}function vi(e,n,t,o,r,i,s,c,l,p){let h=e.options.current,{receiverShadowCache:x,receiverShadowCacheKey:f,casterItemsCache:b,casterItemsCacheKey:y}=e,P=o.handle.transform.position??[0,0,0],v=o.handle.transform.rotation??[0,0,0],C=o.polygons.some(A=>A.texture!==void 0),F=(0,Fe.meshScaleVec3)(o.handle.transform.scale),k=o.bboxCenterCss,z=h.shadow?.lift??.001,O=`${o.polygons.length}|${r.size}|${P.join(",")}|${v.join(",")}|${F.join(",")}|${k?k.join(","):"n"}|${z}`,Z=x.get(o);if(Z===void 0||f.get(o)!==O){Z=(0,Fe.prepareReceiverFacePlanes)(o.polygons,P,o.handle.transform.scale,r,z,v),x.set(o,Z),f.set(o,O);let A=bi(o);for(let g of A.values())g.svg&&g.svg.parentNode&&g.svg.parentNode.removeChild(g.svg);A.clear()}let q=[];for(let A of n){let g=A.handle.transform.position??[0,0,0],u=A.handle.transform.rotation??[0,0,0],d=(0,Fe.meshScaleVec3)(A.handle.transform.scale),T=A.bboxCenterCss,w=`${A.polygons.length}|${g.join(",")}|${u.join(",")}|${d.join(",")}|${T?T.join(","):"n"}`,R=b.get(A);if(R===void 0||y.get(A)!==w){let _=t.get(A),j=new Set;for(let Q of A.rendered)Q.plan&&!_.has(Q.polygonIndex)&&j.add(Q.polygonIndex);R=(0,Fe.prepareCasterPolyItems)(A.polygons,g,A.handle.transform.scale,Q=>j.has(Q),u),b.set(A,R),y.set(A,w)}let L;if(A===o){let _=fi.get(A);(_===void 0||hi.get(A)!==A.polygons)&&(_=(0,Fe.buildSharedEdgeMap)(A.polygons),fi.set(A,_),hi.set(A,A.polygons)),L=_}let re;if(A!==o&&A.polygons.length>=40){let _=gi.get(A);(_===void 0||yi.get(A)!==w)&&(_=(0,Fe.prepareCasterEdgeOwners)(A.polygons,g,A.handle.transform.scale,u),gi.set(A,_),yi.set(A,w)),re=_}q.push({id:A,items:R,selfShadowEdgeMap:L,edgeOwners:re,casterPolygonCount:A.polygons.length})}let D={rotX:e.camera.state.rotX,rotY:e.camera.state.rotY,meshRotation:o.handle.transform.rotation},H=(0,Fe.computeReceiverShadowFaces)({receiverPlanes:Z,receiverPolygons:o.polygons,receiverHasTexture:C,casters:q,lightDir:i,cameraRot:D,ambientLight:h.ambientLight,directionalLight:h.directionalLight,shadow:{color:h.shadow?.color,opacity:p,maxExtend:h.shadow?.maxExtend}}),V=bi(o),G=new Set;for(let A of H){G.add(A.faceIndex);let g=V.get(A.faceIndex);g||(g={svg:null,visible:!1,width:-1,height:-1,matrixCss:""},V.set(A.faceIndex,g));let u=g.svg;u?(g.visible||(u.style.display="block"),(g.width!==A.width||g.height!==A.height)&&(u.setAttribute("width",String(A.width)),u.setAttribute("height",String(A.height)),u.setAttribute("viewBox",`0 0 ${A.width} ${A.height}`),g.width=A.width,g.height=A.height),g.matrixCss!==A.matrixCss&&(u.style.transform=A.matrixCss,g.matrixCss=A.matrixCss)):(u=e.doc.createElementNS(Aa,"svg"),u.setAttribute("class","polycss-shadow polycss-shadow-svg polycss-shadow-receiver"),h.debugShadowAttrs&&(u.setAttribute("data-poly-shadow-type","receiver"),u.setAttribute("data-poly-shadow-receiver",jo(o)),u.setAttribute("data-poly-shadow-receiver-face",String(A.faceIndex)),u.setAttribute("data-poly-shadow-receiver-polys",JSON.stringify(A.memberPolyIndices))),u.setAttribute("width",String(A.width)),u.setAttribute("height",String(A.height)),u.setAttribute("viewBox",`0 0 ${A.width} ${A.height}`),u.setAttribute("style",`position:absolute;top:0;left:0;display:block;overflow:hidden;transform-origin:0 0;pointer-events:none;will-change:transform;transform:${A.matrixCss}`),ri(e.shadowSvgState,e.doc,e.sceneEl).appendChild(u),g.svg=u,g.width=A.width,g.height=A.height,g.matrixCss=A.matrixCss),g.visible=!0;let d=ai(u,e.doc,A.paths.length,!0),T=A.opacity.toFixed(4),w=[],R=!!h.debugShadowAttrs;for(let L=0;L<A.paths.length;L++){let re=A.paths[L],_=R?jo(re.casterId):"";R&&w.push(_);let j=d[L];if(j.setAttribute("d",re.d),j.getAttribute("fill")!==A.fill&&j.setAttribute("fill",A.fill),j.getAttribute("stroke")!==A.fill&&j.setAttribute("stroke",A.fill),j.getAttribute("opacity")!==T&&j.setAttribute("opacity",T),R){j.getAttribute("data-poly-shadow-caster")!==_&&j.setAttribute("data-poly-shadow-caster",_);let Q=JSON.stringify(re.casterPolygonIndices);j.getAttribute("data-poly-shadow-caster-polys")!==Q&&j.setAttribute("data-poly-shadow-caster-polys",Q)}}if(R){let L=w.join(" ");u.getAttribute("data-poly-shadow-casters")!==L&&u.setAttribute("data-poly-shadow-casters",L)}}for(let[A,g]of V)G.has(A)||g.svg&&g.visible&&(g.svg.style.display="none",g.visible=!1)}var xi=Symbol.for("polycss.animation.triangleFrameTarget");var Ma=750;function Pi(e){return!Object.prototype.hasOwnProperty.call(e,"seamBleed")||e.seamBleed!==void 0?e:{...e,seamBleed:ne.DEFAULT_SEAM_BLEED}}var wa={key:"non-cullable",normal:[1,1,0]};function Si(){return[wa]}function Ci(e,n){if(!e||typeof e.appendChild!="function")throw new Error("createPolyScene: host must be an HTMLElement");if(!n?.camera)throw new Error("createPolyScene: a camera handle is required. Use createPolyCamera({...}) or createPolyPerspectiveCamera({...}) and pass as { camera }.");let t=n.camera;e.ownerDocument&&Yr(e.ownerDocument),e.ownerDocument?.defaultView&&e.ownerDocument.defaultView.getComputedStyle(e).position==="static"&&(e.style.position="relative");let{camera:o,...r}=n,i=Pi({seamBleed:ne.DEFAULT_SEAM_BLEED,...r}),s=Xr(e),c=[0,0,0],l=e.ownerDocument??document,p=l.createElement("div");p.className="polycss-camera",Z(p,i),e.appendChild(p);let h=l.createElement("div");h.className="polycss-scene",h.setAttribute("aria-hidden","true"),q(h,i),p.appendChild(h);let x=li({host:e,doc:l,cameraEl:p,sceneEl:h,camera:t,layoutScale:s,options:i}),f=x.meshes,b=new WeakMap,y=x.shadowSvgState,P=()=>si(y),v=()=>pi(x),C=null;function F(a){if(!a)return null;let m=Math.hypot(a[0],a[1],a[2]);if(!Number.isFinite(m)||m<=0)return null;let S=Math.round(a[0]/m*100)/100,E=Math.round(a[1]/m*100)/100,W=Math.round(a[2]/m*100)/100;return`${S}|${E}|${W}`}function k(){C=null}let z=a=>di(x,a),O=a=>ui(x,a);function Z(a,m){let S=t.perspectiveStyle;if(S==="none")a.style.perspective="1000000px";else{let E=parseFloat(S);Number.isFinite(E)&&(a.style.perspective=`${E}px`)}}function q(a,m){Zr(a,s),a.style.transform=Go(t,c,s),ti(a,m)}function D(a){a.style.transform=Go(t,c,s)}function H(a){a.voxelRenderer?.dispose(),a.voxelRenderer=void 0,g(a.rendered,a.disposeAtlas),a.disposeAtlas=void 0,a.rendered.length=0,a.renderedByPolygonIndex=[],a.cameraCullGroups=[],a.cameraCullSignature="",a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,A(a);for(let m of Array.from(a.wrapper.children))m instanceof HTMLElement&&m.classList.contains("polycss-bucket")&&m.remove();a.hasBuckets=!1}function V(a){for(let m of Array.from(a.wrapper.childNodes)){if(!(m instanceof HTMLElement))return m;if(m.classList.contains("polycss-bucket")||m.classList.contains("polycss-shadow"))continue;let S=m.tagName.toLowerCase();if(!(S==="b"||S==="i"||S==="s"||S==="u"||S==="q"))return m}return null}function G(a,m,S){S?.parentNode===a.wrapper?a.wrapper.insertBefore(m,S):a.wrapper.appendChild(m)}function A(a){for(let m of a.shadowRendered)m.parentNode&&m.parentNode.removeChild(m);a.shadowRendered.length=0,v()}function g(a,m){m?.();for(let S of a){try{S.dispose()}catch{}S.element.parentNode&&S.element.parentNode.removeChild(S.element)}}function u(a,m,S){a.rendered=m,a.renderedByPolygonIndex=[];for(let E of m)a.renderedByPolygonIndex[E.polygonIndex]=E;a.disposeAtlas=S,a.solidLightingPreviewPrepared=!1}function d(a,m){let S=a.renderedByPolygonIndex[m];return S?.polygonIndex===m?S:void 0}function T(a){for(let m of Array.from(a.wrapper.children))m instanceof HTMLElement&&m.classList.contains("polycss-bucket")&&m.remove();a.hasBuckets=!1;for(let m of a.rendered)m.element.parentNode&&m.element.parentNode.removeChild(m.element)}function w(a,m){let S=a.polygons[m.polygonIndex];return a.stableDom&&S?(0,ne.polygonCssSurfaceNormal)(S):m.plan?.normal??(S?(0,ne.polygonCssSurfaceNormal)(S):null)}function R(a){if(!Q(a))return a.rendered;let m=L(a);return a.rendered.filter(S=>re(a,S,ne.CAMERA_BACKFACE_CULL_EPS,m))}function L(a){return{rotX:t.state.rotX,rotY:t.state.rotY,meshRotation:a.handle.transform.rotation}}function re(a,m,S=ne.CAMERA_BACKFACE_CULL_EPS,E=L(a)){let W=w(a,m);return W===null||(0,ne.normalFacesCamera)(W,E,S)}function _(a){if(a.excludeFromAutoCenter){a.cameraCullGroups=[];return}let m=new Map;for(let S of a.rendered){let E=w(a,S);if(!E)continue;if(!(0,ne.isAxisAlignedSurfaceNormal)(E)){a.cameraCullGroups=Si();return}let W=(0,ne.cameraCullNormalKey)(E);if(!m.has(W)&&(m.set(W,E),m.size>ne.VOXEL_CAMERA_CULL_NORMAL_LIMIT)){a.cameraCullGroups=Si();return}}a.cameraCullGroups=Array.from(m,([S,E])=>({key:S,normal:E}))}function j(a){return Q(a)?(0,ne.cameraCullVisibleSignature)(a.cameraCullGroups,L(a)):"all"}function Q(a){return!a.excludeFromAutoCenter&&(0,ne.isVoxelCameraCullableNormalGroups)(a.cameraCullGroups)}function ae(a){a.cameraCullSignature=Q(a)?j(a):"all"}function be(a,m){let S=new Array(a.rendered.length),E=!1,W=L(a);for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K],te=re(a,se,m,W);S[K]=te}let B=null,I=null,U=()=>{if(!(!B||!I)){if(B===I)B.remove();else{let K=l.createRange();K.setStartBefore(B),K.setEndAfter(I),K.deleteContents(),K.detach()}B=null,I=null,E=!0}};for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K];!S[K]&&se.element.parentNode===a.wrapper?(I&&I.nextSibling===se.element||(U(),B=se.element),I=se.element):U()}U();let Y=K=>{for(let se=K;se<a.rendered.length;se+=1){let te=a.rendered[se].element;if(te.parentNode===a.wrapper)return te}return V(a)},de=-1,ie=K=>{if(de<0)return;let se=l.createDocumentFragment();for(let te=de;te<K;te+=1){let Ne=a.rendered[te];Se(a,Ne),se.appendChild(Ne.element)}G(a,se,Y(K)),de=-1,E=!0};for(let K=0;K<a.rendered.length;K+=1){let se=a.rendered[K];S[K]&&se.element.parentNode!==a.wrapper?de<0&&(de=K):ie(K)}return ie(a.rendered.length),E}function fe(a,m=!1){if(a.voxelRenderer){m?a.voxelRenderer.render(L(a)):a.voxelRenderer.syncCamera(L(a)),a.cameraCullSignature="voxel-direct";return}if(!Q(a)){let W=a.cameraCullSignature!=="all";a.cameraCullSignature="all",W&&Ce(a);return}if(a.hasBuckets){ge(a,m);return}let S=j(a);if(!m&&S===a.cameraCullSignature)return;let E=be(a,ne.CAMERA_BACKFACE_CULL_EPS);a.cameraCullSignature=S,E&&Ye(a)}function ge(a,m=!1){let S=Q(a)?j(a):"all";!m&&S===a.cameraCullSignature||Ce(a)}function we(a,m){return w(a,m)}function Se(a,m){if(i.textureLighting!=="dynamic")return;let S=we(a,m);S&&(m.element.style.setProperty("--pnx",S[0].toFixed(4)),m.element.style.setProperty("--pny",S[1].toFixed(4)),m.element.style.setProperty("--pnz",S[2].toFixed(4)))}function ke(a){T(a),a.hasBuckets=!1;let m=a.skipBucketNormalCleanupOnce;a.skipBucketNormalCleanupOnce=!1;let S=l.createDocumentFragment(),E=i.textureLighting==="dynamic"&&!a.stableDom,W=new Map,B=[];for(let I of R(a)){let U=a.polygons[I.polygonIndex],Y=E&&U?Qr(U):null;if(!Y){B.push(I);continue}let de=Y.key+"|"+(U.color??""),ie=W.get(de);ie||(ie={vec:Y.vec,items:[]},W.set(de,ie)),ie.items.push(I)}for(let I of B)Se(a,I),S.appendChild(I.element);for(let I of W.values()){if(I.items.length<2){for(let Y of I.items)Se(a,Y),S.appendChild(Y.element);continue}let U=l.createElement("div");U.className="polycss-bucket",a.hasBuckets=!0,U.style.setProperty("--pnx",String(I.vec[0])),U.style.setProperty("--pny",String(I.vec[1])),U.style.setProperty("--pnz",String(I.vec[2]));for(let Y of I.items)U.appendChild(Y.element),(!m||Y.kind==="triangle")&&(Y.element.style.removeProperty("--pnx"),Y.element.style.removeProperty("--pny"),Y.element.style.removeProperty("--pnz"));S.appendChild(U)}G(a,S,V(a)),ae(a)}function We(){return new Promise(a=>setTimeout(a,0))}async function et(a,m){if(i.textureLighting==="dynamic"&&!a.stableDom)return ke(a),!m();T(a);let E=l.createDocumentFragment(),W=V(a),B=0;for(let I of R(a)){if(m())return!1;Se(a,I),E.appendChild(I.element),B++,B%Ma===0&&(G(a,E,W),E=l.createDocumentFragment(),await We())}return E.childNodes.length>0&&G(a,E,W),ae(a),!m()}function mt(a,m){let S=i.textureLighting==="dynamic",E=i.directionalLight?.direction,W=m&&(m[0]!==0||m[1]!==0||m[2]!==0);if(!S||!W||!E){if(a.lightOverrideSignature==="clear")return;a.wrapper.style.removeProperty("--plx"),a.wrapper.style.removeProperty("--ply"),a.wrapper.style.removeProperty("--plz"),a.lightOverrideSignature="clear";return}let B=(0,ne.inverseRotateVec3)(E,m),I=Vt(B),U=Math.hypot(I[0],I[1],I[2])||1,Y=(I[0]/U).toFixed(2),de=(I[1]/U).toFixed(2),ie=(I[2]/U).toFixed(2),K=`${Y}|${de}|${ie}`;a.lightOverrideSignature!==K&&(a.wrapper.style.setProperty("--plx",Y),a.wrapper.style.setProperty("--ply",de),a.wrapper.style.setProperty("--plz",ie),a.lightOverrideSignature=K)}function Ct(a){let m=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(m=Uo(S,E,i)||m)}return a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,m}function ft(a){if((i.textureLighting??"baked")!=="baked")return!1;let m=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(oi(S,E,S.plan.shadedColor),m=!0)}return a.solidLightingPreviewPrepared=m,m}function co(a){return(i.textureLighting??"baked")!=="baked"||!a.solidLightingPreviewPrepared&&!ft(a)?!1:(a.solidLightingPreviewActive=!0,!0)}function uo(a){return a.kind==="atlas"||!!a.plan?.texture}function po(){if((i.textureLighting??"baked")!=="baked")return!1;let a=!1;for(let m of f)a=Ct(m)||a,m.rendered.some(uo)&&(Yt(m),a=!0);h.style.removeProperty(Bt);for(let m of f)bt(m.wrapper),m.solidLightingPreviewActive=!1;return bt(h),a}function mo(){h.style.removeProperty(Bt);for(let a of f)a.solidLightingPreviewActive&&(Ct(a),bt(a.wrapper));(i.textureLighting??"baked")!=="dynamic"&&(bt(h),k(),Le())}function $(a,m){let S=a.handle.transform.rotation,E=m.directionalLight?.direction??i.directionalLight?.direction;if(!(S&&(S[0]!==0||S[1]!==0||S[2]!==0))||!E){bt(a.wrapper);return}let B=(0,ne.inverseRotateVec3)(E,S);Xn(a.wrapper,{...i,...m,directionalLight:{...i.directionalLight,...m.directionalLight,direction:B}})}function le(a){if((i.textureLighting??"baked")!=="baked")return!1;Xn(h,{...i,...a}),!a.skipShadows&&a.directionalLight?.direction&&Le(a.directionalLight.direction);let m=!1;for(let S of f)$(S,a),m=co(S)||m;return m?me(h,Bt,"1"):h.style.removeProperty(Bt),m}function ce(a,m,S){let E=a.polygons[m];if(!E)return!1;let W=d(a,m);if(!W)return!1;let B=i.textureLighting??"baked";return B==="dynamic"?(ni(W.element,S),!0):B==="baked"?Uo(W,E,i):!1}function De(a,m){let S=a.polygons[m];if(!S)return!1;let E=d(a,m);return E?(Pe(E.element,S,m),!0):!1}function Wt(a,m,S){return!(S.length===0||!S.every(E=>E==="color"||E==="data")||S.includes("color")&&!ce(a,m,a.polygons[m]?.color)||S.includes("data")&&!De(a,m))}function Ye(a){k(),Le()}function Le(a){let m=[];for(let te of f)!te.disposed&&te.castShadow&&m.push(te);if(m.length===0){v(),C=null;return}let S=i.shadow?.color??"#000000",E=i.shadow?.opacity??.25,W=(0,ne.parseHexColor)(S)?.rgb??[0,0,0],B=W[0],I=W[1],U=W[2],Y=a??i.directionalLight?.direction??[.4,-.7,.59],de=Vt(Y),ie=F(de);if(ie!==null&&ie===C)return;let K=new Map;for(let te of m)K.set(te,(0,ne.findOverlappingPolygonDuplicates)(te.polygons,{normalTolerance:.1,distanceTolerance:.5,overlapFraction:.95,preserveDoubleSidedBackfaces:!1}));let se=new Map;for(let te of f)te.disposed||!te.receiveShadow||se.set(te,new Set);P();for(let te of f)te.disposed||!te.receiveShadow||vi(x,m,K,te,se.get(te)??new Set,de,B,I,U,E);C=ie}function Ce(a){if(a.voxelRenderer){a.voxelRenderer.render(L(a)),a.cameraCullSignature="voxel-direct";return}A(a),ke(a),Ye(a)}function Be(a,m){if(!m||!a.polygons||a.polygons.length<2)return;let S=Math.hypot(m[0],m[1],m[2]);if(!Number.isFinite(S)||S<=0)return;let E=m[0]/S,W=m[1]/S,B=m[2]/S,I=K=>Math.round(K*1e3)/1e3,U=`${I(E)},${I(W)},${I(B)}`,Y=a.lightOcclusionCache;if(Y&&Y.polygons===a.polygons&&Y.lightDirKey===U)return Y.occluded;let de=Y&&Y.polygons===a.polygons?Y.dedupDropped:(0,ne.findOverlappingPolygonDuplicates)(a.polygons,{normalTolerance:.1,distanceTolerance:.12,overlapFraction:.98,preserveDoubleSidedBackfaces:!1}),ie=(0,ne.computeLightVisibility)(a.polygons,[E,W,B],de);return a.lightOcclusionCache={polygons:a.polygons,lightDirKey:U,occluded:ie,dedupDropped:de},ie}function ze(a){return!!a.voxelSource&&i.textureLighting!=="dynamic"&&!a.stableDom&&!a.castShadow}function Me(a,m){H(a);let S=i.directionalLight,E=m?{...S,direction:m}:S,W=ut(E),B=void 0;if(ze(a)){let Y=jr({doc:l,wrapper:a.wrapper,polygons:a.parseResult.polygons,directionalLight:W,ambientLight:i.ambientLight});if(Y){a.voxelRenderer=Y,Y.render(L(a)),a.cameraCullSignature="voxel-direct";return}}let I={doc:l,directionalLight:W,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,lightOccludedPolyIndices:B},U=a.stableDom?(()=>{let Y=Ot(a.polygons,I);return vt(a.wrapper,Y),on(a.polygons,{...I,solidPaintDefaults:Y})??Ht(a.polygons,{...I,solidPaintDefaults:Y})})():Ht(a.polygons,{...I,computeSolidPaintDefaults:!0,skipDynamicNormalVars:i.textureLighting==="dynamic"});a.stableDom||vt(a.wrapper,U.solidPaintDefaults??{}),u(a,U.rendered,U.dispose),a.skipBucketNormalCleanupOnce=i.textureLighting==="dynamic"&&!a.stableDom,_(a),ke(a),Ye(a)}function Yt(a,m){if(a.rendered.length===0||a.voxelRenderer||a.stableDom||ze(a)){Me(a,m);return}if(a.rendered[0]?.element.parentNode===null){Me(a,m);return}let S=i.directionalLight,E=m?{...S,direction:m}:S,W=ut(E),B={doc:l,directionalLight:W,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,computeSolidPaintDefaults:!0,skipDynamicNormalVars:i.textureLighting==="dynamic"},I=Ht(a.polygons,B),U=()=>{a.rebakeInFlight=!1;let ie=a.rebakeQueuedLightDir;ie!==null&&(a.rebakeQueuedLightDir=null,Yt(a,ie))},Y=()=>{if(a.disposed){I.dispose(),U();return}if(I.rendered.length!==a.rendered.length){I.dispose(),Me(a,m),U();return}for(let se of I.rendered){let te=a.renderedByPolygonIndex[se.polygonIndex];if(!te)continue;let Ne=se.element.getAttribute("style");Ne!==null&&te.element.setAttribute("style",Ne)}let ie=I.solidPaintDefaults;ie&&vt(a.wrapper,ie);let K=a.disposeAtlas;a.disposeAtlas=I.dispose,K&&(typeof requestAnimationFrame=="function"?te=>{requestAnimationFrame(te)}:te=>{setTimeout(te,0)})(K),Ye(a),U()},de=I.pagesReady;de&&typeof de.then=="function"?de.then(()=>ho(I.rendered)).then(go).then(Y,()=>{I.dispose(),a.disposed||Me(a,m),U()}):Y()}function fo(a,m){if(a.rebakeInFlight){a.rebakeQueuedLightDir=m;return}a.rebakeInFlight=!0,Yt(a,m)}function ho(a){let m=new Set;for(let S of a){let E=S.element.getAttribute("style")??"",W=/url\((blob:[^)]+)\)/g,B;for(;(B=W.exec(E))!==null;)m.add(B[1])}return Array.from(m)}function go(a){return a.length===0||typeof Image>"u"?Promise.resolve():Promise.all(a.map(m=>{let S=new Image;S.src=m;let E=S.decode?.();return E?E.catch(()=>{}):Promise.resolve()})).then(()=>{})}function tt(){let a=1/0,m=!1;for(let B of f)if(!B.disposed&&B.receiveShadow){m=!0;break}for(let B of f){if(B.disposed||!(m?B.receiveShadow:B.castShadow))continue;let U=B.handle.transform.position?.[2]??0;for(let Y of B.polygons)for(let de of Y.vertices){let ie=de[2]+U;ie<a&&(a=ie)}}if(!Number.isFinite(a)){let B=y.currentGroundCssZ!==null;y.currentGroundCssZ=null,B&&(v(),k());return}let S=i.shadow?.lift??.05,E=(a+S)*at,W=y.currentGroundCssZ;y.currentGroundCssZ=E,W!==E&&(k(),Le())}async function _n(a,m){H(a);let S=ut(i.directionalLight),E={doc:l,directionalLight:S,ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,strategies:i.strategies,lightOccludedPolyIndices:void 0},W=a.stableDom?on(a.polygons,E):null;if(W){let U=Ot(a.polygons,E);return vt(a.wrapper,U),u(a,W.rendered,W.dispose),_(a),ke(a),Ye(a),!m()}let B=await Gn(a.polygons,{...E,skipDynamicNormalVars:i.textureLighting==="dynamic"},m);if(m())return B.dispose(),!1;vt(a.wrapper,B.solidPaintDefaults),u(a,B.rendered,B.dispose),a.skipBucketNormalCleanupOnce=i.textureLighting==="dynamic"&&!a.stableDom,_(a);let I=await et(a,m);return I&&Ye(a),I}function ht(){let a=c,m=[0,0,0];if(i.autoCenter){let S=[];for(let E of f)!E.disposed&&!E.excludeFromAutoCenter&&S.push(...E.polygons);if(S.length>0){let E=(0,ne.computeSceneBbox)(S);m=[(E.min[0]+E.max[0])/2,(E.min[1]+E.max[1])/2,(E.min[2]+E.max[2])/2]}}a[0]===m[0]&&a[1]===m[1]&&a[2]===m[2]||(c=m,x.autoCenter.offset=m,q(h,i))}function es(a,m={}){let E=(h.ownerDocument??document).createElement("div");E.className="polycss-mesh",m.id&&E.setAttribute("data-poly-mesh-id",m.id);let W=`polycss-mesh-${x.meshAutoCounter.next++}`;E.setAttribute("data-poly-mesh-index",W);let B={...m},I=m.merge!==!1,U=!!m.stableDom,Y=0,de=Yn(B);de&&(E.style.transform=de);let ie=(N,X)=>a.voxelSource?N:X?(0,ne.optimizeMeshPolygons)(N,{meshResolution:m.meshResolution}):(U||m.excludeFromAutoCenter,N),K=ie(a.polygons,I),se=null;function te(){let N=Yn(B);E.style.transform=N??""}function Ne(N){if(N.length===0){se=null,Xe&&(Xe.bboxCenterCss=null),te();return}let X=1/0,ue=1/0,ye=1/0,Oe=-1/0,pe=-1/0,xe=-1/0;for(let qe of N)for(let $e of qe.vertices)$e[0]<X&&(X=$e[0]),$e[0]>Oe&&(Oe=$e[0]),$e[1]<ue&&(ue=$e[1]),$e[1]>pe&&(pe=$e[1]),$e[2]<ye&&(ye=$e[2]),$e[2]>xe&&(xe=$e[2]);if(!Number.isFinite(X)){se=null,Xe&&(Xe.bboxCenterCss=null),te();return}let Ge=(ue+pe)/2*at,Qe=(X+Oe)/2*at,He=(ye+xe)/2*at;se=[Ge,Qe,He],Xe&&(Xe.bboxCenterCss=se),te()}let Xe=null;Ne(K),h.appendChild(E);let M={handle:void 0,wrapper:E,parseResult:a,rendered:[],renderedByPolygonIndex:[],shadowRendered:[],polygons:K,voxelSource:a.voxelSource,disposed:!1,stableDom:U,hasBuckets:!1,skipBucketNormalCleanupOnce:!1,excludeFromAutoCenter:!!m.excludeFromAutoCenter,castShadow:!!m.castShadow,bboxCenterCss:se,receiveShadow:!!m.receiveShadow,cameraCullGroups:[],cameraCullSignature:"",lightOverrideSignature:"clear",stableTriangleColorFrame:0,solidLightingPreviewPrepared:!1,solidLightingPreviewActive:!1,bakedRotation:m.rotation?[...m.rotation]:[0,0,0],autoMeshId:W,rebakeInFlight:!1,rebakeQueuedLightDir:null},Ze=null,yo=0,Rn=-1,Xt=null;function Zt(){Ze=null,Xt=null,Rn=-1}function nr(){let N=Ze;if(!N||N.polygonCount!==M.polygons.length)return M.polygons;if(Xt&&Rn===yo)return Xt;let X=N.vertices,ue=new Array(N.polygonCount);for(let ye=0;ye<N.polygonCount;ye++){let Oe=M.polygons[ye],pe=ye*9;ue[ye]={...Oe,color:N.colors?.[ye]??Oe.color,vertices:[[X[pe],X[pe+1],X[pe+2]],[X[pe+3],X[pe+4],X[pe+5]],[X[pe+6],X[pe+7],X[pe+8]]]}}return Xt=ue,Rn=yo,ue}function or(N,X){let ue=N?.stableTriangleUpdateMode==="color-only";M.stableTriangleColorFrame++;let ye=M.stableDom&&!X;if(ye||Ne(M.polygons),M.stableDom&&!M.hasBuckets){let Oe={doc:l,directionalLight:ut(i.directionalLight),ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed},pe=M.rendered.length===M.polygons.length&&M.rendered.every(He=>He.kind==="triangle"),xe=M.stableDom&&!X,Ge=pe||xe?{}:Ot(M.polygons,Oe);pe||vt(M.wrapper,Ge);let Qe={...Oe,solidPaintDefaults:Ge,optimizeStableTriangleStyle:!0,stableTriangleDebug:N?.stableTriangleDebug,stableTriangleUpdateMode:N?.stableTriangleUpdateMode,stableTriangleColorPolicy:N?.stableTriangleColorPolicy,stableTriangleColorSteps:N?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:N?.stableTriangleColorFreezeFrames,stableTriangleColorBudget:N?.stableTriangleColorBudget,stableTriangleColorMaxAge:N?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:N?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:N?.stableTriangleMatrixDecimals,stableTriangleColorFrame:M.stableTriangleColorFrame};if(Un(M.rendered,M.polygons,Qe))return ue||(_(M),fe(M,!0),X&&ht()),!0}return ye&&Ne(M.polygons),!1}let Et={get polygons(){return nr()},set polygons(N){Zt(),M.polygons=N},element:E,id:m.id,get transform(){return B},remove(){Y++,E.parentNode&&E.parentNode.removeChild(E),H(M),f.delete(M),b.delete(E),z(M),O(M),ht(),tt()},setPolygons(N,X){Y++,I=X?.merge??I,U=X?.stableDom??U,M.stableDom=U,M.voxelSource=void 0,M.polygons=ie(N,I),O(M),z(M),Zt(),Et.polygons=M.polygons;let ue=X?.recomputeAutoCenter??!0;or(X,ue)||(Me(M),ue&&ht())},[xi](N,X){let ue=X?.merge??I,ye=X?.stableDom??U;if(!N.solidTriangles||!ye||ue||m.meshResolution!==void 0||M.hasBuckets||N.polygonCount!==M.polygons.length||N.vertices.length<N.polygonCount*9||M.rendered.length!==N.polygonCount)return!1;for(let xe=0;xe<M.rendered.length;xe++){let Ge=M.rendered[xe],Qe=M.polygons[xe];if(Ge?.kind!=="triangle"||Ge.polygonIndex!==xe||!Qe||Qe.vertices.length!==3||Qe.texture||Qe.material?.texture)return!1}let Oe=X?.recomputeAutoCenter??!0;if(!Oe){let xe=M.stableTriangleColorFrame+1,Ge={doc:l,directionalLight:ut(i.directionalLight),ambientLight:i.ambientLight,textureLighting:i.textureLighting,textureQuality:i.textureQuality,seamBleed:i.seamBleed,solidPaintDefaults:{},optimizeStableTriangleStyle:!0,stableTriangleDebug:X?.stableTriangleDebug,stableTriangleUpdateMode:X?.stableTriangleUpdateMode,stableTriangleColorPolicy:X?.stableTriangleColorPolicy,stableTriangleColorSteps:X?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:X?.stableTriangleColorFreezeFrames??0,stableTriangleColorBudget:X?.stableTriangleColorBudget,stableTriangleColorMaxAge:X?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:X?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:X?.stableTriangleMatrixDecimals,stableTriangleColorFrame:xe};if($n(M.rendered,M.polygons,N,Ge))return Y++,I=ue,U=ye,M.stableDom=U,M.voxelSource=void 0,M.stableTriangleColorFrame=xe,Ze=N,yo++,Xt=null,Rn=-1,Q(M)?(_(M),fe(M,!0)):ae(M),!0}Y++,I=ue,U=ye,M.stableDom=U,M.voxelSource=void 0;let pe=N.vertices;for(let xe=0;xe<N.polygonCount;xe++){let Ge=M.polygons[xe],Qe=N.colors?.[xe];Qe&&(Ge.color=Qe);let He=Ge.vertices,qe=xe*9;He[0][0]=pe[qe],He[0][1]=pe[qe+1],He[0][2]=pe[qe+2],He[1][0]=pe[qe+3],He[1][1]=pe[qe+4],He[1][2]=pe[qe+5],He[2][0]=pe[qe+6],He[2][1]=pe[qe+7],He[2][2]=pe[qe+8]}return Zt(),Et.polygons=M.polygons,or(X,Oe)},updatePolygon(N,X){let ue=typeof N=="number"?N:M.polygons.indexOf(N);if(ue<0&&typeof N!="number"&&Ze&&(ue=nr().indexOf(N)),ue<0||ue>=M.polygons.length)return;Zt(),M.voxelSource=void 0,Object.assign(M.polygons[ue],X);let ye=Object.keys(X);Wt(M,ue,ye)||Me(M)},async setPolygonsChunked(N,X){let ue=++Y;I=X?.merge??I,U=X?.stableDom??U,M.stableDom=U,M.voxelSource=void 0,M.polygons=ie(N,I),Zt(),Et.polygons=M.polygons,Ne(M.polygons);let ye=X?.recomputeAutoCenter??!0;if(!await _n(M,()=>M.disposed||ue!==Y)){H(M);return}ye&&ht()},setTransform(N){let X=M.castShadow,ue=M.receiveShadow;N.castShadow!==void 0&&(M.castShadow=!!N.castShadow),N.receiveShadow!==void 0&&(M.receiveShadow=!!N.receiveShadow),B={...B,...N};let ye=Yn(B);E.style.transform=ye??"",mt(M,B.rotation),N.rotation!==void 0&&fe(M,!0),M.castShadow!==X&&(M.voxelSource&&Me(M),Ye(M),tt()),M.receiveShadow!==ue&&(M.receiveShadow||Wo(M),k(),Le()),(N.position!==void 0||N.scale!==void 0)&&(M.castShadow||M.receiveShadow)&&(tt(),k(),Le())},dispose(){if(!M.disposed){M.disposed=!0,Y++,E.parentNode&&E.parentNode.removeChild(E),H(M);try{a.dispose()}catch{}f.delete(M),b.delete(E),ht(),tt()}},rebakeAtlas(){M.bakedRotation=B.rotation?[...B.rotation]:[0,0,0];let N=i.directionalLight?.direction??[.4,-.7,.59],X=(0,ne.inverseRotateVec3)(N,M.bakedRotation);fo(M,X)},getPosition(){return B.position},getRotation(){return B.rotation},getScale(){return B.scale},getPolygons(){return Et.polygons}};return M.handle=Et,Xe=M,b.set(E,M),f.add(M),Me(M),mt(M,B.rotation),ht(),tt(),M.receiveShadow&&(k(),Le()),Et}function ts(a){let m=!!i.autoCenter,S=i.strategies,E=i.seamBleed,W=i.textureLighting,B=i.directionalLight?.direction,I=i.shadow,U=Pi(a);i={...i,...U},x.options.current=i,q(h,i);let Y=!!i.autoCenter;for(let Ze of f)mt(Ze,Ze.handle.transform.rotation);let de=a.strategies!==void 0&&!qr(a.strategies,S),ie=Object.prototype.hasOwnProperty.call(a,"seamBleed")&&U.seamBleed!==E;if(de||ie)for(let Ze of f)Me(Ze);m!==Y&&ht();let K=a.textureLighting!==void 0&&W!==i.textureLighting,se=i.directionalLight?.direction,te=a.directionalLight!==void 0&&!Kr(B,se),Ne=i.shadow,Xe=a.shadow!==void 0&&!Jr(I,Ne),M=te||Xe;if(K){if(!de&&!ie)for(let Ze of f)Me(Ze);tt(),k(),Le()}else M&&(Xe&&k(),Le());Xe&&a.shadow?.lift!==I?.lift&&tt()}function ns(){return i}function os(){D(h);for(let a of f)fe(a)}function rs(){let a=[];for(let m of f)a.push(m.handle);return a}function is(a){let m=a;for(;m;){if(m instanceof HTMLElement){let S=b.get(m);if(S&&!S.disposed)return S.handle;if(m.classList.contains("polycss-mesh"))return null}m=m.parentElement}return null}function ss(){let a=Array.from(f);for(let m of a)try{m.handle.dispose()}catch{}p.parentNode&&p.parentNode.removeChild(p)}return{add:es,setOptions:ts,destroy:ss,host:e,camera:t,cameraEl:p,sceneElement:h,applyCamera:os,getOptions:ns,meshes:rs,findMeshByElement:is,previewBakedSolidLighting:le,commitBakedSolidLighting:po,clearBakedSolidLightingPreview:mo}}var Yo=require("@layoutit/polycss-core"),La=32e3;function qn(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Yo.createIsometricCamera)(n),o=`${e.perspective??La}px`;return{get state(){return t.state},update(r){t.update(r)},getStyle(r){return t.getStyle(r)},type:"perspective",perspectiveStyle:o}}function rn(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Yo.createIsometricCamera)(n);return{get state(){return t.state},update(o){t.update(o)},getStyle(o){return t.getStyle(o)},type:"orthographic",perspectiveStyle:"none"}}var _a=typeof HTMLElement<"u"?HTMLElement:class{},Ra=["perspective","rot-x","rot-y","zoom","directional-direction","directional-color","directional-intensity","ambient-color","ambient-intensity","texture-lighting","texture-quality","auto-center"];function je(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function ka(e){return e==="false"?!1:je(e)}function Xo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Da(e){if(e==="baked"||e==="dynamic")return e}function Oa(e){return e==="auto"?"auto":je(e)}function Ha(e){return typeof e.getCamera=="function"}var _e=class extends _a{constructor(){super(...arguments);this._scene=null;this._implicitCamera=null}static get observedAttributes(){return[...Ra]}getScene(){return this._scene}_findAncestorCamera(){let t=this.parentElement;for(;t;){if(Ha(t)){let o=t.getCamera();if(o)return o}t=t.parentElement}return null}_buildImplicitCamera(){let t=ka(this.getAttribute("perspective")),o=je(this.getAttribute("rot-x")),r=je(this.getAttribute("rot-y")),i=je(this.getAttribute("zoom")),s=je(this.getAttribute("distance")),c=Xo(this.getAttribute("target")),l={...o!==void 0?{rotX:o}:{},...r!==void 0?{rotY:r}:{},...i!==void 0?{zoom:i}:{},...s!==void 0?{distance:s}:{},...c!==void 0?{target:c}:{}};return t===!1?rn(l):t!==void 0?qn({...l,perspective:t}):rn(l)}_readNonCameraOptions(){let t=this._readDirectionalLight(),o=this._readAmbientLight(),r={};r.textureLighting=Da(this.getAttribute("texture-lighting"))??"baked";let i=Oa(this.getAttribute("texture-quality"));return i!==void 0&&(r.textureQuality=i),r.autoCenter=this.hasAttribute("auto-center"),t&&(r.directionalLight=t),o&&(r.ambientLight=o),r}_readDirectionalLight(){let t=Xo(this.getAttribute("directional-direction")),o=this.getAttribute("directional-color")||void 0,r=je(this.getAttribute("directional-intensity"));if(!t&&!o&&r===void 0)return;let i={direction:t??[.4,-.7,.59]};return o&&(i.color=o),r!==void 0&&(i.intensity=r),i}_readAmbientLight(){let t=this.getAttribute("ambient-color")||void 0,o=je(this.getAttribute("ambient-intensity"));if(!t&&o===void 0)return;let r={};return t&&(r.color=t),o!==void 0&&(r.intensity=o),r}connectedCallback(){if(this._scene)return;let t=this._findAncestorCamera(),o;t?(o=t,this._implicitCamera=null):(this._implicitCamera=this._buildImplicitCamera(),o=this._implicitCamera),this._scene=Ci(this,{camera:o,...this._readNonCameraOptions()}),this.dispatchEvent(new CustomEvent("polycss:scene-ready",{bubbles:!1}))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null),this._implicitCamera=null}attributeChangedCallback(t,o,r){if(o!==r&&this._scene){if(this._implicitCamera&&["rot-x","rot-y","zoom","distance","target"].includes(t)){let s=je(this.getAttribute("rot-x")),c=je(this.getAttribute("rot-y")),l=je(this.getAttribute("zoom")),p=je(this.getAttribute("distance")),h=Xo(this.getAttribute("target"));s!==void 0&&this._implicitCamera.update({rotX:s}),c!==void 0&&this._implicitCamera.update({rotY:c}),l!==void 0&&this._implicitCamera.update({zoom:l}),p!==void 0&&this._implicitCamera.update({distance:p}),h!==void 0&&this._implicitCamera.update({target:h}),this._scene.applyCamera();return}this._scene.setOptions(this._readNonCameraOptions())}}};var Kn=require("@layoutit/polycss-core"),Ia=typeof HTMLElement<"u"?HTMLElement:class{},Fa=["src","mtl","mesh-resolution","position","scale","rotation","auto-center","cast-shadow","receive-shadow","target-size","default-color","palette","include-objects","exclude-objects"];function sn(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Ei(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return sn(e)}}function Zo(e){if(!e)return;let n=e.split(",").map(t=>t.trim()).filter(t=>t.length>0);return n.length>0?n:void 0}function Va(e){let n=e.getAttribute("target-size"),t=e.getAttribute("default-color"),o=Zo(e.getAttribute("palette")),r=Zo(e.getAttribute("include-objects")),i=Zo(e.getAttribute("exclude-objects")),s=n!==null?parseFloat(n):NaN,c={};return Number.isFinite(s)&&(c.targetSize=s),t&&(c.defaultColor=t),o&&(c.palette=o),r&&(c.includeObjects=r),i&&(c.excludeObjects=i),Object.keys(c).length>0?c:void 0}function Ba(e){return e.closest("poly-scene")??null}function za(e){if(e.length===0)return e;let n=(0,Kn.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,r=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&r===0)return e;let i=s=>[s[0]-t,s[1]-o,s[2]-r];return e.map(s=>({...s,vertices:s.vertices.map(i),...s.textureTriangles?.length?{textureTriangles:s.textureTriangles.map(c=>({...c,vertices:c.vertices.map(i)}))}:null}))}var xt=class extends Ia{constructor(){super(...arguments);this._handle=null;this._parseResult=null;this._loadToken=0}static get observedAttributes(){return[...Fa]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r){if(t==="src"||t==="mtl"||t==="mesh-resolution"||t==="target-size"||t==="default-color"||t==="palette"||t==="include-objects"||t==="exclude-objects"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform({position:sn(this.getAttribute("position")),scale:Ei(this.getAttribute("scale")),rotation:sn(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")})}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}this._parseResult=null}async _maybeLoad(){let t=this.getAttribute("src");if(!t)return;let o=Ba(this);if(!o)return;let r=++this._loadToken,i=this.getAttribute("mtl")||void 0,c=this.getAttribute("mesh-resolution")==="lossless"?"lossless":void 0,l=Va(this),p;try{let f=i||c!==void 0||l?{...i?{mtlUrl:i}:{},...c!==void 0?{meshResolution:c}:{},...l?{objOptions:l}:{}}:void 0;p=await(0,Kn.loadMesh)(t,f)}catch(f){this.dispatchEvent(new CustomEvent("polycss:error",{detail:f,bubbles:!0}));return}if(r!==this._loadToken){try{p.dispose()}catch{}return}let h=o.getScene();if(!h){try{p.dispose()}catch{}return}this.hasAttribute("auto-center")&&(p={...p,polygons:za(p.polygons)}),this._parseResult=p,this._handle=h.add(p,{position:sn(this.getAttribute("position")),scale:Ei(this.getAttribute("scale")),rotation:sn(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}),this.dispatchEvent(new CustomEvent("polycss:loaded",{detail:{polygons:this._handle.polygons},bubbles:!0}))}};var zt=require("@layoutit/polycss-core"),Na=typeof HTMLElement<"u"?HTMLElement:class{},Ga=["src","width","height","position","rotation","scale","allow","loading","referrerpolicy","sandbox","title"];function Qo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function $a(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Qo(e)}}function Ti(e,n){if(e===null)return n;let t=parseFloat(e);return Number.isFinite(t)?t:n}function Ua(e){let n=e.closest("poly-scene");return n?n.querySelector(".polycss-scene"):null}function ja(e,n,t,o,r){let i=typeof t=="number"?t:t?.[0]??1,s=typeof t=="number"?t:t?.[1]??1,c=typeof t=="number"?t:t?.[2]??1,l=i!==1||s!==1||c!==1,p=!!n&&(!!n[0]||!!n[1]||!!n[2]),h=(e?.[1]??0)*zt.BASE_TILE,x=(e?.[0]??0)*zt.BASE_TILE,f=(e?.[2]??0)*zt.BASE_TILE,b=[];return b.push(`translate3d(${h}px, ${x}px, ${f}px)`),p&&(n[0]&&b.push(`rotateY(${-n[0]}deg)`),n[1]&&b.push(`rotateX(${-n[1]}deg)`),n[2]&&b.push(`rotateZ(${-n[2]}deg)`)),l&&b.push(`scale3d(${i}, ${s}, ${c})`),b.push(`translate(${-o/2}px, ${-r/2}px)`),b.join(" ")}var an=class extends Na{constructor(){super(...arguments);this._wrapper=null;this._iframe=null}static get observedAttributes(){return[...Ga]}getIframeElement(){return this._iframe}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o!==r&&!(!this._wrapper||!this._iframe)){if(t==="src"){this._iframe.src=this.getAttribute("src")??"";return}if(t==="allow"||t==="loading"||t==="referrerpolicy"||t==="sandbox"||t==="title"){let i=this.getAttribute(t);i===null?this._iframe.removeAttribute(t):this._iframe.setAttribute(t,i);return}this._applyGeometry()}}_mount(){let t=Ua(this);if(!t)return;let o=this.ownerDocument;if(!o)return;let r=o.createElement("div");r.className="polycss-iframe",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.transformOrigin="0 0",r.style.transformStyle="preserve-3d";let i=o.createElement("iframe");i.style.display="block",i.style.border="0",i.style.background="#000";let s=this.getAttribute("src");s&&(i.src=s);let c=this.getAttribute("allow");c&&i.setAttribute("allow",c);for(let l of["loading","referrerpolicy","sandbox","title"]){let p=this.getAttribute(l);p!==null&&i.setAttribute(l,p)}r.appendChild(i),t.appendChild(r),this._wrapper=r,this._iframe=i,this._applyGeometry()}_applyGeometry(){if(!this._wrapper||!this._iframe)return;let t=Ti(this.getAttribute("width"),16),o=Ti(this.getAttribute("height"),9),r=t*zt.BASE_TILE,i=o*zt.BASE_TILE;this._iframe.style.width=`${r}px`,this._iframe.style.height=`${i}px`;let s=Qo(this.getAttribute("position")),c=Qo(this.getAttribute("rotation")),l=$a(this.getAttribute("scale"));this._wrapper.style.transform=ja(s,c,l,r,i)}_teardown(){this._wrapper?.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null,this._iframe=null}};var Wa=typeof HTMLElement<"u"?HTMLElement:class{},Ya=["vertices","color","texture","uvs","position","scale","rotation"];function Ai(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function qo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Xa(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return qo(e)}}function Za(e){return e.closest("poly-scene")??null}var ln=class extends Wa{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...Ya]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){o!==r&&(this._tearDown(),this.isConnected&&this._mount())}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=Za(this);if(!t)return;let o=t.getScene();if(!o)return;let r=Ai(this.getAttribute("vertices"));if(!r||!Array.isArray(r)||r.length<3)return;let i=this.getAttribute("color")||void 0,s=this.getAttribute("texture")||void 0,c=Ai(this.getAttribute("uvs"))??void 0,l={};for(let x of Array.from(this.attributes))x.name.startsWith("data-")&&(l[x.name.slice(5)]=x.value);let h={polygons:[{vertices:r,...i!==void 0?{color:i}:{},...s!==void 0?{texture:s}:{},...c!==void 0?{uvs:c}:{},...Object.keys(l).length>0?{data:l}:{}}],objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(h,{position:qo(this.getAttribute("position")),scale:Xa(this.getAttribute("scale")),rotation:qo(this.getAttribute("rotation"))})}};var wi=require("@layoutit/polycss-core"),Qa=typeof HTMLElement<"u"?HTMLElement:class{},qa=["size","thickness","negative","x-color","y-color","z-color"];function Ka(e){return e.closest("poly-scene")??null}function Mi(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}var cn=class extends Qa{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...qa]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){o!==r&&this._handle&&this._remount()}_polygons(){return(0,wi.axesHelperPolygons)({size:Mi(this.getAttribute("size")),thickness:Mi(this.getAttribute("thickness")),negative:this.hasAttribute("negative"),xColor:this.getAttribute("x-color")??void 0,yColor:this.getAttribute("y-color")??void 0,zColor:this.getAttribute("z-color")??void 0})}_mount(){let t=Ka(this);if(!t)return;let o=t.getScene();if(!o)return;let r={polygons:this._polygons(),objectUrls:[],dispose:()=>{},warnings:[]};this._handle=o.add(r,{excludeFromAutoCenter:!0,merge:!1})}_remount(){this._tearDown(),this._mount()}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}};var Ri=require("@layoutit/polycss-core"),Ja=typeof HTMLElement<"u"?HTMLElement:class{},el=["direction","target","distance","size","color"],tl=5,nl=.35,ol="#ffd54a";function rl(e){return e.closest("poly-scene")??null}function Li(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function _i(e,n){if(e==null)return n;let t=parseFloat(e);return Number.isFinite(t)?t:n}var dn=class extends Ja{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...el]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r&&this._handle){if(t==="size"||t==="color"){this._remount();return}this._handle.setTransform({position:this._meshPosition()})}}_meshPosition(){let t=Li(this.getAttribute("direction"));if(!t)return;let o=Li(this.getAttribute("target"))??[0,0,0],r=_i(this.getAttribute("distance"),tl),[i,s,c]=t,l=Math.hypot(i,s,c)||1;return[o[0]+i/l*r,o[1]+s/l*r,o[2]+c/l*r]}_mount(){let t=rl(this);if(!t)return;let o=t.getScene();if(!o)return;let r=_i(this.getAttribute("size"),nl),i=this.getAttribute("color")??ol,s={polygons:(0,Ri.octahedronPolygons)({center:[0,0,0],size:r,color:i}),objectUrls:[],dispose:()=>{},warnings:[]};this._handle=o.add(s,{position:this._meshPosition(),excludeFromAutoCenter:!0,merge:!1})}_remount(){this._tearDown(),this._mount()}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}};var ki=require("@layoutit/polycss-core");var Jn={drag:!0,wheel:!0,dolly:!1,invert:!1,minZoom:.1,maxZoom:10,minDistance:0,maxDistance:1/0,animate:!1};function Nt(e,n){let t;return n.animate===!1?t=!1:n.animate?t={speed:n.animate.speed??.3,axis:n.animate.axis??"y",pauseOnInteraction:n.animate.pauseOnInteraction??!0}:t=e.animate,{drag:n.drag??e.drag,wheel:n.wheel??e.wheel,dolly:n.dolly??e.dolly,invert:n.invert??e.invert,minZoom:n.minZoom??e.minZoom,maxZoom:n.maxZoom??e.maxZoom,minDistance:n.minDistance??e.minDistance,maxDistance:n.maxDistance??e.maxDistance,animate:t}}function un(e){return e===!0?-1:e===!1?1:e}function Gt(){let e=[],n=[],t=[];function o(s){return s==="change"?e:s==="start"?n:t}function r(s){if(e.length===0)return;let c={type:"change",camera:s()},l=e.slice();for(let p of l)try{p(c)}catch(h){console.error("[polycss] controls 'change' listener threw:",h)}}function i(s,c){let l=s==="start"?n:t;if(l.length===0)return;let p={type:s,camera:c()},h=l.slice();for(let x of h)try{x(p)}catch(f){console.error(`[polycss] controls '${s}' listener threw:`,f)}}return{changeListeners:e,startListeners:n,endListeners:t,listenerArray:o,emitChange:r,emitInteraction:i}}function $t(e){return()=>{let n=e.camera.state,t=n.target??[0,0,0];return{rotX:n.rotX??0,rotY:n.rotY??0,zoom:n.zoom??1,target:[t[0],t[1],t[2]],distance:n.distance??0}}}function eo(e,n,t,o,r,i){let s=!1,c=null;return{onWheel:h=>{let x=n();if(!x.wheel||t())return;h.preventDefault();let f=h.deltaMode===1?16:h.deltaMode===2?100:1,b=h.deltaY*f;h.ctrlKey?b*=10:b*=3;let y=e.camera.state;if(x.dolly){let P=y.distance??0,v=Math.max(x.minDistance,Math.min(x.maxDistance,P+b*.05));e.camera.update({distance:v})}else{let P=Math.exp(-b*513e-6),v=y.zoom??1,C=Math.max(x.minZoom,Math.min(x.maxZoom,v*P));e.camera.update({zoom:C})}e.applyCamera(),s||(s=!0,i("start",o)),r(o),c!==null&&clearTimeout(c),c=setTimeout(()=>{c=null,s=!1,i("end",o)},150)},teardown:()=>{c!==null&&(clearTimeout(c),c=null),s=!1}}}function to(e,n,t,o,r,i,s){let c=null,l=0,p=b=>{if(c===null||o())return;let y=t();if(!y.animate){c=null;return}if(r())l=b;else{let P=Math.min(50,l?b-l:16.67);l=b;let v=y.animate.speed*(P/16.67),C=n.camera.state;if(y.animate.axis==="x"){let F=(((C.rotX??65)+v)%360+360)%360;n.camera.update({rotX:F})}else{let F=(((C.rotY??45)+v)%360+360)%360;n.camera.update({rotY:F})}n.applyCamera(),s(i)}c=e.requestAnimationFrame(p)};return{start:()=>{c!==null||!t().animate||o()||(l=0,c=e.requestAnimationFrame(p))},stop:()=>{c!==null&&(e.cancelAnimationFrame(c),c=null)},isRunning:()=>c!==null}}function Di(e,n={}){let t=Nt(Jn,n),o=e.host,r=o.ownerDocument?.defaultView??globalThis,i=null,s={x:0,y:0},c=!1,l=!1,p=Gt(),h=$t(e),{changeListeners:x,startListeners:f,endListeners:b,listenerArray:y,emitChange:P,emitInteraction:v}=p,C=to(r,e,()=>t,()=>l,()=>c,h,P),F=d=>{if(!(!t.drag||l)&&i===null&&d.isPrimary!==!1){d.preventDefault(),i=d.pointerId,s={x:d.clientX,y:d.clientY},o.style.cursor="grabbing";try{d.target.setPointerCapture(d.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),v("start",h)}},k=d=>{if(i===null||d.pointerId!==i||!t.drag||l)return;d.preventDefault();let T=d.clientX-s.x,w=d.clientY-s.y;s={x:d.clientX,y:d.clientY};let R=un(t.invert),L=T/4*R,re=w/4*R,_=e.camera.state;if(d.shiftKey){let j=_.rotX??65,Q=_.rotY??45,ae=Math.max(.01,_.zoom??1),be=Math.cos(j*Math.PI/180),fe=be>=0?Math.max(.1,be):Math.min(-.1,be),ge=Math.cos(Q*Math.PI/180),we=Math.sin(Q*Math.PI/180),Se=ae*ki.BASE_TILE,ke=(T*we-w*ge/fe)/Se,We=-(T*ge+w*we/fe)/Se,et=_.target??[0,0,0];e.camera.update({target:[et[0]+ke,et[1]+We,et[2]]})}else{let j=Math.max(0,Math.min(89,(_.rotX??65)-re)),Q=(((_.rotY??45)-L)%360+360)%360;e.camera.update({rotX:j,rotY:Q})}e.applyCamera(),P(h)},z=d=>{if(i===d.pointerId){i=null,o.style.cursor=t.drag&&!l?"grab":"";try{d.target.releasePointerCapture(d.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),v("end",h)}},O=eo(e,()=>t,()=>l,h,P,v);function Z(){o.addEventListener("pointerdown",F),o.addEventListener("pointermove",k),o.addEventListener("pointerup",z),o.addEventListener("pointercancel",z),o.addEventListener("wheel",O.onWheel,{passive:!1}),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function q(){o.removeEventListener("pointerdown",F),o.removeEventListener("pointermove",k),o.removeEventListener("pointerup",z),o.removeEventListener("pointercancel",z),o.removeEventListener("wheel",O.onWheel),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",O.teardown()}Z(),C.start();function D(d){let T=!!t.animate;t=Nt(t,d),!l&&i===null&&(o.style.cursor=t.drag?"grab":"");let w=!!t.animate;T&&!w?C.stop():!T&&w&&C.start()}function H(){l&&(l=!1,Z(),C.start())}function V(){l||(l=!0,q(),C.stop(),i=null,c=!1,O.teardown())}function G(){V(),x.length=0,f.length=0,b.length=0}function A(d,T){let w=y(d);w.includes(T)||w.push(T)}function g(d,T){let w=y(d),R=w.indexOf(T);R>=0&&w.splice(R,1)}function u(d,T){return y(d).includes(T)}return{update:D,resume:H,pause:V,destroy:G,addEventListener:A,removeEventListener:g,hasEventListener:u}}function oe(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function no(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Re(e){if(e!==null)return!(e==="false"||e==="0")}function oo(e){if(e===null)return;if(e==="true")return!0;if(e==="false")return!1;let n=parseFloat(e);return Number.isFinite(n)?n:!0}function ro(e){if(e==="x"||e==="y")return e}var il=typeof HTMLElement<"u"?HTMLElement:class{},sl=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],pn=class extends il{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...sl]}getControls(){return this._controls}_readAnimate(){let t=oe(this.getAttribute("animate-speed")),o=ro(this.getAttribute("animate-axis")),r=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...r!==null?{pauseOnInteraction:Re(r)}:{}}}_readOptions(){let t={},o=Re(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let r=Re(this.getAttribute("wheel"));r!==void 0&&(t.wheel=r),this.hasAttribute("dolly")&&(t.dolly=!0);let i=oe(this.getAttribute("min-distance"));i!==void 0&&(t.minDistance=i);let s=oe(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=oo(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=oe(this.getAttribute("zoom-min")),p=oe(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),p!==void 0&&(t.maxZoom=p),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=Di(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var Oi=require("@layoutit/polycss-core");function Hi(e,n={}){let t=Nt(Jn,n),o=e.host,r=o.ownerDocument?.defaultView??globalThis,i=null,s={x:0,y:0},c=!1,l=!1,p=!1,h={x:0,y:0},x=Gt(),f=$t(e),{changeListeners:b,startListeners:y,endListeners:P,listenerArray:v,emitChange:C,emitInteraction:F}=x,k=to(r,e,()=>t,()=>l,()=>c,f,C),z=_=>{if(!(!t.drag||l)&&i===null&&_.isPrimary!==!1){_.preventDefault(),i=_.pointerId,s={x:_.clientX,y:_.clientY},o.style.cursor="grabbing";try{_.target.setPointerCapture(_.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),F("start",f)}},O=_=>{if(i===null||_.pointerId!==i||!t.drag||l)return;_.preventDefault();let j=_.clientX-s.x,Q=_.clientY-s.y;s={x:_.clientX,y:_.clientY};let ae=e.camera.state;if(_.shiftKey){let be=un(t.invert),fe=j/4*be,ge=Q/4*be,we=(ae.rotX??65)-ge,Se=(((ae.rotY??45)-fe)%360+360)%360;e.camera.update({rotX:we,rotY:Se})}else{let be=ae.rotX??65,fe=ae.rotY??45,ge=Math.max(.01,ae.zoom??1),we=Math.cos(be*Math.PI/180),Se=we>=0?Math.max(.1,we):Math.min(-.1,we),ke=Math.cos(fe*Math.PI/180),We=Math.sin(fe*Math.PI/180),et=ge*Oi.BASE_TILE,mt=(j*We-Q*ke/Se)/et,Ct=-(j*ke+Q*We/Se)/et,ft=ae.target??[0,0,0];e.camera.update({target:[ft[0]+mt,ft[1]+Ct,ft[2]]})}e.applyCamera(),C(f)},Z=_=>{if(i===_.pointerId){i=null,o.style.cursor=t.drag&&!l?"grab":"";try{_.target.releasePointerCapture(_.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),F("end",f)}},q=_=>{_.preventDefault()},D=_=>{_.button===2&&(p=!0,h={x:_.clientX,y:_.clientY},t.animate&&t.animate.pauseOnInteraction&&(c=!0),F("start",f))},H=_=>{if(!p||!t.drag)return;let j=_.clientX-h.x,Q=_.clientY-h.y;h={x:_.clientX,y:_.clientY};let ae=un(t.invert),be=j/4*ae,fe=Q/4*ae,ge=e.camera.state,we=(ge.rotX??65)-fe,Se=(((ge.rotY??45)-be)%360+360)%360;e.camera.update({rotX:we,rotY:Se}),e.applyCamera(),C(f)},V=_=>{_.button===2&&p&&(p=!1,F("end",f))},G=eo(e,()=>t,()=>l,f,C,F);function A(){o.addEventListener("pointerdown",z),o.addEventListener("pointermove",O),o.addEventListener("pointerup",Z),o.addEventListener("pointercancel",Z),o.addEventListener("wheel",G.onWheel,{passive:!1}),o.addEventListener("contextmenu",q),o.addEventListener("mousedown",D),o.addEventListener("mousemove",H),o.addEventListener("mouseup",V),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function g(){o.removeEventListener("pointerdown",z),o.removeEventListener("pointermove",O),o.removeEventListener("pointerup",Z),o.removeEventListener("pointercancel",Z),o.removeEventListener("wheel",G.onWheel),o.removeEventListener("contextmenu",q),o.removeEventListener("mousedown",D),o.removeEventListener("mousemove",H),o.removeEventListener("mouseup",V),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",G.teardown()}A(),k.start();function u(_){let j=!!t.animate;t=Nt(t,_),!l&&i===null&&(o.style.cursor=t.drag?"grab":"");let Q=!!t.animate;j&&!Q?k.stop():!j&&Q&&k.start()}function d(){l&&(l=!1,A(),k.start())}function T(){l||(l=!0,g(),k.stop(),i=null,c=!1,p=!1,G.teardown())}function w(){T(),b.length=0,y.length=0,P.length=0}function R(_,j){let Q=v(_);Q.includes(j)||Q.push(j)}function L(_,j){let Q=v(_),ae=Q.indexOf(j);ae>=0&&Q.splice(ae,1)}function re(_,j){return v(_).includes(j)}return{update:u,resume:d,pause:T,destroy:w,addEventListener:R,removeEventListener:L,hasEventListener:re}}var al=typeof HTMLElement<"u"?HTMLElement:class{},ll=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],mn=class extends al{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...ll]}_readAnimate(){let t=oe(this.getAttribute("animate-speed")),o=ro(this.getAttribute("animate-axis")),r=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...r!==null?{pauseOnInteraction:Re(r)}:{}}}_readOptions(){let t={},o=Re(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let r=Re(this.getAttribute("wheel"));r!==void 0&&(t.wheel=r),this.hasAttribute("dolly")&&(t.dolly=!0);let i=oe(this.getAttribute("min-distance"));i!==void 0&&(t.minDistance=i);let s=oe(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=oo(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=oe(this.getAttribute("zoom-min")),p=oe(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),p!==void 0&&(t.maxZoom=p),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=Hi(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var Gi=require("@layoutit/polycss-core");var cl={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function Ii(e,n){return{enabled:n.enabled??e.enabled,lookEnabled:n.lookEnabled??e.lookEnabled,moveEnabled:n.moveEnabled??e.moveEnabled,jumpEnabled:n.jumpEnabled??e.jumpEnabled,crouchEnabled:n.crouchEnabled??e.crouchEnabled,lookSensitivity:n.lookSensitivity??e.lookSensitivity,invertY:n.invertY??e.invertY,moveSpeed:n.moveSpeed??e.moveSpeed,jumpVelocity:n.jumpVelocity??e.jumpVelocity,gravity:n.gravity??e.gravity,eyeHeight:n.eyeHeight??e.eyeHeight,crouchHeight:n.crouchHeight??e.crouchHeight,groundZ:n.groundZ??e.groundZ,minPitch:n.minPitch??e.minPitch,maxPitch:n.maxPitch??e.maxPitch}}var Fi=new Set(["KeyW","ArrowUp"]),Vi=new Set(["KeyS","ArrowDown"]),Bi=new Set(["KeyA","ArrowLeft"]),zi=new Set(["KeyD","ArrowRight"]),Ni=new Set(["Space"]),Ko=new Set(["ControlLeft","ControlRight"]);function $i(e,n={}){let t=Ii(cl,n),o=e.host,r=e.cameraEl,i=o.ownerDocument??document,s=i.defaultView??globalThis,c=Gt(),l=$t(e),{changeListeners:p,startListeners:h,endListeners:x,listenerArray:f,emitChange:b,emitInteraction:y}=c,P=new Set,v=!1,C=!1,F=0,k=0,z=!1,O=[0,0,t.groundZ+t.eyeHeight];function Z($,le){let ce=$*Math.PI/180,De=le*Math.PI/180;return[-Math.sin(ce)*Math.cos(De),-Math.sin(ce)*Math.sin(De),-Math.cos(ce)]}function q(){let $=e.camera.perspectiveStyle,le=$==="none"?0:parseFloat($);return(Number.isFinite(le)&&le>0?le:2e3)/Gi.BASE_TILE}function D(){let $=e.camera.state,le=Z($.rotX??90,$.rotY??0),ce=q();return[O[0]+le[0]*ce,O[1]+le[1]*ce,O[2]+le[2]*ce]}function H(){let $=D();e.camera.update({target:$}),e.applyCamera()}function V(){let $=e.camera.state.target??[0,0,0];O=[$[0],$[1],t.groundZ+t.eyeHeight],H()}let G=()=>{if(!(!t.enabled||!t.lookEnabled||C||v))try{o.requestPointerLock()}catch{}},A=()=>{let $=i.pointerLockElement===o;$!==v&&(v=$,v?(z=!0,y("start",l)):z&&(z=!1,y("end",l)))},g=$=>{if(!v||!t.enabled||!t.lookEnabled||C)return;let le=$.movementX??0,ce=$.movementY??0;if(le===0&&ce===0)return;let De=e.camera.state,Wt=t.lookSensitivity,Ye=t.invertY?-1:1,Le=(((De.rotY??0)-le*Wt)%360+360)%360,Ce=(De.rotX??90)-ce*Wt*Ye;Ce<t.minPitch?Ce=t.minPitch:Ce>t.maxPitch&&(Ce=t.maxPitch);let Be=Z(Ce,Le),ze=q(),Me=[O[0]+Be[0]*ze,O[1]+Be[1]*ze,O[2]+Be[2]*ze];e.camera.update({rotX:Ce,rotY:Le,target:Me}),e.applyCamera(),b(l)},u=$=>Fi.has($)||Vi.has($)||Bi.has($)||zi.has($)||Ni.has($)||Ko.has($),d=$=>{if(!(!t.enabled||C)&&u($.code)&&!(!v&&!t.moveEnabled)){if(Ni.has($.code)){if(!t.jumpEnabled)return;$.preventDefault(),!P.has($.code)&&F===0&&k===0&&(F=t.jumpVelocity),P.add($.code);return}Ko.has($.code)&&!t.crouchEnabled||!t.moveEnabled&&!Ko.has($.code)||($.preventDefault(),P.add($.code))}},T=$=>{u($.code)&&P.delete($.code)},w=()=>{P.clear()},R=null,L=0,re=.05,_=$=>{if(R===null||C)return;let le=Math.min(re,L?($-L)/1e3:.0167);if(L=$,t.enabled){let ce=!1,De=e.camera.state;if(t.moveEnabled){let Ce=0,Be=0;for(let ze of P)Fi.has(ze)?Ce+=1:Vi.has(ze)?Ce-=1:zi.has(ze)?Be+=1:Bi.has(ze)&&(Be-=1);if(Ce!==0||Be!==0){let Me=(De.rotY??0)*Math.PI/180,Yt=-Math.cos(Me),fo=-Math.sin(Me),ho=-Math.sin(Me),go=Math.cos(Me),tt=Math.hypot(Ce,Be)||1,_n=t.moveSpeed*le;O[0]+=(Yt*Ce+ho*Be)/tt*_n,O[1]+=(fo*Ce+go*Be)/tt*_n,ce=!0}}let Ye=t.crouchEnabled&&(P.has("ControlLeft")||P.has("ControlRight"))?t.crouchHeight:t.eyeHeight;t.jumpEnabled&&(F!==0||k>0)?(F-=t.gravity*le,k+=F*le,k<=0&&(k=0,F=0)):t.jumpEnabled||(k=0,F=0);let Le=t.groundZ+Ye+k;if(Math.abs(O[2]-Le)>1e-4&&(O[2]=Le,ce=!0),ce){let Ce=D();e.camera.update({target:Ce}),e.applyCamera(),b(l)}}R=s.requestAnimationFrame(_)};function j(){R!==null||C||(L=0,R=s.requestAnimationFrame(_))}function Q(){R!==null&&(s.cancelAnimationFrame(R),R=null)}function ae(){let le=r.ownerDocument?.defaultView?.getComputedStyle(r).perspective??"",ce=parseFloat(le),De=Number.isFinite(ce)&&ce>0?ce:2e3;r.style.setProperty("--polycss-fpv-perspective",`${De}px`),r.classList.add("polycss-fpv-host")}function be(){r.classList.remove("polycss-fpv-host"),r.style.removeProperty("--polycss-fpv-perspective")}function fe(){o.addEventListener("click",G),i.addEventListener("pointerlockchange",A),i.addEventListener("mousemove",g),s.addEventListener("keydown",d),s.addEventListener("keyup",T),s.addEventListener("blur",w),o.style.cursor=t.lookEnabled?"crosshair":"",ae()}function ge(){if(o.removeEventListener("click",G),i.removeEventListener("pointerlockchange",A),i.removeEventListener("mousemove",g),s.removeEventListener("keydown",d),s.removeEventListener("keyup",T),s.removeEventListener("blur",w),o.style.cursor="",P.clear(),v)try{i.exitPointerLock()}catch{}be()}V(),fe(),j();function we($){let le=t.eyeHeight,ce=t.groundZ;t=Ii(t,$),C||(o.style.cursor=t.lookEnabled?"crosshair":""),(t.eyeHeight!==le||t.groundZ!==ce)&&(O[2]=t.groundZ+t.eyeHeight,H(),b(l))}function Se(){C&&(C=!1,fe(),j())}function ke(){C||(C=!0,ge(),Q(),z&&(z=!1,y("end",l)))}function We(){ke(),p.length=0,h.length=0,x.length=0}function et(){if(!(!t.enabled||!t.lookEnabled||C))try{o.requestPointerLock()}catch{}}function mt(){if(v)try{i.exitPointerLock()}catch{}}function Ct(){return v}function ft($,le){let ce=f($);ce.includes(le)||ce.push(le)}function co($,le){let ce=f($),De=ce.indexOf(le);De>=0&&ce.splice(De,1)}function uo($,le){return f($).includes(le)}function po(){return[O[0],O[1],O[2]]}function mo($){O[0]=$[0],O[1]=$[1],O[2]=$[2],H(),b(l)}return{update:we,resume:Se,pause:ke,destroy:We,lock:et,unlock:mt,isLocked:Ct,getOrigin:po,setOrigin:mo,addEventListener:ft,removeEventListener:co,hasEventListener:uo}}var dl=typeof HTMLElement<"u"?HTMLElement:class{},ul=["enabled","look-enabled","move-enabled","jump-enabled","crouch-enabled","look-sensitivity","invert-y","move-speed","jump-velocity","gravity","eye-height","crouch-height","ground-z","min-pitch","max-pitch"],fn=class extends dl{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...ul]}_readOptions(){let t={},o=Re(this.getAttribute("enabled"));o!==void 0&&(t.enabled=o);let r=Re(this.getAttribute("look-enabled"));r!==void 0&&(t.lookEnabled=r);let i=Re(this.getAttribute("move-enabled"));i!==void 0&&(t.moveEnabled=i);let s=Re(this.getAttribute("jump-enabled"));s!==void 0&&(t.jumpEnabled=s);let c=Re(this.getAttribute("crouch-enabled"));c!==void 0&&(t.crouchEnabled=c);let l=oe(this.getAttribute("look-sensitivity"));if(l!==void 0&&(t.lookSensitivity=l),this.hasAttribute("invert-y")){let C=Re(this.getAttribute("invert-y"));C!==void 0&&(t.invertY=C)}let p=oe(this.getAttribute("move-speed"));p!==void 0&&(t.moveSpeed=p);let h=oe(this.getAttribute("jump-velocity"));h!==void 0&&(t.jumpVelocity=h);let x=oe(this.getAttribute("gravity"));x!==void 0&&(t.gravity=x);let f=oe(this.getAttribute("eye-height"));f!==void 0&&(t.eyeHeight=f);let b=oe(this.getAttribute("crouch-height"));b!==void 0&&(t.crouchHeight=b);let y=oe(this.getAttribute("ground-z"));y!==void 0&&(t.groundZ=y);let P=oe(this.getAttribute("min-pitch"));P!==void 0&&(t.minPitch=P);let v=oe(this.getAttribute("max-pitch"));return v!==void 0&&(t.maxPitch=v),t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._controls=$i(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,r){o!==r&&this._controls&&this._controls.update(this._readOptions())}};var pl=typeof HTMLElement<"u"?HTMLElement:class{},ml=["perspective","zoom","rot-x","rot-y","target","distance"],hn=class extends pl{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...ml]}getCamera(){return this._camera}_readOptions(){return{perspective:oe(this.getAttribute("perspective")),zoom:oe(this.getAttribute("zoom")),rotX:oe(this.getAttribute("rot-x")),rotY:oe(this.getAttribute("rot-y")),target:no(this.getAttribute("target")),distance:oe(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=qn(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o===r||!this._camera||!this._wrapper)return;let i=this._readOptions();if(t==="perspective"){let l=i.perspective!==void 0?`${i.perspective}px`:"32000px";this._wrapper.style.perspective=l;return}this._camera.update({rotX:i.rotX,rotY:i.rotY,zoom:i.zoom,target:i.target,distance:i.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var fl=typeof HTMLElement<"u"?HTMLElement:class{},hl=["zoom","rot-x","rot-y","target","distance"],Pt=class extends fl{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...hl]}getCamera(){return this._camera}_readOptions(){return{zoom:oe(this.getAttribute("zoom")),rotX:oe(this.getAttribute("rot-x")),rotY:oe(this.getAttribute("rot-y")),target:no(this.getAttribute("target")),distance:oe(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=rn(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,r){if(o===r||!this._camera)return;let i=this._readOptions();i.zoom!==void 0&&this._camera.update({zoom:i.zoom}),i.rotX!==void 0&&this._camera.update({rotX:i.rotX}),i.rotY!==void 0&&this._camera.update({rotY:i.rotY}),i.target!==void 0&&this._camera.update({target:i.target}),i.distance!==void 0&&this._camera.update({distance:i.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var gn=class extends Pt{};var Ae=require("@layoutit/polycss-core");function Ut(e,n,t){let o=Array.from(e.querySelectorAll("i,b,s,u"));for(let r of o){let i=r.getBoundingClientRect();if(!(i.width<=0||i.height<=0)&&n>=i.left&&n<=i.right&&t>=i.top&&t<=i.bottom)return!0}return!1}function Ui(e,n,t,o){for(let r of e)if(!(o&&!o(r))&&Ut(r.element,n,t))return r;return null}var io="#ff3653",so="#8adb00",ao="#2c8fff",jt=50,ji=60,gl=.6,yl=.0125,bl=.15,vl=.04,xl=1,Wi=.02,Jo=1.04,Pl=.1,Sl=.25,Qi=1e-4,Cl=.6,El=.8,Tl=1,lt={0:1,1:0,2:2},Yi=[{cssAxis:0,sign:1,key:"x",color:io},{cssAxis:0,sign:-1,key:"-x",color:io},{cssAxis:1,sign:1,key:"y",color:so},{cssAxis:1,sign:-1,key:"-y",color:so},{cssAxis:2,sign:1,key:"z",color:ao},{cssAxis:2,sign:-1,key:"-z",color:ao}],Xi=[{cssAxis:0,key:"x",color:io},{cssAxis:1,key:"y",color:so},{cssAxis:2,key:"z",color:ao}],Zi=[{perpAxis:2,axisA:0,axisB:1,key:"xy",color:ao},{perpAxis:1,axisA:0,axisB:2,key:"xz",color:so},{perpAxis:0,axisA:1,axisB:2,key:"yz",color:io}];function er(e,n,t,o){let r=t*Math.PI/180,i=o*Math.PI/180,s=[0,0,0];s[e]=n;let c=s[0]*Math.cos(i)-s[1]*Math.sin(i),l=s[0]*Math.sin(i)+s[1]*Math.cos(i),p=s[2];return l*Math.sin(r)+p*Math.cos(r)<0}function Al(e,n){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return e;let o=parseInt(t[1],16),r=parseInt(t[2],16),i=parseInt(t[3],16);return`rgba(${o}, ${r}, ${i}, ${n})`}function lo(e,n){return!n||n<=0?e:Math.round(e/n)*n}function Ml(e){if(e.length===0)return[0,0,0];let n=1/0,t=1/0,o=1/0,r=-1/0,i=-1/0,s=-1/0;for(let c of e)for(let l of c.vertices)l[0]<n&&(n=l[0]),l[0]>r&&(r=l[0]),l[1]<t&&(t=l[1]),l[1]>i&&(i=l[1]),l[2]<o&&(o=l[2]),l[2]>s&&(s=l[2]);return Number.isFinite(n)?[(n+r)/2,(t+i)/2,(o+s)/2]:[0,0,0]}function tr(e){if(e.length===0)return ji;let n=1/0,t=1/0,o=1/0,r=-1/0,i=-1/0,s=-1/0;for(let l of e)for(let p of l.vertices)p[0]<n&&(n=p[0]),p[0]>r&&(r=p[0]),p[1]<t&&(t=p[1]),p[1]>i&&(i=p[1]),p[2]<o&&(o=p[2]),p[2]>s&&(s=p[2]);return Number.isFinite(n)?Math.max(r-n,i-t,s-o)*jt*gl:ji}function wl(e){let{cssAxis:n,sign:t,shaftLengthCss:o,wrapper:r,target:i,startClientX:s,startClientY:c,translationSnap:l,onAxisDelta:p,onMouseDown:h,onMouseUp:x,onDraggingChanged:f}=e,b=o,y=[0,0,0];y[n]=t;let P=r.ownerDocument.createElement("div");P.style.position="absolute",P.style.left="0",P.style.top="0",P.style.width="0",P.style.height="0",P.style.transform=`translate3d(${y[0]*b}px, ${y[1]*b}px, ${y[2]*b}px)`,r.appendChild(P);let v=r.getBoundingClientRect(),C=P.getBoundingClientRect();r.removeChild(P);let F=(C.left-v.left)/b,k=(C.top-v.top)/b,z=F*F+k*k;if(z<Qi)return;h?.(),f?.(!0);let O=q=>{let D=q.clientX-s,H=q.clientY-c,V=(D*F+H*k)/z;V=lo(V,l),p(V,y)},Z=()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",Z),window.removeEventListener("pointercancel",Z);let q=D=>{D.stopPropagation(),D.stopImmediatePropagation()};window.addEventListener("click",q,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",q,!0),0),x?.(),f?.(!1)};window.addEventListener("pointermove",O),window.addEventListener("pointerup",Z),window.addEventListener("pointercancel",Z)}function Ll(e){let{axisA:n,axisB:t,probeDistanceCss:o,wrapper:r,startClientX:i,startClientY:s,translationSnap:c,onPlaneDelta:l,onMouseDown:p,onMouseUp:h,onDraggingChanged:x}=e,f=[0,0,0];f[n]=1;let b=[0,0,0];b[t]=1;function y(z){let O=r.ownerDocument.createElement("div");O.style.position="absolute",O.style.left="0",O.style.top="0",O.style.width="0",O.style.height="0",O.style.transform=`translate3d(${z[0]*o}px, ${z[1]*o}px, ${z[2]*o}px)`,r.appendChild(O);let Z=r.getBoundingClientRect(),q=O.getBoundingClientRect();return r.removeChild(O),{x:(q.left-Z.left)/o,y:(q.top-Z.top)/o}}let P=y(f),v=y(b),C=P.x*v.y-v.x*P.y;if(Math.abs(C)<Qi)return;p?.(),x?.(!0);let F=z=>{let O=z.clientX-i,Z=z.clientY-s,q=(v.y*O-v.x*Z)/C,D=(-P.y*O+P.x*Z)/C;q=lo(q,c),D=lo(D,c),l(q,D,f,b)},k=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k);let z=O=>{O.stopPropagation(),O.stopImmediatePropagation()};window.addEventListener("click",z,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",z,!0),0),h?.(),x?.(!1)};window.addEventListener("pointermove",F),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)}function _l(e){let{cssAxis:n,wrapper:t,target:o,startClientX:r,startClientY:i,rotationSnap:s,onAngleDelta:c,onMouseDown:l,onMouseUp:p,onDraggingChanged:h}=e,x=t.getBoundingClientRect(),f=x.left,b=x.top,y=Math.atan2(i-b,r-f),P=0;l?.(),h?.(!0);let v=F=>{let k=Math.atan2(F.clientY-b,F.clientX-f),z=k-y;z>Math.PI?z-=2*Math.PI:z<-Math.PI&&(z+=2*Math.PI),P+=z,y=k;let O=P*180/Math.PI;O=lo(O,s),c(O)},C=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C);let F=k=>{k.stopPropagation(),k.stopImmediatePropagation()};window.addEventListener("click",F,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",F,!0),0),p?.(),h?.(!1)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C)}function qi(e,n={}){let t=null,o=n.mode??"translate",r=n.size??1,i={...n},s=new Map,c=null,l=null,p=[0,0,0];function h(){if(!t)return[0,0,0];let g=t.transform.position??[0,0,0],u=t.transform.rotation??[0,0,0],d=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,T=(0,Ae.rotateVec3)(p,u[0],u[1],u[2]);return[g[0]+d*T[0],g[1]+d*T[1],g[2]+d*T[2]]}function x(g){return l===g?Tl:c===g?El:Cl}function f(){for(let[g,u]of s){let d=b(u.spec,x(g));u.handle.setPolygons(d,{recomputeAutoCenter:!1})}}function b(g,u){let T=tr(t?.polygons??[])*r,w=T/jt,R=Al(g.color,u);if(g.kind==="arrow"){let _=e.camera.state,j=er(g.cssAxis,g.sign,_.rotX??65,_.rotY??45);return(0,Ae.arrowPolygons)({axis:lt[g.cssAxis],sign:g.sign,shaftLength:w,shaftHalfThickness:w*yl,headLength:w*bl,headHalfThickness:w*vl,color:R,shaft:!j})}if(g.kind==="plane"){let _=e.camera.state,j=_.rotX??65,Q=_.rotY??45,ae=lt[g.perpAxis],be=(ae+1)%3,fe=(ae+2)%3,ge=lt[be],we=lt[fe],Se=er(ge,1,j,Q)?-1:1,ke=er(we,1,j,Q)?-1:1,We=w*Sl;return(0,Ae.planePolygons)({axis:ae,size:w*Pl,offset:[Se*We,ke*We],color:R})}let re=T*xl/jt*Jo;return(0,Ae.ringQuadPolygons)({axis:lt[g.cssAxis],outerRadius:re,color:R})}function y(g){return g.kind==="arrow"?"polycss-transform-arrow":g.kind==="plane"?"polycss-transform-plane":"polycss-transform-ring"}function P(){if(o==="translate"){let g=Yi.map(d=>({kind:"arrow",key:d.key,cssAxis:d.cssAxis,sign:d.sign,color:d.color})),u=Zi.map(d=>({kind:"plane",key:d.key,perpAxis:d.perpAxis,axisA:d.axisA,axisB:d.axisB,color:d.color}));return[...g,...u]}return o==="rotate"?Xi.map(g=>({kind:"ring",key:g.key,cssAxis:g.cssAxis,color:g.color})):[]}function v(){if(C(),!t)return;let g={x:i.showX!==!1,y:i.showY!==!1,z:i.showZ!==!1};function u(T){if(T.kind==="arrow"){let L=T.key.replace("-","")[0];return g[L]}if(T.kind==="ring")return g[T.key];let w=["x","y","z"][T.axisA],R=["x","y","z"][T.axisB];return g[w]&&g[R]}let d=h();for(let T of P()){if(!u(T))continue;let w=b(T,x(T.key)),R=e.add({polygons:w,objectUrls:[],warnings:[],dispose:()=>{}},{excludeFromAutoCenter:!0,id:`__poly-gizmo-${T.key}`,position:d}),L=y(T);if(R.element.classList.add("polycss-transform-gizmo",L,`${L}--${T.key}`),T.kind==="ring"){let re=(1-Wi)/Jo,_=(1+Wi)/Jo;R.element.style.setProperty("--ring-inner-ratio",`${re}`),R.element.style.setProperty("--ring-outer-ratio",`${_}`)}s.set(T.key,{handle:R,spec:T})}}function C(){for(let{handle:g}of s.values())g.remove();s.clear(),c=null,l=null}function F(){if(!t)return;let g=h();for(let{handle:u}of s.values())u.setTransform({position:g})}function k(){t&&(s.size===0?v():F())}function z(g){if(t=g,!g){p=[0,0,0],C();return}p=Ml(g.polygons),C(),v()}function O(){z(null)}function Z(g){g!==o&&(o=g,t&&(C(),v()))}function q(g,u,d){if(!t||!D)return;let T=d[g.cssAxis],w=lt[g.cssAxis],R=u*T/jt,L=D.slice();L[w]=D[w]+R,t.setTransform({position:L}),F(),i.onObjectChange?.({object:t,position:L}),i.onChange?.()}let D=null,H=null,V=g=>{if(!t||i.enabled===!1)return;let u={x:i.showX!==!1,y:i.showY!==!1,z:i.showZ!==!1};if(o==="translate"){for(let d of Zi){let T=["x","y","z"][d.axisA],w=["x","y","z"][d.axisB];if(!u[T]||!u[w])continue;let R=s.get(d.key);if(R&&Ut(R.handle.element,g.clientX,g.clientY)){g.preventDefault(),g.stopPropagation(),l=d.key,f(),D=(t.transform.position??[0,0,0]).slice(),Ll({axisA:d.axisA,axisB:d.axisB,probeDistanceCss:tr(t.polygons)*r,wrapper:R.handle.element,target:t,startClientX:g.clientX,startClientY:g.clientY,translationSnap:i.translationSnap??null,onPlaneDelta:(L,re,_,j)=>{if(!t||!D)return;let Q=_[d.axisA],ae=j[d.axisB],be=lt[d.axisA],fe=lt[d.axisB],ge=D.slice();ge[be]+=L*Q/jt,ge[fe]+=re*ae/jt,t.setTransform({position:ge}),F(),i.onObjectChange?.({object:t,position:ge}),i.onChange?.()},onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:L=>{L||(l=null,D=null,f()),i.onDraggingChanged?.(L)}});return}}for(let d of Yi){let T=d.key.replace("-","")[0];if(!u[T])continue;let w=s.get(d.key);if(w&&Ut(w.handle.element,g.clientX,g.clientY)){g.preventDefault(),g.stopPropagation(),l=d.key,f(),D=(t.transform.position??[0,0,0]).slice(),wl({cssAxis:d.cssAxis,sign:d.sign,shaftLengthCss:tr(t.polygons)*r,wrapper:w.handle.element,target:t,startClientX:g.clientX,startClientY:g.clientY,translationSnap:i.translationSnap??null,onAxisDelta:(R,L)=>q(d,R,L),onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:R=>{R||(l=null,D=null,f()),i.onDraggingChanged?.(R)}});return}}}else if(o==="rotate")for(let d of Xi){if(!u[d.key])continue;let T=s.get(d.key);if(T&&Ut(T.handle.element,g.clientX,g.clientY)){g.preventDefault(),g.stopPropagation(),l=d.key,f(),H=(t.transform.rotation??[0,0,0]).slice(),D=(t.transform.position??[0,0,0]).slice(),_l({cssAxis:d.cssAxis,wrapper:T.handle.element,target:t,startClientX:g.clientX,startClientY:g.clientY,rotationSnap:i.rotationSnap??null,onAngleDelta:w=>{if(!t||!H||!D)return;let R=lt[d.cssAxis],L=[0,0,0];L[R]=1;let re=-w*Math.PI/180,_=(0,Ae.quatFromEulerXYZ)(H),j=(0,Ae.quatFromAxisAngle)(L,re),Q=(0,Ae.eulerXYZFromQuat)((0,Ae.quatMultiply)(j,_)),ae=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,be=(0,Ae.rotateVec3)(p,H[0],H[1],H[2]),fe=(0,Ae.rotateVec3)(p,Q[0],Q[1],Q[2]),ge=[D[0]+ae*(be[0]-fe[0]),D[1]+ae*(be[1]-fe[1]),D[2]+ae*(be[2]-fe[2])];t.setTransform({rotation:Q,position:ge}),F(),i.onObjectChange?.({object:t,rotation:Q,position:ge}),i.onChange?.()},onMouseDown:i.onMouseDown,onMouseUp:i.onMouseUp,onDraggingChanged:w=>{w||(l=null,H=null,D=null,f(),t?.rebakeAtlas()),i.onDraggingChanged?.(w)}});return}}};e.host.addEventListener("pointerdown",V,{capture:!0});let G=g=>{if(!t||l||i.enabled===!1)return;let u=null;for(let[d,T]of s)if(Ut(T.handle.element,g.clientX,g.clientY)){u=d;break}u!==c&&(c=u,f())};e.host.addEventListener("pointermove",G);function A(){e.host.removeEventListener("pointerdown",V,{capture:!0}),e.host.removeEventListener("pointermove",G),C()}return{attach:z,detach:O,setMode:Z,update:k,destroy:A}}var Rl=typeof HTMLElement<"u"?HTMLElement:class{},kl=["mode","target","size","enabled"];function Ki(e){if(e==="translate"||e==="rotate")return e}var yn=class extends Rl{constructor(){super(...arguments);this._tc=null}static get observedAttributes(){return[...kl]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_findTargetMesh(){let t=this.getAttribute("target");if(!t)return null;let o=this._findScene();if(!o)return null;let r=null;try{r=o.querySelector(`#${t}`)??o.querySelector(t)}catch{r=o.querySelector(`[id="${t}"]`)}return r instanceof xt?r:null}_readOptions(){let t={},o=Ki(this.getAttribute("mode"));o!==void 0&&(t.mode=o);let r=oe(this.getAttribute("size"));r!==void 0&&(t.size=r);let i=this.getAttribute("enabled");return i!==null&&(t.enabled=i!=="false"&&i!=="0"),t.onObjectChange=s=>{this.dispatchEvent(new CustomEvent("polycss:object-change",{bubbles:!0,detail:{position:s.position,rotation:s.rotation}}))},t}_attach(){if(this._tc)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._tc=qi(o,this._readOptions());let r=this._findTargetMesh();if(r){let i=r.getMeshHandle();i&&this._tc.attach(i)}}connectedCallback(){this._attach()}disconnectedCallback(){this._tc&&(this._tc.destroy(),this._tc=null)}attributeChangedCallback(t,o,r){if(o!==r&&this._tc){if(t==="mode"){let i=Ki(r);i&&this._tc.setMode(i)}else if(t==="target"){let i=this._findTargetMesh();this._tc.attach(i?i.getMeshHandle()??null:null)}}}};function Ji(e,n={}){let t=[],o=new Set;n.onChange&&o.add(n.onChange);function r(){t=n.filter?n.filter(t):t;for(let P of o)try{P(t)}catch(v){console.error("[polycss/createSelect] onChange threw:",v)}}function i(y){t=y,r()}function s(y){n.multiple?t.includes(y)||(t=[...t,y]):t=[y],r()}function c(y){t.includes(y)&&(t=t.filter(P=>P!==y),r())}function l(y){t.includes(y)?t=t.filter(P=>P!==y):n.multiple?t=[...t,y]:t=[y],r()}function p(){t.length!==0&&(t=[],r())}function h(y){return t.includes(y)}function x(y,P){return Ui(e.meshes(),y,P,v=>!v.element.classList.contains("polycss-transform-gizmo"))}let f=y=>{let P=y.target;if(P?.closest(".polycss-transform-gizmo"))return;let v=e.findMeshByElement(P)??x(y.clientX,y.clientY);if(!v){n.onPointerMissed&&n.onPointerMissed(y),n.clearOnMiss!==!1&&p();return}n.multiple&&(y.shiftKey||y.metaKey||y.ctrlKey)?l(v):t.length===1&&t[0]===v?p():i([v])};e.host.addEventListener("click",f);function b(){e.host.removeEventListener("click",f),o.clear()}return{get selected(){return t},set:i,add:s,remove:c,toggle:l,clear:p,has:h,destroy:b}}var Dl=typeof HTMLElement<"u"?HTMLElement:class{},Ol=["multiple","clear-on-miss"],bn=class extends Dl{constructor(){super(...arguments);this._selection=null}static get observedAttributes(){return[...Ol]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof _e)return t;t=t.parentNode}return null}_readOptions(){return{multiple:this.hasAttribute("multiple"),clearOnMiss:!this.hasAttribute("clear-on-miss")||this.getAttribute("clear-on-miss")!=="false",onChange:t=>{this.dispatchEvent(new CustomEvent("polycss:select",{bubbles:!0,detail:{selected:t}}))}}}_attach(){if(this._selection)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._selection=Ji(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._selection&&(this._selection.destroy(),this._selection=null)}attributeChangedCallback(t,o,r){o!==r&&(this._selection&&(this._selection.destroy(),this._selection=null),this._attach())}};var he=require("@layoutit/polycss-core"),Hl=typeof HTMLElement<"u"?HTMLElement:class{};function Il(e){return e.closest("poly-scene")??null}function ve(e,n,t){let o=e.getAttribute(n);if(!o)return t;let r=parseFloat(o);return Number.isFinite(r)?r:t}function Je(e,n,t){return e.getAttribute(n)??t}function St(e,n){let t=e.getAttribute(n);if(!t)return;let o=t.split(",").map(r=>parseFloat(r.trim()));if(!(o.length!==3||o.some(r=>!Number.isFinite(r))))return[o[0],o[1],o[2]]}function Fl(e){if(e.length===0)return e;let n=(0,he.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,r=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&r===0)return e;let i=s=>[s[0]-t,s[1]-o,s[2]-r];return e.map(s=>({...s,vertices:s.vertices.map(i)}))}var Ve=class extends Hl{constructor(){super(...arguments);this._handle=null}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,r){if(o!==r&&this._handle){if(t==="position"||t==="scale"||t==="rotation"||t==="cast-shadow"||t==="receive-shadow"){this._handle.setTransform({position:St(this,"position"),scale:(()=>{let i=this.getAttribute("scale");if(!i)return;if(i.includes(","))return St(this,"scale");let s=parseFloat(i);return Number.isFinite(s)?s:void 0})(),rotation:St(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")});return}this._tearDown(),this._mount()}}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=Il(this);if(!t)return;let o=t.getScene?.();if(!o)return;let r=this.buildPolygons();this.hasAttribute("auto-center")&&(r=Fl(r));let i={polygons:r,objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(i,{position:St(this,"position"),scale:(()=>{let s=this.getAttribute("scale");if(!s)return;if(s.includes(","))return St(this,"scale");let c=parseFloat(s);return Number.isFinite(c)?c:void 0})(),rotation:St(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow"),excludeFromAutoCenter:this.hasAttribute("exclude-from-auto-center"),merge:!1})}},vn=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("size"),t=n?parseFloat(n):void 0;return(0,he.boxPolygons)({size:t!==void 0&&Number.isFinite(t)?t:void 0,color:Je(this,"color")})}},xn=class extends Ve{static get observedAttributes(){return["axis","size","offset","color","auto-center","position","scale","rotation","cast-shadow","receive-shadow"]}buildPolygons(){let n=ve(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("offset"),r=o===null?0:parseFloat(o);return(0,he.planePolygons)({axis:t,size:ve(this,"size",.4),offset:Number.isFinite(r)?r:0,color:Je(this,"color")})}},Pn=class extends Ve{static get observedAttributes(){return["axis","radius","segments","half-thickness","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=ve(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("half-thickness");return(0,he.ringPolygons)({axis:t,radius:ve(this,"radius",50),segments:ve(this,"segments",32),halfThickness:o?parseFloat(o):void 0,color:Je(this,"color")})}},Sn=class extends Ve{static get observedAttributes(){return["size","color","center","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.octahedronPolygons)({center:St(this,"center")??[0,0,0],size:ve(this,"size",50),color:Je(this,"color")})}},Cn=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.tetrahedronPolygons)({size:ve(this,"size",100),color:Je(this,"color")})}},En=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.icosahedronPolygons)({size:ve(this,"size",100),color:Je(this,"color")})}},Tn=class extends Ve{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.dodecahedronPolygons)({size:ve(this,"size",100),color:Je(this,"color")})}},An=class extends Ve{static get observedAttributes(){return["radius","subdivisions","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.spherePolygons)({radius:ve(this,"radius",50),subdivisions:ve(this,"subdivisions",1),color:Je(this,"color")})}},Mn=class extends Ve{static get observedAttributes(){return["radius","radius-top","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("radius-top");return(0,he.cylinderPolygons)({radius:ve(this,"radius",50),radiusTop:n?parseFloat(n):void 0,height:ve(this,"height",100),radialSegments:ve(this,"radial-segments",12),color:Je(this,"color")})}},wn=class extends Ve{static get observedAttributes(){return["radius","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.conePolygons)({radius:ve(this,"radius",50),height:ve(this,"height",100),radialSegments:ve(this,"radial-segments",12),color:Je(this,"color")})}},Ln=class extends Ve{static get observedAttributes(){return["radius","tube","radial-segments","tubular-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,he.torusPolygons)({radius:ve(this,"radius",50),tube:ve(this,"tube",15),radialSegments:ve(this,"radial-segments",12),tubularSegments:ve(this,"tubular-segments",16),color:Je(this,"color")})}};typeof customElements<"u"&&(customElements.get("poly-scene")||customElements.define("poly-scene",_e),customElements.get("poly-mesh")||customElements.define("poly-mesh",xt),customElements.get("poly-iframe")||customElements.define("poly-iframe",an),customElements.get("poly-polygon")||customElements.define("poly-polygon",ln),customElements.get("poly-axes-helper")||customElements.define("poly-axes-helper",cn),customElements.get("poly-directional-light-helper")||customElements.define("poly-directional-light-helper",dn),customElements.get("poly-orbit-controls")||customElements.define("poly-orbit-controls",pn),customElements.get("poly-map-controls")||customElements.define("poly-map-controls",mn),customElements.get("poly-first-person-controls")||customElements.define("poly-first-person-controls",fn),customElements.get("poly-perspective-camera")||customElements.define("poly-perspective-camera",hn),customElements.get("poly-orthographic-camera")||customElements.define("poly-orthographic-camera",Pt),customElements.get("poly-camera")||customElements.define("poly-camera",gn),customElements.get("poly-transform-controls")||customElements.define("poly-transform-controls",yn),customElements.get("poly-select")||customElements.define("poly-select",bn),customElements.get("poly-box")||customElements.define("poly-box",vn),customElements.get("poly-plane")||customElements.define("poly-plane",xn),customElements.get("poly-ring")||customElements.define("poly-ring",Pn),customElements.get("poly-octahedron")||customElements.define("poly-octahedron",Sn),customElements.get("poly-tetrahedron")||customElements.define("poly-tetrahedron",Cn),customElements.get("poly-sphere")||customElements.define("poly-sphere",An),customElements.get("poly-icosahedron")||customElements.define("poly-icosahedron",En),customElements.get("poly-dodecahedron")||customElements.define("poly-dodecahedron",Tn),customElements.get("poly-cylinder")||customElements.define("poly-cylinder",Mn),customElements.get("poly-cone")||customElements.define("poly-cone",wn),customElements.get("poly-torus")||customElements.define("poly-torus",Ln));0&&(module.exports={PolyAxesHelperElement,PolyBoxElement,PolyCameraElement,PolyConeElement,PolyCylinderElement,PolyDirectionalLightHelperElement,PolyDodecahedronElement,PolyFirstPersonControlsElement,PolyIcosahedronElement,PolyIframeElement,PolyMapControlsElement,PolyMeshElement,PolyOctahedronElement,PolyOrbitControlsElement,PolyOrthographicCameraElement,PolyPerspectiveCameraElement,PolyPlaneElement,PolyPolygonElement,PolyRingElement,PolySceneElement,PolySelectElement,PolySphereElement,PolyTetrahedronElement,PolyTorusElement,PolyTransformControlsElement});
|