@epigraph/configurator 1.9.1 → 1.9.3

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8916,7 +8916,7 @@ void main() {
8916
8916
  `;Ye=ie(ve),Ye!==!1;){if(Fe.string+=Ye+`
8917
8917
  `,Ye.charAt(0)==="#"){Fe.comments+=Ye+`
8918
8918
  `;continue}if((rn=Ye.match(De))&&(Fe.gamma=parseFloat(rn[1])),(rn=Ye.match(Le))&&(Fe.exposure=parseFloat(rn[1])),(rn=Ye.match(Ue))&&(Fe.valid|=2,Fe.format=rn[1]),(rn=Ye.match(Ge))&&(Fe.valid|=4,Fe.height=parseInt(rn[1],10),Fe.width=parseInt(rn[2],10)),Fe.valid&2&&Fe.valid&4)break}return Fe.valid&2?Fe.valid&4?Fe:A(3,"missing image size specifier"):A(3,"missing format specifier")},le=function(ve,xe,De){const Le=xe;if(Le<8||Le>32767||ve[0]!==2||ve[1]!==2||ve[2]&128)return new Uint8Array(ve);if(Le!==(ve[2]<<8|ve[3]))return A(3,"wrong scanline width");const Ue=new Uint8Array(4*xe*De);if(!Ue.length)return A(4,"unable to allocate buffer space");let Ge=0,Fe=0;const Ye=4*Le,rn=new Uint8Array(4),yn=new Uint8Array(Ye);let bt=De;for(;bt>0&&Fe<ve.byteLength;){if(Fe+4>ve.byteLength)return A(1);if(rn[0]=ve[Fe++],rn[1]=ve[Fe++],rn[2]=ve[Fe++],rn[3]=ve[Fe++],rn[0]!=2||rn[1]!=2||(rn[2]<<8|rn[3])!=Le)return A(3,"bad rgbe scanline format");let sn=0,Ur;for(;sn<Ye&&Fe<ve.byteLength;){Ur=ve[Fe++];const hr=Ur>128;if(hr&&(Ur-=128),Ur===0||sn+Ur>Ye)return A(3,"bad scanline data");if(hr){const zn=ve[Fe++];for(let ar=0;ar<Ur;ar++)yn[sn++]=zn}else yn.set(ve.subarray(Fe,Fe+Ur),sn),sn+=Ur,Fe+=Ur}const lr=Le;for(let hr=0;hr<lr;hr++){let zn=0;Ue[Ge]=yn[hr+zn],zn+=Le,Ue[Ge+1]=yn[hr+zn],zn+=Le,Ue[Ge+2]=yn[hr+zn],zn+=Le,Ue[Ge+3]=yn[hr+zn],Ge+=4}bt--}return Ue},pe=function(ve,xe,De,Le){const Ue=ve[xe+3],Ge=Math.pow(2,Ue-128)/255;De[Le+0]=ve[xe+0]*Ge,De[Le+1]=ve[xe+1]*Ge,De[Le+2]=ve[xe+2]*Ge,De[Le+3]=1},de=function(ve,xe,De,Le){const Ue=ve[xe+3],Ge=Math.pow(2,Ue-128)/255;De[Le+0]=DataUtils.toHalfFloat(Math.min(ve[xe+0]*Ge,65504)),De[Le+1]=DataUtils.toHalfFloat(Math.min(ve[xe+1]*Ge,65504)),De[Le+2]=DataUtils.toHalfFloat(Math.min(ve[xe+2]*Ge,65504)),De[Le+3]=DataUtils.toHalfFloat(1)},fe=new Uint8Array(e);fe.pos=0;const _e=se(fe);if(_e!==-1){const ve=_e.width,xe=_e.height,De=le(fe.subarray(fe.pos),ve,xe);if(De!==-1){let Le,Ue,Ge;switch(this.type){case FloatType:Ge=De.length/4;const Fe=new Float32Array(Ge*4);for(let rn=0;rn<Ge;rn++)pe(De,rn*4,Fe,rn*4);Le=Fe,Ue=FloatType;break;case HalfFloatType:Ge=De.length/4;const Ye=new Uint16Array(Ge*4);for(let rn=0;rn<Ge;rn++)de(De,rn*4,Ye,rn*4);Le=Ye,Ue=HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:ve,height:xe,data:Le,header:_e.string,gamma:_e.gamma,exposure:_e.exposure,type:Ue}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(v,A){switch(v.type){case FloatType:case HalfFloatType:"colorSpace"in v?v.colorSpace="srgb-linear":v.encoding=3e3,v.minFilter=LinearFilter,v.magFilter=LinearFilter,v.generateMipmaps=!1,v.flipY=!0;break}t&&t(v,A)}return super.load(e,o,n,s)}}const hasColorSpace$1="colorSpace"in new Texture;class EXRLoader extends DataTextureLoader{constructor(e){super(e),this.type=HalfFloatType}parse(e){const Fe=Math.pow(2.7182818,2.2);function Ye(rs,ni){for(var ha=0,ls=0;ls<65536;++ls)(ls==0||rs[ls>>3]&1<<(ls&7))&&(ni[ha++]=ls);for(var es=ha-1;ha<65536;)ni[ha++]=0;return es}function rn(rs){for(var ni=0;ni<16384;ni++)rs[ni]={},rs[ni].len=0,rs[ni].lit=0,rs[ni].p=null}const yn={l:0,c:0,lc:0};function bt(rs,ni,ha,ls,es){for(;ha<rs;)ni=ni<<8|uf(ls,es),ha+=8;ha-=rs,yn.l=ni>>ha&(1<<rs)-1,yn.c=ni,yn.lc=ha}const sn=new Array(59);function Ur(rs){for(var ni=0;ni<=58;++ni)sn[ni]=0;for(var ni=0;ni<65537;++ni)sn[rs[ni]]+=1;for(var ha=0,ni=58;ni>0;--ni){var ls=ha+sn[ni]>>1;sn[ni]=ha,ha=ls}for(var ni=0;ni<65537;++ni){var es=rs[ni];es>0&&(rs[ni]=es|sn[es]++<<6)}}function lr(rs,ni,ha,ls,es,zs,El){for(var bh=ha,Dh=0,af=0;es<=zs;es++){if(bh.value-ha.value>ls)return!1;bt(6,Dh,af,rs,bh);var vf=yn.l;if(Dh=yn.c,af=yn.lc,El[es]=vf,vf==63){if(bh.value-ha.value>ls)throw"Something wrong with hufUnpackEncTable";bt(8,Dh,af,rs,bh);var Bh=yn.l+6;if(Dh=yn.c,af=yn.lc,es+Bh>zs+1)throw"Something wrong with hufUnpackEncTable";for(;Bh--;)El[es++]=0;es--}else if(vf>=59){var Bh=vf-59+2;if(es+Bh>zs+1)throw"Something wrong with hufUnpackEncTable";for(;Bh--;)El[es++]=0;es--}}Ur(El)}function hr(rs){return rs&63}function zn(rs){return rs>>6}function ar(rs,ni,ha,ls){for(;ni<=ha;ni++){var es=zn(rs[ni]),zs=hr(rs[ni]);if(es>>zs)throw"Invalid table entry";if(zs>14){var El=ls[es>>zs-14];if(El.len)throw"Invalid table entry";if(El.lit++,El.p){var bh=El.p;El.p=new Array(El.lit);for(var Dh=0;Dh<El.lit-1;++Dh)El.p[Dh]=bh[Dh]}else El.p=new Array(1);El.p[El.lit-1]=ni}else if(zs)for(var af=0,Dh=1<<14-zs;Dh>0;Dh--){var El=ls[(es<<14-zs)+af];if(El.len||El.p)throw"Invalid table entry";El.len=zs,El.lit=ni,af++}}return!0}const Dr={c:0,lc:0};function Pn(rs,ni,ha,ls){rs=rs<<8|uf(ha,ls),ni+=8,Dr.c=rs,Dr.lc=ni}const si={c:0,lc:0};function ea(rs,ni,ha,ls,es,zs,El,bh,Dh,af){if(rs==ni){ls<8&&(Pn(ha,ls,es,El),ha=Dr.c,ls=Dr.lc),ls-=8;var vf=ha>>ls,vf=new Uint8Array([vf])[0];if(Dh.value+vf>af)return!1;for(var Bh=bh[Dh.value-1];vf-- >0;)bh[Dh.value++]=Bh}else if(Dh.value<af)bh[Dh.value++]=rs;else return!1;si.c=ha,si.lc=ls}function Ra(rs){return rs&65535}function as(rs){var ni=Ra(rs);return ni>32767?ni-65536:ni}const ua={a:0,b:0};function ho(rs,ni){var ha=as(rs),ls=as(ni),es=ls,zs=ha+(es&1)+(es>>1),El=zs,bh=zs-es;ua.a=El,ua.b=bh}function tl(rs,ni){var ha=Ra(rs),ls=Ra(ni),es=ha-(ls>>1)&65535,zs=ls+es-32768&65535;ua.a=zs,ua.b=es}function ll(rs,ni,ha,ls,es,zs,El){for(var bh=El<16384,Dh=ha>es?es:ha,af=1,vf;af<=Dh;)af<<=1;for(af>>=1,vf=af,af>>=1;af>=1;){for(var Bh=0,My=Bh+zs*(es-vf),Cy=zs*af,Xf=zs*vf,UA=ls*af,YA=ls*vf,OA,wy,GR,hC;Bh<=My;Bh+=Xf){for(var sC=Bh,JI=Bh+ls*(ha-vf);sC<=JI;sC+=YA){var mb=sC+UA,jR=sC+Cy,dC=jR+UA;bh?(ho(rs[sC+ni],rs[jR+ni]),OA=ua.a,GR=ua.b,ho(rs[mb+ni],rs[dC+ni]),wy=ua.a,hC=ua.b,ho(OA,wy),rs[sC+ni]=ua.a,rs[mb+ni]=ua.b,ho(GR,hC),rs[jR+ni]=ua.a,rs[dC+ni]=ua.b):(tl(rs[sC+ni],rs[jR+ni]),OA=ua.a,GR=ua.b,tl(rs[mb+ni],rs[dC+ni]),wy=ua.a,hC=ua.b,tl(OA,wy),rs[sC+ni]=ua.a,rs[mb+ni]=ua.b,tl(GR,hC),rs[jR+ni]=ua.a,rs[dC+ni]=ua.b)}if(ha&af){var jR=sC+Cy;bh?ho(rs[sC+ni],rs[jR+ni]):tl(rs[sC+ni],rs[jR+ni]),OA=ua.a,rs[jR+ni]=ua.b,rs[sC+ni]=OA}}if(es&af)for(var sC=Bh,JI=Bh+ls*(ha-vf);sC<=JI;sC+=YA){var mb=sC+UA;bh?ho(rs[sC+ni],rs[mb+ni]):tl(rs[sC+ni],rs[mb+ni]),OA=ua.a,rs[mb+ni]=ua.b,rs[sC+ni]=OA}vf=af,af>>=1}return Bh}function _c(rs,ni,ha,ls,es,zs,El,bh,Dh,af){for(var vf=0,Bh=0,My=bh,Cy=Math.trunc(es.value+(zs+7)/8);es.value<Cy;)for(Pn(vf,Bh,ha,es),vf=Dr.c,Bh=Dr.lc;Bh>=14;){var Xf=vf>>Bh-14&16383,UA=ni[Xf];if(UA.len)Bh-=UA.len,ea(UA.lit,El,vf,Bh,ha,ls,es,Dh,af,My),vf=si.c,Bh=si.lc;else{if(!UA.p)throw"hufDecode issues";var YA;for(YA=0;YA<UA.lit;YA++){for(var OA=hr(rs[UA.p[YA]]);Bh<OA&&es.value<Cy;)Pn(vf,Bh,ha,es),vf=Dr.c,Bh=Dr.lc;if(Bh>=OA&&zn(rs[UA.p[YA]])==(vf>>Bh-OA&(1<<OA)-1)){Bh-=OA,ea(UA.p[YA],El,vf,Bh,ha,ls,es,Dh,af,My),vf=si.c,Bh=si.lc;break}}if(YA==UA.lit)throw"hufDecode issues"}}var wy=8-zs&7;for(vf>>=wy,Bh-=wy;Bh>0;){var UA=ni[vf<<14-Bh&16383];if(UA.len)Bh-=UA.len,ea(UA.lit,El,vf,Bh,ha,ls,es,Dh,af,My),vf=si.c,Bh=si.lc;else throw"hufDecode issues"}return!0}function Al(rs,ni,ha,ls,es,zs){var El={value:0},bh=ha.value,Dh=Kc(ni,ha),af=Kc(ni,ha);ha.value+=4;var vf=Kc(ni,ha);if(ha.value+=4,Dh<0||Dh>=65537||af<0||af>=65537)throw"Something wrong with HUF_ENCSIZE";var Bh=new Array(65537),My=new Array(16384);rn(My);var Cy=ls-(ha.value-bh);if(lr(rs,ni,ha,Cy,Dh,af,Bh),vf>8*(ls-(ha.value-bh)))throw"Something wrong with hufUncompress";ar(Bh,Dh,af,My),_c(Bh,My,rs,ni,ha,vf,af,zs,es,El)}function da(rs,ni,ha){for(var ls=0;ls<ha;++ls)ni[ls]=rs[ni[ls]]}function ul(rs){for(var ni=1;ni<rs.length;ni++){var ha=rs[ni-1]+rs[ni]-128;rs[ni]=ha}}function nl(rs,ni){for(var ha=0,ls=Math.floor((rs.length+1)/2),es=0,zs=rs.length-1;!(es>zs||(ni[es++]=rs[ha++],es>zs));)ni[es++]=rs[ls++]}function kc(rs){for(var ni=rs.byteLength,ha=new Array,ls=0,es=new DataView(rs);ni>0;){var zs=es.getInt8(ls++);if(zs<0){var El=-zs;ni-=El+1;for(var bh=0;bh<El;bh++)ha.push(es.getUint8(ls++))}else{var El=zs;ni-=2;for(var Dh=es.getUint8(ls++),bh=0;bh<El+1;bh++)ha.push(Dh)}}return ha}function gl(rs,ni,ha,ls,es,zs){var mb=new DataView(zs.buffer),El=ha[rs.idx[0]].width,bh=ha[rs.idx[0]].height,Dh=3,af=Math.floor(El/8),vf=Math.ceil(El/8),Bh=Math.ceil(bh/8),My=El-(vf-1)*8,Cy=bh-(Bh-1)*8,Xf={value:0},UA=new Array(Dh),YA=new Array(Dh),OA=new Array(Dh),wy=new Array(Dh),GR=new Array(Dh);for(let XA=0;XA<Dh;++XA)GR[XA]=ni[rs.idx[XA]],UA[XA]=XA<1?0:UA[XA-1]+vf*Bh,YA[XA]=new Float32Array(64),OA[XA]=new Uint16Array(64),wy[XA]=new Uint16Array(vf*64);for(let XA=0;XA<Bh;++XA){var hC=8;XA==Bh-1&&(hC=Cy);var sC=8;for(let FC=0;FC<vf;++FC){FC==vf-1&&(sC=My);for(let NC=0;NC<Dh;++NC)OA[NC].fill(0),OA[NC][0]=es[UA[NC]++],Ef(Xf,ls,OA[NC]),dl(OA[NC],YA[NC]),vl(YA[NC]);Ph(YA);for(let NC=0;NC<Dh;++NC)pf(YA[NC],wy[NC],FC*64)}let $R=0;for(let FC=0;FC<Dh;++FC){const NC=ha[rs.idx[FC]].type;for(let TD=8*XA;TD<8*XA+hC;++TD){$R=GR[FC][TD];for(let PN=0;PN<af;++PN){const gD=PN*64+(TD&7)*8;mb.setUint16($R+0*2*NC,wy[FC][gD+0],!0),mb.setUint16($R+1*2*NC,wy[FC][gD+1],!0),mb.setUint16($R+2*2*NC,wy[FC][gD+2],!0),mb.setUint16($R+3*2*NC,wy[FC][gD+3],!0),mb.setUint16($R+4*2*NC,wy[FC][gD+4],!0),mb.setUint16($R+5*2*NC,wy[FC][gD+5],!0),mb.setUint16($R+6*2*NC,wy[FC][gD+6],!0),mb.setUint16($R+7*2*NC,wy[FC][gD+7],!0),$R+=8*2*NC}}if(af!=vf)for(let TD=8*XA;TD<8*XA+hC;++TD){const PN=GR[FC][TD]+8*af*2*NC,gD=af*64+(TD&7)*8;for(let ZN=0;ZN<sC;++ZN)mb.setUint16(PN+ZN*2*NC,wy[FC][gD+ZN],!0)}}}for(var JI=new Uint16Array(El),mb=new DataView(zs.buffer),jR=0;jR<Dh;++jR){ha[rs.idx[jR]].decoded=!0;var dC=ha[rs.idx[jR]].type;if(ha[jR].type==2)for(var NI=0;NI<bh;++NI){const XA=GR[jR][NI];for(var RI=0;RI<El;++RI)JI[RI]=mb.getUint16(XA+RI*2*dC,!0);for(var RI=0;RI<El;++RI)mb.setFloat32(XA+RI*2*dC,yl(JI[RI]),!0)}}}function Ef(rs,ni,ha){for(var ls,es=1;es<64;)ls=ni[rs.value],ls==65280?es=64:ls>>8==255?es+=ls&255:(ha[es]=ls,es++),rs.value++}function dl(rs,ni){ni[0]=yl(rs[0]),ni[1]=yl(rs[1]),ni[2]=yl(rs[5]),ni[3]=yl(rs[6]),ni[4]=yl(rs[14]),ni[5]=yl(rs[15]),ni[6]=yl(rs[27]),ni[7]=yl(rs[28]),ni[8]=yl(rs[2]),ni[9]=yl(rs[4]),ni[10]=yl(rs[7]),ni[11]=yl(rs[13]),ni[12]=yl(rs[16]),ni[13]=yl(rs[26]),ni[14]=yl(rs[29]),ni[15]=yl(rs[42]),ni[16]=yl(rs[3]),ni[17]=yl(rs[8]),ni[18]=yl(rs[12]),ni[19]=yl(rs[17]),ni[20]=yl(rs[25]),ni[21]=yl(rs[30]),ni[22]=yl(rs[41]),ni[23]=yl(rs[43]),ni[24]=yl(rs[9]),ni[25]=yl(rs[11]),ni[26]=yl(rs[18]),ni[27]=yl(rs[24]),ni[28]=yl(rs[31]),ni[29]=yl(rs[40]),ni[30]=yl(rs[44]),ni[31]=yl(rs[53]),ni[32]=yl(rs[10]),ni[33]=yl(rs[19]),ni[34]=yl(rs[23]),ni[35]=yl(rs[32]),ni[36]=yl(rs[39]),ni[37]=yl(rs[45]),ni[38]=yl(rs[52]),ni[39]=yl(rs[54]),ni[40]=yl(rs[20]),ni[41]=yl(rs[22]),ni[42]=yl(rs[33]),ni[43]=yl(rs[38]),ni[44]=yl(rs[46]),ni[45]=yl(rs[51]),ni[46]=yl(rs[55]),ni[47]=yl(rs[60]),ni[48]=yl(rs[21]),ni[49]=yl(rs[34]),ni[50]=yl(rs[37]),ni[51]=yl(rs[47]),ni[52]=yl(rs[50]),ni[53]=yl(rs[56]),ni[54]=yl(rs[59]),ni[55]=yl(rs[61]),ni[56]=yl(rs[35]),ni[57]=yl(rs[36]),ni[58]=yl(rs[48]),ni[59]=yl(rs[49]),ni[60]=yl(rs[57]),ni[61]=yl(rs[58]),ni[62]=yl(rs[62]),ni[63]=yl(rs[63])}function vl(rs){const ni=.5*Math.cos(.7853975),ha=.5*Math.cos(3.14159/16),ls=.5*Math.cos(3.14159/8),es=.5*Math.cos(3*3.14159/16),zs=.5*Math.cos(5*3.14159/16),El=.5*Math.cos(3*3.14159/8),bh=.5*Math.cos(7*3.14159/16);for(var Dh=new Array(4),af=new Array(4),vf=new Array(4),Bh=new Array(4),My=0;My<8;++My){var Cy=My*8;Dh[0]=ls*rs[Cy+2],Dh[1]=El*rs[Cy+2],Dh[2]=ls*rs[Cy+6],Dh[3]=El*rs[Cy+6],af[0]=ha*rs[Cy+1]+es*rs[Cy+3]+zs*rs[Cy+5]+bh*rs[Cy+7],af[1]=es*rs[Cy+1]-bh*rs[Cy+3]-ha*rs[Cy+5]-zs*rs[Cy+7],af[2]=zs*rs[Cy+1]-ha*rs[Cy+3]+bh*rs[Cy+5]+es*rs[Cy+7],af[3]=bh*rs[Cy+1]-zs*rs[Cy+3]+es*rs[Cy+5]-ha*rs[Cy+7],vf[0]=ni*(rs[Cy+0]+rs[Cy+4]),vf[3]=ni*(rs[Cy+0]-rs[Cy+4]),vf[1]=Dh[0]+Dh[3],vf[2]=Dh[1]-Dh[2],Bh[0]=vf[0]+vf[1],Bh[1]=vf[3]+vf[2],Bh[2]=vf[3]-vf[2],Bh[3]=vf[0]-vf[1],rs[Cy+0]=Bh[0]+af[0],rs[Cy+1]=Bh[1]+af[1],rs[Cy+2]=Bh[2]+af[2],rs[Cy+3]=Bh[3]+af[3],rs[Cy+4]=Bh[3]-af[3],rs[Cy+5]=Bh[2]-af[2],rs[Cy+6]=Bh[1]-af[1],rs[Cy+7]=Bh[0]-af[0]}for(var Xf=0;Xf<8;++Xf)Dh[0]=ls*rs[16+Xf],Dh[1]=El*rs[16+Xf],Dh[2]=ls*rs[48+Xf],Dh[3]=El*rs[48+Xf],af[0]=ha*rs[8+Xf]+es*rs[24+Xf]+zs*rs[40+Xf]+bh*rs[56+Xf],af[1]=es*rs[8+Xf]-bh*rs[24+Xf]-ha*rs[40+Xf]-zs*rs[56+Xf],af[2]=zs*rs[8+Xf]-ha*rs[24+Xf]+bh*rs[40+Xf]+es*rs[56+Xf],af[3]=bh*rs[8+Xf]-zs*rs[24+Xf]+es*rs[40+Xf]-ha*rs[56+Xf],vf[0]=ni*(rs[Xf]+rs[32+Xf]),vf[3]=ni*(rs[Xf]-rs[32+Xf]),vf[1]=Dh[0]+Dh[3],vf[2]=Dh[1]-Dh[2],Bh[0]=vf[0]+vf[1],Bh[1]=vf[3]+vf[2],Bh[2]=vf[3]-vf[2],Bh[3]=vf[0]-vf[1],rs[0+Xf]=Bh[0]+af[0],rs[8+Xf]=Bh[1]+af[1],rs[16+Xf]=Bh[2]+af[2],rs[24+Xf]=Bh[3]+af[3],rs[32+Xf]=Bh[3]-af[3],rs[40+Xf]=Bh[2]-af[2],rs[48+Xf]=Bh[1]-af[1],rs[56+Xf]=Bh[0]-af[0]}function Ph(rs){for(var ni=0;ni<64;++ni){var ha=rs[0][ni],ls=rs[1][ni],es=rs[2][ni];rs[0][ni]=ha+1.5747*es,rs[1][ni]=ha-.1873*ls-.4682*es,rs[2][ni]=ha+1.8556*ls}}function pf(rs,ni,ha){for(var ls=0;ls<64;++ls)ni[ha+ls]=DataUtils.toHalfFloat(of(rs[ls]))}function of(rs){return rs<=1?Math.sign(rs)*Math.pow(Math.abs(rs),2.2):Math.sign(rs)*Math.pow(Fe,Math.abs(rs)-1)}function ta(rs){return new DataView(rs.array.buffer,rs.offset.value,rs.size)}function Ii(rs){var ni=rs.viewer.buffer.slice(rs.offset.value,rs.offset.value+rs.size),ha=new Uint8Array(kc(ni)),ls=new Uint8Array(ha.length);return ul(ha),nl(ha,ls),new DataView(ls.buffer)}function el(rs){var ni=rs.array.slice(rs.offset.value,rs.offset.value+rs.size),ha=unzlibSync(ni),ls=new Uint8Array(ha.length);return ul(ha),nl(ha,ls),new DataView(ls.buffer)}function Fc(rs){for(var ni=rs.viewer,ha={value:rs.offset.value},ls=new Uint16Array(rs.width*rs.scanlineBlockSize*(rs.channels*rs.type)),es=new Uint8Array(8192),zs=0,El=new Array(rs.channels),bh=0;bh<rs.channels;bh++)El[bh]={},El[bh].start=zs,El[bh].end=El[bh].start,El[bh].nx=rs.width,El[bh].ny=rs.lines,El[bh].size=rs.type,zs+=El[bh].nx*El[bh].ny*El[bh].size;var Dh=hl(ni,ha),af=hl(ni,ha);if(af>=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(Dh<=af)for(var bh=0;bh<af-Dh+1;bh++)es[bh+Dh]=Bf(ni,ha);var vf=new Uint16Array(65536),Bh=Ye(es,vf),My=Kc(ni,ha);Al(rs.array,ni,ha,My,ls,zs);for(var bh=0;bh<rs.channels;++bh)for(var Cy=El[bh],Xf=0;Xf<El[bh].size;++Xf)ll(ls,Cy.start+Xf,Cy.nx,Cy.size,Cy.ny,Cy.nx*Cy.size,Bh);da(vf,ls,zs);for(var UA=0,YA=new Uint8Array(ls.buffer.byteLength),OA=0;OA<rs.lines;OA++)for(var wy=0;wy<rs.channels;wy++){var Cy=El[wy],GR=Cy.nx*Cy.size,hC=new Uint8Array(ls.buffer,Cy.end*2,GR*2);YA.set(hC,UA),UA+=GR*2,Cy.end+=GR}return new DataView(YA.buffer)}function Zl(rs){var ni=rs.array.slice(rs.offset.value,rs.offset.value+rs.size),ha=unzlibSync(ni);const ls=rs.lines*rs.channels*rs.width,es=rs.type==1?new Uint16Array(ls):new Uint32Array(ls);let zs=0,El=0;const bh=new Array(4);for(let Dh=0;Dh<rs.lines;Dh++)for(let af=0;af<rs.channels;af++){let vf=0;switch(rs.type){case 1:bh[0]=zs,bh[1]=bh[0]+rs.width,zs=bh[1]+rs.width;for(let Bh=0;Bh<rs.width;++Bh){const My=ha[bh[0]++]<<8|ha[bh[1]++];vf+=My,es[El]=vf,El++}break;case 2:bh[0]=zs,bh[1]=bh[0]+rs.width,bh[2]=bh[1]+rs.width,zs=bh[2]+rs.width;for(let Bh=0;Bh<rs.width;++Bh){const My=ha[bh[0]++]<<24|ha[bh[1]++]<<16|ha[bh[2]++]<<8;vf+=My,es[El]=vf,El++}break}}return new DataView(es.buffer)}function Yc(rs){var ni=rs.viewer,ha={value:rs.offset.value},ls=new Uint8Array(rs.width*rs.lines*(rs.channels*rs.type*2)),es={version:Yf(ni,ha),unknownUncompressedSize:Yf(ni,ha),unknownCompressedSize:Yf(ni,ha),acCompressedSize:Yf(ni,ha),dcCompressedSize:Yf(ni,ha),rleCompressedSize:Yf(ni,ha),rleUncompressedSize:Yf(ni,ha),rleRawSize:Yf(ni,ha),totalAcUncompressedCount:Yf(ni,ha),totalDcUncompressedCount:Yf(ni,ha),acCompression:Yf(ni,ha)};if(es.version<2)throw"EXRLoader.parse: "+lA.compression+" version "+es.version+" is unsupported";for(var zs=new Array,El=hl(ni,ha)-2;El>0;){var bh=qf(ni.buffer,ha),Dh=Bf(ni,ha),af=Dh>>2&3,vf=(Dh>>4)-1,Bh=new Int8Array([vf])[0],My=Bf(ni,ha);zs.push({name:bh,index:Bh,type:My,compression:af}),El-=bh.length+3}for(var Cy=lA.channels,Xf=new Array(rs.channels),UA=0;UA<rs.channels;++UA){var YA=Xf[UA]={},OA=Cy[UA];YA.name=OA.name,YA.compression=0,YA.decoded=!1,YA.type=OA.pixelType,YA.pLinear=OA.pLinear,YA.width=rs.width,YA.height=rs.lines}for(var wy={idx:new Array(3)},GR=0;GR<rs.channels;++GR)for(var YA=Xf[GR],UA=0;UA<zs.length;++UA){var hC=zs[UA];YA.name==hC.name&&(YA.compression=hC.compression,hC.index>=0&&(wy.idx[hC.index]=GR),YA.offset=GR)}if(es.acCompressedSize>0)switch(es.acCompression){case 0:var mb=new Uint16Array(es.totalAcUncompressedCount);Al(rs.array,ni,ha,es.acCompressedSize,mb,es.totalAcUncompressedCount);break;case 1:var sC=rs.array.slice(ha.value,ha.value+es.totalAcUncompressedCount),JI=unzlibSync(sC),mb=new Uint16Array(JI.buffer);ha.value+=es.totalAcUncompressedCount;break}if(es.dcCompressedSize>0){var jR={array:rs.array,offset:ha,size:es.dcCompressedSize},dC=new Uint16Array(el(jR).buffer);ha.value+=es.dcCompressedSize}if(es.rleRawSize>0){var sC=rs.array.slice(ha.value,ha.value+es.rleCompressedSize),JI=unzlibSync(sC),NI=kc(JI.buffer);ha.value+=es.rleCompressedSize}for(var RI=0,XA=new Array(Xf.length),UA=0;UA<XA.length;++UA)XA[UA]=new Array;for(var $R=0;$R<rs.lines;++$R)for(var FC=0;FC<Xf.length;++FC)XA[FC].push(RI),RI+=Xf[FC].width*rs.type*2;gl(wy,XA,Xf,mb,dC,ls);for(var UA=0;UA<Xf.length;++UA){var YA=Xf[UA];if(!YA.decoded)switch(YA.compression){case 2:for(var NC=0,TD=0,$R=0;$R<rs.lines;++$R){for(var PN=XA[UA][NC],gD=0;gD<YA.width;++gD){for(var ZN=0;ZN<2*YA.type;++ZN)ls[PN++]=NI[TD+ZN*YA.width*YA.height];TD++}NC++}break;case 1:default:throw"EXRLoader.parse: unsupported channel compression"}}return new DataView(ls.buffer)}function qf(rs,ni){for(var ha=new Uint8Array(rs),ls=0;ha[ni.value+ls]!=0;)ls+=1;var es=new TextDecoder().decode(ha.slice(ni.value,ni.value+ls));return ni.value=ni.value+ls+1,es}function Sh(rs,ni,ha){var ls=new TextDecoder().decode(new Uint8Array(rs).slice(ni.value,ni.value+ha));return ni.value=ni.value+ha,ls}function mo(rs,ni){var ha=hf(rs,ni),ls=Kc(rs,ni);return[ha,ls]}function Xc(rs,ni){var ha=Kc(rs,ni),ls=Kc(rs,ni);return[ha,ls]}function hf(rs,ni){var ha=rs.getInt32(ni.value,!0);return ni.value=ni.value+4,ha}function Kc(rs,ni){var ha=rs.getUint32(ni.value,!0);return ni.value=ni.value+4,ha}function uf(rs,ni){var ha=rs[ni.value];return ni.value=ni.value+1,ha}function Bf(rs,ni){var ha=rs.getUint8(ni.value);return ni.value=ni.value+1,ha}const Yf=function(rs,ni){let ha;return"getBigInt64"in DataView.prototype?ha=Number(rs.getBigInt64(ni.value,!0)):ha=rs.getUint32(ni.value+4,!0)+Number(rs.getUint32(ni.value,!0)<<32),ni.value+=8,ha};function yf(rs,ni){var ha=rs.getFloat32(ni.value,!0);return ni.value+=4,ha}function wa(rs,ni){return DataUtils.toHalfFloat(yf(rs,ni))}function yl(rs){var ni=(rs&31744)>>10,ha=rs&1023;return(rs>>15?-1:1)*(ni?ni===31?ha?NaN:1/0:Math.pow(2,ni-15)*(1+ha/1024):6103515625e-14*(ha/1024))}function hl(rs,ni){var ha=rs.getUint16(ni.value,!0);return ni.value+=2,ha}function Jc(rs,ni){return yl(hl(rs,ni))}function ff(rs,ni,ha,ls){for(var es=ha.value,zs=[];ha.value<es+ls-1;){var El=qf(ni,ha),bh=hf(rs,ha),Dh=Bf(rs,ha);ha.value+=3;var af=hf(rs,ha),vf=hf(rs,ha);zs.push({name:El,pixelType:bh,pLinear:Dh,xSampling:af,ySampling:vf})}return ha.value+=1,zs}function wf(rs,ni){var ha=yf(rs,ni),ls=yf(rs,ni),es=yf(rs,ni),zs=yf(rs,ni),El=yf(rs,ni),bh=yf(rs,ni),Dh=yf(rs,ni),af=yf(rs,ni);return{redX:ha,redY:ls,greenX:es,greenY:zs,blueX:El,blueY:bh,whiteX:Dh,whiteY:af}}function aA(rs,ni){var ha=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],ls=Bf(rs,ni);return ha[ls]}function BA(rs,ni){var ha=Kc(rs,ni),ls=Kc(rs,ni),es=Kc(rs,ni),zs=Kc(rs,ni);return{xMin:ha,yMin:ls,xMax:es,yMax:zs}}function A_(rs,ni){var ha=["INCREASING_Y"],ls=Bf(rs,ni);return ha[ls]}function qA(rs,ni){var ha=yf(rs,ni),ls=yf(rs,ni);return[ha,ls]}function UC(rs,ni){var ha=yf(rs,ni),ls=yf(rs,ni),es=yf(rs,ni);return[ha,ls,es]}function rC(rs,ni,ha,ls,es){if(ls==="string"||ls==="stringvector"||ls==="iccProfile")return Sh(ni,ha,es);if(ls==="chlist")return ff(rs,ni,ha,es);if(ls==="chromaticities")return wf(rs,ha);if(ls==="compression")return aA(rs,ha);if(ls==="box2i")return BA(rs,ha);if(ls==="lineOrder")return A_(rs,ha);if(ls==="float")return yf(rs,ha);if(ls==="v2f")return qA(rs,ha);if(ls==="v3f")return UC(rs,ha);if(ls==="int")return hf(rs,ha);if(ls==="rational")return mo(rs,ha);if(ls==="timecode")return Xc(rs,ha);if(ls==="preview")return ha.value+=es,"skipped";ha.value+=es}function wI(rs,ni,ha){const ls={};if(rs.getUint32(0,!0)!=20000630)throw"THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.";ls.version=rs.getUint8(4);const es=rs.getUint8(5);ls.spec={singleTile:!!(es&2),longName:!!(es&4),deepFormat:!!(es&8),multiPart:!!(es&16)},ha.value=8;for(var zs=!0;zs;){var El=qf(ni,ha);if(El==0)zs=!1;else{var bh=qf(ni,ha),Dh=Kc(rs,ha),af=rC(rs,ni,ha,bh,Dh);af===void 0?console.warn(`EXRLoader.parse: skipped unknown header attribute type '${bh}'.`):ls[El]=af}}if(es!=0)throw console.error("EXRHeader:",ls),"THREE.EXRLoader: provided file is currently unsupported.";return ls}function bI(rs,ni,ha,ls,es){const zs={size:0,viewer:ni,array:ha,offset:ls,width:rs.dataWindow.xMax-rs.dataWindow.xMin+1,height:rs.dataWindow.yMax-rs.dataWindow.yMin+1,channels:rs.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:rs.channels[0].pixelType,uncompress:null,getter:null,format:null,[hasColorSpace$1?"colorSpace":"encoding"]:null};switch(rs.compression){case"NO_COMPRESSION":zs.lines=1,zs.uncompress=ta;break;case"RLE_COMPRESSION":zs.lines=1,zs.uncompress=Ii;break;case"ZIPS_COMPRESSION":zs.lines=1,zs.uncompress=el;break;case"ZIP_COMPRESSION":zs.lines=16,zs.uncompress=el;break;case"PIZ_COMPRESSION":zs.lines=32,zs.uncompress=Fc;break;case"PXR24_COMPRESSION":zs.lines=16,zs.uncompress=Zl;break;case"DWAA_COMPRESSION":zs.lines=32,zs.uncompress=Yc;break;case"DWAB_COMPRESSION":zs.lines=256,zs.uncompress=Yc;break;default:throw"EXRLoader.parse: "+rs.compression+" is unsupported"}if(zs.scanlineBlockSize=zs.lines,zs.type==1)switch(es){case FloatType:zs.getter=Jc,zs.inputSize=2;break;case HalfFloatType:zs.getter=hl,zs.inputSize=2;break}else if(zs.type==2)switch(es){case FloatType:zs.getter=yf,zs.inputSize=4;break;case HalfFloatType:zs.getter=wa,zs.inputSize=4}else throw"EXRLoader.parse: unsupported pixelType "+zs.type+" for "+rs.compression+".";zs.blockCount=(rs.dataWindow.yMax+1)/zs.scanlineBlockSize;for(var El=0;El<zs.blockCount;El++)Yf(ni,ls);zs.outputChannels=zs.channels==3?4:zs.channels;const bh=zs.width*zs.height*zs.outputChannels;switch(es){case FloatType:zs.byteArray=new Float32Array(bh),zs.channels<zs.outputChannels&&zs.byteArray.fill(1,0,bh);break;case HalfFloatType:zs.byteArray=new Uint16Array(bh),zs.channels<zs.outputChannels&&zs.byteArray.fill(15360,0,bh);break;default:console.error("THREE.EXRLoader: unsupported type: ",es);break}return zs.bytesPerLine=zs.width*zs.inputSize*zs.channels,zs.outputChannels==4?zs.format=RGBAFormat:zs.format=RedFormat,hasColorSpace$1?zs.colorSpace="srgb-linear":zs.encoding=3e3,zs}const IA=new DataView(e),ml=new Uint8Array(e),gy={value:0},lA=wI(IA,e,gy),By=bI(lA,IA,ml,gy,this.type),aC={value:0},Ab={R:0,G:1,B:2,A:3,Y:0};for(let rs=0;rs<By.height/By.scanlineBlockSize;rs++){const ni=Kc(IA,gy);By.size=Kc(IA,gy),By.lines=ni+By.scanlineBlockSize>By.height?By.height-ni:By.scanlineBlockSize;const ls=By.size<By.lines*By.bytesPerLine?By.uncompress(By):ta(By);gy.value+=By.size;for(let es=0;es<By.scanlineBlockSize;es++){const zs=es+rs*By.scanlineBlockSize;if(zs>=By.height)break;for(let El=0;El<By.channels;El++){const bh=Ab[lA.channels[El].name];for(let Dh=0;Dh<By.width;Dh++){aC.value=(es*(By.channels*By.width)+El*By.width+Dh)*By.inputSize;const af=(By.height-1-zs)*(By.width*By.outputChannels)+Dh*By.outputChannels+bh;By.byteArray[af]=By.getter(ls,aC)}}}}return{header:lA,width:By.width,height:By.height,data:By.byteArray,format:By.format,[hasColorSpace$1?"colorSpace":"encoding"]:By[hasColorSpace$1?"colorSpace":"encoding"],type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(v,A){hasColorSpace$1?v.colorSpace=A.colorSpace:v.encoding=A.encoding,v.minFilter=LinearFilter,v.magFilter=LinearFilter,v.generateMipmaps=!1,v.flipY=!1,t&&t(v,A)}return super.load(e,o,n,s)}}const _taskCache=new WeakMap;class DRACOLoader extends Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const o=new FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,v=>{const A={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(v,A).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const b in t.attributeTypes){const T=t.attributeTypes[b];T.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[b]=T.name)}const n=JSON.stringify(t);if(_taskCache.has(e)){const b=_taskCache.get(e);if(b.key===n)return b.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const o=this.workerNextTaskID++,v=e.byteLength,A=this._getWorker(o,v).then(b=>(s=b,new Promise((T,ee)=>{s._callbacks[o]={resolve:T,reject:ee},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(b=>this._createGeometry(b.geometry));return A.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),_taskCache.set(e,{key:n,promise:A}),A}_createGeometry(e){const t=new BufferGeometry;e.index&&t.setIndex(new BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],o=s.name,v=s.array,A=s.itemSize;t.setAttribute(o,new BufferAttribute(v,A))}return t}_loadLibrary(e,t){const n=new FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,o)=>{n.load(e,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=DRACOWorker.toString(),v=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
8919
- `);this.workerSourceURL=URL.createObjectURL(new Blob([v]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const v=o.data;switch(v.type){case"decode":s._callbacks[v.id].resolve(v);break;case"error":s._callbacks[v.id].reject(v);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+v.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function DRACOWorker(){let a,e;onmessage=function(v){const A=v.data;switch(A.type){case"init":a=A.decoderConfig,e=new Promise(function(ee){a.onModuleLoaded=function(re){ee({draco:re})},DracoDecoderModule(a)});break;case"decode":const b=A.buffer,T=A.taskConfig;e.then(ee=>{const re=ee.draco,ie=new re.Decoder,se=new re.DecoderBuffer;se.Init(new Int8Array(b),b.byteLength);try{const le=t(re,ie,se,T),pe=le.attributes.map(de=>de.array.buffer);le.index&&pe.push(le.index.array.buffer),self.postMessage({type:"decode",id:A.id,geometry:le},pe)}catch(le){console.error(le),self.postMessage({type:"error",id:A.id,error:le.message})}finally{re.destroy(se),re.destroy(ie)}});break}};function t(v,A,b,T){const ee=T.attributeIDs,re=T.attributeTypes;let ie,se;const le=A.GetEncodedGeometryType(b);if(le===v.TRIANGULAR_MESH)ie=new v.Mesh,se=A.DecodeBufferToMesh(b,ie);else if(le===v.POINT_CLOUD)ie=new v.PointCloud,se=A.DecodeBufferToPointCloud(b,ie);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!se.ok()||ie.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+se.error_msg());const pe={index:null,attributes:[]};for(const de in ee){const fe=self[re[de]];let _e,ve;if(T.useUniqueIDs)ve=ee[de],_e=A.GetAttributeByUniqueId(ie,ve);else{if(ve=A.GetAttributeId(ie,v[ee[de]]),ve===-1)continue;_e=A.GetAttribute(ie,ve)}pe.attributes.push(s(v,A,ie,de,fe,_e))}return le===v.TRIANGULAR_MESH&&(pe.index=n(v,A,ie)),v.destroy(ie),pe}function n(v,A,b){const ee=b.num_faces()*3,re=ee*4,ie=v._malloc(re);A.GetTrianglesUInt32Array(b,re,ie);const se=new Uint32Array(v.HEAPF32.buffer,ie,ee).slice();return v._free(ie),{array:se,itemSize:1}}function s(v,A,b,T,ee,re){const ie=re.num_components(),le=b.num_points()*ie,pe=le*ee.BYTES_PER_ELEMENT,de=o(v,ee),fe=v._malloc(pe);A.GetAttributeDataArrayForAllPoints(b,re,de,pe,fe);const _e=new ee(v.HEAPF32.buffer,fe,le).slice();return v._free(fe),{name:T,array:_e,itemSize:ie}}function o(v,A){switch(A){case Float32Array:return v.DT_FLOAT32;case Int8Array:return v.DT_INT8;case Int16Array:return v.DT_INT16;case Int32Array:return v.DT_INT32;case Uint8Array:return v.DT_UINT8;case Uint16Array:return v.DT_UINT16;case Uint32Array:return v.DT_UINT32}}}const ENV={}.VITE_APP_ENV,IS_DEV_ENV=!1;let DISABLE_ANALYTICS_EVENTS=!1,ASSETS_SOURCE_ROOT;const LOGGER=new x2("CORE");ENV==="staging"?(LOGGER.setCurrentMode(TR.Staging),ASSETS_SOURCE_ROOT="https://storage.googleapis.com/epigraph-configurator"):(LOGGER.setCurrentMode(TR.Release),ASSETS_SOURCE_ROOT="https://storage.googleapis.com/epigraph-configurator");LOGGER.info({title:"test"});const DEFAULT_INVENTORY=99999,DEFAULT_PRODUCT_PRICE=99999;let CORE_API=null;function setCoreApi(a){CORE_API=a,CORE_API.disableAnalyticsEvents=DISABLE_ANALYTICS_EVENTS}const ALL_PROJECTS_ASSET_DATA_ROOT_URL=`${ASSETS_SOURCE_ROOT}/projects-asset-data`,GENERIC_PROJECT_ASSET_DATA_ROOT_URL=`${ALL_PROJECTS_ASSET_DATA_ROOT_URL}/generic`;let FETCH_MODULE_DATA_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe?moduleID=",SAVE_CONFIG_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe/saveConfig",FETCH_CONFIG_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe?configID=",PUBLIC_DESIGN_ASSETS_ENDPOINT="https://storage.googleapis.com/gsc-epigraph-design/product-assets";function setGlobalEndpoints(a){const e=a.SAVE_CONFIG_ENDPOINT;SAVE_CONFIG_ENDPOINT=e||SAVE_CONFIG_ENDPOINT;const t=a.FETCH_CONFIG_ENDPOINT;FETCH_CONFIG_ENDPOINT=t||FETCH_CONFIG_ENDPOINT;const n=a.PUBLIC_DESIGN_ASSETS_ENDPOINT;PUBLIC_DESIGN_ASSETS_ENDPOINT=n||PUBLIC_DESIGN_ASSETS_ENDPOINT;const s=a.ASSETS_SOURCE_ROOT;ASSETS_SOURCE_ROOT=s||ASSETS_SOURCE_ROOT}const ALERT_TYPES=Object.freeze({info:{id:"info",level:1e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Info.svg",color:"#2E6CDF",cssClass:"alert-info",background:"#D3E0F8",filter:"invert(39%) sepia(41%) saturate(5002%) hue-rotate(208deg) brightness(91%) contrast(92%)"},warn:{id:"warn",level:3e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Warning.svg",color:"#E2B236",cssClass:"alert-warn",background:"#F9EED2",filter:"invert(83%) sepia(67%) saturate(1578%) hue-rotate(328deg) brightness(93%) contrast(90%)"},error:{id:"error",level:4e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Block.svg",color:"#D0342C",cssClass:"alert-error",background:"#F6D7D5",filter:"invert(24%) sepia(96%) saturate(1914%) hue-rotate(349deg) brightness(95%) contrast(81%)"},success:{id:"success",level:2e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/CheckCircle.svg",color:"#65BC6C",cssClass:"alert-success",background:"#DBF0DD",filter:"invert(74%) sepia(3%) saturate(5600%) hue-rotate(75deg) brightness(90%) contrast(90%)"}}),CAMERA_ACTION=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),CURSORS={GRAB:"grab",POINTER:"pointer",BLOCKED:"blocked",GRABBING:"grabbing",MOVE:"move"},ensureUniqueNames=a=>{const e=[],t=new Set;for(const n of a){let s=n,o=0;for(;t.has(s);)s=n+"."+ ++o;t.add(s),e.push(s)}return e},mappingsArrayToTable=(a,e)=>{const t={};for(const n of a.mappings)for(const s of n.variants)t[e[s]]={material:null,gltfMaterialIndex:n.material};return t},compatibleObject=a=>a.material!==void 0&&a.userData&&a.userData.variantMaterials,traversePair=(a,e,t)=>{t(a,e);for(let n=0;n<a.children.length;n++)traversePair(a.children[n],e.children[n],t)},copyVariantMaterials=(a,e)=>{e.userData.variantMaterials!==void 0&&(a.userData.variantMaterials=Object.assign({},e.userData.variantMaterials)),e.userData.originalMaterial!==void 0&&(a.userData.originalMaterial=e.userData.originalMaterial)};class GLTFMaterialsVariantsExtension{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,n=t.json;if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name].variants||[],v=ensureUniqueNames(o.map(T=>T.name));for(const T of e.scenes)T.traverse(ee=>{const re=t.associations.get(ee);if(!re||re.meshes===void 0||re.primitives===void 0)return;const le=n.meshes[re.meshes].primitives[re.primitives].extensions;!le||!le[this.name]||(ee.userData.variantMaterials=mappingsArrayToTable(le[this.name],v))});e.userData.variants=v,e.functions=e.functions||{};const A=async(T,ee,re)=>{T.userData.originalMaterial||(T.userData.originalMaterial=T.material);const ie=T.material;let se=null;if(ee===null||!T.userData.variantMaterials[ee])T.material=T.userData.originalMaterial,t.associations.has(T.material)&&(se=t.associations.get(T.material).index);else{const le=T.userData.variantMaterials[ee];le.material?(T.material=le.material,le.gltfMaterialIndex!==void 0&&(se=le.gltfMaterialIndex)):(se=le.gltfMaterialIndex,T.material=await t.getDependency("material",se),t.assignFinalMaterial(T),le.material=T.material)}re!==null&&re(T,ie,se)},b=T=>{const ee=T.material,re=T.userData.variantMaterials,ie=[];for(const se in re){const le=re[se];if(le.material)continue;const pe=le.gltfMaterialIndex;ie.push(t.getDependency("material",pe).then(de=>{T.material=de,t.assignFinalMaterial(T),re[se].material=T.material}))}return Promise.all(ie).then(()=>{T.material=ee})};e.functions.selectVariant=(T,ee,re=!0,ie=null)=>{const se=[];return re?T.traverse(le=>compatibleObject(le)&&se.push(A(le,ee,ie))):compatibleObject(T)&&se.push(A(T,ee,ie)),Promise.all(se)},e.functions.ensureLoadVariants=(T,ee=!0)=>{const re=[];return ee?T.traverse(ie=>compatibleObject(ie)&&re.push(b(ie))):compatibleObject(T)&&re.push(b(T)),Promise.all(re)},e.functions.copyVariantMaterials=(T,ee,re=!0)=>{re?traversePair(T,ee,(ie,se)=>copyVariantMaterials(ie,se)):copyVariantMaterials(T,ee)}}}var dracoLoader=new DRACOLoader;dracoLoader.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`);dracoLoader.setDecoderConfig({type:"js"});const assetStore=create$3((a,e)=>({assets:{items:{}},actions:{async loadAsset(t,n=!1){const{assets:s}=e();let o,v;if(s.items[t]){const re=n?s.items[t].proxy:s.items[t];if(re.isLoaded)return s.items[t];if(re.errorLoading)throw Error((n?"Proxy ":"Model ")+"Loading failed for: "+t,t)}else s.items[t]={isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}};const A=productDataStore$1.getState().productData[t];if(!A)throw Error("Data doesn't exists for "+t,t);if(n?(o=s.items[t].proxy,v=CORE_API.getResolvedAssetUrl(A.colliderProxyGLTF)):(o=s.items[t],v=CORE_API.getResolvedAssetUrl(A.gltfURL)),!o||!v)return null;const b=new GLTFLoader;b.register(re=>new GLTFMaterialsVariantsExtension(re)),b.setDRACOLoader(dracoLoader);async function T(re){const ie=re.loaded/re.total*100;o.progress=ie}const ee=await b.loadAsync(v,T).catch(re=>{throw o.isLoaded=!1,o.errorLoading=!0,o.error=re,LOGGER.info(v),Error("Couldn't load "+t,t)});return o.data=ee,o.isLoaded=!0,s.items[t]},IsAssetLoaded(t){const{assets:n}=e();return n.items.hasOwnProperty(t)?n.items[t].isLoaded:!1},IsProxyLoaded(t){const{assets:n}=e();return n.items.hasOwnProperty(t)&&n.items[t].hasOwnProperty(proxy)?n.items[t].proxy.isLoaded:!1}}}));var replacingNode=null,swappableNodes=[];const ghostStore=create$3((a,e)=>({ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(t,n=!1,s)=>{const{ghostData:o,ghostsTransform:v}=e();if(o!==null||v.length>0){LOGGER.info("ghosts are already spawned for: "+o.skuID);return}return await new Promise(async(b,T)=>{let ee={};const re=()=>{b(ee)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Ghost_Loaded,re,{once:!0});const ie=productDataStore$1.getState().productData,se=attachmentStore$1.getState().attachmentSystem.currentStructure;if(replacingNode=se.getFirstNodeByCategoryID(ie[t].categoryID),ie[t].replace&&replacingNode){if(t==replacingNode.skuID)return;const{transforms:pe,connectablePlugs:de}=se.findGhostTransformForReplacement(t,replacingNode);if(pe==null&&de==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+t});return}ee.transforms=pe,ee.newNodes=[replacingNode],ee.connectablePlugs=de,ee.addItemOrSwap=["replace"],replacingNode.setModelVisibility(!1)}else{const{transforms:pe,newNodes:de,connectablePlugs:fe}=se.findGhostTransforms(t,n);let _e=pe,ve=fe,xe=de,De=[];for(let Le=0;Le<pe.length;Le++)De.push("add");if(ie[t].swappable&&!sceneStore.getState().dragging){swappableNodes=se.getNodesByCategoryID(ie[t].categoryID);for(let Le=0;Le<swappableNodes.length;Le++){const Ue=se.findGhostTransformForReplacement(t,swappableNodes[Le]);Ue.transforms&&(_e.push(Ue.transforms[0]),ve.push(Ue.connectablePlugs[0]),xe.push(swappableNodes[Le]),De.push("replace"),swappableNodes[Le].setModelVisibility(!1))}}ee.transforms=_e,ee.newNodes=xe,ee.connectablePlugs=ve,ee.addItemOrSwap=De}if(ee.transforms.length<=0)return;const le=await assetStore.getState().actions.loadAsset(t,!0);a({ghostsTransform:ee.transforms,ghostData:{proxyScene:le.proxy.data.scene,skuID:t,newNodes:ee.newNodes,addItemOrSwap:ee.addItemOrSwap,connectablePlugs:ee.connectablePlugs,count:s||ee.transforms.length}})})},clearAllGhosts:()=>{if(replacingNode&&replacingNode.setModelVisibility(!0),swappableNodes)for(let t=0;t<swappableNodes.length;t++)swappableNodes[t].setModelVisibility(!0);a({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),cameraStore=create$3((a,e)=>({focusPointPosition:new Vector3(0,0,0),canCameraRotate:!0,sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{triggerFetchingCamera:()=>{a(t=>({sendCameraDetailsTrigger:!t.sendCameraDetailsTrigger}))},setCameraSettings:t=>{const{cameraSettings:n}=e();sceneStore.getState().isMobile===!0&&t.zoomingMultiplier_mobile!==void 0?t.zoomingMultiplier=t.zoomingMultiplier_mobile:t.zoomingMultiplier_desktop!==void 0&&(t.zoomingMultiplier=t.zoomingMultiplier_desktop),Object.keys(t).map(o=>n[o]=t[o]),a({cameraSettings:{...n},viewPointPosition:ArrToVec3(n.initialViewPointPosition)})}}})),hotspotStore$1=create$3((a,e)=>({activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>a({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(t){const{hotspotsSpawned:n}=e();Object.keys(n).map(s=>{n[s].itemData.guid==t.itemData.guid&&delete n[s]}),a({hotspotsSpawned:{...n}})},checkHotspotHealth(){const{hotspotsHealthCheck:t}=e();a({hotspotsHealthCheck:!t})},toggleHotspotVisibility(){const{hotspotsVisibility:t}=e();a({hotspotsVisibility:!t})},switchHotspotsVisibility(t,n=!1){a(n===!0?{hotspotsTempVisibility:t}:{hotspotsVisibility:t})},clickHotspot(t,n,s,o=!1){const{activeHotspotData:v}=e();a({lastActiveHotspotData:v}),hotspotEnter(t,n,s);let b=itemStore.getState().itemsSpawned[s].itemData.skuID;o===!1&&(CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(b,t),hotspot:hotspotStore$1.getState().activeHotspotData}),CORE_API.fireEvent(CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(t=!1){const{activeHotspotData:n,isAnyHotspotActive:s}=e();if(s&&a({isAnyHotspotActive:!1}),!!n&&(a({lastActiveHotspotData:n}),hotspotExit(),t===!1)){const o=Math.round((performance.now()-e().lastActiveHotspotData.hotspotEnterTime)/1e3);CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:e().lastActiveHotspotData,hotspotTimeSpent:o}),CORE_API.fireEvent(CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(){hotspotStore$1.setState({activeHotspotData:null}),sceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(a,e,t){let n=hotspotStore$1.getState();const o=itemStore.getState().itemsSpawned;let v=n.visitedHotspotsID;const A=o[t].hotspotsData.filter(De=>De.hotspotID==a);if(!A||A.length<=0)return;const b=A[0],T=o[t].itemData.skuID+"_"+a;let re=attachmentStore$1.getState().attachmentSystem.currentStructure.getNodeByGUID(t),ie=new Vector3(0,0,0);re&&re.ref&&re.ref.getWorldPosition(ie);let se=new Quaternion().identity();re&&re.ref&&re.ref.getWorldQuaternion(se);let le=b.focusPointTransform;LOGGER.info(le);let pe=ArrToVec3(le);pe.applyQuaternion(se);let de=b.viewPointTransform,fe=ArrToVec3(de);fe.applyQuaternion(se);let _e=addVector(Vec3ToArr(pe),Vec3ToArr(ie)),ve=addVector(Vec3ToArr(fe),Vec3ToArr(ie));cameraStore.setState({focusPointPosition:_e,viewPointPosition:ve}),hotspotStore$1.setState({activeHotspotData:{hotspotData:{guid:e,...b},itemData:{...o[t],guid:t},domID:"rd_"+T,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),v.includes(T)||(v.push(T),hotspotStore$1.setState({visitedIDs:{...v}}))}const itemStore=create$3((a,e)=>({variantChangeAlert:!1,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],filteredCollidersRef:[],selectedItemData:null,busy:!1,actions:{triggerModelLoaded:()=>a(t=>({modelLoadedAlert:t.modelLoadedAlert+1})),triggerRemoveItem:()=>a(t=>({removeItemTrigger:!t.removeItemTrigger})),addToRemoveItems:t=>{const{removeItems:n}=e();n.push(t)},switchToVariant:async(t,n,s=!1)=>{const{itemsSpawned:o,variantChangeAlert:v}=e(),A=productDataStore$1.getState().categoryData,b=o[t.guid].itemData.clonedScene;var ee=attachmentStore$1.getState().attachmentSystem.currentStructure.getNodeByGUID(t.guid);assetStore.getState().assets.items[t.skuID].data||A.geometryVariants&&A.geometryVariants.map(se=>{se.productsInCategory.map(le=>{let pe=!1;le.products.map(de=>{de==t.skuID&&(pe=!0)}),pe&&le.products.map(de=>{const fe=assetStore.getState().assets.items[de].data;fe&&(assetStore.getState().assets.items[t.skuID].data=fe)})})});const ie=assetStore.getState().assets.items[t.skuID].data;ie&&(await ie.functions.selectVariant(b,n),s?(ee.overrideVariant=n,CORE_API.fireEvent(CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):ee.currentVariant=n,a({variantChangeAlert:!v}))},clearAllItems:()=>{a({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:t=>{a({itemsSpawned:t,itemsCount:Object.keys(t).length})},setHoveredItemRef:t=>a({hoveredItemRef:t}),setCollidersRef:t=>{a({collidersRef:t});let n=[];for(var s=0;s<t.length;s++)t[s].current&&n.push(t[s]);itemStore.setState({filteredCollidersRef:[...n]})},setSelectedItemData:t=>{const{selectedItemData:n,hoveredItemRef:s,actions:o}=e();n&&(delete s[n.itemData.guid],o.setHoveredItemRef({...s})),a({selectedItemData:{...t}}),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.switchHotspotsVisibility(!1,!0),cameraStore.setState({canCameraRotate:!1})},deselectItem:()=>{const{selectedItemData:t}=e();t&&CORE_API.fireEvent(CORE_API.EVENTS.UI.ContextMenu_Hide,t),a(()=>({selectedItemData:null})),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.switchHotspotsVisibility(!0,!0),cameraStore.setState({canCameraRotate:!0}),itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async t=>{const{itemsSpawned:n,actions:s}=e();if(n.hasOwnProperty(t))return new Promise(async(o,v)=>{s.addToRemoveItems(t),s.triggerRemoveItem();const A=b=>{t===b.data.itemData.guid&&o(t)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Item_Removed,A,{once:!0})})},addItemBySkuID:async(t,n=0,s=!1,o)=>{a({busy:!0});const{actions:v,itemsSpawned:A}=e(),b=productDataStore$1.getState().productData,T=productDataStore$1.getState().hotspotsData,ee=attachmentStore$1.getState().attachmentSystem;let re=!0;const ie=await new Promise(async(pe,de)=>{if(v.deselectItem(),!b[t]){LOGGER.warn({title:`Product not found: ${t}`}),CORE_API.alert({alertMsg:t+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),re=!1,de(t+": product not found!");return}const fe=[...ghostStore.getState().ghostsTransform],_e={...ghostStore.getState().ghostData};if(ghostStore.getState().actions.clearAllGhosts(),fe.length<=0){CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),re=!1,de("No available connections for this product to attach to");return}const ve=xe=>{t===xe.data&&pe(_e.newNodes[n].guid)};if(CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,ve,{once:!0}),_e.addItemOrSwap[n]=="replace")await replaceItem(A,_e.skuID,fe[n],_e.newNodes[n]);else{const xe=_e.newNodes[n];xe.isDependent=s;let De=!0;if(b[_e.skuID].hasOwnProperty("disableInteraction")){const Fe=b[_e.skuID].disableInteraction;(Fe==!0||Fe==!1)&&(De=!Fe)}(o==!0||o==!1)&&(De=o),xe.isInteractive=De;const{position:Le,rotation:Ue}=fe[n];xe.transform={position:Le,rotation:Ue},ee.currentStructure.addNode(xe),ee.currentStructure.connectPlugs(_e.connectablePlugs[n]);const Ge=await assetStore.getState().actions.loadAsset(_e.skuID,!0);LOGGER.info("GHOST NEW NODE: ",xe),A[xe.guid]={itemData:{proxyScene:Ge.proxy.data.scene,guid:_e.newNodes[n].guid,...b[_e.skuID],position:Le,rotation:Ue,hasItemLoaded:!1,isDependent:s,isInteractive:De},hotspotsData:T[_e.skuID],hotspotSpawned:!1},await wait(1),v.setItemsSpawned({...A})}}).catch(pe=>{LOGGER.error({title:pe}),re=!1});if(re===!1)return a({busy:!1}),ie;const se=ee.getCartItems();se&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,se);const le=b[t]?.plugs;if(le){for(const pe of le){const de=pe?.dependencySku;if(!de)continue;LOGGER.info(`Found a dependency: ${de} on the plug: ${pe.name}`);let fe=!0;b[de]&&b[de].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(fe=b[de].ignoreSpawningCollisionAsDependency),pe.hasOwnProperty("ignoreSpawningCollision")&&(fe=pe.ignoreSpawningCollision);let _e=sceneStore.getState().sceneSettings.ignoreSpawningCollision;b[de].hasOwnProperty("ignoreSpawningCollision")&&(_e=b[de].ignoreSpawningCollision),b[de].ignoreSpawningCollision=fe;const ve=await ghostStore.getState().actions.spawnGhostsForSkuID(de,fe);if(b[de].ignoreSpawningCollision=_e,!ve)continue;const xe=ee.currentStructure.getNodeByGUID(ie),De=xe.getPlugByName(pe.name)?.guid,Le=pe?.isDependencySkuInteractive?pe.isDependencySkuInteractive===1:!1,Ue=ve.connectablePlugs;let Ge=!1;for(let Fe=0;Fe<ve.connectablePlugs.length;Fe++){if(Ue[Fe].receiverPlug.guid!==De)continue;Ge=!0;const Ye=await v.addItemBySkuID(de,Fe,!0,Le);Ye!==null&&xe.addMyDependenciesGUID(Ye)}Ge||ghostStore.getState().actions.clearAllGhosts()}ghostStore.getState().actions.clearAllGhosts()}return a({busy:!1}),ie},async addItemWithTransform(t,n,s,o=!0){return new Promise(async(v,A)=>{const{actions:b,itemsSpawned:T}=e();b.deselectItem();const ee=productDataStore$1.getState().productData,re=productDataStore$1.getState().hotspotsData;if(!ee[n]){CORE_API.alert({alertMsg:n+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"});return}const{position:ie,rotation:se}=t;T[s]!=null&&(hotspotStore$1.getState().actions.removeHotspotForItem({...T[s]}),delete T[s]);const le=de=>{n==de.data&&v(s)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,le,{once:!0});const pe=await assetStore.getState().actions.loadAsset(n,!0);pe!=null&&(await wait(1),T[s]={itemData:{proxyScene:pe.proxy.data.scene,guid:s,...ee[n],position:ie,rotation:se,hasItemLoaded:!1,isInteractive:o},hotspotsData:re[n],hotspotSpawned:!1},a({itemsSpawned:{...T}}))})},async replaceGUIDItemBySKUID(t,n){const{itemsSpawned:s}=e(),o=productDataStore$1.getState().productData,v=productDataStore$1.getState().hotspotsData,A=attachmentStore$1.getState().attachmentSystem.currentStructure,b=A.getNodeByGUID(t);return b.isReplaceableWithSkuId(n)?(await new Promise(async(ee,re)=>{hotspotStore$1.getState().actions.removeHotspotForItem({...s[t]}),delete s[t],b.update(n);const ie=le=>{n===le.data&&ee(!0)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,ie,{once:!0});const se=await assetStore.getState().actions.loadAsset(n,!0);await wait(1),s[t]={itemData:{proxyScene:se.proxy.data.scene,guid:t,...o[n],position:b.transform.position,rotation:b.transform.rotation,hasItemLoaded:!1},hotspotsData:v[n],hotspotSpawned:!1},itemStore.setState({itemsSpawned:{...s}})}),A.recalculateStructureFromNode(b.whichNodeAreWeAttachedTo()),attachmentStore$1.getState().actions.toggleStructureUpdated(),!0):!1}}}));async function replaceItem(a,e,t,n){const{position:s,rotation:o}=t,v=productDataStore$1.getState().productData,A=productDataStore$1.getState().hotspotsData,b=attachmentStore$1.getState().attachmentSystem.currentStructure;return new Promise(async(T,ee)=>{const re=async()=>{const ie=await assetStore.getState().actions.loadAsset(e,!0);a[n.guid]={itemData:{proxyScene:ie.proxy.data.scene,guid:n.guid,...v[e],position:s,rotation:o,hasItemLoaded:!1},hotspotsData:A[e],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:n.currentVariant}),n.currentVariant=n.currentVariant,n.transform=t,itemStore.setState({itemsSpawned:{...a}}),b.recalculateStructureFromNode(n),attachmentStore$1.getState().actions.toggleStructureUpdated(),T(n.guid)};hotspotStore$1.getState().actions.removeHotspotForItem({...a[n.guid]}),delete a[n.guid],n.update(e),CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Removed,re,{once:!0})})}const inventoryStore=create$3((a,e)=>({inventoryData:{},actions:{getInventoryInfo:()=>{const{inventoryData:t}=e();return t},updateInventoryForAllProducts:t=>{const{actions:n}=e();Object.keys(t).map(s=>{let o=t[s];Object.keys(o).map(v=>{n.updateInventoryForProduct(s,v,o[v].inventory)})}),n.refreshInventory(itemStore.getState().itemsSpawned)},updateInventoryForProduct:(t,n,s)=>{const{inventoryData:o}=e();let v=o[t],A=v[n];!v||!A||(A.inventory=s)},_clearInScene:()=>{const{inventoryData:t}=e();Object.keys(t).map(n=>{const s=t[n];Object.keys(s).map(o=>{s[o].inScene=[]})})},refreshInventory:t=>{if(!t)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:n,inventoryData:s}=e();n._clearInScene();const o=attachmentStore$1.getState().attachmentSystem;if(o===null)return;const v=o.currentStructure;if(v===null)return;Object.keys(t).map(ee=>{const re=v.getNodeByGUID(ee);if(!re)return;const ie=re.overrideVariant?re.overrideVariant:re.currentVariant;if(!ie)return;const se=s[re.skuID];if(!se||!se[ie].inScene)return;se[ie].inScene.push(ee),sceneStore.getState().sceneSettings.disableCart===!0?re.inStock={variantName:ie,newValue:!0}:se[ie].inScene.length>se[ie].inventory?re.inStock={variantName:ie,newValue:!1}:re.inStock={variantName:ie,newValue:!0}});let A=!1;Object.keys(s).map(ee=>{const re=s[ee];Object.keys(re).map(ie=>{re[ie].countAvailable=re[ie].inventory-re[ie].inScene.length,re[ie].countAvailable<0?(re[ie].countUnavailable=re[ie].countAvailable*-1,re[ie].countAvailable=0,A=!0):re[ie].countUnavailable=0})});const b={alertMsg:"Some items selected are out of stock",alertTime:3e3,alertType:"warn",alertLabel:"Stock Alert",alertId:"outOfStock"},T=compareObjects(sceneStore.getState().persistantAlertData,b);A===!1&&T===!0&&CORE_API.removePersistantAlert(),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Inventory_Updated,s)}}})),sceneStore=create$3((a,e)=>({CORE_API:null,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,configurationLoaded:!0,preconfigurationLoaded:!1,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:null,showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:250,g:50,b:0,a:.75},ghostAsWireframe:!1,draggableUI:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:"Empty Scene",emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",textSettings:{cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",tooltipEmptySceneText:"-Add items to the scene-",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:0,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:t=>{a({cssLoaded:t})},actions:{popFromAlertQueue:()=>{const{alertQueue:t}=e();return t.shift(),a({alertQueue:t}),t},addToAlertQueue:t=>{const{alertQueue:n}=e();return n.push(t),a({alertQueue:n}),n},getDeviceState:()=>{const{isDesktop:t,isMobile:n,isTablet:s,isTouchDevice:o,isLandscape:v}=e();return{isDesktop:t,isMobile:n,isTablet:s,isTouchDevice:o,isLandscape:v}},enableCart:()=>{const{sceneSettings:t}=e();t.disableCart=!1,inventoryStore.getState().actions.refreshInventory(itemStore.getState().itemsSpawned),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:t}=e();t.disableCart=!0,inventoryStore.getState().actions.refreshInventory(itemStore.getState().itemsSpawned),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:t}=e();return t},sendAlert:t=>{a({alertData:{...t}})},switchCursor(t){const{cursorParentRef:n}=e();if(!n)return;let s="";switch(t){default:case CURSORS.GRAB:s="grabCursor";break;case CURSORS.GRABBING:s="grabbingCursor";break;case CURSORS.BLOCKED:s="blockedCursor";break;case CURSORS.POINTER:s="pointerCursor";break;case CURSORS.MOVE:s="moveCursor";break}for(let o=0;o<n.classList.length;o++)n.classList[o].includes("Cursor")&&n.classList.remove(n.classList[o]);n.classList.add(s)},setAlertSettings:t=>{a({alertSettings:t})},async completeDropItem(){const t=attachmentStore$1.getState().attachmentSystem,{draggingOnDropCollisionData:n}=e(),{node:s,attachedChildrenGuids:o,collidingStatus:v,intersectingGhostObject:A,initPosition:b,initRotation:T,detachedPlugs:ee,attachedNodesToCurrentNode:re}=n;CORE_API.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[pe,de]of o.entries())v[pe]===!0&&await itemStore.getState().actions.removeItemByGUID(de);const ie=A.userData;let se=s.getPlugByName(ie.incomingPlugName),le=t.currentStructure.getPlugByGUID(ie.receiverPlugGUID);s.ref.position.set(A.position.x,A.position.y,A.position.z),s.ref.setRotationFromEuler(A.rotation),s.transform={position:A.position,rotation:A.quaternion},t.currentStructure.connectPlugs({incomingPlug:se,receiverPlug:le}),ghostStore.getState().actions.clearAllGhosts(),itemStore.getState().actions.deselectItem(),re.map(pe=>{s.ref.parent.attach(pe.ref)}),attachmentStore$1.getState().actions.updateFittingSkuIds()},revertDropItem(){const t=attachmentStore$1.getState().attachmentSystem,{draggingOnDropCollisionData:n}=e(),{node:s,attachedChildrenGuids:o,collidingStatus:v,intersectingGhostObject:A,initPosition:b,initRotation:T,detachedPlugs:ee,attachedNodesToCurrentNode:re}=n;CORE_API.alert({alertMsg:"Position of item"+s.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const ie=ee.neighbourDetachedPlugs;ie&&(ee.neighbourNode.detachNodeFromReceiver(),t.currentStructure.connectPlugs({incomingPlug:ie.incomingPlug,receiverPlug:ie.receiverPlug}));let se=ee.rootDetachedPlugs.incomingPlug,le=ee.rootDetachedPlugs.receiverPlug;s.ref.position.set(b.x,b.y,b.z),s.ref.setRotationFromEuler(T);let pe=new Quaternion().identity();s.ref.getWorldQuaternion(pe),s.transform={position:b,rotation:pe},t.currentStructure.connectPlugs({incomingPlug:se,receiverPlug:le}),ghostStore.getState().actions.clearAllGhosts(),itemStore.getState().actions.deselectItem(),re.map(de=>{s.ref.parent.attach(de.ref)}),attachmentStore$1.getState().actions.updateFittingSkuIds()},setCoreSettings:t=>{const{sceneSettings:n,isMobile:s,isTouchDevice:o,isLandscape:v,actions:A}=e(),b=s===!0?"mobile":"desktop",T=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const ee of T)if(ee==="draggableUI"||ee==="emptySceneTextFontSize"||ee==="showInstructionsOnStartup"||ee==="showInstructionsBtn"||ee==="instructionsSettings"){const ie=`${ee}_${v===!1&&o===!0?"mobile":"desktop"}`;t[ie]!==void 0?n[ee]=t[ie]:n[ie]!==void 0&&(n[ee]=n[ie])}else if(ee==="textSettings"||ee==="variantsTabOrder"||ee==="alertControl"){if(t.hasOwnProperty(ee)){let re=n[ee];Object.keys(re).map(ie=>{let se=t[ee];se.hasOwnProperty(ie)||(se[ie]=re[ie])})}}else{const re=`${ee}_${b}`;if(t[re]!==void 0){let ie=`${ee}Btn`;ee=="showContextMenu"&&(ie=`${ee}`),n[ie]=t[re]}}t.disableCart===!0&&A.disableCart(),Object.keys(t).map(ee=>n[ee]=t[ee]),a({sceneSettings:{...n,ghostThreeColor:{r:n.ghostColor.r/255,g:n.ghostColor.g/255,b:n.ghostColor.b/255,a:n.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:n.ghostColorOnHoverWithDraggableUi.r/255,g:n.ghostColorOnHoverWithDraggableUi.g/255,b:n.ghostColorOnHoverWithDraggableUi.b/255,a:n.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(t=null)=>a(n=>({autoFocusRef:t,autoFocusTrigger:n.autoFocusTrigger+1})),requestNewScreenshot:async(t,n)=>new Promise(async(s,o)=>{LOGGER.info("Taking a screenshot");const{screenshotRenderer:v,sceneRef:A,screenshotCamera:b,canvasSize:T}=e(),ee=await CORE_API.getCurrentCameraDetails();if(v.setClearColor(16777215),b.copy(ee),t!==null&&(b.position.copy(t.position),b.rotation.copy(new Euler(t.rotation.x,t.rotation.y,t.rotation.z))),n==null?v.setSize(T.width,T.height):v.setSize(n.width,n.height),v.render(A.parent,b),v.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),o({success:!1,imageData:null});else{LOGGER.info("Downloading the screenshot");const re=v.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");s({success:!0,imageData:re})}})}})),hotspotIdPrefix="rd",hotspotIdSeparator="_";function generateHotspotAbsoluteID(a,e){return`${hotspotIdPrefix}${hotspotIdSeparator}${a}${hotspotIdSeparator}${e}`}async function wait(a){return LOGGER.info({title:`Waiting for ${a}ms`}),new Promise((e,t)=>{setTimeout(()=>{e(!0)},a)})}function compareObjects(a,e){if(a===null||e===null)return!1;for(let t in a)if(a.hasOwnProperty(t)&&e.hasOwnProperty(t)&&a[t]!==e[t])return!1;return Object.keys(a).length===Object.keys(e).length}const saveStructureToCMS=a=>{const e={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)};return fetch(SAVE_CONFIG_ENDPOINT,e)},mobileCheck=function(){let a=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(a=!0)}(navigator.userAgent||navigator.vendor||window.opera),a};function isIpadOS(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)}function tabletCheck(){const a=navigator.userAgent.toLowerCase(),e=/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(a);return e||isIpadOS()}function touchDeviceCheck(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}async function getJSONFromEndpoint(a){let e={data:null,report:"",success:!1};try{const n=await(await fetch(a)).text();e.data=JSON.parse(n),e.success=!0,e.report="Successfully fetched JSON data."}catch(t){e.report=t,CORE_API.alert({alertMsg:"",alertTime:5e3,alertType:"warn",alertLabel:"Preload Failed"})}return e}const addVector=(a,e)=>new Vector3(a[0]+e[0],a[1]+e[1],a[2]+e[2]),Vec3ToArr=a=>[a.x,a.y,a.z],ArrToVec3=a=>new Vector3(a[0],a[1],a[2]),findMeshAndCloneMatFromScene=(a,e=!0)=>{let t=[];const n=sceneStore.getState().sceneSettings.outOfStock_EmissiveColor,s=sceneStore.getState().sceneSettings.outOfStock_EmissiveIntensity;return a.traverse(o=>{o.isMesh&&(o.material.userData.cloned?o.material.userData.inStock!==e&&(e?(o.material.emissive.set(new Color$1(255,255,255)),o.material.emissiveIntensity=0):(o.material.emissive.set(new Color$1(n.r,n.g,n.b)),o.material.emissiveIntensity=s),o.material.userData.inStock=e):(o.material=o.material.clone(),o.material.userData.inStock=e,o.material.userData.cloned=!0,e?(o.material.emissive.set(new Color$1(255,255,255)),o.material.emissiveIntensity=0):(o.material.emissive.set(new Color$1(n.r,n.g,n.b)),o.material.emissiveIntensity=s)),t.push(o))}),t},filterArrWithCondition=(a,e)=>{let t=0,n=[];for(let s=0;s<a.length;s++){const o=a[s];e(o)?a[t++]=o:n.push(a[s])}return a.length=t,n},degToRad=a=>a*Math.PI/180,resolveAssetUrl=a=>{if(!a)return;if(new RegExp("^(?:[a-z+]+:)?//","i").test(a))return a;let n=a;return n=n.replaceAll("<@all-projects@>",ALL_PROJECTS_ASSET_DATA_ROOT_URL),n=n.replaceAll("<@generic-project@>",GENERIC_PROJECT_ASSET_DATA_ROOT_URL),n};function componentToHex(a){var e=a.toString(16);return e.length==1?"0"+e:e}function rgbToHex(a,e,t){return"#"+componentToHex(a)+componentToHex(e)+componentToHex(t)}function getUrlParameterByName(a,e=window.location.search){const t=new URLSearchParams(e);return Object.fromEntries(t.entries())[a]}const lightStore=create$3((a,e)=>({defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:t=>{a(n=>({envMapUrl:t}))},processLookEnvMapOverride:t=>{const{envMapUrl:n,defaultEnvMapUrl:s,actions:o}=e(),v=productDataStore$1.getState().lookData[t],A=v?.envMapOverride;if(!v||!A){o.setEnvLightMap(s);return}if(A===n){LOGGER.info(`New Env Map Url is the same as the current ${A}`);return}o.setEnvLightMap(A)}}}));var rngBrowser={exports:{}},getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(getRandomValues){var rnds8=new Uint8Array(16);rngBrowser.exports=function(){return getRandomValues(rnds8),rnds8}}else{var rnds=new Array(16);rngBrowser.exports=function(){for(var e=0,t;e<16;e++)e&3||(t=Math.random()*4294967296),rnds[e]=t>>>((e&3)<<3)&255;return rnds}}var rngBrowserExports=rngBrowser.exports,byteToHex=[];for(var i$2=0;i$2<256;++i$2)byteToHex[i$2]=(i$2+256).toString(16).substr(1);function bytesToUuid$2(a,e){var t=e||0,n=byteToHex;return[n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]]].join("")}var bytesToUuid_1=bytesToUuid$2,rng$1=rngBrowserExports,bytesToUuid$1=bytesToUuid_1,_nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1$2(a,e,t){var n=e&&t||0,s=e||[];a=a||{};var o=a.node||_nodeId,v=a.clockseq!==void 0?a.clockseq:_clockseq;if(o==null||v==null){var A=rng$1();o==null&&(o=_nodeId=[A[0]|1,A[1],A[2],A[3],A[4],A[5]]),v==null&&(v=_clockseq=(A[6]<<8|A[7])&16383)}var b=a.msecs!==void 0?a.msecs:new Date().getTime(),T=a.nsecs!==void 0?a.nsecs:_lastNSecs+1,ee=b-_lastMSecs+(T-_lastNSecs)/1e4;if(ee<0&&a.clockseq===void 0&&(v=v+1&16383),(ee<0||b>_lastMSecs)&&a.nsecs===void 0&&(T=0),T>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=b,_lastNSecs=T,_clockseq=v,b+=122192928e5;var re=((b&268435455)*1e4+T)%4294967296;s[n++]=re>>>24&255,s[n++]=re>>>16&255,s[n++]=re>>>8&255,s[n++]=re&255;var ie=b/4294967296*1e4&268435455;s[n++]=ie>>>8&255,s[n++]=ie&255,s[n++]=ie>>>24&15|16,s[n++]=ie>>>16&255,s[n++]=v>>>8|128,s[n++]=v&255;for(var se=0;se<6;++se)s[n+se]=o[se];return e||bytesToUuid$1(s)}var v1_1=v1$2,rng=rngBrowserExports,bytesToUuid=bytesToUuid_1;function v4$1(a,e,t){var n=e&&t||0;typeof a=="string"&&(e=a==="binary"?new Array(16):null,a=null),a=a||{};var s=a.random||(a.rng||rng)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e)for(var o=0;o<16;++o)e[n+o]=s[o];return e||bytesToUuid(s)}var v4_1=v4$1,v1$1=v1_1,v4=v4_1,uuid=v4;uuid.v1=v1$1;uuid.v4=v4;var uuid_1=uuid;class Plug{constructor(e,t,n=null){this._attachedPlug=null,this._name=e.name,this._acceptedPlugTypes=e.acceptedPlugTypes,this._type=e.type,this._affectedNodes=e.affectedNodes,this._weight=e.weight,this._connectsToPlugTypes=e.connectsToPlugTypes,this._node=t,this._guid=uuid_1.v4(),this._isOpen=!0,this._isReceiverPlug=!1,this._attachedPlugGUID=null,n&&(this._guid=n.guid,this._isOpen=n.isOpen,this._isReceiverPlug=n.isReceiverPlug,this._attachedPlugGUID=n.attachedPlugGUID)}export(){return this.isOpen?null:{guid:this._guid,isOpen:this._isOpen,attachedPlugGUID:this._attachedPlugGUID,isReceiverPlug:this._isReceiverPlug}}get node(){return this._node}get attachedPlug(){return this._attachedPlug}set attachedPlug(e){this._attachedPlug=e}get attachedPlugGUID(){return this._attachedPlugGUID}get type(){return this._type}get weight(){return this._weight}get affectedNodes(){return this._affectedNodes}get guid(){return this._guid}get isReceiverPlug(){return this._isReceiverPlug}get name(){return this._name}get acceptedPlugTypes(){return this._acceptedPlugTypes}set acceptedPlugTypes(e){this._acceptedPlugTypes=e}get connectsToPlugTypes(){return this._connectsToPlugTypes}set connectsToPlugTypes(e){this._connectsToPlugTypes=e}get isOpen(){return this._isOpen}attachPlug(e,t=!1){this._attachedPlug=e,this._attachedPlugGUID=e.guid,this._isOpen=!1,this._isReceiverPlug=t;const n=this,s=this._node;if(s.isConnectedToRoot&&t){const o=s.whichPlugAreWeAttachedUsing();switch(e.type){case"weighted_hider":o.weight<n.weight&&(s.showNodes(o.affectedNodes)||CORE_API.coreWCRef.addEventListener(s.guid+":modelLoaded",function(){s.showNodes(o.affectedNodes)},{once:!0}));break}}if(t&&e.type!==""&&e.type==n._type)switch(e.type){default:case"weighted_hider":n._weight>e.weight?e.node.hideNodes(e.affectedNodes)||CORE_API.coreWCRef.addEventListener(e.node.guid+":modelLoaded",function(){e.node.hideNodes(e.affectedNodes)},{once:!0}):n._weight<e.weight&&(s.hideNodes(n._affectedNodes)||CORE_API.coreWCRef.addEventListener(s.guid+":modelLoaded",function(){s.hideNodes(n._affectedNodes)},{once:!0}));break}t&&(s.isEndNode=!1)}openPlug(){if(this._node.isConnectedToRoot){const e=this._node.whichPlugAreWeAttachedUsing();if(e&&this._guid!==e.guid)switch(this.type){case"weighted_hider":e.type==="weighted_hider"&&e.weight<this.weight&&this._node.hideNodes(e.affectedNodes);break}}if(this._isReceiverPlug&&this._attachedPlug.type!==""&&this._attachedPlug.type==this._type)switch(this._attachedPlug.type){default:case"weighted_hider":this._weight>this._attachedPlug.weight?this._attachedPlug.node.showNodes(this._attachedPlug.affectedNodes):this._weight<this._attachedPlug.weight&&this._node.showNodes(this._affectedNodes);break}this._attachedPlug=null,this._attachedPlugGUID=null,this._isOpen=!0,this._isReceiverPlug&&(this._isReceiverPlug=!1,this._node.checkIfEndNode())}canAttachToPlug(e){for(let t=0;t<this._connectsToPlugTypes.length;t++)if(e._acceptedPlugTypes.includes(this._connectsToPlugTypes[t]))return!0;return!1}}let Node$1=class{#t="default";#i=!1;#r=!1;#s=!0;#n={};#o=!1;#c={};#u=[];constructor(e,t=null,n,s){let o=productDataStore$1.getState().productData;this._plugs=[],this._skuID=e,this._ref=null,this._modelData=null,this._transform=null,this.#t="default",this._overrideVariant=null,this._followsParent=o[e].followsParent,this._categoryID=o[e].categoryID,this._replace=o[e].replace,this._swappable=o[e].swappable,this._price=this.#a(),this.#i=o[e]?.ignoreInCart,t?(this._guid=t.guid,this._isEndNode=t.isEndNode,this._overrideVariant=t.overrideVariant,this.generatePlugsWithData(e,t.plugs)):(this._guid=uuid_1.v4(),this._isEndNode=!0,this.generatePlugsForNode(e)),n&&Object.keys(n).map(v=>{if(o[e].looks&&o[e].looks.includes(v)){this.#t=v;return}})}get isRoot(){return this._skuID.toLowerCase()==="root"}updateGeometryVariant(e,t){const s=productDataStore$1.getState().categoryData.geometryVariants;let o=null;if(s.map(ee=>{ee.id==e&&(o=ee)}),!o)return;const v=o.productsInCategory,b=o.variants[t].productsToSwitch,T=itemStore.getState().itemsSpawned;v.map(ee=>{ee.products.map(re=>{this.skuID===re&&ee.products.map(ie=>{b.map(se=>{if(se==ie){const le=productDataStore$1.getState().actions.getProductDataById(se);this.skuID=le.skuID;const pe=T[this.guid];pe&&pe.itemData&&Object.keys(le).map(de=>{pe.itemData[de]=le[de]}),this.hideNodes(le.geometriesToHide),this.showNodes(le.geometriesToShow),this.updatePricing(),this.resetInStock(),inventoryStore.getState().actions.refreshInventory(T)}})})})})}resetInStock(){this.#n={},this.#o=!0}setInStockForRef(e){if(!this.ref)return!1;let t=this.ref.getObjectByName("GRP_RenderGeometry");return t?(t.inStock=e,!0):!1}set inStock({variantName:e,newValue:t}){if(this.#n[e]&&this.#n[e]==t||(this.#n[e]=t,e!==this.#t&&this.#o===!1))return;const n=()=>{this.setInStockForRef(t)};n()||CORE_API.coreWCRef.addEventListener(this.guid+":modelLoaded",n,{once:!0})}get myDependenciesGUID(){return this.#u}set myDependenciesGUID(e){this.#u=e}addMyDependenciesGUID(e){this.#u.push(e)}get isDependent(){return this.#r}set isDependent(e){this.#r=e}get isInteractive(){return this.#s}set isInteractive(e){this.#s=e}update(e){this._skuID=e;const t=productDataStore$1.getState().productData,n=t[e]?.plugs;if(this.ignoreInCart=t[e].ignoreInCart,!!n)for(let s=0;s<this._plugs.length;s++)for(let o=0;o<n.length;o++)this._plugs[s].name==n[o].name&&(this._plugs[s].acceptedPlugTypes=n[o].acceptedPlugTypes,this._plugs[s].connectsToPlugTypes=n[o].connectsToPlugTypes)}export(){let e={};for(var t=0;t<this._plugs.length;t++){let n=this._plugs[t].export();n&&(e[this._plugs[t].name]=n)}return{skuID:this._skuID,guid:this._guid,isEndNode:this._isEndNode,plugs:e,overrideVariant:this._overrideVariant}}get node(){return this}get swappable(){return this._swappable}get replace(){return this._replace}get ignoreInCart(){return this.#i}set ignoreInCart(e){this.#i=e}get canRotate(){let e=!0;if(!this._isEndNode){const v=this.whichNodesAreAttachedToUs();if(v.length>0){let A=!0;if(v.map(b=>{b.followsParent===!1&&(A=!1)}),!A)return!1}}let t=!1;for(var n=0;n<this.plugs.length;n++)if(!this.plugs[n].isOpen&&this.plugs[n].attachedPlug.isReceiverPlug){const v=this.plugs[n].attachedPlug.acceptedPlugTypes;for(var s=0;s<this.plugs.length;s++)if(n!=s)for(var o=0;o<this.plugs[s].connectsToPlugTypes.length;o++)v.includes(this.plugs[s].connectsToPlugTypes[o])&&(t=!0)}return e=t,e}hideNodes(e){if(!this.ref)return!1;const t=this.ref.getObjectByName("GRP_RenderGeometry"),n=this.ref.getObjectByName("GRP_ProxyMesh");return e.map(s=>{if(t){const o=t.getObjectByName(s);o&&(o.visible=!1)}if(n){const o=n.getObjectByName(s);o&&(o.visible=!1)}}),!0}showNodes(e){if(!this.ref)return!1;const t=this.ref.getObjectByName("GRP_RenderGeometry"),n=this.ref.getObjectByName("GRP_ProxyMesh");return e.map(s=>{if(t){const o=t.getObjectByName(s);o&&(o.visible=!0)}if(n){const o=n.getObjectByName(s);o&&(o.visible=!0)}}),!0}canConnectToPlugType(e){let t=!1;return this._plugs.map(n=>{n.connectsToPlugTypes.map(s=>{s==e&&(t=!0)})}),t}isConnectedToSkuID(e){let t=!1;return this._plugs.map(n=>{if(n.isOpen||t===!0)return;let s=n.attachedPlug;!s&&n.attachedPlugGUID&&(s=attachmentStore$1.getState().attachmentSystem.currentStructure.getPlugByGUID(n.attachedPlugGUID)),s.node.skuID==e&&(t=!0)}),t}get isConnectedToRoot(){return this.isConnectedToSkuID("Root")}swapRoot(){if(!this.canSwapRoot)return;const t=attachmentStore$1.getState().attachmentSystem.currentStructure,n=this.whichNodesAreAttachedToUs();let s=null;n.map(T=>{T.followsParent===!1&&(s=T)});const o=s.detachNodeFromReceiver();let v=null;this._plugs.map(T=>{T.isOpen||T.attachedPlug.node.skuID=="Root"&&(v=T.attachedPlug)});const A=this.detachNodeFromReceiver();let b=null;return s.plugs.map(T=>{T.connectsToPlugTypes.includes("root")&&(b=T)}),t.connectPlugs({incomingPlug:b,receiverPlug:v}),{neighbourDetachedPlugs:o,rootDetachedPlugs:A,neighbourNode:s}}get canSwapRoot(){if(sceneStore.getState().sceneSettings.swappableRoot===!1)return!1;let e=!1;if(this.isConnectedToRoot&&!this._isEndNode){const n=this.whichNodesAreAttachedToUs();let s=0,o=null;n.map(v=>{v.followsParent===!1&&(s++,o=v)}),s==1?o.canConnectToPlugType("root")&&(e=!0):s>0&&(e=!1)}return e}get canDrag(){let e=!0;return this._isEndNode||(this.whichNodesAreAttachedToUs().map(n=>{n.followsParent===!1&&(e=!1)}),e||(e=this.canSwapRoot)),e}get followsParent(){return this._followsParent}set followsParent(e){this._followsParent=e}get currentVariant(){return this.#t==="default"?productDataStore$1.getState().actions.getProductDataById(this._skuID).lookDetails.default.id:this.#t}get price(){return this._price}set price(e){this._price=e}updatePricing(){this._price=this.#a()}#a(){let t=productDataStore$1.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.price;return t||(t=0),t}set currentVariant(e){this.#t=e,this._price=this.#a()}get overrideVariant(){return this._overrideVariant}set overrideVariant(e){this._overrideVariant=e,this.#t=this._overrideVariant,this._price=this.#a()}get guid(){return this._guid}get skuID(){return this._skuID}set skuID(e){this._skuID=e}get plugs(){return this._plugs}get ref(){return this._ref}set ref(e){this._ref=e}get modelData(){return this._modelData}set modelData(e){this._modelData=e;let t=new CustomEvent(this._guid+":modelLoaded",{bubbles:!0,cancelable:!1,composed:!0});const n=attachmentStore$1.getState().attachmentSystem;n.globalGeometryVariants&&Object.keys(n.globalGeometryVariants).map(s=>{this.updateGeometryVariant(s,n.globalGeometryVariants[s])}),t.data={},CORE_API.coreWCRef?CORE_API.coreWCRef.dispatchEvent(t):LOGGER.warn({title:"core web component not found!"})}get isEndNode(){return this._isEndNode}set isEndNode(e){this._isEndNode=e}get categoryID(){return this._categoryID}get transform(){return this._transform}set transform(e){this._transform=e}setModelVisibility(e){e?this._ref?.scale.set(1,1,1):this._ref.scale.set(0,0,0)}checkIfEndNode(){let e=!0;for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&(e=!1);this.isEndNode=e}whichNodesAreAttachedToUs(){var e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&e.push(this._plugs[t].attachedPlug.node);return e}whichPlugsAreAttachedToUs(){var e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&e.push({receiverPlug:this._plugs[t],incomingPlug:this._plugs[t].attachedPlug});return e}whichNodeAreWeAttachedTo(){var e=null;for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&(e=this._plugs[t].attachedPlug.node);return e}isReplaceableWithSkuId(e){const n=productDataStore$1.getState().productData[e]?.plugs;let s=0;if(!n)return!1;for(let o=0;o<this._plugs.length;o++)for(let v=0;v<n.length;v++)this._plugs[o].name==n[v].name&&s++;return s==this._plugs.length}whichPlugAreWeAttachedUsing(){for(let e=0;e<this._plugs.length;e++)if(!this._plugs[e].isOpen&&this._plugs[e].attachedPlug.isReceiverPlug)return this._plugs[e]}whichPlugAreWeAttachedTo(){for(let e=0;e<this._plugs.length;e++)if(!this._plugs[e].isOpen&&this._plugs[e].attachedPlug.isReceiverPlug)return this._plugs[e].attachedPlug}getPlugWhichCanConnectToType(e){for(const t of this._plugs)if(t.connectsToPlugTypes.includes(e))return t;return null}getOpenPlugsWeCanAttachFrom(){let e=[];if(this.whichNodeAreWeAttachedTo())return e;for(let t=0;t<this._plugs.length;t++)this.plugs[t].isOpen&&this.plugs[t].connectsToPlugTypes.length>0&&e.push(this._plugs[t]);return e}getOpenPlugsFromNode(){let e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isOpen&&this._plugs[t].acceptedPlugTypes.length>0&&e.push(this._plugs[t]);return e}generatePlugsForNode(e){this._plugs=[];let t=productDataStore$1.getState().productData[e]?.plugs;if(t)for(var n=0;n<t.length;n++){const s=new Plug(t[n],this);this._plugs.push(s)}}generatePlugsWithData(e,t){let n=productDataStore$1.getState().productData[e]?.plugs;if(n)for(var s=0;s<n.length;s++){const o=new Plug(n[s],this,t[n[s].name]);this._plugs.push(o)}}detachNodeFromReceiver(){for(var e=0;e<this.plugs.length;e++)if(!this.plugs[e].isOpen&&this.plugs[e].attachedPlug.isReceiverPlug){const t={incomingPlug:this.plugs[e],receiverPlug:this.plugs[e].attachedPlug};return this.plugs[e].attachedPlug.openPlug(),this.plugs[e].openPlug(),t}}detachNodeCompletely(){for(var e=0;e<this._plugs.length;e++)this._plugs[e].isOpen||(this._plugs[e].attachedPlug.openPlug(),this._plugs[e].openPlug())}getPlugByName(e){for(var t=0;t<this._plugs.length;t++)if(this._plugs[t].name==e)return this._plugs[t];return null}getPlugByGUID(e){for(var t=0;t<this._plugs.length;t++)if(this._plugs[t].guid==e)return this._plugs[t];return null}removeNode(){for(var e=0;e<this._plugs.length;e++)this._plugs[e].isOpen||(this._plugs[e].attachedPlug.isReceiverPlug?this._plugs[e].attachedPlug.openPlug():itemStore.getState().actions.addToRemoveItems(this._plugs[e].attachedPlug.node.guid))}};class Structure{#t=!1;constructor(e=null,t,n){if(this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:e}),e){LOGGER.info({title:"PRELOAD Length-----------------:"+e.length});for(var s=0;s<e.length;s++){LOGGER.info({title:"FOUND PRELOAD-----------------"});let o=e[s].skuID,v=new Node$1(o,e[s],t,n);o=="Root"&&(this._rootNode=v),this._nodes.push(v)}}else{const o=new Node$1("Root",null,t,n);this._rootNode=o,this._nodes.push(o)}itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1),this._boundingBoxLeeway=sceneStore.getState().sceneSettings.boundingBoxLeeway,this.setupCustomLogic()}async customLogic(){if(!["neighbor-bluff","neighbor-terra"].includes(CORE_API.projectId))return;const e={OM:{plugsToConsider:["OM_L_Plug"],geometryNodes:["OM_Legs_root"],rootPlug:"om_root"},ILTable:{plugsToConsider:["iltable_l_plug"],geometryNodes:["IL_Legs_root"],rootPlug:"il_root"}},t=Object.keys(e);for(const n of this._nodes){if(!t.includes(n.skuID))continue;let s=0;for(const o of n.plugs)if(o.name!==e[n.skuID].rootPlug&&(!e[n.skuID].plugsToConsider.includes(o.name)&&o.isOpen===!1&&s++,e[n.skuID].plugsToConsider.includes(o.name)&&o.isOpen===!1)){s=0;break}s>=1?n.hideNodes(e[n.skuID].geometryNodes)||CORE_API.coreWCRef.addEventListener(n.guid+":modelLoaded",()=>{n.hideNodes(e[n.skuID].geometryNodes)},{once:!0}):n.showNodes(e[n.skuID].geometryNodes)||CORE_API.coreWCRef.addEventListener(n.guid+":modelLoaded",()=>{n.showNodes(e[n.skuID].geometryNodes)},{once:!0})}}setupCustomLogic(){CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.customLogic()})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let e=0;e<this._nodes.length;e++)this._nodes[e].updatePricing()}getCurrentItemsInReplaceableCategory(){let e={};for(const t of this._nodes)t.replace&&(e[t.categoryID]=t.skuID);return e}recalculateStructureFromNode(e){for(let t=0;t<e.plugs.length;t++)if(!e.plugs[t].isOpen&&e.plugs[t].isReceiverPlug){const n=e.plugs[t].attachedPlug.node,s={receiverPlug:e.plugs[t],incomingPlug:e.plugs[t].attachedPlug};if(s){const o=this.findItemTransform(s);o&&(n.ref.position.set(o.position.x,o.position.y,o.position.z),n.ref.setRotationFromQuaternion(o.rotation),n.transform={position:o.position,rotation:o.rotation})}this.recalculateStructureFromNode(n)}}rotateNode(e){const t=this.getNodeByGUID(e);let n=null,s=null;for(let A=0;A<t.plugs.length;A++)if(!s&&!t.plugs[A].isOpen&&t.plugs[A].attachedPlug.isReceiverPlug){const b=t.plugs[A].attachedPlug.acceptedPlugTypes;s=t.plugs[A].attachedPlug;let T=[];for(let ee=A+1;ee<t.plugs.length;ee++)T.push(t.plugs[ee]);for(let ee=0;ee<A;ee++)T.push(t.plugs[ee]);for(let ee=0;ee<T.length;ee++)for(let re=0;re<T[ee].connectsToPlugTypes.length;re++)b.includes(T[ee].connectsToPlugTypes[re])&&(n=T[ee])}if(!n)return;t.detachNodeFromReceiver();const{position:o,rotation:v}=this.findItemTransform({receiverPlug:s,incomingPlug:n});t.ref.position.set(o.x,o.y,o.z),t.ref.setRotationFromQuaternion(v),t.transform={position:t.ref.position,rotation:v},this.connectPlugs({receiverPlug:s,incomingPlug:n}),this.recalculateStructureFromNode(t)}async load(e){this.resolvePlugConnections(e),await this.respawnItems()}materialOverrideExists(){let e=!1;return this.nodes.map(t=>{if(t.overrideVariant)return e=!0,!0}),e}findGhostTransformForReplacement(e,t){const n=attachmentStore$1.getState().attachmentSystem,s=t.whichPlugAreWeAttachedTo(),o=t.whichPlugAreWeAttachedUsing(),A=new Node$1(e,null,n.globalVariants,n.globalGeometryVariants).getPlugByName(o.name);if(!A)return{transforms:null,connectablePlugs:null};const b={incomingPlug:A,receiverPlug:s};let T=[],ee=this.findItemTransform(b);if(!ee)return{transforms:T,connectablePlugs:b};let{position:re,rotation:ie}=ee;return re&&ie&&T.push({position:re,rotation:ie,incomingPlugName:b.incomingPlug.name,receiverPlugName:b.receiverPlug.name,incomingPlugGUID:b.incomingPlug.guid,receiverPlugGUID:b.receiverPlug.guid}),{transforms:T,connectablePlugs:b}}findGhostTransforms(e,t){const n=this.getOpenPlugs();if(n.length<=0)return{transforms:[]};const s=attachmentStore$1.getState().attachmentSystem,o=productDataStore$1.getState().productData,v=new Node$1(e,null,s.globalVariants,s.globalGeometryVariants),A=this.getConnectablePlugs(v,n);let b=[];if(A.length<=0)return{transforms:[]};let T=[];for(let re=0;re<A.length;re++){let ie=this.findItemTransform(A[re]);if(!ie)continue;let{position:se,rotation:le}=ie;if(se&&le){let pe=t;Array.isArray(t)===!0&&(pe=!1),o[e].hasOwnProperty("ignoreSpawningCollision")&&(pe=o[e].ignoreSpawningCollision),(pe?!1:this.isColliding(v.skuID,ie,A[re].receiverPlug,t))||(T.push({position:se,rotation:le,incomingPlugName:A[re].incomingPlug.name,receiverPlugName:A[re].receiverPlug.name,incomingPlugGUID:A[re].incomingPlug.guid,receiverPlugGUID:A[re].receiverPlug.guid}),b.push(A[re]))}}let ee=[];for(let re=0;re<T.length;re++)ee.push(v);return{transforms:T,newNodes:ee,connectablePlugs:b}}resolvePlugConnections(e){for(let t=0;t<e.length;t++)Object.keys(e[t].plugs).map(n=>{let s=e[t].plugs[n].guid,o=this.getPlugInNodesByGUID(s);if(!o||o.attachedPlug)return;let v=e[t].plugs[n].attachedPlugGUID,A=this.getPlugInNodesByGUID(v);A&&(A.attachedPlug||(o.attachPlug(A,e[t].plugs[n].isReceiverPlug),A.attachPlug(o,!e[t].plugs[n].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let e=[this.rootNode];for(let t=0;t<e.length;t++){let s=e[t].whichPlugsAreAttachedToUs();for(let o=0;o<s.length;o++){let v=this.findItemTransformForPreload(s[o],s[o].receiverPlug.node.transform);v?await itemStore.getState().actions.addItemWithTransform(v,s[o].incomingPlug.node.skuID,s[o].incomingPlug.node.guid):LOGGER.warn({title:"Problem finding plug transform! "+s[o].name}),s[o].incomingPlug.node.transform=v,e.push(s[o].incomingPlug.node)}}CORE_API.fireEvent(CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.checkHotspotHealth()}getPlugInNodesByGUID(e){for(let t=0;t<this._nodes.length;t++){let n=this._nodes[t].getPlugByGUID(e);if(n)return n}return null}export(){let e=[];for(let t=0;t<this._nodes.length;t++){let n=this._nodes[t].export();n&&e.push(n)}return e}async clear(){return new Promise(async(e,t)=>{!this._rootNode&&this._rootNode.isEndNode&&e(!0);let n=this._rootNode.whichNodeAreWeAttachedTo();this.#t=!0,CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Scene_Cleared,s=>e(s.data),{once:!0}),n?CORE_API.removeItemByGUID(n.guid,!0):(await wait(500),e(!0))})}getNodeByGUID(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e)return this._nodes[t];return null}getPlugByGUID(e){for(const t of this._nodes){const n=t.getPlugByGUID(e);if(n)return n}return null}findItemTransformForPreload(e,t){let{receiverPlug:n,incomingPlug:s}=e,o=n,v=s;if(o.node.skuID=="Root")return this.findItemTransformRoot(e);let A=null,b=null,T=new Object3D,ee=assetStore.getState().assets.items[o.node.skuID].proxy.data.scene.clone();T.add(ee);let{position:re,rotation:ie}=t;if(ee.position.set(re.x,re.y,re.z),ee.setRotationFromQuaternion(ie),b=ee,!b||(A=b.getObjectByName(o.name),!A))return;let se=new Vector3(0,0,0);A.getWorldPosition(se);let le=new Quaternion().identity();A.getWorldQuaternion(le);let pe=new Object3D;A.add(pe);let de=assetStore.getState().assets.items[v.node.skuID].proxy.data.scene.clone();de.position.set(se.x,se.y,se.z),de.applyQuaternion(le);let fe=new Vector3;fe.copy(ee.up).applyQuaternion(b.quaternion);let _e=new Vector3;_e.copy(de.up).applyQuaternion(le),_e.negate();let ve=new Quaternion().setFromUnitVectors(fe,_e);fe.round(),_e.round();let xe=fe.dot(_e);xe!==1&&xe!==-1&&de.applyQuaternion(ve);let De=de.getObjectByName(v.name),Le=new Quaternion().identity();De.getWorldQuaternion(Le);let Ue=new Vector3(0,1,0);Ue.applyQuaternion(Le);let Ge=new Vector3(0,1,0);Ge.applyQuaternion(le),Ge.negate();let Fe=new Quaternion().setFromUnitVectors(Ue,Ge);if(Ue.round(),Ge.round(),Ue.dot(Ge)!==-1)de.applyQuaternion(Fe);else{let Ur=new Vector3(0,1,0),lr=Ge.dot(Ur);if(lr!==1&&lr!==-1)de.rotateOnAxis(Ur,Math.PI);else{let hr=new Vector3(0,0,1),zn=Ge.dot(hr);if(zn!==1&&zn!==-1)de.rotateOnAxis(hr,Math.PI);else{let ar=new Vector3(1,0,0),Dr=Ge.dot(ar);Dr!==1&&Dr!==-1&&de.rotateOnAxis(ar,Math.PI)}}}let rn=de.getObjectByName(v.name),yn=new Vector3(rn.position.x,rn.position.y,rn.position.z);de.translateX(-yn.x),de.translateY(-yn.y),de.translateZ(-yn.z);let bt=new Vector3(0,0,0);de.getWorldPosition(bt);let sn=new Quaternion().identity();return de.getWorldQuaternion(sn),de=null,{position:bt,rotation:sn}}findItemTransformRoot(e){let{receiverPlug:t,incomingPlug:n}=e,s=n;const o=new Object3D;let v=o,A=new Vector3(0,0,0);v.getWorldPosition(A);let b=new Quaternion().identity(),T=new Object3D;T.position.set(0,0,0),o.add(T);let ee=assetStore.getState().assets.items[s.node.skuID].proxy.data.scene.clone();T.attach(ee),ee.translateX(A.x),ee.translateY(A.y),ee.translateZ(A.z);let re=ee.getObjectByName(s.name),ie=new Quaternion().identity();re.getWorldQuaternion(ie);const se=new Vector3(0,1,0);se.applyQuaternion(ie);const le=new Vector3(0,1,0);le.applyQuaternion(b);const pe=le.angleTo(se),de=new Vector3(0,0,0);de.crossVectors(le,se),de.round(),de.length()!==0&&ee.rotateOnAxis(de,pe);var fe=new Matrix4().extractRotation(ee.matrixWorld);let _e=new Vector3(re.position.x,re.position.y,re.position.z);_e.applyMatrix4(fe),ee.translateX(-_e.x),ee.translateY(-_e.y),ee.translateZ(-_e.z);let ve=new Vector3(0,0,0);ee.getWorldPosition(ve);let xe=new Quaternion().identity();return ee.getWorldQuaternion(xe),T.remove(ee),T=null,ee=null,{position:ve,rotation:xe}}findItemTransform(e){let{receiverPlug:t,incomingPlug:n}=e,s=t,o=n;if(s.node.skuID=="Root")return this.findItemTransformRoot(e);const v=s.node.transform;if(!v)return;const A=assetStore.getState().assets.items[s.node.skuID].proxy.data.scene.clone(),b=new Object3D;b.position.set(v.position.x,v.position.y,v.position.z),b.setRotationFromQuaternion(v.rotation),b.add(A);let T=b.getObjectByName(""+s.name);if(!T){LOGGER.error({title:"Plug: "+s.name+" doesn't exist in "+s.node.skuID});return}let ee=new Vector3(0,1,0);T.getWorldPosition(ee);let re=new Quaternion().identity();T.getWorldQuaternion(re);let ie=assetStore.getState().assets.items[o.node.skuID].proxy.data.scene.clone();ie.position.set(ee.x,ee.y,ee.z),ie.applyQuaternion(re);let se=new Vector3;se.copy(A.up).applyQuaternion(b.quaternion);let le=new Vector3;le.copy(ie.up).applyQuaternion(re),le.negate();let pe=new Quaternion().setFromUnitVectors(se,le);se.round(),le.round();let de=se.dot(le);de!==1&&de!==-1&&ie.applyQuaternion(pe);let fe=ie.getObjectByName(o.name);if(!fe){LOGGER.error({title:"Plug: "+o.name+" doesn't exist in "+o.node.skuID});return}let _e=new Quaternion().identity();fe.getWorldQuaternion(_e);let ve=new Vector3(0,1,0);ve.applyQuaternion(_e);let xe=new Vector3(0,1,0);xe.applyQuaternion(re),xe.negate();let De=new Quaternion().setFromUnitVectors(ve,xe);if(ve.round(),xe.round(),ve.dot(xe)!==-1)ie.applyQuaternion(De);else{let rn=new Vector3(0,1,0),yn=xe.dot(rn);if(yn!==1&&yn!==-1)ie.rotateOnAxis(rn,Math.PI);else{let bt=new Vector3(0,0,1),sn=xe.dot(bt);if(sn!==1&&sn!==-1)ie.rotateOnAxis(bt,Math.PI);else{let Ur=new Vector3(1,0,0),lr=xe.dot(Ur);lr!==1&&lr!==-1&&ie.rotateOnAxis(Ur,Math.PI)}}}let Ue=ie.getObjectByName(o.name),Ge=new Vector3(Ue.position.x,Ue.position.y,Ue.position.z);ie.translateX(-Ge.x),ie.translateY(-Ge.y),ie.translateZ(-Ge.z);let Fe=new Vector3(0,0,0);ie.getWorldPosition(Fe);let Ye=new Quaternion().identity();return ie.getWorldQuaternion(Ye),b.remove(A),ie=null,{position:Fe,rotation:Ye}}getSpawningRequirementForSkuID(e){let t=[];const n=productDataStore$1.getState().productData,s=n[e];if(!s)return t;const o=[];return s.plugs.map(v=>{v.connectsToPlugTypes.map(A=>{o.push(A)})}),Object.keys(n).map(v=>{for(let A=0;A<n[v].plugs.length;A++){const b=n[v].plugs[A].acceptedPlugTypes;for(let T=0;T<b.length;T++)o.map(ee=>{ee==b[T]&&!t.includes(v)&&t.push(v)})}}),t}getConnectablePlugs(e,t){let n=[],s=e.getOpenPlugsWeCanAttachFrom();for(let o=0;o<s.length;o++)for(let v=0;v<t.length;v++){let A=!1;for(let T=0;T<n.length;T++)if(n[T].receiverPlug.guid==t[v].guid){A=!0;break}if(A)continue;s[o].canAttachToPlug(t[v])&&n.push({incomingPlug:s[o],receiverPlug:t[v]})}return n}getOpenPlugs(){let e=[];return this._nodes.map(t=>{let n=t.getOpenPlugsFromNode();e=e.concat(n)}),e}checkCollisionforGUID(e){if(sceneStore.getState().sceneSettings.disableCollider)return!1;const t=itemStore.getState().itemsSpawned,n=productDataStore$1.getState().productData;if(!t[e])return!1;const o=this.getNodeByGUID(e);if(!o||!o.ref||n[o.skuID].disableCollider)return!1;const v={position:o.ref.position,rotation:o.ref.rotation},A=o.whichPlugAreWeAttachedTo();return A==null?!1:this.isColliding(o.skuID,v,A,[])}isColliding(e,{position:t,rotation:n},s,o=[]){const v=assetStore.getState().assets.items[e].proxy.data.scene,A=productDataStore$1.getState().productData;if(!v)return!1;let b=v.clone();b.position.set(t.x,t.y,t.z),b.setRotationFromQuaternion(n);let T=new Box3().setFromObject(b);var ee=new Vector3;T.getCenter(ee);let re=new Object3D;re.position.set(ee.x,ee.y,ee.z),re.attach(b),re.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),T=new Box3().setFromObject(re);const ie=[];if(this._nodes.forEach(le=>{s.node.guid!=le.guid&&(Array.isArray(o)===!0&&o.includes(le.guid)||le.ref&&((A[le.skuID].hasOwnProperty("disableCollider")?A[le.skuID].disableCollider:sceneStore.getState().sceneSettings.disableCollider)||ie.push(le.ref)))}),ie.length<=0)return!1;let se=!1;return ie.forEach(le=>{if(se)return;let pe=new Box3().setFromObject(le);if(T.intersectsBox(pe)){se=!0;return}}),re.clear(),b=null,re=null,T=null,se}boxOverlapPercent(e,t){if(e.containsBox(t)||t.containsBox(e))return 100;if(!(e.min.x<t.max.x||t.min.x<e.max.x))return 0;let n=new Vector3(0,0,0);e.getSize(n),n.x*n.y*n.z;let s=new Vector3(0,0,0);t.getSize(s),s.x*s.y*s.z}checkInsideOutCollision(e,t,n){let s=t.position.clone(),o=new Float32Array(n.attributes.position.array),v=o.length/3;for(let A=0;A<v;A++){let b=new Vector3(o[A*3],o[A*3+1],o[A*3+2]),T=b.add(t.position);T=b.applyQuaternion(t.quaternion);let ee=T.sub(t.position);const ie=new Raycaster(s,ee.clone().normalize()).intersectObjects(e),se=ie.length>0,le=ie[0].distance<ee.length();if(se&&le)return!0}return!1}addNode(e){this._nodes.push(e)}getFirstNodeByCategoryID(e){for(var t=0;t<this._nodes.length;t++)if(this._nodes[t]._categoryID==e)return this._nodes[t];return null}getNodesBySKUID(e){let t=[];for(var n=0;n<this._nodes.length;n++)this._nodes[n].skuID==e&&t.push(this._nodes[n]);return t}getNodesByCategoryID(e){let t=[];for(var n=0;n<this._nodes.length;n++)this._nodes[n]._categoryID==e&&t.push(this._nodes[n]);return t}connectPlugs({incomingPlug:e,receiverPlug:t}){e.attachPlug(t,!1),t.attachPlug(e,!0),attachmentStore$1.getState().actions.toggleStructureUpdated()}removeNodeByGUID(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e){this._nodes[t].removeNode(),this._nodes.splice(t,1);break}this._nodes.length==1&&this.#t&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Scene_Cleared,!0),attachmentStore$1.getState().actions.updateFittingSkuIds(),attachmentStore$1.getState().actions.toggleStructureUpdated()}removeNodeFromStructure(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e.guid){this._nodes.splice(t,1);break}attachmentStore$1.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(){this._globalVariants={},this._globalGeometryVariants={},productDataStore$1.getState().categoryData.geometryVariants.map(e=>{this._globalGeometryVariants[e.id]=e.defaultVariant}),productDataStore$1.getState().categoryData.color.map(e=>{this._globalVariants[e.id]=e.defaultLook}),this._currentStructure=new Structure(null,this._globalVariants,this._globalGeometryVariants);for(const[e,t]of Object.entries(this._globalVariants))this.switchGlobalVariant(e,t);for(const[e,t]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(e,t)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(e,t){let n;return n=productDataStore$1.getState()?.productData[e]?.lookDetails[t],n?.clientProductId?n?.clientProductId:""}getCartItems(){let e=[];const t=inventoryStore.getState().inventoryData;this.currentStructure.nodes.map(o=>{if(o.skuID=="Root"||o.ignoreInCart===!0)return;let v=!1;if(e.map(T=>{const ee=t[T.skuID];if(T.skuID==o.skuID&&T.currentVariant==o.currentVariant){T.count++,T.countAvailable=ee[o.currentVariant].countAvailable,T.countUnavailable=ee[o.currentVariant].countUnavailable,T.price=o.price*T.count,v=!0;return}}),v===!0)return;let A={};A.skuID=o.skuID,A.currentVariant=o.currentVariant,A.clientProductId=this.getClientProductId(A.skuID,A.currentVariant),A.count=1;const b=t[A.skuID];A.price=o.price,A.countAvailable=b[o.currentVariant].countAvailable,A.countUnavailable=b[o.currentVariant].countUnavailable,e.push(A)});let n=0;for(const o of e)n=n+o.price;return{cartItems:e,details:{total:n.toFixed(2)}}}getFittingSKUIDs(){const e=productDataStore$1.getState().productData;if(!this.currentStructure)return;let t=this.currentStructure.nodes,n=[],s=[],o=[],v=[];if(t.map(b=>{v.push(b.skuID),b.plugs.map(T=>{if(!T.isOpen){T.attachedPlug.node.replace&&T.acceptedPlugTypes.map(ee=>{s.includes(ee)||s.push(ee)});return}T.acceptedPlugTypes.map(ee=>{n.includes(ee)||n.push(ee)})})}),n.length<=0&&s.length<=0)return[];Object.keys(e).map(b=>{!e[b].plugs||o.includes(b)||e[b].plugs.map(T=>{o.includes(b)||T.connectsToPlugTypes.map(ee=>{if(!o.includes(b)){if(s.includes(ee)){if(!v.includes(b)){let re=!1,ie=this.currentStructure.getFirstNodeByCategoryID(e[b].categoryID),se=!1;ie?.plugs.map(le=>{!le.isOpen&&le.isReceiverPlug&&(se=!0,e[b].plugs.map(pe=>{pe.name==le.name&&le.attachedPlug.connectsToPlugTypes.map(de=>{pe.acceptedPlugTypes.includes(de)&&(re=!0)})}))}),(re||!se)&&o.push(b)}}else if(n.includes(ee)){const re=this.currentStructure.getFirstNodeByCategoryID(e[b].categoryID);if(re&&re.replace)return;o.push(b)}}})})});let A=[];return o.map(b=>{if(A.includes(b))return;if(e[b].replace){A.push(b);return}const{transforms:T,newNodes:ee,connectablePlugs:re}=this.currentStructure.findGhostTransforms(b,sceneStore.getState().sceneSettings.ignoreSpawningCollision);T.length>0&&A.push(b)}),A.map(b=>{e[b].replace}),A}async removeAllVariantOverrides(){let e=this._currentStructure.nodes,t=productDataStore$1.getState().productData,n=itemStore.getState().itemsSpawned;await e.map(async s=>{if(!s.overrideVariant||(s.overrideVariant=null,!t[s.skuID].looks))return;let o=null;Object.keys(this._globalVariants).map(v=>{t[s.skuID].looks.includes(this._globalVariants[v])&&o==null&&(o=this._globalVariants[v])}),o&&await itemStore.getState().actions.switchToVariant(n[s.guid].itemData,o)}),CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1)}async switchGlobalGeometryVariant(e,t){const s=productDataStore$1.getState().categoryData.geometryVariants;let o=null;if(s.map(ie=>{ie.id==e&&(o=ie)}),!o)return;const v=o.productsInCategory,b=o.variants[t].productsToSwitch,T=itemStore.getState().itemsSpawned;let ee=productDataStore$1.getState().categoryData;b.map(ie=>{v.map(se=>{let le=!1;se.products.map(pe=>{ie==pe&&(le=!0)}),le&&ee.build.map(pe=>{se.products.map(de=>{pe.skus.map((fe,_e)=>{pe.skus[_e]==de&&(pe.skus[_e]=ie)})})})})}),this._currentStructure.nodes.map(ie=>{v.map(se=>{se.products.map(le=>{ie.skuID==le&&ie.ref!==null&&se.products.map(pe=>{b.map(de=>{if(de==pe){const fe=productDataStore$1.getState().actions.getProductDataById(de);ie.hideNodes(fe.geometriesToHide),ie.showNodes(fe.geometriesToShow),ie.skuID=de;const _e=T[ie.guid];_e&&_e.itemData&&Object.keys(fe).map(ve=>{_e.itemData[ve]=fe[ve]}),ie.resetInStock(),ie.updatePricing()}})})})})}),this._globalGeometryVariants[e]=t,hotspotStore$1.getState().actions.checkHotspotHealth(),inventoryStore.getState().actions.refreshInventory(T),productDataStore$1.setState({categoryData:ee}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CategoryData_Updated,ee),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const re=this.getCartItems();re&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,re)}async switchGlobalVariant(e,t){this._globalVariants[e]=t;const n=itemStore.getState().actions;let s=itemStore.getState().itemsSpawned;for(let b=0;b<Object.keys(s).length;b++){let T=s[Object.keys(s)[b]];if(T.itemData.looks&&T.itemData.looks.includes(t)){let ee=this._currentStructure.getNodeByGUID(T.itemData.guid);ee&&!ee.overrideVariant&&await n.switchToVariant(T.itemData,t)}}const o=productDataStore$1.getState().lookData;lightStore.getState().actions.processLookEnvMapOverride(t);const v=e;Object.keys(s).length>0&&CORE_API.alert({alertMsg:v.charAt(0).toUpperCase()+v.slice(1)+" was successfully switched to "+o[t].label+".",alertTime:3e3,alertType:"success",alertLabel:`${v} Changed`,alertId:"materialVariantChanged"}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),itemStore.setState({variantChangeAlert:!itemStore.getState().variantChangeAlert});const A=this.getCartItems();A&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,A)}async#t(e){if(!e)return;LOGGER.info({title:"Structure to load",details:e}),delete this._currentStructure,this._globalVariants={...e.globalVariants},this._globalGeometryVariants=e.globalGeometryVariants?{...e.globalGeometryVariants}:{};const t=[...e.structure];this._currentStructure=new Structure(t,this._globalVariants,this._globalGeometryVariants);for(const[n,s]of Object.entries(this._globalVariants))this.switchGlobalVariant(n,s);for(const[n,s]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(n,s);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(t),LOGGER.info({title:"Structure Loaded."})}async loadStructure(e){e&&(CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),sceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(e),sceneStore.getState().preconfigurationLoaded?CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide):sceneStore.setState({preconfigurationLoaded:!0}),sceneStore.setState({configurationLoaded:!0}),attachmentStore$1.getState().actions.toggleStructureUpdated())}export(){return{structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),this._currentStructure.clear(),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),itemStore.getState().selectedItemData&&itemStore.getState().actions.deselectItem(),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear();const e=attachmentStore$1.getState().defaultConfig;await this.#t(e),attachmentStore$1.getState().actions.toggleStructureUpdated(),sceneStore.setState({configurationLoaded:!0}),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide)}}const attachmentStore=create$3((a,e)=>({attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async()=>{const{actions:t,defaultConfig:n}=e(),s=await new AttachmentSystem;a({attachmentSystem:s}),t.updateFittingSkuIds(),t.toggleStructureUpdated()},loadSavedStructureFromConfigID:async t=>{const n=await getJSONFromEndpoint(FETCH_CONFIG_ENDPOINT+t);return n.success===!1?null:n.data},loadDefaultStructure:async()=>{const{actions:t,defaultConfig:n,attachmentSystem:s}=e();await t.loadStructure(n)},updateFittingSkuIds:()=>{const t=attachmentStore.getState().attachmentSystem.getFittingSKUIDs();t&&(itemStore.setState({fittingSkuIds:[...t]}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:t}))},toggleStructureUpdated:()=>{const{attachmentSystem:t}=e();a(s=>({structureUpdated:!s.structureUpdated})),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,t.currentStructure.getCurrentItemsInReplaceableCategory());const n=t.getCartItems();n&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,n)},loadStructure:async t=>{const{attachmentSystem:n}=e();n&&sceneStore.getState().configurationLoaded!==!1&&await n.loadStructure(t)},export:()=>{const{attachmentSystem:t}=e();if(t)return t.export()}}})),attachmentStore$1=attachmentStore,productDataStore=create$3((a,e)=>({productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentPricingInfo:()=>{const{productData:t}=e();let n={};return Object.keys(t).map(s=>{if(s.toLowerCase()==="root")return;let o=t[s].lookDetails,v={};Object.keys(o).map(A=>{A!="default"&&(v[A]=o[A].price)}),n[s]=v}),n},updatePricingForAllProducts:t=>{const{actions:n}=e();Object.keys(t).map(s=>{let o=t[s];Object.keys(o).map(v=>{n.updatePricingForProduct(s,v,o[v])})})},updatePricingForProduct:(t,n,s)=>{const{productData:o}=e();let v=o[t];if(!v||!v.lookDetails)return;let A=v.lookDetails[n];if(!A)return;A.price=s,attachmentStore$1.getState().attachmentSystem.currentStructure.getNodesBySKUID(t).map(ee=>ee.updatePricing())},setProductData:t=>{let n={};t&&Object.keys(t).map(s=>{const o=t[s];if(o.skuID=s,o.skuID.toLowerCase()==="root"){o.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},o.defaultVariant="default";return}if(o?.lookDetails){const v=o.lookDetails;let A=Object.keys(o.lookDetails);if(A.includes("default")){const T=A.indexOf("default");A.splice(T,1)}o.looks=A,Object.keys(o.lookDetails).map(T=>{let ee=o.lookDetails[T];ee.inventory===void 0&&(ee.inventory=DEFAULT_INVENTORY),ee.price===void 0&&(ee.price=DEFAULT_PRODUCT_PRICE),n[s]={...n[s],[T]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let b=o?.defaultVariant;b||(LOGGER.warn({title:`No defaultVariant set for ${o.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),b=Object.keys(o.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+b})),A.includes(b)?(o.lookDetails.default=v[b],o.lookDetails.default.id=b):(LOGGER.error({title:`Default look [ ${b} ] doesn't exist for: ${s}. Please make sure to select a default variant in Input Data for this project`}),o.lookDetails.default=null)}}),LOGGER.info("PRODUCT DATA: ",t),inventoryStore.setState({inventoryData:n}),a({productData:t})},setCategoryData:t=>{const{productData:n}=e();t.geometryVariants!==void 0&&t.geometryVariants.map(s=>{s.defaultVariant===void 0&&Object.keys(s.variants).length>0&&(s.defaultVariant=Object.keys(s.variants)[0])}),t.color!==void 0&&t.color.map(s=>{(s.defaultLook===void 0&&s.looks.length>0||!s.looks.includes(s.defaultLook))&&(s.defaultLook=s.looks[0])}),a({categoryData:t}),t.build!==void 0&&t.build.map(s=>{s.skus.map(o=>{n[o].categoryID=s.categoryID,n[o].categoryLabel=s.label,n[o].swappable=s.swappable?s.swappable:!1,n[o].replace=s.replace})})},getProductDataById:t=>{const{productData:n}=e();let s=null;return n[t]&&(s=n[t]),s},setLookData:t=>a({lookData:t}),setHotspotsData:t=>{const{categoryData:n,productData:s}=e();n.geometryVariants&&Object.keys(t).map(o=>{t[o].map(v=>{v.geometryVariantID&&n.geometryVariants.map(A=>{Object.keys(A.variants).map(b=>{v.geometryVariantID==b&&A.productsInCategory.map(T=>{let ee=null;T.products.map(re=>{t.hasOwnProperty(re)&&(ee=t[re])}),T.products.map(re=>{t.hasOwnProperty(re)||(t[re]=ee)})})})})})}),a({hotspotsData:t})},setEndpoints:t=>{a({endpoints:t}),setGlobalEndpoints(t)},setAssetsData:t=>a({assetsData:t})}})),productDataStore$1=productDataStore,UtilityMenu=({handleShareButtonTrigger:a,handleSaveButtonTrigger:e,handleRestartButtonClick:t,handleShowHotspots:n,handleDimensionClick:s,handleInstructionButtonClick:o,utilityMenuVisible:v,hotspotsVisibility:A,viewInYourSpaceMenuBtnVisible:b,restartMenuBtnVisible:T,saveMenuBtnVisible:ee,hotspotsMenuBtnVisible:re,instructionsMenuBtnVisible:ie,dimensionsMenuBtnVisible:se,shareMenuBtnVisible:le,dimensionsVisible:pe,position:de,CORE_API:fe})=>{const[_e,ve]=reactExports.useState("bottom"),xe=productDataStore$1(Le=>Le.assetsData),De={ar:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/AR.svg",restart:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Restart.svg",save:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/save.svg",share:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Share.svg",dimensions:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Ruler.svg",hotspots:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Eye.svg",instructions:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Info.svg"};return reactExports.useEffect(()=>{switch(de){case"top":ve("top");break;case"bottom":ve("bottom");break;case"left":ve("left");break;case"right":ve("right");break}return()=>{}},[de]),jsxDevRuntimeExports.jsxDEV("div",{className:"shellCanvasContainerParent",id:_e,children:jsxDevRuntimeExports.jsxDEV("div",{className:(v&&(le||b||T||se||re||ie))==!0?"shellCanvasContainer":"shellCanvasContainer shellCanvasContainerInactive",children:[b&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{fe.viewInYourSpace()},buttonLabel:"AR",hoverLabel:"View in Your Space",icon:xe?.icons?.utilityMenu?.viewInYourSpace?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.viewInYourSpace):De.ar},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:81,columnNumber:11},globalThis),T&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{t()},buttonLabel:"Restart",hoverLabel:"Restart",icon:xe?.icons?.utilityMenu?.restart?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.restart):De.restart},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:98,columnNumber:11},globalThis),ee&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{e()},buttonLabel:"Save",hoverLabel:"Save",icon:xe?.icons?.utilityMenu?.save?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.save):De.save},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:115,columnNumber:11},globalThis),le&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{a()},buttonLabel:"Share",hoverLabel:"Share",icon:xe?.icons?.utilityMenu?.share?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.share):De.share},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:132,columnNumber:11},globalThis),se&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{s()},buttonLabel:"Size",hoverLabel:"Size",icon:xe?.icons?.utilityMenu?.dimensions?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.dimensions):De.dimensions,activeCondition:pe},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:149,columnNumber:11},globalThis),re&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{n()},buttonLabel:"Hotspots",hoverLabel:"Hotspots",icon:xe?.icons?.utilityMenu?.hotspots?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.hotspots):De.hotspots,activeCondition:A},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:168,columnNumber:11},globalThis),ie&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{o()},buttonLabel:"Instructions",hoverLabel:"Instructions",icon:xe?.icons?.utilityMenu?.instructions?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.instructions):De.instructions},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:187,columnNumber:11},globalThis)]},void 0,!0,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:67,columnNumber:7},globalThis)},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:66,columnNumber:5},globalThis)};var propTypes$5={exports:{}},reactIs={exports:{}},reactIs_development={};/** @license React v16.13.1
8919
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([v]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const v=o.data;switch(v.type){case"decode":s._callbacks[v.id].resolve(v);break;case"error":s._callbacks[v.id].reject(v);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+v.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function DRACOWorker(){let a,e;onmessage=function(v){const A=v.data;switch(A.type){case"init":a=A.decoderConfig,e=new Promise(function(ee){a.onModuleLoaded=function(re){ee({draco:re})},DracoDecoderModule(a)});break;case"decode":const b=A.buffer,T=A.taskConfig;e.then(ee=>{const re=ee.draco,ie=new re.Decoder,se=new re.DecoderBuffer;se.Init(new Int8Array(b),b.byteLength);try{const le=t(re,ie,se,T),pe=le.attributes.map(de=>de.array.buffer);le.index&&pe.push(le.index.array.buffer),self.postMessage({type:"decode",id:A.id,geometry:le},pe)}catch(le){console.error(le),self.postMessage({type:"error",id:A.id,error:le.message})}finally{re.destroy(se),re.destroy(ie)}});break}};function t(v,A,b,T){const ee=T.attributeIDs,re=T.attributeTypes;let ie,se;const le=A.GetEncodedGeometryType(b);if(le===v.TRIANGULAR_MESH)ie=new v.Mesh,se=A.DecodeBufferToMesh(b,ie);else if(le===v.POINT_CLOUD)ie=new v.PointCloud,se=A.DecodeBufferToPointCloud(b,ie);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!se.ok()||ie.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+se.error_msg());const pe={index:null,attributes:[]};for(const de in ee){const fe=self[re[de]];let _e,ve;if(T.useUniqueIDs)ve=ee[de],_e=A.GetAttributeByUniqueId(ie,ve);else{if(ve=A.GetAttributeId(ie,v[ee[de]]),ve===-1)continue;_e=A.GetAttribute(ie,ve)}pe.attributes.push(s(v,A,ie,de,fe,_e))}return le===v.TRIANGULAR_MESH&&(pe.index=n(v,A,ie)),v.destroy(ie),pe}function n(v,A,b){const ee=b.num_faces()*3,re=ee*4,ie=v._malloc(re);A.GetTrianglesUInt32Array(b,re,ie);const se=new Uint32Array(v.HEAPF32.buffer,ie,ee).slice();return v._free(ie),{array:se,itemSize:1}}function s(v,A,b,T,ee,re){const ie=re.num_components(),le=b.num_points()*ie,pe=le*ee.BYTES_PER_ELEMENT,de=o(v,ee),fe=v._malloc(pe);A.GetAttributeDataArrayForAllPoints(b,re,de,pe,fe);const _e=new ee(v.HEAPF32.buffer,fe,le).slice();return v._free(fe),{name:T,array:_e,itemSize:ie}}function o(v,A){switch(A){case Float32Array:return v.DT_FLOAT32;case Int8Array:return v.DT_INT8;case Int16Array:return v.DT_INT16;case Int32Array:return v.DT_INT32;case Uint8Array:return v.DT_UINT8;case Uint16Array:return v.DT_UINT16;case Uint32Array:return v.DT_UINT32}}}const ENV={}.VITE_APP_ENV,IS_DEV_ENV=!1;let DISABLE_ANALYTICS_EVENTS=!1,ASSETS_SOURCE_ROOT;const LOGGER=new x2("CORE");ENV==="staging"?(LOGGER.setCurrentMode(TR.Staging),ASSETS_SOURCE_ROOT="https://storage.googleapis.com/epigraph-configurator"):(LOGGER.setCurrentMode(TR.Release),ASSETS_SOURCE_ROOT="https://storage.googleapis.com/epigraph-configurator");LOGGER.info({title:"test"});const DEFAULT_INVENTORY=99999,DEFAULT_PRODUCT_PRICE=99999;let CORE_API=null;function setCoreApi(a){CORE_API=a,CORE_API.disableAnalyticsEvents=DISABLE_ANALYTICS_EVENTS}const ALL_PROJECTS_ASSET_DATA_ROOT_URL=`${ASSETS_SOURCE_ROOT}/projects-asset-data`,GENERIC_PROJECT_ASSET_DATA_ROOT_URL=`${ALL_PROJECTS_ASSET_DATA_ROOT_URL}/generic`;let FETCH_MODULE_DATA_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe?moduleID=",SAVE_CONFIG_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe/saveConfig",FETCH_CONFIG_ENDPOINT="https://us-central1-epigraph-product-configurator.cloudfunctions.net/epigraphServe?configID=",PUBLIC_DESIGN_ASSETS_ENDPOINT="https://storage.googleapis.com/gsc-epigraph-design/product-assets";function setGlobalEndpoints(a){const e=a.SAVE_CONFIG_ENDPOINT;SAVE_CONFIG_ENDPOINT=e||SAVE_CONFIG_ENDPOINT;const t=a.FETCH_CONFIG_ENDPOINT;FETCH_CONFIG_ENDPOINT=t||FETCH_CONFIG_ENDPOINT;const n=a.PUBLIC_DESIGN_ASSETS_ENDPOINT;PUBLIC_DESIGN_ASSETS_ENDPOINT=n||PUBLIC_DESIGN_ASSETS_ENDPOINT;const s=a.ASSETS_SOURCE_ROOT;ASSETS_SOURCE_ROOT=s||ASSETS_SOURCE_ROOT}const ALERT_TYPES=Object.freeze({info:{id:"info",level:1e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Info.svg",color:"#2E6CDF",cssClass:"alert-info",background:"#D3E0F8",filter:"invert(39%) sepia(41%) saturate(5002%) hue-rotate(208deg) brightness(91%) contrast(92%)"},warn:{id:"warn",level:3e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Warning.svg",color:"#E2B236",cssClass:"alert-warn",background:"#F9EED2",filter:"invert(83%) sepia(67%) saturate(1578%) hue-rotate(328deg) brightness(93%) contrast(90%)"},error:{id:"error",level:4e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/Block.svg",color:"#D0342C",cssClass:"alert-error",background:"#F6D7D5",filter:"invert(24%) sepia(96%) saturate(1914%) hue-rotate(349deg) brightness(95%) contrast(81%)"},success:{id:"success",level:2e3,src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Icon/CheckCircle.svg",color:"#65BC6C",cssClass:"alert-success",background:"#DBF0DD",filter:"invert(74%) sepia(3%) saturate(5600%) hue-rotate(75deg) brightness(90%) contrast(90%)"}}),CAMERA_ACTION=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),CURSORS={GRAB:"grab",POINTER:"pointer",BLOCKED:"blocked",GRABBING:"grabbing",MOVE:"move"},ensureUniqueNames=a=>{const e=[],t=new Set;for(const n of a){let s=n,o=0;for(;t.has(s);)s=n+"."+ ++o;t.add(s),e.push(s)}return e},mappingsArrayToTable=(a,e)=>{const t={};for(const n of a.mappings)for(const s of n.variants)t[e[s]]={material:null,gltfMaterialIndex:n.material};return t},compatibleObject=a=>a.material!==void 0&&a.userData&&a.userData.variantMaterials,traversePair=(a,e,t)=>{t(a,e);for(let n=0;n<a.children.length;n++)traversePair(a.children[n],e.children[n],t)},copyVariantMaterials=(a,e)=>{e.userData.variantMaterials!==void 0&&(a.userData.variantMaterials=Object.assign({},e.userData.variantMaterials)),e.userData.originalMaterial!==void 0&&(a.userData.originalMaterial=e.userData.originalMaterial)};class GLTFMaterialsVariantsExtension{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,n=t.json;if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name].variants||[],v=ensureUniqueNames(o.map(T=>T.name));for(const T of e.scenes)T.traverse(ee=>{const re=t.associations.get(ee);if(!re||re.meshes===void 0||re.primitives===void 0)return;const le=n.meshes[re.meshes].primitives[re.primitives].extensions;!le||!le[this.name]||(ee.userData.variantMaterials=mappingsArrayToTable(le[this.name],v))});e.userData.variants=v,e.functions=e.functions||{};const A=async(T,ee,re)=>{T.userData.originalMaterial||(T.userData.originalMaterial=T.material);const ie=T.material;let se=null;if(ee===null||!T.userData.variantMaterials[ee])T.material=T.userData.originalMaterial,t.associations.has(T.material)&&(se=t.associations.get(T.material).index);else{const le=T.userData.variantMaterials[ee];le.material?(T.material=le.material,le.gltfMaterialIndex!==void 0&&(se=le.gltfMaterialIndex)):(se=le.gltfMaterialIndex,T.material=await t.getDependency("material",se),t.assignFinalMaterial(T),le.material=T.material)}re!==null&&re(T,ie,se)},b=T=>{const ee=T.material,re=T.userData.variantMaterials,ie=[];for(const se in re){const le=re[se];if(le.material)continue;const pe=le.gltfMaterialIndex;ie.push(t.getDependency("material",pe).then(de=>{T.material=de,t.assignFinalMaterial(T),re[se].material=T.material}))}return Promise.all(ie).then(()=>{T.material=ee})};e.functions.selectVariant=(T,ee,re=!0,ie=null)=>{const se=[];return re?T.traverse(le=>compatibleObject(le)&&se.push(A(le,ee,ie))):compatibleObject(T)&&se.push(A(T,ee,ie)),Promise.all(se)},e.functions.ensureLoadVariants=(T,ee=!0)=>{const re=[];return ee?T.traverse(ie=>compatibleObject(ie)&&re.push(b(ie))):compatibleObject(T)&&re.push(b(T)),Promise.all(re)},e.functions.copyVariantMaterials=(T,ee,re=!0)=>{re?traversePair(T,ee,(ie,se)=>copyVariantMaterials(ie,se)):copyVariantMaterials(T,ee)}}}var dracoLoader=new DRACOLoader;dracoLoader.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`);dracoLoader.setDecoderConfig({type:"js"});const assetStore=create$3((a,e)=>({assets:{items:{}},actions:{async loadAsset(t,n=!1){const{assets:s}=e();let o,v;if(s.items[t]){const re=n?s.items[t].proxy:s.items[t];if(re.isLoaded)return s.items[t];if(re.errorLoading)throw Error((n?"Proxy ":"Model ")+"Loading failed for: "+t,t)}else s.items[t]={isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}};const A=productDataStore$1.getState().productData[t];if(!A)throw Error("Data doesn't exists for "+t,t);if(n?(o=s.items[t].proxy,v=CORE_API.getResolvedAssetUrl(A.colliderProxyGLTF)):(o=s.items[t],v=CORE_API.getResolvedAssetUrl(A.gltfURL)),!o||!v)return null;const b=new GLTFLoader;b.register(re=>new GLTFMaterialsVariantsExtension(re)),b.setDRACOLoader(dracoLoader);async function T(re){const ie=re.loaded/re.total*100;o.progress=ie}const ee=await b.loadAsync(v,T).catch(re=>{throw o.isLoaded=!1,o.errorLoading=!0,o.error=re,LOGGER.info(v),Error("Couldn't load "+t,t)});return o.data=ee,o.isLoaded=!0,s.items[t]},IsAssetLoaded(t){const{assets:n}=e();return n.items.hasOwnProperty(t)?n.items[t].isLoaded:!1},IsProxyLoaded(t){const{assets:n}=e();return n.items.hasOwnProperty(t)&&n.items[t].hasOwnProperty(proxy)?n.items[t].proxy.isLoaded:!1}}}));var replacingNode=null,swappableNodes=[];const ghostStore=create$3((a,e)=>({ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(t,n=!1,s)=>{const{ghostData:o,ghostsTransform:v}=e();if(o!==null||v.length>0){LOGGER.info("ghosts are already spawned for: "+o.skuID);return}return await new Promise(async(b,T)=>{let ee={};const re=()=>{b(ee)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Ghost_Loaded,re,{once:!0});const ie=productDataStore$1.getState().productData,se=attachmentStore$1.getState().attachmentSystem.currentStructure;if(replacingNode=se.getFirstNodeByCategoryID(ie[t].categoryID),ie[t].replace&&replacingNode){if(t==replacingNode.skuID)return;const{transforms:pe,connectablePlugs:de}=se.findGhostTransformForReplacement(t,replacingNode);if(pe==null&&de==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+t});return}ee.transforms=pe,ee.newNodes=[replacingNode],ee.connectablePlugs=de,ee.addItemOrSwap=["replace"],replacingNode.setModelVisibility(!1)}else{const{transforms:pe,newNodes:de,connectablePlugs:fe}=se.findGhostTransforms(t,n);let _e=pe,ve=fe,xe=de,De=[];for(let Le=0;Le<pe.length;Le++)De.push("add");if(ie[t].swappable&&!sceneStore.getState().dragging){swappableNodes=se.getNodesByCategoryID(ie[t].categoryID);for(let Le=0;Le<swappableNodes.length;Le++){const Ue=se.findGhostTransformForReplacement(t,swappableNodes[Le]);Ue.transforms&&(_e.push(Ue.transforms[0]),ve.push(Ue.connectablePlugs[0]),xe.push(swappableNodes[Le]),De.push("replace"),swappableNodes[Le].setModelVisibility(!1))}}ee.transforms=_e,ee.newNodes=xe,ee.connectablePlugs=ve,ee.addItemOrSwap=De}if(ee.transforms.length<=0)return;const le=await assetStore.getState().actions.loadAsset(t,!0);a({ghostsTransform:ee.transforms,ghostData:{proxyScene:le.proxy.data.scene,skuID:t,newNodes:ee.newNodes,addItemOrSwap:ee.addItemOrSwap,connectablePlugs:ee.connectablePlugs,count:s||ee.transforms.length}})})},clearAllGhosts:()=>{if(replacingNode&&replacingNode.setModelVisibility(!0),swappableNodes)for(let t=0;t<swappableNodes.length;t++)swappableNodes[t].setModelVisibility(!0);a({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),cameraStore=create$3((a,e)=>({focusPointPosition:new Vector3(0,0,0),canCameraRotate:!0,sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{triggerFetchingCamera:()=>{a(t=>({sendCameraDetailsTrigger:!t.sendCameraDetailsTrigger}))},setCameraSettings:t=>{const{cameraSettings:n}=e();sceneStore.getState().isMobile===!0&&t.zoomingMultiplier_mobile!==void 0?t.zoomingMultiplier=t.zoomingMultiplier_mobile:t.zoomingMultiplier_desktop!==void 0&&(t.zoomingMultiplier=t.zoomingMultiplier_desktop),Object.keys(t).map(o=>n[o]=t[o]),a({cameraSettings:{...n},viewPointPosition:ArrToVec3(n.initialViewPointPosition)})}}})),hotspotStore$1=create$3((a,e)=>({activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>a({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(t){const{hotspotsSpawned:n}=e();Object.keys(n).map(s=>{n[s].itemData.guid==t.itemData.guid&&delete n[s]}),a({hotspotsSpawned:{...n}})},checkHotspotHealth(){const{hotspotsHealthCheck:t}=e();a({hotspotsHealthCheck:!t})},toggleHotspotVisibility(){const{hotspotsVisibility:t}=e();a({hotspotsVisibility:!t})},switchHotspotsVisibility(t,n=!1){a(n===!0?{hotspotsTempVisibility:t}:{hotspotsVisibility:t})},clickHotspot(t,n,s,o=!1){const{activeHotspotData:v}=e();a({lastActiveHotspotData:v}),hotspotEnter(t,n,s);let b=itemStore.getState().itemsSpawned[s].itemData.skuID;o===!1&&(CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(b,t),hotspot:hotspotStore$1.getState().activeHotspotData}),CORE_API.fireEvent(CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(t=!1){const{activeHotspotData:n,isAnyHotspotActive:s}=e();if(s&&a({isAnyHotspotActive:!1}),!!n&&(a({lastActiveHotspotData:n}),hotspotExit(),t===!1)){const o=Math.round((performance.now()-e().lastActiveHotspotData.hotspotEnterTime)/1e3);CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:e().lastActiveHotspotData,hotspotTimeSpent:o}),CORE_API.fireEvent(CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(){hotspotStore$1.setState({activeHotspotData:null}),sceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(a,e,t){let n=hotspotStore$1.getState();const o=itemStore.getState().itemsSpawned;let v=n.visitedHotspotsID;const A=o[t].hotspotsData.filter(De=>De.hotspotID==a);if(!A||A.length<=0)return;const b=A[0],T=o[t].itemData.skuID+"_"+a;let re=attachmentStore$1.getState().attachmentSystem.currentStructure.getNodeByGUID(t),ie=new Vector3(0,0,0);re&&re.ref&&re.ref.getWorldPosition(ie);let se=new Quaternion().identity();re&&re.ref&&re.ref.getWorldQuaternion(se);let le=b.focusPointTransform;LOGGER.info(le);let pe=ArrToVec3(le);pe.applyQuaternion(se);let de=b.viewPointTransform,fe=ArrToVec3(de);fe.applyQuaternion(se);let _e=addVector(Vec3ToArr(pe),Vec3ToArr(ie)),ve=addVector(Vec3ToArr(fe),Vec3ToArr(ie));cameraStore.setState({focusPointPosition:_e,viewPointPosition:ve}),hotspotStore$1.setState({activeHotspotData:{hotspotData:{guid:e,...b},itemData:{...o[t],guid:t},domID:"rd_"+T,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),v.includes(T)||(v.push(T),hotspotStore$1.setState({visitedIDs:{...v}}))}const itemStore=create$3((a,e)=>({variantChangeAlert:!1,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],filteredCollidersRef:[],selectedItemData:null,busy:!1,actions:{triggerModelLoaded:()=>a(t=>({modelLoadedAlert:t.modelLoadedAlert+1})),triggerRemoveItem:()=>a(t=>({removeItemTrigger:!t.removeItemTrigger})),addToRemoveItems:t=>{const{removeItems:n}=e();n.push(t)},switchToVariant:async(t,n,s=!1)=>{const{itemsSpawned:o,variantChangeAlert:v}=e(),A=productDataStore$1.getState().categoryData,b=o[t.guid].itemData.clonedScene;var ee=attachmentStore$1.getState().attachmentSystem.currentStructure.getNodeByGUID(t.guid);assetStore.getState().assets.items[t.skuID].data||A.geometryVariants&&A.geometryVariants.map(se=>{se.productsInCategory.map(le=>{let pe=!1;le.products.map(de=>{de==t.skuID&&(pe=!0)}),pe&&le.products.map(de=>{const fe=assetStore.getState().assets.items[de].data;fe&&(assetStore.getState().assets.items[t.skuID].data=fe)})})});const ie=assetStore.getState().assets.items[t.skuID].data;ie&&(await ie.functions.selectVariant(b,n),s?(ee.overrideVariant=n,CORE_API.fireEvent(CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):ee.currentVariant=n,a({variantChangeAlert:!v}))},clearAllItems:()=>{a({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:t=>{a({itemsSpawned:t,itemsCount:Object.keys(t).length})},setHoveredItemRef:t=>a({hoveredItemRef:t}),setCollidersRef:t=>{a({collidersRef:t});let n=[];for(var s=0;s<t.length;s++)t[s].current&&n.push(t[s]);itemStore.setState({filteredCollidersRef:[...n]})},setSelectedItemData:t=>{const{selectedItemData:n,hoveredItemRef:s,actions:o}=e();n&&(delete s[n.itemData.guid],o.setHoveredItemRef({...s})),a({selectedItemData:{...t}}),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.switchHotspotsVisibility(!1,!0),cameraStore.setState({canCameraRotate:!1})},deselectItem:()=>{const{selectedItemData:t}=e();t&&CORE_API.fireEvent(CORE_API.EVENTS.UI.ContextMenu_Hide,t),a(()=>({selectedItemData:null})),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.switchHotspotsVisibility(!0,!0),cameraStore.setState({canCameraRotate:!0}),itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async t=>{const{itemsSpawned:n,actions:s}=e();if(n.hasOwnProperty(t))return new Promise(async(o,v)=>{s.addToRemoveItems(t),s.triggerRemoveItem();const A=b=>{t===b.data.itemData.guid&&o(t)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Item_Removed,A,{once:!0})})},addItemBySkuID:async(t,n=0,s=!1,o)=>{a({busy:!0});const{actions:v,itemsSpawned:A}=e(),b=productDataStore$1.getState().productData,T=productDataStore$1.getState().hotspotsData,ee=attachmentStore$1.getState().attachmentSystem;let re=!0;const ie=await new Promise(async(pe,de)=>{if(v.deselectItem(),!b[t]){LOGGER.warn({title:`Product not found: ${t}`}),CORE_API.alert({alertMsg:t+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),re=!1,de(t+": product not found!");return}const fe=[...ghostStore.getState().ghostsTransform],_e={...ghostStore.getState().ghostData};if(ghostStore.getState().actions.clearAllGhosts(),fe.length<=0){CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),re=!1,de("No available connections for this product to attach to");return}const ve=xe=>{t===xe.data&&pe(_e.newNodes[n].guid)};if(CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,ve,{once:!0}),_e.addItemOrSwap[n]=="replace")await replaceItem(A,_e.skuID,fe[n],_e.newNodes[n]);else{const xe=_e.newNodes[n];xe.isDependent=s;let De=!0;if(b[_e.skuID].hasOwnProperty("disableInteraction")){const Fe=b[_e.skuID].disableInteraction;(Fe==!0||Fe==!1)&&(De=!Fe)}(o==!0||o==!1)&&(De=o),xe.isInteractive=De;const{position:Le,rotation:Ue}=fe[n];xe.transform={position:Le,rotation:Ue},ee.currentStructure.addNode(xe),ee.currentStructure.connectPlugs(_e.connectablePlugs[n]);const Ge=await assetStore.getState().actions.loadAsset(_e.skuID,!0);LOGGER.info("GHOST NEW NODE: ",xe),A[xe.guid]={itemData:{proxyScene:Ge.proxy.data.scene,guid:_e.newNodes[n].guid,...b[_e.skuID],position:Le,rotation:Ue,hasItemLoaded:!1,isDependent:s,isInteractive:De},hotspotsData:T[_e.skuID],hotspotSpawned:!1},await wait(1),v.setItemsSpawned({...A})}}).catch(pe=>{LOGGER.error({title:pe}),re=!1});if(re===!1)return a({busy:!1}),ie;const se=ee.getCartItems();se&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,se);const le=b[t]?.plugs;if(le){for(const pe of le){const de=pe?.dependencySku;if(!de)continue;LOGGER.info(`Found a dependency: ${de} on the plug: ${pe.name}`);let fe=!0;b[de]&&b[de].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(fe=b[de].ignoreSpawningCollisionAsDependency),pe.hasOwnProperty("ignoreSpawningCollision")&&(fe=pe.ignoreSpawningCollision);let _e=sceneStore.getState().sceneSettings.ignoreSpawningCollision;b[de].hasOwnProperty("ignoreSpawningCollision")&&(_e=b[de].ignoreSpawningCollision),b[de].ignoreSpawningCollision=fe;const ve=await ghostStore.getState().actions.spawnGhostsForSkuID(de,fe);if(b[de].ignoreSpawningCollision=_e,!ve)continue;const xe=ee.currentStructure.getNodeByGUID(ie),De=xe.getPlugByName(pe.name)?.guid,Le=pe?.isDependencySkuInteractive?pe.isDependencySkuInteractive===1:!1,Ue=ve.connectablePlugs;let Ge=!1;for(let Fe=0;Fe<ve.connectablePlugs.length;Fe++){if(Ue[Fe].receiverPlug.guid!==De)continue;Ge=!0;const Ye=await v.addItemBySkuID(de,Fe,!0,Le);Ye!==null&&xe.addMyDependenciesGUID(Ye)}Ge||ghostStore.getState().actions.clearAllGhosts()}ghostStore.getState().actions.clearAllGhosts()}return a({busy:!1}),ie},async addItemWithTransform(t,n,s,o=!0){return new Promise(async(v,A)=>{const{actions:b,itemsSpawned:T}=e();b.deselectItem();const ee=productDataStore$1.getState().productData,re=productDataStore$1.getState().hotspotsData;if(!ee[n]){CORE_API.alert({alertMsg:n+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"});return}const{position:ie,rotation:se}=t;T[s]!=null&&(hotspotStore$1.getState().actions.removeHotspotForItem({...T[s]}),delete T[s]);const le=de=>{n==de.data&&v(s)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,le,{once:!0});const pe=await assetStore.getState().actions.loadAsset(n,!0);pe!=null&&(await wait(1),T[s]={itemData:{proxyScene:pe.proxy.data.scene,guid:s,...ee[n],position:ie,rotation:se,hasItemLoaded:!1,isInteractive:o},hotspotsData:re[n],hotspotSpawned:!1},a({itemsSpawned:{...T}}))})},async replaceGUIDItemBySKUID(t,n){const{itemsSpawned:s}=e(),o=productDataStore$1.getState().productData,v=productDataStore$1.getState().hotspotsData,A=attachmentStore$1.getState().attachmentSystem.currentStructure,b=A.getNodeByGUID(t);return b.isReplaceableWithSkuId(n)?(await new Promise(async(ee,re)=>{hotspotStore$1.getState().actions.removeHotspotForItem({...s[t]}),delete s[t],b.update(n);const ie=le=>{n===le.data&&ee(!0)};CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Loaded,ie,{once:!0});const se=await assetStore.getState().actions.loadAsset(n,!0);await wait(1),s[t]={itemData:{proxyScene:se.proxy.data.scene,guid:t,...o[n],position:b.transform.position,rotation:b.transform.rotation,hasItemLoaded:!1},hotspotsData:v[n],hotspotSpawned:!1},itemStore.setState({itemsSpawned:{...s}})}),A.recalculateStructureFromNode(b.whichNodeAreWeAttachedTo()),attachmentStore$1.getState().actions.toggleStructureUpdated(),!0):!1}}}));async function replaceItem(a,e,t,n){const{position:s,rotation:o}=t,v=productDataStore$1.getState().productData,A=productDataStore$1.getState().hotspotsData,b=attachmentStore$1.getState().attachmentSystem.currentStructure;return new Promise(async(T,ee)=>{const re=async()=>{const ie=await assetStore.getState().actions.loadAsset(e,!0);a[n.guid]={itemData:{proxyScene:ie.proxy.data.scene,guid:n.guid,...v[e],position:s,rotation:o,hasItemLoaded:!1},hotspotsData:A[e],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:n.currentVariant}),n.currentVariant=n.currentVariant,n.transform=t,itemStore.setState({itemsSpawned:{...a}}),b.recalculateStructureFromNode(n),attachmentStore$1.getState().actions.toggleStructureUpdated(),T(n.guid)};hotspotStore$1.getState().actions.removeHotspotForItem({...a[n.guid]}),delete a[n.guid],n.update(e),CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Model_Removed,re,{once:!0})})}const inventoryStore=create$3((a,e)=>({inventoryData:{},actions:{getInventoryInfo:()=>{const{inventoryData:t}=e();return t},updateInventoryForAllProducts:t=>{const{actions:n}=e();Object.keys(t).map(s=>{let o=t[s];Object.keys(o).map(v=>{n.updateInventoryForProduct(s,v,o[v].inventory)})}),n.refreshInventory(itemStore.getState().itemsSpawned)},updateInventoryForProduct:(t,n,s)=>{const{inventoryData:o}=e();let v=o[t],A=v[n];!v||!A||(A.inventory=s)},_clearInScene:()=>{const{inventoryData:t}=e();Object.keys(t).map(n=>{const s=t[n];Object.keys(s).map(o=>{s[o].inScene=[]})})},refreshInventory:t=>{if(!t)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:n,inventoryData:s}=e();n._clearInScene();const o=attachmentStore$1.getState().attachmentSystem;if(o===null)return;const v=o.currentStructure;if(v===null)return;Object.keys(t).map(ee=>{const re=v.getNodeByGUID(ee);if(!re)return;const ie=re.overrideVariant?re.overrideVariant:re.currentVariant;if(!ie)return;const se=s[re.skuID];if(!se||!se[ie].inScene)return;se[ie].inScene.push(ee),sceneStore.getState().sceneSettings.disableCart===!0?re.inStock={variantName:ie,newValue:!0}:se[ie].inScene.length>se[ie].inventory?re.inStock={variantName:ie,newValue:!1}:re.inStock={variantName:ie,newValue:!0}});let A=!1;Object.keys(s).map(ee=>{const re=s[ee];Object.keys(re).map(ie=>{re[ie].countAvailable=re[ie].inventory-re[ie].inScene.length,re[ie].countAvailable<0?(re[ie].countUnavailable=re[ie].countAvailable*-1,re[ie].countAvailable=0,A=!0):re[ie].countUnavailable=0})});const b={alertMsg:"Some items selected are out of stock",alertTime:3e3,alertType:"warn",alertLabel:"Stock Alert",alertId:"outOfStock"},T=compareObjects(sceneStore.getState().persistantAlertData,b);A===!1&&T===!0&&CORE_API.removePersistantAlert(),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Inventory_Updated,s)}}})),sceneStore=create$3((a,e)=>({CORE_API:null,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,configurationLoaded:!0,preconfigurationLoaded:!1,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:null,showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:250,g:50,b:0,a:.75},ghostAsWireframe:!1,draggableUI:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:"Empty Scene",emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",textSettings:{cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",tooltipEmptySceneText:"-Add items to the scene-",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:0,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:t=>{a({cssLoaded:t})},actions:{popFromAlertQueue:()=>{const{alertQueue:t}=e();return t.shift(),a({alertQueue:t}),t},addToAlertQueue:t=>{const{alertQueue:n}=e();return n.push(t),a({alertQueue:n}),n},getDeviceState:()=>{const{isDesktop:t,isMobile:n,isTablet:s,isTouchDevice:o,isLandscape:v}=e();return{isDesktop:t,isMobile:n,isTablet:s,isTouchDevice:o,isLandscape:v}},enableCart:()=>{const{sceneSettings:t}=e();t.disableCart=!1,inventoryStore.getState().actions.refreshInventory(itemStore.getState().itemsSpawned),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:t}=e();t.disableCart=!0,inventoryStore.getState().actions.refreshInventory(itemStore.getState().itemsSpawned),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:t}=e();return t},sendAlert:t=>{a({alertData:{...t}})},switchCursor(t){const{cursorParentRef:n}=e();if(!n)return;let s="";switch(t){default:case CURSORS.GRAB:s="grabCursor";break;case CURSORS.GRABBING:s="grabbingCursor";break;case CURSORS.BLOCKED:s="blockedCursor";break;case CURSORS.POINTER:s="pointerCursor";break;case CURSORS.MOVE:s="moveCursor";break}for(let o=0;o<n.classList.length;o++)n.classList[o].includes("Cursor")&&n.classList.remove(n.classList[o]);n.classList.add(s)},setAlertSettings:t=>{a({alertSettings:t})},async completeDropItem(){const t=attachmentStore$1.getState().attachmentSystem,{draggingOnDropCollisionData:n}=e(),{node:s,attachedChildrenGuids:o,collidingStatus:v,intersectingGhostObject:A,initPosition:b,initRotation:T,detachedPlugs:ee,attachedNodesToCurrentNode:re}=n;CORE_API.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[pe,de]of o.entries())v[pe]===!0&&await itemStore.getState().actions.removeItemByGUID(de);const ie=A.userData;let se=s.getPlugByName(ie.incomingPlugName),le=t.currentStructure.getPlugByGUID(ie.receiverPlugGUID);s.ref.position.set(A.position.x,A.position.y,A.position.z),s.ref.setRotationFromEuler(A.rotation),s.transform={position:A.position,rotation:A.quaternion},t.currentStructure.connectPlugs({incomingPlug:se,receiverPlug:le}),ghostStore.getState().actions.clearAllGhosts(),itemStore.getState().actions.deselectItem(),re.map(pe=>{s.ref.parent.attach(pe.ref)}),attachmentStore$1.getState().actions.updateFittingSkuIds()},revertDropItem(){const t=attachmentStore$1.getState().attachmentSystem,{draggingOnDropCollisionData:n}=e(),{node:s,attachedChildrenGuids:o,collidingStatus:v,intersectingGhostObject:A,initPosition:b,initRotation:T,detachedPlugs:ee,attachedNodesToCurrentNode:re}=n;CORE_API.alert({alertMsg:"Position of item"+s.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const ie=ee.neighbourDetachedPlugs;ie&&(ee.neighbourNode.detachNodeFromReceiver(),t.currentStructure.connectPlugs({incomingPlug:ie.incomingPlug,receiverPlug:ie.receiverPlug}));let se=ee.rootDetachedPlugs.incomingPlug,le=ee.rootDetachedPlugs.receiverPlug;s.ref.position.set(b.x,b.y,b.z),s.ref.setRotationFromEuler(T);let pe=new Quaternion().identity();s.ref.getWorldQuaternion(pe),s.transform={position:b,rotation:pe},t.currentStructure.connectPlugs({incomingPlug:se,receiverPlug:le}),ghostStore.getState().actions.clearAllGhosts(),itemStore.getState().actions.deselectItem(),re.map(de=>{s.ref.parent.attach(de.ref)}),attachmentStore$1.getState().actions.updateFittingSkuIds()},setCoreSettings:t=>{const{sceneSettings:n,isMobile:s,isTouchDevice:o,isLandscape:v,actions:A}=e(),b=s===!0?"mobile":"desktop",T=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const ee of T)if(ee==="draggableUI"||ee==="emptySceneTextFontSize"||ee==="showInstructionsOnStartup"||ee==="showInstructionsBtn"||ee==="instructionsSettings"){const ie=`${ee}_${v===!1&&o===!0?"mobile":"desktop"}`;t[ie]!==void 0?n[ee]=t[ie]:n[ie]!==void 0&&(n[ee]=n[ie])}else if(ee==="textSettings"||ee==="variantsTabOrder"||ee==="alertControl"){if(t.hasOwnProperty(ee)){let re=n[ee];Object.keys(re).map(ie=>{let se=t[ee];se.hasOwnProperty(ie)||(se[ie]=re[ie])})}}else{const re=`${ee}_${b}`;if(t[re]!==void 0){let ie=`${ee}Btn`;ee=="showContextMenu"&&(ie=`${ee}`),n[ie]=t[re]}}t.disableCart===!0&&A.disableCart(),Object.keys(t).map(ee=>n[ee]=t[ee]),a({sceneSettings:{...n,ghostThreeColor:{r:n.ghostColor.r/255,g:n.ghostColor.g/255,b:n.ghostColor.b/255,a:n.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:n.ghostColorOnHoverWithDraggableUi.r/255,g:n.ghostColorOnHoverWithDraggableUi.g/255,b:n.ghostColorOnHoverWithDraggableUi.b/255,a:n.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(t=null)=>a(n=>({autoFocusRef:t,autoFocusTrigger:n.autoFocusTrigger+1})),requestNewScreenshot:async(t,n)=>new Promise(async(s,o)=>{LOGGER.info("Taking a screenshot");const{screenshotRenderer:v,sceneRef:A,screenshotCamera:b,canvasSize:T}=e(),ee=await CORE_API.getCurrentCameraDetails();if(v.setClearColor(16777215),b.copy(ee),t!==null&&(b.position.copy(t.position),b.rotation.copy(new Euler(t.rotation.x,t.rotation.y,t.rotation.z))),n==null?v.setSize(T.width,T.height):v.setSize(n.width,n.height),v.render(A.parent,b),v.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),o({success:!1,imageData:null});else{LOGGER.info("Downloading the screenshot");const re=v.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");s({success:!0,imageData:re})}})}})),hotspotIdPrefix="rd",hotspotIdSeparator="_";function generateHotspotAbsoluteID(a,e){return`${hotspotIdPrefix}${hotspotIdSeparator}${a}${hotspotIdSeparator}${e}`}async function wait(a){return LOGGER.info({title:`Waiting for ${a}ms`}),new Promise((e,t)=>{setTimeout(()=>{e(!0)},a)})}function compareObjects(a,e){if(a===null||e===null)return!1;for(let t in a)if(a.hasOwnProperty(t)&&e.hasOwnProperty(t)&&a[t]!==e[t])return!1;return Object.keys(a).length===Object.keys(e).length}const saveStructureToCMS=a=>{const e={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)};return fetch(SAVE_CONFIG_ENDPOINT,e)},mobileCheck=function(){let a=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(a=!0)}(navigator.userAgent||navigator.vendor||window.opera),a};function isIpadOS(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)}function tabletCheck(){const a=navigator.userAgent.toLowerCase(),e=/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(a);return e||isIpadOS()}function touchDeviceCheck(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}async function getJSONFromEndpoint(a){let e={data:null,report:"",success:!1};try{const n=await(await fetch(a)).text();e.data=JSON.parse(n),e.success=!0,e.report="Successfully fetched JSON data."}catch(t){e.report=t,CORE_API.alert({alertMsg:"",alertTime:5e3,alertType:"warn",alertLabel:"Preload Failed"})}return e}const addVector=(a,e)=>new Vector3(a[0]+e[0],a[1]+e[1],a[2]+e[2]),Vec3ToArr=a=>[a.x,a.y,a.z],ArrToVec3=a=>new Vector3(a[0],a[1],a[2]),findMeshAndCloneMatFromScene=(a,e=!0)=>{let t=[];const n=sceneStore.getState().sceneSettings.outOfStock_EmissiveColor,s=sceneStore.getState().sceneSettings.outOfStock_EmissiveIntensity;return a.traverse(o=>{o.isMesh&&(o.material.userData.cloned?o.material.userData.inStock!==e&&(e?(o.material.emissive.set(new Color$1(255,255,255)),o.material.emissiveIntensity=0):(o.material.emissive.set(new Color$1(n.r,n.g,n.b)),o.material.emissiveIntensity=s),o.material.userData.inStock=e):(o.material=o.material.clone(),o.material.userData.inStock=e,o.material.userData.cloned=!0,e?(o.material.emissive.set(new Color$1(255,255,255)),o.material.emissiveIntensity=0):(o.material.emissive.set(new Color$1(n.r,n.g,n.b)),o.material.emissiveIntensity=s)),t.push(o))}),t},filterArrWithCondition=(a,e)=>{let t=0,n=[];for(let s=0;s<a.length;s++){const o=a[s];e(o)?a[t++]=o:n.push(a[s])}return a.length=t,n},degToRad=a=>a*Math.PI/180,resolveAssetUrl=a=>{if(!a)return;if(new RegExp("^(?:[a-z+]+:)?//","i").test(a))return a;let n=a;return n=n.replaceAll("<@all-projects@>",ALL_PROJECTS_ASSET_DATA_ROOT_URL),n=n.replaceAll("<@generic-project@>",GENERIC_PROJECT_ASSET_DATA_ROOT_URL),n};function componentToHex(a){var e=a.toString(16);return e.length==1?"0"+e:e}function rgbToHex(a,e,t){return"#"+componentToHex(a)+componentToHex(e)+componentToHex(t)}function getUrlParameterByName(a,e=window.location.search){const t=new URLSearchParams(e);return Object.fromEntries(t.entries())[a]}const lightStore=create$3((a,e)=>({defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:t=>{a(n=>({envMapUrl:t}))},processLookEnvMapOverride:t=>{const{envMapUrl:n,defaultEnvMapUrl:s,actions:o}=e(),v=productDataStore$1.getState().lookData[t],A=v?.envMapOverride;if(!v||!A){o.setEnvLightMap(s);return}if(A===n){LOGGER.info(`New Env Map Url is the same as the current ${A}`);return}o.setEnvLightMap(A)}}}));var rngBrowser={exports:{}},getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(getRandomValues){var rnds8=new Uint8Array(16);rngBrowser.exports=function(){return getRandomValues(rnds8),rnds8}}else{var rnds=new Array(16);rngBrowser.exports=function(){for(var e=0,t;e<16;e++)e&3||(t=Math.random()*4294967296),rnds[e]=t>>>((e&3)<<3)&255;return rnds}}var rngBrowserExports=rngBrowser.exports,byteToHex=[];for(var i$2=0;i$2<256;++i$2)byteToHex[i$2]=(i$2+256).toString(16).substr(1);function bytesToUuid$2(a,e){var t=e||0,n=byteToHex;return[n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],"-",n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]],n[a[t++]]].join("")}var bytesToUuid_1=bytesToUuid$2,rng$1=rngBrowserExports,bytesToUuid$1=bytesToUuid_1,_nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1$2(a,e,t){var n=e&&t||0,s=e||[];a=a||{};var o=a.node||_nodeId,v=a.clockseq!==void 0?a.clockseq:_clockseq;if(o==null||v==null){var A=rng$1();o==null&&(o=_nodeId=[A[0]|1,A[1],A[2],A[3],A[4],A[5]]),v==null&&(v=_clockseq=(A[6]<<8|A[7])&16383)}var b=a.msecs!==void 0?a.msecs:new Date().getTime(),T=a.nsecs!==void 0?a.nsecs:_lastNSecs+1,ee=b-_lastMSecs+(T-_lastNSecs)/1e4;if(ee<0&&a.clockseq===void 0&&(v=v+1&16383),(ee<0||b>_lastMSecs)&&a.nsecs===void 0&&(T=0),T>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=b,_lastNSecs=T,_clockseq=v,b+=122192928e5;var re=((b&268435455)*1e4+T)%4294967296;s[n++]=re>>>24&255,s[n++]=re>>>16&255,s[n++]=re>>>8&255,s[n++]=re&255;var ie=b/4294967296*1e4&268435455;s[n++]=ie>>>8&255,s[n++]=ie&255,s[n++]=ie>>>24&15|16,s[n++]=ie>>>16&255,s[n++]=v>>>8|128,s[n++]=v&255;for(var se=0;se<6;++se)s[n+se]=o[se];return e||bytesToUuid$1(s)}var v1_1=v1$2,rng=rngBrowserExports,bytesToUuid=bytesToUuid_1;function v4$1(a,e,t){var n=e&&t||0;typeof a=="string"&&(e=a==="binary"?new Array(16):null,a=null),a=a||{};var s=a.random||(a.rng||rng)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e)for(var o=0;o<16;++o)e[n+o]=s[o];return e||bytesToUuid(s)}var v4_1=v4$1,v1$1=v1_1,v4=v4_1,uuid=v4;uuid.v1=v1$1;uuid.v4=v4;var uuid_1=uuid;class Plug{constructor(e,t,n=null){this._attachedPlug=null,this._name=e.name,this._acceptedPlugTypes=e.acceptedPlugTypes,this._type=e.type,this._affectedNodes=e.affectedNodes,this._weight=e.weight,this._connectsToPlugTypes=e.connectsToPlugTypes,this._node=t,this._guid=uuid_1.v4(),this._isOpen=!0,this._isReceiverPlug=!1,this._attachedPlugGUID=null,n&&(this._guid=n.guid,this._isOpen=n.isOpen,this._isReceiverPlug=n.isReceiverPlug,this._attachedPlugGUID=n.attachedPlugGUID)}export(){return this.isOpen?null:{guid:this._guid,isOpen:this._isOpen,attachedPlugGUID:this._attachedPlugGUID,isReceiverPlug:this._isReceiverPlug}}get node(){return this._node}get attachedPlug(){return this._attachedPlug}set attachedPlug(e){this._attachedPlug=e}get attachedPlugGUID(){return this._attachedPlugGUID}get type(){return this._type}get weight(){return this._weight}get affectedNodes(){return this._affectedNodes}get guid(){return this._guid}get isReceiverPlug(){return this._isReceiverPlug}get name(){return this._name}get acceptedPlugTypes(){return this._acceptedPlugTypes}set acceptedPlugTypes(e){this._acceptedPlugTypes=e}get connectsToPlugTypes(){return this._connectsToPlugTypes}set connectsToPlugTypes(e){this._connectsToPlugTypes=e}get isOpen(){return this._isOpen}attachPlug(e,t=!1){this._attachedPlug=e,this._attachedPlugGUID=e.guid,this._isOpen=!1,this._isReceiverPlug=t;const n=this,s=this._node;if(s.isConnectedToRoot&&t){const o=s.findRootPlugInNodeIfAny();switch(e.type){case"weighted_hider":o.weight<n.weight&&(s.showNodes(o.affectedNodes)||CORE_API.coreWCRef.addEventListener(s.guid+":modelLoaded",function(){s.showNodes(o.affectedNodes)},{once:!0}));break}}if(t&&e.type!==""&&e.type==n._type)switch(e.type){default:case"weighted_hider":n._weight>e.weight?e.node.hideNodes(e.affectedNodes)||CORE_API.coreWCRef.addEventListener(e.node.guid+":modelLoaded",function(){e.node.hideNodes(e.affectedNodes)},{once:!0}):n._weight<e.weight&&(s.hideNodes(n._affectedNodes)||CORE_API.coreWCRef.addEventListener(s.guid+":modelLoaded",function(){s.hideNodes(n._affectedNodes)},{once:!0}));break}t&&(s.isEndNode=!1)}openPlug(){if(this._node.isConnectedToRoot){const e=this._node.findRootPlugInNodeIfAny();if(e&&this._guid!==e.guid)switch(this.type){case"weighted_hider":e.type==="weighted_hider"&&e.weight<this.weight&&this._node.hideNodes(e.affectedNodes);break}}if(this._isReceiverPlug&&this._attachedPlug.type!==""&&this._attachedPlug.type==this._type)switch(this._attachedPlug.type){default:case"weighted_hider":this._weight>this._attachedPlug.weight?this._attachedPlug.node.showNodes(this._attachedPlug.affectedNodes):this._weight<this._attachedPlug.weight&&this._node.showNodes(this._affectedNodes);break}this._attachedPlug=null,this._attachedPlugGUID=null,this._isOpen=!0,this._isReceiverPlug&&(this._isReceiverPlug=!1,this._node.checkIfEndNode())}canAttachToPlug(e){for(let t=0;t<this._connectsToPlugTypes.length;t++)if(e._acceptedPlugTypes.includes(this._connectsToPlugTypes[t]))return!0;return!1}}let Node$1=class{#t="default";#i=!1;#r=!1;#s=!0;#n={};#o=!1;#c={};#u=[];constructor(e,t=null,n,s){let o=productDataStore$1.getState().productData;this._plugs=[],this._skuID=e,this._ref=null,this._modelData=null,this._transform=null,this.#t="default",this._overrideVariant=null,this._followsParent=o[e].followsParent,this._categoryID=o[e].categoryID,this._replace=o[e].replace,this._swappable=o[e].swappable,this._price=this.#a(),this.#i=o[e]?.ignoreInCart,t?(this._guid=t.guid,this._isEndNode=t.isEndNode,this._overrideVariant=t.overrideVariant,this.generatePlugsWithData(e,t.plugs)):(this._guid=uuid_1.v4(),this._isEndNode=!0,this.generatePlugsForNode(e)),n&&Object.keys(n).map(v=>{if(o[e].looks&&o[e].looks.includes(v)){this.#t=v;return}})}get isRoot(){return this._skuID.toLowerCase()==="root"}updateGeometryVariant(e,t){const s=productDataStore$1.getState().categoryData.geometryVariants;let o=null;if(s.map(ee=>{ee.id==e&&(o=ee)}),!o)return;const v=o.productsInCategory,b=o.variants[t].productsToSwitch,T=itemStore.getState().itemsSpawned;v.map(ee=>{ee.products.map(re=>{this.skuID===re&&ee.products.map(ie=>{b.map(se=>{if(se==ie){const le=productDataStore$1.getState().actions.getProductDataById(se);this.skuID=le.skuID;const pe=T[this.guid];pe&&pe.itemData&&Object.keys(le).map(de=>{pe.itemData[de]=le[de]}),this.hideNodes(le.geometriesToHide),this.showNodes(le.geometriesToShow),this.updatePricing(),this.resetInStock(),inventoryStore.getState().actions.refreshInventory(T)}})})})})}resetInStock(){this.#n={},this.#o=!0}setInStockForRef(e){if(!this.ref)return!1;let t=this.ref.getObjectByName("GRP_RenderGeometry");return t?(t.inStock=e,!0):!1}set inStock({variantName:e,newValue:t}){if(this.#n[e]&&this.#n[e]==t||(this.#n[e]=t,e!==this.#t&&this.#o===!1))return;const n=()=>{this.setInStockForRef(t)};n()||CORE_API.coreWCRef.addEventListener(this.guid+":modelLoaded",n,{once:!0})}get myDependenciesGUID(){return this.#u}set myDependenciesGUID(e){this.#u=e}addMyDependenciesGUID(e){this.#u.push(e)}get isDependent(){return this.#r}set isDependent(e){this.#r=e}get isInteractive(){return this.#s}set isInteractive(e){this.#s=e}update(e){this._skuID=e;const t=productDataStore$1.getState().productData,n=t[e]?.plugs;if(this.ignoreInCart=t[e].ignoreInCart,!!n)for(let s=0;s<this._plugs.length;s++)for(let o=0;o<n.length;o++)this._plugs[s].name==n[o].name&&(this._plugs[s].acceptedPlugTypes=n[o].acceptedPlugTypes,this._plugs[s].connectsToPlugTypes=n[o].connectsToPlugTypes)}export(){let e={};for(var t=0;t<this._plugs.length;t++){let n=this._plugs[t].export();n&&(e[this._plugs[t].name]=n)}return{skuID:this._skuID,guid:this._guid,isEndNode:this._isEndNode,plugs:e,overrideVariant:this._overrideVariant}}get node(){return this}get swappable(){return this._swappable}get replace(){return this._replace}get ignoreInCart(){return this.#i}set ignoreInCart(e){this.#i=e}get canRotate(){let e=!0;if(!this._isEndNode){const v=this.whichNodesAreAttachedToUs();if(v.length>0){let A=!0;if(v.map(b=>{b.followsParent===!1&&(A=!1)}),!A)return!1}}let t=!1;for(var n=0;n<this.plugs.length;n++)if(!this.plugs[n].isOpen&&this.plugs[n].attachedPlug.isReceiverPlug){const v=this.plugs[n].attachedPlug.acceptedPlugTypes;for(var s=0;s<this.plugs.length;s++)if(n!=s)for(var o=0;o<this.plugs[s].connectsToPlugTypes.length;o++)v.includes(this.plugs[s].connectsToPlugTypes[o])&&(t=!0)}return e=t,e}hideNodes(e){if(!this.ref)return!1;const t=this.ref.getObjectByName("GRP_RenderGeometry"),n=this.ref.getObjectByName("GRP_ProxyMesh");return e.map(s=>{if(t){const o=t.getObjectByName(s);o&&(o.visible=!1)}if(n){const o=n.getObjectByName(s);o&&(o.visible=!1)}}),!0}showNodes(e){if(!this.ref)return!1;const t=this.ref.getObjectByName("GRP_RenderGeometry"),n=this.ref.getObjectByName("GRP_ProxyMesh");return e.map(s=>{if(t){const o=t.getObjectByName(s);o&&(o.visible=!0)}if(n){const o=n.getObjectByName(s);o&&(o.visible=!0)}}),!0}canConnectToPlugType(e){let t=!1;return this._plugs.map(n=>{n.connectsToPlugTypes.map(s=>{s==e&&(t=!0)})}),t}isConnectedToSkuID(e){let t=!1;return this._plugs.map(n=>{if(n.isOpen||t===!0)return;let s=n.attachedPlug;!s&&n.attachedPlugGUID&&(s=attachmentStore$1.getState().attachmentSystem.currentStructure.getPlugByGUID(n.attachedPlugGUID)),s.node.skuID==e&&(t=!0)}),t}get isConnectedToRoot(){return this.isConnectedToSkuID("Root")}swapRoot(){if(!this.canSwapRoot)return;const t=attachmentStore$1.getState().attachmentSystem.currentStructure,n=this.whichNodesAreAttachedToUs();let s=null;n.map(T=>{T.followsParent===!1&&(s=T)});const o=s.detachNodeFromReceiver();let v=null;this._plugs.map(T=>{T.isOpen||T.attachedPlug.node.skuID=="Root"&&(v=T.attachedPlug)});const A=this.detachNodeFromReceiver();let b=null;return s.plugs.map(T=>{T.connectsToPlugTypes.includes("root")&&(b=T)}),t.connectPlugs({incomingPlug:b,receiverPlug:v}),{neighbourDetachedPlugs:o,rootDetachedPlugs:A,neighbourNode:s}}get canSwapRoot(){if(sceneStore.getState().sceneSettings.swappableRoot===!1)return!1;let e=!1;if(this.isConnectedToRoot&&!this._isEndNode){const n=this.whichNodesAreAttachedToUs();let s=0,o=null;n.map(v=>{v.followsParent===!1&&(s++,o=v)}),s==1?o.canConnectToPlugType("root")&&(e=!0):s>0&&(e=!1)}return e}get canDrag(){let e=!0;return this._isEndNode||(this.whichNodesAreAttachedToUs().map(n=>{n.followsParent===!1&&(e=!1)}),e||(e=this.canSwapRoot)),e}get followsParent(){return this._followsParent}set followsParent(e){this._followsParent=e}get currentVariant(){return this.#t==="default"?productDataStore$1.getState().actions.getProductDataById(this._skuID).lookDetails.default.id:this.#t}get price(){return this._price}set price(e){this._price=e}updatePricing(){this._price=this.#a()}#a(){let t=productDataStore$1.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.price;return t||(t=0),t}set currentVariant(e){this.#t=e,this._price=this.#a()}get overrideVariant(){return this._overrideVariant}set overrideVariant(e){this._overrideVariant=e,this.#t=this._overrideVariant,this._price=this.#a()}get guid(){return this._guid}get skuID(){return this._skuID}set skuID(e){this._skuID=e}get plugs(){return this._plugs}get ref(){return this._ref}set ref(e){this._ref=e}get modelData(){return this._modelData}set modelData(e){this._modelData=e;let t=new CustomEvent(this._guid+":modelLoaded",{bubbles:!0,cancelable:!1,composed:!0});const n=attachmentStore$1.getState().attachmentSystem;n.globalGeometryVariants&&Object.keys(n.globalGeometryVariants).map(s=>{this.updateGeometryVariant(s,n.globalGeometryVariants[s])}),t.data={},CORE_API.coreWCRef?CORE_API.coreWCRef.dispatchEvent(t):LOGGER.warn({title:"core web component not found!"})}get isEndNode(){return this._isEndNode}set isEndNode(e){this._isEndNode=e}get categoryID(){return this._categoryID}get transform(){return this._transform}set transform(e){this._transform=e}setModelVisibility(e){e?this._ref?.scale.set(1,1,1):this._ref.scale.set(0,0,0)}checkIfEndNode(){let e=!0;for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&(e=!1);this.isEndNode=e}whichNodesAreAttachedToUs(){var e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&e.push(this._plugs[t].attachedPlug.node);return e}whichPlugsAreAttachedToUs(){var e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&e.push({receiverPlug:this._plugs[t],incomingPlug:this._plugs[t].attachedPlug});return e}whichNodeAreWeAttachedTo(){var e=null;for(let t=0;t<this._plugs.length;t++)this._plugs[t].isReceiverPlug&&(e=this._plugs[t].attachedPlug.node);return e}isReplaceableWithSkuId(e){const n=productDataStore$1.getState().productData[e]?.plugs;let s=0;if(!n)return!1;for(let o=0;o<this._plugs.length;o++)for(let v=0;v<n.length;v++)this._plugs[o].name==n[v].name&&s++;return s==this._plugs.length}whichPlugAreWeAttachedUsing(){for(let e=0;e<this._plugs.length;e++){const t=this._plugs[e];let n=t.attachedPlug;if(!n&&t.attachedPlugGUID&&(n=attachmentStore$1.getState().attachmentSystem.currentStructure.getPlugByGUID(t.attachedPlugGUID)),!t.isOpen&&n.isReceiverPlug)return n}}findRootPlugInNodeIfAny(){let e=null;for(const t of this._plugs)if(t.connectsToPlugTypes.includes("root")){e=t;break}return e}whichPlugAreWeAttachedTo(){for(let e=0;e<this._plugs.length;e++)if(!this._plugs[e].isOpen&&this._plugs[e].attachedPlug.isReceiverPlug)return this._plugs[e].attachedPlug}getPlugWhichCanConnectToType(e){for(const t of this._plugs)if(t.connectsToPlugTypes.includes(e))return t;return null}getOpenPlugsWeCanAttachFrom(){let e=[];if(this.whichNodeAreWeAttachedTo())return e;for(let t=0;t<this._plugs.length;t++)this.plugs[t].isOpen&&this.plugs[t].connectsToPlugTypes.length>0&&e.push(this._plugs[t]);return e}getOpenPlugsFromNode(){let e=[];for(let t=0;t<this._plugs.length;t++)this._plugs[t].isOpen&&this._plugs[t].acceptedPlugTypes.length>0&&e.push(this._plugs[t]);return e}generatePlugsForNode(e){this._plugs=[];let t=productDataStore$1.getState().productData[e]?.plugs;if(t)for(var n=0;n<t.length;n++){const s=new Plug(t[n],this);this._plugs.push(s)}}generatePlugsWithData(e,t){let n=productDataStore$1.getState().productData[e]?.plugs;if(n)for(var s=0;s<n.length;s++){const o=new Plug(n[s],this,t[n[s].name]);this._plugs.push(o)}}detachNodeFromReceiver(){for(var e=0;e<this.plugs.length;e++)if(!this.plugs[e].isOpen&&this.plugs[e].attachedPlug.isReceiverPlug){const t={incomingPlug:this.plugs[e],receiverPlug:this.plugs[e].attachedPlug};return this.plugs[e].attachedPlug.openPlug(),this.plugs[e].openPlug(),t}}detachNodeCompletely(){for(var e=0;e<this._plugs.length;e++)this._plugs[e].isOpen||(this._plugs[e].attachedPlug.openPlug(),this._plugs[e].openPlug())}getPlugByName(e){for(var t=0;t<this._plugs.length;t++)if(this._plugs[t].name==e)return this._plugs[t];return null}getPlugByGUID(e){for(var t=0;t<this._plugs.length;t++)if(this._plugs[t].guid==e)return this._plugs[t];return null}removeNode(){for(var e=0;e<this._plugs.length;e++)this._plugs[e].isOpen||(this._plugs[e].attachedPlug.isReceiverPlug?this._plugs[e].attachedPlug.openPlug():itemStore.getState().actions.addToRemoveItems(this._plugs[e].attachedPlug.node.guid))}};class Structure{#t=!1;constructor(e=null,t,n){if(this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:e}),e){LOGGER.info({title:"PRELOAD Length-----------------:"+e.length});for(var s=0;s<e.length;s++){LOGGER.info({title:"FOUND PRELOAD-----------------"});let o=e[s].skuID,v=new Node$1(o,e[s],t,n);o=="Root"&&(this._rootNode=v),this._nodes.push(v)}}else{const o=new Node$1("Root",null,t,n);this._rootNode=o,this._nodes.push(o)}itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1),this._boundingBoxLeeway=sceneStore.getState().sceneSettings.boundingBoxLeeway,this.setupCustomLogic()}async customLogic(){if(!["neighbor-bluff","neighbor-terra"].includes(CORE_API.projectId))return;const e={OM:{plugsToConsider:["OM_L_Plug"],geometryNodes:["OM_Legs_root"],rootPlug:"om_root"},ILTable:{plugsToConsider:["iltable_l_plug"],geometryNodes:["IL_Legs_root"],rootPlug:"il_root"}},t=Object.keys(e);for(const n of this._nodes){if(!t.includes(n.skuID))continue;let s=0;for(const o of n.plugs)if(o.name!==e[n.skuID].rootPlug&&(!e[n.skuID].plugsToConsider.includes(o.name)&&o.isOpen===!1&&s++,e[n.skuID].plugsToConsider.includes(o.name)&&o.isOpen===!1)){s=0;break}s>=1?n.hideNodes(e[n.skuID].geometryNodes)||CORE_API.coreWCRef.addEventListener(n.guid+":modelLoaded",()=>{n.hideNodes(e[n.skuID].geometryNodes)},{once:!0}):n.showNodes(e[n.skuID].geometryNodes)||CORE_API.coreWCRef.addEventListener(n.guid+":modelLoaded",()=>{n.showNodes(e[n.skuID].geometryNodes)},{once:!0})}}setupCustomLogic(){CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.customLogic()})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let e=0;e<this._nodes.length;e++)this._nodes[e].updatePricing()}getCurrentItemsInReplaceableCategory(){let e={};for(const t of this._nodes)t.replace&&(e[t.categoryID]=t.skuID);return e}recalculateStructureFromNode(e){for(let t=0;t<e.plugs.length;t++)if(!e.plugs[t].isOpen&&e.plugs[t].isReceiverPlug){const n=e.plugs[t].attachedPlug.node,s={receiverPlug:e.plugs[t],incomingPlug:e.plugs[t].attachedPlug};if(s){const o=this.findItemTransform(s);o&&(n.ref.position.set(o.position.x,o.position.y,o.position.z),n.ref.setRotationFromQuaternion(o.rotation),n.transform={position:o.position,rotation:o.rotation})}this.recalculateStructureFromNode(n)}}rotateNode(e){const t=this.getNodeByGUID(e);let n=null,s=null;for(let A=0;A<t.plugs.length;A++)if(!s&&!t.plugs[A].isOpen&&t.plugs[A].attachedPlug.isReceiverPlug){const b=t.plugs[A].attachedPlug.acceptedPlugTypes;s=t.plugs[A].attachedPlug;let T=[];for(let ee=A+1;ee<t.plugs.length;ee++)T.push(t.plugs[ee]);for(let ee=0;ee<A;ee++)T.push(t.plugs[ee]);for(let ee=0;ee<T.length;ee++)for(let re=0;re<T[ee].connectsToPlugTypes.length;re++)b.includes(T[ee].connectsToPlugTypes[re])&&(n=T[ee])}if(!n)return;t.detachNodeFromReceiver();const{position:o,rotation:v}=this.findItemTransform({receiverPlug:s,incomingPlug:n});t.ref.position.set(o.x,o.y,o.z),t.ref.setRotationFromQuaternion(v),t.transform={position:t.ref.position,rotation:v},this.connectPlugs({receiverPlug:s,incomingPlug:n}),this.recalculateStructureFromNode(t)}async load(e){this.resolvePlugConnections(e),await this.respawnItems()}materialOverrideExists(){let e=!1;return this.nodes.map(t=>{if(t.overrideVariant)return e=!0,!0}),e}findGhostTransformForReplacement(e,t){const n=attachmentStore$1.getState().attachmentSystem,s=t.whichPlugAreWeAttachedTo(),o=t.whichPlugAreWeAttachedUsing(),A=new Node$1(e,null,n.globalVariants,n.globalGeometryVariants).getPlugByName(o.name);if(!A)return{transforms:null,connectablePlugs:null};const b={incomingPlug:A,receiverPlug:s};let T=[],ee=this.findItemTransform(b);if(!ee)return{transforms:T,connectablePlugs:b};let{position:re,rotation:ie}=ee;return re&&ie&&T.push({position:re,rotation:ie,incomingPlugName:b.incomingPlug.name,receiverPlugName:b.receiverPlug.name,incomingPlugGUID:b.incomingPlug.guid,receiverPlugGUID:b.receiverPlug.guid}),{transforms:T,connectablePlugs:b}}findGhostTransforms(e,t){const n=this.getOpenPlugs();if(n.length<=0)return{transforms:[]};const s=attachmentStore$1.getState().attachmentSystem,o=productDataStore$1.getState().productData,v=new Node$1(e,null,s.globalVariants,s.globalGeometryVariants),A=this.getConnectablePlugs(v,n);let b=[];if(A.length<=0)return{transforms:[]};let T=[];for(let re=0;re<A.length;re++){let ie=this.findItemTransform(A[re]);if(!ie)continue;let{position:se,rotation:le}=ie;if(se&&le){let pe=t;Array.isArray(t)===!0&&(pe=!1),o[e].hasOwnProperty("ignoreSpawningCollision")&&(pe=o[e].ignoreSpawningCollision),(pe?!1:this.isColliding(v.skuID,ie,A[re].receiverPlug,t))||(T.push({position:se,rotation:le,incomingPlugName:A[re].incomingPlug.name,receiverPlugName:A[re].receiverPlug.name,incomingPlugGUID:A[re].incomingPlug.guid,receiverPlugGUID:A[re].receiverPlug.guid}),b.push(A[re]))}}let ee=[];for(let re=0;re<T.length;re++)ee.push(v);return{transforms:T,newNodes:ee,connectablePlugs:b}}resolvePlugConnections(e){for(let t=0;t<e.length;t++)Object.keys(e[t].plugs).map(n=>{let s=e[t].plugs[n].guid,o=this.getPlugInNodesByGUID(s);if(!o||o.attachedPlug)return;let v=e[t].plugs[n].attachedPlugGUID,A=this.getPlugInNodesByGUID(v);A&&(A.attachedPlug||(o.attachPlug(A,e[t].plugs[n].isReceiverPlug),A.attachPlug(o,!e[t].plugs[n].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let e=[this.rootNode];for(let t=0;t<e.length;t++){let s=e[t].whichPlugsAreAttachedToUs();for(let o=0;o<s.length;o++){let v=this.findItemTransformForPreload(s[o],s[o].receiverPlug.node.transform);v?await itemStore.getState().actions.addItemWithTransform(v,s[o].incomingPlug.node.skuID,s[o].incomingPlug.node.guid):LOGGER.warn({title:"Problem finding plug transform! "+s[o].name}),s[o].incomingPlug.node.transform=v,e.push(s[o].incomingPlug.node)}}CORE_API.fireEvent(CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded),sceneStore.getState().actions.triggerAutoFocus(),hotspotStore$1.getState().actions.checkHotspotHealth()}getPlugInNodesByGUID(e){for(let t=0;t<this._nodes.length;t++){let n=this._nodes[t].getPlugByGUID(e);if(n)return n}return null}export(){let e=[];for(let t=0;t<this._nodes.length;t++){let n=this._nodes[t].export();n&&e.push(n)}return e}async clear(){return new Promise(async(e,t)=>{!this._rootNode&&this._rootNode.isEndNode&&e(!0);let n=this._rootNode.whichNodeAreWeAttachedTo();this.#t=!0,CORE_API.coreWCRef.addEventListener(CORE_API.EVENTS.SCENE.Scene_Cleared,s=>e(s.data),{once:!0}),n?CORE_API.removeItemByGUID(n.guid,!0):(await wait(500),e(!0))})}getNodeByGUID(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e)return this._nodes[t];return null}getPlugByGUID(e){for(const t of this._nodes){const n=t.getPlugByGUID(e);if(n)return n}return null}findItemTransformForPreload(e,t){let{receiverPlug:n,incomingPlug:s}=e,o=n,v=s;if(o.node.skuID=="Root")return this.findItemTransformRoot(e);let A=null,b=null,T=new Object3D,ee=assetStore.getState().assets.items[o.node.skuID].proxy.data.scene.clone();T.add(ee);let{position:re,rotation:ie}=t;if(ee.position.set(re.x,re.y,re.z),ee.setRotationFromQuaternion(ie),b=ee,!b||(A=b.getObjectByName(o.name),!A))return;let se=new Vector3(0,0,0);A.getWorldPosition(se);let le=new Quaternion().identity();A.getWorldQuaternion(le);let pe=new Object3D;A.add(pe);let de=assetStore.getState().assets.items[v.node.skuID].proxy.data.scene.clone();de.position.set(se.x,se.y,se.z),de.applyQuaternion(le);let fe=new Vector3;fe.copy(ee.up).applyQuaternion(b.quaternion);let _e=new Vector3;_e.copy(de.up).applyQuaternion(le),_e.negate();let ve=new Quaternion().setFromUnitVectors(fe,_e);fe.round(),_e.round();let xe=fe.dot(_e);xe!==1&&xe!==-1&&de.applyQuaternion(ve);let De=de.getObjectByName(v.name),Le=new Quaternion().identity();De.getWorldQuaternion(Le);let Ue=new Vector3(0,1,0);Ue.applyQuaternion(Le);let Ge=new Vector3(0,1,0);Ge.applyQuaternion(le),Ge.negate();let Fe=new Quaternion().setFromUnitVectors(Ue,Ge);if(Ue.round(),Ge.round(),Ue.dot(Ge)!==-1)de.applyQuaternion(Fe);else{let Ur=new Vector3(0,1,0),lr=Ge.dot(Ur);if(lr!==1&&lr!==-1)de.rotateOnAxis(Ur,Math.PI);else{let hr=new Vector3(0,0,1),zn=Ge.dot(hr);if(zn!==1&&zn!==-1)de.rotateOnAxis(hr,Math.PI);else{let ar=new Vector3(1,0,0),Dr=Ge.dot(ar);Dr!==1&&Dr!==-1&&de.rotateOnAxis(ar,Math.PI)}}}let rn=de.getObjectByName(v.name),yn=new Vector3(rn.position.x,rn.position.y,rn.position.z);de.translateX(-yn.x),de.translateY(-yn.y),de.translateZ(-yn.z);let bt=new Vector3(0,0,0);de.getWorldPosition(bt);let sn=new Quaternion().identity();return de.getWorldQuaternion(sn),de=null,{position:bt,rotation:sn}}findItemTransformRoot(e){let{receiverPlug:t,incomingPlug:n}=e,s=n;const o=new Object3D;let v=o,A=new Vector3(0,0,0);v.getWorldPosition(A);let b=new Quaternion().identity(),T=new Object3D;T.position.set(0,0,0),o.add(T);let ee=assetStore.getState().assets.items[s.node.skuID].proxy.data.scene.clone();T.attach(ee),ee.translateX(A.x),ee.translateY(A.y),ee.translateZ(A.z);let re=ee.getObjectByName(s.name),ie=new Quaternion().identity();re.getWorldQuaternion(ie);const se=new Vector3(0,1,0);se.applyQuaternion(ie);const le=new Vector3(0,1,0);le.applyQuaternion(b);const pe=le.angleTo(se),de=new Vector3(0,0,0);de.crossVectors(le,se),de.round(),de.length()!==0&&ee.rotateOnAxis(de,pe);var fe=new Matrix4().extractRotation(ee.matrixWorld);let _e=new Vector3(re.position.x,re.position.y,re.position.z);_e.applyMatrix4(fe),ee.translateX(-_e.x),ee.translateY(-_e.y),ee.translateZ(-_e.z);let ve=new Vector3(0,0,0);ee.getWorldPosition(ve);let xe=new Quaternion().identity();return ee.getWorldQuaternion(xe),T.remove(ee),T=null,ee=null,{position:ve,rotation:xe}}findItemTransform(e){let{receiverPlug:t,incomingPlug:n}=e,s=t,o=n;if(s.node.skuID=="Root")return this.findItemTransformRoot(e);const v=s.node.transform;if(!v)return;const A=assetStore.getState().assets.items[s.node.skuID].proxy.data.scene.clone(),b=new Object3D;b.position.set(v.position.x,v.position.y,v.position.z),b.setRotationFromQuaternion(v.rotation),b.add(A);let T=b.getObjectByName(""+s.name);if(!T){LOGGER.error({title:"Plug: "+s.name+" doesn't exist in "+s.node.skuID});return}let ee=new Vector3(0,1,0);T.getWorldPosition(ee);let re=new Quaternion().identity();T.getWorldQuaternion(re);let ie=assetStore.getState().assets.items[o.node.skuID].proxy.data.scene.clone();ie.position.set(ee.x,ee.y,ee.z),ie.applyQuaternion(re);let se=new Vector3;se.copy(A.up).applyQuaternion(b.quaternion);let le=new Vector3;le.copy(ie.up).applyQuaternion(re),le.negate();let pe=new Quaternion().setFromUnitVectors(se,le);se.round(),le.round();let de=se.dot(le);de!==1&&de!==-1&&ie.applyQuaternion(pe);let fe=ie.getObjectByName(o.name);if(!fe){LOGGER.error({title:"Plug: "+o.name+" doesn't exist in "+o.node.skuID});return}let _e=new Quaternion().identity();fe.getWorldQuaternion(_e);let ve=new Vector3(0,1,0);ve.applyQuaternion(_e);let xe=new Vector3(0,1,0);xe.applyQuaternion(re),xe.negate();let De=new Quaternion().setFromUnitVectors(ve,xe);if(ve.round(),xe.round(),ve.dot(xe)!==-1)ie.applyQuaternion(De);else{let rn=new Vector3(0,1,0),yn=xe.dot(rn);if(yn!==1&&yn!==-1)ie.rotateOnAxis(rn,Math.PI);else{let bt=new Vector3(0,0,1),sn=xe.dot(bt);if(sn!==1&&sn!==-1)ie.rotateOnAxis(bt,Math.PI);else{let Ur=new Vector3(1,0,0),lr=xe.dot(Ur);lr!==1&&lr!==-1&&ie.rotateOnAxis(Ur,Math.PI)}}}let Ue=ie.getObjectByName(o.name),Ge=new Vector3(Ue.position.x,Ue.position.y,Ue.position.z);ie.translateX(-Ge.x),ie.translateY(-Ge.y),ie.translateZ(-Ge.z);let Fe=new Vector3(0,0,0);ie.getWorldPosition(Fe);let Ye=new Quaternion().identity();return ie.getWorldQuaternion(Ye),b.remove(A),ie=null,{position:Fe,rotation:Ye}}getSpawningRequirementForSkuID(e){let t=[];const n=productDataStore$1.getState().productData,s=n[e];if(!s)return t;const o=[];return s.plugs.map(v=>{v.connectsToPlugTypes.map(A=>{o.push(A)})}),Object.keys(n).map(v=>{for(let A=0;A<n[v].plugs.length;A++){const b=n[v].plugs[A].acceptedPlugTypes;for(let T=0;T<b.length;T++)o.map(ee=>{ee==b[T]&&!t.includes(v)&&t.push(v)})}}),t}getConnectablePlugs(e,t){let n=[],s=e.getOpenPlugsWeCanAttachFrom();for(let o=0;o<s.length;o++)for(let v=0;v<t.length;v++){let A=!1;for(let T=0;T<n.length;T++)if(n[T].receiverPlug.guid==t[v].guid){A=!0;break}if(A)continue;s[o].canAttachToPlug(t[v])&&n.push({incomingPlug:s[o],receiverPlug:t[v]})}return n}getOpenPlugs(){let e=[];return this._nodes.map(t=>{let n=t.getOpenPlugsFromNode();e=e.concat(n)}),e}checkCollisionforGUID(e){if(sceneStore.getState().sceneSettings.disableCollider)return!1;const t=itemStore.getState().itemsSpawned,n=productDataStore$1.getState().productData;if(!t[e])return!1;const o=this.getNodeByGUID(e);if(!o||!o.ref||n[o.skuID].disableCollider)return!1;const v={position:o.ref.position,rotation:o.ref.rotation},A=o.whichPlugAreWeAttachedTo();return A==null?!1:this.isColliding(o.skuID,v,A,[])}isColliding(e,{position:t,rotation:n},s,o=[]){const v=assetStore.getState().assets.items[e].proxy.data.scene,A=productDataStore$1.getState().productData;if(!v)return!1;let b=v.clone();b.position.set(t.x,t.y,t.z),b.setRotationFromQuaternion(n);let T=new Box3().setFromObject(b);var ee=new Vector3;T.getCenter(ee);let re=new Object3D;re.position.set(ee.x,ee.y,ee.z),re.attach(b),re.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),T=new Box3().setFromObject(re);const ie=[];if(this._nodes.forEach(le=>{s.node.guid!=le.guid&&(Array.isArray(o)===!0&&o.includes(le.guid)||le.ref&&((A[le.skuID].hasOwnProperty("disableCollider")?A[le.skuID].disableCollider:sceneStore.getState().sceneSettings.disableCollider)||ie.push(le.ref)))}),ie.length<=0)return!1;let se=!1;return ie.forEach(le=>{if(se)return;let pe=new Box3().setFromObject(le);if(T.intersectsBox(pe)){se=!0;return}}),re.clear(),b=null,re=null,T=null,se}boxOverlapPercent(e,t){if(e.containsBox(t)||t.containsBox(e))return 100;if(!(e.min.x<t.max.x||t.min.x<e.max.x))return 0;let n=new Vector3(0,0,0);e.getSize(n),n.x*n.y*n.z;let s=new Vector3(0,0,0);t.getSize(s),s.x*s.y*s.z}checkInsideOutCollision(e,t,n){let s=t.position.clone(),o=new Float32Array(n.attributes.position.array),v=o.length/3;for(let A=0;A<v;A++){let b=new Vector3(o[A*3],o[A*3+1],o[A*3+2]),T=b.add(t.position);T=b.applyQuaternion(t.quaternion);let ee=T.sub(t.position);const ie=new Raycaster(s,ee.clone().normalize()).intersectObjects(e),se=ie.length>0,le=ie[0].distance<ee.length();if(se&&le)return!0}return!1}addNode(e){this._nodes.push(e)}getFirstNodeByCategoryID(e){for(var t=0;t<this._nodes.length;t++)if(this._nodes[t]._categoryID==e)return this._nodes[t];return null}getNodesBySKUID(e){let t=[];for(var n=0;n<this._nodes.length;n++)this._nodes[n].skuID==e&&t.push(this._nodes[n]);return t}getNodesByCategoryID(e){let t=[];for(var n=0;n<this._nodes.length;n++)this._nodes[n]._categoryID==e&&t.push(this._nodes[n]);return t}connectPlugs({incomingPlug:e,receiverPlug:t}){e.attachPlug(t,!1),t.attachPlug(e,!0),attachmentStore$1.getState().actions.toggleStructureUpdated()}removeNodeByGUID(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e){this._nodes[t].removeNode(),this._nodes.splice(t,1);break}this._nodes.length==1&&this.#t&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.Scene_Cleared,!0),attachmentStore$1.getState().actions.updateFittingSkuIds(),attachmentStore$1.getState().actions.toggleStructureUpdated()}removeNodeFromStructure(e){for(let t=0;t<this._nodes.length;t++)if(this._nodes[t].guid==e.guid){this._nodes.splice(t,1);break}attachmentStore$1.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(){this._globalVariants={},this._globalGeometryVariants={},productDataStore$1.getState().categoryData.geometryVariants.map(e=>{this._globalGeometryVariants[e.id]=e.defaultVariant}),productDataStore$1.getState().categoryData.color.map(e=>{this._globalVariants[e.id]=e.defaultLook}),this._currentStructure=new Structure(null,this._globalVariants,this._globalGeometryVariants);for(const[e,t]of Object.entries(this._globalVariants))this.switchGlobalVariant(e,t);for(const[e,t]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(e,t)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(e,t){let n;return n=productDataStore$1.getState()?.productData[e]?.lookDetails[t],n?.clientProductId?n?.clientProductId:""}getCartItems(){let e=[];const t=inventoryStore.getState().inventoryData;this.currentStructure.nodes.map(o=>{if(o.skuID=="Root"||o.ignoreInCart===!0)return;let v=!1;if(e.map(T=>{const ee=t[T.skuID];if(T.skuID==o.skuID&&T.currentVariant==o.currentVariant){T.count++,T.countAvailable=ee[o.currentVariant].countAvailable,T.countUnavailable=ee[o.currentVariant].countUnavailable,T.price=o.price*T.count,v=!0;return}}),v===!0)return;let A={};A.skuID=o.skuID,A.currentVariant=o.currentVariant,A.clientProductId=this.getClientProductId(A.skuID,A.currentVariant),A.count=1;const b=t[A.skuID];A.price=o.price,A.countAvailable=b[o.currentVariant].countAvailable,A.countUnavailable=b[o.currentVariant].countUnavailable,e.push(A)});let n=0;for(const o of e)n=n+o.price;return{cartItems:e,details:{total:n.toFixed(2)}}}getFittingSKUIDs(){const e=productDataStore$1.getState().productData;if(!this.currentStructure)return;let t=this.currentStructure.nodes,n=[],s=[],o=[],v=[];if(t.map(b=>{v.push(b.skuID),b.plugs.map(T=>{if(!T.isOpen){T.attachedPlug.node.replace&&T.acceptedPlugTypes.map(ee=>{s.includes(ee)||s.push(ee)});return}T.acceptedPlugTypes.map(ee=>{n.includes(ee)||n.push(ee)})})}),n.length<=0&&s.length<=0)return[];Object.keys(e).map(b=>{!e[b].plugs||o.includes(b)||e[b].plugs.map(T=>{o.includes(b)||T.connectsToPlugTypes.map(ee=>{if(!o.includes(b)){if(s.includes(ee)){if(!v.includes(b)){let re=!1,ie=this.currentStructure.getFirstNodeByCategoryID(e[b].categoryID),se=!1;ie?.plugs.map(le=>{!le.isOpen&&le.isReceiverPlug&&(se=!0,e[b].plugs.map(pe=>{pe.name==le.name&&le.attachedPlug.connectsToPlugTypes.map(de=>{pe.acceptedPlugTypes.includes(de)&&(re=!0)})}))}),(re||!se)&&o.push(b)}}else if(n.includes(ee)){const re=this.currentStructure.getFirstNodeByCategoryID(e[b].categoryID);if(re&&re.replace)return;o.push(b)}}})})});let A=[];return o.map(b=>{if(A.includes(b))return;if(e[b].replace){A.push(b);return}const{transforms:T,newNodes:ee,connectablePlugs:re}=this.currentStructure.findGhostTransforms(b,sceneStore.getState().sceneSettings.ignoreSpawningCollision);T.length>0&&A.push(b)}),A.map(b=>{e[b].replace}),A}async removeAllVariantOverrides(){let e=this._currentStructure.nodes,t=productDataStore$1.getState().productData,n=itemStore.getState().itemsSpawned;await e.map(async s=>{if(!s.overrideVariant||(s.overrideVariant=null,!t[s.skuID].looks))return;let o=null;Object.keys(this._globalVariants).map(v=>{t[s.skuID].looks.includes(this._globalVariants[v])&&o==null&&(o=this._globalVariants[v])}),o&&await itemStore.getState().actions.switchToVariant(n[s.guid].itemData,o)}),CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1)}async switchGlobalGeometryVariant(e,t){const s=productDataStore$1.getState().categoryData.geometryVariants;let o=null;if(s.map(ie=>{ie.id==e&&(o=ie)}),!o)return;const v=o.productsInCategory,b=o.variants[t].productsToSwitch,T=itemStore.getState().itemsSpawned;let ee=productDataStore$1.getState().categoryData;b.map(ie=>{v.map(se=>{let le=!1;se.products.map(pe=>{ie==pe&&(le=!0)}),le&&ee.build.map(pe=>{se.products.map(de=>{pe.skus.map((fe,_e)=>{pe.skus[_e]==de&&(pe.skus[_e]=ie)})})})})}),this._currentStructure.nodes.map(ie=>{v.map(se=>{se.products.map(le=>{ie.skuID==le&&ie.ref!==null&&se.products.map(pe=>{b.map(de=>{if(de==pe){const fe=productDataStore$1.getState().actions.getProductDataById(de);ie.hideNodes(fe.geometriesToHide),ie.showNodes(fe.geometriesToShow),ie.skuID=de;const _e=T[ie.guid];_e&&_e.itemData&&Object.keys(fe).map(ve=>{_e.itemData[ve]=fe[ve]}),ie.resetInStock(),ie.updatePricing()}})})})})}),this._globalGeometryVariants[e]=t,hotspotStore$1.getState().actions.checkHotspotHealth(),inventoryStore.getState().actions.refreshInventory(T),productDataStore$1.setState({categoryData:ee}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CategoryData_Updated,ee),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const re=this.getCartItems();re&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,re)}async switchGlobalVariant(e,t){this._globalVariants[e]=t;const n=itemStore.getState().actions;let s=itemStore.getState().itemsSpawned;for(let b=0;b<Object.keys(s).length;b++){let T=s[Object.keys(s)[b]];if(T.itemData.looks&&T.itemData.looks.includes(t)){let ee=this._currentStructure.getNodeByGUID(T.itemData.guid);ee&&!ee.overrideVariant&&await n.switchToVariant(T.itemData,t)}}const o=productDataStore$1.getState().lookData;lightStore.getState().actions.processLookEnvMapOverride(t);const v=e;Object.keys(s).length>0&&CORE_API.alert({alertMsg:v.charAt(0).toUpperCase()+v.slice(1)+" was successfully switched to "+o[t].label+".",alertTime:3e3,alertType:"success",alertLabel:`${v} Changed`,alertId:"materialVariantChanged"}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),itemStore.setState({variantChangeAlert:!itemStore.getState().variantChangeAlert});const A=this.getCartItems();A&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,A)}async#t(e){if(!e)return;LOGGER.info({title:"Structure to load",details:e}),delete this._currentStructure,this._globalVariants={...e.globalVariants},this._globalGeometryVariants=e.globalGeometryVariants?{...e.globalGeometryVariants}:{};const t=[...e.structure];this._currentStructure=new Structure(t,this._globalVariants,this._globalGeometryVariants);for(const[n,s]of Object.entries(this._globalVariants))this.switchGlobalVariant(n,s);for(const[n,s]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(n,s);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(t),LOGGER.info({title:"Structure Loaded."})}async loadStructure(e){e&&(CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),sceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(e),sceneStore.getState().preconfigurationLoaded?CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide):sceneStore.setState({preconfigurationLoaded:!0}),sceneStore.setState({configurationLoaded:!0}),attachmentStore$1.getState().actions.toggleStructureUpdated())}export(){return{structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),this._currentStructure.clear(),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),itemStore.getState().selectedItemData&&itemStore.getState().actions.deselectItem(),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear();const e=attachmentStore$1.getState().defaultConfig;await this.#t(e),attachmentStore$1.getState().actions.toggleStructureUpdated(),sceneStore.setState({configurationLoaded:!0}),CORE_API.fireEvent(CORE_API.EVENTS.UI.PreloadScreen_Hide)}}const attachmentStore=create$3((a,e)=>({attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async()=>{const{actions:t,defaultConfig:n}=e(),s=await new AttachmentSystem;a({attachmentSystem:s}),t.updateFittingSkuIds(),t.toggleStructureUpdated()},loadSavedStructureFromConfigID:async t=>{const n=await getJSONFromEndpoint(FETCH_CONFIG_ENDPOINT+t);return n.success===!1?null:n.data},loadDefaultStructure:async()=>{const{actions:t,defaultConfig:n,attachmentSystem:s}=e();await t.loadStructure(n)},updateFittingSkuIds:()=>{const t=attachmentStore.getState().attachmentSystem.getFittingSKUIDs();t&&(itemStore.setState({fittingSkuIds:[...t]}),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:t}))},toggleStructureUpdated:()=>{const{attachmentSystem:t}=e();a(s=>({structureUpdated:!s.structureUpdated})),CORE_API.fireEvent(CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,t.currentStructure.getCurrentItemsInReplaceableCategory());const n=t.getCartItems();n&&CORE_API.fireEvent(CORE_API.EVENTS.SCENE.CartItems_Updated,n)},loadStructure:async t=>{const{attachmentSystem:n}=e();n&&sceneStore.getState().configurationLoaded!==!1&&await n.loadStructure(t)},export:()=>{const{attachmentSystem:t}=e();if(t)return t.export()}}})),attachmentStore$1=attachmentStore,productDataStore=create$3((a,e)=>({productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentPricingInfo:()=>{const{productData:t}=e();let n={};return Object.keys(t).map(s=>{if(s.toLowerCase()==="root")return;let o=t[s].lookDetails,v={};Object.keys(o).map(A=>{A!="default"&&(v[A]=o[A].price)}),n[s]=v}),n},updatePricingForAllProducts:t=>{const{actions:n}=e();Object.keys(t).map(s=>{let o=t[s];Object.keys(o).map(v=>{n.updatePricingForProduct(s,v,o[v])})})},updatePricingForProduct:(t,n,s)=>{const{productData:o}=e();let v=o[t];if(!v||!v.lookDetails)return;let A=v.lookDetails[n];if(!A)return;A.price=s,attachmentStore$1.getState().attachmentSystem.currentStructure.getNodesBySKUID(t).map(ee=>ee.updatePricing())},setProductData:t=>{let n={};t&&Object.keys(t).map(s=>{const o=t[s];if(o.skuID=s,o.skuID.toLowerCase()==="root"){o.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},o.defaultVariant="default";return}if(o?.lookDetails){const v=o.lookDetails;let A=Object.keys(o.lookDetails);if(A.includes("default")){const T=A.indexOf("default");A.splice(T,1)}o.looks=A,Object.keys(o.lookDetails).map(T=>{let ee=o.lookDetails[T];ee.inventory===void 0&&(ee.inventory=DEFAULT_INVENTORY),ee.price===void 0&&(ee.price=DEFAULT_PRODUCT_PRICE),n[s]={...n[s],[T]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let b=o?.defaultVariant;b||(LOGGER.warn({title:`No defaultVariant set for ${o.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),b=Object.keys(o.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+b})),A.includes(b)?(o.lookDetails.default=v[b],o.lookDetails.default.id=b):(LOGGER.error({title:`Default look [ ${b} ] doesn't exist for: ${s}. Please make sure to select a default variant in Input Data for this project`}),o.lookDetails.default=null)}}),LOGGER.info("PRODUCT DATA: ",t),inventoryStore.setState({inventoryData:n}),a({productData:t})},setCategoryData:t=>{const{productData:n}=e();t.geometryVariants!==void 0&&t.geometryVariants.map(s=>{s.defaultVariant===void 0&&Object.keys(s.variants).length>0&&(s.defaultVariant=Object.keys(s.variants)[0])}),t.color!==void 0&&t.color.map(s=>{(s.defaultLook===void 0&&s.looks.length>0||!s.looks.includes(s.defaultLook))&&(s.defaultLook=s.looks[0])}),a({categoryData:t}),t.build!==void 0&&t.build.map(s=>{s.skus.map(o=>{n[o].categoryID=s.categoryID,n[o].categoryLabel=s.label,n[o].swappable=s.swappable?s.swappable:!1,n[o].replace=s.replace})})},getProductDataById:t=>{const{productData:n}=e();let s=null;return n[t]&&(s=n[t]),s},setLookData:t=>a({lookData:t}),setHotspotsData:t=>{const{categoryData:n,productData:s}=e();n.geometryVariants&&Object.keys(t).map(o=>{t[o].map(v=>{v.geometryVariantID&&n.geometryVariants.map(A=>{Object.keys(A.variants).map(b=>{v.geometryVariantID==b&&A.productsInCategory.map(T=>{let ee=null;T.products.map(re=>{t.hasOwnProperty(re)&&(ee=t[re])}),T.products.map(re=>{t.hasOwnProperty(re)||(t[re]=ee)})})})})})}),a({hotspotsData:t})},setEndpoints:t=>{a({endpoints:t}),setGlobalEndpoints(t)},setAssetsData:t=>a({assetsData:t})}})),productDataStore$1=productDataStore,UtilityMenu=({handleShareButtonTrigger:a,handleSaveButtonTrigger:e,handleRestartButtonClick:t,handleShowHotspots:n,handleDimensionClick:s,handleInstructionButtonClick:o,utilityMenuVisible:v,hotspotsVisibility:A,viewInYourSpaceMenuBtnVisible:b,restartMenuBtnVisible:T,saveMenuBtnVisible:ee,hotspotsMenuBtnVisible:re,instructionsMenuBtnVisible:ie,dimensionsMenuBtnVisible:se,shareMenuBtnVisible:le,dimensionsVisible:pe,position:de,CORE_API:fe})=>{const[_e,ve]=reactExports.useState("bottom"),xe=productDataStore$1(Le=>Le.assetsData),De={ar:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/AR.svg",restart:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Restart.svg",save:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/save.svg",share:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Share.svg",dimensions:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Ruler.svg",hotspots:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Eye.svg",instructions:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/Info.svg"};return reactExports.useEffect(()=>{switch(de){case"top":ve("top");break;case"bottom":ve("bottom");break;case"left":ve("left");break;case"right":ve("right");break}return()=>{}},[de]),jsxDevRuntimeExports.jsxDEV("div",{className:"shellCanvasContainerParent",id:_e,children:jsxDevRuntimeExports.jsxDEV("div",{className:(v&&(le||b||T||se||re||ie))==!0?"shellCanvasContainer":"shellCanvasContainer shellCanvasContainerInactive",children:[b&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{fe.viewInYourSpace()},buttonLabel:"AR",hoverLabel:"View in Your Space",icon:xe?.icons?.utilityMenu?.viewInYourSpace?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.viewInYourSpace):De.ar},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:81,columnNumber:11},globalThis),T&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{t()},buttonLabel:"Restart",hoverLabel:"Restart",icon:xe?.icons?.utilityMenu?.restart?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.restart):De.restart},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:98,columnNumber:11},globalThis),ee&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{e()},buttonLabel:"Save",hoverLabel:"Save",icon:xe?.icons?.utilityMenu?.save?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.save):De.save},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:115,columnNumber:11},globalThis),le&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{a()},buttonLabel:"Share",hoverLabel:"Share",icon:xe?.icons?.utilityMenu?.share?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.share):De.share},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:132,columnNumber:11},globalThis),se&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{s()},buttonLabel:"Size",hoverLabel:"Size",icon:xe?.icons?.utilityMenu?.dimensions?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.dimensions):De.dimensions,activeCondition:pe},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:149,columnNumber:11},globalThis),re&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{n()},buttonLabel:"Hotspots",hoverLabel:"Hotspots",icon:xe?.icons?.utilityMenu?.hotspots?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.hotspots):De.hotspots,activeCondition:A},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:168,columnNumber:11},globalThis),ie&&jsxDevRuntimeExports.jsxDEV(UtilityMenuButton,{buttonAction:()=>{o()},buttonLabel:"Instructions",hoverLabel:"Instructions",icon:xe?.icons?.utilityMenu?.instructions?fe.getResolvedAssetUrl(xe?.icons?.utilityMenu?.instructions):De.instructions},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:187,columnNumber:11},globalThis)]},void 0,!0,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:67,columnNumber:7},globalThis)},void 0,!1,{fileName:"C:/Users/Tanay/Desktop/TANAY/GIT_REPOS/epigraph-configurator/src/ui/scripts/components/reactComponents/UtilityMenu.js",lineNumber:66,columnNumber:5},globalThis)};var propTypes$5={exports:{}},reactIs={exports:{}},reactIs_development={};/** @license React v16.13.1
8920
8920
  * react-is.development.js
8921
8921
  *
8922
8922
  * Copyright (c) Facebook, Inc. and its affiliates.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epigraph/configurator",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "Epigraph Configurator web component.",
5
5
  "keywords": [],
6
6
  "main": "./dist/index.js",