diff --git a/dist/material-rounded-theme.js b/dist/material-rounded-theme.js index d29e3ca..8a57281 100644 --- a/dist/material-rounded-theme.js +++ b/dist/material-rounded-theme.js @@ -1,2 +1,2 @@ /*! For license information please see material-rounded-theme.js.LICENSE.txt */ -(()=>{"use strict";function t(t){return t<0?-1:0===t?0:1}function e(t,e,r){return(1-r)*t+r*e}function r(t,e,r){return re?e:r}function a(t){return(t%=360)<0&&(t+=360),t}function n(t){return(t%=360)<0&&(t+=360),t}function o(t,e){return[t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2]]}const i=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],s=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],c=[95.047,100,108.883];function u(t,e,r){return(255<<24|(255&t)<<16|(255&e)<<8|255&r)>>>0}function h(t){return u(P(t[0]),P(t[1]),P(t[2]))}function l(t){return t>>16&255}function d(t){return t>>8&255}function g(t){return 255&t}function m(t){const e=function(t){return o([C(l(t)),C(d(t)),C(g(t))],i)}(t)[1];return 116*b(e/100)-16}function f(t){return 100*function(t){const e=t*t*t;return e>216/24389?e:(116*t-16)/(24389/27)}((t+16)/116)}function y(t){return 116*b(t/100)-16}function C(t){const e=t/255;return e<=.040449936?e/12.92*100:100*Math.pow((e+.055)/1.055,2.4)}function P(t){const e=t/100;let r=0;return r=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,(a=Math.round(255*r))<0?0:a>255?255:a;var a}function b(t){return t>216/24389?Math.pow(t,1/3):(24389/27*t+16)/116}class p{static make(t=function(){return c}(),r=200/Math.PI*f(50)/100,a=50,n=2,o=!1){const i=t,s=.401288*i[0]+.650173*i[1]+-.051461*i[2],u=-.250268*i[0]+1.204414*i[1]+.045854*i[2],h=-.002079*i[0]+.048952*i[1]+.953127*i[2],l=.8+n/10,d=l>=.9?e(.59,.69,10*(l-.9)):e(.525,.59,10*(l-.8));let g=o?1:l*(1-1/3.6*Math.exp((-r-42)/92));g=g>1?1:g<0?0:g;const m=l,y=[g*(100/s)+1-g,g*(100/u)+1-g,g*(100/h)+1-g],C=1/(5*r+1),P=C*C*C*C,b=1-P,w=P*r+.1*b*b*Math.cbrt(5*r),M=f(a)/t[1],k=1.48+Math.sqrt(M),A=.725/Math.pow(M,.2),D=A,_=[Math.pow(w*y[0]*s/100,.42),Math.pow(w*y[1]*u/100,.42),Math.pow(w*y[2]*h/100,.42)],v=[400*_[0]/(_[0]+27.13),400*_[1]/(_[1]+27.13),400*_[2]/(_[2]+27.13)];return new p(M,(2*v[0]+v[1]+.05*v[2])*A,A,D,d,m,y,w,Math.pow(w,.25),k)}constructor(t,e,r,a,n,o,i,s,c,u){this.n=t,this.aw=e,this.nbb=r,this.ncb=a,this.c=n,this.nc=o,this.rgbD=i,this.fl=s,this.fLRoot=c,this.z=u}}p.DEFAULT=p.make();class w{constructor(t,e,r,a,n,o,i,s,c){this.hue=t,this.chroma=e,this.j=r,this.q=a,this.m=n,this.s=o,this.jstar=i,this.astar=s,this.bstar=c}distance(t){const e=this.jstar-t.jstar,r=this.astar-t.astar,a=this.bstar-t.bstar,n=Math.sqrt(e*e+r*r+a*a);return 1.41*Math.pow(n,.63)}static fromInt(t){return w.fromIntInViewingConditions(t,p.DEFAULT)}static fromIntInViewingConditions(e,r){const a=(65280&e)>>8,n=255&e,o=C((16711680&e)>>16),i=C(a),s=C(n),c=.41233895*o+.35762064*i+.18051042*s,u=.2126*o+.7152*i+.0722*s,h=.01932141*o+.11916382*i+.95034478*s,l=.401288*c+.650173*u-.051461*h,d=-.250268*c+1.204414*u+.045854*h,g=-.002079*c+.048952*u+.953127*h,m=r.rgbD[0]*l,f=r.rgbD[1]*d,y=r.rgbD[2]*g,P=Math.pow(r.fl*Math.abs(m)/100,.42),b=Math.pow(r.fl*Math.abs(f)/100,.42),p=Math.pow(r.fl*Math.abs(y)/100,.42),M=400*t(m)*P/(P+27.13),k=400*t(f)*b/(b+27.13),A=400*t(y)*p/(p+27.13),D=(11*M+-12*k+A)/11,_=(M+k-2*A)/9,v=(20*M+20*k+21*A)/20,T=(40*M+20*k+A)/20,x=180*Math.atan2(_,D)/Math.PI,I=x<0?x+360:x>=360?x-360:x,F=I*Math.PI/180,R=T*r.nbb,O=100*Math.pow(R/r.aw,r.c*r.z),S=4/r.c*Math.sqrt(O/100)*(r.aw+4)*r.fLRoot,L=I<20.14?I+360:I,B=5e4/13*(.25*(Math.cos(L*Math.PI/180+2)+3.8))*r.nc*r.ncb*Math.sqrt(D*D+_*_)/(v+.305),H=Math.pow(B,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),E=H*Math.sqrt(O/100),V=E*r.fLRoot,N=50*Math.sqrt(H*r.c/(r.aw+4)),q=(1+100*.007)*O/(1+.007*O),U=1/.0228*Math.log(1+.0228*V),G=U*Math.cos(F),z=U*Math.sin(F);return new w(I,E,O,S,V,N,q,G,z)}static fromJch(t,e,r){return w.fromJchInViewingConditions(t,e,r,p.DEFAULT)}static fromJchInViewingConditions(t,e,r,a){const n=4/a.c*Math.sqrt(t/100)*(a.aw+4)*a.fLRoot,o=e*a.fLRoot,i=e/Math.sqrt(t/100),s=50*Math.sqrt(i*a.c/(a.aw+4)),c=r*Math.PI/180,u=(1+100*.007)*t/(1+.007*t),h=1/.0228*Math.log(1+.0228*o),l=h*Math.cos(c),d=h*Math.sin(c);return new w(r,e,t,n,o,s,u,l,d)}static fromUcs(t,e,r){return w.fromUcsInViewingConditions(t,e,r,p.DEFAULT)}static fromUcsInViewingConditions(t,e,r,a){const n=e,o=r,i=Math.sqrt(n*n+o*o),s=(Math.exp(.0228*i)-1)/.0228/a.fLRoot;let c=Math.atan2(o,n)*(180/Math.PI);c<0&&(c+=360);const u=t/(1-.007*(t-100));return w.fromJchInViewingConditions(u,s,c,a)}toInt(){return this.viewed(p.DEFAULT)}viewed(e){const r=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,o=.25*(Math.cos(n+2)+3.8),i=e.aw*Math.pow(this.j/100,1/e.c/e.z),c=o*(5e4/13)*e.nc*e.ncb,h=i/e.nbb,l=Math.sin(n),d=Math.cos(n),g=23*(h+.305)*a/(23*c+11*a*d+108*a*l),m=g*d,f=g*l,y=(460*h+451*m+288*f)/1403,C=(460*h-891*m-261*f)/1403,b=(460*h-220*m-6300*f)/1403,p=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),w=t(y)*(100/e.fl)*Math.pow(p,1/.42),M=Math.max(0,27.13*Math.abs(C)/(400-Math.abs(C))),k=t(C)*(100/e.fl)*Math.pow(M,1/.42),A=Math.max(0,27.13*Math.abs(b)/(400-Math.abs(b))),D=t(b)*(100/e.fl)*Math.pow(A,1/.42),_=w/e.rgbD[0],v=k/e.rgbD[1],T=D/e.rgbD[2];return function(t,e,r){const a=s,n=a[0][0]*t+a[0][1]*e+a[0][2]*r,o=a[1][0]*t+a[1][1]*e+a[1][2]*r,i=a[2][0]*t+a[2][1]*e+a[2][2]*r;return u(P(n),P(o),P(i))}(1.86206786*_-1.01125463*v+.14918677*T,.38752654*_+.62144744*v-.00897398*T,-.0158415*_-.03412294*v+1.04996444*T)}static fromXyzInViewingConditions(e,r,a,n){const o=.401288*e+.650173*r-.051461*a,i=-.250268*e+1.204414*r+.045854*a,s=-.002079*e+.048952*r+.953127*a,c=n.rgbD[0]*o,u=n.rgbD[1]*i,h=n.rgbD[2]*s,l=Math.pow(n.fl*Math.abs(c)/100,.42),d=Math.pow(n.fl*Math.abs(u)/100,.42),g=Math.pow(n.fl*Math.abs(h)/100,.42),m=400*t(c)*l/(l+27.13),f=400*t(u)*d/(d+27.13),y=400*t(h)*g/(g+27.13),C=(11*m+-12*f+y)/11,P=(m+f-2*y)/9,b=(20*m+20*f+21*y)/20,p=(40*m+20*f+y)/20,M=180*Math.atan2(P,C)/Math.PI,k=M<0?M+360:M>=360?M-360:M,A=k*Math.PI/180,D=p*n.nbb,_=100*Math.pow(D/n.aw,n.c*n.z),v=4/n.c*Math.sqrt(_/100)*(n.aw+4)*n.fLRoot,T=k<20.14?k+360:k,x=5e4/13*(1/4*(Math.cos(T*Math.PI/180+2)+3.8))*n.nc*n.ncb*Math.sqrt(C*C+P*P)/(b+.305),I=Math.pow(x,.9)*Math.pow(1.64-Math.pow(.29,n.n),.73),F=I*Math.sqrt(_/100),R=F*n.fLRoot,O=50*Math.sqrt(I*n.c/(n.aw+4)),S=(1+100*.007)*_/(1+.007*_),L=Math.log(1+.0228*R)/.0228,B=L*Math.cos(A),H=L*Math.sin(A);return new w(k,F,_,v,R,O,S,B,H)}xyzInViewingConditions(e){const r=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,o=.25*(Math.cos(n+2)+3.8),i=e.aw*Math.pow(this.j/100,1/e.c/e.z),s=o*(5e4/13)*e.nc*e.ncb,c=i/e.nbb,u=Math.sin(n),h=Math.cos(n),l=23*(c+.305)*a/(23*s+11*a*h+108*a*u),d=l*h,g=l*u,m=(460*c+451*d+288*g)/1403,f=(460*c-891*d-261*g)/1403,y=(460*c-220*d-6300*g)/1403,C=Math.max(0,27.13*Math.abs(m)/(400-Math.abs(m))),P=t(m)*(100/e.fl)*Math.pow(C,1/.42),b=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),p=t(f)*(100/e.fl)*Math.pow(b,1/.42),w=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),M=t(y)*(100/e.fl)*Math.pow(w,1/.42),k=P/e.rgbD[0],A=p/e.rgbD[1],D=M/e.rgbD[2];return[1.86206786*k-1.01125463*A+.14918677*D,.38752654*k+.62144744*A-.00897398*D,-.0158415*k-.03412294*A+1.04996444*D]}}class M{static sanitizeRadians(t){return(t+8*Math.PI)%(2*Math.PI)}static trueDelinearized(t){const e=t/100;let r=0;return r=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,255*r}static chromaticAdaptation(e){const r=Math.pow(Math.abs(e),.42);return 400*t(e)*r/(r+27.13)}static hueOf(t){const e=o(t,M.SCALED_DISCOUNT_FROM_LINRGB),r=M.chromaticAdaptation(e[0]),a=M.chromaticAdaptation(e[1]),n=M.chromaticAdaptation(e[2]),i=(11*r+-12*a+n)/11,s=(r+a-2*n)/9;return Math.atan2(s,i)}static areInCyclicOrder(t,e,r){return M.sanitizeRadians(e-t)100.01||w[1]>100.01||w[2]>100.01?0:h(w);a-=(_-r)*a/(2*_)}return 0}static solveToInt(t,e,r){if(e<1e-4||r<1e-4||r>99.9999)return function(t){const e=P(f(t));return u(e,e,e)}(r);const a=(t=n(t))/180*Math.PI,o=f(r),i=M.findResultByJ(a,e,o);return 0!==i?i:h(M.bisectToLimit(o,a))}static solveToCam(t,e,r){return w.fromInt(M.solveToInt(t,e,r))}}M.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]],M.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]],M.Y_FROM_LINRGB=[.2126,.7152,.0722],M.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];class k{static from(t,e,r){return new k(M.solveToInt(t,e,r))}static fromInt(t){return new k(t)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(t){this.setInternalState(M.solveToInt(t,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(t){this.setInternalState(M.solveToInt(this.internalHue,t,this.internalTone))}get tone(){return this.internalTone}set tone(t){this.setInternalState(M.solveToInt(this.internalHue,this.internalChroma,t))}constructor(t){this.argb=t;const e=w.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=m(t),this.argb=t}setInternalState(t){const e=w.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=m(t),this.argb=t}inViewingConditions(t){const e=w.fromInt(this.toInt()).xyzInViewingConditions(t),r=w.fromXyzInViewingConditions(e[0],e[1],e[2],p.make());return k.from(r.hue,r.chroma,y(e[1]))}}class A{static isDisliked(t){const e=Math.round(t.hue)>=90&&Math.round(t.hue)<=111,r=Math.round(t.chroma)>16,a=Math.round(t.tone)<65;return e&&r&&a}static fixIfDisliked(t){return A.isDisliked(t)?k.from(t.hue,t.chroma,70):t}}class D{static fromInt(t){const e=k.fromInt(t);return D.fromHct(e)}static fromHct(t){return new D(t.hue,t.chroma,t)}static fromHueAndChroma(t,e){const r=new _(t,e).create();return new D(t,e,r)}constructor(t,e,r){this.hue=t,this.chroma=e,this.keyColor=r,this.cache=new Map}tone(t){let e=this.cache.get(t);return void 0===e&&(e=k.from(this.hue,this.chroma,t).toInt(),this.cache.set(t,e)),e}getHct(t){return k.fromInt(this.tone(t))}}class _{constructor(t,e){this.hue=t,this.requestedChroma=e,this.chromaCache=new Map,this.maxChromaValue=200}create(){let t=0,e=100;for(;t=this.requestedChroma-.01)if(Math.abs(t-50)e?t:e;return(r+5)/((r===e?t:e)+5)}static lighter(t,e){if(t<0||t>100)return-1;const r=f(t),a=e*(r+5)-5,n=T.ratioOfYs(a,r),o=Math.abs(n-e);if(n.04)return-1;const i=y(a)+.4;return i<0||i>100?-1:i}static darker(t,e){if(t<0||t>100)return-1;const r=f(t),a=(r+5)/e-5,n=T.ratioOfYs(r,a),o=Math.abs(n-e);if(n.04)return-1;const i=y(a)-.4;return i<0||i>100?-1:i}static lighterUnsafe(t,e){const r=T.lighter(t,e);return r<0?100:r}static darkerUnsafe(t,e){const r=T.darker(t,e);return r<0?0:r}}class x{static fromPalette(t){return new x(t.name??"",t.palette,t.tone,t.isBackground??!1,t.background,t.secondBackground,t.contrastCurve,t.toneDeltaPair)}constructor(t,e,r,a,n,o,i,s){if(this.name=t,this.palette=e,this.tone=r,this.isBackground=a,this.background=n,this.secondBackground=o,this.contrastCurve=i,this.toneDeltaPair=s,this.hctCache=new Map,!n&&o)throw new Error(`Color ${t} has secondBackgrounddefined, but background is not defined.`);if(!n&&i)throw new Error(`Color ${t} has contrastCurvedefined, but background is not defined.`);if(n&&!i)throw new Error(`Color ${t} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(t){return this.getHct(t).toInt()}getHct(t){const e=this.hctCache.get(t);if(null!=e)return e;const r=this.getTone(t),a=this.palette(t).getHct(r);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,a),a}getTone(t){const e=t.contrastLevel<0;if(this.toneDeltaPair){const a=this.toneDeltaPair(t),n=a.roleA,o=a.roleB,i=a.delta,s=a.polarity,c=a.stayTogether,u=this.background(t).getTone(t),h="nearer"===s||"lighter"===s&&!t.isDark||"darker"===s&&t.isDark,l=h?n:o,d=h?o:n,g=this.name===l.name,m=t.isDark?1:-1,f=l.contrastCurve.get(t.contrastLevel),y=d.contrastCurve.get(t.contrastLevel),C=l.tone(t);let P=T.ratioOfTones(u,C)>=f?C:x.foregroundTone(u,f);const b=d.tone(t);let p=T.ratioOfTones(u,b)>=y?b:x.foregroundTone(u,y);return e&&(P=x.foregroundTone(u,f),p=x.foregroundTone(u,y)),(p-P)*m>=i||(p=r(0,100,P+i*m),(p-P)*m>=i||(P=r(0,100,p-i*m))),50<=P&&P<60?m>0?(P=60,p=Math.max(p,P+i*m)):(P=49,p=Math.min(p,P+i*m)):50<=p&&p<60&&(c?m>0?(P=60,p=Math.max(p,P+i*m)):(P=49,p=Math.min(p,P+i*m)):p=m>0?60:49),g?P:p}{let r=this.tone(t);if(null==this.background)return r;const a=this.background(t).getTone(t),n=this.contrastCurve.get(t.contrastLevel);if(T.ratioOfTones(a,r)>=n||(r=x.foregroundTone(a,n)),e&&(r=x.foregroundTone(a,n)),this.isBackground&&50<=r&&r<60&&(r=T.ratioOfTones(49,a)>=n?49:60),this.secondBackground){const[e,a]=[this.background,this.secondBackground],[o,i]=[e(t).getTone(t),a(t).getTone(t)],[s,c]=[Math.max(o,i),Math.min(o,i)];if(T.ratioOfTones(s,r)>=n&&T.ratioOfTones(c,r)>=n)return r;const u=T.lighter(s,n),h=T.darker(c,n),l=[];return-1!==u&&l.push(u),-1!==h&&l.push(h),x.tonePrefersLightForeground(o)||x.tonePrefersLightForeground(i)?u<0?100:u:1===l.length?l[0]:h<0?0:h}return r}}static foregroundTone(t,e){const r=T.lighterUnsafe(t,e),a=T.darkerUnsafe(t,e),n=T.ratioOfTones(r,t),o=T.ratioOfTones(a,t);if(x.tonePrefersLightForeground(t)){const t=Math.abs(n-o)<.1&&n=e||n>=o||t?r:a}return o>=e||o>=n?a:r}static tonePrefersLightForeground(t){return Math.round(t)<60}static toneAllowsLightForeground(t){return Math.round(t)<=49}static enableLightForeground(t){return x.tonePrefersLightForeground(t)&&!x.toneAllowsLightForeground(t)?49:t}}class I{constructor(t,e,r,a,n){this.roleA=t,this.roleB=e,this.delta=r,this.polarity=a,this.stayTogether=n}}var F;function R(t){return t.variant===F.FIDELITY||t.variant===F.CONTENT}function O(t){return t.variant===F.MONOCHROME}!function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"}(F||(F={}));class S{static highestSurface(t){return t.isDark?S.surfaceBright:S.surfaceDim}}S.contentAccentToneDelta=15,S.primaryPaletteKeyColor=x.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone}),S.secondaryPaletteKeyColor=x.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone}),S.tertiaryPaletteKeyColor=x.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone}),S.neutralPaletteKeyColor=x.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone}),S.neutralVariantPaletteKeyColor=x.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone}),S.background=x.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),S.onBackground=x.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>S.background,contrastCurve:new v(3,3,4.5,7)}),S.surface=x.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),S.surfaceDim=x.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new v(87,87,80,75).get(t.contrastLevel),isBackground:!0}),S.surfaceBright=x.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(24,24,29,34).get(t.contrastLevel):98,isBackground:!0}),S.surfaceContainerLowest=x.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(4,4,2,0).get(t.contrastLevel):100,isBackground:!0}),S.surfaceContainerLow=x.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(10,10,11,12).get(t.contrastLevel):new v(96,96,96,95).get(t.contrastLevel),isBackground:!0}),S.surfaceContainer=x.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(12,12,16,20).get(t.contrastLevel):new v(94,94,92,90).get(t.contrastLevel),isBackground:!0}),S.surfaceContainerHigh=x.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(17,17,21,25).get(t.contrastLevel):new v(92,92,88,85).get(t.contrastLevel),isBackground:!0}),S.surfaceContainerHighest=x.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(22,22,26,30).get(t.contrastLevel):new v(90,90,84,80).get(t.contrastLevel),isBackground:!0}),S.onSurface=x.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>S.highestSurface(t),contrastCurve:new v(4.5,7,11,21)}),S.surfaceVariant=x.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0}),S.onSurfaceVariant=x.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,11)}),S.inverseSurface=x.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20}),S.inverseOnSurface=x.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>S.inverseSurface,contrastCurve:new v(4.5,7,11,21)}),S.outline=x.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>S.highestSurface(t),contrastCurve:new v(1.5,3,4.5,7)}),S.outlineVariant=x.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5)}),S.shadow=x.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0}),S.scrim=x.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0}),S.surfaceTint=x.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0}),S.primary=x.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>O(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.primaryContainer,S.primary,10,"nearer",!1)}),S.onPrimary=x.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>O(t)?t.isDark?10:90:t.isDark?20:100,background:t=>S.primary,contrastCurve:new v(4.5,7,11,21)}),S.primaryContainer=x.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>R(t)?t.sourceColorHct.tone:O(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryContainer,S.primary,10,"nearer",!1)}),S.onPrimaryContainer=x.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>R(t)?x.foregroundTone(S.primaryContainer.tone(t),4.5):O(t)?t.isDark?0:100:t.isDark?90:30,background:t=>S.primaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.inversePrimary=x.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>S.inverseSurface,contrastCurve:new v(3,4.5,7,7)}),S.secondary=x.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.secondaryContainer,S.secondary,10,"nearer",!1)}),S.onSecondary=x.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>O(t)?t.isDark?10:100:t.isDark?20:100,background:t=>S.secondary,contrastCurve:new v(4.5,7,11,21)}),S.secondaryContainer=x.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{const e=t.isDark?30:90;return O(t)?t.isDark?30:85:R(t)?function(t,e,r,a){let n=r,o=k.from(t,e,r);if(o.chromai.chroma)break;if(Math.abs(i.chroma-e)<.4)break;Math.abs(i.chroma-e)S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryContainer,S.secondary,10,"nearer",!1)}),S.onSecondaryContainer=x.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>O(t)?t.isDark?90:10:R(t)?x.foregroundTone(S.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>S.secondaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.tertiary=x.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.tertiaryContainer,S.tertiary,10,"nearer",!1)}),S.onTertiary=x.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?10:90:t.isDark?20:100,background:t=>S.tertiary,contrastCurve:new v(4.5,7,11,21)}),S.tertiaryContainer=x.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(O(t))return t.isDark?60:49;if(!R(t))return t.isDark?30:90;const e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return A.fixIfDisliked(e).tone},isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryContainer,S.tertiary,10,"nearer",!1)}),S.onTertiaryContainer=x.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?0:100:R(t)?x.foregroundTone(S.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>S.tertiaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.error=x.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.errorContainer,S.error,10,"nearer",!1)}),S.onError=x.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>S.error,contrastCurve:new v(4.5,7,11,21)}),S.errorContainer=x.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.errorContainer,S.error,10,"nearer",!1)}),S.onErrorContainer=x.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>O(t)?t.isDark?90:10:t.isDark?90:30,background:t=>S.errorContainer,contrastCurve:new v(3,4.5,7,11)}),S.primaryFixed=x.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>O(t)?40:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryFixed,S.primaryFixedDim,10,"lighter",!0)}),S.primaryFixedDim=x.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>O(t)?30:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryFixed,S.primaryFixedDim,10,"lighter",!0)}),S.onPrimaryFixed=x.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>O(t)?100:10,background:t=>S.primaryFixedDim,secondBackground:t=>S.primaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onPrimaryFixedVariant=x.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>O(t)?90:30,background:t=>S.primaryFixedDim,secondBackground:t=>S.primaryFixed,contrastCurve:new v(3,4.5,7,11)}),S.secondaryFixed=x.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>O(t)?80:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryFixed,S.secondaryFixedDim,10,"lighter",!0)}),S.secondaryFixedDim=x.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>O(t)?70:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryFixed,S.secondaryFixedDim,10,"lighter",!0)}),S.onSecondaryFixed=x.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>S.secondaryFixedDim,secondBackground:t=>S.secondaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onSecondaryFixedVariant=x.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>O(t)?25:30,background:t=>S.secondaryFixedDim,secondBackground:t=>S.secondaryFixed,contrastCurve:new v(3,4.5,7,11)}),S.tertiaryFixed=x.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>O(t)?40:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryFixed,S.tertiaryFixedDim,10,"lighter",!0)}),S.tertiaryFixedDim=x.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>O(t)?30:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryFixed,S.tertiaryFixedDim,10,"lighter",!0)}),S.onTertiaryFixed=x.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>O(t)?100:10,background:t=>S.tertiaryFixedDim,secondBackground:t=>S.tertiaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onTertiaryFixedVariant=x.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>O(t)?90:30,background:t=>S.tertiaryFixedDim,secondBackground:t=>S.tertiaryFixed,contrastCurve:new v(3,4.5,7,11)});class L{constructor(t){this.sourceColorArgb=t.sourceColorArgb,this.variant=t.variant,this.contrastLevel=t.contrastLevel,this.isDark=t.isDark,this.sourceColorHct=k.fromInt(t.sourceColorArgb),this.primaryPalette=t.primaryPalette,this.secondaryPalette=t.secondaryPalette,this.tertiaryPalette=t.tertiaryPalette,this.neutralPalette=t.neutralPalette,this.neutralVariantPalette=t.neutralVariantPalette,this.errorPalette=D.fromHueAndChroma(25,84)}static getRotatedHue(t,e,r){const a=t.hue;if(e.length!==r.length)throw new Error(`mismatch between hue length ${e.length} & rotations ${r.length}`);if(1===r.length)return n(t.hue+r[0]);const o=e.length;for(let t=0;t<=o-2;t++){const o=e[t],i=e[t+1];if(oe.score?-1:t.score=15;t--){l.length=0;for(const{hct:e}of h)if(l.find((r=>{return a=e.hue,n=r.hue,180-Math.abs(Math.abs(a-n)-180)=r)break;if(l.length>=r)break}const d=[];0===l.length&&d.push(n);for(const t of l)d.push(t.toInt());return d}}function U(t){const e=l(t),r=d(t),a=g(t),n=[e.toString(16),r.toString(16),a.toString(16)];for(const[t,e]of n.entries())1===e.length&&(n[t]="0"+e);return"#"+n.join("")}function G(t){const e=3===(t=t.replace("#","")).length,r=6===t.length,a=8===t.length;if(!e&&!r&&!a)throw new Error("unexpected hex "+t);let n=0,o=0,i=0;return e?(n=z(t.slice(0,1).repeat(2)),o=z(t.slice(1,2).repeat(2)),i=z(t.slice(2,3).repeat(2))):r?(n=z(t.slice(0,2)),o=z(t.slice(2,4)),i=z(t.slice(4,6))):a&&(n=z(t.slice(2,4)),o=z(t.slice(4,6)),i=z(t.slice(6,8))),(255<<24|(255&n)<<16|(255&o)<<8|255&i)>>>0}function z(t){return parseInt(t,16)}q.TARGET_CHROMA=48,q.WEIGHT_PROPORTION=.7,q.WEIGHT_CHROMA_ABOVE=.3,q.WEIGHT_CHROMA_BELOW=.1,q.CUTOFF_CHROMA=5,q.CUTOFF_EXCITED_PROPORTION=.01;const K=["primary","onPrimary","primaryContainer","onPrimaryContainer","primaryPaletteKeyColor","inversePrimary","primaryFixed","primaryFixedDim","onPrimaryFixed","onPrimaryFixedVariant","secondary","onSecondary","secondaryContainer","onSecondaryContainer","secondaryPaletteKeyColor","secondaryFixed","secondaryFixedDim","onSecondaryFixed","onSecondaryFixedVariant","tertiary","onTertiary","tertiaryContainer","onTertiaryContainer","tertiaryPaletteKeyColor","tertiaryFixed","tertiaryFixedDim","onTertiaryFixed","onTertiaryFixedVariant","neutralPaletteKeyColor","neutralVariantPaletteKeyColor","error","onError","errorContainer","onErrorContainer","surface","onSurface","surfaceVariant","onSurfaceVariant","surfaceDim","surfaceBright","surfaceContainerLowest","surfaceContainerLow","surfaceContainer","surfaceContainerHigh","surfaceContainerHighest","inverseSurface","inverseOnSurface","surfaceTint","outline","outlineVariant","shadow","scrim"];async function $(t,e){for(;!t.querySelector(e);)await new Promise((t=>requestAnimationFrame(t)));return t.querySelector(e)}$(document,"home-assistant").then((t=>{const e=t?.shadowRoot?.querySelector("home-assistant-main"),r=document.querySelector("html"),a=t.hass.user?.name.toLowerCase().replace(" ","_"),n=t.hass.user?.id,o="sensor.material_rounded_base_color",i=`${o}_${a}`,s=`${o}_${n}`;function c(){for(const t of K){const e=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();r?.style.removeProperty(`--md-sys-color-${e}-light`),r?.style.removeProperty(`--md-sys-color-${e}-dark`)}console.info("Material design system colors removed.")}function u(){{try{const u=t.hass?.themes?.theme??"";if(u.includes("Material Rounded")||u.includes("Material You")){let u;if(a&&(u=t.hass.states[i]?.state),!u&&n&&(u=t.hass.states[s]?.state),u||(u=t.hass.states[o]?.state),u){const t=[r],a=e?.shadowRoot?.querySelector("iframe")?.contentWindow?.document?.querySelector("body");a&&t.push(a);for(const e of["light","dark"]){const r=new H(k.fromInt(G(u)),"dark"==e,0),a={};for(const t of K)a[t]=S[t].getArgb(r);for(const[r,n]of Object.entries(a)){const a=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=U(n);for(const r of t)r?.style.setProperty(`--md-sys-color-${a}-${e}`,o)}}r?.style.removeProperty("background-color"),console.info(`Material design system colors updated using user defined base color ${u}.`)}else c()}}catch(t){console.error(t),c()}const u={type:"theme-update"};window.externalApp?window.externalApp.externalBus(JSON.stringify(u)):window.webkit&&window.webkit.messageHandlers.externalBus.postMessage(u)}}u(),t.hass.connection.subscribeMessage((()=>u()),{type:"subscribe_trigger",trigger:{platform:"state",entity_id:[o,i,s].filter((e=>t.hass.states[e]))}},{resubscribe:!0}),t.hass.connection.subscribeEvents((()=>u()),"themes_updated"),t.hass.connection.subscribeEvents((t=>{"set_theme"==t?.data?.service&&setTimeout((()=>u()),1e3)}),"call_service"),new MutationObserver((t=>{for(const r of t)for(const t of r.addedNodes)"IFRAME"==t.nodeName&&$(e?.shadowRoot,"iframe").then((t=>{$(t?.contentWindow?.document,"body").then((()=>u()))}))})).observe(e?.shadowRoot,{subtree:!0,childList:!0})}))})(); \ No newline at end of file +(()=>{"use strict";function t(t){return t<0?-1:0===t?0:1}function e(t,e,r){return(1-r)*t+r*e}function r(t,e,r){return re?e:r}function a(t){return(t%=360)<0&&(t+=360),t}function n(t){return(t%=360)<0&&(t+=360),t}function o(t,e){return[t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2]]}const i=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],s=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],c=[95.047,100,108.883];function u(t,e,r){return(255<<24|(255&t)<<16|(255&e)<<8|255&r)>>>0}function h(t){return u(P(t[0]),P(t[1]),P(t[2]))}function l(t){return t>>16&255}function d(t){return t>>8&255}function g(t){return 255&t}function m(t){const e=function(t){return o([C(l(t)),C(d(t)),C(g(t))],i)}(t)[1];return 116*b(e/100)-16}function f(t){return 100*function(t){const e=t*t*t;return e>216/24389?e:(116*t-16)/(24389/27)}((t+16)/116)}function y(t){return 116*b(t/100)-16}function C(t){const e=t/255;return e<=.040449936?e/12.92*100:100*Math.pow((e+.055)/1.055,2.4)}function P(t){const e=t/100;let r=0;return r=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,(a=Math.round(255*r))<0?0:a>255?255:a;var a}function b(t){return t>216/24389?Math.pow(t,1/3):(24389/27*t+16)/116}class p{static make(t=function(){return c}(),r=200/Math.PI*f(50)/100,a=50,n=2,o=!1){const i=t,s=.401288*i[0]+.650173*i[1]+-.051461*i[2],u=-.250268*i[0]+1.204414*i[1]+.045854*i[2],h=-.002079*i[0]+.048952*i[1]+.953127*i[2],l=.8+n/10,d=l>=.9?e(.59,.69,10*(l-.9)):e(.525,.59,10*(l-.8));let g=o?1:l*(1-1/3.6*Math.exp((-r-42)/92));g=g>1?1:g<0?0:g;const m=l,y=[g*(100/s)+1-g,g*(100/u)+1-g,g*(100/h)+1-g],C=1/(5*r+1),P=C*C*C*C,b=1-P,w=P*r+.1*b*b*Math.cbrt(5*r),M=f(a)/t[1],k=1.48+Math.sqrt(M),A=.725/Math.pow(M,.2),D=A,_=[Math.pow(w*y[0]*s/100,.42),Math.pow(w*y[1]*u/100,.42),Math.pow(w*y[2]*h/100,.42)],v=[400*_[0]/(_[0]+27.13),400*_[1]/(_[1]+27.13),400*_[2]/(_[2]+27.13)];return new p(M,(2*v[0]+v[1]+.05*v[2])*A,A,D,d,m,y,w,Math.pow(w,.25),k)}constructor(t,e,r,a,n,o,i,s,c,u){this.n=t,this.aw=e,this.nbb=r,this.ncb=a,this.c=n,this.nc=o,this.rgbD=i,this.fl=s,this.fLRoot=c,this.z=u}}p.DEFAULT=p.make();class w{constructor(t,e,r,a,n,o,i,s,c){this.hue=t,this.chroma=e,this.j=r,this.q=a,this.m=n,this.s=o,this.jstar=i,this.astar=s,this.bstar=c}distance(t){const e=this.jstar-t.jstar,r=this.astar-t.astar,a=this.bstar-t.bstar,n=Math.sqrt(e*e+r*r+a*a);return 1.41*Math.pow(n,.63)}static fromInt(t){return w.fromIntInViewingConditions(t,p.DEFAULT)}static fromIntInViewingConditions(e,r){const a=(65280&e)>>8,n=255&e,o=C((16711680&e)>>16),i=C(a),s=C(n),c=.41233895*o+.35762064*i+.18051042*s,u=.2126*o+.7152*i+.0722*s,h=.01932141*o+.11916382*i+.95034478*s,l=.401288*c+.650173*u-.051461*h,d=-.250268*c+1.204414*u+.045854*h,g=-.002079*c+.048952*u+.953127*h,m=r.rgbD[0]*l,f=r.rgbD[1]*d,y=r.rgbD[2]*g,P=Math.pow(r.fl*Math.abs(m)/100,.42),b=Math.pow(r.fl*Math.abs(f)/100,.42),p=Math.pow(r.fl*Math.abs(y)/100,.42),M=400*t(m)*P/(P+27.13),k=400*t(f)*b/(b+27.13),A=400*t(y)*p/(p+27.13),D=(11*M+-12*k+A)/11,_=(M+k-2*A)/9,v=(20*M+20*k+21*A)/20,T=(40*M+20*k+A)/20,x=180*Math.atan2(_,D)/Math.PI,I=x<0?x+360:x>=360?x-360:x,F=I*Math.PI/180,R=T*r.nbb,O=100*Math.pow(R/r.aw,r.c*r.z),S=4/r.c*Math.sqrt(O/100)*(r.aw+4)*r.fLRoot,L=I<20.14?I+360:I,B=5e4/13*(.25*(Math.cos(L*Math.PI/180+2)+3.8))*r.nc*r.ncb*Math.sqrt(D*D+_*_)/(v+.305),H=Math.pow(B,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),E=H*Math.sqrt(O/100),V=E*r.fLRoot,N=50*Math.sqrt(H*r.c/(r.aw+4)),q=(1+100*.007)*O/(1+.007*O),U=1/.0228*Math.log(1+.0228*V),G=U*Math.cos(F),z=U*Math.sin(F);return new w(I,E,O,S,V,N,q,G,z)}static fromJch(t,e,r){return w.fromJchInViewingConditions(t,e,r,p.DEFAULT)}static fromJchInViewingConditions(t,e,r,a){const n=4/a.c*Math.sqrt(t/100)*(a.aw+4)*a.fLRoot,o=e*a.fLRoot,i=e/Math.sqrt(t/100),s=50*Math.sqrt(i*a.c/(a.aw+4)),c=r*Math.PI/180,u=(1+100*.007)*t/(1+.007*t),h=1/.0228*Math.log(1+.0228*o),l=h*Math.cos(c),d=h*Math.sin(c);return new w(r,e,t,n,o,s,u,l,d)}static fromUcs(t,e,r){return w.fromUcsInViewingConditions(t,e,r,p.DEFAULT)}static fromUcsInViewingConditions(t,e,r,a){const n=e,o=r,i=Math.sqrt(n*n+o*o),s=(Math.exp(.0228*i)-1)/.0228/a.fLRoot;let c=Math.atan2(o,n)*(180/Math.PI);c<0&&(c+=360);const u=t/(1-.007*(t-100));return w.fromJchInViewingConditions(u,s,c,a)}toInt(){return this.viewed(p.DEFAULT)}viewed(e){const r=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,o=.25*(Math.cos(n+2)+3.8),i=e.aw*Math.pow(this.j/100,1/e.c/e.z),c=o*(5e4/13)*e.nc*e.ncb,h=i/e.nbb,l=Math.sin(n),d=Math.cos(n),g=23*(h+.305)*a/(23*c+11*a*d+108*a*l),m=g*d,f=g*l,y=(460*h+451*m+288*f)/1403,C=(460*h-891*m-261*f)/1403,b=(460*h-220*m-6300*f)/1403,p=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),w=t(y)*(100/e.fl)*Math.pow(p,1/.42),M=Math.max(0,27.13*Math.abs(C)/(400-Math.abs(C))),k=t(C)*(100/e.fl)*Math.pow(M,1/.42),A=Math.max(0,27.13*Math.abs(b)/(400-Math.abs(b))),D=t(b)*(100/e.fl)*Math.pow(A,1/.42),_=w/e.rgbD[0],v=k/e.rgbD[1],T=D/e.rgbD[2];return function(t,e,r){const a=s,n=a[0][0]*t+a[0][1]*e+a[0][2]*r,o=a[1][0]*t+a[1][1]*e+a[1][2]*r,i=a[2][0]*t+a[2][1]*e+a[2][2]*r;return u(P(n),P(o),P(i))}(1.86206786*_-1.01125463*v+.14918677*T,.38752654*_+.62144744*v-.00897398*T,-.0158415*_-.03412294*v+1.04996444*T)}static fromXyzInViewingConditions(e,r,a,n){const o=.401288*e+.650173*r-.051461*a,i=-.250268*e+1.204414*r+.045854*a,s=-.002079*e+.048952*r+.953127*a,c=n.rgbD[0]*o,u=n.rgbD[1]*i,h=n.rgbD[2]*s,l=Math.pow(n.fl*Math.abs(c)/100,.42),d=Math.pow(n.fl*Math.abs(u)/100,.42),g=Math.pow(n.fl*Math.abs(h)/100,.42),m=400*t(c)*l/(l+27.13),f=400*t(u)*d/(d+27.13),y=400*t(h)*g/(g+27.13),C=(11*m+-12*f+y)/11,P=(m+f-2*y)/9,b=(20*m+20*f+21*y)/20,p=(40*m+20*f+y)/20,M=180*Math.atan2(P,C)/Math.PI,k=M<0?M+360:M>=360?M-360:M,A=k*Math.PI/180,D=p*n.nbb,_=100*Math.pow(D/n.aw,n.c*n.z),v=4/n.c*Math.sqrt(_/100)*(n.aw+4)*n.fLRoot,T=k<20.14?k+360:k,x=5e4/13*(1/4*(Math.cos(T*Math.PI/180+2)+3.8))*n.nc*n.ncb*Math.sqrt(C*C+P*P)/(b+.305),I=Math.pow(x,.9)*Math.pow(1.64-Math.pow(.29,n.n),.73),F=I*Math.sqrt(_/100),R=F*n.fLRoot,O=50*Math.sqrt(I*n.c/(n.aw+4)),S=(1+100*.007)*_/(1+.007*_),L=Math.log(1+.0228*R)/.0228,B=L*Math.cos(A),H=L*Math.sin(A);return new w(k,F,_,v,R,O,S,B,H)}xyzInViewingConditions(e){const r=0===this.chroma||0===this.j?0:this.chroma/Math.sqrt(this.j/100),a=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),n=this.hue*Math.PI/180,o=.25*(Math.cos(n+2)+3.8),i=e.aw*Math.pow(this.j/100,1/e.c/e.z),s=o*(5e4/13)*e.nc*e.ncb,c=i/e.nbb,u=Math.sin(n),h=Math.cos(n),l=23*(c+.305)*a/(23*s+11*a*h+108*a*u),d=l*h,g=l*u,m=(460*c+451*d+288*g)/1403,f=(460*c-891*d-261*g)/1403,y=(460*c-220*d-6300*g)/1403,C=Math.max(0,27.13*Math.abs(m)/(400-Math.abs(m))),P=t(m)*(100/e.fl)*Math.pow(C,1/.42),b=Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),p=t(f)*(100/e.fl)*Math.pow(b,1/.42),w=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),M=t(y)*(100/e.fl)*Math.pow(w,1/.42),k=P/e.rgbD[0],A=p/e.rgbD[1],D=M/e.rgbD[2];return[1.86206786*k-1.01125463*A+.14918677*D,.38752654*k+.62144744*A-.00897398*D,-.0158415*k-.03412294*A+1.04996444*D]}}class M{static sanitizeRadians(t){return(t+8*Math.PI)%(2*Math.PI)}static trueDelinearized(t){const e=t/100;let r=0;return r=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,255*r}static chromaticAdaptation(e){const r=Math.pow(Math.abs(e),.42);return 400*t(e)*r/(r+27.13)}static hueOf(t){const e=o(t,M.SCALED_DISCOUNT_FROM_LINRGB),r=M.chromaticAdaptation(e[0]),a=M.chromaticAdaptation(e[1]),n=M.chromaticAdaptation(e[2]),i=(11*r+-12*a+n)/11,s=(r+a-2*n)/9;return Math.atan2(s,i)}static areInCyclicOrder(t,e,r){return M.sanitizeRadians(e-t)100.01||w[1]>100.01||w[2]>100.01?0:h(w);a-=(_-r)*a/(2*_)}return 0}static solveToInt(t,e,r){if(e<1e-4||r<1e-4||r>99.9999)return function(t){const e=P(f(t));return u(e,e,e)}(r);const a=(t=n(t))/180*Math.PI,o=f(r),i=M.findResultByJ(a,e,o);return 0!==i?i:h(M.bisectToLimit(o,a))}static solveToCam(t,e,r){return w.fromInt(M.solveToInt(t,e,r))}}M.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]],M.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]],M.Y_FROM_LINRGB=[.2126,.7152,.0722],M.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];class k{static from(t,e,r){return new k(M.solveToInt(t,e,r))}static fromInt(t){return new k(t)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(t){this.setInternalState(M.solveToInt(t,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(t){this.setInternalState(M.solveToInt(this.internalHue,t,this.internalTone))}get tone(){return this.internalTone}set tone(t){this.setInternalState(M.solveToInt(this.internalHue,this.internalChroma,t))}constructor(t){this.argb=t;const e=w.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=m(t),this.argb=t}setInternalState(t){const e=w.fromInt(t);this.internalHue=e.hue,this.internalChroma=e.chroma,this.internalTone=m(t),this.argb=t}inViewingConditions(t){const e=w.fromInt(this.toInt()).xyzInViewingConditions(t),r=w.fromXyzInViewingConditions(e[0],e[1],e[2],p.make());return k.from(r.hue,r.chroma,y(e[1]))}}class A{static isDisliked(t){const e=Math.round(t.hue)>=90&&Math.round(t.hue)<=111,r=Math.round(t.chroma)>16,a=Math.round(t.tone)<65;return e&&r&&a}static fixIfDisliked(t){return A.isDisliked(t)?k.from(t.hue,t.chroma,70):t}}class D{static fromInt(t){const e=k.fromInt(t);return D.fromHct(e)}static fromHct(t){return new D(t.hue,t.chroma,t)}static fromHueAndChroma(t,e){const r=new _(t,e).create();return new D(t,e,r)}constructor(t,e,r){this.hue=t,this.chroma=e,this.keyColor=r,this.cache=new Map}tone(t){let e=this.cache.get(t);return void 0===e&&(e=k.from(this.hue,this.chroma,t).toInt(),this.cache.set(t,e)),e}getHct(t){return k.fromInt(this.tone(t))}}class _{constructor(t,e){this.hue=t,this.requestedChroma=e,this.chromaCache=new Map,this.maxChromaValue=200}create(){let t=0,e=100;for(;t=this.requestedChroma-.01)if(Math.abs(t-50)e?t:e;return(r+5)/((r===e?t:e)+5)}static lighter(t,e){if(t<0||t>100)return-1;const r=f(t),a=e*(r+5)-5,n=T.ratioOfYs(a,r),o=Math.abs(n-e);if(n.04)return-1;const i=y(a)+.4;return i<0||i>100?-1:i}static darker(t,e){if(t<0||t>100)return-1;const r=f(t),a=(r+5)/e-5,n=T.ratioOfYs(r,a),o=Math.abs(n-e);if(n.04)return-1;const i=y(a)-.4;return i<0||i>100?-1:i}static lighterUnsafe(t,e){const r=T.lighter(t,e);return r<0?100:r}static darkerUnsafe(t,e){const r=T.darker(t,e);return r<0?0:r}}class x{static fromPalette(t){return new x(t.name??"",t.palette,t.tone,t.isBackground??!1,t.background,t.secondBackground,t.contrastCurve,t.toneDeltaPair)}constructor(t,e,r,a,n,o,i,s){if(this.name=t,this.palette=e,this.tone=r,this.isBackground=a,this.background=n,this.secondBackground=o,this.contrastCurve=i,this.toneDeltaPair=s,this.hctCache=new Map,!n&&o)throw new Error(`Color ${t} has secondBackgrounddefined, but background is not defined.`);if(!n&&i)throw new Error(`Color ${t} has contrastCurvedefined, but background is not defined.`);if(n&&!i)throw new Error(`Color ${t} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(t){return this.getHct(t).toInt()}getHct(t){const e=this.hctCache.get(t);if(null!=e)return e;const r=this.getTone(t),a=this.palette(t).getHct(r);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,a),a}getTone(t){const e=t.contrastLevel<0;if(this.toneDeltaPair){const a=this.toneDeltaPair(t),n=a.roleA,o=a.roleB,i=a.delta,s=a.polarity,c=a.stayTogether,u=this.background(t).getTone(t),h="nearer"===s||"lighter"===s&&!t.isDark||"darker"===s&&t.isDark,l=h?n:o,d=h?o:n,g=this.name===l.name,m=t.isDark?1:-1,f=l.contrastCurve.get(t.contrastLevel),y=d.contrastCurve.get(t.contrastLevel),C=l.tone(t);let P=T.ratioOfTones(u,C)>=f?C:x.foregroundTone(u,f);const b=d.tone(t);let p=T.ratioOfTones(u,b)>=y?b:x.foregroundTone(u,y);return e&&(P=x.foregroundTone(u,f),p=x.foregroundTone(u,y)),(p-P)*m>=i||(p=r(0,100,P+i*m),(p-P)*m>=i||(P=r(0,100,p-i*m))),50<=P&&P<60?m>0?(P=60,p=Math.max(p,P+i*m)):(P=49,p=Math.min(p,P+i*m)):50<=p&&p<60&&(c?m>0?(P=60,p=Math.max(p,P+i*m)):(P=49,p=Math.min(p,P+i*m)):p=m>0?60:49),g?P:p}{let r=this.tone(t);if(null==this.background)return r;const a=this.background(t).getTone(t),n=this.contrastCurve.get(t.contrastLevel);if(T.ratioOfTones(a,r)>=n||(r=x.foregroundTone(a,n)),e&&(r=x.foregroundTone(a,n)),this.isBackground&&50<=r&&r<60&&(r=T.ratioOfTones(49,a)>=n?49:60),this.secondBackground){const[e,a]=[this.background,this.secondBackground],[o,i]=[e(t).getTone(t),a(t).getTone(t)],[s,c]=[Math.max(o,i),Math.min(o,i)];if(T.ratioOfTones(s,r)>=n&&T.ratioOfTones(c,r)>=n)return r;const u=T.lighter(s,n),h=T.darker(c,n),l=[];return-1!==u&&l.push(u),-1!==h&&l.push(h),x.tonePrefersLightForeground(o)||x.tonePrefersLightForeground(i)?u<0?100:u:1===l.length?l[0]:h<0?0:h}return r}}static foregroundTone(t,e){const r=T.lighterUnsafe(t,e),a=T.darkerUnsafe(t,e),n=T.ratioOfTones(r,t),o=T.ratioOfTones(a,t);if(x.tonePrefersLightForeground(t)){const t=Math.abs(n-o)<.1&&n=e||n>=o||t?r:a}return o>=e||o>=n?a:r}static tonePrefersLightForeground(t){return Math.round(t)<60}static toneAllowsLightForeground(t){return Math.round(t)<=49}static enableLightForeground(t){return x.tonePrefersLightForeground(t)&&!x.toneAllowsLightForeground(t)?49:t}}class I{constructor(t,e,r,a,n){this.roleA=t,this.roleB=e,this.delta=r,this.polarity=a,this.stayTogether=n}}var F;function R(t){return t.variant===F.FIDELITY||t.variant===F.CONTENT}function O(t){return t.variant===F.MONOCHROME}!function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"}(F||(F={}));class S{static highestSurface(t){return t.isDark?S.surfaceBright:S.surfaceDim}}S.contentAccentToneDelta=15,S.primaryPaletteKeyColor=x.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone}),S.secondaryPaletteKeyColor=x.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone}),S.tertiaryPaletteKeyColor=x.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone}),S.neutralPaletteKeyColor=x.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone}),S.neutralVariantPaletteKeyColor=x.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone}),S.background=x.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),S.onBackground=x.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>S.background,contrastCurve:new v(3,3,4.5,7)}),S.surface=x.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0}),S.surfaceDim=x.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new v(87,87,80,75).get(t.contrastLevel),isBackground:!0}),S.surfaceBright=x.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(24,24,29,34).get(t.contrastLevel):98,isBackground:!0}),S.surfaceContainerLowest=x.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(4,4,2,0).get(t.contrastLevel):100,isBackground:!0}),S.surfaceContainerLow=x.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(10,10,11,12).get(t.contrastLevel):new v(96,96,96,95).get(t.contrastLevel),isBackground:!0}),S.surfaceContainer=x.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(12,12,16,20).get(t.contrastLevel):new v(94,94,92,90).get(t.contrastLevel),isBackground:!0}),S.surfaceContainerHigh=x.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(17,17,21,25).get(t.contrastLevel):new v(92,92,88,85).get(t.contrastLevel),isBackground:!0}),S.surfaceContainerHighest=x.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new v(22,22,26,30).get(t.contrastLevel):new v(90,90,84,80).get(t.contrastLevel),isBackground:!0}),S.onSurface=x.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>S.highestSurface(t),contrastCurve:new v(4.5,7,11,21)}),S.surfaceVariant=x.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0}),S.onSurfaceVariant=x.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,11)}),S.inverseSurface=x.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20}),S.inverseOnSurface=x.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>S.inverseSurface,contrastCurve:new v(4.5,7,11,21)}),S.outline=x.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>S.highestSurface(t),contrastCurve:new v(1.5,3,4.5,7)}),S.outlineVariant=x.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5)}),S.shadow=x.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0}),S.scrim=x.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0}),S.surfaceTint=x.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0}),S.primary=x.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>O(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.primaryContainer,S.primary,10,"nearer",!1)}),S.onPrimary=x.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>O(t)?t.isDark?10:90:t.isDark?20:100,background:t=>S.primary,contrastCurve:new v(4.5,7,11,21)}),S.primaryContainer=x.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>R(t)?t.sourceColorHct.tone:O(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryContainer,S.primary,10,"nearer",!1)}),S.onPrimaryContainer=x.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>R(t)?x.foregroundTone(S.primaryContainer.tone(t),4.5):O(t)?t.isDark?0:100:t.isDark?90:30,background:t=>S.primaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.inversePrimary=x.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>S.inverseSurface,contrastCurve:new v(3,4.5,7,7)}),S.secondary=x.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.secondaryContainer,S.secondary,10,"nearer",!1)}),S.onSecondary=x.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>O(t)?t.isDark?10:100:t.isDark?20:100,background:t=>S.secondary,contrastCurve:new v(4.5,7,11,21)}),S.secondaryContainer=x.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{const e=t.isDark?30:90;return O(t)?t.isDark?30:85:R(t)?function(t,e,r,a){let n=r,o=k.from(t,e,r);if(o.chromai.chroma)break;if(Math.abs(i.chroma-e)<.4)break;Math.abs(i.chroma-e)S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryContainer,S.secondary,10,"nearer",!1)}),S.onSecondaryContainer=x.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>O(t)?t.isDark?90:10:R(t)?x.foregroundTone(S.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>S.secondaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.tertiary=x.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.tertiaryContainer,S.tertiary,10,"nearer",!1)}),S.onTertiary=x.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?10:90:t.isDark?20:100,background:t=>S.tertiary,contrastCurve:new v(4.5,7,11,21)}),S.tertiaryContainer=x.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(O(t))return t.isDark?60:49;if(!R(t))return t.isDark?30:90;const e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return A.fixIfDisliked(e).tone},isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryContainer,S.tertiary,10,"nearer",!1)}),S.onTertiaryContainer=x.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>O(t)?t.isDark?0:100:R(t)?x.foregroundTone(S.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>S.tertiaryContainer,contrastCurve:new v(3,4.5,7,11)}),S.error=x.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(3,4.5,7,7),toneDeltaPair:t=>new I(S.errorContainer,S.error,10,"nearer",!1)}),S.onError=x.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>S.error,contrastCurve:new v(4.5,7,11,21)}),S.errorContainer=x.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.errorContainer,S.error,10,"nearer",!1)}),S.onErrorContainer=x.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>O(t)?t.isDark?90:10:t.isDark?90:30,background:t=>S.errorContainer,contrastCurve:new v(3,4.5,7,11)}),S.primaryFixed=x.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>O(t)?40:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryFixed,S.primaryFixedDim,10,"lighter",!0)}),S.primaryFixedDim=x.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>O(t)?30:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.primaryFixed,S.primaryFixedDim,10,"lighter",!0)}),S.onPrimaryFixed=x.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>O(t)?100:10,background:t=>S.primaryFixedDim,secondBackground:t=>S.primaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onPrimaryFixedVariant=x.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>O(t)?90:30,background:t=>S.primaryFixedDim,secondBackground:t=>S.primaryFixed,contrastCurve:new v(3,4.5,7,11)}),S.secondaryFixed=x.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>O(t)?80:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryFixed,S.secondaryFixedDim,10,"lighter",!0)}),S.secondaryFixedDim=x.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>O(t)?70:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.secondaryFixed,S.secondaryFixedDim,10,"lighter",!0)}),S.onSecondaryFixed=x.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>S.secondaryFixedDim,secondBackground:t=>S.secondaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onSecondaryFixedVariant=x.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>O(t)?25:30,background:t=>S.secondaryFixedDim,secondBackground:t=>S.secondaryFixed,contrastCurve:new v(3,4.5,7,11)}),S.tertiaryFixed=x.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>O(t)?40:90,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryFixed,S.tertiaryFixedDim,10,"lighter",!0)}),S.tertiaryFixedDim=x.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>O(t)?30:80,isBackground:!0,background:t=>S.highestSurface(t),contrastCurve:new v(1,1,3,4.5),toneDeltaPair:t=>new I(S.tertiaryFixed,S.tertiaryFixedDim,10,"lighter",!0)}),S.onTertiaryFixed=x.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>O(t)?100:10,background:t=>S.tertiaryFixedDim,secondBackground:t=>S.tertiaryFixed,contrastCurve:new v(4.5,7,11,21)}),S.onTertiaryFixedVariant=x.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>O(t)?90:30,background:t=>S.tertiaryFixedDim,secondBackground:t=>S.tertiaryFixed,contrastCurve:new v(3,4.5,7,11)});class L{constructor(t){this.sourceColorArgb=t.sourceColorArgb,this.variant=t.variant,this.contrastLevel=t.contrastLevel,this.isDark=t.isDark,this.sourceColorHct=k.fromInt(t.sourceColorArgb),this.primaryPalette=t.primaryPalette,this.secondaryPalette=t.secondaryPalette,this.tertiaryPalette=t.tertiaryPalette,this.neutralPalette=t.neutralPalette,this.neutralVariantPalette=t.neutralVariantPalette,this.errorPalette=D.fromHueAndChroma(25,84)}static getRotatedHue(t,e,r){const a=t.hue;if(e.length!==r.length)throw new Error(`mismatch between hue length ${e.length} & rotations ${r.length}`);if(1===r.length)return n(t.hue+r[0]);const o=e.length;for(let t=0;t<=o-2;t++){const o=e[t],i=e[t+1];if(oe.score?-1:t.score=15;t--){l.length=0;for(const{hct:e}of h)if(l.find((r=>{return a=e.hue,n=r.hue,180-Math.abs(Math.abs(a-n)-180)=r)break;if(l.length>=r)break}const d=[];0===l.length&&d.push(n);for(const t of l)d.push(t.toInt());return d}}function U(t){const e=l(t),r=d(t),a=g(t),n=[e.toString(16),r.toString(16),a.toString(16)];for(const[t,e]of n.entries())1===e.length&&(n[t]="0"+e);return"#"+n.join("")}function G(t){const e=3===(t=t.replace("#","")).length,r=6===t.length,a=8===t.length;if(!e&&!r&&!a)throw new Error("unexpected hex "+t);let n=0,o=0,i=0;return e?(n=z(t.slice(0,1).repeat(2)),o=z(t.slice(1,2).repeat(2)),i=z(t.slice(2,3).repeat(2))):r?(n=z(t.slice(0,2)),o=z(t.slice(2,4)),i=z(t.slice(4,6))):a&&(n=z(t.slice(2,4)),o=z(t.slice(4,6)),i=z(t.slice(6,8))),(255<<24|(255&n)<<16|(255&o)<<8|255&i)>>>0}function z(t){return parseInt(t,16)}q.TARGET_CHROMA=48,q.WEIGHT_PROPORTION=.7,q.WEIGHT_CHROMA_ABOVE=.3,q.WEIGHT_CHROMA_BELOW=.1,q.CUTOFF_CHROMA=5,q.CUTOFF_EXCITED_PROPORTION=.01;const K=["primary","onPrimary","primaryContainer","onPrimaryContainer","primaryPaletteKeyColor","inversePrimary","primaryFixed","primaryFixedDim","onPrimaryFixed","onPrimaryFixedVariant","secondary","onSecondary","secondaryContainer","onSecondaryContainer","secondaryPaletteKeyColor","secondaryFixed","secondaryFixedDim","onSecondaryFixed","onSecondaryFixedVariant","tertiary","onTertiary","tertiaryContainer","onTertiaryContainer","tertiaryPaletteKeyColor","tertiaryFixed","tertiaryFixedDim","onTertiaryFixed","onTertiaryFixedVariant","neutralPaletteKeyColor","neutralVariantPaletteKeyColor","error","onError","errorContainer","onErrorContainer","surface","onSurface","surfaceVariant","onSurfaceVariant","surfaceDim","surfaceBright","surfaceContainerLowest","surfaceContainerLow","surfaceContainer","surfaceContainerHigh","surfaceContainerHighest","inverseSurface","inverseOnSurface","surfaceTint","outline","outlineVariant","shadow","scrim"];async function $(t,e){for(;!t.querySelector(e);)await new Promise((t=>requestAnimationFrame(t)));return t.querySelector(e)}$(document,"home-assistant").then((t=>{const e=t?.shadowRoot?.querySelector("home-assistant-main"),r=document.querySelector("html"),a=t.hass.user?.name.toLowerCase().replace(/ /g,"_"),n=t.hass.user?.id,o="sensor.material_rounded_base_color",i=`${o}_${a}`,s=`${o}_${n}`;function c(){for(const t of K){const e=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();r?.style.removeProperty(`--md-sys-color-${e}-light`),r?.style.removeProperty(`--md-sys-color-${e}-dark`)}console.info("Material design system colors removed.")}function u(){{try{const u=t.hass?.themes?.theme??"";if(u.includes("Material Rounded")||u.includes("Material You")){let u;if(a&&(u=t.hass.states[i]?.state),!u&&n&&(u=t.hass.states[s]?.state),u||(u=t.hass.states[o]?.state),u){const t=[r],a=e?.shadowRoot?.querySelector("iframe")?.contentWindow?.document?.querySelector("body");a&&t.push(a);for(const e of["light","dark"]){const r=new H(k.fromInt(G(u)),"dark"==e,0),a={};for(const t of K)a[t]=S[t].getArgb(r);for(const[r,n]of Object.entries(a)){const a=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=U(n);for(const r of t)r?.style.setProperty(`--md-sys-color-${a}-${e}`,o)}}r?.style.removeProperty("background-color"),console.info(`Material design system colors updated using user defined base color ${u}.`)}else c()}}catch(t){console.error(t),c()}const u={type:"theme-update"};window.externalApp?window.externalApp.externalBus(JSON.stringify(u)):window.webkit&&window.webkit.messageHandlers.externalBus.postMessage(u)}}u(),t.hass.connection.subscribeMessage((()=>u()),{type:"subscribe_trigger",trigger:{platform:"state",entity_id:[o,i,s].filter((e=>t.hass.states[e]))}},{resubscribe:!0}),t.hass.connection.subscribeEvents((()=>u()),"themes_updated"),t.hass.connection.subscribeEvents((t=>{"set_theme"==t?.data?.service&&setTimeout((()=>u()),1e3)}),"call_service"),new MutationObserver((t=>{for(const r of t)for(const t of r.addedNodes)"IFRAME"==t.nodeName&&$(e?.shadowRoot,"iframe").then((t=>{$(t?.contentWindow?.document,"body").then((()=>u()))}))})).observe(e?.shadowRoot,{subtree:!0,childList:!0})}))})(); \ No newline at end of file diff --git a/src/material-rounded-theme.ts b/src/material-rounded-theme.ts index acf03f8..8fc6eb6 100644 --- a/src/material-rounded-theme.ts +++ b/src/material-rounded-theme.ts @@ -74,7 +74,7 @@ waitForElement(document, 'home-assistant').then((ha) => { const haMain = ha?.shadowRoot?.querySelector('home-assistant-main'); const html = document.querySelector('html'); - const userName = ha.hass.user?.name.toLowerCase().replace(' ', '_'); + const userName = ha.hass.user?.name.toLowerCase().replace(/ /g, '_'); const userId = ha.hass.user?.id; const sensorName = 'sensor.material_rounded_base_color';