/*! For license information please see bundles.ec08aca4.js.LICENSE.txt */ "use strict";(self.webpackChunkalvanon_analytics_platform_frontend=self.webpackChunkalvanon_analytics_platform_frontend||[]).push([[1155],{5023(e,t,r){r.d(t,{EY:()=>J,PY:()=>C});var n=r(24922),a=r(10067),o=r(82242),i=r(40836),s=r(60713);const l=(0,a.kl)({name:"Typr Font Parser",dependencies:[function(){return"undefined"==typeof window&&(self.window=self),function(e){var t={parse:function(e){var r=t._bin,n=new Uint8Array(e);if("ttcf"==r.readASCII(n,0,4)){var a=4;r.readUshort(n,a),a+=2,r.readUshort(n,a),a+=2;var o=r.readUint(n,a);a+=4;for(var i=[],s=0;s>>r&1&&t++;return t},t._lctf.readClassDef=function(e,r){var n=t._bin,a=[],o=n.readUshort(e,r);if(r+=2,1==o){var i=n.readUshort(e,r);r+=2;var s=n.readUshort(e,r);r+=2;for(var l=0;l0&&(o.featureParams=a+i);var s=n.readUshort(e,r);r+=2,o.tab=[];for(var l=0;l0&&(o.default=t._lctf.readLangSysTable(e,a+i));var s=n.readUshort(e,r);r+=2;for(var l=0;l255?-1:t.CFF.glyphByUnicode(e,t.CFF.tableSE[r])},t.CFF.readEncoding=function(e,r,n){t._bin;var a=[".notdef"],o=e[r];if(r++,0!=o)throw"error: unknown encoding format: "+o;var i=e[r];r++;for(var s=0;s>4,v=15&c;if(15!=p&&d.push(p),15!=v&&d.push(v),15==v)break}for(var g="",y=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],m=0;m=i.xMax||i.yMin>=i.yMax)return null;if(i.noc>0){i.endPts=[];for(var s=0;s=1&&s.fmt<=2){u=o.readUshort(e,n),n+=2;var h=o.readUshort(e,n);n+=2;var f=t._lctf.numOfOnes(u),d=t._lctf.numOfOnes(h);if(1==s.fmt){s.pairsets=[];var c=o.readUshort(e,n);n+=2;for(var p=0;p=1&&s.fmt<=2){if(1==s.fmt)s.delta=o.readShort(e,n),n+=2;else if(2==s.fmt){var u=o.readUshort(e,n);n+=2,s.newg=o.readUshorts(e,n,u),n+=2*s.newg.length}}else if(2==r&&1==s.fmt){u=o.readUshort(e,n),n+=2,s.seqs=[];for(var h=0;h>>8;if(0!=(f&=15))throw"unknown kern table format: "+f;r=t.kern.readFormat0(e,r,l)}return l},t.kern.parseV1=function(e,r,n,a){var o=t._bin;o.readFixed(e,r),r+=4;var i=o.readUint(e,r);r+=4;for(var s={glyph1:[],rval:[]},l=0;l>>8;if(0!=(h&=15))throw"unknown kern table format: "+h;r=t.kern.readFormat0(e,r,s)}return s},t.kern.readFormat0=function(e,r,n){var a=t._bin,o=-1,i=a.readUshort(e,r);r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2;for(var s=0;s=a.map.length?0:a.map[t];if(4==a.format){for(var o=-1,i=0;it?0:65535&(0!=a.idRangeOffset[o]?a.glyphIdArray[t-a.startCount[o]+(a.idRangeOffset[o]>>1)-(a.idRangeOffset.length-o)]:t+a.idDelta[o])}if(12==a.format){if(t>a.groups[a.groups.length-1][1])return 0;for(i=0;i-1?t.U._simpleGlyph(a,n):t.U._compoGlyph(a,r,n))},t.U._simpleGlyph=function(e,r){for(var n=0;no)){for(var c=!0,p=0,v=0;vo)){for(c=!0,v=0;v>1,i.length=0,l=!0;else if("o3"==F||"o23"==F)i.length%2!=0&&!l&&(u=i.shift()+a.nominalWidthX),s+=i.length>>1,i.length=0,l=!0;else if("o4"==F)i.length>1&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),h&&t.U.P.closePath(o),c+=i.pop(),t.U.P.moveTo(o,d,c),h=!0;else if("o5"==F)for(;i.length>0;)d+=i.shift(),c+=i.shift(),t.U.P.lineTo(o,d,c);else if("o6"==F||"o7"==F)for(var w=i.length,C="o6"==F,_=0;_Math.abs(b-c)?d=S+i.shift():c=b+i.shift(),t.U.P.curveTo(o,p,v,g,y,x,k),t.U.P.curveTo(o,m,U,S,b,d,c));else if("o14"==F){if(i.length>0&&!l&&(u=i.shift()+n.nominalWidthX,l=!0),4==i.length){var P=i.shift(),A=i.shift(),O=i.shift(),I=i.shift(),B=t.CFF.glyphBySE(n,O),R=t.CFF.glyphBySE(n,I);t.U._drawCFF(n.CharStrings[B],r,n,a,o),r.x=P,r.y=A,t.U._drawCFF(n.CharStrings[R],r,n,a,o)}h&&(t.U.P.closePath(o),h=!1)}else if("o19"==F||"o20"==F)i.length%2!=0&&!l&&(u=i.shift()+a.nominalWidthX),s+=i.length>>1,i.length=0,l=!0,f+=s+7>>3;else if("o21"==F)i.length>2&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),c+=i.pop(),d+=i.pop(),h&&t.U.P.closePath(o),t.U.P.moveTo(o,d,c),h=!0;else if("o22"==F)i.length>1&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),d+=i.pop(),h&&t.U.P.closePath(o),t.U.P.moveTo(o,d,c),h=!0;else if("o25"==F){for(;i.length>6;)d+=i.shift(),c+=i.shift(),t.U.P.lineTo(o,d,c);p=d+i.shift(),v=c+i.shift(),g=p+i.shift(),y=v+i.shift(),d=g+i.shift(),c=y+i.shift(),t.U.P.curveTo(o,p,v,g,y,d,c)}else if("o26"==F)for(i.length%2&&(d+=i.shift());i.length>0;)p=d,v=c+i.shift(),d=g=p+i.shift(),c=(y=v+i.shift())+i.shift(),t.U.P.curveTo(o,p,v,g,y,d,c);else if("o27"==F)for(i.length%2&&(c+=i.shift());i.length>0;)v=c,g=(p=d+i.shift())+i.shift(),y=v+i.shift(),d=g+i.shift(),c=y,t.U.P.curveTo(o,p,v,g,y,d,c);else if("o10"==F||"o29"==F){var M="o10"==F?a:n;if(0==i.length)console.debug("error: empty stack");else{var E=i.pop(),L=M.Subrs[E+M.Bias];r.x=d,r.y=c,r.nStems=s,r.haveWidth=l,r.width=u,r.open=h,t.U._drawCFF(L,r,n,a,o),d=r.x,c=r.y,s=r.nStems,l=r.haveWidth,u=r.width,h=r.open}}else if("o30"==F||"o31"==F){var z=i.length,W=(G=0,"o31"==F);for(G+=z-(w=-3&z);G>>1|(21845&c)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,d[c]=((65280&p)>>>8|(255&p)<<8)>>>1}var v=function(e,t,n){for(var a=e.length,o=0,i=new r(t);o>>u]=h}else for(s=new r(a),o=0;o>>15-e[o]);return s},g=new t(288);for(c=0;c<144;++c)g[c]=8;for(c=144;c<256;++c)g[c]=9;for(c=256;c<280;++c)g[c]=7;for(c=280;c<288;++c)g[c]=8;var y=new t(32);for(c=0;c<32;++c)y[c]=5;var m=v(g,9,1),U=v(y,5,1),S=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},b=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},x=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},k=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],T=function(e,t,r){var n=new Error(t||k[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,T),!r)throw n;return n},F=function(e,s,l){var h=e.length;if(!h||l&&!l.l&&h<5)return s||new t(0);var d=!s||l,c=!l||l.i;l||(l={}),s||(s=new t(3*h));var p,g=function(e){var r=s.length;if(e>r){var n=new t(Math.max(2*r,e));n.set(s),s=n}},y=l.f||0,k=l.p||0,F=l.b||0,w=l.l,C=l.d,_=l.m,D=l.n,G=8*h;do{if(!w){l.f=y=b(e,k,1);var P=b(e,k+1,3);if(k+=3,!P){var A=e[(j=((p=k)/8|0)+(7&p&&1)+4)-4]|e[j-3]<<8,O=j+A;if(O>h){c&&T(0);break}d&&g(F+A),s.set(e.subarray(j,O),F),l.b=F+=A,l.p=k=8*O;continue}if(1==P)w=m,C=U,_=9,D=5;else if(2==P){var I=b(e,k,31)+257,B=b(e,k+10,15)+4,R=I+b(e,k+5,31)+1;k+=14;for(var M=new t(R),E=new t(19),L=0;L>>4)<16)M[L++]=j;else{var N=0,q=0;for(16==j?(q=3+b(e,k,3),k+=2,N=M[L-1]):17==j?(q=3+b(e,k,7),k+=3):18==j&&(q=11+b(e,k,127),k+=7);q--;)M[L++]=N}}var X=M.subarray(0,I),Y=M.subarray(I);_=S(X),D=S(Y),w=v(X,_,1),C=v(Y,D,1)}else T(1);if(k>G){c&&T(0);break}}d&&g(F+131072);for(var $=(1<<_)-1,Q=(1<>>4;if((k+=15&N)>G){c&&T(0);break}if(N||T(2),J<256)s[F++]=J;else{if(256==J){Z=k,w=null;break}var K=J-254;if(J>264){var ee=a[L=J-257];K=b(e,k,(1<>>4;if(te||T(3),k+=15&te,Y=f[re],re>3&&(ee=o[re],Y+=x(e,k)&(1<G){c&&T(0);break}d&&g(F+131072);for(var ne=F+K;Fe.length)&&(o=e.length);var i=new(e instanceof r?r:e instanceof n?n:t)(o-a);return i.set(e.subarray(a,o)),i}(s,0,F)},w=new t(0),C="undefined"!=typeof TextDecoder&&new TextDecoder;try{C.decode(w,{stream:!0})}catch(e){}return e.convert_streams=function(e){var t=new DataView(e),r=0;function n(){var e=t.getUint16(r);return r+=2,e}function a(){var e=t.getUint32(r);return r+=4,e}function o(e){y.setUint16(m,e),m+=2}function i(e){y.setUint32(m,e),m+=4}for(var s={signature:a(),flavor:a(),length:a(),numTables:n(),reserved:n(),totalSfntSize:a(),majorVersion:n(),minorVersion:n(),metaOffset:a(),metaLength:a(),metaOrigLength:a(),privOffset:a(),privLength:a()},l=0;Math.pow(2,l)<=s.numTables;)l++;l--;for(var u=16*Math.pow(2,l),h=16*s.numTables-u,f=12,d=[],c=0;c{let[o,i]=n.split("+");o=parseInt(o,36),i=i?parseInt(i,36):0,a.set(r+=o,e[t]);for(let n=i;n--;)a.set(++r,e[t])})}}return a.get(e)||32}const i=[null,"isol","init","fina","medi"];function s(e){const t=new Uint8Array(e.length);let r=32,n=1,a=-1;for(let i=0;i65535&&i++)}return t}function l(t,r){const n=t.GDEF&&t.GDEF.glyphClassDef;return n?e.U._getGlyphClass(r,n):0}function u(...e){for(let t=0;te.U.codeToGlyph(t,r)>0,forEachGlyph(a,o,u,h){let f=0;const c=1/d.unitsPerEm*o,p=function(t,r){const n=[];for(let a=0;a65535&&a++,n.push(e.U.codeToGlyph(t,o))}const a=t.GSUB;if(a){const{lookupList:t,featureList:o}=a;let l;const u=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws|ccmp)$/,h=[];o.forEach(a=>{if(u.test(a.tag))for(let o=0;o=0;t--)if(-1!==r[t]&&(!e||e(r[t])))return t;return-1}function i(e){return 1===l(t,e)}function s(e,t){for(let r=0;r<3;r++)n[3*t+r]+=e[r]||0}}(t,p);return p.forEach((i,s)=>{if(-1!==i){let a=n[i];if(!a){const{cmds:o,crds:s}=e.U.glyphToPath(t,i);let l,u,h,f,d="",c=0;for(let e=0,t=o.length;e1?",":"")+s[c++]}if(s.length){l=u=1/0,h=f=-1/0;for(let e=0,t=s.length;eh&&(h=t),r>f&&(f=r)}}else l=h=u=f=0;a=n[i]={index:i,advanceWidth:t.hmtx.aWidth[i],xMin:l,yMin:u,xMax:h,yMax:f,path:d}}h.call(null,a,f+g[3*s]*c,g[3*s+1]*c,v),f+=g[3*s+2]*c,u&&(f+=u*o)}v+=a.codePointAt(v)>65535?2:1}),f}};return d}(e.parse(n)[0])}}],init:(e,t,r)=>r(e(),t())}),u=(0,a.kl)({name:"FontResolver",dependencies:[function(e,t){const r=Object.create(null),n=Object.create(null);function a(t,a){let o=r[t];o?a(o):n[t]?n[t].push(a):(n[t]=[a],function(a){const o=e=>{console.error(`Failure loading font ${a}`,e)};try{const i=new XMLHttpRequest;i.open("get",a,!0),i.responseType="arraybuffer",i.onload=function(){if(i.status>=400)o(new Error(i.statusText));else if(i.status>0)try{const o=e(i.response);o.src=a,(e=>{e.src=t,r[t]=e,n[t].forEach(t=>t(e)),delete n[t]})(o)}catch(e){o(e)}},i.onerror=o,i.send()}catch(e){o(e)}}(t))}return function(e,n,{lang:o,fonts:i=[],style:s="normal",weight:l="normal",unicodeFontsURL:u}={}){const h=new Uint8Array(e.length),f=[];e.length||v();const d=new Map,c=[];if("italic"!==s&&(s="normal"),"number"!=typeof l&&(l="bold"===l?700:400),i&&!Array.isArray(i)&&(i=[i]),(i=i.slice().filter(e=>!e.lang||e.lang.test(o)).reverse()).length){const t=1,n=2;let o=0;!function s(l=0){for(let u=l,p=e.length;u0&&/\s/.test(e[u]))h[u]=h[u-1],o===n&&(c[c.length-1][1]=u);else for(let e=h[u],p=i.length;e<=p;e++)if(e===p)(o===n?c[c.length-1]:c[c.length]=[u,u])[1]=u,o=n;else{h[u]=e;const{src:n,unicodeRange:c}=i[e];if(!c||g(l,c)){const e=r[n];if(!e)return void a(n,()=>{s(u)});if(e.supportsCodePoint(l)){let r=d.get(e);"number"!=typeof r&&(r=f.length,f.push(e),d.set(e,r)),h[u]=r,o=t;break}}}l>65535&&u+1e.substring(t[0],t[1]+1)).join("\n");t.getFontsForString(r,{lang:o||void 0,style:s,weight:l,dataUrl:u}).then(({fontUrls:e,chars:t})=>{const r=f.length;let n=0;c.forEach(e=>{for(let a=0,o=e[1]-e[0];a<=o;a++)h[e[0]+a]=t[n++]+r;n++});let o=0;e.forEach((t,n)=>{a(t,t=>{f[n+r]=t,++o===e.length&&v()})})})}else v()}function v(){n({chars:h,fonts:f})}function g(e,t){for(let r=0;r>5;this.buckets.set(t,(this.buckets.get(t)||0)|1<<(31&e))},t.prototype.has=function(e){var t=this.buckets.get(e>>5);return void 0!==t&&!!(t&1<<(31&e))},t.prototype.serialize=function(){var e=[];return this.buckets.forEach(function(t,r){e.push((+r).toString(36)+":"+t.toString(36))}),e.join(",")},t.prototype.deserialize=function(e){var t=this;this.buckets.clear(),e.split(",").forEach(function(e){var r=e.split(":");t.buckets.set(parseInt(r[0],36),parseInt(r[1],36))})};var r=Math.pow(2,8),n=r-1,a=~n;function o(e){var t=function(e){return e&a}(e).toString(16),n=function(e){return(e&a)+r-1}(e).toString(16);return"codepoint-index/plane"+(e>>16)+"/"+t+"-"+n+".json"}function i(e,t){var r=e&n,a=t.codePointAt(r/6|0);return!!((a=(a||48)-48)&1<65535&&(t++,C=t)},C=0;C65535&&(t++,r=t)},r=0;r65535&&(n++,U[n]=U[n-1])}return{fontUrls:Array.from(m.keys()),chars:U}})},Object.defineProperty(e,"__esModule",{value:!0}),e}({})}],init:(e,t,r)=>e(t,r())}),h=()=>(self.performance||Date).now(),f=(0,o.A)();let d;const c=[];let p=0;function v(){const e=h();for(;c.length&&h()-e<5;)c.shift()();p=c.length?setTimeout(v,0):0}const g={};let y=0;function m(e,t,r,n,i,s,l,u,d,c){const p="TroikaTextSDFGenerator_JS_"+y++%4;let v=g[p];return v||(v=g[p]={workerModule:(0,a.kl)({name:p,workerId:p,dependencies:[o.A,h],init(e,t){const r=e().javascript.generate;return function(...e){const n=t();return{textureData:r(...e),timing:t()-n}}},getTransferables:e=>[e.textureData.buffer]}),requests:0,idleTimer:null}),v.requests++,clearTimeout(v.idleTimer),v.workerModule(e,t,r,n,i,s).then(({textureData:r,timing:n})=>{const o=h(),i=new Uint8Array(4*r.length);for(let e=0;e{(0,a.Qw)(p)},2e3)),{timing:n}})}const U=f.webglUtils.resizeWebGLCanvasWithoutClearing,S={defaultFontURL:null,unicodeFontsURL:null,sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048,useWorker:!0},b=new n.Q1f;let x=!1;function k(){return(self.performance||Date).now()}const T=Object.create(null);function F(e,t){x=!0,e=function(e,t){for(let r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}({},e);const r=k(),{defaultFontURL:a}=S,o=[];if(a&&o.push({label:"default",src:D(a)}),e.font&&o.push({label:"user",src:D(e.font)}),e.font=o,e.text=""+e.text,e.sdfGlyphSize=e.sdfGlyphSize||S.sdfGlyphSize,e.unicodeFontsURL=e.unicodeFontsURL||S.unicodeFontsURL,null!=e.colorRanges){let t={};for(let r in e.colorRanges)if(e.colorRanges.hasOwnProperty(r)){let n=e.colorRanges[r];"number"!=typeof n&&(n=b.set(n).getHex()),t[r]=n}e.colorRanges=t}Object.freeze(e);const{textureWidth:i,sdfExponent:s}=S,{sdfGlyphSize:l}=e,u=i/l*4;let h=T[l];if(!h){const e=document.createElement("canvas");e.width=i,e.height=256*l/u,h=T[l]={glyphCount:0,sdfGlyphSize:l,sdfCanvas:e,sdfTexture:new n.gPd(e,void 0,void 0,void 0,n.k6q,n.k6q),contextLost:!1,glyphsByFont:new Map},h.sdfTexture.generateMipmaps=!1,function(e){const t=e.sdfCanvas;t.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),e.contextLost=!0}),t.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),e.contextLost=!1;const r=[];e.glyphsByFont.forEach(t=>{t.forEach(t=>{r.push(w(t,e,!0))})}),Promise.all(r).then(()=>{G(e),e.sdfTexture.needsUpdate=!0})})}(h)}const{sdfTexture:d,sdfCanvas:c}=h;(S.useWorker?A:O)(e).then(n=>{const{glyphIds:a,glyphFontIndices:o,fontData:f,glyphPositions:p,fontSize:v,timings:g}=n,y=[],m=new Float32Array(4*a.length);let b=0,x=0;const T=k(),F=f.map(e=>{let t=h.glyphsByFont.get(e.src);return t||h.glyphsByFont.set(e.src,t=new Map),t});a.forEach((e,t)=>{const r=o[t],{src:i,unitsPerEm:s}=f[r];let u=F[r].get(e);if(!u){const{path:t,pathBounds:a}=n.glyphData[i][e],o=Math.max(a[2]-a[0],a[3]-a[1])/l*(S.sdfMargin*l+.5),s=h.glyphCount++,f=[a[0]-o,a[1]-o,a[2]+o,a[3]+o];F[r].set(e,u={path:t,atlasIndex:s,sdfViewBox:f}),y.push(u)}const{sdfViewBox:d}=u,c=p[x++],g=p[x++],U=v/s;m[b++]=c+d[0]*U,m[b++]=g+d[1]*U,m[b++]=c+d[2]*U,m[b++]=g+d[3]*U,a[t]=u.atlasIndex}),g.quads=(g.quads||0)+(k()-T);const C=k();g.sdf={};const _=c.height,D=Math.ceil(h.glyphCount/u),P=Math.pow(2,Math.ceil(Math.log2(D*l)));P>_&&(console.info(`Increasing SDF texture size ${_}->${P}`),U(c,i,P),d.dispose()),Promise.all(y.map(t=>w(t,h,e.gpuAccelerateSDF).then(({timing:e})=>{g.sdf[t.atlasIndex]=e}))).then(()=>{y.length&&!h.contextLost&&(G(h),d.needsUpdate=!0),g.sdfTotal=k()-C,g.total=k()-r,t(Object.freeze({parameters:e,sdfTexture:d,sdfGlyphSize:l,sdfExponent:s,glyphBounds:m,glyphAtlasIndices:a,glyphColors:n.glyphColors,caretPositions:n.caretPositions,chunkedBounds:n.chunkedBounds,ascender:n.ascender,descender:n.descender,lineHeight:n.lineHeight,capHeight:n.capHeight,xHeight:n.xHeight,topBaseline:n.topBaseline,blockBounds:n.blockBounds,visibleBounds:n.visibleBounds,timings:n.timings}))})}),Promise.resolve().then(()=>{var e;h.contextLost||(e=c)._warm||(f.webgl.isSupported(e),e._warm=!0)})}function w({path:e,atlasIndex:t,sdfViewBox:r},{sdfGlyphSize:n,sdfCanvas:a,contextLost:o},i){if(o)return Promise.resolve({timing:-1});const{textureWidth:s,sdfExponent:l}=S,u=Math.max(r[2]-r[0],r[3]-r[1]),g=Math.floor(t/4);return function(e,t,r,n,a,o,i,s,l,u,g=!0){return g?((...e)=>new Promise((t,r)=>{c.push(()=>{const n=h();try{f.webgl.generateIntoCanvas(...e),t({timing:h()-n})}catch(e){r(e)}}),p||(p=setTimeout(v,0))}))(e,t,r,n,a,o,i,s,l,u).then(null,h=>(d||(console.warn("WebGL SDF generation failed, falling back to JS",h),d=!0),m(e,t,r,n,a,o,i,s,l,u))):m(e,t,r,n,a,o,i,s,l,u)}(n,n,e,r,u,l,a,g%(s/n)*n,Math.floor(g/(s/n))*n,t%4,i)}function C({font:e,characters:t,sdfGlyphSize:r},n){F({font:e,sdfGlyphSize:r,text:Array.isArray(t)?t.join("\n"):""+t},n)}let _;function D(e){return _||(_="undefined"==typeof document?{}:document.createElement("a")),_.href=e,_.href}function G(e){if("function"!=typeof createImageBitmap){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:t,sdfTexture:r}=e,{width:n,height:a}=t,o=e.sdfCanvas.getContext("webgl");let i=r.image.data;i&&i.length===n*a*4||(i=new Uint8Array(n*a*4),r.image={width:n,height:a,data:i},r.flipY=!1,r.isDataTexture=!0),o.readPixels(0,0,n,a,o.RGBA,o.UNSIGNED_BYTE,i)}}const P=(0,a.kl)({name:"Typesetter",dependencies:[function(e,t){const r=1/0,n=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,a="[^\\S\\u00A0]",o=new RegExp(`${a}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);function i({text:i="",font:f,lang:d,sdfGlyphSize:c=64,fontSize:p=400,fontWeight:v=1,fontStyle:g="normal",letterSpacing:y=0,lineHeight:m="normal",maxWidth:U=r,direction:S,textAlign:b="left",textIndent:x=0,whiteSpace:k="normal",overflowWrap:T="normal",anchorX:F=0,anchorY:w=0,metricsOnly:C=!1,unicodeFontsURL:_,preResolvedFonts:D=null,includeCaretPositions:G=!1,chunkedBoundsSize:P=8192,colorRanges:A=null},O){const I=u(),B={fontLoad:0,typesetting:0};i.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),i=i.replace(/\r\n/g,"\n").replace(/\r/g,"\n")),p=+p,y=+y,U=+U,m=m||"normal",x=+x,function({text:t,lang:r,fonts:n,style:a,weight:o,preResolvedFonts:i,unicodeFontsURL:s},l){const u=({chars:e,fonts:t})=>{let r,n;const a=[];for(let o=0;o{B.fontLoad=u()-I;const f=isFinite(U);let d=null,c=null,v=null,g=null,_=null,D=null,R=null,M=null,E=0,L=0,z="nowrap"!==k;const W=new Map,V=u();let j=x,H=0,N=new h;const q=[N];e.forEach(e=>{const{fontObj:t}=e,{ascender:r,descender:s,unitsPerEm:l,lineGap:u,capHeight:d,xHeight:c}=t;let v=W.get(t);if(!v){const e=p/l,n="normal"===m?(r-s+u)*e:m*p,a=(n-(r-s)*e)/2,o=Math.min(n,(r-s)*e),i=(r+s)/2*e+o/2;v={index:W.size,src:t.src,fontObj:t,fontSizeMult:e,unitsPerEm:l,ascender:r*e,descender:s*e,capHeight:d*e,xHeight:c*e,lineHeight:n,baseline:-a-r*e,caretTop:i,caretBottom:i-o},W.set(t,v)}const{fontSizeMult:g}=v,S=i.slice(e.start,e.end+1);let b,k;t.forEachGlyph(S,p,y,(t,r,s,l)=>{r+=H,l+=e.start,b=r,k=t;const u=i.charAt(l),d=t.advanceWidth*g,c=N.count;let m;if("isEmpty"in t||(t.isWhitespace=!!u&&new RegExp(a).test(u),t.canBreakAfter=!!u&&o.test(u),t.isEmpty=t.xMin===t.xMax||t.yMin===t.yMax||n.test(u)),t.isWhitespace||t.isEmpty||L++,z&&f&&!t.isWhitespace&&r+d+j>U&&c){if(N.glyphAt(c-1).glyphObj.canBreakAfter)m=new h,j=-r;else for(let e=c;e--;){if(0===e&&"break-word"===T){m=new h,j=-r;break}if(N.glyphAt(e).glyphObj.canBreakAfter){m=N.splitAt(e+1);const t=m.glyphAt(0).x;j-=t;for(let e=m.count;e--;)m.glyphAt(e).x-=t;break}}m&&(N.isSoftWrapped=!0,N=m,q.push(N),E=U)}let S=N.glyphAt(N.count);S.glyphObj=t,S.x=r+j,S.y=s,S.width=d,S.charIndex=l,S.fontData=v,"\n"===u&&(N=new h,q.push(N),j=-(r+d+y*p)+x)}),H=b+k.advanceWidth*g+y*p});let X=0;q.forEach(e=>{let t=!0;for(let r=e.count;r--;){const n=e.glyphAt(r);t&&!n.glyphObj.isWhitespace&&(e.width=n.x+n.width,e.width>E&&(E=e.width),t=!1);let{lineHeight:a,capHeight:o,xHeight:i,baseline:s}=n.fontData;a>e.lineHeight&&(e.lineHeight=a);const l=s-e.baseline;l<0&&(e.baseline+=l,e.cap+=l,e.ex+=l),e.cap=Math.max(e.cap,e.baseline+o),e.ex=Math.max(e.ex,e.baseline+i)}e.baseline-=X,e.cap-=X,e.ex-=X,X+=e.lineHeight});let Y=0,$=0;if(F&&("number"==typeof F?Y=-F:"string"==typeof F&&(Y=-E*("left"===F?0:"center"===F?.5:"right"===F?1:s(F)))),w&&("number"==typeof w?$=-w:"string"==typeof w&&($="top"===w?0:"top-baseline"===w?-q[0].baseline:"top-cap"===w?-q[0].cap:"top-ex"===w?-q[0].ex:"middle"===w?X/2:"bottom"===w?X:"bottom-baseline"===w?-q[q.length-1].baseline:s(w)*X)),!C){const e=t.getEmbeddingLevels(i,S);d=new Uint16Array(L),c=new Uint8Array(L),v=new Float32Array(2*L),g={},R=[r,r,-1/0,-1/0],M=[],G&&(D=new Float32Array(4*i.length)),A&&(_=new Uint8Array(3*L));let n,a,o=0,s=-1,u=-1;if(q.forEach((h,f)=>{let{count:p,width:y}=h;if(p>0){let f=0;for(let e=p;e--&&h.glyphAt(e).glyphObj.isWhitespace;)f++;let m=0,U=0;if("center"===b)m=(E-y)/2;else if("right"===b)m=E-y;else if("justify"===b&&h.isSoftWrapped){let e=0;for(let t=p-f;t--;)h.glyphAt(t).glyphObj.isWhitespace&&e++;U=(E-y)/e}if(U||m){let e=0;for(let t=0;t=t){let t=e,o=e;for(;or)break;ox=e;for(let f=0;f1&&l(D,s,a),s=e}if(A){const{charIndex:e}=p;for(;e>u;)u++,A.hasOwnProperty(u)&&(a=A[u])}if(!x.isWhitespace&&!x.isEmpty){const e=o++,{fontSizeMult:t,src:i,index:s}=p.fontData,l=g[i]||(g[i]={});l[y]||(l[y]={path:x.path,pathBounds:[x.xMin,x.yMin,x.xMax,x.yMax]});const u=p.x+Y,f=p.y+h.baseline+$;v[2*e]=u,v[2*e+1]=f;const m=u+x.xMin*t,U=f+x.yMin*t,S=u+x.xMax*t,b=f+x.yMax*t;mR[2]&&(R[2]=S),b>R[3]&&(R[3]=b),e%P===0&&(n={start:e,end:e,rect:[r,r,-1/0,-1/0]},M.push(n)),n.end++;const k=n.rect;if(mk[2]&&(k[2]=S),b>k[3]&&(k[3]=b),d[e]=y,c[e]=s,A){const t=3*e;_[t]=a>>16&255,_[t+1]=a>>8&255,_[t+2]=255&a}}}}}),D){const e=i.length-s;e>1&&l(D,s,e)}}const Q=[];W.forEach(({index:e,src:t,unitsPerEm:r,ascender:n,descender:a,lineHeight:o,capHeight:i,xHeight:s})=>{Q[e]={src:t,unitsPerEm:r,ascender:n,descender:a,lineHeight:o,capHeight:i,xHeight:s}}),B.typesetting=u()-V,O({glyphIds:d,glyphFontIndices:c,glyphPositions:v,glyphData:g,fontData:Q,caretPositions:D,glyphColors:_,chunkedBounds:M,fontSize:p,topBaseline:$+q[0].baseline,blockBounds:[Y,$-X,Y+E,$],visibleBounds:R,timings:B})})}function s(e){let t=e.match(/^([\d.]+)%$/),r=t?parseFloat(t[1]):NaN;return isNaN(r)?0:r/100}function l(e,t,r){const n=e[4*t],a=e[4*t+1],o=e[4*t+2],i=e[4*t+3],s=(a-n)/r;for(let a=0;a(Object.defineProperty(e,t,{get(){return this.data[this.index*f.length+r]},set(e){this.data[this.index*f.length+r]=e}}),e),{data:null,index:0}),{typeset:i,measure:function(e,t){i({...e,metricsOnly:!0},e=>{const[r,n,a,o]=e.blockBounds;t({width:a-r,height:o-n})})}}},u,i.A],init:(e,t,r)=>e(t,r())}),A=(0,a.kl)({name:"Typesetter",dependencies:[P],init:e=>function(t){return new Promise(r=>{e.typeset(t,r)})},getTransferables(e){const t=[];for(let r in e)e[r]&&e[r].buffer&&t.push(e[r].buffer);return t}}),O=A.onMainThread,I={},B="aTroikaGlyphIndex";class R extends n.CmU{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new n.iyt,this.boundingBox=new n.NRn}computeBoundingSphere(){}computeBoundingBox(){}set detail(e){if(e!==this._detail){this._detail=e,("number"!=typeof e||e<1)&&(e=1);let t=function(e){let t=I[e];return t||(t=I[e]=new n.bdM(1,1,e,e).translate(.5,.5,0)),t}(e);["position","normal","uv"].forEach(e=>{this.attributes[e]=t.attributes[e].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,r,n,a){this.updateAttributeData("aTroikaGlyphBounds",e,4),this.updateAttributeData(B,t,1),this.updateAttributeData("aTroikaGlyphColor",a,3),this._blockBounds=r,this._chunkedBounds=n,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:r}=this;if(t){const{PI:n,floor:a,min:o,max:i,sin:s,cos:l}=Math,u=n/2,h=2*n,f=Math.abs(t),d=e[0]/f,c=e[2]/f,p=a((d+u)/h)!==a((c+u)/h)?-f:o(s(d)*f,s(c)*f),v=a((d-u)/h)!==a((c-u)/h)?f:i(s(d)*f,s(c)*f),g=a((d+n)/h)!==a((c+n)/h)?2*f:i(f-l(d)*f,f-l(c)*f);r.min.set(p,e[1],t<0?-g:0),r.max.set(v,e[3],t<0?0:g)}else r.min.set(e[0],e[1],0),r.max.set(e[2],e[3],0);r.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(B).count,r=this._chunkedBounds;if(r)for(let n=r.length;n--;){t=r[n].end;let a=r[n].rect;if(a[1]e.y&&a[0]e.x)break}this.instanceCount=t}updateAttributeData(e,t,r){const a=this.getAttribute(e);t?a&&a.array.length===t.length?(a.array.set(t),a.needsUpdate=!0):(this.setAttribute(e,new n.uWO(t,r)),delete this._maxInstanceCount,this.dispose()):a&&this.deleteAttribute(e)}}const M=new n.V9B({color:16777215,side:n.$EB,transparent:!0}),E=8421504,L=new n.kn4,z=new n.Pq0,W=new n.Pq0,V=[],j=new n.Pq0,H="+x+y";function N(e){return Array.isArray(e)?e[0]:e}let q=()=>{const e=new n.eaF(new n.bdM(1,1),M);return q=()=>e,e},X=()=>{const e=new n.eaF(new n.bdM(1,1,32,1),M);return X=()=>e,e};const Y={type:"syncstart"},$={type:"synccomplete"},Q=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],Z=Q.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");class J extends n.eaF{constructor(){super(new R,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=E,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=H,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(Y),F({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const r=this._queuedSyncs;r&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{r.forEach(e=>e&&e())})),this.dispatchEvent($),e&&e()})))}onBeforeRender(e,t,r,n,a,o){this.sync(),a.isTroikaTextMaterial&&this._prepareForRender(a)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return function(e){const t=(0,s.Fh)(e,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new n.I9Y},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new n.IUQ(0,0,0,0)},uTroikaClipRect:{value:new n.IUQ(0,0,0,0)},uTroikaEdgeOffset:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new n.I9Y},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new n.Q1f},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new n.dwI},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform vec4 uTroikaTotalBounds;\nuniform vec4 uTroikaClipRect;\nuniform mat3 uTroikaOrient;\nuniform bool uTroikaUseGlyphColors;\nuniform float uTroikaEdgeOffset;\nuniform float uTroikaBlurRadius;\nuniform vec2 uTroikaPositionOffset;\nuniform float uTroikaCurveRadius;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nattribute vec3 aTroikaGlyphColor;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec3 vTroikaGlyphColor;\nvarying vec2 vTroikaGlyphDimensions;\n",vertexTransform:"\nvec4 bounds = aTroikaGlyphBounds;\nbounds.xz += uTroikaPositionOffset.x;\nbounds.yw -= uTroikaPositionOffset.y;\n\nvec4 outlineBounds = vec4(\n bounds.xy - uTroikaEdgeOffset - uTroikaBlurRadius,\n bounds.zw + uTroikaEdgeOffset + uTroikaBlurRadius\n);\nvec4 clippedBounds = vec4(\n clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),\n clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)\n);\n\nvec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);\n\nposition.xy = mix(bounds.xy, bounds.zw, clippedXY);\n\nuv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);\n\nfloat rad = uTroikaCurveRadius;\nif (rad != 0.0) {\n float angle = position.x / rad;\n position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);\n normal.xz = vec2(sin(angle), cos(angle));\n}\n \nposition = uTroikaOrient * position;\nnormal = uTroikaOrient * normal;\n\nvTroikaGlyphUV = clippedXY.xy;\nvTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);\n\n\nfloat txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;\nvec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;\nvec2 txStartUV = txUvPerSquare * vec2(\n mod(floor(aTroikaGlyphIndex / 4.0), txCols),\n floor(floor(aTroikaGlyphIndex / 4.0) / txCols)\n);\nvTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);\nvTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);\n",fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform float uTroikaSDFExponent;\nuniform float uTroikaEdgeOffset;\nuniform float uTroikaFillOpacity;\nuniform float uTroikaBlurRadius;\nuniform vec3 uTroikaStrokeColor;\nuniform float uTroikaStrokeWidth;\nuniform float uTroikaStrokeOpacity;\nuniform bool uTroikaSDFDebug;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec2 vTroikaGlyphDimensions;\n\nfloat troikaSdfValueToSignedDistance(float alpha) {\n // Inverse of exponential encoding in webgl-sdf-generator\n \n float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);\n float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;\n float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);\n return signedDist;\n}\n\nfloat troikaGlyphUvToSdfValue(vec2 glyphUV) {\n vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);\n vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);\n float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1\n return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;\n}\n\nfloat troikaGlyphUvToDistance(vec2 uv) {\n return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));\n}\n\nfloat troikaGetAADist() {\n \n #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;\n #else\n return vTroikaGlyphDimensions.x / 64.0;\n #endif\n}\n\nfloat troikaGetFragDistValue() {\n vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);\n float distance = troikaGlyphUvToDistance(clampedGlyphUV);\n \n // Extrapolate distance when outside bounds:\n distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : \n length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);\n\n \n\n return distance;\n}\n\nfloat troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {\n #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)\n float alpha = step(-distanceOffset, -distance);\n #else\n\n float alpha = smoothstep(\n distanceOffset + aaDist,\n distanceOffset - aaDist,\n distance\n );\n #endif\n\n return alpha;\n}\n",fragmentColorTransform:"\nfloat aaDist = troikaGetAADist();\nfloat fragDistance = troikaGetFragDistValue();\nfloat edgeAlpha = uTroikaSDFDebug ?\n troikaGlyphUvToSdfValue(vTroikaGlyphUV) :\n troikaGetEdgeAlpha(fragDistance, uTroikaEdgeOffset, max(aaDist, uTroikaBlurRadius));\n\n#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)\nvec4 fillRGBA = gl_FragColor;\nfillRGBA.a *= uTroikaFillOpacity;\nvec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);\nif (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;\ngl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(\n -uTroikaStrokeWidth - aaDist,\n -uTroikaStrokeWidth + aaDist,\n fragDistance\n));\ngl_FragColor.a *= edgeAlpha;\n#endif\n\nif (edgeAlpha == 0.0) {\n discard;\n}\n",customRewriter({vertexShader:e,fragmentShader:t}){let r=/\buniform\s+vec3\s+diffuse\b/;return r.test(t)&&(t=t.replace(r,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),r.test(e)||(e=e.replace(s.Do,"uniform vec3 diffuse;\n$&\nvTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;\n"))),{vertexShader:e,fragmentShader:t}}});return t.transparent=!0,t.forceSinglePass=!0,Object.defineProperties(t,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),t}(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=M.clone());if(e&&e.isDerivedFrom(t)||(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function r(){t.removeEventListener("dispose",r),e.dispose()})),this.hasOutline()){let t=e._outlineMtl;return t||(t=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),t.isTextOutlineMaterial=!0,t.depthWrite=!1,t.map=null,e.addEventListener("dispose",function r(){e.removeEventListener("dispose",r),t.dispose()})),[t,e]}return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return N(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return N(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,r=e.uniforms,a=this.textRenderInfo;if(a){const{sdfTexture:e,blockBounds:n}=a;r.uTroikaSDFTexture.value=e,r.uTroikaSDFTextureSize.value.set(e.image.width,e.image.height),r.uTroikaSDFGlyphSize.value=a.sdfGlyphSize,r.uTroikaSDFExponent.value=a.sdfExponent,r.uTroikaTotalBounds.value.fromArray(n),r.uTroikaUseGlyphColors.value=!t&&!!a.glyphColors;let o,i,s,l=0,u=0,h=0,f=0,d=0;if(t){let{outlineWidth:e,outlineOffsetX:t,outlineOffsetY:r,outlineBlur:n,outlineOpacity:a}=this;l=this._parsePercent(e)||0,u=Math.max(0,this._parsePercent(n)||0),o=a,f=this._parsePercent(t)||0,d=this._parsePercent(r)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(s=this.strokeColor,r.uTroikaStrokeColor.value.set(null==s?E:s),i=this.strokeOpacity,null==i&&(i=1)),o=this.fillOpacity;r.uTroikaEdgeOffset.value=l,r.uTroikaPositionOffset.value.set(f,d),r.uTroikaBlurRadius.value=u,r.uTroikaStrokeWidth.value=h,r.uTroikaStrokeOpacity.value=i,r.uTroikaFillOpacity.value=null==o?1:o,r.uTroikaCurveRadius.value=this.curveRadius||0;let c=this.clipRect;if(c&&Array.isArray(c)&&4===c.length)r.uTroikaClipRect.value.fromArray(c);else{const e=100*(this.fontSize||.1);r.uTroikaClipRect.value.set(n[0]-e,n[1]-e,n[2]+e,n[3]+e)}this.geometry.applyClipRect(r.uTroikaClipRect.value)}r.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const o=t?this.outlineColor||0:this.color;if(null==o)delete e.color;else{const t=e.hasOwnProperty("color")?e.color:e.color=new n.Q1f;o===t._input&&"object"!=typeof o||t.set(t._input=o)}let i=this.orientation||H;if(i!==e._orientation){let t=r.uTroikaOrient.value;i=i.replace(/[^-+xyz]/g,"");let n=i!==H&&i.match(/^([-+])([xyz])([-+])([xyz])$/);if(n){let[,e,r,a,o]=n;z.set(0,0,0)[r]="-"===e?1:-1,W.set(0,0,0)[o]="-"===a?-1:1,L.lookAt(j,z.cross(W),W),t.setFromMatrix4(L)}else t.identity();e._orientation=i}}_parsePercent(e){if("string"==typeof e){let t=e.match(/^(-?[\d.]+)%$/),r=t?parseFloat(t[1]):NaN;e=(isNaN(r)?0:r/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new n.I9Y){t.copy(e);const r=this.curveRadius;return r&&(t.x=Math.atan2(e.x,Math.abs(r)-Math.abs(e.z))*Math.abs(r)),t}worldPositionToTextCoords(e,t=new n.I9Y){return z.copy(e),this.localPositionToTextCoords(this.worldToLocal(z),t)}raycast(e,t){const{textRenderInfo:r,curveRadius:n}=this;if(r){const a=r.blockBounds,o=n?X():q(),i=o.geometry,{position:s,uv:l}=i.attributes;for(let e=0;e{this[t]=e[t]}),this}clone(){return(new this.constructor).copy(this)}}Q.forEach(e=>{const t="_private_"+e;Object.defineProperty(J.prototype,e,{get(){return this[t]},set(e){e!==this[t]&&(this[t]=e,this._needsSync=!0)}})}),new n.NRn,new n.Q1f,new WeakMap,new WeakMap}}]);