shiraha-colors
Version:
Browser script to generate colors for Shiraha.
1 lines • 52.7 kB
JavaScript
var ne=([e,t,r])=>(e.width+(r-t)*10)*(e.classList.contains("u-photo")?1.2:1),Tt=()=>[...document.images].filter(({width:t})=>t>=128).map((t,r,n)=>[t,r,n.length]).sort((t,r)=>ne(r)-ne(t))[0][0]??null;function U(e){return e<0?-1:e===0?0:1}function Nt(e,t,r){return (1-r)*e+r*t}function oe(e,t,r){return r<e?e:r>t?t:r}function st(e,t,r){return r<e?e:r>t?t:r}function Ut(e){return e=e%360,e<0&&(e=e+360),e}function W(e){return e=e%360,e<0&&(e=e+360),e}function ae(e,t){return W(t-e)<=180?1:-1}function It(e,t){return 180-Math.abs(Math.abs(e-t)-180)}function yt(e,t){let r=e[0]*t[0][0]+e[1]*t[0][1]+e[2]*t[0][2],n=e[0]*t[1][0]+e[1]*t[1][1]+e[2]*t[1][2],o=e[0]*t[2][0]+e[1]*t[2][1]+e[2]*t[2][2];return [r,n,o]}var se=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],be=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],Gt=[95.047,100,108.883];function Ct(e,t,r){return (255<<24|(e&255)<<16|(t&255)<<8|r&255)>>>0}function qt(e){let t=it(e[0]),r=it(e[1]),n=it(e[2]);return Ct(t,r,n)}function jt(e){return e>>24&255}function ct(e){return e>>16&255}function lt(e){return e>>8&255}function ht(e){return e&255}function vt(e,t,r){let n=be,o=n[0][0]*e+n[0][1]*t+n[0][2]*r,a=n[1][0]*e+n[1][1]*t+n[1][2]*r,s=n[2][0]*e+n[2][1]*t+n[2][2]*r,i=it(o),c=it(a),u=it(s);return Ct(i,c,u)}function Ce(e){let t=tt(ct(e)),r=tt(lt(e)),n=tt(ht(e));return yt([t,r,n],se)}function ie(e,t,r){let n=Gt,o=(e+16)/116,a=t/500+o,s=o-r/200,i=Dt(a),c=Dt(o),u=Dt(s),l=i*n[0],f=c*n[1],g=u*n[2];return vt(l,f,g)}function Yt(e){let t=tt(ct(e)),r=tt(lt(e)),n=tt(ht(e)),o=se,a=o[0][0]*t+o[0][1]*r+o[0][2]*n,s=o[1][0]*t+o[1][1]*r+o[1][2]*n,i=o[2][0]*t+o[2][1]*r+o[2][2]*n,c=Gt,u=a/c[0],l=s/c[1],f=i/c[2],g=bt(u),p=bt(l),y=bt(f),C=116*p-16,P=500*(g-p),T=200*(p-y);return [C,P,T]}function ce(e){let t=K(e),r=it(t);return Ct(r,r,r)}function ut(e){let t=Ce(e)[1];return 116*bt(t/100)-16}function K(e){return 100*Dt((e+16)/116)}function xt(e){return bt(e/100)*116-16}function tt(e){let t=e/255;return t<=.040449936?t/12.92*100:Math.pow((t+.055)/1.055,2.4)*100}function it(e){let t=e/100,r=0;return t<=.0031308?r=t*12.92:r=1.055*Math.pow(t,1/2.4)-.055,oe(0,255,Math.round(r*255))}function le(){return Gt}function $t(e){let t=ct(e),r=lt(e),n=ht(e),o=jt(e);return {r:t,g:r,b:n,a:o}}function bt(e){let t=.008856451679035631,r=24389/27;return e>t?Math.pow(e,1/3):(r*e+16)/116}function Dt(e){let t=.008856451679035631,r=24389/27,n=e*e*e;return n>t?n:(116*e-16)/r}var N=class{static make(t=le(),r=200/Math.PI*K(50)/100,n=50,o=2,a=!1){let s=t,i=s[0]*.401288+s[1]*.650173+s[2]*-.051461,c=s[0]*-.250268+s[1]*1.204414+s[2]*.045854,u=s[0]*-.002079+s[1]*.048952+s[2]*.953127,l=.8+o/10,f=l>=.9?Nt(.59,.69,(l-.9)*10):Nt(.525,.59,(l-.8)*10),g=a?1:l*(1-1/3.6*Math.exp((-r-42)/92));g=g>1?1:g<0?0:g;let p=l,y=[g*(100/i)+1-g,g*(100/c)+1-g,g*(100/u)+1-g],C=1/(5*r+1),P=C*C*C*C,T=1-P,d=P*r+.1*T*T*Math.cbrt(5*r),A=K(n)/t[1],w=1.48+Math.sqrt(A),O=.725/Math.pow(A,.2),R=O,b=[Math.pow(d*y[0]*i/100,.42),Math.pow(d*y[1]*c/100,.42),Math.pow(d*y[2]*u/100,.42)],k=[400*b[0]/(b[0]+27.13),400*b[1]/(b[1]+27.13),400*b[2]/(b[2]+27.13)],F=(2*k[0]+k[1]+.05*k[2])*O;return new N(A,F,O,R,f,p,y,d,Math.pow(d,.25),w)}constructor(t,r,n,o,a,s,i,c,u,l){this.n=t,this.aw=r,this.nbb=n,this.ncb=o,this.c=a,this.nc=s,this.rgbD=i,this.fl=c,this.fLRoot=u,this.z=l;}};N.DEFAULT=N.make();var B=class{constructor(t,r,n,o,a,s,i,c,u){this.hue=t,this.chroma=r,this.j=n,this.q=o,this.m=a,this.s=s,this.jstar=i,this.astar=c,this.bstar=u;}distance(t){let r=this.jstar-t.jstar,n=this.astar-t.astar,o=this.bstar-t.bstar,a=Math.sqrt(r*r+n*n+o*o);return 1.41*Math.pow(a,.63)}static fromInt(t){return B.fromIntInViewingConditions(t,N.DEFAULT)}static fromIntInViewingConditions(t,r){let n=(t&16711680)>>16,o=(t&65280)>>8,a=t&255,s=tt(n),i=tt(o),c=tt(a),u=.41233895*s+.35762064*i+.18051042*c,l=.2126*s+.7152*i+.0722*c,f=.01932141*s+.11916382*i+.95034478*c,g=.401288*u+.650173*l-.051461*f,p=-.250268*u+1.204414*l+.045854*f,y=-.002079*u+.048952*l+.953127*f,C=r.rgbD[0]*g,P=r.rgbD[1]*p,T=r.rgbD[2]*y,d=Math.pow(r.fl*Math.abs(C)/100,.42),A=Math.pow(r.fl*Math.abs(P)/100,.42),w=Math.pow(r.fl*Math.abs(T)/100,.42),O=U(C)*400*d/(d+27.13),R=U(P)*400*A/(A+27.13),b=U(T)*400*w/(w+27.13),k=(11*O+-12*R+b)/11,F=(O+R-2*b)/9,D=(20*O+20*R+21*b)/20,G=(40*O+20*R+b)/20,Y=Math.atan2(F,k)*180/Math.PI,H=Y<0?Y+360:Y>=360?Y-360:Y,at=H*Math.PI/180,At=G*r.nbb,nt=100*Math.pow(At/r.aw,r.c*r.z),Mt=4/r.c*Math.sqrt(nt/100)*(r.aw+4)*r.fLRoot,Lt=H<20.14?H+360:H,Ht=.25*(Math.cos(Lt*Math.PI/180+2)+3.8),zt=5e4/13*Ht*r.nc*r.ncb*Math.sqrt(k*k+F*F)/(D+.305),kt=Math.pow(zt,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),te=kt*Math.sqrt(nt/100),ee=te*r.fLRoot,pe=50*Math.sqrt(kt*r.c/(r.aw+4)),de=(1+100*.007)*nt/(1+.007*nt),re=1/.0228*Math.log(1+.0228*ee),ge=re*Math.cos(at),ye=re*Math.sin(at);return new B(H,te,nt,Mt,ee,pe,de,ge,ye)}static fromJch(t,r,n){return B.fromJchInViewingConditions(t,r,n,N.DEFAULT)}static fromJchInViewingConditions(t,r,n,o){let a=4/o.c*Math.sqrt(t/100)*(o.aw+4)*o.fLRoot,s=r*o.fLRoot,i=r/Math.sqrt(t/100),c=50*Math.sqrt(i*o.c/(o.aw+4)),u=n*Math.PI/180,l=(1+100*.007)*t/(1+.007*t),f=1/.0228*Math.log(1+.0228*s),g=f*Math.cos(u),p=f*Math.sin(u);return new B(n,r,t,a,s,c,l,g,p)}static fromUcs(t,r,n){return B.fromUcsInViewingConditions(t,r,n,N.DEFAULT)}static fromUcsInViewingConditions(t,r,n,o){let a=r,s=n,i=Math.sqrt(a*a+s*s),u=(Math.exp(i*.0228)-1)/.0228/o.fLRoot,l=Math.atan2(s,a)*(180/Math.PI);l<0&&(l+=360);let f=t/(1-(t-100)*.007);return B.fromJchInViewingConditions(f,u,l,o)}toInt(){return this.viewed(N.DEFAULT)}viewed(t){let r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(r/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),o=this.hue*Math.PI/180,a=.25*(Math.cos(o+2)+3.8),s=t.aw*Math.pow(this.j/100,1/t.c/t.z),i=a*(5e4/13)*t.nc*t.ncb,c=s/t.nbb,u=Math.sin(o),l=Math.cos(o),f=23*(c+.305)*n/(23*i+11*n*l+108*n*u),g=f*l,p=f*u,y=(460*c+451*g+288*p)/1403,C=(460*c-891*g-261*p)/1403,P=(460*c-220*g-6300*p)/1403,T=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),d=U(y)*(100/t.fl)*Math.pow(T,1/.42),A=Math.max(0,27.13*Math.abs(C)/(400-Math.abs(C))),w=U(C)*(100/t.fl)*Math.pow(A,1/.42),O=Math.max(0,27.13*Math.abs(P)/(400-Math.abs(P))),R=U(P)*(100/t.fl)*Math.pow(O,1/.42),b=d/t.rgbD[0],k=w/t.rgbD[1],F=R/t.rgbD[2],D=1.86206786*b-1.01125463*k+.14918677*F,G=.38752654*b+.62144744*k-.00897398*F,J=-.0158415*b-.03412294*k+1.04996444*F;return vt(D,G,J)}static fromXyzInViewingConditions(t,r,n,o){let a=.401288*t+.650173*r-.051461*n,s=-.250268*t+1.204414*r+.045854*n,i=-.002079*t+.048952*r+.953127*n,c=o.rgbD[0]*a,u=o.rgbD[1]*s,l=o.rgbD[2]*i,f=Math.pow(o.fl*Math.abs(c)/100,.42),g=Math.pow(o.fl*Math.abs(u)/100,.42),p=Math.pow(o.fl*Math.abs(l)/100,.42),y=U(c)*400*f/(f+27.13),C=U(u)*400*g/(g+27.13),P=U(l)*400*p/(p+27.13),T=(11*y+-12*C+P)/11,d=(y+C-2*P)/9,A=(20*y+20*C+21*P)/20,w=(40*y+20*C+P)/20,R=Math.atan2(d,T)*180/Math.PI,b=R<0?R+360:R>=360?R-360:R,k=b*Math.PI/180,F=w*o.nbb,D=100*Math.pow(F/o.aw,o.c*o.z),G=4/o.c*Math.sqrt(D/100)*(o.aw+4)*o.fLRoot,J=b<20.14?b+360:b,Y=1/4*(Math.cos(J*Math.PI/180+2)+3.8),at=5e4/13*Y*o.nc*o.ncb*Math.sqrt(T*T+d*d)/(A+.305),At=Math.pow(at,.9)*Math.pow(1.64-Math.pow(.29,o.n),.73),nt=At*Math.sqrt(D/100),Mt=nt*o.fLRoot,Lt=50*Math.sqrt(At*o.c/(o.aw+4)),Ht=(1+100*.007)*D/(1+.007*D),Vt=Math.log(1+.0228*Mt)/.0228,zt=Vt*Math.cos(k),kt=Vt*Math.sin(k);return new B(b,nt,D,G,Mt,Lt,Ht,zt,kt)}xyzInViewingConditions(t){let r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(r/Math.pow(1.64-Math.pow(.29,t.n),.73),1/.9),o=this.hue*Math.PI/180,a=.25*(Math.cos(o+2)+3.8),s=t.aw*Math.pow(this.j/100,1/t.c/t.z),i=a*(5e4/13)*t.nc*t.ncb,c=s/t.nbb,u=Math.sin(o),l=Math.cos(o),f=23*(c+.305)*n/(23*i+11*n*l+108*n*u),g=f*l,p=f*u,y=(460*c+451*g+288*p)/1403,C=(460*c-891*g-261*p)/1403,P=(460*c-220*g-6300*p)/1403,T=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),d=U(y)*(100/t.fl)*Math.pow(T,1/.42),A=Math.max(0,27.13*Math.abs(C)/(400-Math.abs(C))),w=U(C)*(100/t.fl)*Math.pow(A,1/.42),O=Math.max(0,27.13*Math.abs(P)/(400-Math.abs(P))),R=U(P)*(100/t.fl)*Math.pow(O,1/.42),b=d/t.rgbD[0],k=w/t.rgbD[1],F=R/t.rgbD[2],D=1.86206786*b-1.01125463*k+.14918677*F,G=.38752654*b+.62144744*k-.00897398*F,J=-.0158415*b-.03412294*k+1.04996444*F;return [D,G,J]}};var x=class{static sanitizeRadians(t){return (t+Math.PI*8)%(Math.PI*2)}static trueDelinearized(t){let r=t/100,n=0;return r<=.0031308?n=r*12.92:n=1.055*Math.pow(r,1/2.4)-.055,n*255}static chromaticAdaptation(t){let r=Math.pow(Math.abs(t),.42);return U(t)*400*r/(r+27.13)}static hueOf(t){let r=yt(t,x.SCALED_DISCOUNT_FROM_LINRGB),n=x.chromaticAdaptation(r[0]),o=x.chromaticAdaptation(r[1]),a=x.chromaticAdaptation(r[2]),s=(11*n+-12*o+a)/11,i=(n+o-2*a)/9;return Math.atan2(i,s)}static areInCyclicOrder(t,r,n){let o=x.sanitizeRadians(r-t),a=x.sanitizeRadians(n-t);return o<a}static intercept(t,r,n){return (r-t)/(n-t)}static lerpPoint(t,r,n){return [t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r,t[2]+(n[2]-t[2])*r]}static setCoordinate(t,r,n,o){let a=x.intercept(t[o],r,n[o]);return x.lerpPoint(t,a,n)}static isBounded(t){return 0<=t&&t<=100}static nthVertex(t,r){let n=x.Y_FROM_LINRGB[0],o=x.Y_FROM_LINRGB[1],a=x.Y_FROM_LINRGB[2],s=r%4<=1?0:100,i=r%2===0?0:100;if(r<4){let c=s,u=i,l=(t-c*o-u*a)/n;return x.isBounded(l)?[l,c,u]:[-1,-1,-1]}else if(r<8){let c=s,u=i,l=(t-u*n-c*a)/o;return x.isBounded(l)?[u,l,c]:[-1,-1,-1]}else {let c=s,u=i,l=(t-c*n-u*o)/a;return x.isBounded(l)?[c,u,l]:[-1,-1,-1]}}static bisectToSegment(t,r){let n=[-1,-1,-1],o=n,a=0,s=0,i=!1,c=!0;for(let u=0;u<12;u++){let l=x.nthVertex(t,u);if(l[0]<0)continue;let f=x.hueOf(l);if(!i){n=l,o=l,a=f,s=f,i=!0;continue}(c||x.areInCyclicOrder(a,f,s))&&(c=!1,x.areInCyclicOrder(a,r,f)?(o=l,s=f):(n=l,a=f));}return [n,o]}static midpoint(t,r){return [(t[0]+r[0])/2,(t[1]+r[1])/2,(t[2]+r[2])/2]}static criticalPlaneBelow(t){return Math.floor(t-.5)}static criticalPlaneAbove(t){return Math.ceil(t-.5)}static bisectToLimit(t,r){let n=x.bisectToSegment(t,r),o=n[0],a=x.hueOf(o),s=n[1];for(let i=0;i<3;i++)if(o[i]!==s[i]){let c=-1,u=255;o[i]<s[i]?(c=x.criticalPlaneBelow(x.trueDelinearized(o[i])),u=x.criticalPlaneAbove(x.trueDelinearized(s[i]))):(c=x.criticalPlaneAbove(x.trueDelinearized(o[i])),u=x.criticalPlaneBelow(x.trueDelinearized(s[i])));for(let l=0;l<8&&!(Math.abs(u-c)<=1);l++){let f=Math.floor((c+u)/2),g=x.CRITICAL_PLANES[f],p=x.setCoordinate(o,g,s,i),y=x.hueOf(p);x.areInCyclicOrder(a,r,y)?(s=p,u=f):(o=p,a=y,c=f);}}return x.midpoint(o,s)}static inverseChromaticAdaptation(t){let r=Math.abs(t),n=Math.max(0,27.13*r/(400-r));return U(t)*Math.pow(n,1/.42)}static findResultByJ(t,r,n){let o=Math.sqrt(n)*11,a=N.DEFAULT,s=1/Math.pow(1.64-Math.pow(.29,a.n),.73),c=.25*(Math.cos(t+2)+3.8)*(5e4/13)*a.nc*a.ncb,u=Math.sin(t),l=Math.cos(t);for(let f=0;f<5;f++){let g=o/100,p=r===0||o===0?0:r/Math.sqrt(g),y=Math.pow(p*s,1/.9),P=a.aw*Math.pow(g,1/a.c/a.z)/a.nbb,T=23*(P+.305)*y/(23*c+11*y*l+108*y*u),d=T*l,A=T*u,w=(460*P+451*d+288*A)/1403,O=(460*P-891*d-261*A)/1403,R=(460*P-220*d-6300*A)/1403,b=x.inverseChromaticAdaptation(w),k=x.inverseChromaticAdaptation(O),F=x.inverseChromaticAdaptation(R),D=yt([b,k,F],x.LINRGB_FROM_SCALED_DISCOUNT);if(D[0]<0||D[1]<0||D[2]<0)return 0;let G=x.Y_FROM_LINRGB[0],J=x.Y_FROM_LINRGB[1],Y=x.Y_FROM_LINRGB[2],H=G*D[0]+J*D[1]+Y*D[2];if(H<=0)return 0;if(f===4||Math.abs(H-n)<.002)return D[0]>100.01||D[1]>100.01||D[2]>100.01?0:qt(D);o=o-(H-n)*o/(2*H);}return 0}static solveToInt(t,r,n){if(r<1e-4||n<1e-4||n>99.9999)return ce(n);t=W(t);let o=t/180*Math.PI,a=K(n),s=x.findResultByJ(o,r,a);if(s!==0)return s;let i=x.bisectToLimit(a,o);return qt(i)}static solveToCam(t,r,n){return B.fromInt(x.solveToInt(t,r,n))}};x.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]];x.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]];x.Y_FROM_LINRGB=[.2126,.7152,.0722];x.CRITICAL_PLANES=[.015176349177441876,.045529047532325624,.07588174588720938,.10623444424209313,.13658714259697685,.16693984095186062,.19729253930674434,.2276452376616281,.2579979360165119,.28835063437139563,.3188300904430532,.350925934958123,.3848314933096426,.42057480301049466,.458183274052838,.4976837250274023,.5391024159806381,.5824650784040898,.6277969426914107,.6751227633498623,.7244668422128921,.775853049866786,.829304845476233,.8848452951698498,.942497089126609,1.0022825574869039,1.0642236851973577,1.1283421258858297,1.1946592148522128,1.2631959812511864,1.3339731595349034,1.407011200216447,1.4823302800086415,1.5599503113873272,1.6398909516233677,1.7221716113234105,1.8068114625156377,1.8938294463134073,1.9832442801866852,2.075074464868551,2.1693382909216234,2.2660538449872063,2.36523901573795,2.4669114995532007,2.5710888059345764,2.6777882626779785,2.7870270208169257,2.898822059350997,3.0131901897720907,3.1301480604002863,3.2497121605402226,3.3718988244681087,3.4967242352587946,3.624204428461639,3.754355295633311,3.887192587735158,4.022731918402185,4.160988767090289,4.301978482107941,4.445716283538092,4.592217266055746,4.741496401646282,4.893568542229298,5.048448422192488,5.20615066083972,5.3666897647573375,5.5300801301023865,5.696336044816294,5.865471690767354,6.037501145825082,6.212438385869475,6.390297286737924,6.571091626112461,6.7548350853498045,6.941541251256611,7.131223617812143,7.323895587840543,7.5195704746346665,7.7182615035334345,7.919981813454504,8.124744458384042,8.332562408825165,8.543448553206703,8.757415699253682,8.974476575321063,9.194643831691977,9.417930041841839,9.644347703669503,9.873909240696694,10.106627003236781,10.342513269534024,10.58158024687427,10.8238400726681,11.069304815507364,11.317986476196008,11.569896988756009,11.825048221409341,12.083451977536606,12.345119996613247,12.610063955123938,12.878295467455942,13.149826086772048,13.42466730586372,13.702830557985108,13.984327217668513,14.269168601521828,14.55736596900856,14.848930523210871,15.143873411576273,15.44220572664832,15.743938506781891,16.04908273684337,16.35764934889634,16.66964922287304,16.985093187232053,17.30399201960269,17.62635644741625,17.95219714852476,18.281524751807332,18.614349837764564,18.95068293910138,19.290534541298456,19.633915083172692,19.98083495742689,20.331304511189067,20.685334046541502,21.042933821039977,21.404114048223256,21.76888489811322,22.137256497705877,22.50923893145328,22.884842241736916,23.264076429332462,23.6469514538663,24.033477234264016,24.42366364919083,24.817520537484558,25.21505769858089,25.61628489293138,26.021211842414342,26.429848230738664,26.842203703840827,27.258287870275353,27.678110301598522,28.10168053274597,28.529008062403893,28.96010235337422,29.39497283293396,29.83362889318845,30.276079891419332,30.722335150426627,31.172403958865512,31.62629557157785,32.08401920991837,32.54558406207592,33.010999283389665,33.4802739966603,33.953417292456834,34.430438229418264,34.911345834551085,35.39614910352207,35.88485700094671,36.37747846067349,36.87402238606382,37.37449765026789,37.87891309649659,38.38727753828926,38.89959975977785,39.41588851594697,39.93615253289054,40.460400508064545,40.98864111053629,41.520882981230194,42.05713473317016,42.597404951718396,43.141702194811224,43.6900349931913,44.24241185063697,44.798841244188324,45.35933162437017,45.92389141541209,46.49252901546552,47.065252796817916,47.64207110610409,48.22299226451468,48.808024568002054,49.3971762874833,49.9904556690408,50.587870934119984,51.189430279724725,51.79514187861014,52.40501387947288,53.0190544071392,53.637271562750364,54.259673423945976,54.88626804504493,55.517063457223934,56.15206766869424,56.79128866487574,57.43473440856916,58.08241284012621,58.734331877617365,59.39049941699807,60.05092333227251,60.715611475655585,61.38457167773311,62.057811747619894,62.7353394731159,63.417162620860914,64.10328893648692,64.79372614476921,65.48848194977529,66.18756403501224,66.89098006357258,67.59873767827808,68.31084450182222,69.02730813691093,69.74813616640164,70.47333615344107,71.20291564160104,71.93688215501312,72.67524319850172,73.41800625771542,74.16517879925733,74.9167682708136,75.67278210128072,76.43322770089146,77.1981124613393,77.96744375590167,78.74122893956174,79.51947534912904,80.30219030335869,81.08938110306934,81.88105503125999,82.67721935322541,83.4778813166706,84.28304815182372,85.09272707154808,85.90692527145302,86.72564993000343,87.54890820862819,88.3767072518277,89.2090541872801,90.04595612594655,90.88742016217518,91.73345337380438,92.58406282226491,93.43925555268066,94.29903859396902,95.16341895893969,96.03240364439274,96.9059996312159,97.78421388448044,98.6670533535366,99.55452497210776];var I=class{static from(t,r,n){return new I(x.solveToInt(t,r,n))}static fromInt(t){return new I(t)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(t){this.setInternalState(x.solveToInt(t,this.internalChroma,this.internalTone));}get chroma(){return this.internalChroma}set chroma(t){this.setInternalState(x.solveToInt(this.internalHue,t,this.internalTone));}get tone(){return this.internalTone}set tone(t){this.setInternalState(x.solveToInt(this.internalHue,this.internalChroma,t));}constructor(t){this.argb=t;let r=B.fromInt(t);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=ut(t),this.argb=t;}setInternalState(t){let r=B.fromInt(t);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=ut(t),this.argb=t;}inViewingConditions(t){let n=B.fromInt(this.toInt()).xyzInViewingConditions(t),o=B.fromXyzInViewingConditions(n[0],n[1],n[2],N.make());return I.from(o.hue,o.chroma,xt(n[1]))}};var ft=class{static harmonize(t,r){let n=I.fromInt(t),o=I.fromInt(r),a=It(n.hue,o.hue),s=Math.min(a*.5,15),i=W(n.hue+s*ae(n.hue,o.hue));return I.from(i,n.chroma,n.tone).toInt()}static hctHue(t,r,n){let o=ft.cam16Ucs(t,r,n),a=B.fromInt(o),s=B.fromInt(t);return I.from(a.hue,s.chroma,ut(t)).toInt()}static cam16Ucs(t,r,n){let o=B.fromInt(t),a=B.fromInt(r),s=o.jstar,i=o.astar,c=o.bstar,u=a.jstar,l=a.astar,f=a.bstar,g=s+(u-s)*n,p=i+(l-i)*n,y=c+(f-c)*n;return B.fromUcs(g,p,y).toInt()}};var V=class{static ratioOfTones(t,r){return t=st(0,100,t),r=st(0,100,r),V.ratioOfYs(K(t),K(r))}static ratioOfYs(t,r){let n=t>r?t:r,o=n===r?t:r;return (n+5)/(o+5)}static lighter(t,r){if(t<0||t>100)return -1;let n=K(t),o=r*(n+5)-5,a=V.ratioOfYs(o,n),s=Math.abs(a-r);if(a<r&&s>.04)return -1;let i=xt(o)+.4;return i<0||i>100?-1:i}static darker(t,r){if(t<0||t>100)return -1;let n=K(t),o=(n+5)/r-5,a=V.ratioOfYs(n,o),s=Math.abs(a-r);if(a<r&&s>.04)return -1;let i=xt(o)-.4;return i<0||i>100?-1:i}static lighterUnsafe(t,r){let n=V.lighter(t,r);return n<0?100:n}static darkerUnsafe(t,r){let n=V.darker(t,r);return n<0?0:n}};var ot=class{static isDisliked(t){let r=Math.round(t.hue)>=90&&Math.round(t.hue)<=111,n=Math.round(t.chroma)>16,o=Math.round(t.tone)<65;return r&&n&&o}static fixIfDisliked(t){return ot.isDisliked(t)?I.from(t.hue,t.chroma,70):t}};var m=class{static fromPalette(t){return new m(r=>t.palette(r).hue,r=>t.palette(r).chroma,t.tone,r=>m.toneMinContrastDefault({tone:t.tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),r=>m.toneMaxContrastDefault({tone:t.tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),t.background,t.toneDeltaConstraint)}static fromHueAndChroma(t){return new m(t.hue,t.chroma,t.tone,r=>m.toneMinContrastDefault({tone:t.tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),r=>m.toneMaxContrastDefault({tone:t.tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),t.background,t.toneDeltaConstraint)}static fromArgb(t){return new m(r=>I.fromInt(t.argb(r)).hue,r=>I.fromInt(t.argb(r)).chroma,r=>t.tone?.(r)??I.fromInt(t.argb(r)).tone,r=>m.toneMinContrastDefault({tone:n=>t.tone?.(n)??I.fromInt(t.argb(n)).tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),r=>m.toneMaxContrastDefault({tone:n=>t.tone?.(n)??I.fromInt(t.argb(n)).tone,scheme:r,background:t.background,toneDeltaConstraint:t.toneDeltaConstraint}),t.background,t.toneDeltaConstraint)}constructor(t,r,n,o,a,s,i){this.hue=t,this.chroma=r,this.tone=n,this.toneMinContrast=o,this.toneMaxContrast=a,this.background=s,this.toneDeltaConstraint=i,this.hctCache=new Map;}getArgb(t){return this.getHct(t).toInt()}getHct(t){let r=this.hctCache.get(t);if(r!=null)return r;let n=I.from(this.hue(t),this.chroma(t),this.getTone(t));return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,n),n}getTone(t){let r=this.tone(t),n=t.contrastLevel<0;if(t.contrastLevel!==0){let c=this.tone(t);r=((n?this.toneMinContrast(t):this.toneMaxContrast(t))-c)*Math.abs(t.contrastLevel)+c;}let o=this.background?.(t),a,s,i;if(o!=null){let c=o?.background?.(t)!=null;if(a=V.ratioOfTones(this.tone(t),o.tone(t)),n){let u=V.ratioOfTones(this.toneMinContrast(t),o.toneMinContrast(t));s=c?u:null,i=a;}else {let u=V.ratioOfTones(this.toneMaxContrast(t),o.toneMaxContrast(t));s=c?Math.min(u,a):null,i=c?Math.max(u,a):null;}}return r=m.calculateDynamicTone({scheme:t,toneStandard:this.tone,toneToJudge:c=>c.getTone(t),desiredTone:(c,u)=>r,background:o!=null?c=>o:void 0,toneDeltaConstraint:this.toneDeltaConstraint,minRatio:c=>s??1,maxRatio:c=>i??21}),r}static ensureToneDelta(t,r,n,o,a){let s=o?o(n):null;if(s==null||a==null)return t;let i=s.delta,c=a(s.keepAway),u=Math.abs(t-c);if(u>i)return t;switch(s.keepAwayPolarity){case"darker":return st(0,100,c+i);case"lighter":return st(0,100,c-i);case"no-preference":let l=s.keepAway.tone(n),f=r>l,g=Math.abs(u-i);return (f?t+g<=100:t<g)?t+g:t-g;default:return t}}static foregroundTone(t,r){let n=V.lighterUnsafe(t,r),o=V.darkerUnsafe(t,r),a=V.ratioOfTones(n,t),s=V.ratioOfTones(o,t);if(m.tonePrefersLightForeground(t)){let c=Math.abs(a-s)<.1&&a<r&&s<r;return a>=r||a>=s||c?n:o}else return s>=r||s>=a?o:n}static calculateDynamicTone(t){let r=t.background,n=t.scheme,o=t.toneStandard,a=t.toneToJudge,s=t.desiredTone,i=t.minRatio,c=t.maxRatio,u=t.toneDeltaConstraint,l=o(n),f=l,g=r?.(n);if(g==null)return f;let p=g.tone(n),y=V.ratioOfTones(l,p),C=a(g),P=s(y,C),T=V.ratioOfTones(C,P),d=st(i?.(y)??1,c?.(y)??21,T);return d===T?f=P:f=m.foregroundTone(C,d),g.background?.(n)==null&&(f=m.enableLightForeground(f)),f=m.ensureToneDelta(f,l,n,u,A=>a(A)),f}static toneMaxContrastDefault(t){return m.calculateDynamicTone({scheme:t.scheme,toneStandard:t.tone,toneToJudge:r=>r.toneMaxContrast(t.scheme),desiredTone:(r,n)=>t.background?.(t.scheme)?.background?.(t.scheme)!=null?m.foregroundTone(n,7):m.foregroundTone(n,Math.max(7,r)),background:t.background,toneDeltaConstraint:t.toneDeltaConstraint})}static toneMinContrastDefault(t){return m.calculateDynamicTone({scheme:t.scheme,toneStandard:t.tone,toneToJudge:r=>r.toneMinContrast(t.scheme),desiredTone:(r,n)=>{let o=t.tone(t.scheme);return r>=7?o=m.foregroundTone(n,4.5):r>=3?o=m.foregroundTone(n,3):t.background?.(t.scheme)?.background?.(t.scheme)!=null&&(o=m.foregroundTone(n,r)),o},background:t.background,toneDeltaConstraint:t.toneDeltaConstraint,minRatio:r=>1,maxRatio:r=>r})}static tonePrefersLightForeground(t){return Math.round(t)<60}static toneAllowsLightForeground(t){return Math.round(t)<=49}static enableLightForeground(t){return m.tonePrefersLightForeground(t)&&!m.toneAllowsLightForeground(t)?49:t}};var q;(function(e){e[e.MONOCHROME=0]="MONOCHROME",e[e.NEUTRAL=1]="NEUTRAL",e[e.TONAL_SPOT=2]="TONAL_SPOT",e[e.VIBRANT=3]="VIBRANT",e[e.EXPRESSIVE=4]="EXPRESSIVE",e[e.FIDELITY=5]="FIDELITY",e[e.CONTENT=6]="CONTENT";})(q||(q={}));var mt=class{constructor(t,r,n){this.delta=t,this.keepAway=r,this.keepAwayPolarity=n;}};function pt(e){return e.variant===q.FIDELITY||e.variant===q.CONTENT}function E(e){return e.variant===q.MONOCHROME}function xe(e,t,r,n){let o=r,a=I.from(e,t,r);if(a.chroma<t){let s=a.chroma;for(;a.chroma<t;){o+=n?-1:1;let i=I.from(e,t,o);if(s>i.chroma||Math.abs(i.chroma-t)<.4)break;let c=Math.abs(i.chroma-t),u=Math.abs(a.chroma-t);c<u&&(a=i),s=Math.max(s,i.chroma);}}return o}function Pe(e){return N.make(void 0,void 0,e.isDark?30:80,void 0,void 0)}function Jt(e,t){let r=e.inViewingConditions(Pe(t));return m.tonePrefersLightForeground(e.tone)&&!m.toneAllowsLightForeground(r.tone)?m.enableLightForeground(e.tone):m.enableLightForeground(r.tone)}var h=class{static highestSurface(t){return t.isDark?h.surfaceBright:h.surfaceDim}};h.contentAccentToneDelta=15;h.background=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?6:98});h.onBackground=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?90:10,background:e=>h.background});h.surface=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?6:98});h.surfaceDim=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?6:87});h.surfaceBright=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?24:98});h.surfaceContainerLowest=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?4:100});h.surfaceContainerLow=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?10:96});h.surfaceContainer=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?12:94});h.surfaceContainerHigh=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?17:92});h.surfaceContainerHighest=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?22:90});h.onSurface=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?90:10,background:e=>h.highestSurface(e)});h.surfaceVariant=m.fromPalette({palette:e=>e.neutralVariantPalette,tone:e=>e.isDark?30:90});h.onSurfaceVariant=m.fromPalette({palette:e=>e.neutralVariantPalette,tone:e=>e.isDark?80:30,background:e=>h.surfaceVariant});h.inverseSurface=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?90:20});h.inverseOnSurface=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>e.isDark?20:95,background:e=>h.inverseSurface});h.outline=m.fromPalette({palette:e=>e.neutralVariantPalette,tone:e=>50,background:e=>h.highestSurface(e)});h.outlineVariant=m.fromPalette({palette:e=>e.neutralVariantPalette,tone:e=>e.isDark?30:80,background:e=>h.highestSurface(e)});h.shadow=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>0});h.scrim=m.fromPalette({palette:e=>e.neutralPalette,tone:e=>0});h.surfaceTintColor=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>e.isDark?80:40});h.primary=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?100:0:e.isDark?80:40,background:e=>h.highestSurface(e),toneDeltaConstraint:e=>new mt(h.contentAccentToneDelta,h.primaryContainer,e.isDark?"darker":"lighter")});h.onPrimary=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?10:90:e.isDark?20:100,background:e=>h.primary});h.primaryContainer=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?85:25:pt(e)?Jt(e.sourceColorHct,e):e.isDark?30:90,background:e=>h.highestSurface(e)});h.onPrimaryContainer=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?0:100:pt(e)?m.foregroundTone(h.primaryContainer.tone(e),4.5):e.isDark?90:10,background:e=>h.primaryContainer});h.inversePrimary=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>e.isDark?40:80,background:e=>h.inverseSurface});h.inverseOnPrimary=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>e.isDark?100:20,background:e=>h.inversePrimary});h.secondary=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>e.isDark?80:40,background:e=>h.highestSurface(e),toneDeltaConstraint:e=>new mt(h.contentAccentToneDelta,h.secondaryContainer,e.isDark?"darker":"lighter")});h.onSecondary=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>E(e)?e.isDark?10:100:e.isDark?20:100,background:e=>h.secondary});h.secondaryContainer=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>{let t=e.isDark?30:90;if(E(e))return e.isDark?30:85;if(!pt(e))return t;let r=xe(e.secondaryPalette.hue,e.secondaryPalette.chroma,t,!e.isDark);return r=Jt(e.secondaryPalette.getHct(r),e),r},background:e=>h.highestSurface(e)});h.onSecondaryContainer=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>pt(e)?m.foregroundTone(h.secondaryContainer.tone(e),4.5):e.isDark?90:10,background:e=>h.secondaryContainer});h.tertiary=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?e.isDark?90:25:e.isDark?80:40,background:e=>h.highestSurface(e),toneDeltaConstraint:e=>new mt(h.contentAccentToneDelta,h.tertiaryContainer,e.isDark?"darker":"lighter")});h.onTertiary=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?e.isDark?10:90:e.isDark?20:100,background:e=>h.tertiary});h.tertiaryContainer=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>{if(E(e))return e.isDark?60:49;if(!pt(e))return e.isDark?30:90;let t=Jt(e.tertiaryPalette.getHct(e.sourceColorHct.tone),e),r=e.tertiaryPalette.getHct(t);return ot.fixIfDisliked(r).tone},background:e=>h.highestSurface(e)});h.onTertiaryContainer=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?e.isDark?0:100:pt(e)?m.foregroundTone(h.tertiaryContainer.tone(e),4.5):e.isDark?90:10,background:e=>h.tertiaryContainer});h.error=m.fromPalette({palette:e=>e.errorPalette,tone:e=>e.isDark?80:40,background:e=>h.highestSurface(e),toneDeltaConstraint:e=>new mt(h.contentAccentToneDelta,h.errorContainer,e.isDark?"darker":"lighter")});h.onError=m.fromPalette({palette:e=>e.errorPalette,tone:e=>e.isDark?20:100,background:e=>h.error});h.errorContainer=m.fromPalette({palette:e=>e.errorPalette,tone:e=>e.isDark?30:90,background:e=>h.highestSurface(e)});h.onErrorContainer=m.fromPalette({palette:e=>e.errorPalette,tone:e=>e.isDark?90:10,background:e=>h.errorContainer});h.primaryFixed=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?100:10:90,background:e=>h.highestSurface(e)});h.primaryFixedDim=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?90:20:80,background:e=>h.highestSurface(e)});h.onPrimaryFixed=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?10:90:10,background:e=>h.primaryFixedDim});h.onPrimaryFixedVariant=m.fromPalette({palette:e=>e.primaryPalette,tone:e=>E(e)?e.isDark?30:70:30,background:e=>h.primaryFixedDim});h.secondaryFixed=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>E(e)?80:90,background:e=>h.highestSurface(e)});h.secondaryFixedDim=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>E(e)?70:80,background:e=>h.highestSurface(e)});h.onSecondaryFixed=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>10,background:e=>h.secondaryFixedDim});h.onSecondaryFixedVariant=m.fromPalette({palette:e=>e.secondaryPalette,tone:e=>E(e)?25:30,background:e=>h.secondaryFixedDim});h.tertiaryFixed=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?40:90,background:e=>h.highestSurface(e)});h.tertiaryFixedDim=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?30:80,background:e=>h.highestSurface(e)});h.onTertiaryFixed=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?90:10,background:e=>h.tertiaryFixedDim});h.onTertiaryFixedVariant=m.fromPalette({palette:e=>e.tertiaryPalette,tone:e=>E(e)?70:30,background:e=>h.tertiaryFixedDim});var M=class{static fromInt(t){let r=I.fromInt(t);return M.fromHueAndChroma(r.hue,r.chroma)}static fromHueAndChroma(t,r){return new M(t,r)}constructor(t,r){this.hue=t,this.chroma=r,this.cache=new Map;}tone(t){let r=this.cache.get(t);return r===void 0&&(r=I.from(this.hue,this.chroma,t).toInt(),this.cache.set(t,r)),r}getHct(t){return I.fromInt(this.tone(t))}};var L=class{static of(t){return new L(t,!1)}static contentOf(t){return new L(t,!0)}static fromColors(t){return L.createPaletteFromColors(!1,t)}static contentFromColors(t){return L.createPaletteFromColors(!0,t)}static createPaletteFromColors(t,r){let n=new L(r.primary,t);if(r.secondary){let o=new L(r.secondary,t);n.a2=o.a1;}if(r.tertiary){let o=new L(r.tertiary,t);n.a3=o.a1;}if(r.error){let o=new L(r.error,t);n.error=o.a1;}if(r.neutral){let o=new L(r.neutral,t);n.n1=o.n1;}if(r.neutralVariant){let o=new L(r.neutralVariant,t);n.n2=o.n2;}return n}constructor(t,r){let n=I.fromInt(t),o=n.hue,a=n.chroma;r?(this.a1=M.fromHueAndChroma(o,a),this.a2=M.fromHueAndChroma(o,a/3),this.a3=M.fromHueAndChroma(o+60,a/2),this.n1=M.fromHueAndChroma(o,Math.min(a/12,4)),this.n2=M.fromHueAndChroma(o,Math.min(a/6,8))):(this.a1=M.fromHueAndChroma(o,Math.max(48,a)),this.a2=M.fromHueAndChroma(o,16),this.a3=M.fromHueAndChroma(o+60,24),this.n1=M.fromHueAndChroma(o,4),this.n2=M.fromHueAndChroma(o,8)),this.error=M.fromHueAndChroma(25,84);}};var wt=class{fromInt(t){return Yt(t)}toInt(t){return ie(t[0],t[1],t[2])}distance(t,r){let n=t[0]-r[0],o=t[1]-r[1],a=t[2]-r[2];return n*n+o*o+a*a}};var Ae=10,Me=3,Ft=class{static quantize(t,r,n){let o=new Map,a=new Array,s=new Array,i=new wt,c=0;for(let d=0;d<t.length;d++){let A=t[d],w=o.get(A);w===void 0?(c++,a.push(i.fromInt(A)),s.push(A),o.set(A,1)):o.set(A,w+1);}let u=new Array;for(let d=0;d<c;d++){let A=s[d],w=o.get(A);w!==void 0&&(u[d]=w);}let l=Math.min(n,c);r.length>0&&(l=Math.min(l,r.length));let f=new Array;for(let d=0;d<r.length;d++)f.push(i.fromInt(r[d]));let g=l-f.length;if(r.length===0&&g>0)for(let d=0;d<g;d++){let A=Math.random()*100,w=Math.random()*(100- -100+1)+-100,O=Math.random()*(100- -100+1)+-100;f.push(new Array(A,w,O));}let p=new Array;for(let d=0;d<c;d++)p.push(Math.floor(Math.random()*l));let y=new Array;for(let d=0;d<l;d++){y.push(new Array);for(let A=0;A<l;A++)y[d].push(0);}let C=new Array;for(let d=0;d<l;d++){C.push(new Array);for(let A=0;A<l;A++)C[d].push(new Wt);}let P=new Array;for(let d=0;d<l;d++)P.push(0);for(let d=0;d<Ae;d++){for(let b=0;b<l;b++){for(let k=b+1;k<l;k++){let F=i.distance(f[b],f[k]);C[k][b].distance=F,C[k][b].index=b,C[b][k].distance=F,C[b][k].index=k;}C[b].sort();for(let k=0;k<l;k++)y[b][k]=C[b][k].index;}let A=0;for(let b=0;b<c;b++){let k=a[b],F=p[b],D=f[F],G=i.distance(k,D),J=G,Y=-1;for(let H=0;H<l;H++){if(C[F][H].distance>=4*G)continue;let at=i.distance(k,f[H]);at<J&&(J=at,Y=H);}Y!==-1&&Math.abs(Math.sqrt(J)-Math.sqrt(G))>Me&&(A++,p[b]=Y);}if(A===0&&d!==0)break;let w=new Array(l).fill(0),O=new Array(l).fill(0),R=new Array(l).fill(0);for(let b=0;b<l;b++)P[b]=0;for(let b=0;b<c;b++){let k=p[b],F=a[b],D=u[b];P[k]+=D,w[k]+=F[0]*D,O[k]+=F[1]*D,R[k]+=F[2]*D;}for(let b=0;b<l;b++){let k=P[b];if(k===0){f[b]=[0,0,0];continue}let F=w[b]/k,D=O[b]/k,G=R[b]/k;f[b]=[F,D,G];}}let T=new Map;for(let d=0;d<l;d++){let A=P[d];if(A===0)continue;let w=i.toInt(f[d]);T.has(w)||T.set(w,A);}return T}},Wt=class{constructor(){this.distance=-1,this.index=-1;}};var Rt=class{static quantize(t){let r=new Map;for(let n=0;n<t.length;n++){let o=t[n];jt(o)<255||r.set(o,(r.get(o)??0)+1);}return r}};var Bt=5,Q=33,Pt=35937,j={RED:"red",GREEN:"green",BLUE:"blue"},Ot=class{constructor(t=[],r=[],n=[],o=[],a=[],s=[]){this.weights=t,this.momentsR=r,this.momentsG=n,this.momentsB=o,this.moments=a,this.cubes=s;}quantize(t,r){this.constructHistogram(t),this.computeMoments();let n=this.createBoxes(r);return this.createResult(n.resultCount)}constructHistogram(t){this.weights=Array.from({length:Pt}).fill(0),this.momentsR=Array.from({length:Pt}).fill(0),this.momentsG=Array.from({length:Pt}).fill(0),this.momentsB=Array.from({length:Pt}).fill(0),this.moments=Array.from({length:Pt}).fill(0);let r=Rt.quantize(t);for(let[n,o]of r.entries()){let a=ct(n),s=lt(n),i=ht(n),c=8-Bt,u=(a>>c)+1,l=(s>>c)+1,f=(i>>c)+1,g=this.getIndex(u,l,f);this.weights[g]=(this.weights[g]??0)+o,this.momentsR[g]+=o*a,this.momentsG[g]+=o*s,this.momentsB[g]+=o*i,this.moments[g]+=o*(a*a+s*s+i*i);}}computeMoments(){for(let t=1;t<Q;t++){let r=Array.from({length:Q}).fill(0),n=Array.from({length:Q}).fill(0),o=Array.from({length:Q}).fill(0),a=Array.from({length:Q}).fill(0),s=Array.from({length:Q}).fill(0);for(let i=1;i<Q;i++){let c=0,u=0,l=0,f=0,g=0;for(let p=1;p<Q;p++){let y=this.getIndex(t,i,p);c+=this.weights[y],u+=this.momentsR[y],l+=this.momentsG[y],f+=this.momentsB[y],g+=this.moments[y],r[p]+=c,n[p]+=u,o[p]+=l,a[p]+=f,s[p]+=g;let C=this.getIndex(t-1,i,p);this.weights[y]=this.weights[C]+r[p],this.momentsR[y]=this.momentsR[C]+n[p],this.momentsG[y]=this.momentsG[C]+o[p],this.momentsB[y]=this.momentsB[C]+a[p],this.moments[y]=this.moments[C]+s[p];}}}}createBoxes(t){this.cubes=Array.from({length:t}).fill(0).map(()=>new Xt);let r=Array.from({length:t}).fill(0);this.cubes[0].r0=0,this.cubes[0].g0=0,this.cubes[0].b0=0,this.cubes[0].r1=Q-1,this.cubes[0].g1=Q-1,this.cubes[0].b1=Q-1;let n=t,o=0;for(let a=1;a<t;a++){this.cut(this.cubes[o],this.cubes[a])?(r[o]=this.cubes[o].vol>1?this.variance(this.cubes[o]):0,r[a]=this.cubes[a].vol>1?this.variance(this.cubes[a]):0):(r[o]=0,a--),o=0;let s=r[0];for(let i=1;i<=a;i++)r[i]>s&&(s=r[i],o=i);if(s<=0){n=a+1;break}}return new Zt(t,n)}createResult(t){let r=[];for(let n=0;n<t;++n){let o=this.cubes[n],a=this.volume(o,this.weights);if(a>0){let s=Math.round(this.volume(o,this.momentsR)/a),i=Math.round(this.volume(o,this.momentsG)/a),c=Math.round(this.volume(o,this.momentsB)/a),u=255<<24|(s&255)<<16|(i&255)<<8|c&255;r.push(u);}}return r}variance(t){let r=this.volume(t,this.momentsR),n=this.volume(t,this.momentsG),o=this.volume(t,this.momentsB),a=this.moments[this.getIndex(t.r1,t.g1,t.b1)]-this.moments[this.getIndex(t.r1,t.g1,t.b0)]-this.moments[this.getIndex(t.r1,t.g0,t.b1)]+this.moments[this.getIndex(t.r1,t.g0,t.b0)]-this.moments[this.getIndex(t.r0,t.g1,t.b1)]+this.moments[this.getIndex(t.r0,t.g1,t.b0)]+this.moments[this.getIndex(t.r0,t.g0,t.b1)]-this.moments[this.getIndex(t.r0,t.g0,t.b0)],s=r*r+n*n+o*o,i=this.volume(t,this.weights);return a-s/i}cut(t,r){let n=this.volume(t,this.momentsR),o=this.volume(t,this.momentsG),a=this.volume(t,this.momentsB),s=this.volume(t,this.weights),i=this.maximize(t,j.RED,t.r0+1,t.r1,n,o,a,s),c=this.maximize(t,j.GREEN,t.g0+1,t.g1,n,o,a,s),u=this.maximize(t,j.BLUE,t.b0+1,t.b1,n,o,a,s),l,f=i.maximum,g=c.maximum,p=u.maximum;if(f>=g&&f>=p){if(i.cutLocation<0)return !1;l=j.RED;}else g>=f&&g>=p?l=j.GREEN:l=j.BLUE;switch(r.r1=t.r1,r.g1=t.g1,r.b1=t.b1,l){case j.RED:t.r1=i.cutLocation,r.r0=t.r1,r.g0=t.g0,r.b0=t.b0;break;case j.GREEN:t.g1=c.cutLocation,r.r0=t.r0,r.g0=t.g1,r.b0=t.b0;break;case j.BLUE:t.b1=u.cutLocation,r.r0=t.r0,r.g0=t.g0,r.b0=t.b1;break;default:throw new Error("unexpected direction "+l)}return t.vol=(t.r1-t.r0)*(t.g1-t.g0)*(t.b1-t.b0),r.vol=(r.r1-r.r0)*(r.g1-r.g0)*(r.b1-r.b0),!0}maximize(t,r,n,o,a,s,i,c){let u=this.bottom(t,r,this.momentsR),l=this.bottom(t,r,this.momentsG),f=this.bottom(t,r,this.momentsB),g=this.bottom(t,r,this.weights),p=0,y=-1,C=0,P=0,T=0,d=0;for(let A=n;A<o;A++){if(C=u+this.top(t,r,A,this.momentsR),P=l+this.top(t,r,A,this.momentsG),T=f+this.top(t,r,A,this.momentsB),d=g+this.top(t,r,A,this.weights),d===0)continue;let w=(C*C+P*P+T*T)*1,O=d*1,R=w/O;C=a-C,P=s-P,T=i-T,d=c-d,d!==0&&(w=(C*C+P*P+T*T)*1,O=d*1,R+=w/O,R>p&&(p=R,y=A));}return new Kt(y,p)}volume(t,r){return r[this.getIndex(t.r1,t.g1,t.b1)]-r[this.getIndex(t.r1,t.g1,t.b0)]-r[this.getIndex(t.r1,t.g0,t.b1)]+r[this.getIndex(t.r1,t.g0,t.b0)]-r[this.getIndex(t.r0,t.g1,t.b1)]+r[this.getIndex(t.r0,t.g1,t.b0)]+r[this.getIndex(t.r0,t.g0,t.b1)]-r[this.getIndex(t.r0,t.g0,t.b0)]}bottom(t,r,n){switch(r){case j.RED:return -n[this.getIndex(t.r0,t.g1,t.b1)]+n[this.getIndex(t.r0,t.g1,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case j.GREEN:return -n[this.getIndex(t.r1,t.g0,t.b1)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g0,t.b1)]-n[this.getIndex(t.r0,t.g0,t.b0)];case j.BLUE:return -n[this.getIndex(t.r1,t.g1,t.b0)]+n[this.getIndex(t.r1,t.g0,t.b0)]+n[this.getIndex(t.r0,t.g1,t.b0)]-n[this.getIndex(t.r0,t.g0,t.b0)];default:throw new Error("unexpected direction $direction")}}top(t,r,n,o){switch(r){case j.RED:return o[this.getIndex(n,t.g1,t.b1)]-o[this.getIndex(n,t.g1,t.b0)]-o[this.getIndex(n,t.g0,t.b1)]+o[this.getIndex(n,t.g0,t.b0)];case j.GREEN:return o[this.getIndex(t.r1,n,t.b1)]-o[this.getIndex(t.r1,n,t.b0)]-o[this.getIndex(t.r0,n,t.b1)]+o[this.getIndex(t.r0,n,t.b0)];case j.BLUE:return o[this.getIndex(t.r1,t.g1,n)]-o[this.getIndex(t.r1,t.g0,n)]-o[this.getIndex(t.r0,t.g1,n)]+o[this.getIndex(t.r0,t.g0,n)];default:throw new Error("unexpected direction $direction")}}getIndex(t,r,n){return (t<<Bt*2)+(t<<Bt+1)+t+(r<<Bt)+r+n}},Xt=class{constructor(t=0,r=0,n=0,o=0,a=0,s=0,i=0){this.r0=t,this.r1=r,this.g0=n,this.g1=o,this.b0=a,this.b1=s,this.vol=i;}},Zt=class{constructor(t,r){this.requestedCount=t,this.resultCount=r;}},Kt=class{constructor(t,r){this.cutLocation=t,this.maximum=r;}};var St=class{static quantize(t,r){let o=new Ot().quantize(t,r);return Ft.quantize(t,o,r)}};var $=class{get primary(){return this.props.primary}get onPrimary(){return this.props.onPrimary}get primaryContainer(){return this.props.primaryContainer}get onPrimaryContainer(){return this.props.onPrimaryContainer}get secondary(){return this.props.secondary}get onSecondary(){return this.props.onSecondary}get secondaryContainer(){return this.props.secondaryContainer}get onSecondaryContainer(){return this.props.onSecondaryContainer}get tertiary(){return this.props.tertiary}get onTertiary(){return this.props.onTertiary}get tertiaryContainer(){return this.props.tertiaryContainer}get onTertiaryContainer(){return this.props.onTertiaryContainer}get error(){return this.props.error}get onError(){return this.props.onError}get errorContainer(){return this.props.errorContainer}get onErrorContainer(){return this.props.onErrorContainer}get background(){return this.props.background}get onBackground(){return this.props.onBackground}get surface(){return this.props.surface}get onSurface(){return this.props.onSurface}get surfaceVariant(){return this.props.surfaceVariant}get onSurfaceVariant(){return this.props.onSurfaceVariant}get outline(){return this.props.outline}get outlineVariant(){return this.props.outlineVariant}get shadow(){return this.props.shadow}get scrim(){return this.props.scrim}get inverseSurface(){return this.props.inverseSurface}get inverseOnSurface(){return this.props.inverseOnSurface}get inversePrimary(){return this.props.inversePrimary}static light(t){return $.lightFromCorePalette(L.of(t))}static dark(t){return $.darkFromCorePalette(L.of(t))}static lightContent(t){return $.lightFromCorePalette(L.contentOf(t))}static darkContent(t){return $.darkFromCorePalette(L.contentOf(t))}static lightFromCorePalette(t){return new $({primary:t.a1.tone(40),onPrimary:t.a1.tone(100),primaryContainer:t.a1.tone(90),onPrimaryContainer:t.a1.tone(10),secondary:t.a2.tone(40),onSecondary:t.a2.tone(100),secondaryContainer:t.a2.tone(90),onSecondaryContainer:t.a2.tone(10),tertiary:t.a3.tone(40),onTertiary:t.a3.tone(100),tertiaryContainer:t.a3.tone(90),onTertiaryContainer:t.a3.tone(10),error:t.error.tone(40),onError:t.error.tone(100),errorContainer:t.error.tone(90),onErrorContainer:t.error.tone(10),background:t.n1.tone(99),onBackground:t.n1.tone(10),surface:t.n1.tone(99),onSurface:t.n1.tone(10),surfaceVariant:t.n2.tone(90),onSurfaceVariant:t.n2.tone(30),outline:t.n2.tone(50),outlineVariant:t.n2.tone(80),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(20),inverseOnSurface:t.n1.tone(95),inversePrimary:t.a1.tone(80)})}static darkFromCorePalette(t){return new $({primary:t.a1.tone(80),onPrimary:t.a1.tone(20),primaryContainer:t.a1.tone(30),onPrimaryContainer:t.a1.tone(90),secondary:t.a2.tone(80),onSecondary:t.a2.tone(20),secondaryContainer:t.a2.tone(30),onSecondaryContainer:t.a2.tone(90),tertiary:t.a3.tone(80),onTertiary:t.a3.tone(20),tertiaryContainer:t.a3.tone(30),onTertiaryContainer:t.a3.tone(90),error:t.error.tone(80),onError:t.error.tone(20),errorContainer:t.error.tone(30),onErrorContainer:t.error.tone(80),background:t.n1.tone(10),onBackground:t.n1.tone(90),surface:t.n1.tone(10),onSurface:t.n1.tone(90),surfaceVariant:t.n2.tone(30),onSurfaceVariant:t.n2.tone(80),outline:t.n2.tone(60),outlineVariant:t.n2.tone(30),shadow:t.n1.tone(0),scrim:t.n1.tone(0),inverseSurface:t.n1.tone(90),inverseOnSurface:t.n1.tone(20),inversePrimary:t.a1.tone(40)})}constructor(t){this.props=t;}toJSON(){return {...this.props}}};var S=class{constructor(){}static score(t,r=!1){let n=0;for(let p of t.values())n+=p;let o=new Map,a=new Map,s=new Array(360).fill(0);for(let[p,y]of t.entries()){let C=y/n;o.set(p,C);let P=B.fromInt(p);a.set(p,P);let T=Math.round(P.hue);s[T]+=C;}let i=new Map;for(let[p,y]of a.entries()){let C=Math.round(y.hue),P=0;for(let T=C-15;T<C+15;T++){let d=Ut(T);P+=s[d];}i.set(p,P);}let c=new Map;for(let[p,y]of a.entries()){let P=i.get(p)*100*S.WEIGHT_PROPORTION,T=y.chroma<S.TARGET_CHROMA?S.WEIGHT_CHROMA_BELOW:S.WEIGHT_CHROMA_ABOVE,d=(y.chroma-S.TARGET_CHROMA)*T,A=P+d;c.set(p,A);}let u=r?S.filterContent(a):S.filter(i,a),l=new Map;for(let p of u){let y=!1,C=a.get(p).hue;for(let[P]of l){let T=a.get(P).hue;if(It(C,T)<15){y=!0;break}}y||l.set(p,c.get(p));}let f=Array.from(l.entries());f.sort((p,y)=>y[1]-p[1]);let g=f.map(p=>p[0]);return g.length===0&&g.push(4282549748),g}static filter(t,r){let n=new Array;for(let[o,a]of r.entries()){let s=t.get(o);a.chroma>=S.CUTOFF_CHROMA&&ut(o)>=S.CUTOFF_TONE&&s>=S.CUTOFF_EXCITED_PROPORTION&&n.push(o);}return n}static filterContent(t){return Array.from(t.keys())}};S.TARGET_CHROMA=48;S.WEIGHT_PROPORTION=.7;S.WEIGHT_CHROMA_ABOVE=.3;S.WEIGHT_CHROMA_BELOW=.1;S.CUTOFF_CHROMA=15;S.CUTOFF_TONE=10;S.CUTOFF_EXCITED_PROPORTION=.01;function dt(e){let t=ct(e),r=lt(e),n=ht(e),o=[t.toString(16),r.toString(16),n.toString(16)];for(let[a,s]of o.entries())s.length===1&&(o[a]="0"+s);return "#"+o.join("")}async function Qt(e){let t=await new Promise((s,i)=>{let c=document.createElement("canvas"),u=c.getContext("2d");if(!u){i(new Error("Could not get canvas context"));return}let l=()=>{c.width=e.width,c.height=e.height,u.drawImage(e,0,0);let f=[0,0,e.width,e.height],g=e.dataset.area;g&&/^\d+(\s*,\s*\d+){3}$/.test(g)&&(f=g.split(/\s*,\s*/).map(T=>parseInt(T,10)));let[p,y,C,P]=f;s(u.getImageData(p,y,C,P).data);};e.complete?l():e.onload=l;}),r=[];for(let s=0;s<t.length;s+=4){let i=t[s],c=t[s+1],u=t[s+2];if(t[s+3]<255)continue;let f=Ct(i,c,u);r.push(f);}let n=St.quantize(r,128);return S.score(n)[0]}function he(e,t){let r=t.value,n=r,o=e;t.blend&&(r=ft.harmonize(n,o));let s=L.of(r).a1;return {color:t,value:r,light:{color:s.tone(40),onColor:s.tone(100),colorContainer:s.tone(90),onColorContainer:s.tone(10)},dark:{color:s.tone(80),onColor:s.tone(20),colorContainer:s.tone(30),onColorContainer:s.tone(90)}}}var Te=Object.defineProperty,Ie=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gt=(e,t,r)=>(Ie(e,typeof t!="symbol"?t+"":t,r),r),_t=(e,t,r="",n)=>{for(let[o,a]of Object.entries(t.toJSON())){let s=o.replaceAll(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=n==="rgb"?Object.values($t(a)).slice(0,-1).join(" "):dt(a);e.style.setProperty(`--md-sys-color-${s}${r}`,i);}},ue=(e,t)=>{let r=t?.target||document.body,n=t?.dark??!1?e.schemes.dark:e.schemes.light;if(t!=null&&t.brightnessSuffix?(_t(r,e.schemes.dark,"-dark",t?.colorFormat),_t(r,e.schemes.light,"-light",t?.colorFormat)):_t(r,n,"",t?.colorFormat),t!=null&&t.paletteTones){let o=t?.paletteTones??[];for(let[a,s]of Object.entries(e.palettes)){let i=a.replaceAll(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();for(let c of o){let u=`--md-ref-palette-${i}${c}`,l=t?.colorFormat==="rgb"?Object.values($t(s.tone(c))).slice(0,-1).join(" "):dt(s.tone(c));r.style.setProperty(u,l);}}}},z=class{constructor(t,r){gt(this,"a1"),gt(this,"a2"),gt(this,"a3"),gt(this,"n1"),gt(this,"n2"),gt(this,"error");let{hue:n,chroma:o}=I.fromInt(t);r?(this.a1=M.fromHueAndChroma(n,o),this.a2=M.fromHueAndChroma(n,o/3),this.a3=M.fromHueAndChroma(n+60,o/2),this.n1=M.fromHueAndChroma(n,Math.min(o/12,4)),this.n2=M.fromHueAndChroma(n,Math.min(o/6,8))):(this.a1=M.fromHueAndChroma(n,Math.max(48,o)),this.a2=M.fromHueAndChroma(n,16),this.a3=M.fromHueAndChroma(n+60,24),this.n1=M.fromHueAndChroma(n,6),this.n2=M.fromHueAndChroma(n,8)),this.error=M.fromHueAndChroma(25,84);}static of(t){return new z(t,!1)}static contentOf(t){return new z(t,!0)}static fromColors(t){return z.createPaletteFromColors(!1,t)}static contentFromColors(t){return z.createPaletteFromColors(!0,t)}static createPaletteFromColors(t,r){let n=new z(r.primary,t);if(r.secondary){let o=new z(r.secondary,t);n.a2=o.a1;}if(r.tertiary){let o=new z(r.tertiary,t);n.a3=o.a1;}if(r.error){let o=new z(r.error,t);n.error=o.a1;}if(r.neutral){let o=new z(r.neutral,t);n.n1=o.n1;}if(r.neutralVariant){let o=new z(r.neutralVariant,t);n.n2=o.n2;}return n}},_=class{constructor(t){this.props=t;}get primary(){return this.props.primary}get onPrimary(){return this.props.onPrimary}get primaryContainer(){return this.props.primaryContainer}get onPrimaryContainer(){return this.props.onPrimaryContainer}get secondary(){return this.props.secondary}get onSecondary(){return this.props.onSecondary}get secondaryContainer(){return this.props.secondaryContainer}get onSecondaryContainer(){return this.props.onSecondaryContainer}get tertiary(){return this.props.tertiary}get onTertiary(){return this.props.onTertiary}get tertiaryContainer(){return this.props.tertiaryContainer}get onTertiaryContainer(){return this.props.onTertiaryContainer}get error(){return this.props.error}get onError(){return this.props.onError}get errorContainer(){return this.props.errorContainer}get onErrorContainer(){return this.props.onErrorContainer}get background(){return this.props.background}get onBackground(){return this.props.onBackground}get surface(){return this.props.surface}get onSurface(){return this.props.onSurface}get surfaceVariant(){return this.props.surfaceVariant}get onSurfaceVariant(){return this.props.onSurfaceVariant}get outline(){return this.props.outline}get outlineVariant(){return this.props.outlineVariant}get shadow(){return this.props.shadow}get scrim(){return this.props.scrim}get inverseSurface(){return this.props.inverseSurface}get inverseOnSurface(){return this.props.inverseOnSurface}get inversePrimary(){return this.props.inversePrimary}get surfaceBright(){return this.props.surfaceBright}get surfaceContainer(){return this.props.surfaceContainer}get s