c.d2e52e5a.js 481 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941
  1. import{Q as e,S as t,T as i,V as a,m as n,A as o,aY as s,r,aZ as l,aa as d,a7 as c,a_ as u,a$ as h,a9 as p,x as v,b0 as m,a as f,h as g,e as _,i as y,L as k,N as b,$ as x,z as $,ac as w,ad as C,n as A,b1 as I,aQ as E,b2 as z,b3 as S,b4 as T,b5 as L,b6 as O,b7 as M,b8 as P,b9 as F,aB as D,ba as B,bb as N,bc as V,bd as q,be as j,bf as R,bg as U,bh as H,bi as G,bj as W,bk as K,bl as Y,bm as Z,bn as Q,aS as J,bo as X,bp as ee,bq as te,br as ie,bs as ae,ag as ne,bt as oe,bu as se,bv as re,bw as le,bx as de,by as ce,bz as ue,bA as he,bB as pe,bC as ve,bD as me,bE as fe,bF as ge,bG as _e,bH as ye,bI as ke,bJ as be,bK as xe,bL as $e,bM as we,bN as Ce,bO as Ae,bP as Ie,bQ as Ee,bR as ze,E as Se,bS as Te,bT as Le,bU as Oe,bV as Me,bW as Pe,bX as Fe,bY as De,bZ as Be,b_ as Ne,b$ as Ve,c0 as qe,c1 as je,c2 as Re,c3 as Ue,c4 as He,c5 as Ge,c6 as We,c7 as Ke,c8 as Ye,c9 as Ze,ca as Qe,cb as Je,cc as Xe,cd as et,ce as tt,cf as it,cg as at,ch as nt,ci as ot,cj as st,ck as rt,cl as lt,cm as dt,cn as ct,co as ut,cp as ht,cq as pt,cr as vt,cs as mt,ct as ft,cu as gt,cv as _t,cw as yt,cx as kt,cy as bt,cz as xt,cA as $t,cB as wt,cC as Ct,cD as At,az as It,cE as Et,cF as zt,cG as St,cH as Tt,cI as Lt,cJ as Ot,cK as Mt,cL as Pt,cM as Ft,cN as Dt,cO as Bt,cP as Nt,cQ as Vt,cR as qt,cS as jt,cT as Rt,cU as Ut,cV as Ht,cW as Gt,cX as Wt,cY as Kt,cZ as Yt,c_ as Zt,c$ as Qt,d0 as Jt,d1 as Xt,d2 as ei,d3 as ti,d4 as ii,d5 as ai,d6 as ni,d7 as oi,d8 as si,d9 as ri,da as li,db as di,dc as ci,dd as ui,de as hi,df as pi,dg as vi,dh as mi,di as fi,dj as gi,dk as _i,dl as yi,dm as ki,dn as bi,dp as xi,dq as $i,dr as wi,ds as Ci,dt as Ai,du as Ii,dv as Ei,dw as zi,dx as Si,dy as Ti,dz as Li,dA as Oi,dB as Mi,dC as Pi,dD as Fi,dE as Di,dF as Bi,dG as Ni,dH as Vi,dI as qi,dJ as ji,dK as Ri,dL as Ui,dM as Hi,dN as Gi,dO as Wi,dP as Ki,dQ as Yi,dR as Zi,t as Qi,I as Ji,j as Xi,Z as ea,aK as ta,aD as ia,dS as aa,dT as na,dU as oa,dV as sa,dW as ra,dX as la,dY as da,dZ as ca,d_ as ua,d$ as ha,e0 as pa,e1 as va,aM as ma,e2 as fa,e3 as ga,e4 as _a,e5 as ya,e6 as ka,o as ba,e7 as xa,_ as $a,e8 as wa,e9 as Ca,ea as Aa,eb as Ia,ec as Ea,ed as za,ee as Sa,ef as Ta,eg as La,eh as Oa,ei as Ma,ej as Pa,ek as Fa,el as Da,em as Ba,en as Na,eo as Va,ep as qa,eq as ja,er as Ra,es as Ua,et as Ha,eu as Ga,ev as Wa,ax as Ka,ew as Ya,ex as Za,ey as Qa,ez as Ja,eA as Xa,eB as en,eC as tn,eD as an,eE as nn,eF as on,eG as sn,eH as rn,eI as ln,J as dn,af as cn}from"./main-ad130be7.js";import{d as un,a as hn}from"./c.d262aab0.js";import{a as pn,c as vn,u as mn,m as fn,s as gn,T as _n,b as yn,d as kn}from"./c.3f859915.js";import"./c.0ca5587f.js";import"./c.82eccc94.js";import"./c.f1291e50.js";import"./c.2d5ed670.js";import"./c.2ee83bd0.js";import{c as bn,u as xn}from"./c.743a15a1.js";import{s as $n,a as wn,b as Cn}from"./c.4266acdb.js";import{b as An,e as In}from"./c.0a1cf8d0.js";import{d as En}from"./c.9b92f489.js";import{i as zn}from"./c.21c042d4.js";import"./c.8d4c35ad.js";import{g as Sn}from"./c.f2bb3724.js";import"./c.4feb0cb8.js";import{a as Tn}from"./c.42d6aebd.js";import"./c.3da15c48.js";let Ln=!1,On=[],Mn=[];function Pn(){Ln=!0,requestAnimationFrame((function(){Ln=!1,function(e){for(;e.length;)Fn(e.shift())}(On),setTimeout((function(){!function(e){for(let t=0,i=e.length;t<i;t++)Fn(e.shift())}(Mn)}))}))}function Fn(e){const t=e[0],i=e[1],a=e[2];try{i.apply(t,a)}catch(e){setTimeout((()=>{throw e}))}}function Dn(e,t,i){Ln||Pn(),Mn.push([e,t,i])}const Bn=(e,t,i)=>{const a=new Map;for(let n=t;n<=i;n++)a.set(e[n],n);return a},Nn=e(class extends t{constructor(e){if(super(e),e.type!==i.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let a;void 0===i?i=t:void 0!==t&&(a=t);const n=[],o=[];let s=0;for(const t of e)n[s]=a?a(t,s):s,o[s]=i(t,s),s++;return{values:o,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,n]){var o;const s=pn(e),{values:r,keys:l}=this.dt(t,i,n);if(!Array.isArray(s))return this.at=l,r;const d=null!==(o=this.at)&&void 0!==o?o:this.at=[],c=[];let u,h,p=0,v=s.length-1,m=0,f=r.length-1;for(;p<=v&&m<=f;)if(null===s[p])p++;else if(null===s[v])v--;else if(d[p]===l[m])c[m]=vn(s[p],r[m]),p++,m++;else if(d[v]===l[f])c[f]=vn(s[v],r[f]),v--,f--;else if(d[p]===l[f])c[f]=vn(s[p],r[f]),mn(e,c[f+1],s[p]),p++,f--;else if(d[v]===l[m])c[m]=vn(s[v],r[m]),mn(e,s[p],s[v]),v--,m++;else if(void 0===u&&(u=Bn(l,m,f),h=Bn(d,p,v)),u.has(d[p]))if(u.has(d[v])){const t=h.get(l[m]),i=void 0!==t?s[t]:null;if(null===i){const t=mn(e,s[p]);vn(t,r[m]),c[m]=t}else c[m]=vn(i,r[m]),mn(e,s[p],i),s[t]=null;m++}else fn(s[v]),v--;else fn(s[p]),p++;for(;m<=f;){const t=mn(e,c[f+1]);vn(t,r[m]),c[m++]=t}for(;p<=v;){const e=s[p++];null!==e&&fn(e)}return this.at=l,gn(e,c),a}});function Vn(e){if(!e||"object"!=typeof e)return e;if("[object Date]"==Object.prototype.toString.call(e))return new Date(e.getTime());if(Array.isArray(e))return e.map(Vn);var t={};return Object.keys(e).forEach((function(i){t[i]=Vn(e[i])})),t}class qn extends TypeError{constructor(e,t){let i;const{message:a,...n}=e,{path:o}=e;super(0===o.length?a:"At path: "+o.join(".")+" -- "+a),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,n),this.name=this.constructor.name,this.failures=()=>{var a;return null!=(a=i)?a:i=[e,...t()]}}}function jn(e){return"object"==typeof e&&null!=e}function Rn(e){return"string"==typeof e?JSON.stringify(e):""+e}function Un(e,t,i,a){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:n,branch:o}=t,{type:s}=i,{refinement:r,message:l="Expected a value of type `"+s+"`"+(r?" with refinement `"+r+"`":"")+", but received: `"+Rn(a)+"`"}=e;return{value:a,type:s,refinement:r,key:n[n.length-1],path:n,branch:o,...e,message:l}}function*Hn(e,t,i,a){(function(e){return jn(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const n of e){const e=Un(n,t,i,a);e&&(yield e)}}function*Gn(e,t,i){void 0===i&&(i={});const{path:a=[],branch:n=[e],coerce:o=!1,mask:s=!1}=i,r={path:a,branch:n};if(o&&(e=t.coercer(e,r),s&&"type"!==t.type&&jn(t.schema)&&jn(e)&&!Array.isArray(e)))for(const i in e)void 0===t.schema[i]&&delete e[i];let l=!0;for(const i of t.validator(e,r))l=!1,yield[i,void 0];for(let[i,d,c]of t.entries(e,r)){const t=Gn(d,c,{path:void 0===i?a:[...a,i],branch:void 0===i?n:[...n,d],coerce:o,mask:s});for(const a of t)a[0]?(l=!1,yield[a[0],void 0]):o&&(d=a[1],void 0===i?e=d:e instanceof Map?e.set(i,d):e instanceof Set?e.add(d):jn(e)&&(e[i]=d))}if(l)for(const i of t.refiner(e,r))l=!1,yield[i,void 0];l&&(yield[void 0,e])}class Wn{constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:t,schema:i,validator:a,refiner:n,coercer:o=(e=>e),entries:s=function*(){}}=e;this.type=t,this.schema=i,this.entries=s,this.coercer=o,this.validator=a?(e,t)=>Hn(a(e,t),t,this,e):()=>[],this.refiner=n?(e,t)=>Hn(n(e,t),t,this,e):()=>[]}assert(e){return Kn(e,this)}create(e){return function(e,t){const i=Zn(e,t,{coerce:!0});if(i[0])throw i[0];return i[1]}(e,this)}is(e){return Yn(e,this)}mask(e){return function(e,t){const i=Zn(e,t,{coerce:!0,mask:!0});if(i[0])throw i[0];return i[1]}(e,this)}validate(e,t){return void 0===t&&(t={}),Zn(e,this,t)}}function Kn(e,t){const i=Zn(e,t);if(i[0])throw i[0]}function Yn(e,t){return!Zn(e,t)[0]}function Zn(e,t,i){void 0===i&&(i={});const a=Gn(e,t,i),n=function(e){const{done:t,value:i}=e.next();return t?void 0:i}(a);if(n[0]){const e=new qn(n[0],(function*(){for(const e of a)e[0]&&(yield e[0])}));return[e,void 0]}return[void 0,n[1]]}function Qn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const a="type"===t[0].type,n=t.map((e=>e.schema)),o=Object.assign({},...n);return a?ro(o):no(o)}function Jn(e,t){return new Wn({type:e,schema:null,validator:t})}function Xn(){return Jn("any",(()=>!0))}function eo(e){return new Wn({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[i,a]of t.entries())yield[i,a,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||"Expected an array value, but received: "+Rn(e)})}function to(){return Jn("boolean",(e=>"boolean"==typeof e))}function io(e){const t=Rn(e),i=typeof e;return new Wn({type:"literal",schema:"string"===i||"number"===i||"boolean"===i?e:null,validator:i=>i===e||"Expected the literal `"+t+"`, but received: "+Rn(i)})}function ao(){return Jn("number",(e=>"number"==typeof e&&!isNaN(e)||"Expected a number, but received: "+Rn(e)))}function no(e){const t=e?Object.keys(e):[],i=Jn("never",(()=>!1));return new Wn({type:"object",schema:e||null,*entries(a){if(e&&jn(a)){const n=new Set(Object.keys(a));for(const i of t)n.delete(i),yield[i,a[i],e[i]];for(const e of n)yield[e,a[e],i]}},validator:e=>jn(e)||"Expected an object, but received: "+Rn(e),coercer:e=>jn(e)?{...e}:e})}function oo(e){return new Wn({...e,validator:(t,i)=>void 0===t||e.validator(t,i),refiner:(t,i)=>void 0===t||e.refiner(t,i)})}function so(){return Jn("string",(e=>"string"==typeof e||"Expected a string, but received: "+Rn(e)))}function ro(e){const t=Object.keys(e);return new Wn({type:"type",schema:e,*entries(i){if(jn(i))for(const a of t)yield[a,i[a],e[a]]},validator:e=>jn(e)||"Expected an object, but received: "+Rn(e)})}function lo(e){const t=e.map((e=>e.type)).join(" | ");return new Wn({type:"union",schema:null,coercer(t,i){const a=e.find((e=>{const[i]=e.validate(t,{coerce:!0});return!i}))||Jn("unknown",(()=>!0));return a.coercer(t,i)},validator(i,a){const n=[];for(const t of e){const[...e]=Gn(i,t,a),[o]=e;if(!o[0])return[];for(const[t]of e)t&&n.push(t)}return["Expected the value to satisfy a union of `"+t+"`, but received: "+Rn(i),...n]}})}const co=(e,t)=>{if(!(t instanceof qn))return{warnings:[t.message],errors:void 0};const i=[],a=[];for(const n of t.failures())if(void 0===n.value)i.push(e.localize("ui.errors.config.key_missing","key",n.path.join(".")));else if("never"===n.type)a.push(e.localize("ui.errors.config.key_not_expected","key",n.path.join(".")));else{if("union"===n.type)continue;"enums"===n.type?a.push(e.localize("ui.errors.config.key_wrong_type","key",n.path.join("."),"type_correct",n.message.replace("Expected ","").split(", ")[0],"type_wrong",JSON.stringify(n.value))):a.push(e.localize("ui.errors.config.key_wrong_type","key",n.path.join("."),"type_correct",n.refinement||n.type,"type_wrong",JSON.stringify(n.value)))}return{warnings:a,errors:i}},uo=(e,t)=>e.callWS({type:"validate_config",...t}),ho=e=>e.substr(e.indexOf(".")+1),po=no({alias:oo(so()),enabled:oo(to())}),vo=no({entity_id:oo(lo([so(),eo(so())])),device_id:oo(lo([so(),eo(so())])),area_id:oo(lo([so(),eo(so())]))});Qn(po,no({service:oo(so()),service_template:oo(so()),entity_id:oo(so()),target:oo(vo),data:oo(no())}));const mo=Qn(po,no({service:io("media_player.play_media"),target:oo(no({entity_id:oo(so())})),entity_id:oo(so()),data:no({media_content_id:so(),media_content_type:so()}),metadata:no()})),fo=Qn(po,no({service:io("scene.turn_on"),target:oo(no({entity_id:oo(so())})),entity_id:oo(so()),metadata:no()})),go=e=>{if("delay"in e)return"delay";if("wait_template"in e)return"wait_template";if(["condition","and","or","not"].some((t=>t in e)))return"check_condition";if("event"in e)return"fire_event";if("device_id"in e)return"device_action";if("scene"in e)return"activate_scene";if("repeat"in e)return"repeat";if("choose"in e)return"choose";if("if"in e)return"if";if("wait_for_trigger"in e)return"wait_for_trigger";if("variables"in e)return"variables";if("stop"in e)return"stop";if("parallel"in e)return"parallel";if("service"in e){if("metadata"in e){if(Yn(e,fo))return"activate_scene";if(Yn(e,mo))return"play_media"}return"service"}return"unknown"},_o=e=>e<10?`0${e}`:e;function yo(e){const t=Math.floor(e/3600),i=Math.floor(e%3600/60),a=Math.floor(e%3600%60);return t>0?`${t}:${_o(i)}:${_o(a)}`:i>0?`${i}:${_o(a)}`:a>0?""+a:null}function ko(e){return void 0===e||Array.isArray(e)?e:[e]}const bo=e=>{return t=e.entity_id,void 0===(i=e.attributes).friendly_name?ho(t).replace(/_/g," "):i.friendly_name||"";var t,i},xo=new RegExp("{%|{{"),$o=e=>xo.test(e),wo=e=>{if(!e)return!1;if("string"==typeof e)return $o(e);if("object"==typeof e){return(Array.isArray(e)?e:Object.values(e)).some((e=>e&&wo(e)))}return!1};var Co=/-u(?:-[0-9a-z]{2,8})+/gi;function Ao(e,t,i){if(void 0===i&&(i=Error),!e)throw new i(t)}function Io(e,t){for(var i=t;;){if(e.has(i))return i;var a=i.lastIndexOf("-");if(!~a)return;a>=2&&"-"===i[a-2]&&(a-=2),i=i.slice(0,a)}}function Eo(e,t){Ao(2===t.length,"key must have 2 elements");var i=e.length,a="-".concat(t,"-"),n=e.indexOf(a);if(-1!==n){for(var o=n+4,s=o,r=o,l=!1;!l;){var d=e.indexOf("-",r);2===(-1===d?i-r:d-r)?l=!0:-1===d?(s=i,l=!0):(s=d,r=d+1)}return e.slice(o,s)}if(a="-".concat(t),-1!==(n=e.indexOf(a))&&n+3===i)return""}function zo(e,t,i,a,n,o){var s;s="lookup"===i.localeMatcher?function(e,t,i){for(var a={locale:""},n=0,o=t;n<o.length;n++){var s=o[n],r=s.replace(Co,""),l=Io(e,r);if(l)return a.locale=l,s!==r&&(a.extension=s.slice(r.length+1,s.length)),a}return a.locale=i(),a}(e,t,o):function(e,t,i){var a,n={},o={},s={},r=new Set;e.forEach((function(e){var t=new Intl.Locale(e).minimize().toString(),i=Intl.getCanonicalLocales(e)[0]||e;n[t]=e,o[e]=e,s[i]=e,r.add(t),r.add(e),r.add(i)}));for(var l=0,d=t;l<d.length;l++){var c=d[l];if(a)break;var u=c.replace(Co,"");if(e.has(u)){a=u;break}if(r.has(u)){a=u;break}var h=new Intl.Locale(u),p=h.maximize().toString(),v=h.minimize().toString();if(r.has(v)){a=v;break}a=Io(r,p)}return a?{locale:o[a]||s[a]||n[a]||a}:{locale:i()}}(e,t,o);for(var r=s.locale,l={locale:"",dataLocale:r},d="-u",c=0,u=a;c<u.length;c++){var h=u[c];Ao(r in n,"Missing locale data for ".concat(r));var p=n[r];Ao("object"==typeof p&&null!==p,"locale data ".concat(h," must be an object"));var v=p[h];Ao(Array.isArray(v),"keyLocaleData for ".concat(h," must be an array"));var m=v[0];Ao("string"==typeof m||null===m,"value must be string or null but got ".concat(typeof m," in key ").concat(h));var f="";if(s.extension){var g=Eo(s.extension,h);void 0!==g&&(""!==g?~v.indexOf(g)&&(m=g,f="-".concat(h,"-").concat(m)):~g.indexOf("true")&&(m="true",f="-".concat(h)))}if(h in i){var _=i[h];Ao("string"==typeof _||null==_,"optionsValue must be String, Undefined or Null"),~v.indexOf(_)&&_!==m&&(m=_,f="")}l[h]=m,d+=f}if(d.length>2){var y=r.indexOf("-x-");if(-1===y)r+=d;else{var k=r.slice(0,y),b=r.slice(y,r.length);r=k+d+b}r=Intl.getCanonicalLocales(r)[0]}return l.locale=r,l}function So(e,t,i,a){var n=t.reduce((function(e,t){return e.add(t),e}),new Set);return zo(n,function(e){return Intl.getCanonicalLocales(e)}(e),{localeMatcher:(null==a?void 0:a.algorithm)||"best fit"},[],{},(function(){return i})).locale}var To=Object.freeze({__proto__:null,match:So,LookupSupportedLocales:function(e,t){for(var i=[],a=0,n=t;a<n.length;a++){var o=Io(e,n[a].replace(Co,""));o&&i.push(o)}return i},ResolveLocale:zo}),Lo=["af","ak","am","an","ar","ars","as","asa","ast","az","bal","be","bem","bez","bg","bho","bm","bn","bo","br","brx","bs","ca","ce","ceb","cgg","chr","ckb","cs","cy","da","de","doi","dsb","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fil","fo","fr","fur","fy","ga","gd","gl","gsw","gu","guw","gv","ha","haw","he","hi","hnj","hr","hsb","hu","hy","ia","id","ig","ii","io","is","it","iu","ja","jbo","jgo","jmc","jv","jw","ka","kab","kaj","kcg","kde","kea","kk","kkj","kl","km","kn","ko","ks","ksb","ksh","ku","kw","ky","lag","lb","lg","lij","lkt","ln","lo","lt","lv","mas","mg","mgo","mk","ml","mn","mo","mr","ms","mt","my","nah","naq","nb","nd","ne","nl","nn","nnh","no","nqo","nr","nso","ny","nyn","om","or","os","osa","pa","pap","pcm","pl","prg","ps","pt-PT","pt","rm","ro","rof","ru","rwk","sah","saq","sat","sc","scn","sd","sdh","se","seh","ses","sg","sh","shi","si","sk","sl","sma","smi","smj","smn","sms","sn","so","sq","sr","ss","ssy","st","su","sv","sw","syr","ta","te","teo","th","ti","tig","tk","tl","tn","to","tpi","tr","ts","tzm","ug","uk","und","ur","uz","ve","vi","vo","vun","wa","wae","wo","xh","xog","yi","yo","yue","zh","zu"];var Oo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CanonicalizeLocaleList=void 0,t.CanonicalizeLocaleList=function(e){return Intl.getCanonicalLocales(e)}}));xn(Oo),Oo.CanonicalizeLocaleList;var Mo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.invariant=t.UNICODE_EXTENSION_SEQUENCE_REGEX=void 0,t.UNICODE_EXTENSION_SEQUENCE_REGEX=/-u(?:-[0-9a-z]{2,8})+/gi,t.invariant=function(e,t,i){if(void 0===i&&(i=Error),!e)throw new i(t)}}));xn(Mo),Mo.invariant,Mo.UNICODE_EXTENSION_SEQUENCE_REGEX;var Po=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BestAvailableLocale=void 0,t.BestAvailableLocale=function(e,t){for(var i=t;;){if(e.has(i))return i;var a=i.lastIndexOf("-");if(!~a)return;a>=2&&"-"===i[a-2]&&(a-=2),i=i.slice(0,a)}}}));xn(Po),Po.BestAvailableLocale;var Fo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.LookupMatcher=void 0,t.LookupMatcher=function(e,t,i){for(var a={locale:""},n=0,o=t;n<o.length;n++){var s=o[n],r=s.replace(Mo.UNICODE_EXTENSION_SEQUENCE_REGEX,""),l=(0,Po.BestAvailableLocale)(e,r);if(l)return a.locale=l,s!==r&&(a.extension=s.slice(r.length+1,s.length)),a}return a.locale=i(),a}}));xn(Fo),Fo.LookupMatcher;var Do=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BestFitMatcher=void 0,t.BestFitMatcher=function(e,t,i){var a,n={},o={},s={},r=new Set;e.forEach((function(e){var t=new Intl.Locale(e).minimize().toString(),i=Intl.getCanonicalLocales(e)[0]||e;n[t]=e,o[e]=e,s[i]=e,r.add(t),r.add(e),r.add(i)}));for(var l=0,d=t;l<d.length;l++){var c=d[l];if(a)break;var u=c.replace(Mo.UNICODE_EXTENSION_SEQUENCE_REGEX,"");if(e.has(u)){a=u;break}if(r.has(u)){a=u;break}var h=new Intl.Locale(u),p=h.maximize().toString(),v=h.minimize().toString();if(r.has(v)){a=v;break}a=(0,Po.BestAvailableLocale)(r,p)}return a?{locale:o[a]||s[a]||n[a]||a}:{locale:i()}}}));xn(Do),Do.BestFitMatcher;var Bo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeExtensionValue=void 0,t.UnicodeExtensionValue=function(e,t){(0,Mo.invariant)(2===t.length,"key must have 2 elements");var i=e.length,a="-".concat(t,"-"),n=e.indexOf(a);if(-1!==n){for(var o=n+4,s=o,r=o,l=!1;!l;){var d=e.indexOf("-",r);2===(-1===d?i-r:d-r)?l=!0:-1===d?(s=i,l=!0):(s=d,r=d+1)}return e.slice(o,s)}if(a="-".concat(t),-1!==(n=e.indexOf(a))&&n+3===i)return""}}));xn(Bo),Bo.UnicodeExtensionValue;var No=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ResolveLocale=void 0,t.ResolveLocale=function(e,t,i,a,n,o){for(var s,r=(s="lookup"===i.localeMatcher?(0,Fo.LookupMatcher)(e,t,o):(0,Do.BestFitMatcher)(e,t,o)).locale,l={locale:"",dataLocale:r},d="-u",c=0,u=a;c<u.length;c++){var h=u[c];(0,Mo.invariant)(r in n,"Missing locale data for ".concat(r));var p=n[r];(0,Mo.invariant)("object"==typeof p&&null!==p,"locale data ".concat(h," must be an object"));var v=p[h];(0,Mo.invariant)(Array.isArray(v),"keyLocaleData for ".concat(h," must be an array"));var m=v[0];(0,Mo.invariant)("string"==typeof m||null===m,"value must be string or null but got ".concat(typeof m," in key ").concat(h));var f="";if(s.extension){var g=(0,Bo.UnicodeExtensionValue)(s.extension,h);void 0!==g&&(""!==g?~v.indexOf(g)&&(m=g,f="-".concat(h,"-").concat(m)):~g.indexOf("true")&&(m="true",f="-".concat(h)))}if(h in i){var _=i[h];(0,Mo.invariant)("string"==typeof _||null==_,"optionsValue must be String, Undefined or Null"),~v.indexOf(_)&&_!==m&&(m=_,f="")}l[h]=m,d+=f}if(d.length>2){var y=r.indexOf("-x-");if(-1===y)r+=d;else{var k=r.slice(0,y),b=r.slice(y,r.length);r=k+d+b}r=Intl.getCanonicalLocales(r)[0]}return l.locale=r,l}}));xn(No),No.ResolveLocale;var Vo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.LookupSupportedLocales=void 0,t.LookupSupportedLocales=function(e,t){for(var i=[],a=0,n=t;a<n.length;a++){var o=n[a].replace(Mo.UNICODE_EXTENSION_SEQUENCE_REGEX,""),s=(0,Po.BestAvailableLocale)(e,o);s&&i.push(s)}return i}}));xn(Vo),Vo.LookupSupportedLocales;var qo=bn((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ResolveLocale=t.LookupSupportedLocales=t.match=void 0,t.match=function(e,t,i,a){var n=t.reduce((function(e,t){return e.add(t),e}),new Set);return(0,No.ResolveLocale)(n,(0,Oo.CanonicalizeLocaleList)(e),{localeMatcher:(null==a?void 0:a.algorithm)||"best fit"},[],{},(function(){return i})).locale},Object.defineProperty(t,"LookupSupportedLocales",{enumerable:!0,get:function(){return Vo.LookupSupportedLocales}});var i=No;Object.defineProperty(t,"ResolveLocale",{enumerable:!0,get:function(){return i.ResolveLocale}})}));xn(qo);var jo=qo.ResolveLocale,Ro=qo.LookupSupportedLocales,Uo=qo.match,Ho=["af-NA","af","agq","ak","am","ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-EH","ar-ER","ar-IL","ar-IQ","ar-JO","ar-KM","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR","ar-OM","ar-PS","ar-QA","ar-SA","ar-SD","ar-SO","ar-SS","ar-SY","ar-TD","ar-TN","ar-YE","ar","as","asa","ast","az-Cyrl","az-Latn","az","bas","be-tarask","be","bem","bez","bg","bm","bn-IN","bn","bo-IN","bo","br","brx","bs-Cyrl","bs-Latn","bs","ca-AD","ca-ES-valencia","ca-FR","ca-IT","ca","ccp-IN","ccp","ce","ceb","cgg","chr","ckb-IR","ckb","cs","cy","da-GL","da","dav","de-AT","de-BE","de-CH","de-IT","de-LI","de-LU","de","dje","doi","dsb","dua","dyo","dz","ebu","ee-TG","ee","el-CY","el","en-001","en-150","en-AE","en-AG","en-AI","en-AS","en-AT","en-AU","en-BB","en-BE","en-BI","en-BM","en-BS","en-BW","en-BZ","en-CA","en-CC","en-CH","en-CK","en-CM","en-CX","en-CY","en-DE","en-DG","en-DK","en-DM","en-ER","en-FI","en-FJ","en-FK","en-FM","en-GB","en-GD","en-GG","en-GH","en-GI","en-GM","en-GU","en-GY","en-HK","en-IE","en-IL","en-IM","en-IN","en-IO","en-JE","en-JM","en-KE","en-KI","en-KN","en-KY","en-LC","en-LR","en-LS","en-MG","en-MH","en-MO","en-MP","en-MS","en-MT","en-MU","en-MW","en-MY","en-NA","en-NF","en-NG","en-NL","en-NR","en-NU","en-NZ","en-PG","en-PH","en-PK","en-PN","en-PR","en-PW","en-RW","en-SB","en-SC","en-SD","en-SE","en-SG","en-SH","en-SI","en-SL","en-SS","en-SX","en-SZ","en-TC","en-TK","en-TO","en-TT","en-TV","en-TZ","en-UG","en-UM","en-VC","en-VG","en-VI","en-VU","en-WS","en-ZA","en-ZM","en-ZW","en","eo","es-419","es-AR","es-BO","es-BR","es-BZ","es-CL","es-CO","es-CR","es-CU","es-DO","es-EA","es-EC","es-GQ","es-GT","es-HN","es-IC","es-MX","es-NI","es-PA","es-PE","es-PH","es-PR","es-PY","es-SV","es-US","es-UY","es-VE","es","et","eu","ewo","fa-AF","fa","ff-Adlm-BF","ff-Adlm-CM","ff-Adlm-GH","ff-Adlm-GM","ff-Adlm-GW","ff-Adlm-LR","ff-Adlm-MR","ff-Adlm-NE","ff-Adlm-NG","ff-Adlm-SL","ff-Adlm-SN","ff-Adlm","ff-Latn-BF","ff-Latn-CM","ff-Latn-GH","ff-Latn-GM","ff-Latn-GN","ff-Latn-GW","ff-Latn-LR","ff-Latn-MR","ff-Latn-NE","ff-Latn-NG","ff-Latn-SL","ff-Latn","ff","fi","fil","fo-DK","fo","fr-BE","fr-BF","fr-BI","fr-BJ","fr-BL","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI","fr-CM","fr-DJ","fr-DZ","fr-GA","fr-GF","fr-GN","fr-GP","fr-GQ","fr-HT","fr-KM","fr-LU","fr-MA","fr-MC","fr-MF","fr-MG","fr-ML","fr-MQ","fr-MR","fr-MU","fr-NC","fr-NE","fr-PF","fr-PM","fr-RE","fr-RW","fr-SC","fr-SN","fr-SY","fr-TD","fr-TG","fr-TN","fr-VU","fr-WF","fr-YT","fr","fur","fy","ga-GB","ga","gd","gl","gsw-FR","gsw-LI","gsw","gu","guz","gv","ha-GH","ha-NE","ha","haw","he","hi","hr-BA","hr","hsb","hu","hy","ia","id","ig","ii","is","it-CH","it-SM","it-VA","it","ja","jgo","jmc","jv","ka","kab","kam","kde","kea","kgp","khq","ki","kk","kkj","kl","kln","km","kn","ko-KP","ko","kok","ks-Arab","ks","ksb","ksf","ksh","ku","kw","ky","lag","lb","lg","lkt","ln-AO","ln-CF","ln-CG","ln","lo","lrc-IQ","lrc","lt","lu","luo","luy","lv","mai","mas-TZ","mas","mer","mfe","mg","mgh","mgo","mi","mk","ml","mn","mni-Beng","mni","mr","ms-BN","ms-ID","ms-SG","ms","mt","mua","my","mzn","naq","nb-SJ","nb","nd","nds-NL","nds","ne-IN","ne","nl-AW","nl-BE","nl-BQ","nl-CW","nl-SR","nl-SX","nl","nmg","nn","nnh","no","nus","nyn","om-KE","om","or","os-RU","os","pa-Arab","pa-Guru","pa","pcm","pl","ps-PK","ps","pt-AO","pt-CH","pt-CV","pt-GQ","pt-GW","pt-LU","pt-MO","pt-MZ","pt-PT","pt-ST","pt-TL","pt","qu-BO","qu-EC","qu","rm","rn","ro-MD","ro","rof","ru-BY","ru-KG","ru-KZ","ru-MD","ru-UA","ru","rw","rwk","sa","sah","saq","sat-Olck","sat","sbp","sc","sd-Arab","sd-Deva","sd","se-FI","se-SE","se","seh","ses","sg","shi-Latn","shi-Tfng","shi","si","sk","sl","smn","sn","so-DJ","so-ET","so-KE","so","sq-MK","sq-XK","sq","sr-Cyrl-BA","sr-Cyrl-ME","sr-Cyrl-XK","sr-Cyrl","sr-Latn-BA","sr-Latn-ME","sr-Latn-XK","sr-Latn","sr","su-Latn","su","sv-AX","sv-FI","sv","sw-CD","sw-KE","sw-UG","sw","ta-LK","ta-MY","ta-SG","ta","te","teo-KE","teo","tg","th","ti-ER","ti","tk","to","tr-CY","tr","tt","twq","tzm","ug","uk","und","ur-IN","ur","uz-Arab","uz-Cyrl","uz-Latn","uz","vai-Latn","vai-Vaii","vai","vi","vun","wae","wo","xh","xog","yav","yi","yo-BJ","yo","yrl-CO","yrl-VE","yrl","yue-Hans","yue-Hant","yue","zgh","zh-Hans-HK","zh-Hans-MO","zh-Hans-SG","zh-Hans","zh-Hant-HK","zh-Hant-MO","zh-Hant","zh","zu"];var Go=["af-NA","af","agq","ak","am","ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-EH","ar-ER","ar-IL","ar-IQ","ar-JO","ar-KM","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR","ar-OM","ar-PS","ar-QA","ar-SA","ar-SD","ar-SO","ar-SS","ar-SY","ar-TD","ar-TN","ar-YE","ar","as","asa","ast","az-Cyrl","az-Latn","az","bas","be-tarask","be","bem","bez","bg","bm","bn-IN","bn","bo-IN","bo","br","brx","bs-Cyrl","bs-Latn","bs","ca-AD","ca-ES-valencia","ca-FR","ca-IT","ca","ccp-IN","ccp","ce","ceb","cgg","chr","ckb-IR","ckb","cs","cy","da-GL","da","dav","de-AT","de-BE","de-CH","de-IT","de-LI","de-LU","de","dje","doi","dsb","dua","dyo","dz","ebu","ee-TG","ee","el-CY","el","en-001","en-150","en-AE","en-AG","en-AI","en-AS","en-AT","en-AU","en-BB","en-BE","en-BI","en-BM","en-BS","en-BW","en-BZ","en-CA","en-CC","en-CH","en-CK","en-CM","en-CX","en-CY","en-DE","en-DG","en-DK","en-DM","en-ER","en-FI","en-FJ","en-FK","en-FM","en-GB","en-GD","en-GG","en-GH","en-GI","en-GM","en-GU","en-GY","en-HK","en-IE","en-IL","en-IM","en-IN","en-IO","en-JE","en-JM","en-KE","en-KI","en-KN","en-KY","en-LC","en-LR","en-LS","en-MG","en-MH","en-MO","en-MP","en-MS","en-MT","en-MU","en-MW","en-MY","en-NA","en-NF","en-NG","en-NL","en-NR","en-NU","en-NZ","en-PG","en-PH","en-PK","en-PN","en-PR","en-PW","en-RW","en-SB","en-SC","en-SD","en-SE","en-SG","en-SH","en-SI","en-SL","en-SS","en-SX","en-SZ","en-TC","en-TK","en-TO","en-TT","en-TV","en-TZ","en-UG","en-UM","en-VC","en-VG","en-VI","en-VU","en-WS","en-ZA","en-ZM","en-ZW","en","eo","es-419","es-AR","es-BO","es-BR","es-BZ","es-CL","es-CO","es-CR","es-CU","es-DO","es-EA","es-EC","es-GQ","es-GT","es-HN","es-IC","es-MX","es-NI","es-PA","es-PE","es-PH","es-PR","es-PY","es-SV","es-US","es-UY","es-VE","es","et","eu","ewo","fa-AF","fa","ff-Adlm-BF","ff-Adlm-CM","ff-Adlm-GH","ff-Adlm-GM","ff-Adlm-GW","ff-Adlm-LR","ff-Adlm-MR","ff-Adlm-NE","ff-Adlm-NG","ff-Adlm-SL","ff-Adlm-SN","ff-Adlm","ff-Latn-BF","ff-Latn-CM","ff-Latn-GH","ff-Latn-GM","ff-Latn-GN","ff-Latn-GW","ff-Latn-LR","ff-Latn-MR","ff-Latn-NE","ff-Latn-NG","ff-Latn-SL","ff-Latn","ff","fi","fil","fo-DK","fo","fr-BE","fr-BF","fr-BI","fr-BJ","fr-BL","fr-CA","fr-CD","fr-CF","fr-CG","fr-CH","fr-CI","fr-CM","fr-DJ","fr-DZ","fr-GA","fr-GF","fr-GN","fr-GP","fr-GQ","fr-HT","fr-KM","fr-LU","fr-MA","fr-MC","fr-MF","fr-MG","fr-ML","fr-MQ","fr-MR","fr-MU","fr-NC","fr-NE","fr-PF","fr-PM","fr-RE","fr-RW","fr-SC","fr-SN","fr-SY","fr-TD","fr-TG","fr-TN","fr-VU","fr-WF","fr-YT","fr","fur","fy","ga-GB","ga","gd","gl","gsw-FR","gsw-LI","gsw","gu","guz","gv","ha-GH","ha-NE","ha","haw","he","hi","hr-BA","hr","hsb","hu","hy","ia","id","ig","ii","is","it-CH","it-SM","it-VA","it","ja","jgo","jmc","jv","ka","kab","kam","kde","kea","kgp","khq","ki","kk","kkj","kl","kln","km","kn","ko-KP","ko","kok","ks-Arab","ks","ksb","ksf","ksh","ku","kw","ky","lag","lb","lg","lkt","ln-AO","ln-CF","ln-CG","ln","lo","lrc-IQ","lrc","lt","lu","luo","luy","lv","mai","mas-TZ","mas","mer","mfe","mg","mgh","mgo","mi","mk","ml","mn","mni-Beng","mni","mr","ms-BN","ms-ID","ms-SG","ms","mt","mua","my","mzn","naq","nb-SJ","nb","nd","nds-NL","nds","ne-IN","ne","nl-AW","nl-BE","nl-BQ","nl-CW","nl-SR","nl-SX","nl","nmg","nn","nnh","no","nus","nyn","om-KE","om","or","os-RU","os","pa-Arab","pa-Guru","pa","pcm","pl","ps-PK","ps","pt-AO","pt-CH","pt-CV","pt-GQ","pt-GW","pt-LU","pt-MO","pt-MZ","pt-PT","pt-ST","pt-TL","pt","qu-BO","qu-EC","qu","rm","rn","ro-MD","ro","rof","ru-BY","ru-KG","ru-KZ","ru-MD","ru-UA","ru","rw","rwk","sa","sah","saq","sat-Olck","sat","sbp","sc","sd-Arab","sd-Deva","sd","se-FI","se-SE","se","seh","ses","sg","shi-Latn","shi-Tfng","shi","si","sk","sl","smn","sn","so-DJ","so-ET","so-KE","so","sq-MK","sq-XK","sq","sr-Cyrl-BA","sr-Cyrl-ME","sr-Cyrl-XK","sr-Cyrl","sr-Latn-BA","sr-Latn-ME","sr-Latn-XK","sr-Latn","sr","su-Latn","su","sv-AX","sv-FI","sv","sw-CD","sw-KE","sw-UG","sw","ta-LK","ta-MY","ta-SG","ta","te","teo-KE","teo","tg","th","ti-ER","ti","tk","to","tr-CY","tr","tt","twq","tzm","ug","uk","und","ur-IN","ur","uz-Arab","uz-Cyrl","uz-Latn","uz","vai-Latn","vai-Vaii","vai","vi","vun","wae","wo","xh","xog","yav","yi","yo-BJ","yo","yrl-CO","yrl-VE","yrl","yue-Hans","yue-Hant","yue","zgh","zh-Hans-HK","zh-Hans-MO","zh-Hans-SG","zh-Hans","zh-Hant-HK","zh-Hant-MO","zh-Hant","zh","zu"];let Wo,Ko;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(Wo||(Wo={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(Ko||(Ko={}));const Yo={},Zo=window.localStorage||{},Qo={"zh-cn":"zh-Hans","zh-sg":"zh-Hans","zh-my":"zh-Hans","zh-tw":"zh-Hant","zh-hk":"zh-Hant","zh-mo":"zh-Hant",zh:"zh-Hant"};function Jo(e){if(e in Yo.translations)return e;const t=e.toLowerCase();if(t in Qo)return Qo[t];const i=Object.keys(Yo.translations).find((e=>e.toLowerCase()===t));return i||(e.includes("-")?Jo(e.split("-")[0]):void 0)}const Xo=new Set,es=[];"Locale"in Intl&&!function(){try{return"x-private"===new Intl.Locale("und-x-private").toString()}catch(e){return!0}}()||es.push(import("./c.8de55195.js")),function(e){if(void 0===e&&(e="en"),!("PluralRules"in Intl)||"one"===new Intl.PluralRules("en",{minimumFractionDigits:2}).select(1)||!function(e){if(!e)return!0;var t=Array.isArray(e)?e:[e];return Intl.PluralRules.supportedLocalesOf(t).length===t.length}(e))return e?So([e],Lo,"en"):void 0}()&&(es.push(import("./c.568c70d8.js")),es.push(import("./c.e23b0d0b.js"))),function(e){if(void 0===e&&(e="en"),!("RelativeTimeFormat"in Intl)||!function(e){if(!e)return!0;var t=Array.isArray(e)?e:[e];return Intl.RelativeTimeFormat.supportedLocalesOf(t).length===t.length}(e)||!function(e){try{return"numberingSystem"in new Intl.RelativeTimeFormat(e||"en",{numeric:"auto"}).resolvedOptions()}catch(e){return!1}}(e))return Uo([e],Ho,"en")}()&&es.push(import("./c.4c04acb5.js")),function(e){if(void 0===e&&(e="en"),!("DateTimeFormat"in Intl)||!("formatToParts"in Intl.DateTimeFormat.prototype)||!("formatRange"in Intl.DateTimeFormat.prototype)||function(){try{return"dayPeriod"!==new Intl.DateTimeFormat("en",{hourCycle:"h11",hour:"numeric"}).formatToParts(0)[2].type}catch(e){return!1}}()||function(){try{return!!new Intl.DateTimeFormat("en",{dateStyle:"short",hour:"numeric"}).format(new Date(0))}catch(e){return!1}}()||!function(){try{return!!new Intl.DateTimeFormat(void 0,{dateStyle:"short"}).resolvedOptions().dateStyle}catch(e){return!1}}()||!function(e){if(!e)return!0;var t=Array.isArray(e)?e:[e];return Intl.DateTimeFormat.supportedLocalesOf(t).length===t.length}(e))return e?Uo([e],Go,"en"):void 0}()&&(es.push(import("./c.456b65b4.js")),es.push(import("./c.ad739743.js")));const ts=0===es.length?void 0:Promise.all(es).then((()=>is(function(){let e=null;if(Zo.selectedLanguage)try{const t=JSON.parse(Zo.selectedLanguage);if(t&&(e=Jo(t),e))return e}catch(e){}if(navigator.languages)for(const t of navigator.languages)if(e=Jo(t),e)return e;return e=Jo(navigator.language),e||"en"}()))),is=async e=>{if(!Xo.has(e)){Xo.add(e);try{if(Intl.NumberFormat&&"function"==typeof Intl.NumberFormat.__addLocaleData){const t=await fetch(`/static/locale-data/intl-numberformat/${e}.json`);Intl.NumberFormat.__addLocaleData(await t.json())}if(Intl.RelativeTimeFormat&&"function"==typeof Intl.RelativeTimeFormat.__addLocaleData){const t=await fetch(`/static/locale-data/intl-relativetimeformat/${e}.json`);Intl.RelativeTimeFormat.__addLocaleData(await t.json())}if(Intl.DateTimeFormat&&"function"==typeof Intl.DateTimeFormat.__addLocaleData){const t=await fetch(`/static/locale-data/intl-datetimeformat/${e}.json`);Intl.DateTimeFormat.__addLocaleData(await t.json())}}catch(e){}}};ts&&await ts,n((e=>new Intl.DateTimeFormat(e.language,{weekday:"long",month:"long",day:"numeric"})));const as=(e,t)=>ns(t).format(e),ns=n((e=>new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric"}))),os=n((e=>new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric"})));n((e=>new Intl.DateTimeFormat(e.language,{day:"numeric",month:"short"}))),n((e=>new Intl.DateTimeFormat(e.language,{month:"long",year:"numeric"}))),n((e=>new Intl.DateTimeFormat(e.language,{month:"long"}))),n((e=>new Intl.DateTimeFormat(e.language,{year:"numeric"})));const ss=n((e=>{if(e.time_format===Ko.language||e.time_format===Ko.system){const t=e.time_format===Ko.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===Ko.am_pm}));ts&&await ts;const rs=(e,t)=>ls(t).format(e),ls=n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{year:"numeric",month:"long",day:"numeric",hour:ss(e)?"numeric":"2-digit",minute:"2-digit",hour12:ss(e)})));n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{month:"short",day:"numeric",hour:ss(e)?"numeric":"2-digit",minute:"2-digit",hour12:ss(e)}))),n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{year:"numeric",month:"long",day:"numeric",hour:ss(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:ss(e)}))),n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:ss(e)})));const ds=(e,t,i)=>{const a=t?(e=>{switch(e.number_format){case Wo.comma_decimal:return["en-US","en"];case Wo.decimal_comma:return["de","es","it"];case Wo.space_comma:return["fr","sv","cs"];case Wo.system:return;default:return e.language}})(t):void 0;if(Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},(null==t?void 0:t.number_format)!==Wo.none&&!Number.isNaN(Number(e))&&Intl)try{return new Intl.NumberFormat(a,cs(e,i)).format(Number(e))}catch(t){return console.error(t),new Intl.NumberFormat(void 0,cs(e,i)).format(Number(e))}return"string"==typeof e?e:`${((e,t=2)=>Math.round(e*10**t)/10**t)(e,null==i?void 0:i.maximumFractionDigits).toString()}${"currency"===(null==i?void 0:i.style)?` ${i.currency}`:""}`},cs=(e,t)=>{const i={maximumFractionDigits:2,...t};if("string"!=typeof e)return i;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){const t=e.indexOf(".")>-1?e.split(".")[1].length:0;i.minimumFractionDigits=t,i.maximumFractionDigits=t}return i},us=e=>e.charAt(0).toUpperCase()+e.slice(1);function hs(e){return e=e.replace(/_/g," ").replace(/\bid\b/g,"ID").replace(/\bip\b/g,"IP").replace(/\bmac\b/g,"MAC").replace(/\bgps\b/g,"GPS"),us(e)}const ps=(e,t,i=!1)=>{if(e.alias&&!i)return e.alias;if("event"===e.platform&&e.event_type){let t="";if(Array.isArray(e.event_type))for(const[i,a]of e.event_type.entries())t+=`${i>0?",":""} ${e.event_type.length>1&&i===e.event_type.length-1?"or":""} ${a}`;else t=e.event_type.toString();return`When ${t} event is fired`}if("homeassistant"===e.platform&&e.event)return"When Home Assistant is "+("start"===e.event?"started":"shutdown");if("numeric_state"===e.platform&&e.entity_id){let i="When";const a=t.states[e.entity_id],n=a?bo(a):e.entity_id;return e.attribute&&(i+=` ${hs(e.attribute)} from`),i+=` ${n} is`,"above"in e&&(i+=` above ${e.above}`),"below"in e&&"above"in e&&(i+=" and"),"below"in e&&(i+=` below ${e.below}`),i}if("state"===e.platform&&e.entity_id){let i="When",a="";const n=t.states;if(e.attribute&&(i+=` ${hs(e.attribute)} from`),Array.isArray(e.entity_id))for(const[t,i]of e.entity_id.entries())n[i]&&(a+=`${t>0?",":""} ${e.entity_id.length>1&&t===e.entity_id.length-1?"or":""} ${bo(n[i])||i}`);else a=n[e.entity_id]?bo(n[e.entity_id]):e.entity_id;if(i+=` ${a} changes`,e.from){let t="";if(Array.isArray(e.from))for(const[i,a]of e.from.entries())t+=`${i>0?",":""} ${e.from.length>1&&i===e.from.length-1?"or":""} ${a}`;else t=e.from.toString();i+=` from ${t}`}if(e.to){let t="";if(Array.isArray(e.to))for(const[i,a]of e.to.entries())t+=`${i>0?",":""} ${e.to.length>1&&i===e.to.length-1?"or":""} ${a}`;else e.to&&(t=e.to.toString());i+=` to ${t}`}if("for"in e){let t;t="number"==typeof e.for?`for ${yo(e.for)}`:"string"==typeof e.for?`for ${e.for}`:`for ${JSON.stringify(e.for)}`,i+=` for ${t}`}return i}if("sun"===e.platform&&e.event){let t="When the sun "+("sunset"===e.event?"sets":"rises");if(e.offset){let i="";e.offset&&(i="number"==typeof e.offset?` offset by ${yo(e.offset)}`:"string"==typeof e.offset?` offset by ${e.offset}`:` offset by ${JSON.stringify(e.offset)}`),t+=i}return t}if("tag"===e.platform)return"When a tag is scanned";if("time"===e.platform&&e.at){return`When the time is equal to ${e.at.includes(".")&&t.states[e.at]||e.at}`}if("time_pattern"===e.platform)return"Time pattern trigger";if("zone"===e.platform&&e.entity_id&&e.zone){let i="",a="",n=!1;const o=t.states;if(Array.isArray(e.entity_id))for(const[t,a]of e.entity_id.entries())o[a]&&(i+=`${t>0?",":""} ${e.entity_id.length>1&&t===e.entity_id.length-1?"or":""} ${bo(o[a])||a}`);else i=o[e.entity_id]?bo(o[e.entity_id]):e.entity_id;if(Array.isArray(e.zone)){e.zone.length>1&&(n=!0);for(const[t,i]of e.zone.entries())o[i]&&(a+=`${t>0?",":""} ${e.zone.length>1&&t===e.zone.length-1?"or":""} ${bo(o[i])||i}`)}else a=o[e.zone]?bo(o[e.zone]):e.zone;return`When ${i} ${e.event}s ${a} ${n?"zones":"zone"}`}if("geo_location"===e.platform&&e.source&&e.zone){let i="",a="",n=!1;const o=t.states;if(Array.isArray(e.source))for(const[t,a]of e.source.entries())i+=`${t>0?",":""} ${e.source.length>1&&t===e.source.length-1?"or":""} ${a}`;else i=e.source;if(Array.isArray(e.zone)){e.zone.length>1&&(n=!0);for(const[t,i]of e.zone.entries())o[i]&&(a+=`${t>0?",":""} ${e.zone.length>1&&t===e.zone.length-1?"or":""} ${bo(o[i])||i}`)}else a=o[e.zone]?bo(o[e.zone]):e.zone;return`When ${i} ${e.event}s ${a} ${n?"zones":"zone"}`}return"mqtt"===e.platform?"When a MQTT payload has been received":"template"===e.platform?"When a template triggers":"webhook"===e.platform?"When a Webhook payload has been received":`${e.platform||"Unknown"} trigger`},vs=(e,t,i=!1)=>{if(e.alias&&!i)return e.alias;if(["or","and","not"].includes(e.condition))return`multiple conditions using "${e.condition}"`;if("state"===e.condition&&e.entity_id){let i="Confirm";const a=t.states[e.entity_id],n=a?bo(a):e.entity_id;"attribute"in e&&(i+=` ${e.attribute} from`);let o="";if(Array.isArray(e.state))for(const[t,i]of e.state.entries())o+=`${t>0?",":""} ${e.state.length>1&&t===e.state.length-1?"or":""} ${i}`;else o=e.state.toString();if(i+=` ${n} is ${o}`,"for"in e){let t;t="number"==typeof e.for?`for ${yo(e.for)}`:"string"==typeof e.for?`for ${e.for}`:`for ${JSON.stringify(e.for)}`,i+=` for ${t}`}return i}if("numeric_state"===e.condition&&e.entity_id){let i="Confirm";const a=t.states[e.entity_id],n=a?bo(a):e.entity_id;return"attribute"in e&&(i+=` ${e.attribute} from`),i+=` ${n} is`,"above"in e&&(i+=` above ${e.above}`),"below"in e&&"above"in e&&(i+=" and"),"below"in e&&(i+=` below ${e.below}`),i}if("sun"===e.condition&&("before"in e||"after"in e)){let t="Confirm";if(!e.after&&!e.before)return t+=" sun",t;if(t+=" sun",e.after){let i="";e.after_offset&&(i="number"==typeof e.after_offset?` offset by ${yo(e.after_offset)}`:"string"==typeof e.after_offset?` offset by ${e.after_offset}`:` offset by ${JSON.stringify(e.after_offset)}`),t+=` after ${e.after}${i}`}return e.before&&(t+=` before ${e.before}`),t}if("zone"===e.condition&&e.entity_id&&e.zone){let i="",a=!1,n="",o=!1;const s=t.states;if(Array.isArray(e.entity_id)){e.entity_id.length>1&&(a=!0);for(const[t,a]of e.entity_id.entries())s[a]&&(i+=`${t>0?",":""} ${e.entity_id.length>1&&t===e.entity_id.length-1?"or":""} ${bo(s[a])||a}`)}else i=s[e.entity_id]?bo(s[e.entity_id]):e.entity_id;if(Array.isArray(e.zone)){e.zone.length>1&&(o=!0);for(const[t,i]of e.zone.entries())s[i]&&(n+=`${t>0?",":""} ${e.zone.length>1&&t===e.zone.length-1?"or":""} ${bo(s[i])||i}`)}else n=s[e.zone]?bo(s[e.zone]):e.zone;return`Confirm ${i} ${a?"are":"is"} in ${n} ${o?"zones":"zone"}`}return`${e.condition} condition`},ms=(e,t,i,a=!1)=>{if(t.alias&&!a)return t.alias;if(i||(i=go(t)),"service"===i){const e=t;let a;if(e.service_template||e.service&&$o(e.service))a="Call a service based on a template";else{if(!e.service)return i;a=`Call service ${e.service}`}if(e.target){const t=[];for(const[i,a]of Object.entries({area_id:"areas",device_id:"devices",entity_id:"entities"})){if(!(i in e.target))continue;const n=Array.isArray(e.target[i])?e.target[i]:[e.target[i]],o=[];let s=!0;for(const e of n){if($o(e)){t.push(`templated ${a}`),s=!1;break}o.push(e)}s&&t.push(`${a} ${o.join(", ")}`)}t.length>0&&(a+=` on ${t.join(", ")}`)}return a}if("delay"===i){const e=t;let i;return i="number"==typeof e.delay?`for ${yo(e.delay)}`:"string"==typeof e.delay?$o(e.delay)?"based on a template":`for ${e.delay}`:`for ${JSON.stringify(e.delay)}`,`Delay ${i}`}if("activate_scene"===i){var n;const i=t;let a;var o;if("scene"in i)a=i.scene;else a=(null===(o=i.target)||void 0===o?void 0:o.entity_id)||i.entity_id;const s=a?e.states[a]:void 0;return`Activate scene ${s?bo(s):"scene"in i?i.scene:(null===(n=i.target)||void 0===n?void 0:n.entity_id)||i.entity_id||""}`}if("play_media"===i){var s,r;const i=t,a=(null===(s=i.target)||void 0===s?void 0:s.entity_id)||i.entity_id,n=a?e.states[a]:void 0;return`Play ${i.metadata.title||i.data.media_content_id} on ${n?bo(n):(null===(r=i.target)||void 0===r?void 0:r.entity_id)||i.entity_id}`}if("wait_for_trigger"===i){return`Wait for ${ko(t.wait_for_trigger).map((t=>ps(t,e))).join(", ")}`}if("variables"===i){const e=t;return`Define variables ${Object.keys(e.variables).join(", ")}`}if("fire_event"===i){const e=t;return $o(e.event)?"Fire event based on a template":`Fire event ${e.event}`}if("wait_template"===i)return"Wait for a template to render true";if("check_condition"===i)return`Test ${vs(t,e)}`;if("stop"===i){const e=t;return"Stopped"+(e.stop?` because: ${e.stop}`:"")}if("if"===i){const i=t;return`If ${"string"==typeof i.if?i.if:ko(i.if).map((t=>vs(t,e))).join(", ")} then ${ko(i.then).map((t=>ms(e,t)))}${i.else?` else ${ko(i.else).map((t=>ms(e,t)))}`:""}`}if("choose"===i){const i=t;return i.choose?`If ${ko(i.choose).map((t=>`${"string"==typeof t.conditions?t.conditions:ko(t.conditions).map((t=>vs(t,e))).join(", ")} then ${ko(t.sequence).map((t=>ms(e,t))).join(", ")}`)).join(", else if ")}${i.default?`. If none match: ${ko(i.default).map((t=>ms(e,t))).join(", ")}`:""}`:"Choose"}if("repeat"===i){const i=t;return`Repeat ${ko(i.repeat.sequence).map((t=>ms(e,t)))} ${"count"in i.repeat?`${i.repeat.count} times`:""}${"while"in i.repeat?`while ${ko(i.repeat.while).map((t=>vs(t,e))).join(", ")} is true`:"until"in i.repeat?`until ${ko(i.repeat.until).map((t=>vs(t,e))).join(", ")} is true`:"for_each"in i.repeat?`for every item: ${ko(i.repeat.for_each).map((e=>JSON.stringify(e))).join(", ")}`:""}`}if("check_condition"===i)return`Test ${vs(t,e)}`;if("device_action"===i){const i=t,a=e.states[i.entity_id];return`${i.type||"Perform action with"} ${a?bo(a):i.entity_id}`}if("parallel"===i){return`Run in parallel: ${ko(t.parallel).map((t=>ms(e,t))).join(", ")}`}return i},fs=(e,t)=>o(e,"hass-notification",t),gs=e=>e.substr(0,e.indexOf(".")),_s=(e,t)=>e<t?-1:e>t?1:0,ys=(e,t)=>_s(e.toLowerCase(),t.toLowerCase());class ks extends HTMLElement{static get version(){return"23.1.6"}}customElements.define("vaadin-material-styles",ks);const bs=e=>class extends e{static get properties(){return{theme:{type:String,reflectToAttribute:!0,observer:"__deprecatedThemePropertyChanged"},_theme:{type:String,readOnly:!0}}}__deprecatedThemePropertyChanged(e){this._set_theme(e)}},xs=[];function $s(e,t,i={}){var a;e&&(a=e,Es(customElements.get(a))&&console.warn(`The custom element definition for "${e}"\n was finalized before a style module was registered.\n Make sure to add component specific style modules before\n importing the corresponding custom element.`)),t=function(e=[]){return[e].flat(1/0).filter((e=>e instanceof s||(console.warn("An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`."),!1)))}(t),window.Vaadin&&window.Vaadin.styleModules?window.Vaadin.styleModules.registerStyles(e,t,i):xs.push({themeFor:e,styles:t,include:i.include,moduleId:i.moduleId})}function ws(){return window.Vaadin&&window.Vaadin.styleModules?window.Vaadin.styleModules.getAllThemes():xs}function Cs(e=""){let t=0;return 0===e.indexOf("lumo-")||0===e.indexOf("material-")?t=1:0===e.indexOf("vaadin-")&&(t=2),t}function As(e){const t=[];return e.include&&[].concat(e.include).forEach((e=>{const i=ws().find((t=>t.moduleId===e));i?t.push(...As(i),...i.styles):console.warn(`Included moduleId ${e} not found in style registry`)}),e.styles),t}function Is(e){const t=`${e}-default-theme`,i=ws().filter((i=>i.moduleId!==t&&function(e,t){return(e||"").split(" ").some((e=>new RegExp(`^${e.split("*").join(".*")}$`).test(t)))}(i.themeFor,e))).map((e=>({...e,styles:[...As(e),...e.styles],includePriority:Cs(e.moduleId)}))).sort(((e,t)=>t.includePriority-e.includePriority));return i.length>0?i:ws().filter((e=>e.moduleId===t))}function Es(e){return e&&Object.prototype.hasOwnProperty.call(e,"__themes")}const zs=e=>class extends(bs(e)){static finalize(){if(super.finalize(),this.elementStyles)return;const e=this.prototype._template;e&&!Es(this)&&function(e,t){const i=document.createElement("style");i.innerHTML=e.map((e=>e.cssText)).join("\n"),t.content.appendChild(i)}(this.getStylesForThis(),e)}static finalizeStyles(e){const t=this.getStylesForThis();return e?[...super.finalizeStyles(e),...t]:t}static getStylesForThis(){const e=Object.getPrototypeOf(this.prototype),t=(e?e.constructor.__themes:[])||[];this.__themes=[...t,...Is(this.is)];const i=this.__themes.flatMap((e=>e.styles));return i.filter(((e,t)=>t===i.lastIndexOf(e)))}};$s("",r`
  2. :host {
  3. /* Text colors */
  4. --material-body-text-color: var(--light-theme-text-color, rgba(0, 0, 0, 0.87));
  5. --material-secondary-text-color: var(--light-theme-secondary-color, rgba(0, 0, 0, 0.54));
  6. --material-disabled-text-color: var(--light-theme-disabled-color, rgba(0, 0, 0, 0.38));
  7. /* Primary colors */
  8. --material-primary-color: var(--primary-color, #6200ee);
  9. --material-primary-contrast-color: var(--dark-theme-base-color, #fff);
  10. --material-primary-text-color: var(--material-primary-color);
  11. /* Error colors */
  12. --material-error-color: var(--error-color, #b00020);
  13. --material-error-text-color: var(--material-error-color);
  14. /* Background colors */
  15. --material-background-color: var(--light-theme-background-color, #fff);
  16. --material-secondary-background-color: var(--light-theme-secondary-background-color, #f5f5f5);
  17. --material-disabled-color: rgba(0, 0, 0, 0.26);
  18. /* Divider colors */
  19. --material-divider-color: rgba(0, 0, 0, 0.12);
  20. /* Undocumented internal properties (prefixed with three dashes) */
  21. /* Text field tweaks */
  22. --_material-text-field-input-line-background-color: initial;
  23. --_material-text-field-input-line-opacity: initial;
  24. --_material-text-field-input-line-hover-opacity: initial;
  25. --_material-text-field-focused-label-opacity: initial;
  26. /* Button tweaks */
  27. --_material-button-raised-background-color: initial;
  28. --_material-button-outline-color: initial;
  29. /* Grid tweaks */
  30. --_material-grid-row-hover-background-color: initial;
  31. /* Split layout tweaks */
  32. --_material-split-layout-splitter-background-color: initial;
  33. background-color: var(--material-background-color);
  34. color: var(--material-body-text-color);
  35. }
  36. [theme~='dark'] {
  37. /* Text colors */
  38. --material-body-text-color: var(--dark-theme-text-color, rgba(255, 255, 255, 1));
  39. --material-secondary-text-color: var(--dark-theme-secondary-color, rgba(255, 255, 255, 0.7));
  40. --material-disabled-text-color: var(--dark-theme-disabled-color, rgba(255, 255, 255, 0.5));
  41. /* Primary colors */
  42. --material-primary-color: var(--light-primary-color, #7e3ff2);
  43. --material-primary-text-color: #b794f6;
  44. /* Error colors */
  45. --material-error-color: var(--error-color, #de2839);
  46. --material-error-text-color: var(--material-error-color);
  47. /* Background colors */
  48. --material-background-color: var(--dark-theme-background-color, #303030);
  49. --material-secondary-background-color: var(--dark-theme-secondary-background-color, #3b3b3b);
  50. --material-disabled-color: rgba(255, 255, 255, 0.3);
  51. /* Divider colors */
  52. --material-divider-color: rgba(255, 255, 255, 0.12);
  53. /* Undocumented internal properties (prefixed with three dashes) */
  54. /* Text field tweaks */
  55. --_material-text-field-input-line-background-color: #fff;
  56. --_material-text-field-input-line-opacity: 0.7;
  57. --_material-text-field-input-line-hover-opacity: 1;
  58. --_material-text-field-focused-label-opacity: 1;
  59. /* Button tweaks */
  60. --_material-button-raised-background-color: rgba(255, 255, 255, 0.08);
  61. --_material-button-outline-color: rgba(255, 255, 255, 0.2);
  62. /* Grid tweaks */
  63. --_material-grid-row-hover-background-color: rgba(255, 255, 255, 0.08);
  64. --_material-grid-row-selected-overlay-opacity: 0.16;
  65. /* Split layout tweaks */
  66. --_material-split-layout-splitter-background-color: rgba(255, 255, 255, 0.8);
  67. background-color: var(--material-background-color);
  68. color: var(--material-body-text-color);
  69. }
  70. a {
  71. color: inherit;
  72. }
  73. `,{moduleId:"material-color-light"});$s("",r`
  74. :host {
  75. /* Text colors */
  76. --material-body-text-color: var(--dark-theme-text-color, rgba(255, 255, 255, 1));
  77. --material-secondary-text-color: var(--dark-theme-secondary-color, rgba(255, 255, 255, 0.7));
  78. --material-disabled-text-color: var(--dark-theme-disabled-color, rgba(255, 255, 255, 0.5));
  79. /* Primary colors */
  80. --material-primary-color: var(--light-primary-color, #7e3ff2);
  81. --material-primary-text-color: #b794f6;
  82. /* Error colors */
  83. --material-error-color: var(--error-color, #de2839);
  84. --material-error-text-color: var(--material-error-color);
  85. /* Background colors */
  86. --material-background-color: var(--dark-theme-background-color, #303030);
  87. --material-secondary-background-color: var(--dark-theme-secondary-background-color, #3b3b3b);
  88. --material-disabled-color: rgba(255, 255, 255, 0.3);
  89. /* Divider colors */
  90. --material-divider-color: rgba(255, 255, 255, 0.12);
  91. /* Undocumented internal properties (prefixed with three dashes) */
  92. /* Text field tweaks */
  93. --_material-text-field-input-line-background-color: #fff;
  94. --_material-text-field-input-line-opacity: 0.7;
  95. --_material-text-field-input-line-hover-opacity: 1;
  96. --_material-text-field-focused-label-opacity: 1;
  97. /* Button tweaks */
  98. --_material-button-raised-background-color: rgba(255, 255, 255, 0.08);
  99. --_material-button-outline-color: rgba(255, 255, 255, 0.2);
  100. /* Grid tweaks */
  101. --_material-grid-row-hover-background-color: rgba(255, 255, 255, 0.08);
  102. --_material-grid-row-selected-overlay-opacity: 0.16;
  103. /* Split layout tweaks */
  104. --_material-split-layout-splitter-background-color: rgba(255, 255, 255, 0.8);
  105. background-color: var(--material-background-color);
  106. color: var(--material-body-text-color);
  107. }
  108. `,{moduleId:"material-color-dark"});const Ss=r`
  109. :host {
  110. /* Text colors */
  111. --material-body-text-color: var(--light-theme-text-color, rgba(0, 0, 0, 0.87));
  112. --material-secondary-text-color: var(--light-theme-secondary-color, rgba(0, 0, 0, 0.54));
  113. --material-disabled-text-color: var(--light-theme-disabled-color, rgba(0, 0, 0, 0.38));
  114. /* Primary colors */
  115. --material-primary-color: var(--primary-color, #6200ee);
  116. --material-primary-contrast-color: var(--dark-theme-base-color, #fff);
  117. --material-primary-text-color: var(--material-primary-color);
  118. /* Error colors */
  119. --material-error-color: var(--error-color, #b00020);
  120. --material-error-text-color: var(--material-error-color);
  121. /* Background colors */
  122. --material-background-color: var(--light-theme-background-color, #fff);
  123. --material-secondary-background-color: var(--light-theme-secondary-background-color, #f5f5f5);
  124. --material-disabled-color: rgba(0, 0, 0, 0.26);
  125. /* Divider colors */
  126. --material-divider-color: rgba(0, 0, 0, 0.12);
  127. }
  128. `,Ts=document.createElement("template");Ts.innerHTML=`<style>${Ss.toString().replace(":host","html")}</style>`,document.head.appendChild(Ts.content);const Ls=r`
  129. :host {
  130. /* Font family */
  131. --material-font-family: 'Roboto', sans-serif;
  132. /* Font sizes */
  133. --material-h1-font-size: 6rem;
  134. --material-h2-font-size: 3.75rem;
  135. --material-h3-font-size: 3rem;
  136. --material-h4-font-size: 2.125rem;
  137. --material-h5-font-size: 1.5rem;
  138. --material-h6-font-size: 1.25rem;
  139. --material-body-font-size: 1rem;
  140. --material-small-font-size: 0.875rem;
  141. --material-button-font-size: 0.875rem;
  142. --material-caption-font-size: 0.75rem;
  143. /* Icon size */
  144. --material-icon-font-size: 20px;
  145. }
  146. `;$s("",r`
  147. body,
  148. :host {
  149. font-family: var(--material-font-family);
  150. font-size: var(--material-body-font-size);
  151. line-height: 1.4;
  152. -webkit-text-size-adjust: 100%;
  153. -webkit-font-smoothing: antialiased;
  154. -moz-osx-font-smoothing: grayscale;
  155. }
  156. h1,
  157. h2,
  158. h3,
  159. h4,
  160. h5,
  161. h6 {
  162. color: inherit;
  163. line-height: 1.1;
  164. margin-top: 1.5em;
  165. }
  166. h1 {
  167. font-size: var(--material-h3-font-size);
  168. font-weight: 300;
  169. letter-spacing: -0.015em;
  170. margin-bottom: 1em;
  171. text-indent: -0.07em;
  172. }
  173. h2 {
  174. font-size: var(--material-h4-font-size);
  175. font-weight: 300;
  176. letter-spacing: -0.01em;
  177. margin-bottom: 0.75em;
  178. text-indent: -0.07em;
  179. }
  180. h3 {
  181. font-size: var(--material-h5-font-size);
  182. font-weight: 400;
  183. margin-bottom: 0.75em;
  184. text-indent: -0.05em;
  185. }
  186. h4 {
  187. font-size: var(--material-h6-font-size);
  188. font-weight: 400;
  189. letter-spacing: 0.01em;
  190. margin-bottom: 0.75em;
  191. text-indent: -0.05em;
  192. }
  193. h5 {
  194. font-size: var(--material-body-font-size);
  195. font-weight: 500;
  196. margin-bottom: 0.5em;
  197. text-indent: -0.025em;
  198. }
  199. h6 {
  200. font-size: var(--material-small-font-size);
  201. font-weight: 500;
  202. letter-spacing: 0.01em;
  203. margin-bottom: 0.25em;
  204. text-indent: -0.025em;
  205. }
  206. a,
  207. b,
  208. strong {
  209. font-weight: 500;
  210. }
  211. `,{moduleId:"material-typography"});const Os=document.createElement("template");if(Os.innerHTML=`<style>${Ls.toString().replace(":host","html")}</style>`,document.head.appendChild(Os.content),!window.polymerSkipLoadingFontRoboto){const e="https://fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,300,300italic,400italic,500,500italic,700,700italic",t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.crossOrigin="anonymous",t.href=e,document.head.appendChild(t)}const Ms=r`
  212. /* prettier-ignore */
  213. :host {
  214. /* from http://codepen.io/shyndman/pen/c5394ddf2e8b2a5c9185904b57421cdb */
  215. --material-shadow-elevation-2dp: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
  216. --material-shadow-elevation-3dp: 0 3px 4px 0 rgba(0, 0, 0, 0.14), 0 1px 8px 0 rgba(0, 0, 0, 0.12), 0 3px 3px -2px rgba(0, 0, 0, 0.4);
  217. --material-shadow-elevation-4dp: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
  218. --material-shadow-elevation-6dp: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.4);
  219. --material-shadow-elevation-8dp: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.4);
  220. --material-shadow-elevation-12dp: 0 12px 16px 1px rgba(0, 0, 0, 0.14), 0 4px 22px 3px rgba(0, 0, 0, 0.12), 0 6px 7px -4px rgba(0, 0, 0, 0.4);
  221. --material-shadow-elevation-16dp: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.4);
  222. --material-shadow-elevation-24dp: 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12), 0 11px 15px -7px rgba(0, 0, 0, 0.4);
  223. }
  224. `,Ps=document.createElement("template");Ps.innerHTML=`<style>${Ms.toString().replace(":host","html")}</style>`,document.head.appendChild(Ps.content);const Fs=r`
  225. :host {
  226. top: 16px;
  227. right: 16px;
  228. /* TODO (@jouni): remove unnecessary multiplication after https://github.com/vaadin/vaadin-overlay/issues/90 is fixed */
  229. bottom: calc(1px * var(--vaadin-overlay-viewport-bottom) + 16px);
  230. left: 16px;
  231. }
  232. [part='overlay'] {
  233. background-color: var(--material-background-color);
  234. border-radius: 4px;
  235. box-shadow: var(--material-shadow-elevation-4dp);
  236. color: var(--material-body-text-color);
  237. font-family: var(--material-font-family);
  238. font-size: var(--material-body-font-size);
  239. font-weight: 400;
  240. }
  241. [part='content'] {
  242. padding: 8px 0;
  243. }
  244. [part='backdrop'] {
  245. opacity: 0.2;
  246. animation: 0.2s vaadin-overlay-backdrop-enter;
  247. will-change: opacity;
  248. }
  249. @keyframes vaadin-overlay-backdrop-enter {
  250. 0% {
  251. opacity: 0;
  252. }
  253. }
  254. `;$s("",Fs,{moduleId:"material-overlay"}),$s("vaadin-overlay",Fs,{moduleId:"material-vaadin-overlay"});const Ds=e=>e.test(navigator.userAgent),Bs=e=>e.test(navigator.platform);Ds(/Android/),Ds(/Chrome/)&&/Google Inc/.test(navigator.vendor),Ds(/Firefox/);const Ns=Bs(/^iPad/)||Bs(/^Mac/)&&navigator.maxTouchPoints>1,Vs=Bs(/^iPhone/)||Ns,qs=Ds(/^((?!chrome|android).)*safari/i),js=(()=>{try{return document.createEvent("TouchEvent"),!0}catch(e){return!1}})(),Rs=l((e=>class extends e{constructor(){super(),this.__controllers=new Set}connectedCallback(){super.connectedCallback(),this.__controllers.forEach((e=>{e.hostConnected&&e.hostConnected()}))}disconnectedCallback(){super.disconnectedCallback(),this.__controllers.forEach((e=>{e.hostDisconnected&&e.hostDisconnected()}))}addController(e){this.__controllers.add(e),void 0!==this.$&&this.isConnected&&e.hostConnected&&e.hostConnected()}removeController(e){this.__controllers.delete(e)}}));class Us{static detectScrollType(){const e=document.createElement("div");e.textContent="ABCD",e.dir="rtl",e.style.fontSize="14px",e.style.width="4px",e.style.height="1px",e.style.position="absolute",e.style.top="-1000px",e.style.overflow="scroll",document.body.appendChild(e);let t="reverse";return e.scrollLeft>0?t="default":(e.scrollLeft=2,e.scrollLeft<2&&(t="negative")),document.body.removeChild(e),t}static getNormalizedScrollLeft(e,t,i){const{scrollLeft:a}=i;if("rtl"!==t||!e)return a;switch(e){case"negative":return i.scrollWidth-i.clientWidth+a;case"reverse":return i.scrollWidth-i.clientWidth-a;default:return a}}static setNormalizedScrollLeft(e,t,i,a){if("rtl"===t&&e)switch(e){case"negative":i.scrollLeft=i.clientWidth-i.scrollWidth+a;break;case"reverse":i.scrollLeft=i.scrollWidth-i.clientWidth-a;break;default:i.scrollLeft=a}else i.scrollLeft=a}}const Hs=[];let Gs;function Ws(e,t,i=e.getAttribute("dir")){t?e.setAttribute("dir",t):null!=i&&e.removeAttribute("dir")}function Ks(){return document.documentElement.getAttribute("dir")}new MutationObserver((function(){const e=Ks();Hs.forEach((t=>{Ws(t,e)}))})).observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]});const Ys=e=>class extends e{static get properties(){return{dir:{type:String,value:"",reflectToAttribute:!0,converter:{fromAttribute:e=>e||"",toAttribute:e=>""===e?null:e}}}}static finalize(){super.finalize(),Gs||(Gs=Us.detectScrollType())}connectedCallback(){super.connectedCallback(),this.hasAttribute("dir")||(this.__subscribe(),Ws(this,Ks(),null))}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),"dir"!==e)return;const a=Ks(),n=i===a&&-1===Hs.indexOf(this),o=!i&&t&&-1===Hs.indexOf(this),s=i!==a&&t===a;n||o?(this.__subscribe(),Ws(this,a,i)):s&&this.__subscribe(!1)}disconnectedCallback(){super.disconnectedCallback(),this.__subscribe(!1),this.removeAttribute("dir")}_valueToNodeAttribute(e,t,i){("dir"!==i||""!==t||e.hasAttribute("dir"))&&super._valueToNodeAttribute(e,t,i)}_attributeToProperty(e,t,i){"dir"!==e||t?super._attributeToProperty(e,t,i):this.dir=""}__subscribe(e=!0){e?Hs.includes(this)||Hs.push(this):Hs.includes(this)&&Hs.splice(Hs.indexOf(this),1)}__getNormalizedScrollLeft(e){return Us.getNormalizedScrollLeft(Gs,this.getAttribute("dir")||"ltr",e)}__setNormalizedScrollLeft(e,t){return Us.setNormalizedScrollLeft(Gs,this.getAttribute("dir")||"ltr",e,t)}};function Zs(e,t){const i=Math.max(e.tabIndex,0),a=Math.max(t.tabIndex,0);return 0===i||0===a?a>i:i>a}function Qs(e){const t=e.length;if(t<2)return e;const i=Math.ceil(t/2);return function(e,t){const i=[];for(;e.length>0&&t.length>0;)Zs(e[0],t[0])?i.push(t.shift()):i.push(e.shift());return i.concat(e,t)}(Qs(e.slice(0,i)),Qs(e.slice(i)))}function Js(e,t){if(e.nodeType!==Node.ELEMENT_NODE||function(e){const t=e.style;if("hidden"===t.visibility||"none"===t.display)return!0;const i=window.getComputedStyle(e);return"hidden"===i.visibility||"none"===i.display}(e))return!1;const i=e,a=function(e){if(!function(e){return!e.matches('[tabindex="-1"]')&&(e.matches("input, select, textarea, button, object")?e.matches(":not([disabled])"):e.matches("a[href], area[href], iframe, [tabindex], [contentEditable]"))}(e))return-1;const t=e.getAttribute("tabindex")||0;return Number(t)}(i);let n=a>0;a>=0&&t.push(i);let o=[];return o="slot"===i.localName?i.assignedNodes({flatten:!0}):(i.shadowRoot||i).children,[...o].forEach((e=>{n=Js(e,t)||n})),n}function Xs(e){return e.getRootNode().activeElement===e}const er=[];class tr{constructor(e){this.host=e,this.__trapNode=null,this.__onKeyDown=this.__onKeyDown.bind(this)}hostConnected(){document.addEventListener("keydown",this.__onKeyDown)}hostDisconnected(){document.removeEventListener("keydown",this.__onKeyDown)}trapFocus(e){if(this.__trapNode=e,0===this.__focusableElements.length)throw this.__trapNode=null,new Error("The trap node should have at least one focusable descendant or be focusable itself.");er.push(this),-1===this.__focusedElementIndex&&this.__focusableElements[0].focus()}releaseFocus(){this.__trapNode=null,er.pop()}__onKeyDown(e){if(this.__trapNode&&this===Array.from(er).pop()&&"Tab"===e.key){e.preventDefault();const t=e.shiftKey;this.__focusNextElement(t)}}__focusNextElement(e=!1){const t=this.__focusableElements,i=e?-1:1,a=this.__focusedElementIndex,n=t[(t.length+a+i)%t.length];n.focus(),"input"===n.localName&&n.select()}get __focusableElements(){return function(e){const t=[];return Js(e,t)?Qs(t):t}(this.__trapNode)}get __focusedElementIndex(){const e=this.__focusableElements;return e.indexOf(e.filter(Xs).pop())}}class ir extends(zs(Ys(Rs(d)))){static get template(){return c`
  255. <style>
  256. :host {
  257. z-index: 200;
  258. position: fixed;
  259. /* Despite of what the names say, <vaadin-overlay> is just a container
  260. for position/sizing/alignment. The actual overlay is the overlay part. */
  261. /* Default position constraints: the entire viewport. Note: themes can
  262. override this to introduce gaps between the overlay and the viewport. */
  263. top: 0;
  264. right: 0;
  265. bottom: var(--vaadin-overlay-viewport-bottom);
  266. left: 0;
  267. /* Use flexbox alignment for the overlay part. */
  268. display: flex;
  269. flex-direction: column; /* makes dropdowns sizing easier */
  270. /* Align to center by default. */
  271. align-items: center;
  272. justify-content: center;
  273. /* Allow centering when max-width/max-height applies. */
  274. margin: auto;
  275. /* The host is not clickable, only the overlay part is. */
  276. pointer-events: none;
  277. /* Remove tap highlight on touch devices. */
  278. -webkit-tap-highlight-color: transparent;
  279. /* CSS API for host */
  280. --vaadin-overlay-viewport-bottom: 0;
  281. }
  282. :host([hidden]),
  283. :host(:not([opened]):not([closing])) {
  284. display: none !important;
  285. }
  286. [part='overlay'] {
  287. -webkit-overflow-scrolling: touch;
  288. overflow: auto;
  289. pointer-events: auto;
  290. /* Prevent overflowing the host in MSIE 11 */
  291. max-width: 100%;
  292. box-sizing: border-box;
  293. -webkit-tap-highlight-color: initial; /* reenable tap highlight inside */
  294. }
  295. [part='backdrop'] {
  296. z-index: -1;
  297. content: '';
  298. background: rgba(0, 0, 0, 0.5);
  299. position: fixed;
  300. top: 0;
  301. left: 0;
  302. bottom: 0;
  303. right: 0;
  304. pointer-events: auto;
  305. }
  306. </style>
  307. <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div>
  308. <div part="overlay" id="overlay" tabindex="0">
  309. <div part="content" id="content">
  310. <slot></slot>
  311. </div>
  312. </div>
  313. `}static get is(){return"vaadin-overlay"}static get properties(){return{opened:{type:Boolean,notify:!0,observer:"_openedChanged",reflectToAttribute:!0},owner:Element,renderer:Function,template:{type:Object,notify:!0},content:{type:Object,notify:!0},withBackdrop:{type:Boolean,value:!1,reflectToAttribute:!0},model:Object,modeless:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_modelessChanged"},hidden:{type:Boolean,reflectToAttribute:!0,observer:"_hiddenChanged"},focusTrap:{type:Boolean,value:!1},restoreFocusOnClose:{type:Boolean,value:!1},restoreFocusNode:{type:HTMLElement},_mouseDownInside:{type:Boolean},_mouseUpInside:{type:Boolean},_instance:{type:Object},_originalContentPart:Object,_contentNodes:Array,_oldOwner:Element,_oldModel:Object,_oldTemplate:Object,_oldRenderer:Object,_oldOpened:Boolean}}static get observers(){return["_templateOrRendererChanged(template, renderer, owner, model, opened)"]}constructor(){super(),this._boundMouseDownListener=this._mouseDownListener.bind(this),this._boundMouseUpListener=this._mouseUpListener.bind(this),this._boundOutsideClickListener=this._outsideClickListener.bind(this),this._boundKeydownListener=this._keydownListener.bind(this),this._observer=new u(this,(e=>{this._setTemplateFromNodes(e.addedNodes)})),this._boundIronOverlayCanceledListener=this._ironOverlayCanceled.bind(this),Vs&&(this._boundIosResizeListener=()=>this._detectIosNavbar()),this.__focusTrapController=new tr(this)}ready(){super.ready(),this._observer.flush(),this.addEventListener("click",(()=>{})),this.$.backdrop.addEventListener("click",(()=>{})),this.addController(this.__focusTrapController)}_detectIosNavbar(){if(!this.opened)return;const e=window.innerHeight,t=window.innerWidth>e,i=document.documentElement.clientHeight;t&&i>e?this.style.setProperty("--vaadin-overlay-viewport-bottom",i-e+"px"):this.style.setProperty("--vaadin-overlay-viewport-bottom","0")}_setTemplateFromNodes(e){this.template=e.filter((e=>e.localName&&"template"===e.localName))[0]||this.template}close(e){const t=new CustomEvent("vaadin-overlay-close",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),t.defaultPrevented||(this.opened=!1)}connectedCallback(){super.connectedCallback(),this._boundIosResizeListener&&(this._detectIosNavbar(),window.addEventListener("resize",this._boundIosResizeListener))}disconnectedCallback(){super.disconnectedCallback(),this._boundIosResizeListener&&window.removeEventListener("resize",this._boundIosResizeListener)}requestContentUpdate(){this.renderer&&this.renderer.call(this.owner,this.content,this.owner,this.model)}_ironOverlayCanceled(e){e.preventDefault()}_mouseDownListener(e){this._mouseDownInside=e.composedPath().indexOf(this.$.overlay)>=0}_mouseUpListener(e){this._mouseUpInside=e.composedPath().indexOf(this.$.overlay)>=0}_outsideClickListener(e){if(e.composedPath().includes(this.$.overlay)||this._mouseDownInside||this._mouseUpInside)return this._mouseDownInside=!1,void(this._mouseUpInside=!1);if(!this._last)return;const t=new CustomEvent("vaadin-overlay-outside-click",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),this.opened&&!t.defaultPrevented&&this.close(e)}_keydownListener(e){if(this._last&&(!this.modeless||e.composedPath().includes(this.$.overlay))&&"Escape"===e.key){const t=new CustomEvent("vaadin-overlay-escape-press",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),this.opened&&!t.defaultPrevented&&this.close(e)}}_ensureTemplatized(){this._setTemplateFromNodes(Array.from(this.children))}_openedChanged(e,t){this._instance||this._ensureTemplatized(),e?(this.__restoreFocusNode=this._getActiveElement(),this._animatedOpening(),Dn(this,(()=>{this.focusTrap&&this.__focusTrapController.trapFocus(this.$.overlay);const e=new CustomEvent("vaadin-overlay-open",{bubbles:!0});this.dispatchEvent(e)})),document.addEventListener("keydown",this._boundKeydownListener),this.modeless||this._addGlobalListeners()):t&&(this.focusTrap&&this.__focusTrapController.releaseFocus(),this._animatedClosing(),document.removeEventListener("keydown",this._boundKeydownListener),this.modeless||this._removeGlobalListeners())}_hiddenChanged(e){e&&this.hasAttribute("closing")&&this._flushAnimation("closing")}_shouldAnimate(){const e=getComputedStyle(this).getPropertyValue("animation-name");return!("none"===getComputedStyle(this).getPropertyValue("display"))&&e&&"none"!==e}_enqueueAnimation(e,t){const i=`__${e}Handler`,a=e=>{e&&e.target!==this||(t(),this.removeEventListener("animationend",a),delete this[i])};this[i]=a,this.addEventListener("animationend",a)}_flushAnimation(e){const t=`__${e}Handler`;"function"==typeof this[t]&&this[t]()}_animatedOpening(){this.parentNode===document.body&&this.hasAttribute("closing")&&this._flushAnimation("closing"),this._attachOverlay(),this.modeless||this._enterModalState(),this.setAttribute("opening",""),this._shouldAnimate()?this._enqueueAnimation("opening",(()=>{this._finishOpening()})):this._finishOpening()}_attachOverlay(){this._placeholder=document.createComment("vaadin-overlay-placeholder"),this.parentNode.insertBefore(this._placeholder,this),document.body.appendChild(this),this.bringToFront()}_finishOpening(){document.addEventListener("iron-overlay-canceled",this._boundIronOverlayCanceledListener),this.removeAttribute("opening")}_finishClosing(){document.removeEventListener("iron-overlay-canceled",this._boundIronOverlayCanceledListener),this._detachOverlay(),this.$.overlay.style.removeProperty("pointer-events"),this.removeAttribute("closing")}_animatedClosing(){if(this.hasAttribute("opening")&&this._flushAnimation("opening"),this._placeholder){this._exitModalState();const e=this.restoreFocusNode||this.__restoreFocusNode;if(this.restoreFocusOnClose&&e){const t=this._getActiveElement();(t===document.body||this._deepContains(t))&&setTimeout((()=>e.focus())),this.__restoreFocusNode=null}this.setAttribute("closing",""),this.dispatchEvent(new CustomEvent("vaadin-overlay-closing")),this._shouldAnimate()?this._enqueueAnimation("closing",(()=>{this._finishClosing()})):this._finishClosing()}}_detachOverlay(){this._placeholder.parentNode.insertBefore(this,this._placeholder),this._placeholder.parentNode.removeChild(this._placeholder)}static get __attachedInstances(){return Array.from(document.body.children).filter((e=>e instanceof ir&&!e.hasAttribute("closing"))).sort(((e,t)=>e.__zIndex-t.__zIndex||0))}get _last(){return this===ir.__attachedInstances.pop()}_modelessChanged(e){e?(this._removeGlobalListeners(),this._exitModalState()):this.opened&&(this._addGlobalListeners(),this._enterModalState())}_addGlobalListeners(){document.addEventListener("mousedown",this._boundMouseDownListener),document.addEventListener("mouseup",this._boundMouseUpListener),document.documentElement.addEventListener("click",this._boundOutsideClickListener,!0)}_enterModalState(){"none"!==document.body.style.pointerEvents&&(this._previousDocumentPointerEvents=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),ir.__attachedInstances.forEach((e=>{e!==this&&(e.shadowRoot.querySelector('[part="overlay"]').style.pointerEvents="none")}))}_removeGlobalListeners(){document.removeEventListener("mousedown",this._boundMouseDownListener),document.removeEventListener("mouseup",this._boundMouseUpListener),document.documentElement.removeEventListener("click",this._boundOutsideClickListener,!0)}_exitModalState(){void 0!==this._previousDocumentPointerEvents&&(document.body.style.pointerEvents=this._previousDocumentPointerEvents,delete this._previousDocumentPointerEvents);const e=ir.__attachedInstances;let t;for(;(t=e.pop())&&(t===this||(t.shadowRoot.querySelector('[part="overlay"]').style.removeProperty("pointer-events"),t.modeless)););}_removeOldContent(){this.content&&this._contentNodes&&(this._observer.disconnect(),this._contentNodes.forEach((e=>{e.parentNode===this.content&&this.content.removeChild(e)})),this._originalContentPart&&(this.$.content.parentNode.replaceChild(this._originalContentPart,this.$.content),this.$.content=this._originalContentPart,this._originalContentPart=void 0),this._observer.connect(),this._contentNodes=void 0,this.content=void 0)}_stampOverlayTemplate(e){this._removeOldContent(),e._Templatizer||(e._Templatizer=h(e,this,{forwardHostProp(e,t){this._instance&&this._instance.forwardHostProp(e,t)}})),this._instance=new e._Templatizer({}),this._contentNodes=Array.from(this._instance.root.childNodes);const t=e._templateRoot||(e._templateRoot=e.getRootNode());if(t!==document){this.$.content.shadowRoot||this.$.content.attachShadow({mode:"open"});let e=Array.from(t.querySelectorAll("style")).reduce(((e,t)=>e+t.textContent),"");if(e=e.replace(/:host/g,":host-nomatch"),e){const t=document.createElement("style");t.textContent=e,this.$.content.shadowRoot.appendChild(t),this._contentNodes.unshift(t)}this.$.content.shadowRoot.appendChild(this._instance.root),this.content=this.$.content.shadowRoot}else this.appendChild(this._instance.root),this.content=this}_removeNewRendererOrTemplate(e,t,i,a){e!==t?this.template=void 0:i!==a&&(this.renderer=void 0)}_templateOrRendererChanged(e,t,i,a,n){if(e&&t)throw this._removeNewRendererOrTemplate(e,this._oldTemplate,t,this._oldRenderer),new Error("You should only use either a renderer or a template for overlay content");const o=this._oldOwner!==i||this._oldModel!==a;this._oldModel=a,this._oldOwner=i;const s=this._oldTemplate!==e;this._oldTemplate=e;const r=this._oldRenderer!==t;this._oldRenderer=t;const l=this._oldOpened!==n;this._oldOpened=n,r&&(this.content=this,this.content.innerHTML="",delete this.content._$litPart$),e&&s?this._stampOverlayTemplate(e):t&&(r||l||o)&&n&&this.requestContentUpdate()}_getActiveElement(){let e=document.activeElement||document.body;for(;e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}_deepContains(e){if(this.contains(e))return!0;let t=e;const i=e.ownerDocument;for(;t&&t!==i&&t!==this;)t=t.parentNode||t.host;return t===this}bringToFront(){let e="";const t=ir.__attachedInstances.filter((e=>e!==this)).pop();if(t){e=t.__zIndex+1}this.style.zIndex=e,this.__zIndex=e||parseFloat(getComputedStyle(this).zIndex)}}customElements.define(ir.is,ir);const ar=Fs;$s("",ar,{moduleId:"material-menu-overlay"});$s("vaadin-combo-box-overlay",[ar,r`
  314. :host {
  315. --_vaadin-combo-box-items-container-border-width: 8px 0;
  316. --_vaadin-combo-box-items-container-border-style: solid;
  317. --_vaadin-combo-box-items-container-border-color: transparent;
  318. }
  319. [part='overlay'] {
  320. position: relative;
  321. overflow: visible;
  322. border-top-left-radius: 0;
  323. border-top-right-radius: 0;
  324. }
  325. [part='content'] {
  326. padding: 0;
  327. }
  328. :host([loading]) [part='loader'] {
  329. height: 2px;
  330. position: absolute;
  331. z-index: 1;
  332. top: -2px;
  333. left: 0;
  334. right: 0;
  335. background: var(--material-background-color)
  336. linear-gradient(
  337. 90deg,
  338. transparent 0%,
  339. transparent 20%,
  340. var(--material-primary-color) 20%,
  341. var(--material-primary-color) 40%,
  342. transparent 40%,
  343. transparent 60%,
  344. var(--material-primary-color) 60%,
  345. var(--material-primary-color) 80%,
  346. transparent 80%,
  347. transparent 100%
  348. )
  349. 0 0 / 400% 100% repeat-x;
  350. opacity: 0;
  351. animation: 3s linear infinite material-combo-box-loader-progress, 0.3s 0.1s both material-combo-box-loader-fade-in;
  352. }
  353. [part='loader']::before {
  354. content: '';
  355. display: block;
  356. height: 100%;
  357. opacity: 0.16;
  358. background: var(--material-primary-color);
  359. }
  360. @keyframes material-combo-box-loader-fade-in {
  361. 0% {
  362. opacity: 0;
  363. }
  364. 100% {
  365. opacity: 1;
  366. }
  367. }
  368. @keyframes material-combo-box-loader-progress {
  369. 0% {
  370. background-position: 0 0;
  371. background-size: 300% 100%;
  372. }
  373. 33% {
  374. background-position: -100% 0;
  375. background-size: 400% 100%;
  376. }
  377. 67% {
  378. background-position: -200% 0;
  379. background-size: 250% 100%;
  380. }
  381. 100% {
  382. background-position: -300% 0;
  383. background-size: 300% 100%;
  384. }
  385. }
  386. /* RTL specific styles */
  387. @keyframes material-combo-box-loader-progress-rtl {
  388. 0% {
  389. background-position: 100% 0;
  390. background-size: 300% 100%;
  391. }
  392. 33% {
  393. background-position: 200% 0;
  394. background-size: 400% 100%;
  395. }
  396. 67% {
  397. background-position: 300% 0;
  398. background-size: 250% 100%;
  399. }
  400. 100% {
  401. background-position: 400% 0;
  402. background-size: 300% 100%;
  403. }
  404. }
  405. :host([loading][dir='rtl']) [part='loader'] {
  406. animation: 3s linear infinite material-combo-box-loader-progress-rtl,
  407. 0.3s 0.1s both material-combo-box-loader-fade-in;
  408. }
  409. `],{moduleId:"material-combo-box-overlay"});const nr=document.createElement("template");nr.innerHTML='\n <style>\n @font-face {\n font-family: \'material-icons\';\n src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAjAAAsAAAAADaAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADsAAABUIIslek9TLzIAAAFEAAAARAAAAFZSk1xEY21hcAAAAYgAAACNAAACNOuCXH5nbHlmAAACGAAABDoAAAX4NWGBxmhlYWQAAAZUAAAAMAAAADZhSa2YaGhlYQAABoQAAAAeAAAAJBGxCLtobXR4AAAGpAAAABMAAABAjXoAAGxvY2EAAAa4AAAAIgAAACIKMAjcbWF4cAAABtwAAAAfAAAAIAEeAFRuYW1lAAAG/AAAATQAAAJe3l764XBvc3QAAAgwAAAAkAAAAMondETCeJxjYGRgYOBiMGCwY2BycfMJYeDLSSzJY5BiYGGAAJA8MpsxJzM9kYEDxgPKsYBpDiBmg4gCACY7BUgAeJxjYOS4wTiBgZWBga2WbQIDA2MAhGZpYChlymZgYGJgZWbACgLSXFMYHF4xvuJnv/CvgOEG+wXG6UBhRpAcAA0HDXt4nO2R2Q0DIQxEHwt7HzSSGlJQvlJkqqGJjYdJGbH0PPJgELKBEcjBIyiQ3iQUr3BT9zNb9wvP3lPkt3rfkZNy1KXnIXpLvDgxs7DGvZ2Dk4saxxP/OHr+/KqqCZo+08EgzUa7acVoym002lubDNLZIF0M0tUg3Yz22XaD9DD6XTsN0ssgrYb6BZEQJiUAAAB4nH1UXUgcVxS+Z2ZnZpeq7IT9CbTY2Z24o1m72+zPTB/UFSS2MWssTZRs6doqialmy27bPIghPzQttCxjfEhjfGhoUFLBQoVdKixSkofCEkurwQdBgw1NqeCWFrokVt3b3pnRqm3J/Nw598537v3Od869CBC5uFm2EZkRAgl4kQcOuFm1NJcv3R+kBVpQS/dNdzcilH9w80e0F+8EPsiDAjCkUv485SMIgqd8GxHT3dIc8UYUQnjefINLoGfR88RDDIt2F3lFdwXYeVslBF2BBgjzIR/QLt7FzZ7Kb+7Pn5LfkMnDNhrfP++wjexYnlx6Z9fPtTXGZnAyh5hbiEHIApwFJPpD/OYg5TdNqnAJbpFgiGXgWIbp13AgWQhxllFL49RJFcumVWKVxlWY2cI1buHIdE6gV1S4h2WVOsn0qziMw8Ta0iLBLKFnjPk0qDYrlyArluaIJnpD+UmXaSONbu38IO40Qn+9RPQxo/3oEFLIPG6ORRxrdTqQ0yEoMlJkq+RBkod2Sz6QPFalARRZcFaC02HlKoBjaVFLgemrmVwGr0aPHYuCPZOD4VwG7NG2tihezeRmRq8NPaiPROofDF2D5h373etU+VHcwJkJrJDN4b5cFhc0J7Blc3A9lwVbtG1t7T9+OKfbjK00jr89D1r4umZj9IqWcQtFTUMRivQKLoPinhifQ8LTYhTDwbDIB02TM//HxGB5RiuEp1NeP5DPkwQZ+pLa2GQr0D7kRY3ba/+z8C5lQ7qyAV1Zm6EswXKszelwOgKKrMghySN5TJOPlxfwVEcHHFlYhsLyAhzp6MBTC8uPe+KxtEeSPOlY/Lsds+e15qbqmprqpuaxbYOt6IrjicVFPBHv6opD++IitMe7Nir/7WqYtLDHWTeQieyrXssyN4sqUBWqQy8jVMWKgqaivE/RahBYu02PJRhQJFZ0a9zDIcUCcjikxyu6OUkOCloSWIoMBwNaoHYb+8v8I1wsruKRzro7FzGXNi+l12PV3oPD3aeTZ7uzZeWxaEttLZi68Q+yt0YbvZD69acnUPZHAc50Rr4vfYYvCm4d1Nna1wPv/zYClrdhLf3kQJr5ovts8nT3cI23OgMveFuisfLyUh4OpS5oowe9cuH13h6s/v45LsB7cIWt9ba0xlxo114j9QU80IIpyiytf0xNo11nko90SJiCnj3rdvREEFEbEPfm2eEEF8/+nLxqlHNdJFJHSnt0avTmw9rZmvHUucsDycRtn9/vu51IFpN9x/E31DTTnty7B0jh8V+e+zoQ2oJpHi/6TmhYjRalNZa3CLcqVGuw05XX+Gj3do5cAZ1VWC8x4MlRSI6Tq+6+3pGbmcErl+5FPj0/cPgVfY0BxmZUWqS+N1HqxSk8r2+2RxPpT1pfDQam+q0njl/+6IbB3qjBD1LvNB3GD3EKhqCIy9DfIQrMlQAAeJxjYGRgYABiYWGbw/H8Nl8ZuDkTgCIMNaobGhH0v0zO++wXgFwOBiaQKAAHHgoPeJxjYGRgYL/wr4CBgcuKAQg47zMwMqACAQBc2wOEAAB4nGNgYGDgTCAec1mh8gG9VgYDAAAAAAAAGAAwAGIAdgCKAJ4AwAEkATIBcAHcAlQCYgKwAvwAAHicY2BkYGAQYPBgYGEAASYg5gJCBob/YD4DABFeAXMAeJx9kL1uwjAUhU8gUJVIVaWqnRgsVepSEX5G1BkkRgb2EBwIcuLIMUi8QR+kT9CH6NgH6VP0xHiBAVtyvvvdc50oAB7xgwDNCvDgzma1cMfqzG3Ss+eQ/Oq5gwhjz136D889vGPhOcITDrwhCO9p+vj03GL+y3Ob/ttzSP713MEL/jx30Q/guYdV0Pcc4S0wRWKlyRM1yFNd1ku5PajkSl5WK2nqXJdiHI8uG3NZSkOzEeuTqI/bibWZyIwuxEyXViqlRWX0XqY23llbTYfDzPs41QUKJLCQMMhJCgM+U2iUqLGk3/JfKHbMzeSt3sr5mqapBf9/jNHNiTl96XrnzIZTa5x41jjyiya0FhnrjBnNuwRmbrZJK25NU7nenialj7FzUxWmGHJnV/nYvb34BzHZcLZ4nG2M0Q6CMBRDV2CIOhTf/Ak+am5XIdyw5QoS/l4W4ptN2uYkTVWmdt3VfzXIkKOARokDKhxxwhkGNS64osFNXaxIWFoflnGx4s2Oc0xQOcs0eivadeQGs+VHwtgyPaf6B9K/ukk7pjTj4IbKS4jpT9P2JTmtZDa3vn/bB5MvItu1FOJgfTnHVEp9AbKdMX4=) format(\'woff\');\n font-weight: normal;\n font-style: normal;\n }\n\n html {\n --material-icons-arrow-downward: "\\ea01";\n --material-icons-arrow-upward: "\\ea02";\n --material-icons-calendar: "\\ea03";\n --material-icons-check: "\\ea04";\n --material-icons-chevron-left: "\\ea05";\n --material-icons-chevron-right: "\\ea06";\n --material-icons-clear: "\\ea07";\n --material-icons-clock: "\\ea08";\n --material-icons-dropdown: "\\ea09";\n --material-icons-error: "\\ea0a";\n --material-icons-eye: "\\ea0b";\n --material-icons-eye-disabled: "\\ea0c";\n --material-icons-play: "\\ea0d";\n --material-icons-reload: "\\ea0e";\n --material-icons-upload: "\\ea0f";\n }\n </style>\n',document.head.appendChild(nr.content);const or=r`
  410. :host {
  411. display: flex;
  412. align-items: center;
  413. box-sizing: border-box;
  414. min-height: 36px;
  415. padding: 8px 32px 8px 10px;
  416. overflow: hidden;
  417. font-family: var(--material-font-family);
  418. font-size: var(--material-small-font-size);
  419. line-height: 24px;
  420. }
  421. /* It's the list-box's responsibility to add the focus style */
  422. :host([focused]) {
  423. outline: none;
  424. }
  425. /* Checkmark */
  426. [part='checkmark']::before {
  427. display: var(--_material-item-selected-icon-display, none);
  428. content: '';
  429. font-family: material-icons;
  430. font-size: 24px;
  431. line-height: 1;
  432. font-weight: 400;
  433. width: 24px;
  434. text-align: center;
  435. margin-right: 10px;
  436. color: var(--material-secondary-text-color);
  437. flex: none;
  438. }
  439. :host([selected]) [part='checkmark']::before {
  440. content: var(--material-icons-check);
  441. }
  442. @media (any-hover: hover) {
  443. :host(:hover:not([disabled])) {
  444. background-color: var(--material-secondary-background-color);
  445. }
  446. :host([focused]:not([disabled])) {
  447. background-color: var(--material-divider-color);
  448. }
  449. }
  450. /* Disabled */
  451. :host([disabled]) {
  452. color: var(--material-disabled-text-color);
  453. cursor: default;
  454. pointer-events: none;
  455. }
  456. /* RTL specific styles */
  457. :host([dir='rtl']) {
  458. padding: 8px 10px 8px 32px;
  459. }
  460. :host([dir='rtl']) [part='checkmark']::before {
  461. margin-right: 0;
  462. margin-left: 10px;
  463. }
  464. `;$s("vaadin-item",or,{moduleId:"material-item"});$s("vaadin-combo-box-item",[or,r`
  465. :host {
  466. cursor: pointer;
  467. -webkit-tap-highlight-color: transparent;
  468. padding: 4px 10px;
  469. --_material-item-selected-icon-display: block;
  470. }
  471. `],{moduleId:"material-combo-box-item"});class sr extends(zs(Ys(d))){static get template(){return c`
  472. <style>
  473. :host {
  474. display: block;
  475. }
  476. :host([hidden]) {
  477. display: none;
  478. }
  479. </style>
  480. <span part="checkmark" aria-hidden="true"></span>
  481. <div part="content">
  482. <slot></slot>
  483. </div>
  484. `}static get is(){return"vaadin-combo-box-item"}static get properties(){return{index:Number,item:Object,label:String,selected:{type:Boolean,value:!1,reflectToAttribute:!0},focused:{type:Boolean,value:!1,reflectToAttribute:!0},renderer:Function,_oldRenderer:Function}}static get observers(){return["__rendererOrItemChanged(renderer, index, item.*, selected, focused)","__updateLabel(label, renderer)"]}connectedCallback(){super.connectedCallback(),this._comboBox=this.parentNode.comboBox;const e=this._comboBox.getAttribute("dir");e&&this.setAttribute("dir",e)}requestContentUpdate(){if(!this.renderer)return;const e={index:this.index,item:this.item,focused:this.focused,selected:this.selected};this.renderer(this,this._comboBox,e)}__rendererOrItemChanged(e,t,i){void 0!==i&&void 0!==t&&(this._oldRenderer!==e&&(this.innerHTML="",delete this._$litPart$),e&&(this._oldRenderer=e,this.requestContentUpdate()))}__updateLabel(e,t){t||(this.textContent=e)}}customElements.define(sr.is,sr);const rr={start:"top",end:"bottom"},lr={start:"left",end:"right"},dr=e=>class extends e{static get properties(){return{positionTarget:{type:Object,value:null},horizontalAlign:{type:String,value:"start"},verticalAlign:{type:String,value:"top"},noHorizontalOverlap:{type:Boolean,value:!1},noVerticalOverlap:{type:Boolean,value:!1}}}static get observers(){return["__positionSettingsChanged(horizontalAlign, verticalAlign, noHorizontalOverlap, noVerticalOverlap)","__overlayOpenedChanged(opened, positionTarget)"]}constructor(){super(),this._updatePosition=this._updatePosition.bind(this)}connectedCallback(){super.connectedCallback(),this.opened&&this.__addUpdatePositionEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.__removeUpdatePositionEventListeners()}__addUpdatePositionEventListeners(){window.addEventListener("resize",this._updatePosition),this.__positionTargetAncestorRootNodes=function(e){const t=[];for(;e;){if(e.nodeType===Node.DOCUMENT_NODE){t.push(e);break}e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?e=e.assignedSlot?e.assignedSlot:e.parentNode:(t.push(e),e=e.host)}return t}(this.positionTarget),this.__positionTargetAncestorRootNodes.forEach((e=>{e.addEventListener("scroll",this._updatePosition,!0)}))}__removeUpdatePositionEventListeners(){window.removeEventListener("resize",this._updatePosition),this.__positionTargetAncestorRootNodes&&(this.__positionTargetAncestorRootNodes.forEach((e=>{e.removeEventListener("scroll",this._updatePosition,!0)})),this.__positionTargetAncestorRootNodes=null)}__overlayOpenedChanged(e,t){if(this.__removeUpdatePositionEventListeners(),e&&t&&this.__addUpdatePositionEventListeners(),e){const e=getComputedStyle(this);this.__margins||(this.__margins={},["top","bottom","left","right"].forEach((t=>{this.__margins[t]=parseInt(e[t],10)}))),this.setAttribute("dir",e.direction),this._updatePosition(),requestAnimationFrame((()=>this._updatePosition()))}}get __isRTL(){return"rtl"===this.getAttribute("dir")}__positionSettingsChanged(){this._updatePosition()}_updatePosition(){if(!this.positionTarget||!this.opened)return;const e=this.positionTarget.getBoundingClientRect(),t=this.__shouldAlignStartVertically(e);this.style.justifyContent=t?"flex-start":"flex-end";const i=this.__shouldAlignStartHorizontally(e,this.__isRTL),a=!this.__isRTL&&i||this.__isRTL&&!i;this.style.alignItems=a?"flex-start":"flex-end";const n=this.getBoundingClientRect(),o=this.__calculatePositionInOneDimension(e,n,this.noVerticalOverlap,rr,this,t),s=this.__calculatePositionInOneDimension(e,n,this.noHorizontalOverlap,lr,this,i);Object.assign(this.style,o,s),this.toggleAttribute("bottom-aligned",!t),this.toggleAttribute("top-aligned",t),this.toggleAttribute("end-aligned",!a),this.toggleAttribute("start-aligned",a)}__shouldAlignStartHorizontally(e,t){const i=Math.max(this.__oldContentWidth||0,this.$.overlay.offsetWidth);this.__oldContentWidth=this.$.overlay.offsetWidth;const a=Math.min(window.innerWidth,document.documentElement.clientWidth),n=!t&&"start"===this.horizontalAlign||t&&"end"===this.horizontalAlign;return this.__shouldAlignStart(e,i,a,this.__margins,n,this.noHorizontalOverlap,lr)}__shouldAlignStartVertically(e){const t=Math.max(this.__oldContentHeight||0,this.$.overlay.offsetHeight);this.__oldContentHeight=this.$.overlay.offsetHeight;const i=Math.min(window.innerHeight,document.documentElement.clientHeight),a="top"===this.verticalAlign;return this.__shouldAlignStart(e,t,i,this.__margins,a,this.noVerticalOverlap,rr)}__shouldAlignStart(e,t,i,a,n,o,s){const r=i-e[o?s.end:s.start]-a[s.end],l=e[o?s.start:s.end]-a[s.start],d=n?r:l;return n===(d>(n?l:r)||d>t)}__calculatePositionInOneDimension(e,t,i,a,n,o){const s=o?a.start:a.end,r=o?a.end:a.start;return{[s]:`${parseFloat(n.style[s]||getComputedStyle(n)[s])+(t[o?a.start:a.end]-e[i===o?a.end:a.start])*(o?-1:1)}px`,[r]:""}}};let cr;$s("vaadin-combo-box-overlay",r`
  485. #overlay {
  486. width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
  487. }
  488. [part='content'] {
  489. display: flex;
  490. flex-direction: column;
  491. height: 100%;
  492. }
  493. `,{moduleId:"vaadin-combo-box-overlay-styles"});class ur extends(dr(ir)){static get is(){return"vaadin-combo-box-overlay"}static get template(){return cr||(cr=super.template.cloneNode(!0),cr.content.querySelector('[part~="overlay"]').removeAttribute("tabindex")),cr}static get observers(){return["_setOverlayWidth(positionTarget, opened)"]}connectedCallback(){super.connectedCallback();const e=this.__dataHost,t=e&&e.getRootNode().host;this._comboBox=t;const i=t&&t.getAttribute("dir");i&&this.setAttribute("dir",i)}ready(){super.ready();const e=document.createElement("div");e.setAttribute("part","loader");const t=this.shadowRoot.querySelector('[part~="content"]');t.parentNode.insertBefore(e,t)}_outsideClickListener(e){const t=e.composedPath();t.includes(this.positionTarget)||t.includes(this)||this.close()}_setOverlayWidth(e,t){if(e&&t){const t=this.localName;this.style.setProperty(`--_${t}-default-width`,`${e.clientWidth}px`);const i=getComputedStyle(this._comboBox).getPropertyValue(`--${t}-width`);""===i?this.style.removeProperty(`--${t}-width`):this.style.setProperty(`--${t}-width`,i),this._updatePosition()}}}customElements.define(ur.is,ur);let hr=0,pr=0;const vr=[];let mr=0,fr=!1;const gr=document.createTextNode("");new window.MutationObserver((function(){fr=!1;const e=vr.length;for(let t=0;t<e;t++){const e=vr[t];if(e)try{e()}catch(e){setTimeout((()=>{throw e}))}}vr.splice(0,e),pr+=e})).observe(gr,{characterData:!0});const _r={after:e=>({run:t=>window.setTimeout(t,e),cancel(e){window.clearTimeout(e)}}),run:(e,t)=>window.setTimeout(e,t),cancel(e){window.clearTimeout(e)}},yr={run:e=>window.requestAnimationFrame(e),cancel(e){window.cancelAnimationFrame(e)}},kr={run:e=>window.requestIdleCallback?window.requestIdleCallback(e):window.setTimeout(e,16),cancel(e){window.cancelIdleCallback?window.cancelIdleCallback(e):window.clearTimeout(e)}},br={run(e){fr||(fr=!0,gr.textContent=mr,mr+=1),vr.push(e);const t=hr;return hr+=1,t},cancel(e){const t=e-pr;if(t>=0){if(!vr[t])throw new Error(`invalid async handle: ${e}`);vr[t]=null}}};class xr{static debounce(e,t,i){return e instanceof xr?e._cancelAsync():e=new xr,e.setConfig(t,i),e}constructor(){this._asyncModule=null,this._callback=null,this._timer=null}setConfig(e,t){this._asyncModule=e,this._callback=t,this._timer=this._asyncModule.run((()=>{this._timer=null,$r.delete(this),this._callback()}))}cancel(){this.isActive()&&(this._cancelAsync(),$r.delete(this))}_cancelAsync(){this.isActive()&&(this._asyncModule.cancel(this._timer),this._timer=null)}flush(){this.isActive()&&(this.cancel(),this._callback())}isActive(){return null!=this._timer}}let $r=new Set;function wr(){const e=Boolean($r.size);return $r.forEach((e=>{try{e.flush()}catch(e){setTimeout((()=>{throw e}))}})),e}const Cr=()=>{let e;do{e=wr()}while(e)},Ar=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),Ir=Ar&&Ar[1]>=8,Er={_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_maxPages:2,_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){return this._physicalSize-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollOffset},get _maxVirtualStart(){const e=this._virtualCount;return Math.max(0,e-this._physicalCount)},get _virtualStart(){return this._virtualStartVal||0},set _virtualStart(e){e=this._clamp(e,0,this._maxVirtualStart),this._virtualStartVal=e},get _physicalStart(){return this._physicalStartVal||0},set _physicalStart(e){(e%=this._physicalCount)<0&&(e=this._physicalCount+e),this._physicalStartVal=e},get _physicalEnd(){return(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _physicalCount(){return this._physicalCountVal||0},set _physicalCount(e){this._physicalCountVal=e},get _optPhysicalSize(){return 0===this._viewportHeight?1/0:this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){let e=this._firstVisibleIndexVal;if(null==e){let t=this._physicalTop+this._scrollOffset;e=this._iterateItems(((e,i)=>{if(t+=this._getPhysicalSizeIncrement(e),t>this._scrollPosition)return i}))||0,this._firstVisibleIndexVal=e}return e},get lastVisibleIndex(){let e=this._lastVisibleIndexVal;if(null==e){let t=this._physicalTop+this._scrollOffset;this._iterateItems(((i,a)=>{t<this._scrollBottom&&(e=a),t+=this._getPhysicalSizeIncrement(i)})),this._lastVisibleIndexVal=e}return e},get _scrollOffset(){return this._scrollerPaddingTop+this.scrollOffset},_scrollHandler(){const e=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));let t=e-this._scrollPosition;const i=t>=0;if(this._scrollPosition=e,this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,Math.abs(t)>this._physicalSize&&this._physicalSize>0){t-=this._scrollOffset;const e=Math.round(t/this._physicalAverage);this._virtualStart+=e,this._physicalStart+=e,this._physicalTop=Math.min(Math.floor(this._virtualStart)*this._physicalAverage,this._scrollPosition),this._update()}else if(this._physicalCount>0){const e=this._getReusables(i);i?(this._physicalTop=e.physicalTop,this._virtualStart+=e.indexes.length,this._physicalStart+=e.indexes.length):(this._virtualStart-=e.indexes.length,this._physicalStart-=e.indexes.length),this._update(e.indexes,i?null:e.indexes),this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,0),br)}},_getReusables(e){let t,i,a;const n=[],o=this._hiddenContentSize*this._ratio,s=this._virtualStart,r=this._virtualEnd,l=this._physicalCount;let d=this._physicalTop+this._scrollOffset;const c=this._physicalBottom+this._scrollOffset,u=this._scrollPosition,h=this._scrollBottom;for(e?(t=this._physicalStart,i=u-d):(t=this._physicalEnd,i=c-h);a=this._getPhysicalSizeIncrement(t),i-=a,!(n.length>=l||i<=o);)if(e){if(r+n.length+1>=this._virtualCount)break;if(d+a>=u-this._scrollOffset)break;n.push(t),d+=a,t=(t+1)%l}else{if(s-n.length<=0)break;if(d+this._physicalSize-a<=h)break;n.push(t),d-=a,t=0===t?l-1:t-1}return{indexes:n,physicalTop:d-this._scrollOffset}},_update(e,t){if(!(e&&0===e.length||0===this._physicalCount)){if(this._assignModels(e),this._updateMetrics(e),t)for(;t.length;){const e=t.pop();this._physicalTop-=this._getPhysicalSizeIncrement(e)}this._positionItems(),this._updateScrollerSize()}},_isClientFull(){return 0!==this._scrollBottom&&this._physicalBottom-1>=this._scrollBottom&&this._physicalTop<=this._scrollPosition},_increasePoolIfNeeded(e){const t=this._clamp(this._physicalCount+e,3,this._virtualCount-this._virtualStart)-this._physicalCount;let i=Math.round(.5*this._physicalCount);if(!(t<0)){if(t>0){const e=window.performance.now();[].push.apply(this._physicalItems,this._createPool(t));for(let e=0;e<t;e++)this._physicalSizes.push(0);this._physicalCount+=t,this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedVirtualIndex)&&this._getPhysicalIndex(this._focusedVirtualIndex)<this._physicalEnd&&(this._physicalStart+=t),this._update(),this._templateCost=(window.performance.now()-e)/t,i=Math.round(.5*this._physicalCount)}this._virtualEnd>=this._virtualCount-1||0===i||(this._isClientFull()?this._physicalSize<this._optPhysicalSize&&this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,this._clamp(Math.round(50/this._templateCost),1,i)),kr):this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,i),br))}},_render(){if(this.isAttached&&this._isVisible)if(0!==this._physicalCount){const e=this._getReusables(!0);this._physicalTop=e.physicalTop,this._virtualStart+=e.indexes.length,this._physicalStart+=e.indexes.length,this._update(e.indexes),this._update(),this._increasePoolIfNeeded(0)}else this._virtualCount>0&&(this.updateViewportBoundaries(),this._increasePoolIfNeeded(3))},_itemsChanged(e){"items"===e.path&&(this._virtualStart=0,this._physicalTop=0,this._virtualCount=this.items?this.items.length:0,this._physicalIndexForKey={},this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._physicalCount=this._physicalCount||0,this._physicalItems=this._physicalItems||[],this._physicalSizes=this._physicalSizes||[],this._physicalStart=0,this._scrollTop>this._scrollOffset&&this._resetScrollPosition(0),this._debounce("_render",this._render,yr))},_iterateItems(e,t){let i,a,n,o;if(2===arguments.length&&t){for(o=0;o<t.length;o++)if(i=t[o],a=this._computeVidx(i),null!=(n=e.call(this,i,a)))return n}else{for(i=this._physicalStart,a=this._virtualStart;i<this._physicalCount;i++,a++)if(null!=(n=e.call(this,i,a)))return n;for(i=0;i<this._physicalStart;i++,a++)if(null!=(n=e.call(this,i,a)))return n}},_computeVidx(e){return e>=this._physicalStart?this._virtualStart+(e-this._physicalStart):this._virtualStart+(this._physicalCount-this._physicalStart)+e},_updateMetrics(e){Cr();let t=0,i=0;const a=this._physicalAverageCount,n=this._physicalAverage;this._iterateItems(((e,a)=>{i+=this._physicalSizes[e],this._physicalSizes[e]=this._physicalItems[e].offsetHeight,t+=this._physicalSizes[e],this._physicalAverageCount+=this._physicalSizes[e]?1:0}),e),this._physicalSize=this._physicalSize+t-i,this._physicalAverageCount!==a&&(this._physicalAverage=Math.round((n*a+t)/this._physicalAverageCount))},_positionItems(){this._adjustScrollPosition();let e=this._physicalTop;this._iterateItems((t=>{this.translate3d(0,`${e}px`,0,this._physicalItems[t]),e+=this._physicalSizes[t]}))},_getPhysicalSizeIncrement(e){return this._physicalSizes[e]},_adjustScrollPosition(){const e=0===this._virtualStart?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(0!==e){this._physicalTop-=e;const t=this._scrollPosition;!Ir&&t>0&&this._resetScrollPosition(t-e)}},_resetScrollPosition(e){this.scrollTarget&&e>=0&&(this._scrollTop=e,this._scrollPosition=this._scrollTop)},_updateScrollerSize(e){this._estScrollHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage,((e=(e=e||0===this._scrollHeight)||this._scrollPosition>=this._estScrollHeight-this._physicalSize)||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._viewportHeight)&&(this.$.items.style.height=`${this._estScrollHeight}px`,this._scrollHeight=this._estScrollHeight)},scrollToIndex(e){if("number"!=typeof e||e<0||e>this.items.length-1)return;if(Cr(),0===this._physicalCount)return;e=this._clamp(e,0,this._virtualCount-1),(!this._isIndexRendered(e)||e>=this._maxVirtualStart)&&(this._virtualStart=e-1),this._assignModels(),this._updateMetrics(),this._physicalTop=this._virtualStart*this._physicalAverage;let t=this._physicalStart,i=this._virtualStart,a=0;const n=this._hiddenContentSize;for(;i<e&&a<=n;)a+=this._getPhysicalSizeIncrement(t),t=(t+1)%this._physicalCount,i+=1;this._updateScrollerSize(!0),this._positionItems(),this._resetScrollPosition(this._physicalTop+this._scrollOffset+a),this._increasePoolIfNeeded(0),this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null},_resetAverage(){this._physicalAverage=0,this._physicalAverageCount=0},_resizeHandler(){this._debounce("_render",(()=>{this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._isVisible?(this.updateViewportBoundaries(),this.toggleScrollListener(!0),this._resetAverage(),this._render()):this.toggleScrollListener(!1)}),yr)},_isIndexRendered(e){return e>=this._virtualStart&&e<=this._virtualEnd},_getPhysicalIndex(e){return(this._physicalStart+(e-this._virtualStart))%this._physicalCount},_clamp:(e,t,i)=>Math.min(i,Math.max(t,e)),_debounce(e,t,i){var a;this._debouncers=this._debouncers||{},this._debouncers[e]=xr.debounce(this._debouncers[e],i,t.bind(this)),a=this._debouncers[e],$r.add(a)}};class zr{constructor({createElements:e,updateElement:t,scrollTarget:i,scrollContainer:a,elementsContainer:n,reorderElements:o}){this.isAttached=!0,this._vidxOffset=0,this.createElements=e,this.updateElement=t,this.scrollTarget=i,this.scrollContainer=a,this.elementsContainer=n||a,this.reorderElements=o,this._maxPages=1.3,this.__placeholderHeight=200,this.__elementHeightQueue=Array(10),this.timeouts={SCROLL_REORDER:500,IGNORE_WHEEL:500},this.__resizeObserver=new ResizeObserver((()=>this._resizeHandler())),"visible"===getComputedStyle(this.scrollTarget).overflow&&(this.scrollTarget.style.overflow="auto"),"static"===getComputedStyle(this.scrollContainer).position&&(this.scrollContainer.style.position="relative"),this.__resizeObserver.observe(this.scrollTarget),this.scrollTarget.addEventListener("scroll",(()=>this._scrollHandler())),this._scrollLineHeight=this._getScrollLineHeight(),this.scrollTarget.addEventListener("wheel",(e=>this.__onWheel(e))),this.reorderElements&&(this.scrollTarget.addEventListener("mousedown",(()=>this.__mouseDown=!0)),this.scrollTarget.addEventListener("mouseup",(()=>{this.__mouseDown=!1,this.__pendingReorder&&this.__reorderElements()})))}get scrollOffset(){return 0}get adjustedFirstVisibleIndex(){return this.firstVisibleIndex+this._vidxOffset}get adjustedLastVisibleIndex(){return this.lastVisibleIndex+this._vidxOffset}scrollToIndex(e){if("number"!=typeof e||isNaN(e)||0===this.size||!this.scrollTarget.offsetHeight)return;e=this._clamp(e,0,this.size-1);const t=this.__getVisibleElements().length;let i=Math.floor(e/this.size*this._virtualCount);this._virtualCount-i<t?(i=this._virtualCount-(this.size-e),this._vidxOffset=this.size-this._virtualCount):i<t?e<1e3?(i=e,this._vidxOffset=0):(i=1e3,this._vidxOffset=e-i):this._vidxOffset=e-i,this.__skipNextVirtualIndexAdjust=!0,super.scrollToIndex(i),this.adjustedFirstVisibleIndex!==e&&this._scrollTop<this._maxScrollTop&&!this.grid&&(this._scrollTop-=this.__getIndexScrollOffset(e)||0),this._scrollHandler()}flush(){0!==this.scrollTarget.offsetHeight&&(this._resizeHandler(),Cr(),this._scrollHandler(),this.__scrollReorderDebouncer&&this.__scrollReorderDebouncer.flush(),this.__debouncerWheelAnimationFrame&&this.__debouncerWheelAnimationFrame.flush())}update(e=0,t=this.size-1){this.__getVisibleElements().forEach((i=>{i.__virtualIndex>=e&&i.__virtualIndex<=t&&this.__updateElement(i,i.__virtualIndex,!0)}))}__updateElement(e,t,i){e.style.paddingTop&&(e.style.paddingTop=""),this.__preventElementUpdates||e.__lastUpdatedIndex===t&&!i||(this.updateElement(e,t),e.__lastUpdatedIndex=t);const a=e.offsetHeight;if(0===a)e.style.paddingTop=`${this.__placeholderHeight}px`;else{this.__elementHeightQueue.push(a),this.__elementHeightQueue.shift();const e=this.__elementHeightQueue.filter((e=>void 0!==e));this.__placeholderHeight=Math.round(e.reduce(((e,t)=>e+t),0)/e.length)}}__getIndexScrollOffset(e){const t=this.__getVisibleElements().find((t=>t.__virtualIndex===e));return t?this.scrollTarget.getBoundingClientRect().top-t.getBoundingClientRect().top:void 0}get size(){return this.__size}set size(e){if(e===this.size)return;let t,i;if(this.__preventElementUpdates=!0,e>0&&(t=this.adjustedFirstVisibleIndex,i=this.__getIndexScrollOffset(t)),this.__size=e,Cr(),this._itemsChanged({path:"items"}),Cr(),e>0){t=Math.min(t,e-1),this.scrollToIndex(t);const a=this.__getIndexScrollOffset(t);void 0!==i&&void 0!==a&&(this._scrollTop+=i-a)}this.elementsContainer.children.length||requestAnimationFrame((()=>this._resizeHandler())),this.__preventElementUpdates=!1,this._resizeHandler(),Cr()}get _scrollTop(){return this.scrollTarget.scrollTop}set _scrollTop(e){this.scrollTarget.scrollTop=e}get items(){return{length:Math.min(this.size,1e5)}}get offsetHeight(){return this.scrollTarget.offsetHeight}get $(){return{items:this.scrollContainer}}updateViewportBoundaries(){const e=window.getComputedStyle(this.scrollTarget);this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(e["padding-top"],10),this._isRTL=Boolean("rtl"===e.direction),this._viewportWidth=this.elementsContainer.offsetWidth,this._viewportHeight=this.scrollTarget.offsetHeight,this._scrollPageHeight=this._viewportHeight-this._scrollLineHeight,this.grid&&this._updateGridMetrics()}setAttribute(){}_createPool(e){const t=this.createElements(e),i=document.createDocumentFragment();return t.forEach((e=>{e.style.position="absolute",i.appendChild(e),this.__resizeObserver.observe(e)})),this.elementsContainer.appendChild(i),t}_assignModels(e){this._iterateItems(((e,t)=>{const i=this._physicalItems[e];i.hidden=t>=this.size,i.hidden?delete i.__lastUpdatedIndex:(i.__virtualIndex=t+(this._vidxOffset||0),this.__updateElement(i,i.__virtualIndex))}),e)}_isClientFull(){return setTimeout((()=>this.__clientFull=!0)),this.__clientFull||super._isClientFull()}translate3d(e,t,i,a){a.style.transform=`translateY(${t})`}toggleScrollListener(){}_scrollHandler(){this._adjustVirtualIndexOffset(this._scrollTop-(this.__previousScrollTop||0));const e=this.scrollTarget.scrollTop-this._scrollPosition;if(super._scrollHandler(),0!==this._physicalCount){const t=e>=0,i=this._getReusables(!t);i.indexes.length&&(this._physicalTop=i.physicalTop,t?(this._virtualStart-=i.indexes.length,this._physicalStart-=i.indexes.length):(this._virtualStart+=i.indexes.length,this._physicalStart+=i.indexes.length),this._resizeHandler())}this.reorderElements&&(this.__scrollReorderDebouncer=xr.debounce(this.__scrollReorderDebouncer,_r.after(this.timeouts.SCROLL_REORDER),(()=>this.__reorderElements()))),this.__previousScrollTop=this._scrollTop}__onWheel(e){if(e.ctrlKey||this._hasScrolledAncestor(e.target,e.deltaX,e.deltaY))return;let t=e.deltaY;if(e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._scrollLineHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._scrollPageHeight),this._deltaYAcc=this._deltaYAcc||0,this._wheelAnimationFrame)return this._deltaYAcc+=t,void e.preventDefault();t+=this._deltaYAcc,this._deltaYAcc=0,this._wheelAnimationFrame=!0,this.__debouncerWheelAnimationFrame=xr.debounce(this.__debouncerWheelAnimationFrame,yr,(()=>this._wheelAnimationFrame=!1));const i=Math.abs(e.deltaX)+Math.abs(t);this._canScroll(this.scrollTarget,e.deltaX,t)?(e.preventDefault(),this.scrollTarget.scrollTop+=t,this.scrollTarget.scrollLeft+=e.deltaX,this._hasResidualMomentum=!0,this._ignoreNewWheel=!0,this._debouncerIgnoreNewWheel=xr.debounce(this._debouncerIgnoreNewWheel,_r.after(this.timeouts.IGNORE_WHEEL),(()=>this._ignoreNewWheel=!1))):this._hasResidualMomentum&&i<=this._previousMomentum||this._ignoreNewWheel?e.preventDefault():i>this._previousMomentum&&(this._hasResidualMomentum=!1),this._previousMomentum=i}_hasScrolledAncestor(e,t,i){return e!==this.scrollTarget&&e!==this.scrollTarget.getRootNode().host&&(!(!this._canScroll(e,t,i)||-1===["auto","scroll"].indexOf(getComputedStyle(e).overflow))||(e!==this&&e.parentElement?this._hasScrolledAncestor(e.parentElement,t,i):void 0))}_canScroll(e,t,i){return i>0&&e.scrollTop<e.scrollHeight-e.offsetHeight||i<0&&e.scrollTop>0||t>0&&e.scrollLeft<e.scrollWidth-e.offsetWidth||t<0&&e.scrollLeft>0}_getScrollLineHeight(){const e=document.createElement("div");e.style.fontSize="initial",e.style.display="none",document.body.appendChild(e);const t=window.getComputedStyle(e).fontSize;return document.body.removeChild(e),t?window.parseInt(t):void 0}__getVisibleElements(){return Array.from(this.elementsContainer.children).filter((e=>!e.hidden))}__reorderElements(){if(this.__mouseDown)return void(this.__pendingReorder=!0);this.__pendingReorder=!1;const e=this._virtualStart+(this._vidxOffset||0),t=this.__getVisibleElements(),i=t.find((e=>e.contains(this.elementsContainer.getRootNode().activeElement)||e.contains(this.scrollTarget.getRootNode().activeElement)))||t[0];if(!i)return;const a=i.__virtualIndex-e,n=t.indexOf(i)-a;if(n>0)for(let e=0;e<n;e++)this.elementsContainer.appendChild(t[e]);else if(n<0)for(let e=t.length+n;e<t.length;e++)this.elementsContainer.insertBefore(t[e],t[0]);if(qs){const{transform:e}=this.scrollTarget.style;this.scrollTarget.style.transform="translateZ(0)",setTimeout((()=>this.scrollTarget.style.transform=e))}}_adjustVirtualIndexOffset(e){if(this._virtualCount>=this.size)this._vidxOffset=0;else if(this.__skipNextVirtualIndexAdjust)this.__skipNextVirtualIndexAdjust=!1;else if(Math.abs(e)>1e4){const e=this._scrollTop/(this.scrollTarget.scrollHeight-this.scrollTarget.offsetHeight),t=e*this.size;this._vidxOffset=Math.round(t-e*this._virtualCount)}else{const e=this._vidxOffset,t=1e3,i=100;0===this._scrollTop?(this._vidxOffset=0,e!==this._vidxOffset&&super.scrollToIndex(0)):this.firstVisibleIndex<t&&this._vidxOffset>0&&(this._vidxOffset-=Math.min(this._vidxOffset,i),super.scrollToIndex(this.firstVisibleIndex+(e-this._vidxOffset)));const a=this.size-this._virtualCount;this._scrollTop>=this._maxScrollTop&&this._maxScrollTop>0?(this._vidxOffset=a,e!==this._vidxOffset&&super.scrollToIndex(this._virtualCount-1)):this.firstVisibleIndex>this._virtualCount-t&&this._vidxOffset<a&&(this._vidxOffset+=Math.min(a-this._vidxOffset,i),super.scrollToIndex(this.firstVisibleIndex-(this._vidxOffset-e)))}}}Object.setPrototypeOf(zr.prototype,Er);class Sr{constructor(e){this.__adapter=new zr(e)}get size(){return this.__adapter.size}set size(e){this.__adapter.size=e}scrollToIndex(e){this.__adapter.scrollToIndex(e)}update(e=0,t=this.size-1){this.__adapter.update(e,t)}flush(){this.__adapter.flush()}get firstVisibleIndex(){return this.__adapter.adjustedFirstVisibleIndex}get lastVisibleIndex(){return this.__adapter.adjustedLastVisibleIndex}}const Tr=class{toString(){return""}};class Lr extends d{static get is(){return"vaadin-combo-box-scroller"}static get template(){return c`
  494. <style>
  495. :host {
  496. display: block;
  497. min-height: 1px;
  498. overflow: auto;
  499. /* Fixes item background from getting on top of scrollbars on Safari */
  500. transform: translate3d(0, 0, 0);
  501. /* Enable momentum scrolling on iOS */
  502. -webkit-overflow-scrolling: touch;
  503. /* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
  504. box-shadow: 0 0 0 white;
  505. }
  506. #selector {
  507. border-width: var(--_vaadin-combo-box-items-container-border-width);
  508. border-style: var(--_vaadin-combo-box-items-container-border-style);
  509. border-color: var(--_vaadin-combo-box-items-container-border-color);
  510. }
  511. </style>
  512. <div id="selector">
  513. <slot></slot>
  514. </div>
  515. `}static get properties(){return{items:{type:Array,observer:"__itemsChanged"},focusedIndex:{type:Number,observer:"__focusedIndexChanged"},loading:{type:Boolean,observer:"__loadingChanged"},opened:{type:Boolean,observer:"__openedChanged"},selectedItem:{type:Object},itemIdPath:{type:String},comboBox:{type:Object},getItemLabel:{type:Object},renderer:{type:Object,observer:"__rendererChanged"},theme:{type:String}}}constructor(){super(),this.__boundOnItemClick=this.__onItemClick.bind(this)}__openedChanged(e){e&&this.requestContentUpdate()}ready(){super.ready(),this.__hostTagName=this.constructor.is.replace("-scroller",""),this.setAttribute("role","listbox"),this.addEventListener("click",(e=>e.stopPropagation())),this.__patchWheelOverScrolling(),this.__virtualizer=new Sr({createElements:this.__createElements.bind(this),updateElement:this.__updateElement.bind(this),elementsContainer:this,scrollTarget:this,scrollContainer:this.$.selector})}requestContentUpdate(){this.__virtualizer&&this.__virtualizer.update()}scrollIntoView(e){if(!(this.opened&&e>=0))return;const t=this._visibleItemsCount();let i=e;e>this.__virtualizer.lastVisibleIndex-1?(this.__virtualizer.scrollToIndex(e),i=e-t+1):e>this.__virtualizer.firstVisibleIndex&&(i=this.__virtualizer.firstVisibleIndex),this.__virtualizer.scrollToIndex(Math.max(0,i));const a=[...this.children].find((e=>!e.hidden&&e.index===this.__virtualizer.lastVisibleIndex));if(!a||e!==a.index)return;const n=a.getBoundingClientRect(),o=this.getBoundingClientRect(),s=n.bottom-o.bottom+this._viewportTotalPaddingBottom;s>0&&(this.scrollTop+=s)}__getAriaRole(e){return void 0!==e&&"option"}__getAriaSelected(e,t){return this.__isItemFocused(e,t).toString()}__isItemFocused(e,t){return e===t}__isItemSelected(e,t,i){return!(e instanceof Tr)&&(i&&void 0!==e&&void 0!==t?this.get(i,e)===this.get(i,t):e===t)}__itemsChanged(e){this.__virtualizer&&e&&(this.__virtualizer.size=e.length,this.__virtualizer.flush(),this.setAttribute("aria-setsize",e.length),this.requestContentUpdate())}__loadingChanged(e){this.__virtualizer&&!e&&setTimeout((()=>this.requestContentUpdate()))}__focusedIndexChanged(e,t){this.__virtualizer&&(e!==t&&this.requestContentUpdate(),e>=0&&!this.loading&&this.scrollIntoView(e))}__rendererChanged(e,t){(e||t)&&this.requestContentUpdate()}__createElements(e){return[...Array(e)].map((()=>{const e=document.createElement(`${this.__hostTagName}-item`);return e.addEventListener("click",this.__boundOnItemClick),e.tabIndex="-1",e.style.width="100%",e}))}__updateElement(e,t){const i=this.items[t],a=this.focusedIndex;e.setProperties({item:i,index:this.__requestItemByIndex(i,t),label:this.getItemLabel(i),selected:this.__isItemSelected(i,this.selectedItem,this.itemIdPath),renderer:this.renderer,focused:this.__isItemFocused(a,t)}),e.id=`${this.__hostTagName}-item-${t}`,e.setAttribute("role",this.__getAriaRole(t)),e.setAttribute("aria-selected",this.__getAriaSelected(a,t)),e.setAttribute("aria-posinset",t+1),this.theme?e.setAttribute("theme",this.theme):e.removeAttribute("theme")}__onItemClick(e){this.dispatchEvent(new CustomEvent("selection-changed",{detail:{item:e.currentTarget.item}}))}__patchWheelOverScrolling(){this.$.selector.addEventListener("wheel",(e=>{const t=0===this.scrollTop,i=this.scrollHeight-this.scrollTop-this.clientHeight<=1;(t&&e.deltaY<0||i&&e.deltaY>0)&&e.preventDefault()}))}get _viewportTotalPaddingBottom(){if(void 0===this._cachedViewportTotalPaddingBottom){const e=window.getComputedStyle(this.$.selector);this._cachedViewportTotalPaddingBottom=[e.paddingBottom,e.borderBottomWidth].map((e=>parseInt(e,10))).reduce(((e,t)=>e+t))}return this._cachedViewportTotalPaddingBottom}__requestItemByIndex(e,t){return e instanceof Tr&&void 0!==t&&this.dispatchEvent(new CustomEvent("index-requested",{detail:{index:t,currentScrollerPos:this._oldScrollerPosition}})),t}_visibleItemsCount(){this.__virtualizer.scrollToIndex(this.__virtualizer.firstVisibleIndex);return this.__virtualizer.size>0?this.__virtualizer.lastVisibleIndex-this.__virtualizer.firstVisibleIndex+1:0}}customElements.define(Lr.is,Lr);class Or extends d{static get is(){return"vaadin-combo-box-dropdown"}static get template(){return c`
  516. <vaadin-combo-box-overlay
  517. id="overlay"
  518. hidden$="[[_isOverlayHidden(_items.*, loading)]]"
  519. loading$="[[loading]]"
  520. opened="{{_overlayOpened}}"
  521. theme$="[[theme]]"
  522. position-target="[[positionTarget]]"
  523. no-vertical-overlap
  524. restore-focus-on-close="[[restoreFocusOnClose]]"
  525. restore-focus-node="[[restoreFocusNode]]"
  526. ></vaadin-combo-box-overlay>
  527. `}static get properties(){return{opened:Boolean,positionTarget:{type:Object},renderer:Function,loading:{type:Boolean,value:!1,reflectToAttribute:!0},theme:String,_selectedItem:{type:Object},_items:{type:Array},_focusedIndex:{type:Number,value:-1},focusedItem:{type:String,computed:"_getFocusedItem(_focusedIndex)"},_itemLabelPath:{type:String,value:"label"},_itemValuePath:{type:String,value:"value"},_scroller:Object,_itemIdPath:String,_overlayOpened:{type:Boolean,observer:"_openedChanged"}}}static get observers(){return["_openedOrItemsChanged(opened, _items, loading)","__updateScroller(_scroller, _items, opened, loading, _selectedItem, _itemIdPath, _focusedIndex, renderer, theme)"]}constructor(){super();const e=Or._uniqueId=1+Or._uniqueId||0;this.scrollerId=`${this.localName}-scroller-${e}`}ready(){super.ready(),this.__hostTagName=this.constructor.is.replace("-dropdown","");const e=this.$.overlay,t=`${this.__hostTagName}-scroller`;e.renderer=e=>{if(!e.firstChild){const i=document.createElement(t);e.appendChild(i)}},e.requestContentUpdate(),this._scroller=e.content.querySelector(t),this._scroller.id=this.scrollerId,this._scroller.getItemLabel=this.getItemLabel.bind(this),this._scroller.comboBox=this.getRootNode().host,this._scroller.addEventListener("selection-changed",(e=>this._forwardScrollerEvent(e))),this._scroller.addEventListener("index-requested",(e=>this._forwardScrollerEvent(e))),e.addEventListener("touchend",(e=>this._fireTouchAction(e))),e.addEventListener("touchmove",(e=>this._fireTouchAction(e))),e.addEventListener("mousedown",(e=>e.preventDefault())),e.addEventListener("vaadin-overlay-outside-click",(e=>{e.preventDefault()}))}disconnectedCallback(){super.disconnectedCallback(),this._overlayOpened=!1}_fireTouchAction(e){this.dispatchEvent(new CustomEvent("vaadin-overlay-touch-action",{detail:{sourceEvent:e}}))}_forwardScrollerEvent(e){this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))}_openedChanged(e,t){e?(this._scroller.style.maxHeight=getComputedStyle(this).getPropertyValue(`--${this.__hostTagName}-overlay-max-height`)||"65vh",this.dispatchEvent(new CustomEvent("vaadin-combo-box-dropdown-opened",{bubbles:!0,composed:!0}))):t&&!this.__emptyItems&&this.dispatchEvent(new CustomEvent("vaadin-combo-box-dropdown-closed",{bubbles:!0,composed:!0}))}_openedOrItemsChanged(e,t,i){const a=t&&t.length;a||(this.__emptyItems=!0),this._overlayOpened=!(!e||!i&&!a),this.__emptyItems=!1}_getFocusedItem(e){if(e>=0)return this._items[e]}indexOfLabel(e){if(this._items&&e)for(let t=0;t<this._items.length;t++)if(this.getItemLabel(this._items[t]).toString().toLowerCase()===e.toString().toLowerCase())return t;return-1}getItemLabel(e,t){t=t||this._itemLabelPath;let i=e&&t?this.get(t,e):void 0;return null==i&&(i=e?e.toString():""),i}_scrollIntoView(e){this._scroller&&this._scroller.scrollIntoView(e)}adjustScrollPosition(){this.opened&&this._items&&this._scrollIntoView(this._focusedIndex)}__updateScroller(e,t,i,a,n,o,s,r,l){e&&e.setProperties({items:i?t:[],opened:i,loading:a,selectedItem:n,itemIdPath:o,focusedIndex:s,renderer:r,theme:l})}_isOverlayHidden(){return!(this.loading||this._items&&this._items.length)}}customElements.define(Or.is,Or);const Mr=e=>class extends e{static get properties(){return{pageSize:{type:Number,value:50,observer:"_pageSizeChanged"},size:{type:Number,observer:"_sizeChanged"},dataProvider:{type:Object,observer:"_dataProviderChanged"},_pendingRequests:{value:()=>({})},__placeHolder:{value:new Tr},__previousDataProviderFilter:{type:String}}}static get observers(){return["_dataProviderFilterChanged(filter)","_warnDataProviderValue(dataProvider, value)","_ensureFirstPage(opened)"]}ready(){super.ready(),this.$.dropdown.addEventListener("index-requested",(e=>{const t=e.detail.index,i=e.detail.currentScrollerPos,a=Math.floor(1.5*this.pageSize);if(!this._shouldSkipIndex(t,a,i)&&void 0!==t){const e=this._getPageForIndex(t);this._shouldLoadPage(e)&&this._loadPage(e)}}))}_dataProviderFilterChanged(e){void 0!==this.__previousDataProviderFilter||""!==e?this.__previousDataProviderFilter!==e&&(this.__previousDataProviderFilter=e,this._pendingRequests={},this.loading=this._shouldFetchData(),this.size=void 0,this.clearCache()):this.__previousDataProviderFilter=e}_shouldFetchData(){return!!this.dataProvider&&(this.opened||this.filter&&this.filter.length)}_ensureFirstPage(e){e&&this._shouldLoadPage(0)&&this._loadPage(0)}_shouldSkipIndex(e,t,i){return 0!==i&&e>=i-t&&e<=i+t}_shouldLoadPage(e){if(!this.filteredItems||this._forceNextRequest)return this._forceNextRequest=!1,!0;const t=this.filteredItems[e*this.pageSize];return void 0!==t?t instanceof Tr:void 0===this.size}_loadPage(e){if(!this._pendingRequests[e]&&this.dataProvider){this.loading=!0;const t={page:e,pageSize:this.pageSize,filter:this.filter},i=(a,n)=>{if(this._pendingRequests[e]===i){const i=this.filteredItems?[...this.filteredItems]:[];i.splice(t.page*t.pageSize,a.length,...a),this.filteredItems=i,this._isValidValue(this.value)&&this._getItemValue(this.selectedItem)!==this.value&&this._selectItemForValue(this.value),this.opened||this.hasAttribute("focused")||this._commitValue(),this.size=n,delete this._pendingRequests[e],0===Object.keys(this._pendingRequests).length&&(this.loading=!1)}};this._pendingRequests[e]||(this._pendingRequests[e]=i,this.dataProvider(t,i))}}_getPageForIndex(e){return Math.floor(e/this.pageSize)}clearCache(){if(!this.dataProvider)return;this._pendingRequests={};const e=[];for(let t=0;t<(this.size||0);t++)e.push(this.__placeHolder);this.filteredItems=e,this._shouldFetchData()?(this._forceNextRequest=!1,this._loadPage(0)):this._forceNextRequest=!0}_sizeChanged(e=0){const t=(this.filteredItems||[]).slice(0,e);for(let i=0;i<e;i++)t[i]=void 0!==t[i]?t[i]:this.__placeHolder;this.filteredItems=t,this._flushPendingRequests(e)}_pageSizeChanged(e,t){if(Math.floor(e)!==e||e<1)throw this.pageSize=t,new Error("`pageSize` value must be an integer > 0");this.clearCache()}_dataProviderChanged(e,t){this._ensureItemsOrDataProvider((()=>{this.dataProvider=t})),this.clearCache()}_ensureItemsOrDataProvider(e){if(void 0!==this.items&&void 0!==this.dataProvider)throw e(),new Error("Using `items` and `dataProvider` together is not supported");this.dataProvider&&!this.filteredItems&&(this.filteredItems=[])}_warnDataProviderValue(e,t){if(e&&""!==t&&(void 0===this.selectedItem||null===this.selectedItem)){const e=this._indexOfValue(t,this.filteredItems);(e<0||!this._getItemLabel(this.filteredItems[e]))&&console.warn("Warning: unable to determine the label for the provided `value`. Nothing to display in the text field. This usually happens when setting an initial `value` before any items are returned from the `dataProvider` callback. Consider setting `selectedItem` instead of `value`")}}_flushPendingRequests(e){if(this._pendingRequests){const t=Math.ceil(e/this.pageSize),i=Object.keys(this._pendingRequests);for(let a=0;a<i.length;a++){const n=parseInt(i[a]);n>=t&&this._pendingRequests[n]([],e)}}}},Pr=l((e=>class extends e{static get properties(){return{disabled:{type:Boolean,value:!1,observer:"_disabledChanged",reflectToAttribute:!0}}}_disabledChanged(e){this._setAriaDisabled(e)}_setAriaDisabled(e){e?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}click(){this.disabled||super.click()}})),Fr=l((e=>class extends e{ready(){super.ready(),this.addEventListener("keydown",(e=>{this._onKeyDown(e)})),this.addEventListener("keyup",(e=>{this._onKeyUp(e)}))}_onKeyDown(e){switch(e.key){case"Enter":this._onEnter(e);break;case"Escape":this._onEscape(e)}}_onKeyUp(e){}_onEnter(e){}_onEscape(e){}}));const Dr=l((e=>class extends e{static get properties(){return{inputElement:{type:Object,readOnly:!0,observer:"_inputElementChanged"},type:{type:String,readOnly:!0},value:{type:String,value:"",observer:"_valueChanged",notify:!0}}}constructor(){super(),this._boundOnInput=this._onInput.bind(this),this._boundOnChange=this._onChange.bind(this)}clear(){this.value=""}_addInputListeners(e){e.addEventListener("input",this._boundOnInput),e.addEventListener("change",this._boundOnChange)}_removeInputListeners(e){e.removeEventListener("input",this._boundOnInput),e.removeEventListener("change",this._boundOnChange)}_forwardInputValue(e){this.inputElement&&(this.inputElement.value=null!=e?e:"")}_inputElementChanged(e,t){e?this._addInputListeners(e):t&&this._removeInputListeners(t)}_onInput(e){this.__userInput=e.isTrusted,this.value=e.target.value,this.__userInput=!1}_onChange(e){}_toggleHasValue(e){this.toggleAttribute("has-value",e)}_valueChanged(e,t){this._toggleHasValue(""!==e&&null!=e),""===e&&void 0===t||this.__userInput||this._forwardInputValue(e)}}));class Br{constructor(e){this.host=e,e.addEventListener("opened-changed",(()=>{e.opened||this.__setVirtualKeyboardEnabled(!1)})),e.addEventListener("blur",(()=>this.__setVirtualKeyboardEnabled(!0))),e.addEventListener("touchstart",(()=>this.__setVirtualKeyboardEnabled(!0)))}__setVirtualKeyboardEnabled(e){this.host.inputElement&&(this.host.inputElement.inputMode=e?"":"none")}}const Nr=e=>class extends(Rs(Fr(Dr(Pr(e))))){static get properties(){return{opened:{type:Boolean,notify:!0,value:!1,reflectToAttribute:!0,observer:"_openedChanged"},autoOpenDisabled:{type:Boolean},readonly:{type:Boolean,value:!1,reflectToAttribute:!0},renderer:Function,items:{type:Array,observer:"_itemsChanged"},allowCustomValue:{type:Boolean,value:!1},filteredItems:{type:Array},_lastCommittedValue:String,loading:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_loadingChanged"},_focusedIndex:{type:Number,observer:"_focusedIndexChanged",value:-1},filter:{type:String,value:"",notify:!0},selectedItem:{type:Object,notify:!0},itemLabelPath:{type:String,value:"label",observer:"_itemLabelPathChanged"},itemValuePath:{type:String,value:"value"},itemIdPath:String,_toggleElement:{type:Object,observer:"_toggleElementChanged"},_closeOnBlurIsPrevented:Boolean,__restoreFocusOnClose:Boolean}}static get observers(){return["_filterChanged(filter, itemValuePath, itemLabelPath)","_filteredItemsChanged(filteredItems)","_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)"]}constructor(){super(),this._boundOnFocusout=this._onFocusout.bind(this),this._boundOverlaySelectedItemChanged=this._overlaySelectedItemChanged.bind(this),this._boundOnClearButtonMouseDown=this.__onClearButtonMouseDown.bind(this),this._boundClose=this.close.bind(this),this._boundOnOpened=this._onOpened.bind(this),this._boundOnClick=this._onClick.bind(this),this._boundOnOverlayTouchAction=this._onOverlayTouchAction.bind(this),this._boundOnTouchend=this._onTouchend.bind(this)}get _inputElementValue(){return this.inputElement?this.inputElement[this._propertyForValue]:void 0}set _inputElementValue(e){this.inputElement&&(this.inputElement[this._propertyForValue]=e)}get _nativeInput(){return this.inputElement}_inputElementChanged(e){super._inputElementChanged(e);const t=this._nativeInput;t&&(t.autocomplete="off",t.autocapitalize="off",t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded",!!this.opened),t.setAttribute("spellcheck","false"),t.setAttribute("autocorrect","off"),this._revertInputValueToValue(),this.clearElement&&this.clearElement.addEventListener("mousedown",this._boundOnClearButtonMouseDown))}ready(){super.ready(),this.addEventListener("focusout",this._boundOnFocusout),this._lastCommittedValue=this.value,this.$.dropdown.addEventListener("selection-changed",this._boundOverlaySelectedItemChanged),this.addEventListener("vaadin-combo-box-dropdown-closed",this._boundClose),this.addEventListener("vaadin-combo-box-dropdown-opened",this._boundOnOpened),this.addEventListener("click",this._boundOnClick),this.$.dropdown.addEventListener("vaadin-overlay-touch-action",this._boundOnOverlayTouchAction),this.addEventListener("touchend",this._boundOnTouchend);const e=()=>{requestAnimationFrame((()=>{this.$.dropdown.$.overlay.bringToFront()}))};var t;this.addEventListener("mousedown",e),this.addEventListener("touchstart",e),t=this,window.Vaadin&&window.Vaadin.templateRendererCallback?window.Vaadin.templateRendererCallback(t):t.querySelector("template")&&console.warn(`WARNING: <template> inside <${t.localName}> is no longer supported. Import @vaadin/polymer-legacy-adapter/template-renderer.js to enable compatibility.`),this.addController(new Br(this))}requestContentUpdate(){this.$.dropdown._scroller&&(this.$.dropdown._scroller.requestContentUpdate(),this._getItemElements().forEach((e=>{e.requestContentUpdate()})))}open(){this.disabled||this.readonly||(this.opened=!0)}close(){this.opened=!1}_focusedIndexChanged(e,t){void 0!==t&&this._updateActiveDescendant(e)}_updateActiveDescendant(e){const t=this._nativeInput;if(!t)return;const i=this._getItemElements().find((t=>t.index===e));i?t.setAttribute("aria-activedescendant",i.id):t.removeAttribute("aria-activedescendant")}_openedChanged(e,t){if(void 0===t)return;e?(this._openedWithFocusRing=this.hasAttribute("focus-ring"),this.hasAttribute("focused")||js||this.focus(),this.__restoreFocusOnClose=!0):(this._onClosed(),this._openedWithFocusRing&&this.hasAttribute("focused")&&this.setAttribute("focus-ring",""));const i=this._nativeInput;i&&(i.setAttribute("aria-expanded",!!e),e?i.setAttribute("aria-controls",this.$.dropdown.scrollerId):i.removeAttribute("aria-controls"))}_onOverlayTouchAction(){this._closeOnBlurIsPrevented=!0,this.inputElement.blur(),this._closeOnBlurIsPrevented=!1}_isClearButton(e){return e.composedPath()[0]===this.clearElement}_handleClearButtonClick(e){e.preventDefault(),this._clear(),this.opened&&this.requestContentUpdate()}_onToggleButtonClick(e){e.preventDefault(),this.opened?this.close():this.open()}_onHostClick(e){this.autoOpenDisabled||(e.preventDefault(),this.open())}_onClick(e){this._closeOnBlurIsPrevented=!0;const t=e.composedPath();this._isClearButton(e)?this._handleClearButtonClick(e):t.indexOf(this._toggleElement)>-1?this._onToggleButtonClick(e):this._onHostClick(e),this._closeOnBlurIsPrevented=!1}_onKeyDown(e){super._onKeyDown(e),"Tab"===e.key?this.__restoreFocusOnClose=!1:"ArrowDown"===e.key?(this._closeOnBlurIsPrevented=!0,this._onArrowDown(),this._closeOnBlurIsPrevented=!1,e.preventDefault()):"ArrowUp"===e.key&&(this._closeOnBlurIsPrevented=!0,this._onArrowUp(),this._closeOnBlurIsPrevented=!1,e.preventDefault())}_getItemLabel(e){return this.$.dropdown.getItemLabel(e)}_getItemValue(e){let t=e&&this.itemValuePath?this.get(this.itemValuePath,e):void 0;return void 0===t&&(t=e?e.toString():""),t}_onArrowDown(){if(this.opened){const e=this._getOverlayItems();e&&(this._focusedIndex=Math.min(e.length-1,this._focusedIndex+1),this._prefillFocusedItemLabel())}else this.open()}_onArrowUp(){if(this.opened){if(this._focusedIndex>-1)this._focusedIndex=Math.max(0,this._focusedIndex-1);else{const e=this._getOverlayItems();e&&(this._focusedIndex=e.length-1)}this._prefillFocusedItemLabel()}else this.open()}_prefillFocusedItemLabel(){this._focusedIndex>-1&&(this._inputElementValue=this._getItemLabel(this.$.dropdown.focusedItem),this._markAllSelectionRange())}_setSelectionRange(e,t){this.hasAttribute("focused")&&this.inputElement.setSelectionRange(e,t)}_markAllSelectionRange(){void 0!==this._inputElementValue&&this._setSelectionRange(0,this._inputElementValue.length)}_clearSelectionRange(){if(void 0!==this._inputElementValue){const e=this._inputElementValue?this._inputElementValue.length:0;this._setSelectionRange(e,e)}}_closeOrCommit(){this.opened||this.loading?this.close():this._commitValue()}_onEnter(e){if(!this.allowCustomValue&&""!==this._inputElementValue&&this._focusedIndex<0)return e.preventDefault(),void e.stopPropagation();this.opened&&(e.preventDefault(),e.stopPropagation()),this._closeOrCommit()}_onEscape(e){this.autoOpenDisabled?this.opened||this.value!==this._inputElementValue&&this._inputElementValue.length>0?(e.stopPropagation(),this._focusedIndex=-1,this.cancel()):this.clearButtonVisible&&!this.opened&&this.value&&(e.stopPropagation(),this._clear()):this.opened?(e.stopPropagation(),this._focusedIndex>-1?(this._focusedIndex=-1,this._revertInputValue()):this.cancel()):this.clearButtonVisible&&this.value&&(e.stopPropagation(),this._clear())}_toggleElementChanged(e){e&&(e.addEventListener("mousedown",(e=>e.preventDefault())),e.addEventListener("click",(()=>{js&&!this.hasAttribute("focused")&&document.activeElement.blur()})))}_clear(){this.selectedItem=null,this.allowCustomValue&&(this.value=""),this._detectAndDispatchChange()}cancel(){this._revertInputValueToValue(),this._lastCommittedValue=this.value,this._closeOrCommit()}_onOpened(){requestAnimationFrame((()=>{this.$.dropdown.adjustScrollPosition(),this._updateActiveDescendant(this._focusedIndex)})),this._lastCommittedValue=this.value}_onClosed(){this.loading&&!this.allowCustomValue||this._commitValue()}_commitValue(){const e=this._getOverlayItems();if(e&&this._focusedIndex>-1){const t=e[this._focusedIndex];this.selectedItem!==t&&(this.selectedItem=t),this._inputElementValue=this._getItemLabel(this.selectedItem)}else if(""===this._inputElementValue||void 0===this._inputElementValue)this.selectedItem=null,this.allowCustomValue&&(this.value="");else{const e=e=>e&&e.toLowerCase&&e.toLowerCase(),t=[...this.filteredItems||[],this.selectedItem].find((t=>e(this._getItemLabel(t))===e(this._inputElementValue)));if(this.allowCustomValue&&!t){const e=this._inputElementValue;this._lastCustomValue=e;const t=new CustomEvent("custom-value-set",{detail:e,composed:!0,cancelable:!0,bubbles:!0});this.dispatchEvent(t),t.defaultPrevented||(this._selectItemForValue(e),this.value=e)}else this.allowCustomValue||this.opened||!t?this._inputElementValue=this.selectedItem?this._getItemLabel(this.selectedItem):this.value||"":this.value=this._getItemValue(t)}this._detectAndDispatchChange(),this._clearSelectionRange(),this.filter=""}get _propertyForValue(){return"value"}_onInput(e){this.opened||this._isClearButton(e)||this.autoOpenDisabled||this.open();const t=this._inputElementValue;this.filter===t?this._filterChanged(this.filter,this.itemValuePath,this.itemLabelPath):this.filter=t}_onChange(e){e.stopPropagation()}_itemLabelPathChanged(e){"string"!=typeof e&&console.error("You should set itemLabelPath to a valid string")}_filterChanged(e,t,i){void 0!==e&&(this.$.dropdown._scrollIntoView(0),this.items?this.filteredItems=this._filterItems(this.items,e):this._filteredItemsChanged(this.filteredItems))}_loadingChanged(e){e&&(this._focusedIndex=-1)}_revertInputValue(){""!==this.filter?this._inputElementValue=this.filter:this._revertInputValueToValue(),this._clearSelectionRange()}_revertInputValueToValue(){this.allowCustomValue&&!this.selectedItem?this._inputElementValue=this.value:this._inputElementValue=this._getItemLabel(this.selectedItem)}_selectedItemChanged(e){if(null==e)this.filteredItems&&(this.allowCustomValue||(this.value=""),this._toggleHasValue(""!==this.value),this._inputElementValue=this.value);else{const t=this._getItemValue(e);if(this.value!==t&&(this.value=t,this.value!==t))return;this._toggleHasValue(!0),this._inputElementValue=this._getItemLabel(e)}this.$.dropdown._selectedItem=e;const t=this._getOverlayItems();this.filteredItems&&t&&(this._focusedIndex=this.filteredItems.indexOf(e))}_valueChanged(e,t){""===e&&void 0===t||(this._isValidValue(e)?(this._getItemValue(this.selectedItem)!==e&&this._selectItemForValue(e),!this.selectedItem&&this.allowCustomValue&&(this._inputElementValue=e),this._toggleHasValue(""!==this.value)):this.selectedItem=null,this.filter="",this._lastCommittedValue=void 0)}_detectAndDispatchChange(){this.value!==this._lastCommittedValue&&(this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),this._lastCommittedValue=this.value)}_itemsChanged(e,t){this._ensureItemsOrDataProvider((()=>{this.items=t})),e?this.filteredItems=e.slice(0):this.__previousItems&&(this.filteredItems=null);const i=this._indexOfValue(this.value,e);this._focusedIndex=i;const a=i>-1&&e[i];a&&(this.selectedItem=a),this.__previousItems=e}_filteredItemsChanged(e,t,i){this._setOverlayItems(e);const a=this._indexOfValue(this.value,e);null===this.selectedItem&&a>=0&&this._selectItemForValue(this.value);const n=this._inputElementValue;void 0===n||n===this._getItemLabel(this.selectedItem)?this._focusedIndex=this.$.dropdown.indexOfLabel(this._getItemLabel(this.selectedItem)):this._focusedIndex=this.$.dropdown.indexOfLabel(this.filter)}_filterItems(e,t){if(!e)return e;const i=e.filter((e=>(t=t?t.toString().toLowerCase():"",this._getItemLabel(e).toString().toLowerCase().indexOf(t)>-1)));return i}_selectItemForValue(e){const t=this._indexOfValue(e,this.filteredItems),i=this.selectedItem;t>=0?this.selectedItem=this.filteredItems[t]:this.dataProvider&&void 0===this.selectedItem?this.selectedItem=void 0:this.selectedItem=null,null===this.selectedItem&&null===i&&this._selectedItemChanged(this.selectedItem)}_getItemElements(){return Array.from(this.$.dropdown._scroller.querySelectorAll("vaadin-combo-box-item"))}_getOverlayItems(){return this.$.dropdown._items}_setOverlayItems(e){this.$.dropdown.set("_items",e)}_indexOfValue(e,t){return t&&this._isValidValue(e)?t.findIndex((t=>!(t instanceof Tr)&&this._getItemValue(t)===e)):-1}_isValidValue(e){return null!=e}_overlaySelectedItemChanged(e){e.stopPropagation(),e.detail.item instanceof Tr||(this.opened?(this._focusedIndex=this.filteredItems.indexOf(e.detail.item),this.close()):this.selectedItem!==e.detail.item&&(this.selectedItem=e.detail.item,this._detectAndDispatchChange()))}__onClearButtonMouseDown(e){e.preventDefault(),this.inputElement.focus()}_onFocusout(e){if(!e.relatedTarget||!this._getItemElements().includes(e.relatedTarget))if(e.relatedTarget!==this.$.dropdown.$.overlay){if(!this.readonly&&!this._closeOnBlurIsPrevented){if(!this.opened&&this.allowCustomValue&&this._inputElementValue===this._lastCustomValue)return void delete this._lastCustomValue;this._closeOrCommit()}}else e.composedPath()[0].focus()}_onTouchend(e){this.clearElement&&e.composedPath()[0]===this.clearElement&&(e.preventDefault(),this._clear())}validate(){return!(this.invalid=!this.checkValidity())}checkValidity(){return super.checkValidity?super.checkValidity():!this.required||!!this.value}};class Vr extends(Mr(Nr(zs(d)))){static get is(){return"vaadin-combo-box-light"}static get template(){return c`
  528. <style>
  529. :host([opened]) {
  530. pointer-events: auto;
  531. }
  532. </style>
  533. <slot></slot>
  534. <vaadin-combo-box-dropdown
  535. id="dropdown"
  536. opened="[[opened]]"
  537. position-target="[[inputElement]]"
  538. restore-focus-on-close="[[__restoreFocusOnClose]]"
  539. restore-focus-node="[[inputElement]]"
  540. renderer="[[renderer]]"
  541. _focused-index="[[_focusedIndex]]"
  542. _item-id-path="[[itemIdPath]]"
  543. _item-label-path="[[itemLabelPath]]"
  544. loading="[[loading]]"
  545. theme="[[_theme]]"
  546. ></vaadin-combo-box-dropdown>
  547. `}static get properties(){return{attrForValue:{type:String,value:"value"}}}get clearElement(){return this.querySelector(".clear-button")}ready(){super.ready(),this._toggleElement=this.querySelector(".toggle-button"),Dn(this,(()=>{this._setInputElement(this.querySelector("vaadin-text-field,.input")),this._revertInputValue()}))}checkValidity(){return this.inputElement.validate?this.inputElement.validate():super.checkValidity()}get _propertyForValue(){return p(this.attrForValue)}get _nativeInput(){const e=this.inputElement;if(e){if(e instanceof HTMLInputElement)return e;const t=e.querySelector("input");if(t)return t;if(e.shadowRoot){const t=e.shadowRoot.querySelector("input");if(t)return t}}}_isClearButton(e){return super._isClearButton(e)||"input"===e.type&&!e.isTrusted||"clear-button"===e.composedPath()[0].getAttribute("part")}_onChange(e){super._onChange(e),this._isClearButton(e)&&this._clear()}}customElements.define(Vr.is,Vr);const qr={};class jr extends t{constructor(e){if(super(e),this.previousValue=qr,e.type!==i.ELEMENT)throw new Error("renderer only supports binding to element")}render(e,t){return v}update(e,[t,i]){var a;const n=this.previousValue===qr;if(!this.hasChanged(i))return v;this.previousValue=Array.isArray(i)?Array.from(i):i;const o=e.element;if(n){const i=null===(a=e.options)||void 0===a?void 0:a.host;this.addRenderer(o,t,{host:i})}else this.runRenderer(o);return v}hasChanged(e){let t=!0;return Array.isArray(e)?Array.isArray(this.previousValue)&&this.previousValue.length===e.length&&e.every(((e,t)=>e===this.previousValue[t]))&&(t=!1):this.previousValue===e&&(t=!1),t}}const Rr=e(class extends jr{addRenderer(e,t,i){e.renderer=(e,a,n)=>{m(t.call(i.host,n.item,n,a),e,i)}}runRenderer(e){e.requestContentUpdate()}});$s("vaadin-combo-box-item",r`
  548. :host {
  549. padding: 0;
  550. }
  551. :host([focused]:not([disabled])) {
  552. background-color: rgba(var(--rgb-primary-text-color, 0, 0, 0), 0.12);
  553. }
  554. :host([selected]:not([disabled])) {
  555. background-color: transparent;
  556. color: var(--mdc-theme-primary);
  557. --mdc-ripple-color: var(--mdc-theme-primary);
  558. --mdc-theme-text-primary-on-background: var(--mdc-theme-primary);
  559. }
  560. :host([selected]:not([disabled])):before {
  561. background-color: var(--mdc-theme-primary);
  562. opacity: 0.12;
  563. content: "";
  564. position: absolute;
  565. top: 0;
  566. left: 0;
  567. width: 100%;
  568. height: 100%;
  569. }
  570. :host([selected][focused]:not([disabled])):before {
  571. opacity: 0.24;
  572. }
  573. :host(:hover:not([disabled])) {
  574. background-color: transparent;
  575. }
  576. [part="content"] {
  577. width: 100%;
  578. }
  579. [part="checkmark"] {
  580. display: none;
  581. }
  582. `),f([A("ha-combo-box")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_()],key:"validationMessage",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({attribute:"error-message"})],key:"errorMessage",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"invalid",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"icon",value:void 0},{kind:"field",decorators:[_()],key:"items",value:void 0},{kind:"field",decorators:[_()],key:"filteredItems",value:void 0},{kind:"field",decorators:[_({attribute:"allow-custom-value",type:Boolean})],key:"allowCustomValue",value:void 0},{kind:"field",decorators:[_({attribute:"item-value-path"})],key:"itemValuePath",value:void 0},{kind:"field",decorators:[_({attribute:"item-label-path"})],key:"itemLabelPath",value:void 0},{kind:"field",decorators:[_({attribute:"item-id-path"})],key:"itemIdPath",value:void 0},{kind:"field",decorators:[_()],key:"renderer",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0,attribute:"opened"})],key:"_opened",value:void 0},{kind:"field",decorators:[y("vaadin-combo-box-light",!0)],key:"_comboBox",value:void 0},{kind:"field",key:"_overlayMutationObserver",value:void 0},{kind:"method",key:"open",value:function(){this.updateComplete.then((()=>{var e;null===(e=this._comboBox)||void 0===e||e.open()}))}},{kind:"method",key:"focus",value:function(){this.updateComplete.then((()=>{var e,t;null===(e=this._comboBox)||void 0===e||null===(t=e.inputElement)||void 0===t||t.focus()}))}},{kind:"method",key:"disconnectedCallback",value:function(){k(b(i.prototype),"disconnectedCallback",this).call(this),this._overlayMutationObserver&&(this._overlayMutationObserver.disconnect(),this._overlayMutationObserver=void 0)}},{kind:"get",key:"selectedItem",value:function(){return this._comboBox.selectedItem}},{kind:"method",key:"setInputValue",value:function(e){this._comboBox.value=e}},{kind:"method",key:"render",value:function(){var e,t,i,a;return x`
  583. <vaadin-combo-box-light
  584. .itemValuePath=${this.itemValuePath}
  585. .itemIdPath=${this.itemIdPath}
  586. .itemLabelPath=${this.itemLabelPath}
  587. .items=${this.items}
  588. .value=${this.value||""}
  589. .filteredItems=${this.filteredItems}
  590. .allowCustomValue=${this.allowCustomValue}
  591. .disabled=${this.disabled}
  592. .required=${this.required}
  593. ${i=this.renderer||this._defaultRowRenderer,Rr(i,a)}
  594. @opened-changed=${this._openedChanged}
  595. @filter-changed=${this._filterChanged}
  596. @value-changed=${this._valueChanged}
  597. attr-for-value="value"
  598. >
  599. <ha-textfield
  600. .label=${this.label}
  601. .placeholder=${this.placeholder}
  602. .disabled=${this.disabled}
  603. .required=${this.required}
  604. .validationMessage=${this.validationMessage}
  605. .errorMessage=${this.errorMessage}
  606. class="input"
  607. autocapitalize="none"
  608. autocomplete="off"
  609. autocorrect="off"
  610. spellcheck="false"
  611. .suffix=${x`<div style="width: 28px;"></div>`}
  612. .icon=${this.icon}
  613. .invalid=${this.invalid}
  614. .helper=${this.helper}
  615. helperPersistent
  616. >
  617. <slot name="icon" slot="leadingIcon"></slot>
  618. </ha-textfield>
  619. ${this.value?x`<ha-svg-icon
  620. aria-label=${null===(e=this.hass)||void 0===e?void 0:e.localize("ui.components.combo-box.clear")}
  621. class="clear-button"
  622. .path=${$}
  623. @click=${this._clearValue}
  624. ></ha-svg-icon>`:""}
  625. <ha-svg-icon
  626. aria-label=${null===(t=this.hass)||void 0===t?void 0:t.localize("ui.components.combo-box.show")}
  627. class="toggle-button"
  628. .path=${this._opened?w:C}
  629. @click=${this._toggleOpen}
  630. ></ha-svg-icon>
  631. </vaadin-combo-box-light>
  632. `}},{kind:"field",key:"_defaultRowRenderer",value(){return e=>x`<mwc-list-item>
  633. ${this.itemLabelPath?e[this.itemLabelPath]:e}
  634. </mwc-list-item>`}},{kind:"method",key:"_clearValue",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:void 0})}},{kind:"method",key:"_toggleOpen",value:function(e){var t,i;this._opened?(null===(t=this._comboBox)||void 0===t||t.close(),e.stopPropagation()):null===(i=this._comboBox)||void 0===i||i.inputElement.focus()}},{kind:"method",key:"_openedChanged",value:function(e){const t=e.detail.value;if(setTimeout((()=>{this._opened=t}),0),o(this,e.type,e.detail),t&&"MutationObserver"in window&&!this._overlayMutationObserver){const e=document.querySelector("vaadin-combo-box-overlay");if(!e)return;this._overlayMutationObserver=new MutationObserver((t=>{t.forEach((t=>{var i;"attributes"===t.type&&"inert"===t.attributeName?(null===(i=this._overlayMutationObserver)||void 0===i||i.disconnect(),this._overlayMutationObserver=void 0,e.inert=!1):"childList"===t.type&&t.removedNodes.forEach((e=>{var t;"VAADIN-COMBO-BOX-OVERLAY"===e.nodeName&&(null===(t=this._overlayMutationObserver)||void 0===t||t.disconnect(),this._overlayMutationObserver=void 0)}))}))})),this._overlayMutationObserver.observe(e,{attributes:!0}),this._overlayMutationObserver.observe(document.body,{childList:!0})}}},{kind:"method",key:"_filterChanged",value:function(e){o(this,e.type,e.detail,{composed:!1})}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t!==this.value&&o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  635. :host {
  636. display: block;
  637. width: 100%;
  638. }
  639. vaadin-combo-box-light {
  640. position: relative;
  641. }
  642. ha-textfield {
  643. width: 100%;
  644. }
  645. ha-textfield > ha-icon-button {
  646. --mdc-icon-button-size: 24px;
  647. padding: 2px;
  648. color: var(--secondary-text-color);
  649. }
  650. ha-svg-icon {
  651. color: var(--input-dropdown-icon-color);
  652. position: absolute;
  653. cursor: pointer;
  654. }
  655. .toggle-button {
  656. right: 12px;
  657. top: -10px;
  658. inset-inline-start: initial;
  659. inset-inline-end: 12px;
  660. direction: var(--direction);
  661. }
  662. :host([opened]) .toggle-button {
  663. color: var(--primary-color);
  664. }
  665. .clear-button {
  666. --mdc-icon-size: 20px;
  667. top: -7px;
  668. right: 36px;
  669. inset-inline-start: initial;
  670. inset-inline-end: 36px;
  671. direction: var(--direction);
  672. }
  673. `}}]}}),g);const Ur=["unavailable","unknown"],Hr=e=>gs(e.entity_id),Gr=r`
  674. ha-state-icon[data-domain="alert"][data-state="on"],
  675. ha-state-icon[data-domain="automation"][data-state="on"],
  676. ha-state-icon[data-domain="binary_sensor"][data-state="on"],
  677. ha-state-icon[data-domain="calendar"][data-state="on"],
  678. ha-state-icon[data-domain="camera"][data-state="streaming"],
  679. ha-state-icon[data-domain="cover"][data-state="open"],
  680. ha-state-icon[data-domain="device_tracker"][data-state="home"],
  681. ha-state-icon[data-domain="fan"][data-state="on"],
  682. ha-state-icon[data-domain="humidifier"][data-state="on"],
  683. ha-state-icon[data-domain="light"][data-state="on"],
  684. ha-state-icon[data-domain="input_boolean"][data-state="on"],
  685. ha-state-icon[data-domain="lock"][data-state="unlocked"],
  686. ha-state-icon[data-domain="media_player"][data-state="on"],
  687. ha-state-icon[data-domain="media_player"][data-state="paused"],
  688. ha-state-icon[data-domain="media_player"][data-state="playing"],
  689. ha-state-icon[data-domain="remote"][data-state="on"],
  690. ha-state-icon[data-domain="script"][data-state="on"],
  691. ha-state-icon[data-domain="sun"][data-state="above_horizon"],
  692. ha-state-icon[data-domain="switch"][data-state="on"],
  693. ha-state-icon[data-domain="timer"][data-state="active"],
  694. ha-state-icon[data-domain="vacuum"][data-state="cleaning"],
  695. ha-state-icon[data-domain="group"][data-state="on"],
  696. ha-state-icon[data-domain="group"][data-state="home"],
  697. ha-state-icon[data-domain="group"][data-state="open"],
  698. ha-state-icon[data-domain="group"][data-state="locked"],
  699. ha-state-icon[data-domain="group"][data-state="problem"] {
  700. color: var(--paper-item-icon-active-color, #fdd835);
  701. }
  702. ha-state-icon[data-domain="climate"][data-state="cooling"] {
  703. color: var(--cool-color, var(--state-climate-cool-color));
  704. }
  705. ha-state-icon[data-domain="climate"][data-state="heating"] {
  706. color: var(--heat-color, var(--state-climate-heat-color));
  707. }
  708. ha-state-icon[data-domain="climate"][data-state="drying"] {
  709. color: var(--dry-color, var(--state-climate-dry-color));
  710. }
  711. ha-state-icon[data-domain="alarm_control_panel"] {
  712. color: var(--alarm-color-armed, var(--label-badge-red));
  713. }
  714. ha-state-icon[data-domain="alarm_control_panel"][data-state="disarmed"] {
  715. color: var(--alarm-color-disarmed, var(--label-badge-green));
  716. }
  717. ha-state-icon[data-domain="alarm_control_panel"][data-state="pending"],
  718. ha-state-icon[data-domain="alarm_control_panel"][data-state="arming"] {
  719. color: var(--alarm-color-pending, var(--label-badge-yellow));
  720. animation: pulse 1s infinite;
  721. }
  722. ha-state-icon[data-domain="alarm_control_panel"][data-state="triggered"] {
  723. color: var(--alarm-color-triggered, var(--label-badge-red));
  724. animation: pulse 1s infinite;
  725. }
  726. @keyframes pulse {
  727. 0% {
  728. opacity: 1;
  729. }
  730. 50% {
  731. opacity: 0;
  732. }
  733. 100% {
  734. opacity: 1;
  735. }
  736. }
  737. ha-state-icon[data-domain="plant"][data-state="problem"] {
  738. color: var(--state-icon-error-color);
  739. }
  740. /* Color the icon if unavailable */
  741. ha-state-icon[data-state="unavailable"] {
  742. color: var(--state-unavailable-color);
  743. }
  744. `,Wr=(e,t)=>e.callWS({type:"auth/sign_path",path:t}),Kr=I,Yr={alert:E,air_quality:z,automation:S,calendar:T,camera:L,climate:O,configurator:M,conversation:P,counter:F,demo:D,fan:B,google_assistant:N,group:V,homeassistant:D,homekit:q,image_processing:j,input_button:R,input_datetime:U,input_number:H,input_select:G,input_text:W,light:K,mailbox:Y,notify:Z,number:H,persistent_notification:Q,person:J,plant:X,proximity:ee,remote:te,scene:ie,script:ae,select:G,sensor:ne,siren:oe,simple_alarm:Q,sun:se,timer:re,updater:le,vacuum:de,water_heater:ce,weather:ue,zone:he},Zr={apparent_power:pe,aqi:z,carbon_dioxide:ve,carbon_monoxide:me,current:fe,date:T,energy:ge,frequency:_e,gas:ye,humidity:ke,illuminance:be,monetary:xe,nitrogen_dioxide:$e,nitrogen_monoxide:$e,nitrous_oxide:$e,ozone:$e,pm1:$e,pm10:$e,pm25:$e,power:pe,power_factor:we,pressure:Ce,reactive_power:pe,signal_strength:Ae,sulphur_dioxide:$e,temperature:ce,timestamp:Ie,volatile_organic_compounds:$e,voltage:_e},Qr=(e,t)=>0!=(e.supported_features&t),Jr=e=>Qr(e,4)&&"number"==typeof e.in_progress,Xr=e=>(e=>Jr(e.attributes))(e)||!!e.attributes.in_progress,el={"clear-night":ze,cloudy:ue,exceptional:Se,fog:Te,hail:Le,lightning:Oe,"lightning-rainy":Me,partlycloudy:Pe,pouring:Fe,rainy:De,snowy:Be,"snowy-rainy":Ne,sunny:Ve,windy:qe,"windy-variant":je};r`
  745. .rain {
  746. fill: var(--weather-icon-rain-color, #30b3ff);
  747. }
  748. .sun {
  749. fill: var(--weather-icon-sun-color, #fdd93c);
  750. }
  751. .moon {
  752. fill: var(--weather-icon-moon-color, #fcf497);
  753. }
  754. .cloud-back {
  755. fill: var(--weather-icon-cloud-back-color, #d4d4d4);
  756. }
  757. .cloud-front {
  758. fill: var(--weather-icon-cloud-front-color, #f9f9f9);
  759. }
  760. `;const tl={10:oi,20:si,30:ri,40:li,50:di,60:ci,70:ui,80:hi,90:pi,100:Dt},il={10:vi,20:mi,30:fi,40:gi,50:_i,60:yi,70:ki,80:bi,90:xi,100:Bt},al=(e,t)=>{const i=Number(e);if(isNaN(i))return"off"===e?Dt:"on"===e?ti:ii;const a=10*Math.round(i/10);return t&&i>=10?il[a]:t?ai:i<=5?ni:tl[a]},nl=e=>{const t=null==e?void 0:e.attributes.device_class;if(t&&t in Zr)return Zr[t];if("battery"===t)return e?((e,t)=>{const i=e.state,a=t&&"on"===t.state;return al(i,a)})(e):Dt;const i=null==e?void 0:e.attributes.unit_of_measurement;return"°C"===i||"°F"===i?ce:void 0},ol=(e,t,i)=>{const a=void 0!==i?i:null==t?void 0:t.state;switch(e){case"alarm_control_panel":return(e=>{switch(e){case"armed_away":return Qe;case"armed_vacation":return Ze;case"armed_home":return Ye;case"armed_night":return Ke;case"armed_custom_bypass":return We;case"pending":return Ge;case"triggered":return He;case"disarmed":return Ue;default:return Re}})(a);case"binary_sensor":return((e,t)=>{const i="off"===e;switch(null==t?void 0:t.attributes.device_class){case"battery":return i?Dt:Nt;case"battery_charging":return i?Dt:Bt;case"carbon_monoxide":return i?Pt:Ft;case"cold":return i?ce:Mt;case"connectivity":return i?Lt:Ot;case"door":return i?St:Tt;case"garage_door":return i?Et:zt;case"power":case"plug":return i?ht:pt;case"gas":case"problem":case"safety":case"tamper":return i?At:It;case"smoke":return i?wt:Ct;case"heat":return i?ce:$t;case"light":return i?be:xt;case"lock":return i?kt:bt;case"moisture":return i?_t:yt;case"motion":return i?ft:gt;case"occupancy":case"presence":return i?ct:ut;case"opening":return i?vt:mt;case"running":return i?lt:dt;case"sound":return i?st:rt;case"update":return i?nt:ot;case"vibration":return i?it:at;case"window":return i?et:tt;default:return i?Je:Xe}})(a,t);case"button":switch(null==t?void 0:t.attributes.device_class){case"restart":return Zi;case"update":return ot;default:return R}case"cover":return((e,t)=>{const i="closed"!==e;switch(null==t?void 0:t.attributes.device_class){case"garage":switch(e){case"opening":return qt;case"closing":return Vt;case"closed":return Et;default:return zt}case"gate":switch(e){case"opening":case"closing":return ei;case"closed":return Xt;default:return Jt}case"door":return i?Tt:St;case"damper":return i?Zt:Qt;case"shutter":switch(e){case"opening":return qt;case"closing":return Vt;case"closed":return Yt;default:return Kt}case"curtain":switch(e){case"opening":return Wt;case"closing":return Gt;case"closed":return Ht;default:return Ut}case"blind":case"shade":switch(e){case"opening":return qt;case"closing":return Vt;case"closed":return Rt;default:return jt}case"window":switch(e){case"opening":return qt;case"closing":return Vt;case"closed":return et;default:return tt}}switch(e){case"opening":return qt;case"closing":return Vt;case"closed":return et;default:return tt}})(a,t);case"device_tracker":return"router"===(null==t?void 0:t.attributes.source_type)?"home"===a?Hi:Gi:["bluetooth","bluetooth_le"].includes(null==t?void 0:t.attributes.source_type)?"home"===a?Wi:Ki:"not_home"===a?Yi:J;case"humidifier":return i&&"off"===i?Ri:Ui;case"input_boolean":return"on"===a?qi:ji;case"input_datetime":if(null==t||!t.attributes.has_date)return Ie;if(!t.attributes.has_time)return T;break;case"lock":switch(a){case"unlocked":return bt;case"jammed":return Vi;case"locking":case"unlocking":return Ni;default:return kt}case"media_player":switch(null==t?void 0:t.attributes.device_class){case"speaker":switch(a){case"playing":return Bi;case"paused":return Di;case"off":return Fi;default:return Pi}case"tv":switch(a){case"playing":return Mi;case"paused":return Oi;case"off":return Li;default:return Ti}default:switch(a){case"playing":case"paused":return Si;case"off":return zi;default:return Ei}}case"switch":switch(null==t?void 0:t.attributes.device_class){case"outlet":return"on"===a?pt:ht;case"switch":return"on"===a?Ai:Ii;default:return Ai}case"sensor":{const e=nl(t);if(e)return e;break}case"sun":return"above_horizon"===(null==t?void 0:t.state)?Yr[e]:ze;case"switch_as_x":return Ci;case"threshold":return wi;case"update":return"on"===a?Xr(t)?$i:ot:nt;case"weather":return((e,t)=>e?t&&"partlycloudy"===e?Ee:el[e]:void 0)(null==t?void 0:t.state)}if(e in Yr)return Yr[e]},sl=e=>e?((e,t,i)=>ol(e,t,i)||(console.warn(`Unable to find icon for domain ${e}`),Kr))(gs(e.entity_id),e):Kr;f([A("ha-state-icon")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"state",value:void 0},{kind:"field",decorators:[_()],key:"icon",value:void 0},{kind:"method",key:"render",value:function(){var e,t;return this.icon||null!==(e=this.state)&&void 0!==e&&e.attributes.icon?x`<ha-icon
  761. .icon=${this.icon||(null===(t=this.state)||void 0===t?void 0:t.attributes.icon)}
  762. ></ha-icon>`:x`<ha-svg-icon .path=${sl(this.state)}></ha-svg-icon>`}}]}}),g);let rl=f(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"stateObj",value:void 0},{kind:"field",decorators:[_()],key:"overrideIcon",value:void 0},{kind:"field",decorators:[_()],key:"overrideImage",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"stateColor",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0,attribute:"icon"})],key:"_showIcon",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_iconStyle",value:()=>({})},{kind:"method",key:"render",value:function(){const e=this.stateObj;if(!e&&!this.overrideIcon&&!this.overrideImage)return x`<div class="missing">
  763. <ha-svg-icon .path=${E}></ha-svg-icon>
  764. </div>`;if(!this._showIcon)return x``;const t=e?Hr(e):void 0;return x`<ha-state-icon
  765. style=${Ji(this._iconStyle)}
  766. data-domain=${Xi(this.stateColor||"light"===t&&!1!==this.stateColor?t:void 0)}
  767. data-state=${e?(e=>{if(Ur.includes(e.state))return e.state;const t=e.entity_id.split(".")[0];let i=e.state;return"climate"===t&&(i=e.attributes.hvac_action),i})(e):""}
  768. .icon=${this.overrideIcon}
  769. .state=${e}
  770. ></ha-state-icon>`}},{kind:"method",key:"willUpdate",value:function(e){if(k(b(i.prototype),"willUpdate",this).call(this,e),!e.has("stateObj")&&!e.has("overrideImage")&&!e.has("overrideIcon"))return;const t=this.stateObj,a={},n={backgroundImage:""};if(this._showIcon=!0,t&&void 0===this.overrideImage)if(!t.attributes.entity_picture_local&&!t.attributes.entity_picture||this.overrideIcon){if("on"===t.state&&(!1!==this.stateColor&&t.attributes.rgb_color&&(a.color=`rgb(${t.attributes.rgb_color.join(",")})`),t.attributes.brightness&&!1!==this.stateColor)){const e=t.attributes.brightness;if("number"!=typeof e){const i=`Type error: state-badge expected number, but type of ${t.entity_id}.attributes.brightness is ${typeof e} (${e})`;console.warn(i)}a.filter=`brightness(${(e+245)/5}%)`}}else{let e=t.attributes.entity_picture_local||t.attributes.entity_picture;this.hass&&(e=this.hass.hassUrl(e)),"camera"===gs(t.entity_id)&&(e=`${e}&width=${80}&height=${80}`),n.backgroundImage=`url(${e})`,this._showIcon=!1}else if(this.overrideImage){let e=this.overrideImage;this.hass&&(e=this.hass.hassUrl(e)),n.backgroundImage=`url(${e})`,this._showIcon=!1}this._iconStyle=a,Object.assign(this.style,n)}},{kind:"get",static:!0,key:"styles",value:function(){return[Gr,r`
  771. :host {
  772. position: relative;
  773. display: inline-block;
  774. width: 40px;
  775. color: var(--paper-item-icon-color, #44739e);
  776. border-radius: 50%;
  777. height: 40px;
  778. text-align: center;
  779. background-size: cover;
  780. line-height: 40px;
  781. vertical-align: middle;
  782. box-sizing: border-box;
  783. }
  784. :host(:focus) {
  785. outline: none;
  786. }
  787. :host(:not([icon]):focus) {
  788. border: 2px solid var(--divider-color);
  789. }
  790. :host([icon]:focus) {
  791. background: var(--divider-color);
  792. }
  793. ha-state-icon {
  794. transition: color 0.3s ease-in-out, filter 0.3s ease-in-out;
  795. }
  796. .missing {
  797. color: #fce588;
  798. }
  799. `]}}]}}),g);customElements.define("state-badge",rl);const ll=e=>x`<mwc-list-item graphic="avatar" .twoline=${!!e.entity_id}>
  800. ${e.state?x`<state-badge slot="graphic" .stateObj=${e}></state-badge>`:""}
  801. <span>${e.friendly_name}</span>
  802. <span slot="secondary">${e.entity_id}</span>
  803. </mwc-list-item>`;f([A("ha-entity-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autofocus",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[_({type:Boolean,attribute:"allow-custom-entity"})],key:"allowCustomEntity",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-unit-of-measurement"})],key:"includeUnitOfMeasurement",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-entities"})],key:"includeEntities",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-entities"})],key:"excludeEntities",value:void 0},{kind:"field",decorators:[_()],key:"entityFilter",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"hideClearIcon",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_opened",value:()=>!1},{kind:"field",decorators:[y("ha-combo-box",!0)],key:"comboBox",value:void 0},{kind:"method",key:"open",value:function(){this.updateComplete.then((()=>{var e;null===(e=this.comboBox)||void 0===e||e.open()}))}},{kind:"method",key:"focus",value:function(){this.updateComplete.then((()=>{var e;null===(e=this.comboBox)||void 0===e||e.focus()}))}},{kind:"field",key:"_initedStates",value:()=>!1},{kind:"field",key:"_states",value:()=>[]},{kind:"field",key:"_getStates",value(){return n(((e,t,i,a,n,o,s,r,l)=>{let d=[];if(!t)return[];let c=Object.keys(t.states);return c.length?r?(c=c.filter((e=>this.includeEntities.includes(e))),c.map((e=>({...t.states[e],friendly_name:bo(t.states[e])||e}))).sort(((e,t)=>ys(e.friendly_name,t.friendly_name)))):(l&&(c=c.filter((e=>!l.includes(e)))),i&&(c=c.filter((e=>i.includes(gs(e))))),a&&(c=c.filter((e=>!a.includes(gs(e))))),d=c.map((e=>({...t.states[e],friendly_name:bo(t.states[e])||e}))).sort(((e,t)=>ys(e.friendly_name,t.friendly_name))),o&&(d=d.filter((e=>e.entity_id===this.value||e.attributes.device_class&&o.includes(e.attributes.device_class)))),s&&(d=d.filter((e=>e.entity_id===this.value||e.attributes.unit_of_measurement&&s.includes(e.attributes.unit_of_measurement)))),n&&(d=d.filter((e=>e.entity_id===this.value||n(e)))),d.length?d:[{entity_id:"",state:"",last_changed:"",last_updated:"",context:{id:"",user_id:null,parent_id:null},friendly_name:this.hass.localize("ui.components.entity.entity-picker.no_match"),attributes:{friendly_name:this.hass.localize("ui.components.entity.entity-picker.no_match"),icon:"mdi:magnify"}}]):[{entity_id:"",state:"",last_changed:"",last_updated:"",context:{id:"",user_id:null,parent_id:null},friendly_name:this.hass.localize("ui.components.entity.entity-picker.no_entities"),attributes:{friendly_name:this.hass.localize("ui.components.entity.entity-picker.no_entities"),icon:"mdi:magnify"}}]}))}},{kind:"method",key:"shouldUpdate",value:function(e){return!!(e.has("value")||e.has("label")||e.has("disabled"))||!(!e.has("_opened")&&this._opened)}},{kind:"method",key:"willUpdate",value:function(e){(!this._initedStates||e.has("_opened")&&this._opened)&&(this._states=this._getStates(this._opened,this.hass,this.includeDomains,this.excludeDomains,this.entityFilter,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.includeEntities,this.excludeEntities),this._initedStates&&(this.comboBox.filteredItems=this._states),this._initedStates=!0)}},{kind:"method",key:"render",value:function(){return x`
  804. <ha-combo-box
  805. item-value-path="entity_id"
  806. item-label-path="friendly_name"
  807. .hass=${this.hass}
  808. .value=${this._value}
  809. .label=${void 0===this.label?this.hass.localize("ui.components.entity.entity-picker.entity"):this.label}
  810. .helper=${this.helper}
  811. .allowCustomValue=${this.allowCustomEntity}
  812. .filteredItems=${this._states}
  813. .renderer=${ll}
  814. .required=${this.required}
  815. @opened-changed=${this._openedChanged}
  816. @value-changed=${this._valueChanged}
  817. @filter-changed=${this._filterChanged}
  818. >
  819. </ha-combo-box>
  820. `}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t!==this._value&&this._setValue(t)}},{kind:"method",key:"_filterChanged",value:function(e){const t=e.detail.value.toLowerCase();this.comboBox.filteredItems=this._states.filter((e=>e.entity_id.toLowerCase().includes(t)||bo(e).toLowerCase().includes(t)))}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{o(this,"value-changed",{value:e}),o(this,"change")}),0)}}]}}),g);const dl=["scene"];f([A("ha-automation-action-activate_scene")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{service:"scene.turn_on",target:{entity_id:""},metadata:{}}}},{kind:"method",key:"render",value:function(){let e;var t;"scene"in this.action?e=this.action.scene:e=null===(t=this.action.target)||void 0===t?void 0:t.entity_id;return x`
  821. <ha-entity-picker
  822. .hass=${this.hass}
  823. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.activate_scene.scene")}
  824. .value=${e}
  825. @value-changed=${this._entityPicked}
  826. .includeDomains=${dl}
  827. allow-custom-entity
  828. ></ha-entity-picker>
  829. `}},{kind:"method",key:"_entityPicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{service:"scene.turn_on",target:{entity_id:e.detail.value},metadata:{}}})}}]}}),g),f([A("ha-automation-action-choose")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{choose:[{conditions:[],sequence:[]}],default:[]}}},{kind:"method",key:"render",value:function(){const e=this.action;return x`
  830. ${(e.choose?ko(e.choose):[]).map(((e,t)=>x`<ha-card>
  831. <ha-icon-button
  832. .idx=${t}
  833. @click=${this._removeOption}
  834. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.remove_option")}
  835. .path=${ea}
  836. ></ha-icon-button>
  837. <div class="card-content">
  838. <h2>
  839. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.option","number",t+1)}:
  840. </h2>
  841. <h3>
  842. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.conditions")}:
  843. </h3>
  844. <ha-automation-condition
  845. .conditions=${e.conditions}
  846. .hass=${this.hass}
  847. .idx=${t}
  848. @value-changed=${this._conditionChanged}
  849. ></ha-automation-condition>
  850. <h3>
  851. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.sequence")}:
  852. </h3>
  853. <ha-form
  854. .hass=${this.hass}
  855. .schema=${[{name:"sequence",selector:{action:{}}}]}
  856. .data=${e}
  857. .idx=${t}
  858. @value-changed=${this._actionChanged}
  859. ></ha-form>
  860. </div>
  861. </ha-card>`))}
  862. <mwc-button
  863. outlined
  864. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.add_option")}
  865. @click=${this._addOption}
  866. >
  867. <ha-svg-icon .path=${ta} slot="icon"></ha-svg-icon>
  868. </mwc-button>
  869. <h2>
  870. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.default")}:
  871. </h2>
  872. <ha-automation-action
  873. .actions=${e.default||[]}
  874. @value-changed=${this._defaultChanged}
  875. .hass=${this.hass}
  876. ></ha-automation-action>
  877. `}},{kind:"method",key:"_conditionChanged",value:function(e){e.stopPropagation();const t=e.detail.value,i=e.target.idx,a=this.action.choose?[...ko(this.action.choose)]:[];a[i].conditions=t,o(this,"value-changed",{value:{...this.action,choose:a}})}},{kind:"method",key:"_actionChanged",value:function(e){e.stopPropagation();const t=e.detail.value.sequence,i=e.target.idx,a=this.action.choose?[...ko(this.action.choose)]:[];a[i].sequence=t,o(this,"value-changed",{value:{...this.action,choose:a}})}},{kind:"method",key:"_addOption",value:function(){const e=this.action.choose?[...ko(this.action.choose)]:[];e.push({conditions:[],sequence:[]}),o(this,"value-changed",{value:{...this.action,choose:e}})}},{kind:"method",key:"_removeOption",value:function(e){const t=e.currentTarget.idx,i=this.action.choose?[...ko(this.action.choose)]:[];i.splice(t,1),o(this,"value-changed",{value:{...this.action,choose:i}})}},{kind:"method",key:"_defaultChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{...this.action,default:t}})}},{kind:"get",static:!0,key:"styles",value:function(){return[ia,r`
  878. ha-card {
  879. margin: 16px 0;
  880. }
  881. .add-card mwc-button {
  882. display: block;
  883. text-align: center;
  884. }
  885. ha-icon-button {
  886. position: absolute;
  887. right: 0;
  888. padding: 4px;
  889. }
  890. ha-form::part(root) {
  891. overflow: visible;
  892. }
  893. ha-svg-icon {
  894. height: 20px;
  895. }
  896. `]}}]}}),g);const cl={device:aa,and:na,or:oa,not:sa,state:ra,numeric_state:la,sun:Ve,template:da,time:ca,trigger:ua,zone:he};function ul(e){return null==e}var hl=function(e,t){var i,a="";for(i=0;i<t;i+=1)a+=e;return a},pl=function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},vl={isNothing:ul,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:ul(e)?[]:[e]},repeat:hl,isNegativeZero:pl,extend:function(e,t){var i,a,n,o;if(t)for(i=0,a=(o=Object.keys(t)).length;i<a;i+=1)e[n=o[i]]=t[n];return e}};function ml(e,t){var i="",a=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(i+="\n\n"+e.mark.snippet),a+" "+i):a}function fl(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=ml(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}fl.prototype=Object.create(Error.prototype),fl.prototype.constructor=fl,fl.prototype.toString=function(e){return this.name+": "+ml(this,e)};var gl=fl;function _l(e,t,i,a,n){var o="",s="",r=Math.floor(n/2)-1;return a-t>r&&(t=a-r+(o=" ... ").length),i-a>r&&(i=a+r-(s=" ...").length),{str:o+e.slice(t,i).replace(/\t/g,"→")+s,pos:a-t+o.length}}function yl(e,t){return vl.repeat(" ",t-e.length)+e}var kl=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,a=/\r?\n|\r|\0/g,n=[0],o=[],s=-1;i=a.exec(e.buffer);)o.push(i.index),n.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=n.length-2);s<0&&(s=n.length-1);var r,l,d="",c=Math.min(e.line+t.linesAfter,o.length).toString().length,u=t.maxLength-(t.indent+c+3);for(r=1;r<=t.linesBefore&&!(s-r<0);r++)l=_l(e.buffer,n[s-r],o[s-r],e.position-(n[s]-n[s-r]),u),d=vl.repeat(" ",t.indent)+yl((e.line-r+1).toString(),c)+" | "+l.str+"\n"+d;for(l=_l(e.buffer,n[s],o[s],e.position,u),d+=vl.repeat(" ",t.indent)+yl((e.line+1).toString(),c)+" | "+l.str+"\n",d+=vl.repeat("-",t.indent+c+3+l.pos)+"^\n",r=1;r<=t.linesAfter&&!(s+r>=o.length);r++)l=_l(e.buffer,n[s+r],o[s+r],e.position-(n[s]-n[s+r]),u),d+=vl.repeat(" ",t.indent)+yl((e.line+r+1).toString(),c)+" | "+l.str+"\n";return d.replace(/\n$/,"")},bl=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xl=["scalar","sequence","mapping"];var $l=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===bl.indexOf(t))throw new gl('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(i){e[i].forEach((function(e){t[String(e)]=i}))})),t}(t.styleAliases||null),-1===xl.indexOf(this.kind))throw new gl('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function wl(e,t){var i=[];return e[t].forEach((function(e){var t=i.length;i.forEach((function(i,a){i.tag===e.tag&&i.kind===e.kind&&i.multi===e.multi&&(t=a)})),i[t]=e})),i}function Cl(e){return this.extend(e)}Cl.prototype.extend=function(e){var t=[],i=[];if(e instanceof $l)i.push(e);else if(Array.isArray(e))i=i.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new gl("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(i=i.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof $l))throw new gl("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new gl("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new gl("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(e){if(!(e instanceof $l))throw new gl("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var a=Object.create(Cl.prototype);return a.implicit=(this.implicit||[]).concat(t),a.explicit=(this.explicit||[]).concat(i),a.compiledImplicit=wl(a,"implicit"),a.compiledExplicit=wl(a,"explicit"),a.compiledTypeMap=function(){var e,t,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(e){e.multi?(i.multi[e.kind].push(e),i.multi.fallback.push(e)):i[e.kind][e.tag]=i.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(a);return i}(a.compiledImplicit,a.compiledExplicit),a};var Al=new Cl({explicit:[new $l("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),new $l("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),new $l("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})]});var Il=new $l("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});var El=new $l("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function zl(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Sl(e){return 48<=e&&e<=55}function Tl(e){return 48<=e&&e<=57}var Ll=new $l("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i=e.length,a=0,n=!1;if(!i)return!1;if("-"!==(t=e[a])&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===i)return!0;if("b"===(t=e[++a])){for(a++;a<i;a++)if("_"!==(t=e[a])){if("0"!==t&&"1"!==t)return!1;n=!0}return n&&"_"!==t}if("x"===t){for(a++;a<i;a++)if("_"!==(t=e[a])){if(!zl(e.charCodeAt(a)))return!1;n=!0}return n&&"_"!==t}if("o"===t){for(a++;a<i;a++)if("_"!==(t=e[a])){if(!Sl(e.charCodeAt(a)))return!1;n=!0}return n&&"_"!==t}}if("_"===t)return!1;for(;a<i;a++)if("_"!==(t=e[a])){if(!Tl(e.charCodeAt(a)))return!1;n=!0}return!(!n||"_"===t)},construct:function(e){var t,i=e,a=1;if(-1!==i.indexOf("_")&&(i=i.replace(/_/g,"")),"-"!==(t=i[0])&&"+"!==t||("-"===t&&(a=-1),t=(i=i.slice(1))[0]),"0"===i)return 0;if("0"===t){if("b"===i[1])return a*parseInt(i.slice(2),2);if("x"===i[1])return a*parseInt(i.slice(2),16);if("o"===i[1])return a*parseInt(i.slice(2),8)}return a*parseInt(i,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!vl.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ol=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var Ml=/^[-+]?[0-9]+e/;var Pl=new $l("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!Ol.test(e)||"_"===e[e.length-1])},construct:function(e){var t,i;return i="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:i*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||vl.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(vl.isNegativeZero(e))return"-0.0";return i=e.toString(10),Ml.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Fl=Al.extend({implicit:[Il,El,Ll,Pl]}),Dl=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Bl=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var Nl=new $l("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==Dl.exec(e)||null!==Bl.exec(e))},construct:function(e){var t,i,a,n,o,s,r,l,d=0,c=null;if(null===(t=Dl.exec(e))&&(t=Bl.exec(e)),null===t)throw new Error("Date resolve error");if(i=+t[1],a=+t[2]-1,n=+t[3],!t[4])return new Date(Date.UTC(i,a,n));if(o=+t[4],s=+t[5],r=+t[6],t[7]){for(d=t[7].slice(0,3);d.length<3;)d+="0";d=+d}return t[9]&&(c=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(c=-c)),l=new Date(Date.UTC(i,a,n,o,s,r,d)),c&&l.setTime(l.getTime()-c),l},instanceOf:Date,represent:function(e){return e.toISOString()}});var Vl=new $l("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),ql="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var jl=new $l("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,i,a=0,n=e.length,o=ql;for(i=0;i<n;i++)if(!((t=o.indexOf(e.charAt(i)))>64)){if(t<0)return!1;a+=6}return a%8==0},construct:function(e){var t,i,a=e.replace(/[\r\n=]/g,""),n=a.length,o=ql,s=0,r=[];for(t=0;t<n;t++)t%4==0&&t&&(r.push(s>>16&255),r.push(s>>8&255),r.push(255&s)),s=s<<6|o.indexOf(a.charAt(t));return 0===(i=n%4*6)?(r.push(s>>16&255),r.push(s>>8&255),r.push(255&s)):18===i?(r.push(s>>10&255),r.push(s>>2&255)):12===i&&r.push(s>>4&255),new Uint8Array(r)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,i,a="",n=0,o=e.length,s=ql;for(t=0;t<o;t++)t%3==0&&t&&(a+=s[n>>18&63],a+=s[n>>12&63],a+=s[n>>6&63],a+=s[63&n]),n=(n<<8)+e[t];return 0===(i=o%3)?(a+=s[n>>18&63],a+=s[n>>12&63],a+=s[n>>6&63],a+=s[63&n]):2===i?(a+=s[n>>10&63],a+=s[n>>4&63],a+=s[n<<2&63],a+=s[64]):1===i&&(a+=s[n>>2&63],a+=s[n<<4&63],a+=s[64],a+=s[64]),a}}),Rl=Object.prototype.hasOwnProperty,Ul=Object.prototype.toString;var Hl=new $l("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,a,n,o,s=[],r=e;for(t=0,i=r.length;t<i;t+=1){if(a=r[t],o=!1,"[object Object]"!==Ul.call(a))return!1;for(n in a)if(Rl.call(a,n)){if(o)return!1;o=!0}if(!o)return!1;if(-1!==s.indexOf(n))return!1;s.push(n)}return!0},construct:function(e){return null!==e?e:[]}}),Gl=Object.prototype.toString;var Wl=new $l("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,i,a,n,o,s=e;for(o=new Array(s.length),t=0,i=s.length;t<i;t+=1){if(a=s[t],"[object Object]"!==Gl.call(a))return!1;if(1!==(n=Object.keys(a)).length)return!1;o[t]=[n[0],a[n[0]]]}return!0},construct:function(e){if(null===e)return[];var t,i,a,n,o,s=e;for(o=new Array(s.length),t=0,i=s.length;t<i;t+=1)a=s[t],n=Object.keys(a),o[t]=[n[0],a[n[0]]];return o}}),Kl=Object.prototype.hasOwnProperty;var Yl=new $l("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,i=e;for(t in i)if(Kl.call(i,t)&&null!==i[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),Zl=Fl.extend({implicit:[Nl,Vl],explicit:[jl,Hl,Wl,Yl]}),Ql=Object.prototype.hasOwnProperty,Jl=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Xl=/[\x85\u2028\u2029]/,ed=/[,\[\]\{\}]/,td=/^(?:!|!!|![a-z\-]+!)$/i,id=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function ad(e){return Object.prototype.toString.call(e)}function nd(e){return 10===e||13===e}function od(e){return 9===e||32===e}function sd(e){return 9===e||32===e||10===e||13===e}function rd(e){return 44===e||91===e||93===e||123===e||125===e}function ld(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function dd(e){return 120===e?2:117===e?4:85===e?8:0}function cd(e){return 48<=e&&e<=57?e-48:-1}function ud(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"…":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function hd(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var pd=new Array(256),vd=new Array(256),md=0;md<256;md++)pd[md]=ud(md)?1:0,vd[md]=ud(md);function fd(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Zl,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function gd(e,t){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=kl(i),new gl(t,i)}function _d(e,t){throw gd(e,t)}function yd(e,t){e.onWarning&&e.onWarning.call(null,gd(e,t))}var kd={YAML:function(e,t,i){var a,n,o;null!==e.version&&_d(e,"duplication of %YAML directive"),1!==i.length&&_d(e,"YAML directive accepts exactly one argument"),null===(a=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&_d(e,"ill-formed argument of the YAML directive"),n=parseInt(a[1],10),o=parseInt(a[2],10),1!==n&&_d(e,"unacceptable YAML version of the document"),e.version=i[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&yd(e,"unsupported YAML version of the document")},TAG:function(e,t,i){var a,n;2!==i.length&&_d(e,"TAG directive accepts exactly two arguments"),a=i[0],n=i[1],td.test(a)||_d(e,"ill-formed tag handle (first argument) of the TAG directive"),Ql.call(e.tagMap,a)&&_d(e,'there is a previously declared suffix for "'+a+'" tag handle'),id.test(n)||_d(e,"ill-formed tag prefix (second argument) of the TAG directive");try{n=decodeURIComponent(n)}catch(t){_d(e,"tag prefix is malformed: "+n)}e.tagMap[a]=n}};function bd(e,t,i,a){var n,o,s,r;if(t<i){if(r=e.input.slice(t,i),a)for(n=0,o=r.length;n<o;n+=1)9===(s=r.charCodeAt(n))||32<=s&&s<=1114111||_d(e,"expected valid JSON character");else Jl.test(r)&&_d(e,"the stream contains non-printable characters");e.result+=r}}function xd(e,t,i,a){var n,o,s,r;for(vl.isObject(i)||_d(e,"cannot merge mappings; the provided source object is unacceptable"),s=0,r=(n=Object.keys(i)).length;s<r;s+=1)o=n[s],Ql.call(t,o)||(t[o]=i[o],a[o]=!0)}function $d(e,t,i,a,n,o,s,r,l){var d,c;if(Array.isArray(n))for(d=0,c=(n=Array.prototype.slice.call(n)).length;d<c;d+=1)Array.isArray(n[d])&&_d(e,"nested arrays are not supported inside keys"),"object"==typeof n&&"[object Object]"===ad(n[d])&&(n[d]="[object Object]");if("object"==typeof n&&"[object Object]"===ad(n)&&(n="[object Object]"),n=String(n),null===t&&(t={}),"tag:yaml.org,2002:merge"===a)if(Array.isArray(o))for(d=0,c=o.length;d<c;d+=1)xd(e,t,o[d],i);else xd(e,t,o,i);else e.json||Ql.call(i,n)||!Ql.call(t,n)||(e.line=s||e.line,e.lineStart=r||e.lineStart,e.position=l||e.position,_d(e,"duplicated mapping key")),"__proto__"===n?Object.defineProperty(t,n,{configurable:!0,enumerable:!0,writable:!0,value:o}):t[n]=o,delete i[n];return t}function wd(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):_d(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Cd(e,t,i){for(var a=0,n=e.input.charCodeAt(e.position);0!==n;){for(;od(n);)9===n&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),n=e.input.charCodeAt(++e.position);if(t&&35===n)do{n=e.input.charCodeAt(++e.position)}while(10!==n&&13!==n&&0!==n);if(!nd(n))break;for(wd(e),n=e.input.charCodeAt(e.position),a++,e.lineIndent=0;32===n;)e.lineIndent++,n=e.input.charCodeAt(++e.position)}return-1!==i&&0!==a&&e.lineIndent<i&&yd(e,"deficient indentation"),a}function Ad(e){var t,i=e.position;return!(45!==(t=e.input.charCodeAt(i))&&46!==t||t!==e.input.charCodeAt(i+1)||t!==e.input.charCodeAt(i+2)||(i+=3,0!==(t=e.input.charCodeAt(i))&&!sd(t)))}function Id(e,t){1===t?e.result+=" ":t>1&&(e.result+=vl.repeat("\n",t-1))}function Ed(e,t){var i,a,n=e.tag,o=e.anchor,s=[],r=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=s),a=e.input.charCodeAt(e.position);0!==a&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,_d(e,"tab characters must not be used in indentation")),45===a)&&sd(e.input.charCodeAt(e.position+1));)if(r=!0,e.position++,Cd(e,!0,-1)&&e.lineIndent<=t)s.push(null),a=e.input.charCodeAt(e.position);else if(i=e.line,Td(e,t,3,!1,!0),s.push(e.result),Cd(e,!0,-1),a=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>t)&&0!==a)_d(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!r&&(e.tag=n,e.anchor=o,e.kind="sequence",e.result=s,!0)}function zd(e){var t,i,a,n,o=!1,s=!1;if(33!==(n=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&_d(e,"duplication of a tag property"),60===(n=e.input.charCodeAt(++e.position))?(o=!0,n=e.input.charCodeAt(++e.position)):33===n?(s=!0,i="!!",n=e.input.charCodeAt(++e.position)):i="!",t=e.position,o){do{n=e.input.charCodeAt(++e.position)}while(0!==n&&62!==n);e.position<e.length?(a=e.input.slice(t,e.position),n=e.input.charCodeAt(++e.position)):_d(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==n&&!sd(n);)33===n&&(s?_d(e,"tag suffix cannot contain exclamation marks"):(i=e.input.slice(t-1,e.position+1),td.test(i)||_d(e,"named tag handle cannot contain such characters"),s=!0,t=e.position+1)),n=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),ed.test(a)&&_d(e,"tag suffix cannot contain flow indicator characters")}a&&!id.test(a)&&_d(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch(t){_d(e,"tag name is malformed: "+a)}return o?e.tag=a:Ql.call(e.tagMap,i)?e.tag=e.tagMap[i]+a:"!"===i?e.tag="!"+a:"!!"===i?e.tag="tag:yaml.org,2002:"+a:_d(e,'undeclared tag handle "'+i+'"'),!0}function Sd(e){var t,i;if(38!==(i=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&_d(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!sd(i)&&!rd(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&_d(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function Td(e,t,i,a,n){var o,s,r,l,d,c,u,h,p,v=1,m=!1,f=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=s=r=4===i||3===i,a&&Cd(e,!0,-1)&&(m=!0,e.lineIndent>t?v=1:e.lineIndent===t?v=0:e.lineIndent<t&&(v=-1)),1===v)for(;zd(e)||Sd(e);)Cd(e,!0,-1)?(m=!0,r=o,e.lineIndent>t?v=1:e.lineIndent===t?v=0:e.lineIndent<t&&(v=-1)):r=!1;if(r&&(r=m||n),1!==v&&4!==i||(h=1===i||2===i?t:t+1,p=e.position-e.lineStart,1===v?r&&(Ed(e,p)||function(e,t,i){var a,n,o,s,r,l,d,c=e.tag,u=e.anchor,h={},p=Object.create(null),v=null,m=null,f=null,g=!1,_=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=h),d=e.input.charCodeAt(e.position);0!==d;){if(g||-1===e.firstTabInLine||(e.position=e.firstTabInLine,_d(e,"tab characters must not be used in indentation")),a=e.input.charCodeAt(e.position+1),o=e.line,63!==d&&58!==d||!sd(a)){if(s=e.line,r=e.lineStart,l=e.position,!Td(e,i,2,!1,!0))break;if(e.line===o){for(d=e.input.charCodeAt(e.position);od(d);)d=e.input.charCodeAt(++e.position);if(58===d)sd(d=e.input.charCodeAt(++e.position))||_d(e,"a whitespace character is expected after the key-value separator within a block mapping"),g&&($d(e,h,p,v,m,null,s,r,l),v=m=f=null),_=!0,g=!1,n=!1,v=e.tag,m=e.result;else{if(!_)return e.tag=c,e.anchor=u,!0;_d(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!_)return e.tag=c,e.anchor=u,!0;_d(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===d?(g&&($d(e,h,p,v,m,null,s,r,l),v=m=f=null),_=!0,g=!0,n=!0):g?(g=!1,n=!0):_d(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,d=a;if((e.line===o||e.lineIndent>t)&&(g&&(s=e.line,r=e.lineStart,l=e.position),Td(e,t,4,!0,n)&&(g?m=e.result:f=e.result),g||($d(e,h,p,v,m,f,s,r,l),v=m=f=null),Cd(e,!0,-1),d=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==d)_d(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return g&&$d(e,h,p,v,m,null,s,r,l),_&&(e.tag=c,e.anchor=u,e.kind="mapping",e.result=h),_}(e,p,h))||function(e,t){var i,a,n,o,s,r,l,d,c,u,h,p,v=!0,m=e.tag,f=e.anchor,g=Object.create(null);if(91===(p=e.input.charCodeAt(e.position)))s=93,d=!1,o=[];else{if(123!==p)return!1;s=125,d=!0,o={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),p=e.input.charCodeAt(++e.position);0!==p;){if(Cd(e,!0,t),(p=e.input.charCodeAt(e.position))===s)return e.position++,e.tag=m,e.anchor=f,e.kind=d?"mapping":"sequence",e.result=o,!0;v?44===p&&_d(e,"expected the node content, but found ','"):_d(e,"missed comma between flow collection entries"),h=null,r=l=!1,63===p&&sd(e.input.charCodeAt(e.position+1))&&(r=l=!0,e.position++,Cd(e,!0,t)),i=e.line,a=e.lineStart,n=e.position,Td(e,t,1,!1,!0),u=e.tag,c=e.result,Cd(e,!0,t),p=e.input.charCodeAt(e.position),!l&&e.line!==i||58!==p||(r=!0,p=e.input.charCodeAt(++e.position),Cd(e,!0,t),Td(e,t,1,!1,!0),h=e.result),d?$d(e,o,g,u,c,h,i,a,n):r?o.push($d(e,null,g,u,c,h,i,a,n)):o.push(c),Cd(e,!0,t),44===(p=e.input.charCodeAt(e.position))?(v=!0,p=e.input.charCodeAt(++e.position)):v=!1}_d(e,"unexpected end of the stream within a flow collection")}(e,h)?f=!0:(s&&function(e,t){var i,a,n,o,s=1,r=!1,l=!1,d=t,c=0,u=!1;if(124===(o=e.input.charCodeAt(e.position)))a=!1;else{if(62!==o)return!1;a=!0}for(e.kind="scalar",e.result="";0!==o;)if(43===(o=e.input.charCodeAt(++e.position))||45===o)1===s?s=43===o?3:2:_d(e,"repeat of a chomping mode identifier");else{if(!((n=cd(o))>=0))break;0===n?_d(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):l?_d(e,"repeat of an indentation width identifier"):(d=t+n-1,l=!0)}if(od(o)){do{o=e.input.charCodeAt(++e.position)}while(od(o));if(35===o)do{o=e.input.charCodeAt(++e.position)}while(!nd(o)&&0!==o)}for(;0!==o;){for(wd(e),e.lineIndent=0,o=e.input.charCodeAt(e.position);(!l||e.lineIndent<d)&&32===o;)e.lineIndent++,o=e.input.charCodeAt(++e.position);if(!l&&e.lineIndent>d&&(d=e.lineIndent),nd(o))c++;else{if(e.lineIndent<d){3===s?e.result+=vl.repeat("\n",r?1+c:c):1===s&&r&&(e.result+="\n");break}for(a?od(o)?(u=!0,e.result+=vl.repeat("\n",r?1+c:c)):u?(u=!1,e.result+=vl.repeat("\n",c+1)):0===c?r&&(e.result+=" "):e.result+=vl.repeat("\n",c):e.result+=vl.repeat("\n",r?1+c:c),r=!0,l=!0,c=0,i=e.position;!nd(o)&&0!==o;)o=e.input.charCodeAt(++e.position);bd(e,i,e.position,!1)}}return!0}(e,h)||function(e,t){var i,a,n;if(39!==(i=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,a=n=e.position;0!==(i=e.input.charCodeAt(e.position));)if(39===i){if(bd(e,a,e.position,!0),39!==(i=e.input.charCodeAt(++e.position)))return!0;a=e.position,e.position++,n=e.position}else nd(i)?(bd(e,a,n,!0),Id(e,Cd(e,!1,t)),a=n=e.position):e.position===e.lineStart&&Ad(e)?_d(e,"unexpected end of the document within a single quoted scalar"):(e.position++,n=e.position);_d(e,"unexpected end of the stream within a single quoted scalar")}(e,h)||function(e,t){var i,a,n,o,s,r;if(34!==(r=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=a=e.position;0!==(r=e.input.charCodeAt(e.position));){if(34===r)return bd(e,i,e.position,!0),e.position++,!0;if(92===r){if(bd(e,i,e.position,!0),nd(r=e.input.charCodeAt(++e.position)))Cd(e,!1,t);else if(r<256&&pd[r])e.result+=vd[r],e.position++;else if((s=dd(r))>0){for(n=s,o=0;n>0;n--)(s=ld(r=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+s:_d(e,"expected hexadecimal character");e.result+=hd(o),e.position++}else _d(e,"unknown escape sequence");i=a=e.position}else nd(r)?(bd(e,i,a,!0),Id(e,Cd(e,!1,t)),i=a=e.position):e.position===e.lineStart&&Ad(e)?_d(e,"unexpected end of the document within a double quoted scalar"):(e.position++,a=e.position)}_d(e,"unexpected end of the stream within a double quoted scalar")}(e,h)?f=!0:!function(e){var t,i,a;if(42!==(a=e.input.charCodeAt(e.position)))return!1;for(a=e.input.charCodeAt(++e.position),t=e.position;0!==a&&!sd(a)&&!rd(a);)a=e.input.charCodeAt(++e.position);return e.position===t&&_d(e,"name of an alias node must contain at least one character"),i=e.input.slice(t,e.position),Ql.call(e.anchorMap,i)||_d(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],Cd(e,!0,-1),!0}(e)?function(e,t,i){var a,n,o,s,r,l,d,c,u=e.kind,h=e.result;if(sd(c=e.input.charCodeAt(e.position))||rd(c)||35===c||38===c||42===c||33===c||124===c||62===c||39===c||34===c||37===c||64===c||96===c)return!1;if((63===c||45===c)&&(sd(a=e.input.charCodeAt(e.position+1))||i&&rd(a)))return!1;for(e.kind="scalar",e.result="",n=o=e.position,s=!1;0!==c;){if(58===c){if(sd(a=e.input.charCodeAt(e.position+1))||i&&rd(a))break}else if(35===c){if(sd(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Ad(e)||i&&rd(c))break;if(nd(c)){if(r=e.line,l=e.lineStart,d=e.lineIndent,Cd(e,!1,-1),e.lineIndent>=t){s=!0,c=e.input.charCodeAt(e.position);continue}e.position=o,e.line=r,e.lineStart=l,e.lineIndent=d;break}}s&&(bd(e,n,o,!1),Id(e,e.line-r),n=o=e.position,s=!1),od(c)||(o=e.position+1),c=e.input.charCodeAt(++e.position)}return bd(e,n,o,!1),!!e.result||(e.kind=u,e.result=h,!1)}(e,h,1===i)&&(f=!0,null===e.tag&&(e.tag="?")):(f=!0,null===e.tag&&null===e.anchor||_d(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===v&&(f=r&&Ed(e,p))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&_d(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),l=0,d=e.implicitTypes.length;l<d;l+=1)if((u=e.implicitTypes[l]).resolve(e.result)){e.result=u.construct(e.result),e.tag=u.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(Ql.call(e.typeMap[e.kind||"fallback"],e.tag))u=e.typeMap[e.kind||"fallback"][e.tag];else for(u=null,l=0,d=(c=e.typeMap.multi[e.kind||"fallback"]).length;l<d;l+=1)if(e.tag.slice(0,c[l].tag.length)===c[l].tag){u=c[l];break}u||_d(e,"unknown tag !<"+e.tag+">"),null!==e.result&&u.kind!==e.kind&&_d(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+u.kind+'", not "'+e.kind+'"'),u.resolve(e.result,e.tag)?(e.result=u.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):_d(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||f}function Ld(e){var t,i,a,n,o=e.position,s=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(n=e.input.charCodeAt(e.position))&&(Cd(e,!0,-1),n=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==n));){for(s=!0,n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!sd(n);)n=e.input.charCodeAt(++e.position);for(a=[],(i=e.input.slice(t,e.position)).length<1&&_d(e,"directive name must not be less than one character in length");0!==n;){for(;od(n);)n=e.input.charCodeAt(++e.position);if(35===n){do{n=e.input.charCodeAt(++e.position)}while(0!==n&&!nd(n));break}if(nd(n))break;for(t=e.position;0!==n&&!sd(n);)n=e.input.charCodeAt(++e.position);a.push(e.input.slice(t,e.position))}0!==n&&wd(e),Ql.call(kd,i)?kd[i](e,i,a):yd(e,'unknown document directive "'+i+'"')}Cd(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Cd(e,!0,-1)):s&&_d(e,"directives end mark is expected"),Td(e,e.lineIndent-1,4,!1,!0),Cd(e,!0,-1),e.checkLineBreaks&&Xl.test(e.input.slice(o,e.position))&&yd(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Ad(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Cd(e,!0,-1)):e.position<e.length-1&&_d(e,"end of the stream or a document separator is expected")}function Od(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var i=new fd(e,t),a=e.indexOf("\0");for(-1!==a&&(i.position=a,_d(i,"null byte is not allowed in input")),i.input+="\0";32===i.input.charCodeAt(i.position);)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Ld(i);return i.documents}var Md={loadAll:function(e,t,i){null!==t&&"object"==typeof t&&void 0===i&&(i=t,t=null);var a=Od(e,i);if("function"!=typeof t)return a;for(var n=0,o=a.length;n<o;n+=1)t(a[n])},load:function(e,t){var i=Od(e,t);if(0!==i.length){if(1===i.length)return i[0];throw new gl("expected a single document in the stream, but found more")}}},Pd=Object.prototype.toString,Fd=Object.prototype.hasOwnProperty,Dd={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},Bd=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Nd=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Vd(e){var t,i,a;if(t=e.toString(16).toUpperCase(),e<=255)i="x",a=2;else if(e<=65535)i="u",a=4;else{if(!(e<=4294967295))throw new gl("code point within a string may not be greater than 0xFFFFFFFF");i="U",a=8}return"\\"+i+vl.repeat("0",a-t.length)+t}function qd(e){this.schema=e.schema||Zl,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=vl.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){var i,a,n,o,s,r,l;if(null===t)return{};for(i={},n=0,o=(a=Object.keys(t)).length;n<o;n+=1)s=a[n],r=String(t[s]),"!!"===s.slice(0,2)&&(s="tag:yaml.org,2002:"+s.slice(2)),(l=e.compiledTypeMap.fallback[s])&&Fd.call(l.styleAliases,r)&&(r=l.styleAliases[r]),i[s]=r;return i}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType='"'===e.quotingType?2:1,this.forceQuotes=e.forceQuotes||!1,this.replacer="function"==typeof e.replacer?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function jd(e,t){for(var i,a=vl.repeat(" ",t),n=0,o=-1,s="",r=e.length;n<r;)-1===(o=e.indexOf("\n",n))?(i=e.slice(n),n=r):(i=e.slice(n,o+1),n=o+1),i.length&&"\n"!==i&&(s+=a),s+=i;return s}function Rd(e,t){return"\n"+vl.repeat(" ",e.indent*t)}function Ud(e){return 32===e||9===e}function Hd(e){return 32<=e&&e<=126||161<=e&&e<=55295&&8232!==e&&8233!==e||57344<=e&&e<=65533&&65279!==e||65536<=e&&e<=1114111}function Gd(e){return Hd(e)&&65279!==e&&13!==e&&10!==e}function Wd(e,t,i){var a=Gd(e),n=a&&!Ud(e);return(i?a:a&&44!==e&&91!==e&&93!==e&&123!==e&&125!==e)&&35!==e&&!(58===t&&!n)||Gd(t)&&!Ud(t)&&35===e||58===t&&n}function Kd(e,t){var i,a=e.charCodeAt(t);return a>=55296&&a<=56319&&t+1<e.length&&(i=e.charCodeAt(t+1))>=56320&&i<=57343?1024*(a-55296)+i-56320+65536:a}function Yd(e){return/^\n* /.test(e)}function Zd(e,t,i,a,n,o,s,r){var l,d=0,c=null,u=!1,h=!1,p=-1!==a,v=-1,m=function(e){return Hd(e)&&65279!==e&&!Ud(e)&&45!==e&&63!==e&&58!==e&&44!==e&&91!==e&&93!==e&&123!==e&&125!==e&&35!==e&&38!==e&&42!==e&&33!==e&&124!==e&&61!==e&&62!==e&&39!==e&&34!==e&&37!==e&&64!==e&&96!==e}(Kd(e,0))&&function(e){return!Ud(e)&&58!==e}(Kd(e,e.length-1));if(t||s)for(l=0;l<e.length;d>=65536?l+=2:l++){if(!Hd(d=Kd(e,l)))return 5;m=m&&Wd(d,c,r),c=d}else{for(l=0;l<e.length;d>=65536?l+=2:l++){if(10===(d=Kd(e,l)))u=!0,p&&(h=h||l-v-1>a&&" "!==e[v+1],v=l);else if(!Hd(d))return 5;m=m&&Wd(d,c,r),c=d}h=h||p&&l-v-1>a&&" "!==e[v+1]}return u||h?i>9&&Yd(e)?5:s?2===o?5:2:h?4:3:!m||s||n(e)?2===o?5:2:1}function Qd(e,t,i,a,n){e.dump=function(){if(0===t.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==Bd.indexOf(t)||Nd.test(t)))return 2===e.quotingType?'"'+t+'"':"'"+t+"'";var o=e.indent*Math.max(1,i),s=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),r=a||e.flowLevel>-1&&i>=e.flowLevel;switch(Zd(t,r,e.indent,s,(function(t){return function(e,t){var i,a;for(i=0,a=e.implicitTypes.length;i<a;i+=1)if(e.implicitTypes[i].resolve(t))return!0;return!1}(e,t)}),e.quotingType,e.forceQuotes&&!a,n)){case 1:return t;case 2:return"'"+t.replace(/'/g,"''")+"'";case 3:return"|"+Jd(t,e.indent)+Xd(jd(t,o));case 4:return">"+Jd(t,e.indent)+Xd(jd(function(e,t){var i,a,n=/(\n+)([^\n]*)/g,o=(r=e.indexOf("\n"),r=-1!==r?r:e.length,n.lastIndex=r,ec(e.slice(0,r),t)),s="\n"===e[0]||" "===e[0];var r;for(;a=n.exec(e);){var l=a[1],d=a[2];i=" "===d[0],o+=l+(s||i||""===d?"":"\n")+ec(d,t),s=i}return o}(t,s),o));case 5:return'"'+function(e){for(var t,i="",a=0,n=0;n<e.length;a>=65536?n+=2:n++)a=Kd(e,n),!(t=Dd[a])&&Hd(a)?(i+=e[n],a>=65536&&(i+=e[n+1])):i+=t||Vd(a);return i}(t)+'"';default:throw new gl("impossible error: invalid scalar style")}}()}function Jd(e,t){var i=Yd(e)?String(t):"",a="\n"===e[e.length-1];return i+(a&&("\n"===e[e.length-2]||"\n"===e)?"+":a?"":"-")+"\n"}function Xd(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function ec(e,t){if(""===e||" "===e[0])return e;for(var i,a,n=/ [^ ]/g,o=0,s=0,r=0,l="";i=n.exec(e);)(r=i.index)-o>t&&(a=s>o?s:r,l+="\n"+e.slice(o,a),o=a+1),s=r;return l+="\n",e.length-o>t&&s>o?l+=e.slice(o,s)+"\n"+e.slice(s+1):l+=e.slice(o),l.slice(1)}function tc(e,t,i,a){var n,o,s,r="",l=e.tag;for(n=0,o=i.length;n<o;n+=1)s=i[n],e.replacer&&(s=e.replacer.call(i,String(n),s)),(ac(e,t+1,s,!0,!0,!1,!0)||void 0===s&&ac(e,t+1,null,!0,!0,!1,!0))&&(a&&""===r||(r+=Rd(e,t)),e.dump&&10===e.dump.charCodeAt(0)?r+="-":r+="- ",r+=e.dump);e.tag=l,e.dump=r||"[]"}function ic(e,t,i){var a,n,o,s,r,l;for(o=0,s=(n=i?e.explicitTypes:e.implicitTypes).length;o<s;o+=1)if(((r=n[o]).instanceOf||r.predicate)&&(!r.instanceOf||"object"==typeof t&&t instanceof r.instanceOf)&&(!r.predicate||r.predicate(t))){if(i?r.multi&&r.representName?e.tag=r.representName(t):e.tag=r.tag:e.tag="?",r.represent){if(l=e.styleMap[r.tag]||r.defaultStyle,"[object Function]"===Pd.call(r.represent))a=r.represent(t,l);else{if(!Fd.call(r.represent,l))throw new gl("!<"+r.tag+'> tag resolver accepts not "'+l+'" style');a=r.represent[l](t,l)}e.dump=a}return!0}return!1}function ac(e,t,i,a,n,o,s){e.tag=null,e.dump=i,ic(e,i,!1)||ic(e,i,!0);var r,l=Pd.call(e.dump),d=a;a&&(a=e.flowLevel<0||e.flowLevel>t);var c,u,h="[object Object]"===l||"[object Array]"===l;if(h&&(u=-1!==(c=e.duplicates.indexOf(i))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(n=!1),u&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(h&&u&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),"[object Object]"===l)a&&0!==Object.keys(e.dump).length?(!function(e,t,i,a){var n,o,s,r,l,d,c="",u=e.tag,h=Object.keys(i);if(!0===e.sortKeys)h.sort();else if("function"==typeof e.sortKeys)h.sort(e.sortKeys);else if(e.sortKeys)throw new gl("sortKeys must be a boolean or a function");for(n=0,o=h.length;n<o;n+=1)d="",a&&""===c||(d+=Rd(e,t)),r=i[s=h[n]],e.replacer&&(r=e.replacer.call(i,s,r)),ac(e,t+1,s,!0,!0,!0)&&((l=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024)&&(e.dump&&10===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,l&&(d+=Rd(e,t)),ac(e,t+1,r,!0,l)&&(e.dump&&10===e.dump.charCodeAt(0)?d+=":":d+=": ",c+=d+=e.dump));e.tag=u,e.dump=c||"{}"}(e,t,e.dump,n),u&&(e.dump="&ref_"+c+e.dump)):(!function(e,t,i){var a,n,o,s,r,l="",d=e.tag,c=Object.keys(i);for(a=0,n=c.length;a<n;a+=1)r="",""!==l&&(r+=", "),e.condenseFlow&&(r+='"'),s=i[o=c[a]],e.replacer&&(s=e.replacer.call(i,o,s)),ac(e,t,o,!1,!1)&&(e.dump.length>1024&&(r+="? "),r+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ac(e,t,s,!1,!1)&&(l+=r+=e.dump));e.tag=d,e.dump="{"+l+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+c+" "+e.dump));else if("[object Array]"===l)a&&0!==e.dump.length?(e.noArrayIndent&&!s&&t>0?tc(e,t-1,e.dump,n):tc(e,t,e.dump,n),u&&(e.dump="&ref_"+c+e.dump)):(!function(e,t,i){var a,n,o,s="",r=e.tag;for(a=0,n=i.length;a<n;a+=1)o=i[a],e.replacer&&(o=e.replacer.call(i,String(a),o)),(ac(e,t,o,!1,!1)||void 0===o&&ac(e,t,null,!1,!1))&&(""!==s&&(s+=","+(e.condenseFlow?"":" ")),s+=e.dump);e.tag=r,e.dump="["+s+"]"}(e,t,e.dump),u&&(e.dump="&ref_"+c+" "+e.dump));else{if("[object String]"!==l){if("[object Undefined]"===l)return!1;if(e.skipInvalid)return!1;throw new gl("unacceptable kind of an object to dump "+l)}"?"!==e.tag&&Qd(e,e.dump,t,o,d)}null!==e.tag&&"?"!==e.tag&&(r=encodeURI("!"===e.tag[0]?e.tag.slice(1):e.tag).replace(/!/g,"%21"),r="!"===e.tag[0]?"!"+r:"tag:yaml.org,2002:"===r.slice(0,18)?"!!"+r.slice(18):"!<"+r+">",e.dump=r+" "+e.dump)}return!0}function nc(e,t){var i,a,n=[],o=[];for(oc(e,n,o),i=0,a=o.length;i<a;i+=1)t.duplicates.push(n[o[i]]);t.usedDuplicates=new Array(a)}function oc(e,t,i){var a,n,o;if(null!==e&&"object"==typeof e)if(-1!==(n=t.indexOf(e)))-1===i.indexOf(n)&&i.push(n);else if(t.push(e),Array.isArray(e))for(n=0,o=e.length;n<o;n+=1)oc(e[n],t,i);else for(n=0,o=(a=Object.keys(e)).length;n<o;n+=1)oc(e[a[n]],t,i)}var sc=Zl,rc=Md.load,lc={dump:function(e,t){var i=new qd(t=t||{});i.noRefs||nc(e,i);var a=e;return i.replacer&&(a=i.replacer.call({"":a},"",a)),ac(i,0,a,!0,!0)?i.dump+"\n":""}}.dump;let dc;const cc={key:"Mod-s",run:e=>(o(e.dom,"editor-save"),!0)},uc=e=>{const t=document.createElement("ha-icon");return t.icon=e.label,t};f([A("ha-code-editor")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:"codemirror",value:void 0},{kind:"field",decorators:[_()],key:"mode",value:()=>"yaml"},{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autofocus",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"readOnly",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"autocomplete-entities"})],key:"autocompleteEntities",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"autocomplete-icons"})],key:"autocompleteIcons",value:()=>!1},{kind:"field",decorators:[_()],key:"error",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_value",value:()=>""},{kind:"field",key:"_loadedCodeMirror",value:void 0},{kind:"field",key:"_iconList",value:void 0},{kind:"set",key:"value",value:function(e){this._value=e}},{kind:"get",key:"value",value:function(){return this.codemirror?this.codemirror.state.doc.toString():this._value}},{kind:"get",key:"hasComments",value:function(){if(!this.codemirror||!this._loadedCodeMirror)return!1;const e=this._loadedCodeMirror.HighlightStyle.get(this.codemirror.state,this._loadedCodeMirror.tags.comment);return!!this.shadowRoot.querySelector(`span.${e}`)}},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this),this.codemirror&&!1!==this.autofocus&&this.codemirror.focus()}},{kind:"method",key:"update",value:function(e){k(b(i.prototype),"update",this).call(this,e),this.codemirror&&(e.has("mode")&&this.codemirror.dispatch({effects:this._loadedCodeMirror.langCompartment.reconfigure(this._mode)}),e.has("readOnly")&&this.codemirror.dispatch({effects:this._loadedCodeMirror.readonlyCompartment.reconfigure(this._loadedCodeMirror.EditorView.editable.of(!this.readOnly))}),e.has("_value")&&this._value!==this.value&&this.codemirror.dispatch({changes:{from:0,to:this.codemirror.state.doc.length,insert:this._value}}),e.has("error")&&this.classList.toggle("error-state",this.error))}},{kind:"method",key:"firstUpdated",value:function(e){k(b(i.prototype),"firstUpdated",this).call(this,e),this._blockKeyboardShortcuts(),this._load()}},{kind:"get",key:"_mode",value:function(){return this._loadedCodeMirror.langs[this.mode]}},{kind:"method",key:"_load",value:async function(){this._loadedCodeMirror=await(async()=>(dc||(dc=import("./c.10c7d0ce.js")),dc))();const e=[this._loadedCodeMirror.lineNumbers(),this._loadedCodeMirror.EditorState.allowMultipleSelections.of(!0),this._loadedCodeMirror.history(),this._loadedCodeMirror.highlightSelectionMatches(),this._loadedCodeMirror.highlightActiveLine(),this._loadedCodeMirror.drawSelection(),this._loadedCodeMirror.rectangularSelection(),this._loadedCodeMirror.keymap.of([...this._loadedCodeMirror.defaultKeymap,...this._loadedCodeMirror.searchKeymap,...this._loadedCodeMirror.historyKeymap,...this._loadedCodeMirror.tabKeyBindings,cc]),this._loadedCodeMirror.langCompartment.of(this._mode),this._loadedCodeMirror.theme,this._loadedCodeMirror.Prec.fallback(this._loadedCodeMirror.highlightStyle),this._loadedCodeMirror.readonlyCompartment.of(this._loadedCodeMirror.EditorView.editable.of(!this.readOnly)),this._loadedCodeMirror.EditorView.updateListener.of((e=>this._onUpdate(e)))];if(!this.readOnly){const t=[];this.autocompleteEntities&&this.hass&&t.push(this._entityCompletions.bind(this)),this.autocompleteIcons&&t.push(this._mdiCompletions.bind(this)),t.length>0&&e.push(this._loadedCodeMirror.autocompletion({override:t,maxRenderedOptions:10}))}this.codemirror=new this._loadedCodeMirror.EditorView({state:this._loadedCodeMirror.EditorState.create({doc:this._value,extensions:e}),root:this.shadowRoot,parent:this.shadowRoot})}},{kind:"field",key:"_getStates",value:()=>n((e=>{if(!e)return[];return Object.keys(e).map((t=>({type:"variable",label:t,detail:e[t].attributes.friendly_name,info:`State: ${e[t].state}`})))}))},{kind:"method",key:"_entityCompletions",value:function(e){const t=e.matchBefore(/[a-z_]{3,}\.\w*/);if(!t||t.from===t.to&&!e.explicit)return null;const i=this._getStates(this.hass.states);return i&&i.length?{from:Number(t.from),options:i,span:/^[a-z_]{3,}\.\w*$/}:null}},{kind:"field",key:"_getIconItems",value(){return async()=>{if(!this._iconList){let e;e=[],this._iconList=e.map((e=>({type:"variable",label:`mdi:${e.name}`,detail:e.keywords.join(", "),info:uc})))}return this._iconList}}},{kind:"method",key:"_mdiCompletions",value:async function(e){const t=e.matchBefore(/mdi:\S*/);if(!t||t.from===t.to&&!e.explicit)return null;const i=await this._getIconItems();return{from:Number(t.from),options:i,span:/^mdi:\S*$/}}},{kind:"method",key:"_blockKeyboardShortcuts",value:function(){this.addEventListener("keydown",(e=>e.stopPropagation()))}},{kind:"method",key:"_onUpdate",value:function(e){if(!e.docChanged)return;const t=this.value;t!==this._value&&(this._value=t,o(this,"value-changed",{value:this._value}))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  897. :host(.error-state) .cm-gutters {
  898. border-color: var(--error-state-color, red);
  899. }
  900. `}}]}}),ha);f([A("ha-yaml-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"yamlSchema",value:()=>sc},{kind:"field",decorators:[_()],key:"defaultValue",value:void 0},{kind:"field",decorators:[_()],key:"isValid",value:()=>!0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"readOnly",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_yaml",value:()=>""},{kind:"method",key:"setValue",value:function(e){try{this._yaml=e&&!(e=>{if("object"!=typeof e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0})(e)?lc(e,{schema:this.yamlSchema,quotingType:'"'}):""}catch(t){console.error(t,e),alert(`There was an error converting to YAML: ${t}`)}}},{kind:"method",key:"firstUpdated",value:function(){this.defaultValue&&this.setValue(this.defaultValue)}},{kind:"method",key:"render",value:function(){return void 0===this._yaml?x``:x`
  901. ${this.label?x`<p>${this.label}${this.required?" *":""}</p>`:""}
  902. <ha-code-editor
  903. .hass=${this.hass}
  904. .value=${this._yaml}
  905. .readOnly=${this.readOnly}
  906. mode="yaml"
  907. autocomplete-entities
  908. autocomplete-icons
  909. .error=${!1===this.isValid}
  910. @value-changed=${this._onChange}
  911. dir="ltr"
  912. ></ha-code-editor>
  913. `}},{kind:"method",key:"_onChange",value:function(e){let t;e.stopPropagation(),this._yaml=e.detail.value;let i=!0;if(this._yaml)try{t=rc(this._yaml,{schema:this.yamlSchema})}catch(e){i=!1}else t={};this.value=t,this.isValid=i,o(this,"value-changed",{value:t,isValid:i})}},{kind:"get",key:"yaml",value:function(){return this._yaml}}]}}),g);f([A("ha-progress-button")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"progress",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"raised",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_result",value:void 0},{kind:"method",key:"render",value:function(){const e=this._result||this.progress;return x`
  914. <mwc-button
  915. ?raised=${this.raised}
  916. .disabled=${this.disabled||this.progress}
  917. @click=${this._buttonTapped}
  918. class=${this._result||""}
  919. >
  920. <slot></slot>
  921. </mwc-button>
  922. ${e?x`
  923. <div class="progress">
  924. ${"success"===this._result?x`<ha-svg-icon .path=${pa}></ha-svg-icon>`:"error"===this._result?x`<ha-svg-icon .path=${va}></ha-svg-icon>`:this.progress?x`
  925. <ha-circular-progress
  926. size="small"
  927. active
  928. ></ha-circular-progress>
  929. `:""}
  930. </div>
  931. `:""}
  932. `}},{kind:"method",key:"actionSuccess",value:function(){this._setResult("success")}},{kind:"method",key:"actionError",value:function(){this._setResult("error")}},{kind:"method",key:"_setResult",value:function(e){this._result=e,setTimeout((()=>{this._result=void 0}),2e3)}},{kind:"method",key:"_buttonTapped",value:function(e){this.progress&&e.stopPropagation()}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  933. :host {
  934. outline: none;
  935. display: inline-block;
  936. position: relative;
  937. }
  938. mwc-button {
  939. transition: all 1s;
  940. }
  941. mwc-button.success {
  942. --mdc-theme-primary: white;
  943. background-color: var(--success-color);
  944. transition: none;
  945. border-radius: 4px;
  946. pointer-events: none;
  947. }
  948. mwc-button[raised].success {
  949. --mdc-theme-primary: var(--success-color);
  950. --mdc-theme-on-primary: white;
  951. }
  952. mwc-button.error {
  953. --mdc-theme-primary: white;
  954. background-color: var(--error-color);
  955. transition: none;
  956. border-radius: 4px;
  957. pointer-events: none;
  958. }
  959. mwc-button[raised].error {
  960. --mdc-theme-primary: var(--error-color);
  961. --mdc-theme-on-primary: white;
  962. }
  963. .progress {
  964. bottom: 4px;
  965. position: absolute;
  966. text-align: center;
  967. top: 4px;
  968. width: 100%;
  969. }
  970. ha-svg-icon {
  971. color: white;
  972. }
  973. mwc-button.success slot,
  974. mwc-button.error slot {
  975. visibility: hidden;
  976. }
  977. `}}]}}),g);const hc=e=>e.preventDefault();f([A("ha-automation-condition-row")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"condition",value:void 0},{kind:"field",decorators:[Qi()],key:"_yamlMode",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_warnings",value:void 0},{kind:"method",key:"render",value:function(){return this.condition?x`
  978. <ha-card outlined>
  979. ${!1===this.condition.enabled?x`<div class="disabled-bar">
  980. ${this.hass.localize("ui.panel.config.automation.editor.actions.disabled")}
  981. </div>`:""}
  982. <ha-expansion-panel leftChevron>
  983. <div slot="header">
  984. <ha-svg-icon
  985. class="condition-icon"
  986. .path=${cl[this.condition.condition]}
  987. ></ha-svg-icon>
  988. ${us(vs(this.condition,this.hass))}
  989. </div>
  990. <ha-progress-button slot="icons" @click=${this._testCondition}>
  991. ${this.hass.localize("ui.panel.config.automation.editor.conditions.test")}
  992. </ha-progress-button>
  993. <ha-button-menu
  994. slot="icons"
  995. fixed
  996. corner="BOTTOM_START"
  997. @action=${this._handleAction}
  998. @click=${hc}
  999. >
  1000. <ha-icon-button
  1001. slot="trigger"
  1002. .label=${this.hass.localize("ui.common.menu")}
  1003. .path=${ma}
  1004. >
  1005. </ha-icon-button>
  1006. <mwc-list-item graphic="icon">
  1007. ${this.hass.localize("ui.panel.config.automation.editor.conditions.rename")}
  1008. <ha-svg-icon slot="graphic" .path=${fa}></ha-svg-icon>
  1009. </mwc-list-item>
  1010. <mwc-list-item graphic="icon">
  1011. ${this.hass.localize("ui.panel.config.automation.editor.actions.duplicate")}
  1012. <ha-svg-icon
  1013. slot="graphic"
  1014. .path=${ga}
  1015. ></ha-svg-icon>
  1016. </mwc-list-item>
  1017. <li divider role="separator"></li>
  1018. <mwc-list-item graphic="icon">
  1019. ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")}
  1020. ${this._yamlMode?"":x`<ha-svg-icon
  1021. slot="graphic"
  1022. .path=${_a}
  1023. ></ha-svg-icon>`}
  1024. </mwc-list-item>
  1025. <mwc-list-item graphic="icon">
  1026. ${this.hass.localize("ui.panel.config.automation.editor.edit_yaml")}
  1027. ${this._yamlMode?x`<ha-svg-icon
  1028. slot="graphic"
  1029. .path=${_a}
  1030. ></ha-svg-icon>`:""}
  1031. </mwc-list-item>
  1032. <li divider role="separator"></li>
  1033. <mwc-list-item graphic="icon">
  1034. ${!1===this.condition.enabled?this.hass.localize("ui.panel.config.automation.editor.actions.enable"):this.hass.localize("ui.panel.config.automation.editor.actions.disable")}
  1035. <ha-svg-icon
  1036. slot="graphic"
  1037. .path=${!1===this.condition.enabled?ya:ka}
  1038. ></ha-svg-icon>
  1039. </mwc-list-item>
  1040. <mwc-list-item class="warning" graphic="icon">
  1041. ${this.hass.localize("ui.panel.config.automation.editor.actions.delete")}
  1042. <ha-svg-icon
  1043. class="warning"
  1044. slot="graphic"
  1045. .path=${ea}
  1046. ></ha-svg-icon>
  1047. </mwc-list-item>
  1048. </ha-button-menu>
  1049. <div
  1050. class=${ba({"card-content":!0,disabled:!1===this.condition.enabled})}
  1051. >
  1052. ${this._warnings?x`<ha-alert
  1053. alert-type="warning"
  1054. .title=${this.hass.localize("ui.errors.config.editor_not_supported")}
  1055. >
  1056. ${this._warnings.length>0&&void 0!==this._warnings[0]?x` <ul>
  1057. ${this._warnings.map((e=>x`<li>${e}</li>`))}
  1058. </ul>`:""}
  1059. ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")}
  1060. </ha-alert>`:""}
  1061. <ha-automation-condition-editor
  1062. @ui-mode-not-available=${this._handleUiModeNotAvailable}
  1063. @value-changed=${this._handleChangeEvent}
  1064. .yamlMode=${this._yamlMode}
  1065. .hass=${this.hass}
  1066. .condition=${this.condition}
  1067. ></ha-automation-condition-editor>
  1068. </div>
  1069. </ha-expansion-panel>
  1070. </ha-card>
  1071. `:x``}},{kind:"method",key:"_handleUiModeNotAvailable",value:function(e){e.stopPropagation(),this._warnings=co(this.hass,e.detail).warnings,this._yamlMode||(this._yamlMode=!0)}},{kind:"method",key:"_handleChangeEvent",value:function(e){e.detail.yaml&&(this._warnings=void 0)}},{kind:"method",key:"_handleAction",value:async function(e){switch(e.detail.index){case 0:await this._renameCondition();break;case 1:o(this,"duplicate");break;case 2:this._switchUiMode(),this.expand();break;case 3:this._switchYamlMode(),this.expand();break;case 4:this._onDisable();break;case 5:this._onDelete()}}},{kind:"method",key:"_onDisable",value:function(){var e;const t=!(null===(e=this.condition.enabled)||void 0===e||e),i={...this.condition,enabled:t};o(this,"value-changed",{value:i})}},{kind:"method",key:"_onDelete",value:function(){$n(this,{text:this.hass.localize("ui.panel.config.automation.editor.conditions.delete_confirm"),dismissText:this.hass.localize("ui.common.cancel"),confirmText:this.hass.localize("ui.common.delete"),confirm:()=>{o(this,"value-changed",{value:null})}})}},{kind:"method",key:"_switchUiMode",value:function(){this._warnings=void 0,this._yamlMode=!1}},{kind:"method",key:"_switchYamlMode",value:function(){this._warnings=void 0,this._yamlMode=!0}},{kind:"method",key:"_testCondition",value:async function(e){e.preventDefault();const t=this.condition,i=e.target;if(!i.progress){i.progress=!0;try{const e=await uo(this.hass,{condition:t});if(this.condition!==t)return;if(!e.condition.valid)return void wn(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.invalid_condition"),text:e.condition.error});let a;try{a=await((e,t,i)=>e.callWS({type:"test_condition",condition:t,variables:i}))(this.hass,t)}catch(e){if(this.condition!==t)return;return void wn(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.test_failed"),text:e.message})}if(this.condition!==t)return;a.result?i.actionSuccess():i.actionError()}finally{i.progress=!1}}}},{kind:"method",key:"_renameCondition",value:async function(){const e=await Cn(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.change_alias"),inputLabel:this.hass.localize("ui.panel.config.automation.editor.conditions.alias"),inputType:"string",placeholder:us(vs(this.condition,this.hass,!0)),defaultValue:this.condition.alias,confirmText:this.hass.localize("ui.common.submit")}),t={...this.condition};e?t.alias=e:delete t.alias,o(this,"value-changed",{value:t})}},{kind:"method",key:"expand",value:function(){this.updateComplete.then((()=>{this.shadowRoot.querySelector("ha-expansion-panel").expanded=!0}))}},{kind:"get",static:!0,key:"styles",value:function(){return[ia,r`
  1072. ha-button-menu,
  1073. ha-progress-button {
  1074. --mdc-theme-text-primary-on-background: var(--primary-text-color);
  1075. }
  1076. .disabled {
  1077. opacity: 0.5;
  1078. pointer-events: none;
  1079. }
  1080. ha-expansion-panel {
  1081. --expansion-panel-summary-padding: 0 0 0 8px;
  1082. --expansion-panel-content-padding: 0;
  1083. }
  1084. .condition-icon {
  1085. color: var(--sidebar-icon-color);
  1086. padding-right: 8px;
  1087. }
  1088. .card-content {
  1089. padding: 16px;
  1090. }
  1091. .disabled-bar {
  1092. background: var(--divider-color, #e0e0e0);
  1093. text-align: center;
  1094. border-top-right-radius: var(--ha-card-border-radius);
  1095. border-top-left-radius: var(--ha-card-border-radius);
  1096. }
  1097. mwc-list-item[disabled] {
  1098. --mdc-theme-text-primary-on-background: var(--disabled-text-color);
  1099. }
  1100. `]}}]}}),g);const pc=(e,t)=>e.callWS({type:"device_automation/action/list",device_id:t}),vc=(e,t)=>e.callWS({type:"device_automation/condition/list",device_id:t}),mc=(e,t)=>e.callWS({type:"device_automation/trigger/list",device_id:t}),fc=["device_id","domain","entity_id","type","subtype","event","condition","platform"],gc=(e,t)=>{if(typeof e!=typeof t)return!1;for(const i in e)if(fc.includes(i)&&!Object.is(e[i],t[i]))return!1;for(const i in t)if(fc.includes(i)&&!Object.is(e[i],t[i]))return!1;return!0},_c=(e,t)=>{const i=t.entity_id?e.states[t.entity_id]:void 0;return e.localize(`component.${t.domain}.device_automation.action_type.${t.type}`,"entity_name",i?bo(i):t.entity_id||"<unknown>","subtype",t.subtype?e.localize(`component.${t.domain}.device_automation.action_subtype.${t.subtype}`)||t.subtype:"")||(t.subtype?`"${t.subtype}" ${t.type}`:t.type)},yc=(e,t)=>{const i=t.entity_id?e.states[t.entity_id]:void 0;return e.localize(`component.${t.domain}.device_automation.condition_type.${t.type}`,"entity_name",i?bo(i):t.entity_id||"<unknown>","subtype",t.subtype?e.localize(`component.${t.domain}.device_automation.condition_subtype.${t.subtype}`)||t.subtype:"")||(t.subtype?`"${t.subtype}" ${t.type}`:t.type)},kc=(e,t)=>{const i=t.entity_id?e.states[t.entity_id]:void 0;return e.localize(`component.${t.domain}.device_automation.trigger_type.${t.type}`,"entity_name",i?bo(i):t.entity_id||"<unknown>","subtype",t.subtype?e.localize(`component.${t.domain}.device_automation.trigger_subtype.${t.subtype}`)||t.subtype:"")||(t.subtype?`"${t.subtype}" ${t.type}`:t.type)},bc=(e,t)=>{var i,a,n,o;return null===(i=e.metadata)||void 0===i||!i.secondary||null!==(a=t.metadata)&&void 0!==a&&a.secondary?null!==(n=e.metadata)&&void 0!==n&&n.secondary||null===(o=t.metadata)||void 0===o||!o.secondary?0:-1:1},xc="NO_AUTOMATION",$c="UNKNOWN_AUTOMATION";let wc=f(null,(function(e,t){class i extends t{constructor(t,i,a){super(),e(this),this._localizeDeviceAutomation=t,this._fetchDeviceAutomations=i,this._createNoAutomation=a}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"deviceId",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[Qi()],key:"_automations",value:()=>[]},{kind:"field",decorators:[Qi()],key:"_renderEmpty",value:()=>!1},{kind:"get",key:"NO_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.actions.no_actions")}},{kind:"get",key:"UNKNOWN_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.actions.unknown_action")}},{kind:"field",key:"_localizeDeviceAutomation",value:void 0},{kind:"field",key:"_fetchDeviceAutomations",value:void 0},{kind:"field",key:"_createNoAutomation",value:void 0},{kind:"get",key:"_value",value:function(){if(!this.value)return"";if(!this._automations.length)return xc;const e=this._automations.findIndex((e=>gc(e,this.value)));return-1===e?$c:`${this._automations[e].device_id}_${e}`}},{kind:"method",key:"render",value:function(){if(this._renderEmpty)return x``;const e=this._value;return x`
  1101. <ha-select
  1102. .label=${this.label}
  1103. .value=${e}
  1104. @selected=${this._automationChanged}
  1105. .disabled=${0===this._automations.length}
  1106. >
  1107. ${e===xc?x`<mwc-list-item .value=${xc}>
  1108. ${this.NO_AUTOMATION_TEXT}
  1109. </mwc-list-item>`:""}
  1110. ${e===$c?x`<mwc-list-item .value=${$c}>
  1111. ${this.UNKNOWN_AUTOMATION_TEXT}
  1112. </mwc-list-item>`:""}
  1113. ${this._automations.map(((e,t)=>x`
  1114. <mwc-list-item .value=${`${e.device_id}_${t}`}>
  1115. ${this._localizeDeviceAutomation(this.hass,e)}
  1116. </mwc-list-item>
  1117. `))}
  1118. </ha-select>
  1119. `}},{kind:"method",key:"updated",value:function(e){k(b(i.prototype),"updated",this).call(this,e),e.has("deviceId")&&this._updateDeviceInfo()}},{kind:"method",key:"_updateDeviceInfo",value:async function(){this._automations=this.deviceId?(await this._fetchDeviceAutomations(this.hass,this.deviceId)).sort(bc):[],this.value&&this.value.device_id===this.deviceId||this._setValue(this._automations.length?this._automations[0]:this._createNoAutomation(this.deviceId)),this._renderEmpty=!0,await this.updateComplete,this._renderEmpty=!1}},{kind:"method",key:"_automationChanged",value:function(e){const t=e.target.value;if(!t||[$c,xc].includes(t))return;const[i,a]=t.split("_"),n=this._automations[a];n.device_id===i&&this._setValue(n)}},{kind:"method",key:"_setValue",value:function(e){if(this.value&&gc(e,this.value))return;const t={...e};delete t.metadata,o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1120. ha-select {
  1121. display: block;
  1122. }
  1123. `}}]}}),g);f([A("ha-device-condition-picker")],(function(e,t){return{F:class extends t{constructor(){super(yc,vc,(e=>({device_id:e||"",condition:"device",domain:"",entity_id:""}))),e(this)}},d:[{kind:"get",key:"NO_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.conditions.no_conditions")}},{kind:"get",key:"UNKNOWN_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.conditions.unknown_condition")}}]}}),wc);const Cc=e=>e.sendMessagePromise({type:"config/area_registry/list"}).then((e=>e.sort(((e,t)=>_s(e.name,t.name))))),Ac=(e,t)=>e.subscribeEvents(un((()=>Cc(e).then((e=>t.setState(e,!0)))),500,!0),"area_registry_updated"),Ic=(e,t)=>xa("_areaRegistry",Cc,Ac,e,t),Ec=(e,t,i)=>e.name_by_user||e.name||i&&((e,t)=>{for(const i of t||[]){const t="string"==typeof i?i:i.entity_id,a=e.states[t];if(a)return bo(a)}})(t,i)||t.localize("ui.panel.config.devices.unnamed_device","type",t.localize(`ui.panel.config.devices.type.${e.entry_type||"device"}`)),zc=e=>e.sendMessagePromise({type:"config/device_registry/list"}),Sc=(e,t)=>e.subscribeEvents(un((()=>zc(e).then((e=>t.setState(e,!0)))),500,!0),"device_registry_updated"),Tc=(e,t)=>xa("_dr",zc,Sc,e,t),Lc=(e,t)=>{const i={};for(const a of t){const t=e[a.entity_id];null!=t&&t.domain&&null!==a.device_id&&(i[a.device_id]||(i[a.device_id]=[]),i[a.device_id].push(t.domain))}return i},Oc=e=>e.sendMessagePromise({type:"config/entity_registry/list"}),Mc=(e,t)=>e.subscribeEvents(un((()=>Oc(e).then((e=>t.setState(e,!0)))),500,!0),"entity_registry_updated"),Pc=(e,t)=>xa("_entityRegistry",Oc,Mc,e,t),Fc=e=>f(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",key:"hassSubscribeRequiredHostProps",value:void 0},{kind:"field",key:"__unsubs",value:void 0},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this),this.__checkSubscribed()}},{kind:"method",key:"disconnectedCallback",value:function(){if(k(b(i.prototype),"disconnectedCallback",this).call(this),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then((e=>e())):e()}this.__unsubs=void 0}}},{kind:"method",key:"updated",value:function(e){if(k(b(i.prototype),"updated",this).call(this,e),e.has("hass"))this.__checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const t of e.keys())if(this.hassSubscribeRequiredHostProps.includes(t))return void this.__checkSubscribed()}},{kind:"method",key:"hassSubscribe",value:function(){return[]}},{kind:"method",key:"__checkSubscribed",value:function(){var e;void 0!==this.__unsubs||!this.isConnected||void 0===this.hass||null!==(e=this.hassSubscribeRequiredHostProps)&&void 0!==e&&e.some((e=>void 0===this[e]))||(this.__unsubs=this.hassSubscribe())}}]}}),e),Dc=e=>x`<mwc-list-item
  1124. .twoline=${!!e.area}
  1125. >
  1126. <span>${e.name}</span>
  1127. <span slot="secondary">${e.area}</span>
  1128. </mwc-list-item>`;f([A("ha-device-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"devices",value:void 0},{kind:"field",decorators:[_()],key:"areas",value:void 0},{kind:"field",decorators:[_()],key:"entities",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_()],key:"deviceFilter",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[Qi()],key:"_opened",value:void 0},{kind:"field",decorators:[y("ha-combo-box",!0)],key:"comboBox",value:void 0},{kind:"field",key:"_init",value:()=>!1},{kind:"field",key:"_getDevices",value(){return n(((e,t,i,a,n,o,s)=>{if(!e.length)return[{id:"no_devices",area:"",name:this.hass.localize("ui.components.device-picker.no_devices")}];const r={};if(a||n||o)for(const e of i)e.device_id&&(e.device_id in r||(r[e.device_id]=[]),r[e.device_id].push(e));const l={};for(const e of t)l[e.area_id]=e;let d=e.filter((e=>e.id===this.value||!e.disabled_by));a&&(d=d.filter((e=>{const t=r[e.id];return!(!t||!t.length)&&r[e.id].some((e=>a.includes(gs(e.entity_id))))}))),n&&(d=d.filter((e=>{const t=r[e.id];return!t||!t.length||i.every((e=>!n.includes(gs(e.entity_id))))}))),o&&(d=d.filter((e=>{const t=r[e.id];return!(!t||!t.length)&&r[e.id].some((e=>{const t=this.hass.states[e.entity_id];return!!t&&(t.attributes.device_class&&o.includes(t.attributes.device_class))}))}))),s&&(d=d.filter((e=>e.id===this.value||s(e))));const c=d.map((e=>({id:e.id,name:Ec(e,this.hass,r[e.id]),area:e.area_id&&l[e.area_id]?l[e.area_id].name:this.hass.localize("ui.components.device-picker.no_area")})));return c.length?1===c.length?c:c.sort(((e,t)=>_s(e.name||"",t.name||""))):[{id:"no_devices",area:"",name:this.hass.localize("ui.components.device-picker.no_match")}]}))}},{kind:"method",key:"open",value:function(){var e;null===(e=this.comboBox)||void 0===e||e.open()}},{kind:"method",key:"focus",value:function(){var e;null===(e=this.comboBox)||void 0===e||e.focus()}},{kind:"method",key:"hassSubscribe",value:function(){return[Tc(this.hass.connection,(e=>{this.devices=e})),Ic(this.hass.connection,(e=>{this.areas=e})),Pc(this.hass.connection,(e=>{this.entities=e}))]}},{kind:"method",key:"updated",value:function(e){(!this._init&&this.devices&&this.areas&&this.entities||e.has("_opened")&&this._opened)&&(this._init=!0,this.comboBox.items=this._getDevices(this.devices,this.areas,this.entities,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter))}},{kind:"method",key:"render",value:function(){return this.devices&&this.areas&&this.entities?x`
  1129. <ha-combo-box
  1130. .hass=${this.hass}
  1131. .label=${void 0===this.label&&this.hass?this.hass.localize("ui.components.device-picker.device"):this.label}
  1132. .value=${this._value}
  1133. .helper=${this.helper}
  1134. .renderer=${Dc}
  1135. .disabled=${this.disabled}
  1136. .required=${this.required}
  1137. item-value-path="id"
  1138. item-label-path="name"
  1139. @opened-changed=${this._openedChanged}
  1140. @value-changed=${this._deviceChanged}
  1141. ></ha-combo-box>
  1142. `:x``}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_deviceChanged",value:function(e){e.stopPropagation();let t=e.detail.value;"no_devices"===t&&(t=""),t!==this._value&&this._setValue(t)}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{o(this,"value-changed",{value:e}),o(this,"change")}),0)}}]}}),Fc(g)),f([A("ha-automation-condition-device")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Object})],key:"condition",value:void 0},{kind:"field",decorators:[Qi()],key:"_deviceId",value:void 0},{kind:"field",decorators:[Qi()],key:"_capabilities",value:void 0},{kind:"field",key:"_origCondition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{device_id:"",domain:"",entity_id:""}}},{kind:"field",key:"_extraFieldsData",value:()=>n(((e,t)=>{const i={};return t.extra_fields.forEach((t=>{void 0!==e[t.name]&&(i[t.name]=e[t.name])})),i}))},{kind:"method",key:"render",value:function(){var e;const t=this._deviceId||this.condition.device_id;return x`
  1143. <ha-device-picker
  1144. .value=${t}
  1145. @value-changed=${this._devicePicked}
  1146. .hass=${this.hass}
  1147. label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type.device.label")}
  1148. ></ha-device-picker>
  1149. <ha-device-condition-picker
  1150. .value=${this.condition}
  1151. .deviceId=${t}
  1152. @value-changed=${this._deviceConditionPicked}
  1153. .hass=${this.hass}
  1154. label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type.device.condition")}
  1155. ></ha-device-condition-picker>
  1156. ${null!==(e=this._capabilities)&&void 0!==e&&e.extra_fields?x`
  1157. <ha-form
  1158. .hass=${this.hass}
  1159. .data=${this._extraFieldsData(this.condition,this._capabilities)}
  1160. .schema=${this._capabilities.extra_fields}
  1161. .computeLabel=${this._extraFieldsComputeLabelCallback(this.hass.localize)}
  1162. @value-changed=${this._extraFieldsChanged}
  1163. ></ha-form>
  1164. `:""}
  1165. `}},{kind:"method",key:"firstUpdated",value:function(){this._capabilities||this._getCapabilities(),this.condition&&(this._origCondition=this.condition)}},{kind:"method",key:"updated",value:function(e){const t=e.get("condition");t&&!gc(t,this.condition)&&this._getCapabilities()}},{kind:"method",key:"_getCapabilities",value:async function(){const e=this.condition;this._capabilities=e.domain?await((e,t)=>e.callWS({type:"device_automation/condition/capabilities",condition:t}))(this.hass,e):void 0}},{kind:"method",key:"_devicePicked",value:function(e){e.stopPropagation(),this._deviceId=e.target.value,void 0===this._deviceId&&o(this,"value-changed",{value:{...i.defaultConfig,condition:"device"}})}},{kind:"method",key:"_deviceConditionPicked",value:function(e){e.stopPropagation();let t=e.detail.value;this._origCondition&&gc(this._origCondition,t)&&(t=this._origCondition),o(this,"value-changed",{value:t})}},{kind:"method",key:"_extraFieldsChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.condition,...e.detail.value}})}},{kind:"method",key:"_extraFieldsComputeLabelCallback",value:function(e){return t=>e(`ui.panel.config.automation.editor.conditions.type.device.extra_fields.${t.name}`)||t.name}},{kind:"field",static:!0,key:"styles",value:()=>r`
  1166. ha-device-picker {
  1167. display: block;
  1168. margin-bottom: 24px;
  1169. }
  1170. `}]}}),g),f([A("ha-automation-condition-numeric_state")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:""}}},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"entity_id",required:!0,selector:{entity:{}}},{name:"attribute",selector:{attribute:{entity_id:e,hide_attributes:["access_token","auto_update","available_modes","away_mode","changed_by","code_format","color_modes","current_activity","device_class","editable","effect_list","effect","entity_picture","fan_mode","fan_modes","fan_speed_list","forecast","friendly_name","frontend_stream_type","has_date","has_time","hs_color","hvac_mode","hvac_modes","icon","media_album_name","media_artist","media_content_type","media_position_updated_at","media_title","next_dawn","next_dusk","next_midnight","next_noon","next_rising","next_setting","operation_list","operation_mode","options","preset_mode","preset_modes","release_notes","release_summary","release_url","restored","rgb_color","rgbw_color","shuffle","sound_mode_list","sound_mode","source_list","source_type","source","state_class","supported_features","swing_mode","swing_mode","swing_modes","title","token","unit_of_measurement","xy_color"]}}},{name:"above",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}},{name:"below",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}},{name:"value_template",selector:{template:{}}}]))},{kind:"method",key:"render",value:function(){const e=this._schema(this.condition.entity_id);return x`
  1171. <ha-form
  1172. .hass=${this.hass}
  1173. .data=${this.condition}
  1174. .schema=${e}
  1175. @value-changed=${this._valueChanged}
  1176. .computeLabel=${this._computeLabelCallback}
  1177. ></ha-form>
  1178. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>{switch(e.name){case"entity_id":return this.hass.localize("ui.components.entity.entity-picker.entity");case"attribute":return this.hass.localize("ui.components.entity.entity-attribute-picker.attribute");default:return this.hass.localize(`ui.panel.config.automation.editor.triggers.type.numeric_state.${e.name}`)}}}}]}}),g);const Bc=e=>{if(void 0===e)return;if("object"!=typeof e){if("string"==typeof e||isNaN(e)){const t=(null==e?void 0:e.toString().split(":"))||[];return{hours:Number(t[0])||0,minutes:Number(t[1])||0,seconds:Number(t[2])||0,milliseconds:Number(t[3])||0}}return{seconds:e}}if(!("days"in e))return e;const{days:t,minutes:i,seconds:a,milliseconds:n}=e;let o=e.hours||0;return o=(o||0)+24*(t||0),{hours:o,minutes:i,seconds:a,milliseconds:n}},Nc=no({platform:so(),id:oo(so()),enabled:oo(to())}),Vc=no({days:oo(ao()),hours:oo(ao()),minutes:oo(ao()),seconds:oo(ao())}),qc=no({alias:oo(so()),condition:io("state"),entity_id:oo(so()),attribute:oo(so()),state:oo(so()),for:oo(lo([so(),Vc]))});f([A("ha-automation-condition-state")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:"",state:""}}},{kind:"field",key:"_schema",value:()=>n(((e,t)=>[{name:"entity_id",required:!0,selector:{entity:{}}},{name:"attribute",selector:{attribute:{entity_id:e,hide_attributes:["access_token","available_modes","color_modes","editable","effect_list","entity_picture","fan_modes","fan_speed_list","forecast","friendly_name","hvac_modes","icon","operation_list","options","preset_modes","sound_mode_list","source_list","state_class","swing_modes","token"]}}},{name:"state",required:!0,selector:{state:{entity_id:e,attribute:t}}},{name:"for",selector:{duration:{}}}]))},{kind:"method",key:"shouldUpdate",value:function(e){if(e.has("condition"))try{Kn(this.condition,qc)}catch(e){return o(this,"ui-mode-not-available",e),!1}return!0}},{kind:"method",key:"render",value:function(){const e=Bc(this.condition.for),t={...this.condition,for:e},i=this._schema(this.condition.entity_id,this.condition.attribute);return x`
  1179. <ha-form
  1180. .hass=${this.hass}
  1181. .data=${t}
  1182. .schema=${i}
  1183. @value-changed=${this._valueChanged}
  1184. .computeLabel=${this._computeLabelCallback}
  1185. ></ha-form>
  1186. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;Object.keys(t).forEach((e=>void 0===t[e]||""===t[e]?delete t[e]:{})),t.state||(t.state=""),o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>{switch(e.name){case"entity_id":return this.hass.localize("ui.components.entity.entity-picker.entity");case"attribute":return this.hass.localize("ui.components.entity.entity-attribute-picker.attribute");case"for":return this.hass.localize("ui.panel.config.automation.editor.triggers.type.state.for");default:return this.hass.localize(`ui.panel.config.automation.editor.conditions.type.state.${e.name}`)}}}}]}}),g),f([A("ha-automation-condition-sun")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{}}},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"before",type:"select",required:!0,options:[["sunrise",e("ui.panel.config.automation.editor.conditions.type.sun.sunrise")],["sunset",e("ui.panel.config.automation.editor.conditions.type.sun.sunset")]]},{name:"before_offset",selector:{text:{}}},{name:"after",type:"select",required:!0,options:[["sunrise",e("ui.panel.config.automation.editor.conditions.type.sun.sunrise")],["sunset",e("ui.panel.config.automation.editor.conditions.type.sun.sunset")]]},{name:"after_offset",selector:{text:{}}}]))},{kind:"method",key:"render",value:function(){const e=this._schema(this.hass.localize);return x`
  1187. <ha-form
  1188. .schema=${e}
  1189. .data=${this.condition}
  1190. .hass=${this.hass}
  1191. .computeLabel=${this._computeLabelCallback}
  1192. @value-changed=${this._valueChanged}
  1193. ></ha-form>
  1194. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.sun.${e.name}`)}}]}}),g);const jc={fromAttribute:e=>null!==e&&(""===e||e),toAttribute:e=>"boolean"==typeof e?e?"":null:e};class Rc extends _n{constructor(){super(...arguments),this.rows=2,this.cols=20,this.charCounter=!1}render(){const e=this.charCounter&&-1!==this.maxLength,t=e&&"internal"===this.charCounter,i=e&&!t,a=!!this.helper||!!this.validationMessage||i,n={"mdc-text-field--disabled":this.disabled,"mdc-text-field--no-label":!this.label,"mdc-text-field--filled":!this.outlined,"mdc-text-field--outlined":this.outlined,"mdc-text-field--end-aligned":this.endAligned,"mdc-text-field--with-internal-counter":t};return x`
  1195. <label class="mdc-text-field mdc-text-field--textarea ${ba(n)}">
  1196. ${this.renderRipple()}
  1197. ${this.outlined?this.renderOutline():this.renderLabel()}
  1198. ${this.renderInput()}
  1199. ${this.renderCharCounter(t)}
  1200. ${this.renderLineRipple()}
  1201. </label>
  1202. ${this.renderHelperText(a,i)}
  1203. `}renderInput(){const e=this.label?"label":void 0,t=-1===this.minLength?void 0:this.minLength,i=-1===this.maxLength?void 0:this.maxLength,a=this.autocapitalize?this.autocapitalize:void 0;return x`
  1204. <textarea
  1205. aria-labelledby=${Xi(e)}
  1206. class="mdc-text-field__input"
  1207. .value="${yn(this.value)}"
  1208. rows="${this.rows}"
  1209. cols="${this.cols}"
  1210. ?disabled="${this.disabled}"
  1211. placeholder="${this.placeholder}"
  1212. ?required="${this.required}"
  1213. ?readonly="${this.readOnly}"
  1214. minlength="${Xi(t)}"
  1215. maxlength="${Xi(i)}"
  1216. name="${Xi(""===this.name?void 0:this.name)}"
  1217. inputmode="${Xi(this.inputMode)}"
  1218. autocapitalize="${Xi(a)}"
  1219. @input="${this.handleInputChange}"
  1220. @blur="${this.onInputBlur}">
  1221. </textarea>`}}$a([y("textarea")],Rc.prototype,"formElement",void 0),$a([_({type:Number})],Rc.prototype,"rows",void 0),$a([_({type:Number})],Rc.prototype,"cols",void 0),$a([_({converter:jc})],Rc.prototype,"charCounter",void 0);const Uc=r`.mdc-text-field{height:100%}.mdc-text-field__input{resize:none}`;f([A("ha-textarea")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"autogrow",value:()=>!1},{kind:"method",key:"updated",value:function(e){k(b(i.prototype),"updated",this).call(this,e),this.autogrow&&e.has("value")&&(this.mdcRoot.dataset.value=this.value+'=​"')}},{kind:"field",static:!0,key:"styles",value:()=>[kn,Uc,r`
  1222. :host([autogrow]) .mdc-text-field {
  1223. position: relative;
  1224. min-height: 74px;
  1225. min-width: 178px;
  1226. max-height: 200px;
  1227. }
  1228. :host([autogrow]) .mdc-text-field:after {
  1229. content: attr(data-value);
  1230. margin-top: 23px;
  1231. margin-bottom: 9px;
  1232. line-height: 1.5rem;
  1233. min-height: 42px;
  1234. padding: 0px 32px 0 16px;
  1235. letter-spacing: var(
  1236. --mdc-typography-subtitle1-letter-spacing,
  1237. 0.009375em
  1238. );
  1239. visibility: hidden;
  1240. white-space: pre-wrap;
  1241. }
  1242. :host([autogrow]) .mdc-text-field__input {
  1243. position: absolute;
  1244. height: calc(100% - 32px);
  1245. }
  1246. :host([autogrow]) .mdc-text-field.mdc-text-field--no-label:after {
  1247. margin-top: 16px;
  1248. margin-bottom: 16px;
  1249. }
  1250. `]}]}}),Rc),f([A("ha-automation-condition-template")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{value_template:""}}},{kind:"method",key:"render",value:function(){const{value_template:e}=this.condition;return x`
  1251. <p>
  1252. ${this.hass.localize("ui.panel.config.automation.editor.conditions.type.template.value_template")}
  1253. *
  1254. </p>
  1255. <ha-code-editor
  1256. .name=${"value_template"}
  1257. mode="jinja2"
  1258. .hass=${this.hass}
  1259. .value=${e}
  1260. autocomplete-entities
  1261. @value-changed=${this._valueChanged}
  1262. dir="ltr"
  1263. ></ha-code-editor>
  1264. `}},{kind:"method",key:"_valueChanged",value:function(e){((e,t)=>{var i,a,n;t.stopPropagation();const s=null===(i=t.currentTarget)||void 0===i?void 0:i.name;if(!s)return;const r=(null===(a=t.detail)||void 0===a?void 0:a.value)||(null===(n=t.currentTarget)||void 0===n?void 0:n.value);if((e.condition[s]||"")===r)return;let l;r?l={...e.condition,[s]:r}:(l={...e.condition},delete l[s]),o(e,"value-changed",{value:l})})(this,e)}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1265. p {
  1266. margin-top: 0;
  1267. }
  1268. `}}]}}),g);const Hc=["mon","tue","wed","thu","fri","sat","sun"];f([A("ha-automation-condition-time")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"field",decorators:[Qi()],key:"_inputModeBefore",value:void 0},{kind:"field",decorators:[Qi()],key:"_inputModeAfter",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{}}},{kind:"field",key:"_schema",value:()=>n(((e,t,i)=>[{name:"mode_after",type:"select",required:!0,options:[["value",e("ui.panel.config.automation.editor.conditions.type.time.type_value")],["input",e("ui.panel.config.automation.editor.conditions.type.time.type_input")]]},{name:"after",selector:t?{entity:{domain:"input_datetime"}}:{time:{}}},{name:"mode_before",type:"select",required:!0,options:[["value",e("ui.panel.config.automation.editor.conditions.type.time.type_value")],["input",e("ui.panel.config.automation.editor.conditions.type.time.type_input")]]},{name:"before",selector:i?{entity:{domain:"input_datetime"}}:{time:{}}},{type:"multi_select",name:"weekday",options:Hc.map((t=>[t,e(`ui.panel.config.automation.editor.conditions.type.time.weekdays.${t}`)]))}]))},{kind:"method",key:"render",value:function(){var e,t,i,a;const n=null!==(e=this._inputModeBefore)&&void 0!==e?e:null===(t=this.condition.before)||void 0===t?void 0:t.startsWith("input_datetime."),o=null!==(i=this._inputModeAfter)&&void 0!==i?i:null===(a=this.condition.after)||void 0===a?void 0:a.startsWith("input_datetime."),s=this._schema(this.hass.localize,o,n),r={mode_before:n?"input":"value",mode_after:o?"input":"value",...this.condition};return x`
  1269. <ha-form
  1270. .hass=${this.hass}
  1271. .data=${r}
  1272. .schema=${s}
  1273. @value-changed=${this._valueChanged}
  1274. .computeLabel=${this._computeLabelCallback}
  1275. ></ha-form>
  1276. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;this._inputModeAfter="input"===t.mode_after,this._inputModeBefore="input"===t.mode_before,delete t.mode_after,delete t.mode_before,Object.keys(t).forEach((e=>void 0===t[e]||""===t[e]?delete t[e]:{})),o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.time.${e.name}`)}}]}}),g),f([A("ha-automation-condition-trigger")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"field",decorators:[Qi()],key:"_triggers",value:()=>[]},{kind:"field",key:"_unsub",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{id:""}}},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this);const e={callback:e=>this._automationUpdated(e)};o(this,"subscribe-automation-config",e),this._unsub=e.unsub}},{kind:"method",key:"disconnectedCallback",value:function(){k(b(i.prototype),"disconnectedCallback",this).call(this),this._unsub&&this._unsub()}},{kind:"method",key:"render",value:function(){const{id:e}=this.condition;return this._triggers.length?x`<ha-select
  1277. .label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type.trigger.id")}
  1278. .value=${e}
  1279. @selected=${this._triggerPicked}
  1280. >
  1281. ${this._triggers.map((e=>x`
  1282. <mwc-list-item .value=${e.id}> ${e.id} </mwc-list-item>
  1283. `))}
  1284. </ha-select>`:this.hass.localize("ui.panel.config.automation.editor.conditions.type.trigger.no_triggers")}},{kind:"method",key:"_automationUpdated",value:function(e){this._triggers=null!=e&&e.trigger?ko(e.trigger).filter((e=>e.id)):[]}},{kind:"method",key:"_triggerPicked",value:function(e){if(e.stopPropagation(),!e.target.value)return;const t=e.target.value;this.condition.id!==t&&o(this,"value-changed",{value:{...this.condition,id:t}})}}]}}),g);const Gc=e=>"latitude"in e.attributes&&"longitude"in e.attributes;function Wc(e){return Gc(e)&&"zone"!==Hr(e)}const Kc=["zone"];f([A("ha-automation-condition-zone")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:"",zone:""}}},{kind:"method",key:"render",value:function(){const{entity_id:e,zone:t}=this.condition;return x`
  1285. <ha-entity-picker
  1286. .label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type.zone.entity")}
  1287. .value=${e}
  1288. @value-changed=${this._entityPicked}
  1289. .hass=${this.hass}
  1290. allow-custom-entity
  1291. .entityFilter=${Wc}
  1292. ></ha-entity-picker>
  1293. <ha-entity-picker
  1294. .label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type.zone.zone")}
  1295. .value=${t}
  1296. @value-changed=${this._zonePicked}
  1297. .hass=${this.hass}
  1298. allow-custom-entity
  1299. .includeDomains=${Kc}
  1300. ></ha-entity-picker>
  1301. <label id="eventlabel">
  1302. ${this.hass.localize("ui.panel.config.automation.editor.conditions.type.zone.event")}
  1303. </label>
  1304. `}},{kind:"method",key:"_entityPicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.condition,entity_id:e.detail.value}})}},{kind:"method",key:"_zonePicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.condition,zone:e.detail.value}})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  1305. ha-entity-picker:first-child {
  1306. display: block;
  1307. margin-bottom: 24px;
  1308. }
  1309. `}]}}),g),f([A("ha-automation-condition")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"conditions",value:void 0},{kind:"field",key:"_focusLastConditionOnChange",value:()=>!1},{kind:"field",key:"_conditionKeys",value:()=>new WeakMap},{kind:"method",key:"updated",value:function(e){if(!e.has("conditions"))return;let t;if(Array.isArray(this.conditions)||(t=[this.conditions]),(t||this.conditions).forEach(((e,i)=>{"string"==typeof e&&(t=t||[...this.conditions],t[i]={condition:"template",value_template:e})})),t)o(this,"value-changed",{value:t});else if(this._focusLastConditionOnChange){this._focusLastConditionOnChange=!1;const e=this.shadowRoot.querySelector("ha-automation-condition-row:last-of-type");e.updateComplete.then((()=>{e.expand(),e.scrollIntoView(),e.focus()}))}}},{kind:"method",key:"render",value:function(){return Array.isArray(this.conditions)?x`
  1310. ${Nn(this.conditions,(e=>this._getKey(e)),((e,t)=>x`
  1311. <ha-automation-condition-row
  1312. .index=${t}
  1313. .condition=${e}
  1314. @duplicate=${this._duplicateCondition}
  1315. @value-changed=${this._conditionChanged}
  1316. .hass=${this.hass}
  1317. ></ha-automation-condition-row>
  1318. `))}
  1319. <ha-button-menu fixed @action=${this._addCondition}>
  1320. <mwc-button
  1321. slot="trigger"
  1322. outlined
  1323. .label=${this.hass.localize("ui.panel.config.automation.editor.conditions.add")}
  1324. >
  1325. <ha-svg-icon .path=${ta} slot="icon"></ha-svg-icon>
  1326. </mwc-button>
  1327. ${this._processedTypes(this.hass.localize).map((([e,t,i])=>x`
  1328. <mwc-list-item .value=${e} aria-label=${t} graphic="icon">
  1329. ${t}<ha-svg-icon slot="graphic" .path=${i}></ha-svg-icon
  1330. ></mwc-list-item>
  1331. `))}
  1332. </ha-button-menu>
  1333. `:x``}},{kind:"method",key:"_getKey",value:function(e){return this._conditionKeys.has(e)||this._conditionKeys.set(e,Math.random().toString()),this._conditionKeys.get(e)}},{kind:"method",key:"_addCondition",value:function(e){const t=e.currentTarget.items[e.detail.index].value,i=customElements.get(`ha-automation-condition-${t}`),a=this.conditions.concat({condition:t,...i.defaultConfig});this._focusLastConditionOnChange=!0,o(this,"value-changed",{value:a})}},{kind:"method",key:"_conditionChanged",value:function(e){e.stopPropagation();const t=[...this.conditions],i=e.detail.value,a=e.target.index;if(null===i)t.splice(a,1);else{const e=this._getKey(t[a]);this._conditionKeys.set(i,e),t[a]=i}o(this,"value-changed",{value:t})}},{kind:"method",key:"_duplicateCondition",value:function(e){e.stopPropagation();const t=e.target.index;o(this,"value-changed",{value:this.conditions.concat(Vn(this.conditions[t]))})}},{kind:"field",key:"_processedTypes",value:()=>n((e=>Object.entries(cl).map((([t,i])=>[t,e(`ui.panel.config.automation.editor.conditions.type.${t}.label`),i])).sort(((e,t)=>_s(e[1],t[1])))))},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1334. ha-automation-condition-row {
  1335. display: block;
  1336. margin-bottom: 16px;
  1337. scroll-margin-top: 48px;
  1338. }
  1339. ha-svg-icon {
  1340. height: 20px;
  1341. }
  1342. `}}]}}),g);let Yc=f([A("ha-automation-condition-logical")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{conditions:[]}}},{kind:"method",key:"render",value:function(){return x`
  1343. <ha-automation-condition
  1344. .conditions=${this.condition.conditions||[]}
  1345. @value-changed=${this._valueChanged}
  1346. .hass=${this.hass}
  1347. ></ha-automation-condition>
  1348. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.condition,conditions:e.detail.value}})}}]}}),g);f([A("ha-automation-condition-and")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[]}}),Yc),f([A("ha-automation-condition-not")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[]}}),Yc),f([A("ha-automation-condition-or")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[]}}),Yc),f([A("ha-automation-condition-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"condition",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"yamlMode",value:()=>!1},{kind:"field",key:"_processedCondition",value:()=>n((e=>(e=>{if("condition"in e&&Array.isArray(e.condition))return{condition:"and",conditions:e.condition};for(const t of["and","or","not"])if(t in e)return{condition:t,conditions:e[t]};return e})(e)))},{kind:"method",key:"render",value:function(){const e=this._processedCondition(this.condition),t=void 0!==customElements.get(`ha-automation-condition-${e.condition}`),i=this.yamlMode||!t;return x`
  1349. ${i?x`
  1350. ${t?"":x`
  1351. ${this.hass.localize("ui.panel.config.automation.editor.conditions.unsupported_condition","condition",e.condition)}
  1352. `}
  1353. <ha-yaml-editor
  1354. .hass=${this.hass}
  1355. .defaultValue=${this.condition}
  1356. @value-changed=${this._onYamlChange}
  1357. ></ha-yaml-editor>
  1358. `:x`
  1359. <div>
  1360. ${hn(`ha-automation-condition-${e.condition}`,{hass:this.hass,condition:e})}
  1361. </div>
  1362. `}
  1363. `}},{kind:"method",key:"_onYamlChange",value:function(e){e.stopPropagation(),e.detail.isValid&&o(this,"value-changed",{value:e.detail.value,yaml:!0})}},{kind:"field",static:!0,key:"styles",value:()=>ia}]}}),g),f([A("ha-automation-action-condition")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{condition:"state"}}},{kind:"method",key:"render",value:function(){return x`
  1364. <ha-select
  1365. fixedMenuPosition
  1366. .label=${this.hass.localize("ui.panel.config.automation.editor.conditions.type_select")}
  1367. .value=${this.action.condition}
  1368. naturalMenuWidth
  1369. @selected=${this._typeChanged}
  1370. >
  1371. ${this._processedTypes(this.hass.localize).map((([e,t,i])=>x`
  1372. <mwc-list-item .value=${e} aria-label=${t} graphic="icon">
  1373. ${t}<ha-svg-icon slot="graphic" .path=${i}></ha-svg-icon
  1374. ></mwc-list-item>
  1375. `))}
  1376. </ha-select>
  1377. <ha-automation-condition-editor
  1378. .condition=${this.action}
  1379. .hass=${this.hass}
  1380. @value-changed=${this._conditionChanged}
  1381. ></ha-automation-condition-editor>
  1382. `}},{kind:"field",key:"_processedTypes",value:()=>n((e=>Object.entries(cl).map((([t,i])=>[t,e(`ui.panel.config.automation.editor.conditions.type.${t}.label`),i])).sort(((e,t)=>_s(e[1],t[1])))))},{kind:"method",key:"_conditionChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:e.detail.value})}},{kind:"method",key:"_typeChanged",value:function(e){const t=e.target.value;if(!t)return;const i=customElements.get(`ha-automation-condition-${t}`);t!==this.action.condition&&o(this,"value-changed",{value:{condition:t,...i.defaultConfig}})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1383. ha-select {
  1384. margin-bottom: 24px;
  1385. }
  1386. `}}]}}),g),f([A("ha-automation-action-delay")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"field",decorators:[Qi()],key:"_timeData",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{delay:""}}},{kind:"method",key:"willUpdate",value:function(e){e.has("action")&&(this.action&&wo(this.action)?o(this,"ui-mode-not-available",Error(this.hass.localize("ui.errors.config.no_template_editor_support"))):this._timeData=Bc(this.action.delay))}},{kind:"method",key:"render",value:function(){return x`<ha-duration-input
  1387. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.delay.delay")}
  1388. .data=${this._timeData}
  1389. enableMillisecond
  1390. @value-changed=${this._valueChanged}
  1391. ></ha-duration-input>`}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t&&o(this,"value-changed",{value:{...this.action,delay:t}})}}]}}),g),f([A("ha-device-action-picker")],(function(e,t){return{F:class extends t{constructor(){super(_c,pc,(e=>({device_id:e||"",domain:"",entity_id:""}))),e(this)}},d:[{kind:"get",key:"NO_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.actions.no_actions")}},{kind:"get",key:"UNKNOWN_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.actions.unknown_action")}}]}}),wc),f([A("ha-automation-action-device_id")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Object})],key:"action",value:void 0},{kind:"field",decorators:[Qi()],key:"_deviceId",value:void 0},{kind:"field",decorators:[Qi()],key:"_capabilities",value:void 0},{kind:"field",key:"_origAction",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{device_id:"",domain:"",entity_id:""}}},{kind:"field",key:"_extraFieldsData",value:()=>n(((e,t)=>{const i={};return t.extra_fields.forEach((t=>{void 0!==e[t.name]&&(i[t.name]=e[t.name])})),i}))},{kind:"method",key:"render",value:function(){var e;const t=this._deviceId||this.action.device_id;return x`
  1392. <ha-device-picker
  1393. .value=${t}
  1394. @value-changed=${this._devicePicked}
  1395. .hass=${this.hass}
  1396. label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.device_id.label")}
  1397. ></ha-device-picker>
  1398. <ha-device-action-picker
  1399. .value=${this.action}
  1400. .deviceId=${t}
  1401. @value-changed=${this._deviceActionPicked}
  1402. .hass=${this.hass}
  1403. label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.device_id.action")}
  1404. ></ha-device-action-picker>
  1405. ${null!==(e=this._capabilities)&&void 0!==e&&e.extra_fields?x`
  1406. <ha-form
  1407. .hass=${this.hass}
  1408. .data=${this._extraFieldsData(this.action,this._capabilities)}
  1409. .schema=${this._capabilities.extra_fields}
  1410. .computeLabel=${this._extraFieldsComputeLabelCallback(this.hass.localize)}
  1411. @value-changed=${this._extraFieldsChanged}
  1412. ></ha-form>
  1413. `:""}
  1414. `}},{kind:"method",key:"firstUpdated",value:function(){this._capabilities||this._getCapabilities(),this.action&&(this._origAction=this.action)}},{kind:"method",key:"updated",value:function(e){const t=e.get("action");t&&!gc(t,this.action)&&(this._deviceId=void 0,this._getCapabilities())}},{kind:"method",key:"_getCapabilities",value:async function(){var e,t;this._capabilities=this.action.domain?await(e=this.hass,t=this.action,e.callWS({type:"device_automation/action/capabilities",action:t})):void 0}},{kind:"method",key:"_devicePicked",value:function(e){e.stopPropagation(),this._deviceId=e.target.value,void 0===this._deviceId&&o(this,"value-changed",{value:i.defaultConfig})}},{kind:"method",key:"_deviceActionPicked",value:function(e){e.stopPropagation();let t=e.detail.value;this._origAction&&gc(this._origAction,t)&&(t=this._origAction),o(this,"value-changed",{value:t})}},{kind:"method",key:"_extraFieldsChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.action,...e.detail.value}})}},{kind:"method",key:"_extraFieldsComputeLabelCallback",value:function(e){return t=>e(`ui.panel.config.automation.editor.actions.type.device_id.extra_fields.${t.name}`)||t.name}},{kind:"field",static:!0,key:"styles",value:()=>r`
  1415. ha-device-picker {
  1416. display: block;
  1417. margin-bottom: 16px;
  1418. }
  1419. ha-device-action-picker {
  1420. display: block;
  1421. }
  1422. `}]}}),g);const Zc=(e,t,i)=>e(`component.${t}.title`)||(null==i?void 0:i.name)||t,Qc=e=>x`<mwc-list-item twoline>
  1423. <span>${e.name}</span>
  1424. <span slot="secondary"
  1425. >${e.name===e.service?"":e.service}</span
  1426. >
  1427. </mwc-list-item>`;let Jc=f(null,(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[Qi()],key:"_filter",value:void 0},{kind:"method",key:"render",value:function(){return x`
  1428. <ha-combo-box
  1429. .hass=${this.hass}
  1430. .label=${this.hass.localize("ui.components.service-picker.service")}
  1431. .filteredItems=${this._filteredServices(this.hass.localize,this.hass.services,this._filter)}
  1432. .value=${this.value}
  1433. .renderer=${Qc}
  1434. item-value-path="service"
  1435. item-label-path="name"
  1436. allow-custom-value
  1437. @filter-changed=${this._filterChanged}
  1438. @value-changed=${this._valueChanged}
  1439. ></ha-combo-box>
  1440. `}},{kind:"field",key:"_services",value:()=>n(((e,t)=>{if(!t)return[];const i=[];return Object.keys(t).sort().forEach((a=>{const n=Object.keys(t[a]).sort();for(const o of n)i.push({service:`${a}.${o}`,name:`${Zc(e,a)}: ${t[a][o].name||o}`})})),i}))},{kind:"field",key:"_filteredServices",value(){return n(((e,t,i)=>{if(!t)return[];const a=this._services(e,t);return i?a.filter((e=>{var t;return e.service.toLowerCase().includes(i)||(null===(t=e.name)||void 0===t?void 0:t.toLowerCase().includes(i))})):a}))}},{kind:"method",key:"_filterChanged",value:function(e){this._filter=e.detail.value.toLowerCase()}},{kind:"method",key:"_valueChanged",value:function(e){this.value=e.detail.value,o(this,"change"),o(this,"value-changed",{value:this.value})}}]}}),g);customElements.define("ha-service-picker",Jc),f([A("ha-automation-action-event")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"field",decorators:[y("ha-yaml-editor",!0)],key:"_yamlEditor",value:void 0},{kind:"field",key:"_actionData",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{event:"",event_data:{}}}},{kind:"method",key:"updated",value:function(e){e.has("action")&&(this._actionData&&this._actionData!==this.action.event_data&&this._yamlEditor&&this._yamlEditor.setValue(this.action.event_data),this._actionData=this.action.event_data)}},{kind:"method",key:"render",value:function(){const{event:e,event_data:t}=this.action;return x`
  1441. <ha-textfield
  1442. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.event.event")}
  1443. .value=${e}
  1444. @change=${this._eventChanged}
  1445. ></ha-textfield>
  1446. <ha-yaml-editor
  1447. .hass=${this.hass}
  1448. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.event.event_data")}
  1449. .name=${"event_data"}
  1450. .defaultValue=${t}
  1451. @value-changed=${this._dataChanged}
  1452. ></ha-yaml-editor>
  1453. `}},{kind:"method",key:"_dataChanged",value:function(e){e.stopPropagation(),e.detail.isValid&&(this._actionData=e.detail.value,Iu(this,e))}},{kind:"method",key:"_eventChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.action,event:e.target.value}})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1454. ha-textfield {
  1455. display: block;
  1456. }
  1457. `}}]}}),g),f([A("ha-automation-action-if")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{if:[],then:[]}}},{kind:"method",key:"render",value:function(){const e=this.action;return x`
  1458. <h3>
  1459. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.if.if")}*:
  1460. </h3>
  1461. <ha-automation-condition
  1462. .conditions=${e.if}
  1463. .hass=${this.hass}
  1464. @value-changed=${this._ifChanged}
  1465. ></ha-automation-condition>
  1466. <h3>
  1467. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.if.then")}*:
  1468. </h3>
  1469. <ha-automation-action
  1470. .actions=${e.then}
  1471. @value-changed=${this._thenChanged}
  1472. .hass=${this.hass}
  1473. ></ha-automation-action>
  1474. <h3>
  1475. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.if.else")}:
  1476. </h3>
  1477. <ha-automation-action
  1478. .actions=${e.else||[]}
  1479. @value-changed=${this._elseChanged}
  1480. .hass=${this.hass}
  1481. ></ha-automation-action>
  1482. `}},{kind:"method",key:"_ifChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{...this.action,if:t}})}},{kind:"method",key:"_thenChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{...this.action,then:t}})}},{kind:"method",key:"_elseChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{...this.action,else:t}})}},{kind:"get",static:!0,key:"styles",value:function(){return ia}}]}}),g),f([A("ha-automation-action-parallel")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{parallel:[]}}},{kind:"method",key:"render",value:function(){const e=this.action;return x`
  1483. <ha-automation-action
  1484. .actions=${e.parallel}
  1485. @value-changed=${this._actionsChanged}
  1486. .hass=${this.hass}
  1487. ></ha-automation-action>
  1488. `}},{kind:"method",key:"_actionsChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{...this.action,parallel:t}})}},{kind:"get",static:!0,key:"styles",value:function(){return ia}}]}}),g);const Xc="browser",eu={album:{icon:wa,layout:"grid"},app:{icon:Ca,layout:"grid"},artist:{icon:Aa,layout:"grid",show_list_images:!0},channel:{icon:Ia,thumbnail_ratio:"portrait",layout:"grid"},composer:{icon:Ea,layout:"grid",show_list_images:!0},contributing_artist:{icon:Aa,layout:"grid",show_list_images:!0},directory:{icon:za,layout:"grid",show_list_images:!0},episode:{icon:Ia,layout:"grid",thumbnail_ratio:"portrait"},game:{icon:Sa,layout:"grid",thumbnail_ratio:"portrait"},genre:{icon:Ta,layout:"grid",show_list_images:!0},image:{icon:La,layout:"grid"},movie:{icon:Oa,thumbnail_ratio:"portrait",layout:"grid"},music:{icon:Ma},playlist:{icon:Pa,layout:"grid",show_list_images:!0},podcast:{icon:Fa,layout:"grid"},season:{icon:Ia,layout:"grid",thumbnail_ratio:"portrait"},track:{icon:Da},tv_show:{icon:Ia,layout:"grid",thumbnail_ratio:"portrait"},url:{icon:Ba},video:{icon:L,layout:"grid"}},tu=(e,t,i,a)=>e.callWS({type:"media_player/browse_media",entity_id:t,media_content_id:i,media_content_type:a}),iu=[{name:"media_content_id",required:!1,selector:{text:{}}},{name:"media_content_type",required:!1,selector:{text:{}}}];f([A("ha-selector-media")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"required",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_thumbnailUrl",value:void 0},{kind:"method",key:"willUpdate",value:function(e){if(e.has("value")){var t,i,a,n;const s=null===(t=this.value)||void 0===t||null===(i=t.metadata)||void 0===i?void 0:i.thumbnail;if(s===(null===(a=e.get("value"))||void 0===a||null===(n=a.metadata)||void 0===n?void 0:n.thumbnail))return;if(s&&s.startsWith("/"))this._thumbnailUrl=void 0,Wr(this.hass,s).then((e=>{this._thumbnailUrl=e.path}));else if(s&&s.startsWith("https://brands.home-assistant.io")){var o;this._thumbnailUrl=An({domain:In(s),type:"icon",useFallback:!0,darkOptimized:null===(o=this.hass.themes)||void 0===o?void 0:o.darkMode})}else this._thumbnailUrl=s}}},{kind:"method",key:"render",value:function(){var e,t,i,a,n,o,s,r,l,d,c,u,h;const p=null!==(e=this.value)&&void 0!==e&&e.entity_id?this.hass.states[this.value.entity_id]:void 0,v=!(null!==(t=this.value)&&void 0!==t&&t.entity_id)||p&&((e,t)=>Qr(e.attributes,t))(p,131072);return x`<ha-entity-picker
  1489. .hass=${this.hass}
  1490. .value=${null===(i=this.value)||void 0===i?void 0:i.entity_id}
  1491. .label=${this.label||this.hass.localize("ui.components.selectors.media.pick_media_player")}
  1492. .disabled=${this.disabled}
  1493. .helper=${this.helper}
  1494. .required=${this.required}
  1495. include-domains='["media_player"]'
  1496. allow-custom-entity
  1497. @value-changed=${this._entityChanged}
  1498. ></ha-entity-picker>
  1499. ${v?x`<ha-card
  1500. outlined
  1501. @click=${this._pickMedia}
  1502. class=${this.disabled||null===(a=this.value)||void 0===a||!a.entity_id?"disabled":""}
  1503. >
  1504. <div
  1505. class="thumbnail ${ba({portrait:!(null===(n=this.value)||void 0===n||null===(o=n.metadata)||void 0===o||!o.media_class)&&"portrait"===eu[this.value.metadata.children_media_class||this.value.metadata.media_class].thumbnail_ratio})}"
  1506. >
  1507. ${null!==(s=this.value)&&void 0!==s&&null!==(r=s.metadata)&&void 0!==r&&r.thumbnail?x`
  1508. <div
  1509. class="${ba({"centered-image":!!this.value.metadata.media_class&&["app","directory"].includes(this.value.metadata.media_class)})}
  1510. image"
  1511. style=${this._thumbnailUrl?`background-image: url(${this._thumbnailUrl});`:""}
  1512. ></div>
  1513. `:x`
  1514. <div class="icon-holder image">
  1515. <ha-svg-icon
  1516. class="folder"
  1517. .path=${null!==(l=this.value)&&void 0!==l&&l.media_content_id?null!==(d=this.value)&&void 0!==d&&null!==(c=d.metadata)&&void 0!==c&&c.media_class?eu["directory"===this.value.metadata.media_class&&this.value.metadata.children_media_class||this.value.metadata.media_class].icon:Na:ta}
  1518. ></ha-svg-icon>
  1519. </div>
  1520. `}
  1521. </div>
  1522. <div class="title">
  1523. ${null!==(u=this.value)&&void 0!==u&&u.media_content_id?(null===(h=this.value.metadata)||void 0===h?void 0:h.title)||this.value.media_content_id:this.hass.localize("ui.components.selectors.media.pick_media")}
  1524. </div>
  1525. </ha-card>`:x`<ha-alert>
  1526. ${this.hass.localize("ui.components.selectors.media.browse_not_supported")}
  1527. </ha-alert>
  1528. <ha-form
  1529. .hass=${this.hass}
  1530. .data=${this.value}
  1531. .schema=${iu}
  1532. .computeLabel=${this._computeLabelCallback}
  1533. ></ha-form>`}`}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.components.selectors.media.${e.name}`)}},{kind:"method",key:"_entityChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{entity_id:e.detail.value,media_content_id:"",media_content_type:""}})}},{kind:"method",key:"_pickMedia",value:function(){var e,t,i;t=this,i={action:"pick",entityId:this.value.entity_id,navigateIds:null===(e=this.value.metadata)||void 0===e?void 0:e.navigateIds,mediaPickedCallback:e=>{var t;o(this,"value-changed",{value:{...this.value,media_content_id:e.item.media_content_id,media_content_type:e.item.media_content_type,metadata:{title:e.item.title,thumbnail:e.item.thumbnail,media_class:e.item.media_class,children_media_class:e.item.children_media_class,navigateIds:null===(t=e.navigateIds)||void 0===t?void 0:t.map((e=>({media_content_type:e.media_content_type,media_content_id:e.media_content_id})))}}})}},o(t,"show-dialog",{dialogTag:"dialog-media-player-browse",dialogImport:()=>import("./c.aa05d073.js").then((function(e){return e.a})),dialogParams:i})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1534. ha-entity-picker {
  1535. display: block;
  1536. margin-bottom: 16px;
  1537. }
  1538. mwc-button {
  1539. margin-top: 8px;
  1540. }
  1541. ha-alert {
  1542. display: block;
  1543. margin-bottom: 16px;
  1544. }
  1545. ha-card {
  1546. position: relative;
  1547. width: 200px;
  1548. box-sizing: border-box;
  1549. cursor: pointer;
  1550. }
  1551. ha-card.disabled {
  1552. pointer-events: none;
  1553. color: var(--disabled-text-color);
  1554. }
  1555. ha-card .thumbnail {
  1556. width: 100%;
  1557. position: relative;
  1558. box-sizing: border-box;
  1559. transition: padding-bottom 0.1s ease-out;
  1560. padding-bottom: 100%;
  1561. }
  1562. ha-card .thumbnail.portrait {
  1563. padding-bottom: 150%;
  1564. }
  1565. ha-card .image {
  1566. border-radius: 3px 3px 0 0;
  1567. }
  1568. .folder {
  1569. --mdc-icon-size: calc(var(--media-browse-item-size, 175px) * 0.4);
  1570. }
  1571. .title {
  1572. font-size: 16px;
  1573. padding-top: 16px;
  1574. overflow: hidden;
  1575. text-overflow: ellipsis;
  1576. margin-bottom: 16px;
  1577. padding-left: 16px;
  1578. padding-right: 4px;
  1579. white-space: nowrap;
  1580. }
  1581. .image {
  1582. position: absolute;
  1583. top: 0;
  1584. right: 0;
  1585. left: 0;
  1586. bottom: 0;
  1587. background-size: cover;
  1588. background-repeat: no-repeat;
  1589. background-position: center;
  1590. }
  1591. .centered-image {
  1592. margin: 0 8px;
  1593. background-size: contain;
  1594. }
  1595. .icon-holder {
  1596. display: flex;
  1597. justify-content: center;
  1598. align-items: center;
  1599. }
  1600. `}}]}}),g),f([A("ha-automation-action-play_media")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"narrow",value:()=>!1},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{service:"media_player.play_media",target:{entity_id:""},data:{media_content_id:"",media_content_type:""},metadata:{}}}},{kind:"field",key:"_getSelectorValue",value:()=>n((e=>{var t,i,a;return{entity_id:(null===(t=e.target)||void 0===t?void 0:t.entity_id)||e.entity_id,media_content_id:null===(i=e.data)||void 0===i?void 0:i.media_content_id,media_content_type:null===(a=e.data)||void 0===a?void 0:a.media_content_type,metadata:e.metadata}}))},{kind:"method",key:"render",value:function(){return x`
  1601. <ha-selector-media
  1602. .hass=${this.hass}
  1603. .value=${this._getSelectorValue(this.action)}
  1604. @value-changed=${this._valueChanged}
  1605. ></ha-selector-media>
  1606. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{service:"media_player.play_media",target:{entity_id:e.detail.value.entity_id},data:{media_content_id:e.detail.value.media_content_id,media_content_type:e.detail.value.media_content_type},metadata:e.detail.value.metadata||{}}})}}]}}),g);const au=["count","while","until"],nu=e=>au.find((t=>t in e));f([A("ha-automation-action-repeat")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{repeat:{count:2,sequence:[]}}}},{kind:"method",key:"render",value:function(){const e=this.action.repeat,t=nu(e);return x`
  1607. <ha-select
  1608. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.repeat.type_select")}
  1609. .value=${t}
  1610. @selected=${this._typeChanged}
  1611. >
  1612. ${au.map((e=>x`
  1613. <mwc-list-item .value=${e}>
  1614. ${this.hass.localize(`ui.panel.config.automation.editor.actions.type.repeat.type.${e}.label`)}
  1615. </mwc-list-item>
  1616. `))}
  1617. </ha-select>
  1618. <div>
  1619. ${"count"===t?x`
  1620. <ha-textfield
  1621. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.repeat.type.count.label")}
  1622. name="count"
  1623. .value=${e.count||"0"}
  1624. @change=${this._countChanged}
  1625. ></ha-textfield>
  1626. `:"while"===t?x` <h3>
  1627. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.repeat.type.while.conditions")}:
  1628. </h3>
  1629. <ha-automation-condition
  1630. .conditions=${e.while||[]}
  1631. .hass=${this.hass}
  1632. @value-changed=${this._conditionChanged}
  1633. ></ha-automation-condition>`:"until"===t?x` <h3>
  1634. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.repeat.type.until.conditions")}:
  1635. </h3>
  1636. <ha-automation-condition
  1637. .conditions=${e.until||[]}
  1638. .hass=${this.hass}
  1639. @value-changed=${this._conditionChanged}
  1640. ></ha-automation-condition>`:""}
  1641. </div>
  1642. <h3>
  1643. ${this.hass.localize("ui.panel.config.automation.editor.actions.type.repeat.sequence")}:
  1644. </h3>
  1645. <ha-automation-action
  1646. .actions=${e.sequence}
  1647. @value-changed=${this._actionChanged}
  1648. .hass=${this.hass}
  1649. ></ha-automation-action>
  1650. `}},{kind:"method",key:"_typeChanged",value:function(e){const t=e.target.value;if(!t||t===nu(this.action.repeat))return;o(this,"value-changed",{value:{repeat:{[t]:"count"===t?2:[],sequence:this.action.repeat.sequence}}})}},{kind:"method",key:"_conditionChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{repeat:{...this.action.repeat,[nu(this.action.repeat)]:t}}})}},{kind:"method",key:"_actionChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:{repeat:{...this.action.repeat,sequence:t}}})}},{kind:"method",key:"_countChanged",value:function(e){const t=e.target.value;this.action.repeat.count!==t&&o(this,"value-changed",{value:{repeat:{...this.action.repeat,count:t}}})}},{kind:"get",static:!0,key:"styles",value:function(){return[ia,r`
  1651. ha-textfield {
  1652. margin-top: 16px;
  1653. }
  1654. `]}}]}}),g);const ou=e=>"all"===e||(e=>e.includes("."))(e),su=(e,t)=>`https://${e.config.version.includes("b")?"rc":e.config.version.includes("dev")?"next":"www"}.home-assistant.io${t}`,ru=e=>e.selector&&!e.required&&!("boolean"in e.selector&&e.default);f([A("ha-service-control")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[Qi()],key:"_value",value:void 0},{kind:"field",decorators:[_({reflect:!0,type:Boolean})],key:"narrow",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"showAdvanced",value:void 0},{kind:"field",decorators:[Qi()],key:"_checkedKeys",value:()=>new Set},{kind:"field",decorators:[Qi()],key:"_manifest",value:void 0},{kind:"field",decorators:[y("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"method",key:"willUpdate",value:function(e){var t,i,a,n,s,r,l,d,c,u,h;if(!e.has("value"))return;const p=e.get("value");(null==p?void 0:p.service)!==(null===(t=this.value)||void 0===t?void 0:t.service)&&(this._checkedKeys=new Set);const v=this._getServiceInfo(null===(i=this.value)||void 0===i?void 0:i.service,this.hass.services);var m;null!==(a=this.value)&&void 0!==a&&a.service?null!=p&&p.service&&gs(this.value.service)===gs(p.service)||this._fetchManifest(gs(null===(m=this.value)||void 0===m?void 0:m.service)):this._manifest=void 0;if(v&&"target"in v&&(null!==(n=this.value)&&void 0!==n&&null!==(s=n.data)&&void 0!==s&&s.entity_id||null!==(r=this.value)&&void 0!==r&&null!==(l=r.data)&&void 0!==l&&l.area_id||null!==(d=this.value)&&void 0!==d&&null!==(c=d.data)&&void 0!==c&&c.device_id)){var f,g,_;const e={...this.value.target};!this.value.data.entity_id||null!==(f=this.value.target)&&void 0!==f&&f.entity_id||(e.entity_id=this.value.data.entity_id),!this.value.data.area_id||null!==(g=this.value.target)&&void 0!==g&&g.area_id||(e.area_id=this.value.data.area_id),!this.value.data.device_id||null!==(_=this.value.target)&&void 0!==_&&_.device_id||(e.device_id=this.value.data.device_id),this._value={...this.value,target:e,data:{...this.value.data}},delete this._value.data.entity_id,delete this._value.data.device_id,delete this._value.data.area_id}else this._value=this.value;if((null==p?void 0:p.service)!==(null===(u=this.value)||void 0===u?void 0:u.service)){let e=!1;this._value&&v&&(this._value.data||(this._value.data={}),v.fields.forEach((t=>{t.selector&&t.required&&void 0===t.default&&"boolean"in t.selector&&void 0===this._value.data[t.key]&&(e=!0,this._value.data[t.key]=!1)}))),e&&o(this,"value-changed",{value:{...this._value}})}if(null!==(h=this._value)&&void 0!==h&&h.data){const e=this._yamlEditor;e&&e.value!==this._value.data&&e.setValue(this._value.data)}}},{kind:"field",key:"_getServiceInfo",value:()=>n(((e,t)=>{if(!e||!t)return;const i=gs(e),a=ho(e);if(!(i in t))return;if(!(a in t[i]))return;const n=Object.entries(t[i][a].fields).map((([e,t])=>({key:e,...t,selector:t.selector})));return{...t[i][a],fields:n,hasSelector:n.length?n.filter((e=>e.selector)).map((e=>e.key)):[]}}))},{kind:"method",key:"render",value:function(){var e,t,i,a,n,o,s;const r=this._getServiceInfo(null===(e=this._value)||void 0===e?void 0:e.service,this.hass.services),l=(null==r?void 0:r.fields.length)&&!r.hasSelector.length||r&&Object.keys((null===(t=this._value)||void 0===t?void 0:t.data)||{}).some((e=>!r.hasSelector.includes(e))),d=l&&(null==r?void 0:r.fields.find((e=>"entity_id"===e.key))),c=Boolean(!l&&(null==r?void 0:r.fields.some((e=>ru(e)))));return x`<ha-service-picker
  1655. .hass=${this.hass}
  1656. .value=${null===(i=this._value)||void 0===i?void 0:i.service}
  1657. @value-changed=${this._serviceChanged}
  1658. ></ha-service-picker>
  1659. <div class="description">
  1660. ${null!=r&&r.description?x`<p>${null==r?void 0:r.description}</p>`:""}
  1661. ${this._manifest?x` <a
  1662. href=${this._manifest.is_built_in?su(this.hass,`/integrations/${this._manifest.domain}`):this._manifest.documentation}
  1663. title=${this.hass.localize("ui.components.service-control.integration_doc")}
  1664. target="_blank"
  1665. rel="noreferrer"
  1666. >
  1667. <ha-icon-button
  1668. .path=${Va}
  1669. class="help-icon"
  1670. ></ha-icon-button>
  1671. </a>`:""}
  1672. </div>
  1673. ${r&&"target"in r?x`<ha-settings-row .narrow=${this.narrow}>
  1674. ${c?x`<div slot="prefix" class="checkbox-spacer"></div>`:""}
  1675. <span slot="heading"
  1676. >${this.hass.localize("ui.components.service-control.target")}</span
  1677. >
  1678. <span slot="description"
  1679. >${this.hass.localize("ui.components.service-control.target_description")}</span
  1680. ><ha-selector
  1681. .hass=${this.hass}
  1682. .selector=${r.target?{target:r.target}:{target:{}}}
  1683. @value-changed=${this._targetChanged}
  1684. .value=${null===(a=this._value)||void 0===a?void 0:a.target}
  1685. ></ha-selector
  1686. ></ha-settings-row>`:d?x`<ha-entity-picker
  1687. .hass=${this.hass}
  1688. .value=${null===(n=this._value)||void 0===n||null===(o=n.data)||void 0===o?void 0:o.entity_id}
  1689. .label=${d.description}
  1690. @value-changed=${this._entityPicked}
  1691. allow-custom-entity
  1692. ></ha-entity-picker>`:""}
  1693. ${l?x`<ha-yaml-editor
  1694. .hass=${this.hass}
  1695. .label=${this.hass.localize("ui.components.service-control.data")}
  1696. .name=${"data"}
  1697. .defaultValue=${null===(s=this._value)||void 0===s?void 0:s.data}
  1698. @value-changed=${this._dataChanged}
  1699. ></ha-yaml-editor>`:null==r?void 0:r.fields.map((e=>{var t,i,a,n;const o=ru(e);return e.selector&&(!e.advanced||this.showAdvanced||null!==(t=this._value)&&void 0!==t&&t.data&&void 0!==this._value.data[e.key])?x`<ha-settings-row .narrow=${this.narrow}>
  1700. ${o?x`<ha-checkbox
  1701. .key=${e.key}
  1702. .checked=${this._checkedKeys.has(e.key)||(null===(i=this._value)||void 0===i?void 0:i.data)&&void 0!==this._value.data[e.key]}
  1703. @change=${this._checkboxChanged}
  1704. slot="prefix"
  1705. ></ha-checkbox>`:c?x`<div slot="prefix" class="checkbox-spacer"></div>`:""}
  1706. <span slot="heading">${e.name||e.key}</span>
  1707. <span slot="description">${null==e?void 0:e.description}</span>
  1708. <ha-selector
  1709. .disabled=${o&&!this._checkedKeys.has(e.key)&&(!(null!==(a=this._value)&&void 0!==a&&a.data)||void 0===this._value.data[e.key])}
  1710. .hass=${this.hass}
  1711. .selector=${e.selector}
  1712. .key=${e.key}
  1713. @value-changed=${this._serviceDataChanged}
  1714. .value=${null!==(n=this._value)&&void 0!==n&&n.data&&void 0!==this._value.data[e.key]?this._value.data[e.key]:e.default}
  1715. ></ha-selector>
  1716. </ha-settings-row>`:""}))}`}},{kind:"method",key:"_checkboxChanged",value:function(e){const t=e.currentTarget.checked,i=e.currentTarget.key;let a;if(t){var n,s,r;this._checkedKeys.add(i);const e=null===(n=this._getServiceInfo(null===(r=this._value)||void 0===r?void 0:r.service,this.hass.services))||void 0===n||null===(s=n.fields.find((e=>e.key===i)))||void 0===s?void 0:s.default;var l;if(e)a={...null===(l=this._value)||void 0===l?void 0:l.data,[i]:e}}else{var d;this._checkedKeys.delete(i),a={...null===(d=this._value)||void 0===d?void 0:d.data},delete a[i]}a&&o(this,"value-changed",{value:{...this._value,data:a}}),this.requestUpdate("_checkedKeys")}},{kind:"method",key:"_serviceChanged",value:function(e){var t;e.stopPropagation(),e.detail.value!==(null===(t=this._value)||void 0===t?void 0:t.service)&&o(this,"value-changed",{value:{service:e.detail.value||""}})}},{kind:"method",key:"_entityPicked",value:function(e){var t,i,a;e.stopPropagation();const n=e.detail.value;if((null===(t=this._value)||void 0===t||null===(i=t.data)||void 0===i?void 0:i.entity_id)===n)return;let s;var r;!n&&null!==(a=this._value)&&void 0!==a&&a.data?(s={...this._value},delete s.data.entity_id):s={...this._value,data:{...null===(r=this._value)||void 0===r?void 0:r.data,entity_id:e.detail.value}};o(this,"value-changed",{value:s})}},{kind:"method",key:"_targetChanged",value:function(e){var t;e.stopPropagation();const i=e.detail.value;if((null===(t=this._value)||void 0===t?void 0:t.target)===i)return;let a;i?a={...this._value,target:e.detail.value}:(a={...this._value},delete a.target),o(this,"value-changed",{value:a})}},{kind:"method",key:"_serviceDataChanged",value:function(e){var t,i,a,n,s;e.stopPropagation();const r=e.currentTarget.key,l=e.detail.value;if((null===(t=this._value)||void 0===t||null===(i=t.data)||void 0===i?void 0:i[r])===l||(null===(a=this._value)||void 0===a||null===(n=a.data)||void 0===n||!n[r])&&(""===l||void 0===l))return;const d={...null===(s=this._value)||void 0===s?void 0:s.data,[r]:l};""!==l&&void 0!==l||delete d[r],o(this,"value-changed",{value:{...this._value,data:d}})}},{kind:"method",key:"_dataChanged",value:function(e){e.stopPropagation(),e.detail.isValid&&o(this,"value-changed",{value:{...this._value,data:e.detail.value}})}},{kind:"method",key:"_fetchManifest",value:async function(e){this._manifest=void 0;try{this._manifest=await((e,t)=>e.callWS({type:"manifest/get",integration:t}))(this.hass,e)}catch(e){}}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1717. ha-settings-row {
  1718. padding: var(--service-control-padding, 0 16px);
  1719. }
  1720. ha-settings-row {
  1721. --paper-time-input-justify-content: flex-end;
  1722. --settings-row-content-width: 100%;
  1723. --settings-row-prefix-display: contents;
  1724. border-top: var(
  1725. --service-control-items-border-top,
  1726. 1px solid var(--divider-color)
  1727. );
  1728. }
  1729. ha-service-picker,
  1730. ha-entity-picker,
  1731. ha-yaml-editor {
  1732. display: block;
  1733. margin: var(--service-control-padding, 0 16px);
  1734. }
  1735. ha-yaml-editor {
  1736. padding: 16px 0;
  1737. }
  1738. p {
  1739. margin: var(--service-control-padding, 0 16px);
  1740. padding: 16px 0;
  1741. }
  1742. .checkbox-spacer {
  1743. width: 32px;
  1744. }
  1745. ha-checkbox {
  1746. margin-left: -16px;
  1747. }
  1748. .help-icon {
  1749. color: var(--secondary-text-color);
  1750. }
  1751. .description {
  1752. justify-content: space-between;
  1753. display: flex;
  1754. align-items: center;
  1755. padding-right: 2px;
  1756. }
  1757. `}}]}}),g);const lu=no({alias:oo(so()),service:oo(so()),entity_id:oo((du=so(),cu="entity ID (domain.entity or all)",uu=ou,new Wn({...du,*refiner(e,t){yield*du.refiner(e,t);const i=Hn(uu(e,t),t,du,e);for(const e of i)yield{...e,refinement:cu}}}))),target:oo(Xn()),data:oo(Xn())});var du,cu,uu;f([A("ha-automation-action-service")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"narrow",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{service:"",data:{}}}},{kind:"method",key:"willUpdate",value:function(e){if(e.has("action")){try{Kn(this.action,lu)}catch(e){return void o(this,"ui-mode-not-available",e)}this.action&&wo(this.action)?o(this,"ui-mode-not-available",Error(this.hass.localize("ui.errors.config.no_template_editor_support"))):this.action.entity_id?(this._action={...this.action,data:{...this.action.data,entity_id:this.action.entity_id}},delete this._action.entity_id):this._action=this.action}}},{kind:"method",key:"render",value:function(){var e;return x`
  1758. <ha-service-control
  1759. .narrow=${this.narrow}
  1760. .hass=${this.hass}
  1761. .value=${this._action}
  1762. .showAdvanced=${null===(e=this.hass.userData)||void 0===e?void 0:e.showAdvanced}
  1763. @value-changed=${this._actionChanged}
  1764. ></ha-service-control>
  1765. `}},{kind:"method",key:"_actionChanged",value:function(e){e.detail.value===this._action&&e.stopPropagation()}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1766. ha-service-control {
  1767. display: block;
  1768. margin: 0 -16px;
  1769. }
  1770. `}}]}}),g),f([A("ha-automation-action-stop")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{stop:""}}},{kind:"method",key:"render",value:function(){const{error:e,stop:t}=this.action;return x`
  1771. <ha-textfield
  1772. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.stop.stop")}
  1773. .value=${t}
  1774. @change=${this._stopChanged}
  1775. ></ha-textfield>
  1776. <ha-formfield
  1777. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.stop.error")}
  1778. >
  1779. <ha-switch
  1780. .checked=${null!=e&&e}
  1781. @change=${this._errorChanged}
  1782. ></ha-switch>
  1783. </ha-formfield>
  1784. `}},{kind:"method",key:"_stopChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.action,stop:e.target.value}})}},{kind:"method",key:"_errorChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.action,error:e.target.checked}})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1785. ha-textfield {
  1786. display: block;
  1787. margin-bottom: 24px;
  1788. }
  1789. `}}]}}),g);const hu={calendar:T,device:aa,event:ua,state:ra,geo_location:qa,homeassistant:D,mqtt:Ci,numeric_state:la,sun:Ve,tag:ja,template:da,time:ca,time_pattern:Ra,webhook:Ua,zone:he};f([A("ha-automation-trigger-calendar")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"entity_id",required:!0,selector:{entity:{domain:"calendar"}}},{name:"event",type:"select",required:!0,options:[["start",e("ui.panel.config.automation.editor.triggers.type.calendar.start")],["end",e("ui.panel.config.automation.editor.triggers.type.calendar.end")]]},{name:"offset",selector:{duration:{enable_day:!0}}},{name:"offset_type",type:"select",required:!0,options:[["before",e("ui.panel.config.automation.editor.triggers.type.calendar.before")],["after",e("ui.panel.config.automation.editor.triggers.type.calendar.after")]]}]))},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{event:"start",offset:0}}},{kind:"method",key:"render",value:function(){const e=this._schema(this.hass.localize),t=this.trigger.offset,i=Bc(t);let a="after";("object"==typeof t&&i.hours<0||"string"==typeof t&&t.startsWith("-"))&&(i.hours=Math.abs(i.hours),a="before");const n={...this.trigger,offset:i,offset_type:a};return x`
  1790. <ha-form
  1791. .schema=${e}
  1792. .data=${n}
  1793. .hass=${this.hass}
  1794. .computeLabel=${this._computeLabelCallback}
  1795. @value-changed=${this._valueChanged}
  1796. ></ha-form>
  1797. `}},{kind:"method",key:"_valueChanged",value:function(e){var t,i,a;e.stopPropagation();const n=e.detail.value.offset,s="before"===e.detail.value.offset_type?"-":"",r={...e.detail.value,offset:`${s}${null!==(t=n.hours)&&void 0!==t?t:0}:${null!==(i=n.minutes)&&void 0!==i?i:0}:${null!==(a=n.seconds)&&void 0!==a?a:0}`};delete r.offset_type,o(this,"value-changed",{value:r})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.calendar.${e.name}`)}}]}}),g),f([A("ha-device-trigger-picker")],(function(e,t){return{F:class extends t{constructor(){super(kc,mc,(e=>({device_id:e||"",platform:"device",domain:"",entity_id:""}))),e(this)}},d:[{kind:"get",key:"NO_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.triggers.no_triggers")}},{kind:"get",key:"UNKNOWN_AUTOMATION_TEXT",value:function(){return this.hass.localize("ui.panel.config.devices.automation.triggers.unknown_trigger")}}]}}),wc),f([A("ha-automation-trigger-device")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Object})],key:"trigger",value:void 0},{kind:"field",decorators:[Qi()],key:"_deviceId",value:void 0},{kind:"field",decorators:[Qi()],key:"_capabilities",value:void 0},{kind:"field",key:"_origTrigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{device_id:"",domain:"",entity_id:""}}},{kind:"field",key:"_extraFieldsData",value:()=>n(((e,t)=>{const i={};return t.extra_fields.forEach((t=>{void 0!==e[t.name]&&(i[t.name]=e[t.name])})),i}))},{kind:"method",key:"render",value:function(){var e;const t=this._deviceId||this.trigger.device_id;return x`
  1798. <ha-device-picker
  1799. .value=${t}
  1800. @value-changed=${this._devicePicked}
  1801. .hass=${this.hass}
  1802. label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.device.label")}
  1803. ></ha-device-picker>
  1804. <ha-device-trigger-picker
  1805. .value=${this.trigger}
  1806. .deviceId=${t}
  1807. @value-changed=${this._deviceTriggerPicked}
  1808. .hass=${this.hass}
  1809. label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.device.trigger")}
  1810. ></ha-device-trigger-picker>
  1811. ${null!==(e=this._capabilities)&&void 0!==e&&e.extra_fields?x`
  1812. <ha-form
  1813. .hass=${this.hass}
  1814. .data=${this._extraFieldsData(this.trigger,this._capabilities)}
  1815. .schema=${this._capabilities.extra_fields}
  1816. .computeLabel=${this._extraFieldsComputeLabelCallback(this.hass.localize)}
  1817. @value-changed=${this._extraFieldsChanged}
  1818. ></ha-form>
  1819. `:""}
  1820. `}},{kind:"method",key:"firstUpdated",value:function(){this._capabilities||this._getCapabilities(),this.trigger&&(this._origTrigger=this.trigger)}},{kind:"method",key:"updated",value:function(e){if(!e.has("trigger"))return;const t=e.get("trigger");t&&!gc(t,this.trigger)&&this._getCapabilities()}},{kind:"method",key:"_getCapabilities",value:async function(){const e=this.trigger;this._capabilities=e.domain?await((e,t)=>e.callWS({type:"device_automation/trigger/capabilities",trigger:t}))(this.hass,e):void 0}},{kind:"method",key:"_devicePicked",value:function(e){e.stopPropagation(),this._deviceId=e.target.value,void 0===this._deviceId&&o(this,"value-changed",{value:{...i.defaultConfig,platform:"device"}})}},{kind:"method",key:"_deviceTriggerPicked",value:function(e){e.stopPropagation();let t=e.detail.value;this._origTrigger&&gc(this._origTrigger,t)&&(t=this._origTrigger),this.trigger.id&&(t.id=this.trigger.id),o(this,"value-changed",{value:t})}},{kind:"method",key:"_extraFieldsChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.trigger,...e.detail.value}})}},{kind:"method",key:"_extraFieldsComputeLabelCallback",value:function(e){return t=>e(`ui.panel.config.automation.editor.triggers.type.device.extra_fields.${t.name}`)||t.name}},{kind:"field",static:!0,key:"styles",value:()=>r`
  1821. ha-device-picker {
  1822. display: block;
  1823. margin-bottom: 24px;
  1824. }
  1825. `}]}}),g);const pu={},vu=e(class extends t{constructor(){super(...arguments),this.nt=pu}render(e,t){return t()}update(e,[t,i]){if(Array.isArray(t)){if(Array.isArray(this.nt)&&this.nt.length===t.length&&t.every(((e,t)=>e===this.nt[t])))return a}else if(this.nt===t)return a;return this.nt=Array.isArray(t)?Array.from(t):t,this.render(t,i)}}),mu=async e=>e.callWS({type:"config/auth/list"});f([A("ha-user-badge")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"user",value:void 0},{kind:"field",decorators:[Qi()],key:"_personPicture",value:void 0},{kind:"field",key:"_personEntityId",value:void 0},{kind:"method",key:"willUpdate",value:function(e){if(k(b(i.prototype),"willUpdate",this).call(this,e),e.has("user"))return void this._getPersonPicture();const t=e.get("hass");if(this._personEntityId&&t&&this.hass.states[this._personEntityId]!==t.states[this._personEntityId]){const e=this.hass.states[this._personEntityId];e?this._personPicture=e.attributes.entity_picture:this._getPersonPicture()}else!this._personEntityId&&t&&this._getPersonPicture()}},{kind:"method",key:"render",value:function(){if(!this.hass||!this.user)return x``;const e=this._personPicture;if(e)return x`<div
  1826. style=${Ji({backgroundImage:`url(${e})`})}
  1827. class="picture"
  1828. ></div>`;const t=(e=>e?e.trim().split(" ").slice(0,3).map((e=>e.substring(0,1))).join(""):"?")(this.user.name);return x`<div
  1829. class="initials ${ba({long:t.length>2})}"
  1830. >
  1831. ${t}
  1832. </div>`}},{kind:"method",key:"_getPersonPicture",value:function(){if(this._personEntityId=void 0,this._personPicture=void 0,this.hass&&this.user)for(const e of Object.values(this.hass.states))if(e.attributes.user_id===this.user.id&&"person"===Hr(e)){this._personEntityId=e.entity_id,this._personPicture=e.attributes.entity_picture;break}}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1833. :host {
  1834. display: contents;
  1835. }
  1836. .picture {
  1837. width: 40px;
  1838. height: 40px;
  1839. background-size: cover;
  1840. border-radius: 50%;
  1841. }
  1842. .initials {
  1843. display: inline-block;
  1844. box-sizing: border-box;
  1845. width: 40px;
  1846. line-height: 40px;
  1847. border-radius: 50%;
  1848. text-align: center;
  1849. background-color: var(--light-primary-color);
  1850. text-decoration: none;
  1851. color: var(--text-light-primary-color, var(--primary-text-color));
  1852. overflow: hidden;
  1853. }
  1854. .initials.long {
  1855. font-size: 80%;
  1856. }
  1857. `}}]}}),g);let fu=f(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"noUserLabel",value:void 0},{kind:"field",decorators:[_()],key:"value",value:()=>""},{kind:"field",decorators:[_()],key:"users",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",key:"_sortedUsers",value:()=>n((e=>e?e.filter((e=>!e.system_generated)).sort(((e,t)=>_s(e.name,t.name))):[]))},{kind:"method",key:"render",value:function(){var e,t;return x`
  1858. <ha-select
  1859. .label=${this.label}
  1860. .disabled=${this.disabled}
  1861. .value=${this.value}
  1862. @selected=${this._userChanged}
  1863. >
  1864. ${0===(null===(e=this.users)||void 0===e?void 0:e.length)?x`<mwc-list-item value="">
  1865. ${this.noUserLabel||(null===(t=this.hass)||void 0===t?void 0:t.localize("ui.components.user-picker.no_user"))}
  1866. </mwc-list-item>`:""}
  1867. ${this._sortedUsers(this.users).map((e=>x`
  1868. <ha-list-item graphic="avatar" .value=${e.id}>
  1869. <ha-user-badge
  1870. .hass=${this.hass}
  1871. .user=${e}
  1872. slot="graphic"
  1873. ></ha-user-badge>
  1874. ${e.name}
  1875. </ha-list-item>
  1876. `))}
  1877. </ha-select>
  1878. `}},{kind:"method",key:"firstUpdated",value:function(e){k(b(i.prototype),"firstUpdated",this).call(this,e),void 0===this.users&&mu(this.hass).then((e=>{this.users=e}))}},{kind:"method",key:"_userChanged",value:function(e){const t=e.target.value;t!==this.value&&(this.value=t,setTimeout((()=>{o(this,"value-changed",{value:t}),o(this,"change")}),0))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1879. :host {
  1880. display: inline-block;
  1881. }
  1882. mwc-list {
  1883. display: block;
  1884. }
  1885. `}}]}}),g);customElements.define("ha-user-picker",fu),f([A("ha-users-picker")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_({attribute:"picked-user-label"})],key:"pickedUserLabel",value:void 0},{kind:"field",decorators:[_({attribute:"pick-user-label"})],key:"pickUserLabel",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"users",value:void 0},{kind:"method",key:"firstUpdated",value:function(e){k(b(i.prototype),"firstUpdated",this).call(this,e),void 0===this.users&&mu(this.hass).then((e=>{this.users=e}))}},{kind:"method",key:"render",value:function(){if(!this.hass||!this.users)return x``;const e=this._notSelectedUsers(this.users,this.value);return x`
  1886. ${vu([e],(()=>{var t;return null===(t=this.value)||void 0===t?void 0:t.map(((t,i)=>x`
  1887. <div>
  1888. <ha-user-picker
  1889. .label=${this.pickedUserLabel}
  1890. .noUserLabel=${this.hass.localize("ui.components.user-picker.remove_user")}
  1891. .index=${i}
  1892. .hass=${this.hass}
  1893. .value=${t}
  1894. .users=${this._notSelectedUsersAndSelected(t,this.users,e)}
  1895. @value-changed=${this._userChanged}
  1896. ></ha-user-picker>
  1897. <ha-icon-button
  1898. .userId=${t}
  1899. .label=${this.hass.localize("ui.components.user-picker.remove_user")}
  1900. .path=${$}
  1901. @click=${this._removeUser}
  1902. >
  1903. ></ha-icon-button
  1904. >
  1905. </div>
  1906. `))}))}
  1907. <ha-user-picker
  1908. .label=${this.pickUserLabel||this.hass.localize("ui.components.user-picker.add_user")}
  1909. .hass=${this.hass}
  1910. .users=${e}
  1911. .disabled=${!(null!=e&&e.length)}
  1912. @value-changed=${this._addUser}
  1913. ></ha-user-picker>
  1914. `}},{kind:"field",key:"_notSelectedUsers",value:()=>n(((e,t)=>t?null==e?void 0:e.filter((e=>!e.system_generated&&!t.includes(e.id))):null==e?void 0:e.filter((e=>!e.system_generated))))},{kind:"field",key:"_notSelectedUsersAndSelected",value:()=>(e,t,i)=>{const a=null==t?void 0:t.find((t=>t.id===e));return a?i?[...i,a]:[a]:i}},{kind:"get",key:"_currentUsers",value:function(){return this.value||[]}},{kind:"method",key:"_updateUsers",value:async function(e){this.value=e,o(this,"value-changed",{value:e})}},{kind:"method",key:"_userChanged",value:function(e){e.stopPropagation();const t=e.currentTarget.index,i=e.detail.value,a=[...this._currentUsers];""===i?a.splice(t,1):a.splice(t,1,i),this._updateUsers(a)}},{kind:"method",key:"_addUser",value:async function(e){e.stopPropagation();const t=e.detail.value;if(e.currentTarget.value="",!t)return;const i=this._currentUsers;i.includes(t)||this._updateUsers([...i,t])}},{kind:"method",key:"_removeUser",value:function(e){const t=e.currentTarget.userId;this._updateUsers(this._currentUsers.filter((e=>e!==t)))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1915. :host {
  1916. display: block;
  1917. }
  1918. div {
  1919. display: flex;
  1920. align-items: center;
  1921. }
  1922. `}}]}}),g),f([A("ha-automation-trigger-event")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{event_type:""}}},{kind:"method",key:"render",value:function(){const{event_type:e,event_data:t,context:i}=this.trigger;return x`
  1923. <ha-textfield
  1924. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.event.event_type")}
  1925. name="event_type"
  1926. .value=${e}
  1927. @change=${this._valueChanged}
  1928. ></ha-textfield>
  1929. <ha-yaml-editor
  1930. .hass=${this.hass}
  1931. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.event.event_data")}
  1932. .name=${"event_data"}
  1933. .defaultValue=${t}
  1934. @value-changed=${this._dataChanged}
  1935. ></ha-yaml-editor>
  1936. <br />
  1937. ${this.hass.localize("ui.panel.config.automation.editor.triggers.type.event.context_users")}
  1938. <ha-users-picker
  1939. .pickedUserLabel=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.event.context_user_picked")}
  1940. .pickUserLabel=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.event.context_user_pick")}
  1941. .hass=${this.hass}
  1942. .value=${this._wrapUsersInArray(null==i?void 0:i.user_id)}
  1943. @value-changed=${this._usersChanged}
  1944. ></ha-users-picker>
  1945. `}},{kind:"method",key:"_wrapUsersInArray",value:function(e){return e?"string"==typeof e?[e]:e:[]}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation(),xu(this,e)}},{kind:"method",key:"_dataChanged",value:function(e){e.stopPropagation(),e.detail.isValid&&xu(this,e)}},{kind:"method",key:"_usersChanged",value:function(e){e.stopPropagation();const t={...this.trigger};!e.detail.value.length&&t.context?delete t.context.user_id:(t.context||(t.context={}),t.context.user_id=e.detail.value),o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  1946. ha-textfield {
  1947. display: block;
  1948. }
  1949. `}}]}}),g),f([A("ha-automation-trigger-geo_location")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"source",selector:{text:{}}},{name:"zone",selector:{entity:{domain:"zone"}}},{name:"event",type:"select",required:!0,options:[["enter",e("ui.panel.config.automation.editor.triggers.type.geo_location.enter")],["leave",e("ui.panel.config.automation.editor.triggers.type.geo_location.leave")]]}]))},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{source:"",zone:"",event:"enter"}}},{kind:"method",key:"render",value:function(){return x`
  1950. <ha-form
  1951. .schema=${this._schema(this.hass.localize)}
  1952. .data=${this.trigger}
  1953. .hass=${this.hass}
  1954. .computeLabel=${this._computeLabelCallback}
  1955. @value-changed=${this._valueChanged}
  1956. ></ha-form>
  1957. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.geo_location.${e.name}`)}}]}}),g),f([A("ha-automation-trigger-homeassistant")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"event",type:"select",required:!0,options:[["start",e("ui.panel.config.automation.editor.triggers.type.homeassistant.start")],["shutdown",e("ui.panel.config.automation.editor.triggers.type.homeassistant.shutdown")]]}]))},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{event:"start"}}},{kind:"method",key:"render",value:function(){return x`
  1958. <ha-form
  1959. .schema=${this._schema(this.hass.localize)}
  1960. .data=${this.trigger}
  1961. .hass=${this.hass}
  1962. .computeLabel=${this._computeLabelCallback}
  1963. @value-changed=${this._valueChanged}
  1964. ></ha-form>
  1965. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.homeassistant.${e.name}`)}},{kind:"field",static:!0,key:"styles",value:()=>r`
  1966. label {
  1967. display: flex;
  1968. align-items: center;
  1969. }
  1970. `}]}}),g);const gu=[{name:"topic",required:!0,selector:{text:{}}},{name:"payload",selector:{text:{}}}];f([A("ha-automation-trigger-mqtt")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{topic:""}}},{kind:"method",key:"render",value:function(){return x`
  1971. <ha-form
  1972. .schema=${gu}
  1973. .data=${this.trigger}
  1974. .hass=${this.hass}
  1975. .computeLabel=${this._computeLabelCallback}
  1976. @value-changed=${this._valueChanged}
  1977. ></ha-form>
  1978. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.mqtt.${e.name}`)}}]}}),g),f([A("ha-automation-trigger-numeric_state")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"entity_id",required:!0,selector:{entity:{}}},{name:"attribute",selector:{attribute:{entity_id:e,hide_attributes:["access_token","auto_update","available_modes","away_mode","changed_by","code_format","color_modes","current_activity","device_class","editable","effect_list","effect","entity_picture","fan_mode","fan_modes","fan_speed_list","forecast","friendly_name","frontend_stream_type","has_date","has_time","hs_color","hvac_mode","hvac_modes","icon","media_album_name","media_artist","media_content_type","media_position_updated_at","media_title","next_dawn","next_dusk","next_midnight","next_noon","next_rising","next_setting","operation_list","operation_mode","options","preset_mode","preset_modes","release_notes","release_summary","release_url","restored","rgb_color","rgbw_color","shuffle","sound_mode_list","sound_mode","source_list","source_type","source","state_class","supported_features","swing_mode","swing_mode","swing_modes","title","token","unit_of_measurement","xy_color"]}}},{name:"above",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}},{name:"below",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}},{name:"value_template",selector:{template:{}}},{name:"for",selector:{duration:{}}}]))},{kind:"method",key:"willUpdate",value:function(e){e.has("trigger")&&this.trigger&&wo(this.trigger.for)&&o(this,"ui-mode-not-available",Error(this.hass.localize("ui.errors.config.no_template_editor_support")))}},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:""}}},{kind:"method",key:"render",value:function(){const e=Bc(this.trigger.for),t={...this.trigger,for:e},i=this._schema(this.trigger.entity_id);return x`
  1979. <ha-form
  1980. .hass=${this.hass}
  1981. .data=${t}
  1982. .schema=${i}
  1983. @value-changed=${this._valueChanged}
  1984. .computeLabel=${this._computeLabelCallback}
  1985. ></ha-form>
  1986. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>{switch(e.name){case"entity_id":return this.hass.localize("ui.components.entity.entity-picker.entity");case"attribute":return this.hass.localize("ui.components.entity.entity-attribute-picker.attribute");case"for":return this.hass.localize("ui.panel.config.automation.editor.triggers.type.state.for");default:return this.hass.localize(`ui.panel.config.automation.editor.triggers.type.numeric_state.${e.name}`)}}}}]}}),g);const _u=Qn(Nc,no({alias:oo(so()),platform:io("state"),entity_id:oo(lo([so(),eo(so())])),attribute:oo(so()),from:oo(so()),to:oo(so()),for:oo(lo([so(),Vc]))}));f([A("ha-automation-trigger-state")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:[]}}},{kind:"field",key:"_schema",value:()=>n(((e,t)=>[{name:"entity_id",required:!0,selector:{entity:{multiple:!0}}},{name:"attribute",selector:{attribute:{entity_id:e?e[0]:void 0,hide_attributes:["access_token","available_modes","color_modes","device_class","editable","effect_list","entity_picture","fan_modes","fan_speed_list","friendly_name","has_date","has_time","hvac_modes","icon","operation_list","options","preset_modes","sound_mode_list","source_list","state_class","supported_features","swing_modes","token","unit_of_measurement"]}}},{name:"from",selector:{state:{entity_id:e?e[0]:void 0,attribute:t}}},{name:"to",selector:{state:{entity_id:e?e[0]:void 0,attribute:t}}},{name:"for",selector:{duration:{}}}]))},{kind:"method",key:"shouldUpdate",value:function(e){if(!e.has("trigger"))return!0;if(this.trigger.for&&"object"==typeof this.trigger.for&&0===this.trigger.for.milliseconds&&delete this.trigger.for.milliseconds,this.trigger&&wo(this.trigger))return o(this,"ui-mode-not-available",Error(this.hass.localize("ui.errors.config.no_template_editor_support"))),!1;try{Kn(this.trigger,_u)}catch(e){return o(this,"ui-mode-not-available",e),!1}return!0}},{kind:"method",key:"render",value:function(){const e=Bc(this.trigger.for),t={...this.trigger,entity_id:ko(this.trigger.entity_id),for:e},i=this._schema(this.trigger.entity_id,this.trigger.attribute);return x`
  1987. <ha-form
  1988. .hass=${this.hass}
  1989. .data=${t}
  1990. .schema=${i}
  1991. @value-changed=${this._valueChanged}
  1992. .computeLabel=${this._computeLabelCallback}
  1993. ></ha-form>
  1994. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;Object.keys(t).forEach((e=>void 0===t[e]||""===t[e]?delete t[e]:{})),o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize("entity_id"===e.name?"ui.components.entity.entity-picker.entity":`ui.panel.config.automation.editor.triggers.type.state.${e.name}`)}}]}}),g),f([A("ha-automation-trigger-sun")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",key:"_schema",value:()=>n((e=>[{name:"event",type:"select",required:!0,options:[["sunrise",e("ui.panel.config.automation.editor.triggers.type.sun.sunrise")],["sunset",e("ui.panel.config.automation.editor.triggers.type.sun.sunset")]]},{name:"offset",selector:{text:{}}}]))},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{event:"sunrise",offset:0}}},{kind:"method",key:"render",value:function(){const e=this._schema(this.hass.localize);return x`
  1995. <ha-form
  1996. .schema=${e}
  1997. .data=${this.trigger}
  1998. .hass=${this.hass}
  1999. .computeLabel=${this._computeLabelCallback}
  2000. @value-changed=${this._valueChanged}
  2001. ></ha-form>
  2002. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.sun.${e.name}`)}}]}}),g);f([A("ha-automation-trigger-tag")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"trigger",value:void 0},{kind:"field",decorators:[Qi()],key:"_tags",value:()=>[]},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{tag_id:""}}},{kind:"method",key:"firstUpdated",value:function(e){k(b(i.prototype),"firstUpdated",this).call(this,e),this._fetchTags()}},{kind:"method",key:"render",value:function(){const{tag_id:e}=this.trigger;return x`
  2003. <ha-select
  2004. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.tag.label")}
  2005. .disabled=${0===this._tags.length}
  2006. .value=${e}
  2007. @selected=${this._tagChanged}
  2008. >
  2009. ${this._tags.map((e=>x`
  2010. <mwc-list-item .value=${e.id}>
  2011. ${e.name||e.id}
  2012. </mwc-list-item>
  2013. `))}
  2014. </ha-select>
  2015. `}},{kind:"method",key:"_fetchTags",value:async function(){this._tags=await(async e=>e.callWS({type:"tag/list"}))(this.hass),this._tags.sort(((e,t)=>ys(e.name||e.id,t.name||t.id)))}},{kind:"method",key:"_tagChanged",value:function(e){o(this,"value-changed",{value:{...this.trigger,tag_id:e.target.value}})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2016. ha-select {
  2017. display: block;
  2018. }
  2019. `}}]}}),g),f([A("ha-automation-trigger-template")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{value_template:""}}},{kind:"method",key:"render",value:function(){const{value_template:e}=this.trigger;return x`
  2020. <p>
  2021. ${this.hass.localize("ui.panel.config.automation.editor.triggers.type.template.value_template")}
  2022. *
  2023. </p>
  2024. <ha-code-editor
  2025. .name=${"value_template"}
  2026. mode="jinja2"
  2027. .hass=${this.hass}
  2028. .value=${e}
  2029. autocomplete-entities
  2030. @value-changed=${this._valueChanged}
  2031. dir="ltr"
  2032. ></ha-code-editor>
  2033. `}},{kind:"method",key:"_valueChanged",value:function(e){xu(this,e)}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2034. p {
  2035. margin-top: 0;
  2036. }
  2037. `}}]}}),g),f([A("ha-automation-trigger-time")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",decorators:[Qi()],key:"_inputMode",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{at:""}}},{kind:"field",key:"_schema",value:()=>n(((e,t)=>{const i=t?{entity:{domain:"input_datetime"}}:{time:{}};return[{name:"mode",type:"select",required:!0,options:[["value",e("ui.panel.config.automation.editor.triggers.type.time.type_value")],["input",e("ui.panel.config.automation.editor.triggers.type.time.type_input")]]},{name:"at",selector:i}]}))},{kind:"method",key:"willUpdate",value:function(e){e.has("trigger")&&this.trigger&&Array.isArray(this.trigger.at)&&o(this,"ui-mode-not-available",Error(this.hass.localize("ui.errors.config.editor_not_supported")))}},{kind:"method",key:"render",value:function(){var e;const t=this.trigger.at;if(Array.isArray(t))return x``;const i=null!==(e=this._inputMode)&&void 0!==e?e:(null==t?void 0:t.startsWith("input_datetime."))||(null==t?void 0:t.startsWith("sensor.")),a=this._schema(this.hass.localize,i),n={mode:i?"input":"value",...this.trigger};return x`
  2038. <ha-form
  2039. .hass=${this.hass}
  2040. .data=${n}
  2041. .schema=${a}
  2042. @value-changed=${this._valueChanged}
  2043. .computeLabel=${this._computeLabelCallback}
  2044. ></ha-form>
  2045. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;this._inputMode="input"===t.mode,delete t.mode,Object.keys(t).forEach((e=>void 0===t[e]||""===t[e]?delete t[e]:{})),o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.time.${e.name}`)}}]}}),g);const yu=[{name:"hours",selector:{text:{}}},{name:"minutes",selector:{text:{}}},{name:"seconds",selector:{text:{}}}];f([A("ha-automation-trigger-time_pattern")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{}}},{kind:"method",key:"render",value:function(){return x`
  2046. <ha-form
  2047. .hass=${this.hass}
  2048. .schema=${yu}
  2049. .data=${this.trigger}
  2050. .computeLabel=${this._computeLabelCallback}
  2051. @value-changed=${this._valueChanged}
  2052. ></ha-form>
  2053. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;o(this,"value-changed",{value:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.triggers.type.time_pattern.${e.name}`)}}]}}),g);function ku(e){return Gc(e)&&"zone"!==Hr(e)}f([A("ha-automation-trigger-webhook")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"trigger",value:void 0},{kind:"field",decorators:[Qi()],key:"_config",value:void 0},{kind:"field",key:"_unsub",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{webhook_id:""}}},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this);const e={callback:e=>{this._config=e}};o(this,"subscribe-automation-config",e),this._unsub=e.unsub}},{kind:"method",key:"disconnectedCallback",value:function(){k(b(i.prototype),"disconnectedCallback",this).call(this),this._unsub&&this._unsub()}},{kind:"method",key:"_generateWebhookId",value:function(){var e;const t=crypto.getRandomValues(new Uint8Array(18)),i=btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_"),a=((e,t="_")=>{const i="àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;",a=`aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz${t}${t}${t}${t}${t}${t}`,n=new RegExp(i.split("").join("|"),"g");return e.toString().toLowerCase().replace(/\s+/g,t).replace(n,(e=>a.charAt(i.indexOf(e)))).replace(/&/g,`${t}and${t}`).replace(/[^\w-]+/g,"").replace(/-/g,t).replace(new RegExp(`(${t})\\1+`,"g"),"$1").replace(new RegExp(`^${t}+`),"").replace(new RegExp(`${t}+$`),"")})((null===(e=this._config)||void 0===e?void 0:e.alias)||"","-");return`${a}-${i}`}},{kind:"method",key:"willUpdate",value:function(e){k(b(i.prototype),"willUpdate",this).call(this,e),e.has("trigger")&&""===this.trigger.webhook_id&&(this.trigger.webhook_id=this._generateWebhookId())}},{kind:"method",key:"render",value:function(){const{webhook_id:e}=this.trigger;return x`
  2054. <ha-textfield
  2055. name="webhook_id"
  2056. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.webhook.webhook_id")}
  2057. .helper=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.webhook.webhook_id_helper")}
  2058. iconTrailing
  2059. .value=${e||""}
  2060. @input=${this._valueChanged}
  2061. >
  2062. <ha-icon-button
  2063. @click=${this._copyUrl}
  2064. slot="trailingIcon"
  2065. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.webhook.copy_url")}
  2066. .path=${Ha}
  2067. ></ha-icon-button>
  2068. </ha-textfield>
  2069. `}},{kind:"method",key:"_valueChanged",value:function(e){xu(this,e)}},{kind:"method",key:"_copyUrl",value:async function(e){const t=e.target.parentElement,i=this.hass.hassUrl(`/api/webhook/${t.value}`);await(async e=>{if(navigator.clipboard)try{return void await navigator.clipboard.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)})(i),fs(this,{message:this.hass.localize("ui.common.copied_clipboard")})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2070. ha-textfield {
  2071. display: block;
  2072. }
  2073. ha-textfield > ha-icon-button {
  2074. --mdc-icon-button-size: 24px;
  2075. --mdc-icon-size: 18px;
  2076. }
  2077. `}]}}),g);const bu=["zone"];f([A("ha-automation-trigger-zone")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"trigger",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{entity_id:"",zone:"",event:"enter"}}},{kind:"method",key:"render",value:function(){const{entity_id:e,zone:t,event:i}=this.trigger;return x`
  2078. <ha-entity-picker
  2079. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.zone.entity")}
  2080. .value=${e}
  2081. @value-changed=${this._entityPicked}
  2082. .hass=${this.hass}
  2083. allow-custom-entity
  2084. .entityFilter=${ku}
  2085. ></ha-entity-picker>
  2086. <ha-entity-picker
  2087. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.zone.zone")}
  2088. .value=${t}
  2089. @value-changed=${this._zonePicked}
  2090. .hass=${this.hass}
  2091. allow-custom-entity
  2092. .includeDomains=${bu}
  2093. ></ha-entity-picker>
  2094. <label>
  2095. ${this.hass.localize("ui.panel.config.automation.editor.triggers.type.zone.event")}
  2096. <ha-formfield
  2097. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.zone.enter")}
  2098. >
  2099. <ha-radio
  2100. name="event"
  2101. value="enter"
  2102. .checked=${"enter"===i}
  2103. @change=${this._radioGroupPicked}
  2104. ></ha-radio>
  2105. </ha-formfield>
  2106. <ha-formfield
  2107. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.type.zone.leave")}
  2108. >
  2109. <ha-radio
  2110. name="event"
  2111. value="leave"
  2112. .checked=${"leave"===i}
  2113. @change=${this._radioGroupPicked}
  2114. ></ha-radio>
  2115. </ha-formfield>
  2116. </label>
  2117. `}},{kind:"method",key:"_entityPicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.trigger,entity_id:e.detail.value}})}},{kind:"method",key:"_zonePicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.trigger,zone:e.detail.value}})}},{kind:"method",key:"_radioGroupPicked",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:{...this.trigger,event:e.target.value}})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2118. label {
  2119. display: flex;
  2120. align-items: center;
  2121. }
  2122. ha-entity-picker {
  2123. display: block;
  2124. margin-bottom: 24px;
  2125. }
  2126. `}]}}),g);const xu=(e,t)=>{var i,a;t.stopPropagation();const n=null===(i=t.currentTarget)||void 0===i?void 0:i.name;if(!n)return;const s=null===(a=t.target)||void 0===a?void 0:a.value;if((e.trigger[n]||"")===s)return;let r;void 0===s||""===s?(r={...e.trigger},delete r[n]):r={...e.trigger,[n]:s},o(e,"value-changed",{value:r})},$u=e=>e.preventDefault();f([A("ha-automation-trigger-row")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"trigger",value:void 0},{kind:"field",decorators:[Qi()],key:"_warnings",value:void 0},{kind:"field",decorators:[Qi()],key:"_yamlMode",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_requestShowId",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_triggered",value:void 0},{kind:"field",decorators:[Qi()],key:"_triggerColor",value:()=>!1},{kind:"field",decorators:[y("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"field",key:"_triggerUnsub",value:void 0},{kind:"method",key:"render",value:function(){const e=void 0!==customElements.get(`ha-automation-trigger-${this.trigger.platform}`),t=this._yamlMode||!e,i="id"in this.trigger||this._requestShowId;return x`
  2127. <ha-card outlined>
  2128. ${!1===this.trigger.enabled?x`
  2129. <div class="disabled-bar">
  2130. ${this.hass.localize("ui.panel.config.automation.editor.actions.disabled")}
  2131. </div>
  2132. `:""}
  2133. <ha-expansion-panel leftChevron>
  2134. <div slot="header">
  2135. <ha-svg-icon
  2136. class="trigger-icon"
  2137. .path=${hu[this.trigger.platform]}
  2138. ></ha-svg-icon>
  2139. ${us(ps(this.trigger,this.hass))}
  2140. </div>
  2141. <ha-button-menu
  2142. slot="icons"
  2143. fixed
  2144. corner="BOTTOM_START"
  2145. @action=${this._handleAction}
  2146. @click=${$u}
  2147. >
  2148. <ha-icon-button
  2149. slot="trigger"
  2150. .label=${this.hass.localize("ui.common.menu")}
  2151. .path=${ma}
  2152. ></ha-icon-button>
  2153. <mwc-list-item graphic="icon">
  2154. ${this.hass.localize("ui.panel.config.automation.editor.triggers.rename")}
  2155. <ha-svg-icon slot="graphic" .path=${fa}></ha-svg-icon>
  2156. </mwc-list-item>
  2157. <mwc-list-item graphic="icon">
  2158. ${this.hass.localize("ui.panel.config.automation.editor.actions.duplicate")}
  2159. <ha-svg-icon
  2160. slot="graphic"
  2161. .path=${ga}
  2162. ></ha-svg-icon>
  2163. </mwc-list-item>
  2164. <mwc-list-item graphic="icon">
  2165. ${this.hass.localize("ui.panel.config.automation.editor.triggers.edit_id")}
  2166. <ha-svg-icon slot="graphic" .path=${Ga}></ha-svg-icon>
  2167. </mwc-list-item>
  2168. <li divider role="separator"></li>
  2169. <mwc-list-item .disabled=${!e} graphic="icon">
  2170. ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")}
  2171. ${t?"":x`<ha-svg-icon
  2172. slot="graphic"
  2173. .path=${_a}
  2174. ></ha-svg-icon>`}
  2175. </mwc-list-item>
  2176. <mwc-list-item .disabled=${!e} graphic="icon">
  2177. ${this.hass.localize("ui.panel.config.automation.editor.edit_yaml")}
  2178. ${t?x`<ha-svg-icon
  2179. slot="graphic"
  2180. .path=${_a}
  2181. ></ha-svg-icon>`:""}
  2182. </mwc-list-item>
  2183. <li divider role="separator"></li>
  2184. <mwc-list-item graphic="icon">
  2185. ${!1===this.trigger.enabled?this.hass.localize("ui.panel.config.automation.editor.actions.enable"):this.hass.localize("ui.panel.config.automation.editor.actions.disable")}
  2186. <ha-svg-icon
  2187. slot="graphic"
  2188. .path=${!1===this.trigger.enabled?ya:ka}
  2189. ></ha-svg-icon>
  2190. </mwc-list-item>
  2191. <mwc-list-item class="warning" graphic="icon">
  2192. ${this.hass.localize("ui.panel.config.automation.editor.actions.delete")}
  2193. <ha-svg-icon
  2194. class="warning"
  2195. slot="graphic"
  2196. .path=${ea}
  2197. ></ha-svg-icon>
  2198. </mwc-list-item>
  2199. </ha-button-menu>
  2200. <div
  2201. class=${ba({"card-content":!0,disabled:!1===this.trigger.enabled})}
  2202. >
  2203. ${this._warnings?x`<ha-alert
  2204. alert-type="warning"
  2205. .title=${this.hass.localize("ui.errors.config.editor_not_supported")}
  2206. >
  2207. ${this._warnings.length&&void 0!==this._warnings[0]?x` <ul>
  2208. ${this._warnings.map((e=>x`<li>${e}</li>`))}
  2209. </ul>`:""}
  2210. ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")}
  2211. </ha-alert>`:""}
  2212. ${t?x`
  2213. ${e?"":x`
  2214. ${this.hass.localize("ui.panel.config.automation.editor.triggers.unsupported_platform","platform",this.trigger.platform)}
  2215. `}
  2216. <ha-yaml-editor
  2217. .hass=${this.hass}
  2218. .defaultValue=${this.trigger}
  2219. @value-changed=${this._onYamlChange}
  2220. ></ha-yaml-editor>
  2221. `:x`
  2222. ${i?x`
  2223. <ha-textfield
  2224. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.id")}
  2225. .value=${this.trigger.id||""}
  2226. @change=${this._idChanged}
  2227. >
  2228. </ha-textfield>
  2229. `:""}
  2230. <div @ui-mode-not-available=${this._handleUiModeNotAvailable}>
  2231. ${hn(`ha-automation-trigger-${this.trigger.platform}`,{hass:this.hass,trigger:this.trigger})}
  2232. </div>
  2233. `}
  2234. </div>
  2235. </ha-expansion-panel>
  2236. <div
  2237. class="triggered ${ba({active:void 0!==this._triggered,accent:this._triggerColor})}"
  2238. @click=${this._showTriggeredInfo}
  2239. >
  2240. ${this.hass.localize("ui.panel.config.automation.editor.triggers.triggered")}
  2241. </div>
  2242. </ha-card>
  2243. `}},{kind:"method",key:"updated",value:function(e){k(b(i.prototype),"updated",this).call(this,e),e.has("trigger")&&this._subscribeTrigger()}},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this),this.hasUpdated&&this.trigger&&this._subscribeTrigger()}},{kind:"method",key:"disconnectedCallback",value:function(){k(b(i.prototype),"disconnectedCallback",this).call(this),this._triggerUnsub&&(this._triggerUnsub.then((e=>e())),this._triggerUnsub=void 0),this._doSubscribeTrigger.cancel()}},{kind:"method",key:"_subscribeTrigger",value:function(){this._triggerUnsub&&(this._triggerUnsub.then((e=>e())),this._triggerUnsub=void 0),this._doSubscribeTrigger()}},{kind:"field",key:"_doSubscribeTrigger",value(){return un((async()=>{let e;const t=this.trigger;this._triggerUnsub&&(this._triggerUnsub.then((e=>e())),this._triggerUnsub=void 0);if(!(await uo(this.hass,{trigger:t})).trigger.valid||this.trigger!==t)return;const i=((e,t,i,a)=>e.connection.subscribeMessage(t,{type:"subscribe_trigger",trigger:i,variables:a}))(this.hass,(t=>{void 0!==e?(clearTimeout(e),this._triggerColor=!this._triggerColor):this._triggerColor=!1,this._triggered=t,e=window.setTimeout((()=>{this._triggered=void 0,e=void 0}),5e3)}),t);i.catch((()=>{this._triggerUnsub===i&&(this._triggerUnsub=void 0)})),this._triggerUnsub=i}),5e3)}},{kind:"method",key:"_handleUiModeNotAvailable",value:function(e){this._warnings=co(this.hass,e.detail).warnings,this._yamlMode||(this._yamlMode=!0)}},{kind:"method",key:"_handleAction",value:async function(e){switch(e.detail.index){case 0:await this._renameTrigger();break;case 1:o(this,"duplicate");break;case 2:this._requestShowId=!0,this.expand();break;case 3:this._switchUiMode(),this.expand();break;case 4:this._switchYamlMode(),this.expand();break;case 5:this._onDisable();break;case 6:this._onDelete()}}},{kind:"method",key:"_onDelete",value:function(){$n(this,{text:this.hass.localize("ui.panel.config.automation.editor.triggers.delete_confirm"),dismissText:this.hass.localize("ui.common.cancel"),confirmText:this.hass.localize("ui.common.delete"),confirm:()=>{o(this,"value-changed",{value:null})}})}},{kind:"method",key:"_onDisable",value:function(){var e;const t=!(null===(e=this.trigger.enabled)||void 0===e||e),i={...this.trigger,enabled:t};var a;(o(this,"value-changed",{value:i}),this._yamlMode)&&(null===(a=this._yamlEditor)||void 0===a||a.setValue(i))}},{kind:"method",key:"_idChanged",value:function(e){var t;const i=e.target.value;if(i===(null!==(t=this.trigger.id)&&void 0!==t?t:""))return;this._requestShowId=!0;const a={...this.trigger};i?a.id=i:delete a.id,o(this,"value-changed",{value:a})}},{kind:"method",key:"_onYamlChange",value:function(e){e.stopPropagation(),e.detail.isValid&&(this._warnings=void 0,o(this,"value-changed",{value:e.detail.value}))}},{kind:"method",key:"_switchUiMode",value:function(){this._warnings=void 0,this._yamlMode=!1}},{kind:"method",key:"_switchYamlMode",value:function(){this._warnings=void 0,this._yamlMode=!0}},{kind:"method",key:"_showTriggeredInfo",value:function(){wn(this,{text:x`
  2244. <ha-yaml-editor
  2245. readOnly
  2246. .hass=${this.hass}
  2247. .defaultValue=${this._triggered}
  2248. ></ha-yaml-editor>
  2249. `})}},{kind:"method",key:"_renameTrigger",value:async function(){const e=await Cn(this,{title:this.hass.localize("ui.panel.config.automation.editor.triggers.change_alias"),inputLabel:this.hass.localize("ui.panel.config.automation.editor.triggers.alias"),inputType:"string",placeholder:us(ps(this.trigger,this.hass,!0)),defaultValue:this.trigger.alias,confirmText:this.hass.localize("ui.common.submit")}),t={...this.trigger};var i;(e?t.alias=e:delete t.alias,o(this,"value-changed",{value:t}),this._yamlMode)&&(null===(i=this._yamlEditor)||void 0===i||i.setValue(t))}},{kind:"method",key:"expand",value:function(){this.updateComplete.then((()=>{this.shadowRoot.querySelector("ha-expansion-panel").expanded=!0}))}},{kind:"get",static:!0,key:"styles",value:function(){return[ia,r`
  2250. ha-button-menu {
  2251. --mdc-theme-text-primary-on-background: var(--primary-text-color);
  2252. }
  2253. .disabled {
  2254. opacity: 0.5;
  2255. pointer-events: none;
  2256. }
  2257. ha-expansion-panel {
  2258. --expansion-panel-summary-padding: 0 0 0 8px;
  2259. --expansion-panel-content-padding: 0;
  2260. }
  2261. .trigger-icon {
  2262. color: var(--sidebar-icon-color);
  2263. padding-right: 8px;
  2264. }
  2265. .card-content {
  2266. padding: 16px;
  2267. }
  2268. .disabled-bar {
  2269. background: var(--divider-color, #e0e0e0);
  2270. text-align: center;
  2271. border-top-right-radius: var(--ha-card-border-radius);
  2272. border-top-left-radius: var(--ha-card-border-radius);
  2273. }
  2274. .triggered {
  2275. cursor: pointer;
  2276. position: absolute;
  2277. top: 0px;
  2278. right: 0px;
  2279. left: 0px;
  2280. text-transform: uppercase;
  2281. font-weight: bold;
  2282. font-size: 14px;
  2283. background-color: var(--primary-color);
  2284. color: var(--text-primary-color);
  2285. max-height: 0px;
  2286. overflow: hidden;
  2287. transition: max-height 0.3s;
  2288. text-align: center;
  2289. border-top-right-radius: var(--ha-card-border-radius, 4px);
  2290. border-top-left-radius: var(--ha-card-border-radius, 4px);
  2291. }
  2292. .triggered.active {
  2293. max-height: 100px;
  2294. }
  2295. .triggered:hover {
  2296. opacity: 0.8;
  2297. }
  2298. .triggered.accent {
  2299. background-color: var(--accent-color);
  2300. color: var(--text-accent-color, var(--text-primary-color));
  2301. }
  2302. mwc-list-item[disabled] {
  2303. --mdc-theme-text-primary-on-background: var(--disabled-text-color);
  2304. }
  2305. ha-textfield {
  2306. display: block;
  2307. margin-bottom: 24px;
  2308. }
  2309. `]}}]}}),g),f([A("ha-automation-trigger")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"triggers",value:void 0},{kind:"field",key:"_focusLastTriggerOnChange",value:()=>!1},{kind:"field",key:"_triggerKeys",value:()=>new WeakMap},{kind:"method",key:"render",value:function(){return x`
  2310. ${Nn(this.triggers,(e=>this._getKey(e)),((e,t)=>x`
  2311. <ha-automation-trigger-row
  2312. .index=${t}
  2313. .trigger=${e}
  2314. @duplicate=${this._duplicateTrigger}
  2315. @value-changed=${this._triggerChanged}
  2316. .hass=${this.hass}
  2317. ></ha-automation-trigger-row>
  2318. `))}
  2319. <ha-button-menu @action=${this._addTrigger}>
  2320. <mwc-button
  2321. slot="trigger"
  2322. outlined
  2323. .label=${this.hass.localize("ui.panel.config.automation.editor.triggers.add")}
  2324. >
  2325. <ha-svg-icon .path=${ta} slot="icon"></ha-svg-icon>
  2326. </mwc-button>
  2327. ${this._processedTypes(this.hass.localize).map((([e,t,i])=>x`
  2328. <mwc-list-item .value=${e} aria-label=${t} graphic="icon">
  2329. ${t}<ha-svg-icon slot="graphic" .path=${i}></ha-svg-icon
  2330. ></mwc-list-item>
  2331. `))}
  2332. </ha-button-menu>
  2333. `}},{kind:"method",key:"updated",value:function(e){if(k(b(i.prototype),"updated",this).call(this,e),e.has("triggers")&&this._focusLastTriggerOnChange){this._focusLastTriggerOnChange=!1;const e=this.shadowRoot.querySelector("ha-automation-trigger-row:last-of-type");e.updateComplete.then((()=>{e.expand(),e.scrollIntoView(),e.focus()}))}}},{kind:"method",key:"_getKey",value:function(e){return this._triggerKeys.has(e)||this._triggerKeys.set(e,Math.random().toString()),this._triggerKeys.get(e)}},{kind:"method",key:"_addTrigger",value:function(e){const t=e.currentTarget.items[e.detail.index].value,i=customElements.get(`ha-automation-trigger-${t}`),a=this.triggers.concat({platform:t,...i.defaultConfig});this._focusLastTriggerOnChange=!0,o(this,"value-changed",{value:a})}},{kind:"method",key:"_triggerChanged",value:function(e){e.stopPropagation();const t=[...this.triggers],i=e.detail.value,a=e.target.index;if(null===i)t.splice(a,1);else{const e=this._getKey(t[a]);this._triggerKeys.set(i,e),t[a]=i}o(this,"value-changed",{value:t})}},{kind:"method",key:"_duplicateTrigger",value:function(e){e.stopPropagation();const t=e.target.index;o(this,"value-changed",{value:this.triggers.concat(Vn(this.triggers[t]))})}},{kind:"field",key:"_processedTypes",value:()=>n((e=>Object.entries(hu).map((([t,i])=>[t,e(`ui.panel.config.automation.editor.triggers.type.${t}.label`),i])).sort(((e,t)=>_s(e[1],t[1])))))},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2334. ha-automation-trigger-row {
  2335. display: block;
  2336. margin-bottom: 16px;
  2337. scroll-margin-top: 48px;
  2338. }
  2339. ha-svg-icon {
  2340. height: 20px;
  2341. }
  2342. `}}]}}),g),f([A("ha-automation-action-wait_for_trigger")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{wait_for_trigger:[]}}},{kind:"method",key:"render",value:function(){var e;const t=Bc(this.action.timeout);return x`
  2343. <ha-duration-input
  2344. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.wait_for_trigger.timeout")}
  2345. .data=${t}
  2346. enableMillisecond
  2347. @value-changed=${this._timeoutChanged}
  2348. ></ha-duration-input>
  2349. <ha-formfield
  2350. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.type.wait_for_trigger.continue_timeout")}
  2351. >
  2352. <ha-switch
  2353. .checked=${null===(e=this.action.continue_on_timeout)||void 0===e||e}
  2354. @change=${this._continueChanged}
  2355. ></ha-switch>
  2356. </ha-formfield>
  2357. <ha-automation-trigger
  2358. .triggers=${ko(this.action.wait_for_trigger)}
  2359. .hass=${this.hass}
  2360. .name=${"wait_for_trigger"}
  2361. @value-changed=${this._valueChanged}
  2362. ></ha-automation-trigger>
  2363. `}},{kind:"method",key:"_timeoutChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t&&o(this,"value-changed",{value:{...this.action,timeout:t}})}},{kind:"method",key:"_continueChanged",value:function(e){o(this,"value-changed",{value:{...this.action,continue_on_timeout:e.target.checked}})}},{kind:"method",key:"_valueChanged",value:function(e){Iu(this,e)}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2364. ha-duration-input {
  2365. display: block;
  2366. margin-bottom: 24px;
  2367. }
  2368. ha-automation-trigger {
  2369. display: block;
  2370. margin-top: 24px;
  2371. }
  2372. `}}]}}),g);const wu=[{name:"wait_template",selector:{template:{}}},{name:"timeout",required:!1,selector:{text:{}}},{name:"continue_on_timeout",selector:{boolean:{}}}];f([A("ha-automation-action-wait_template")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"action",value:void 0},{kind:"get",static:!0,key:"defaultConfig",value:function(){return{wait_template:"",continue_on_timeout:!0}}},{kind:"method",key:"render",value:function(){return x`
  2373. <ha-form
  2374. .hass=${this.hass}
  2375. .data=${this.action}
  2376. .schema=${wu}
  2377. .computeLabel=${this._computeLabelCallback}
  2378. ></ha-form>
  2379. `}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.panel.config.automation.editor.actions.type.wait_template.${"continue_on_timeout"===e.name?"continue_timeout":e.name}`)}}]}}),g);const Cu={condition:Wa,delay:re,event:ua,play_media:dt,activate_scene:ie,service:Ka,wait_template:Ya,wait_for_trigger:Ya,repeat:Za,choose:Qa,if:Ja,device_id:aa,stop:Xa,parallel:en},Au=e=>{if(e)return"service"in e||"scene"in e?go(e):["and","or","not"].some((t=>t in e))?"condition":Object.keys(Cu).find((t=>t in e))},Iu=(e,t)=>{var i,a;t.stopPropagation();const n=null===(i=t.target)||void 0===i?void 0:i.name;if(!n)return;const s=(null===(a=t.detail)||void 0===a?void 0:a.value)||t.target.value;if((e.action[n]||"")===s)return;let r;s?r={...e.action,[n]:s}:(r={...e.action},delete r[n]),o(e,"value-changed",{value:r})},Eu=e=>e.preventDefault();f([A("ha-automation-action-row")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"action",value:void 0},{kind:"field",decorators:[_()],key:"index",value:void 0},{kind:"field",decorators:[_()],key:"totalActions",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"narrow",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_warnings",value:void 0},{kind:"field",decorators:[Qi()],key:"_uiModeAvailable",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_yamlMode",value:()=>!1},{kind:"field",decorators:[y("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"method",key:"willUpdate",value:function(e){e.has("action")&&(this._uiModeAvailable=void 0!==Au(this.action),this._uiModeAvailable||this._yamlMode||(this._yamlMode=!0))}},{kind:"method",key:"updated",value:function(e){if(e.has("action")&&this._yamlMode){const e=this._yamlEditor;e&&e.value!==this.action&&e.setValue(this.action)}}},{kind:"method",key:"render",value:function(){const e=Au(this.action),t=this._yamlMode;return x`
  2380. <ha-card outlined>
  2381. ${!1===this.action.enabled?x`<div class="disabled-bar">
  2382. ${this.hass.localize("ui.panel.config.automation.editor.actions.disabled")}
  2383. </div>`:""}
  2384. <ha-expansion-panel leftChevron>
  2385. <div slot="header">
  2386. <ha-svg-icon
  2387. class="action-icon"
  2388. .path=${Cu[e]}
  2389. ></ha-svg-icon>
  2390. ${us(ms(this.hass,this.action))}
  2391. </div>
  2392. ${0!==this.index?x`
  2393. <ha-icon-button
  2394. slot="icons"
  2395. .label=${this.hass.localize("ui.panel.config.automation.editor.move_up")}
  2396. .path=${tn}
  2397. @click=${this._moveUp}
  2398. ></ha-icon-button>
  2399. `:""}
  2400. ${this.index!==this.totalActions-1?x`
  2401. <ha-icon-button
  2402. slot="icons"
  2403. .label=${this.hass.localize("ui.panel.config.automation.editor.move_down")}
  2404. .path=${an}
  2405. @click=${this._moveDown}
  2406. ></ha-icon-button>
  2407. `:""}
  2408. <ha-button-menu
  2409. slot="icons"
  2410. fixed
  2411. corner="BOTTOM_START"
  2412. @action=${this._handleAction}
  2413. @click=${Eu}
  2414. >
  2415. <ha-icon-button
  2416. slot="trigger"
  2417. .label=${this.hass.localize("ui.common.menu")}
  2418. .path=${ma}
  2419. ></ha-icon-button>
  2420. <mwc-list-item graphic="icon">
  2421. ${this.hass.localize("ui.panel.config.automation.editor.actions.run")}
  2422. <ha-svg-icon slot="graphic" .path=${dt}></ha-svg-icon>
  2423. </mwc-list-item>
  2424. <mwc-list-item graphic="icon">
  2425. ${this.hass.localize("ui.panel.config.automation.editor.actions.rename")}
  2426. <ha-svg-icon slot="graphic" .path=${fa}></ha-svg-icon>
  2427. </mwc-list-item>
  2428. <mwc-list-item graphic="icon">
  2429. ${this.hass.localize("ui.panel.config.automation.editor.actions.duplicate")}
  2430. <ha-svg-icon
  2431. slot="graphic"
  2432. .path=${ga}
  2433. ></ha-svg-icon>
  2434. </mwc-list-item>
  2435. <li divider role="separator"></li>
  2436. <mwc-list-item .disabled=${!this._uiModeAvailable} graphic="icon">
  2437. ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")}
  2438. ${t?"":x`<ha-svg-icon
  2439. slot="graphic"
  2440. .path=${_a}
  2441. ></ha-svg-icon>`}
  2442. </mwc-list-item>
  2443. <mwc-list-item .disabled=${!this._uiModeAvailable} graphic="icon">
  2444. ${this.hass.localize("ui.panel.config.automation.editor.edit_yaml")}
  2445. ${t?x`<ha-svg-icon
  2446. slot="graphic"
  2447. .path=${_a}
  2448. ></ha-svg-icon>`:""}
  2449. </mwc-list-item>
  2450. <li divider role="separator"></li>
  2451. <mwc-list-item graphic="icon">
  2452. ${!1===this.action.enabled?this.hass.localize("ui.panel.config.automation.editor.actions.enable"):this.hass.localize("ui.panel.config.automation.editor.actions.disable")}
  2453. <ha-svg-icon
  2454. slot="graphic"
  2455. .path=${!1===this.action.enabled?ya:ka}
  2456. ></ha-svg-icon>
  2457. </mwc-list-item>
  2458. <mwc-list-item class="warning" graphic="icon">
  2459. ${this.hass.localize("ui.panel.config.automation.editor.actions.delete")}
  2460. <ha-svg-icon
  2461. class="warning"
  2462. slot="graphic"
  2463. .path=${ea}
  2464. ></ha-svg-icon>
  2465. </mwc-list-item>
  2466. </ha-button-menu>
  2467. <div
  2468. class=${ba({"card-content":!0,disabled:!1===this.action.enabled})}
  2469. >
  2470. ${this._warnings?x`<ha-alert
  2471. alert-type="warning"
  2472. .title=${this.hass.localize("ui.errors.config.editor_not_supported")}
  2473. >
  2474. ${this._warnings.length>0&&void 0!==this._warnings[0]?x` <ul>
  2475. ${this._warnings.map((e=>x`<li>${e}</li>`))}
  2476. </ul>`:""}
  2477. ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")}
  2478. </ha-alert>`:""}
  2479. ${t?x`
  2480. ${void 0===e?x`
  2481. ${this.hass.localize("ui.panel.config.automation.editor.actions.unsupported_action","action",e)}
  2482. `:""}
  2483. <ha-yaml-editor
  2484. .hass=${this.hass}
  2485. .defaultValue=${this.action}
  2486. @value-changed=${this._onYamlChange}
  2487. ></ha-yaml-editor>
  2488. `:x`
  2489. <div @ui-mode-not-available=${this._handleUiModeNotAvailable}>
  2490. ${hn(`ha-automation-action-${e}`,{hass:this.hass,action:this.action,narrow:this.narrow})}
  2491. </div>
  2492. `}
  2493. </div>
  2494. </ha-expansion-panel>
  2495. </ha-card>
  2496. `}},{kind:"method",key:"_handleUiModeNotAvailable",value:function(e){e.stopPropagation(),this._warnings=co(this.hass,e.detail).warnings,this._yamlMode||(this._yamlMode=!0)}},{kind:"method",key:"_moveUp",value:function(e){e.preventDefault(),o(this,"move-action",{direction:"up"})}},{kind:"method",key:"_moveDown",value:function(e){e.preventDefault(),o(this,"move-action",{direction:"down"})}},{kind:"method",key:"_handleAction",value:async function(e){switch(e.detail.index){case 0:this._runAction();break;case 1:await this._renameAction();break;case 2:o(this,"duplicate");break;case 3:this._switchUiMode(),this.expand();break;case 4:this._switchYamlMode(),this.expand();break;case 5:this._onDisable();break;case 6:this._onDelete()}}},{kind:"method",key:"_onDisable",value:function(){var e;const t=!(null===(e=this.action.enabled)||void 0===e||e),i={...this.action,enabled:t};var a;(o(this,"value-changed",{value:i}),this._yamlMode)&&(null===(a=this._yamlEditor)||void 0===a||a.setValue(i))}},{kind:"method",key:"_runAction",value:async function(){const e=await uo(this.hass,{action:this.action});if(e.action.valid){try{await(t=this.hass,i=this.action,t.callWS({type:"execute_script",sequence:i}))}catch(e){return void wn(this,{title:this.hass.localize("ui.panel.config.automation.editor.actions.run_action_error"),text:e.message||e})}var t,i;fs(this,{message:this.hass.localize("ui.panel.config.automation.editor.actions.run_action_success")})}else wn(this,{title:this.hass.localize("ui.panel.config.automation.editor.actions.invalid_action"),text:e.action.error})}},{kind:"method",key:"_onDelete",value:function(){$n(this,{text:this.hass.localize("ui.panel.config.automation.editor.actions.delete_confirm"),dismissText:this.hass.localize("ui.common.cancel"),confirmText:this.hass.localize("ui.common.delete"),confirm:()=>{o(this,"value-changed",{value:null})}})}},{kind:"method",key:"_onYamlChange",value:function(e){e.stopPropagation(),e.detail.isValid&&o(this,"value-changed",{value:e.detail.value})}},{kind:"method",key:"_switchUiMode",value:function(){this._warnings=void 0,this._yamlMode=!1}},{kind:"method",key:"_switchYamlMode",value:function(){this._warnings=void 0,this._yamlMode=!0}},{kind:"method",key:"_renameAction",value:async function(){const e=await Cn(this,{title:this.hass.localize("ui.panel.config.automation.editor.actions.change_alias"),inputLabel:this.hass.localize("ui.panel.config.automation.editor.actions.alias"),inputType:"string",placeholder:us(ms(this.hass,this.action,void 0,!0)),defaultValue:this.action.alias,confirmText:this.hass.localize("ui.common.submit")}),t={...this.action};var i;(e?t.alias=e:delete t.alias,o(this,"value-changed",{value:t}),this._yamlMode)&&(null===(i=this._yamlEditor)||void 0===i||i.setValue(t))}},{kind:"method",key:"expand",value:function(){this.updateComplete.then((()=>{this.shadowRoot.querySelector("ha-expansion-panel").expanded=!0}))}},{kind:"get",static:!0,key:"styles",value:function(){return[ia,r`
  2497. ha-button-menu,
  2498. ha-icon-button {
  2499. --mdc-theme-text-primary-on-background: var(--primary-text-color);
  2500. }
  2501. .disabled {
  2502. opacity: 0.5;
  2503. pointer-events: none;
  2504. }
  2505. ha-expansion-panel {
  2506. --expansion-panel-summary-padding: 0 0 0 8px;
  2507. --expansion-panel-content-padding: 0;
  2508. }
  2509. .action-icon {
  2510. color: var(--sidebar-icon-color);
  2511. padding-right: 8px;
  2512. }
  2513. .card-content {
  2514. padding: 16px;
  2515. }
  2516. .disabled-bar {
  2517. background: var(--divider-color, #e0e0e0);
  2518. text-align: center;
  2519. border-top-right-radius: var(--ha-card-border-radius);
  2520. border-top-left-radius: var(--ha-card-border-radius);
  2521. }
  2522. mwc-list-item[disabled] {
  2523. --mdc-theme-text-primary-on-background: var(--disabled-text-color);
  2524. }
  2525. .warning ul {
  2526. margin: 4px 0;
  2527. }
  2528. `]}}]}}),g),f([A("ha-automation-action")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"narrow",value:()=>!1},{kind:"field",decorators:[_()],key:"actions",value:void 0},{kind:"field",key:"_focusLastActionOnChange",value:()=>!1},{kind:"field",key:"_actionKeys",value:()=>new WeakMap},{kind:"method",key:"render",value:function(){return x`
  2529. ${Nn(this.actions,(e=>this._getKey(e)),((e,t)=>x`
  2530. <ha-automation-action-row
  2531. .index=${t}
  2532. .totalActions=${this.actions.length}
  2533. .action=${e}
  2534. .narrow=${this.narrow}
  2535. @duplicate=${this._duplicateAction}
  2536. @move-action=${this._move}
  2537. @value-changed=${this._actionChanged}
  2538. .hass=${this.hass}
  2539. ></ha-automation-action-row>
  2540. `))}
  2541. <ha-button-menu fixed @action=${this._addAction}>
  2542. <mwc-button
  2543. slot="trigger"
  2544. outlined
  2545. .label=${this.hass.localize("ui.panel.config.automation.editor.actions.add")}
  2546. >
  2547. <ha-svg-icon .path=${ta} slot="icon"></ha-svg-icon>
  2548. </mwc-button>
  2549. ${this._processedTypes(this.hass.localize).map((([e,t,i])=>x`
  2550. <mwc-list-item .value=${e} aria-label=${t} graphic="icon">
  2551. ${t}<ha-svg-icon slot="graphic" .path=${i}></ha-svg-icon
  2552. ></mwc-list-item>
  2553. `))}
  2554. </ha-button-menu>
  2555. `}},{kind:"method",key:"updated",value:function(e){if(k(b(i.prototype),"updated",this).call(this,e),e.has("actions")&&this._focusLastActionOnChange){this._focusLastActionOnChange=!1;const e=this.shadowRoot.querySelector("ha-automation-action-row:last-of-type");e.updateComplete.then((()=>{e.expand(),e.scrollIntoView(),e.focus()}))}}},{kind:"method",key:"_getKey",value:function(e){return this._actionKeys.has(e)||this._actionKeys.set(e,Math.random().toString()),this._actionKeys.get(e)}},{kind:"method",key:"_addAction",value:function(e){const t=e.currentTarget.items[e.detail.index].value,i=customElements.get(`ha-automation-action-${t}`),a=this.actions.concat({...i.defaultConfig});this._focusLastActionOnChange=!0,o(this,"value-changed",{value:a})}},{kind:"method",key:"_move",value:function(e){e.stopPropagation();const t=e.target.index,i="up"===e.detail.direction?t-1:t+1,a=this.actions.concat(),n=a.splice(t,1)[0];a.splice(i,0,n),o(this,"value-changed",{value:a})}},{kind:"method",key:"_actionChanged",value:function(e){e.stopPropagation();const t=[...this.actions],i=e.detail.value,a=e.target.index;if(null===i)t.splice(a,1);else{const e=this._getKey(t[a]);this._actionKeys.set(i,e),t[a]=i}o(this,"value-changed",{value:t})}},{kind:"method",key:"_duplicateAction",value:function(e){e.stopPropagation();const t=e.target.index;o(this,"value-changed",{value:this.actions.concat(Vn(this.actions[t]))})}},{kind:"field",key:"_processedTypes",value:()=>n((e=>Object.entries(Cu).map((([t,i])=>[t,e(`ui.panel.config.automation.editor.actions.type.${t}.label`),i])).sort(((e,t)=>_s(e[1],t[1])))))},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2556. ha-automation-action-row {
  2557. display: block;
  2558. margin-bottom: 16px;
  2559. scroll-margin-top: 48px;
  2560. }
  2561. ha-svg-icon {
  2562. height: 20px;
  2563. }
  2564. `}}]}}),g),f([A("ha-selector-action")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"method",key:"render",value:function(){return x`<ha-automation-action
  2565. .disabled=${this.disabled}
  2566. .actions=${this.value||[]}
  2567. .hass=${this.hass}
  2568. ></ha-automation-action>`}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2569. ha-automation-action {
  2570. display: block;
  2571. margin-bottom: 16px;
  2572. }
  2573. :host([disabled]) ha-automation-action {
  2574. opacity: var(--light-disabled-opacity);
  2575. pointer-events: none;
  2576. }
  2577. `}}]}}),g);const zu=async e=>((e,t,i,a)=>{const[n,o,s]=e.split(".",3);return Number(n)>t||Number(n)===t&&(void 0===a?Number(o)>=i:Number(o)>i)||void 0!==a&&Number(n)===t&&Number(o)===i&&Number(s)>=a})(e.config.version,2021,2,4)?e.callWS({type:"supervisor/api",endpoint:"/addons",method:"get"}):(await e.callApi("GET","hassio/addons")).data,Su=e=>x`<mwc-list-item twoline graphic="icon">
  2578. <span>${e.name}</span>
  2579. <span slot="secondary">${e.slug}</span>
  2580. ${e.icon?x`<img slot="graphic" .src="/api/hassio/addons/${e.slug}/icon" />`:""}
  2581. </mwc-list-item>`;f([A("ha-addon-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:()=>""},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[Qi()],key:"_addons",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[y("ha-combo-box")],key:"_comboBox",value:void 0},{kind:"method",key:"open",value:function(){var e;null===(e=this._comboBox)||void 0===e||e.open()}},{kind:"method",key:"focus",value:function(){var e;null===(e=this._comboBox)||void 0===e||e.focus()}},{kind:"method",key:"firstUpdated",value:function(){this._getAddons()}},{kind:"method",key:"render",value:function(){return this._addons?x`
  2582. <ha-combo-box
  2583. .hass=${this.hass}
  2584. .label=${void 0===this.label&&this.hass?this.hass.localize("ui.components.addon-picker.addon"):this.label}
  2585. .value=${this._value}
  2586. .required=${this.required}
  2587. .disabled=${this.disabled}
  2588. .helper=${this.helper}
  2589. .renderer=${Su}
  2590. .items=${this._addons}
  2591. item-value-path="slug"
  2592. item-id-path="slug"
  2593. item-label-path="name"
  2594. @value-changed=${this._addonChanged}
  2595. ></ha-combo-box>
  2596. `:x``}},{kind:"method",key:"_getAddons",value:async function(){try{if(zn(this.hass,"hassio")){const e=await zu(this.hass);this._addons=e.addons.filter((e=>e.version)).sort(((e,t)=>_s(e.name,t.name)))}else wn(this,{title:this.hass.localize("ui.components.addon-picker.error.no_supervisor.title"),text:this.hass.localize("ui.components.addon-picker.error.no_supervisor.description")})}catch(e){wn(this,{title:this.hass.localize("ui.components.addon-picker.error.fetch_addons.title"),text:this.hass.localize("ui.components.addon-picker.error.fetch_addons.description")})}}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_addonChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t!==this._value&&this._setValue(t)}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{o(this,"value-changed",{value:e}),o(this,"change")}),0)}}]}}),g),f([A("ha-selector-addon")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`<ha-addon-picker
  2597. .hass=${this.hass}
  2598. .value=${this.value}
  2599. .label=${this.label}
  2600. .helper=${this.helper}
  2601. .disabled=${this.disabled}
  2602. .required=${this.required}
  2603. allow-custom-entity
  2604. ></ha-addon-picker>`}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2605. ha-addon-picker {
  2606. width: 100%;
  2607. }
  2608. `}]}}),g);const Tu=async(e,t,i,a,n,...o)=>{const s=n,r=s[e],l=r=>a&&a(n,r.result)!==r.cacheKey?(s[e]=void 0,Tu(e,t,i,a,n,...o)):r.result;if(r)return r instanceof Promise?r.then(l):l(r);const d=i(n,...o);return s[e]=d,d.then((i=>{s[e]={result:i,cacheKey:null==a?void 0:a(n,i)},setTimeout((()=>{s[e]=void 0}),t)}),(()=>{s[e]=void 0})),d},Lu=(e,t)=>e.callWS({type:"entity/source",entity_id:t}),Ou=(e,t)=>t?Lu(e,t):Tu("_entitySources",3e4,Lu,(e=>Object.keys(e.states).length),e),Mu=(e,t,i)=>{const{manufacturer:a,model:n,integration:o}=e;if(a&&t.manufacturer!==a)return!1;if(n&&t.model!==n)return!1;var s;if(o&&i&&(null==i||null===(s=i[t.id])||void 0===s||!s.includes(o)))return!1;return!0},Pu=(e,t,i)=>{var a;const{domain:n,device_class:o,integration:s}=e;if(n){const e=Hr(t);if(Array.isArray(n)?!n.includes(e):e!==n)return!1}return(!o||t.attributes.device_class===o)&&(!s||(null==i||null===(a=i[t.entity_id])||void 0===a?void 0:a.domain)===s)},Fu=e=>x`<mwc-list-item
  2609. class=${ba({"add-new":"add_new"===e.area_id})}
  2610. >
  2611. ${e.name}
  2612. </mwc-list-item>`;f([A("ha-area-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_({type:Boolean,attribute:"no-add"})],key:"noAdd",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_()],key:"deviceFilter",value:void 0},{kind:"field",decorators:[_()],key:"entityFilter",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[Qi()],key:"_areas",value:void 0},{kind:"field",decorators:[Qi()],key:"_devices",value:void 0},{kind:"field",decorators:[Qi()],key:"_entities",value:void 0},{kind:"field",decorators:[Qi()],key:"_opened",value:void 0},{kind:"field",decorators:[y("ha-combo-box",!0)],key:"comboBox",value:void 0},{kind:"field",key:"_filter",value:void 0},{kind:"field",key:"_init",value:()=>!1},{kind:"method",key:"hassSubscribe",value:function(){return[Ic(this.hass.connection,(e=>{this._areas=e})),Tc(this.hass.connection,(e=>{this._devices=e})),Pc(this.hass.connection,(e=>{this._entities=e}))]}},{kind:"method",key:"open",value:function(){this.updateComplete.then((()=>{var e;null===(e=this.comboBox)||void 0===e||e.open()}))}},{kind:"method",key:"focus",value:function(){this.updateComplete.then((()=>{var e;null===(e=this.comboBox)||void 0===e||e.focus()}))}},{kind:"field",key:"_getAreas",value(){return n(((e,t,i,a,n,o,s,r,l)=>{if(!e.length)return[{area_id:"no_areas",name:this.hass.localize("ui.components.area-picker.no_areas"),picture:null}];const d={};let c,u;if(a||n||o){for(const e of i)e.device_id&&(e.device_id in d||(d[e.device_id]=[]),d[e.device_id].push(e));c=t,u=i.filter((e=>e.area_id))}else s&&(c=t),r&&(u=i.filter((e=>e.area_id)));a&&(c=c.filter((e=>{const t=d[e.id];return!(!t||!t.length)&&d[e.id].some((e=>a.includes(gs(e.entity_id))))})),u=u.filter((e=>a.includes(gs(e.entity_id))))),n&&(c=c.filter((e=>{const t=d[e.id];return!t||!t.length||i.every((e=>!n.includes(gs(e.entity_id))))})),u=u.filter((e=>!n.includes(gs(e.entity_id))))),o&&(c=c.filter((e=>{const t=d[e.id];return!(!t||!t.length)&&d[e.id].some((e=>{const t=this.hass.states[e.entity_id];return!!t&&(t.attributes.device_class&&o.includes(t.attributes.device_class))}))})),u=u.filter((e=>{const t=this.hass.states[e.entity_id];return t.attributes.device_class&&o.includes(t.attributes.device_class)}))),s&&(c=c.filter((e=>s(e)))),r&&(u=u.filter((e=>r(e))));let h,p=e;var v;(c&&(h=c.filter((e=>e.area_id)).map((e=>e.area_id))),u)&&(h=(null!==(v=h)&&void 0!==v?v:[]).concat(u.filter((e=>e.area_id)).map((e=>e.area_id))));return h&&(p=e.filter((e=>h.includes(e.area_id)))),p.length||(p=[{area_id:"no_areas",name:this.hass.localize("ui.components.area-picker.no_match"),picture:null}]),l?p:[...p,{area_id:"add_new",name:this.hass.localize("ui.components.area-picker.add_new"),picture:null}]}))}},{kind:"method",key:"updated",value:function(e){(!this._init&&this._devices&&this._areas&&this._entities||e.has("_opened")&&this._opened)&&(this._init=!0,this.comboBox.items=this._getAreas(this._areas,this._devices,this._entities,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd))}},{kind:"method",key:"render",value:function(){var e;return this._devices&&this._areas&&this._entities?x`
  2613. <ha-combo-box
  2614. .hass=${this.hass}
  2615. .helper=${this.helper}
  2616. item-value-path="area_id"
  2617. item-id-path="area_id"
  2618. item-label-path="name"
  2619. .value=${this.value}
  2620. .disabled=${this.disabled}
  2621. .required=${this.required}
  2622. .label=${void 0===this.label&&this.hass?this.hass.localize("ui.components.area-picker.area"):this.label}
  2623. .placeholder=${this.placeholder?null===(e=this._area(this.placeholder))||void 0===e?void 0:e.name:void 0}
  2624. .renderer=${Fu}
  2625. @filter-changed=${this._filterChanged}
  2626. @opened-changed=${this._openedChanged}
  2627. @value-changed=${this._areaChanged}
  2628. >
  2629. </ha-combo-box>
  2630. `:x``}},{kind:"field",key:"_area",value(){return n((e=>{var t;return null===(t=this._areas)||void 0===t?void 0:t.find((t=>t.area_id===e))}))}},{kind:"method",key:"_filterChanged",value:function(e){var t,i;(this._filter=e.detail.value,this._filter)?this.noAdd||0!==(null===(t=this.comboBox._comboBox.filteredItems)||void 0===t?void 0:t.length)?this.comboBox.filteredItems=null===(i=this.comboBox.items)||void 0===i?void 0:i.filter((e=>e.name.toLowerCase().includes(this._filter.toLowerCase()))):this.comboBox.filteredItems=[{area_id:"add_new_suggestion",name:this.hass.localize("ui.components.area-picker.add_new_sugestion",{name:this._filter}),picture:null}]:this.comboBox.filteredItems=this.comboBox.items}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_areaChanged",value:function(e){e.stopPropagation();let t=e.detail.value;"no_areas"===t&&(t=""),["add_new_suggestion","add_new"].includes(t)?(e.target.value=this._value,Cn(this,{title:this.hass.localize("ui.components.area-picker.add_dialog.title"),text:this.hass.localize("ui.components.area-picker.add_dialog.text"),confirmText:this.hass.localize("ui.components.area-picker.add_dialog.add"),inputLabel:this.hass.localize("ui.components.area-picker.add_dialog.name"),defaultValue:"add_new_suggestion"===t?this._filter:void 0,confirm:async e=>{var t,i;if(e)try{const a=await(t=this.hass,i={name:e},t.callWS({type:"config/area_registry/create",...i}));this._areas=[...this._areas,a],this.comboBox.filteredItems=this._getAreas(this._areas,this._devices,this._entities,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd),await this.updateComplete,await this.comboBox.updateComplete,this._setValue(a.area_id)}catch(e){wn(this,{title:this.hass.localize("ui.components.area-picker.add_dialog.failed_create_area"),text:e.message})}}})):t!==this._value&&this._setValue(t)}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{o(this,"value-changed",{value:e}),o(this,"change")}),0)}}]}}),Fc(g)),f([A("ha-areas-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_({type:Boolean,attribute:"no-add"})],key:"noAdd",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_()],key:"deviceFilter",value:void 0},{kind:"field",decorators:[_()],key:"entityFilter",value:void 0},{kind:"field",decorators:[_({attribute:"picked-area-label"})],key:"pickedAreaLabel",value:void 0},{kind:"field",decorators:[_({attribute:"pick-area-label"})],key:"pickAreaLabel",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"method",key:"render",value:function(){if(!this.hass)return x``;const e=this._currentAreas;return x`
  2631. ${e.map((e=>x`
  2632. <div>
  2633. <ha-area-picker
  2634. .curValue=${e}
  2635. .noAdd=${this.noAdd}
  2636. .hass=${this.hass}
  2637. .value=${e}
  2638. .label=${this.pickedAreaLabel}
  2639. .includeDomains=${this.includeDomains}
  2640. .excludeDomains=${this.excludeDomains}
  2641. .includeDeviceClasses=${this.includeDeviceClasses}
  2642. .deviceFilter=${this.deviceFilter}
  2643. .entityFilter=${this.entityFilter}
  2644. .disabled=${this.disabled}
  2645. @value-changed=${this._areaChanged}
  2646. ></ha-area-picker>
  2647. </div>
  2648. `))}
  2649. <div>
  2650. <ha-area-picker
  2651. .noAdd=${this.noAdd}
  2652. .hass=${this.hass}
  2653. .label=${this.pickAreaLabel}
  2654. .helper=${this.helper}
  2655. .includeDomains=${this.includeDomains}
  2656. .excludeDomains=${this.excludeDomains}
  2657. .includeDeviceClasses=${this.includeDeviceClasses}
  2658. .deviceFilter=${this.deviceFilter}
  2659. .entityFilter=${this.entityFilter}
  2660. .disabled=${this.disabled}
  2661. .placeholder=${this.placeholder}
  2662. .required=${this.required&&!e.length}
  2663. @value-changed=${this._addArea}
  2664. ></ha-area-picker>
  2665. </div>
  2666. `}},{kind:"get",key:"_currentAreas",value:function(){return this.value||[]}},{kind:"method",key:"_updateAreas",value:async function(e){this.value=e,o(this,"value-changed",{value:e})}},{kind:"method",key:"_areaChanged",value:function(e){e.stopPropagation();const t=e.currentTarget.curValue,i=e.detail.value;if(i===t)return;const a=this._currentAreas;i&&!a.includes(i)?this._updateAreas(a.map((e=>e===t?i:e))):this._updateAreas(a.filter((e=>e!==t)))}},{kind:"method",key:"_addArea",value:function(e){e.stopPropagation();const t=e.detail.value;if(!t)return;e.currentTarget.value="";const i=this._currentAreas;i.includes(t)||this._updateAreas([...i,t])}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2667. div {
  2668. margin-top: 8px;
  2669. }
  2670. `}]}}),Fc(g)),f([A("ha-selector-area")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_entitySources",value:void 0},{kind:"field",decorators:[Qi()],key:"_entities",value:void 0},{kind:"field",key:"_deviceIntegrationLookup",value:()=>n(Lc)},{kind:"method",key:"hassSubscribe",value:function(){return[Pc(this.hass.connection,(e=>{this._entities=e.filter((e=>null!==e.device_id))}))]}},{kind:"method",key:"updated",value:function(e){var t,i;e.has("selector")&&(null!==(t=this.selector.area.device)&&void 0!==t&&t.integration||null!==(i=this.selector.area.entity)&&void 0!==i&&i.integration)&&!this._entitySources&&Ou(this.hass).then((e=>{this._entitySources=e}))}},{kind:"method",key:"render",value:function(){var e,t;return(null!==(e=this.selector.area.device)&&void 0!==e&&e.integration||null!==(t=this.selector.area.entity)&&void 0!==t&&t.integration)&&!this._entitySources?x``:this.selector.area.multiple?x`
  2671. <ha-areas-picker
  2672. .hass=${this.hass}
  2673. .value=${this.value}
  2674. .helper=${this.helper}
  2675. .pickAreaLabel=${this.label}
  2676. no-add
  2677. .deviceFilter=${this._filterDevices}
  2678. .entityFilter=${this._filterEntities}
  2679. .disabled=${this.disabled}
  2680. .required=${this.required}
  2681. ></ha-areas-picker>
  2682. `:x`
  2683. <ha-area-picker
  2684. .hass=${this.hass}
  2685. .value=${this.value}
  2686. .label=${this.label}
  2687. .helper=${this.helper}
  2688. no-add
  2689. .deviceFilter=${this._filterDevices}
  2690. .entityFilter=${this._filterEntities}
  2691. .disabled=${this.disabled}
  2692. .required=${this.required}
  2693. ></ha-area-picker>
  2694. `}},{kind:"field",key:"_filterEntities",value(){return e=>!this.selector.area.entity||Pu(this.selector.area.entity,e,this._entitySources)}},{kind:"field",key:"_filterDevices",value(){return e=>{if(!this.selector.area.device)return!0;const t=this._entitySources&&this._entities?this._deviceIntegrationLookup(this._entitySources,this._entities):void 0;return Mu(this.selector.area.device,e,t)}}}]}}),Fc(g)),f([A("ha-entity-attribute-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"entityId",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"hide-attributes"})],key:"hideAttributes",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autofocus",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"allow-custom-value"})],key:"allowCustomValue",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"_opened",value:()=>!1},{kind:"field",decorators:[y("ha-combo-box",!0)],key:"_comboBox",value:void 0},{kind:"method",key:"shouldUpdate",value:function(e){return!(!e.has("_opened")&&this._opened)}},{kind:"method",key:"updated",value:function(e){if(e.has("_opened")&&this._opened){const e=this.entityId?this.hass.states[this.entityId]:void 0;this._comboBox.items=e?Object.keys(e.attributes).filter((e=>{var t;return!(null!==(t=this.hideAttributes)&&void 0!==t&&t.includes(e))})).map((e=>({value:e,label:hs(e)}))):[]}}},{kind:"method",key:"render",value:function(){var e;return this.hass?x`
  2695. <ha-combo-box
  2696. .hass=${this.hass}
  2697. .value=${this.value?hs(this.value):""}
  2698. .autofocus=${this.autofocus}
  2699. .label=${null!==(e=this.label)&&void 0!==e?e:this.hass.localize("ui.components.entity.entity-attribute-picker.attribute")}
  2700. .disabled=${this.disabled||!this.entityId}
  2701. .required=${this.required}
  2702. .helper=${this.helper}
  2703. .allowCustomValue=${this.allowCustomValue}
  2704. item-value-path="value"
  2705. item-label-path="label"
  2706. @opened-changed=${this._openedChanged}
  2707. @value-changed=${this._valueChanged}
  2708. >
  2709. </ha-combo-box>
  2710. `:x``}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_valueChanged",value:function(e){this.value=e.detail.value}}]}}),g),f([A("ha-selector-attribute")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[_({attribute:!1})],key:"context",value:void 0},{kind:"method",key:"render",value:function(){var e;return x`
  2711. <ha-entity-attribute-picker
  2712. .hass=${this.hass}
  2713. .entityId=${this.selector.attribute.entity_id||(null===(e=this.context)||void 0===e?void 0:e.filter_entity)}
  2714. .hideAttributes=${this.selector.attribute.hide_attributes}
  2715. .value=${this.value}
  2716. .label=${this.label}
  2717. .helper=${this.helper}
  2718. .disabled=${this.disabled}
  2719. .required=${this.required}
  2720. allow-custom-value
  2721. ></ha-entity-attribute-picker>
  2722. `}},{kind:"method",key:"updated",value:function(e){if(k(b(i.prototype),"updated",this).call(this,e),!this.value||this.selector.attribute.entity_id||!e.has("context"))return;const t=e.get("context");if(!this.context||(null==t?void 0:t.filter_entity)===this.context.filter_entity)return;let a=!1;if(this.context.filter_entity){const e=this.hass.states[this.context.filter_entity];e&&this.value in e.attributes||(a=!0)}else a=void 0!==this.value;a&&o(this,"value-changed",{value:void 0})}}]}}),Fc(g)),f([A("ha-selector-boolean")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"method",key:"render",value:function(){return x`
  2723. <ha-formfield alignEnd spaceBetween .label=${this.label}>
  2724. <ha-switch
  2725. .checked=${this.value}
  2726. @change=${this._handleChange}
  2727. .disabled=${this.disabled}
  2728. ></ha-switch>
  2729. </ha-formfield>
  2730. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  2731. `}},{kind:"method",key:"_handleChange",value:function(e){const t=e.target.checked;this.value!==t&&o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2732. ha-formfield {
  2733. display: flex;
  2734. height: 56px;
  2735. align-items: center;
  2736. --mdc-typography-body2-font-size: 1em;
  2737. }
  2738. `}}]}}),g),f([A("ha-selector-color_rgb")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  2739. <ha-textfield
  2740. type="color"
  2741. helperPersistent
  2742. .value=${this.value?nn(this.value):""}
  2743. .label=${this.label||""}
  2744. .required=${this.required}
  2745. .helper=${this.helper}
  2746. .disalbled=${this.disabled}
  2747. @change=${this._valueChanged}
  2748. ></ha-textfield>
  2749. `}},{kind:"method",key:"_valueChanged",value:function(e){const t=e.target.value;o(this,"value-changed",{value:on(t)})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2750. :host {
  2751. display: flex;
  2752. justify-content: flex-end;
  2753. align-items: center;
  2754. }
  2755. ha-textfield {
  2756. --text-field-padding: 8px;
  2757. min-width: 75px;
  2758. flex-grow: 1;
  2759. margin: 0 4px;
  2760. }
  2761. `}]}}),g),f([A("ha-config-entry-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"integration",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:()=>""},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[Qi()],key:"_configEntries",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[y("ha-combo-box")],key:"_comboBox",value:void 0},{kind:"method",key:"open",value:function(){var e;null===(e=this._comboBox)||void 0===e||e.open()}},{kind:"method",key:"focus",value:function(){var e;null===(e=this._comboBox)||void 0===e||e.focus()}},{kind:"method",key:"firstUpdated",value:function(){this._getConfigEntries()}},{kind:"field",key:"_rowRenderer",value(){return e=>{var t;return x`<mwc-list-item twoline graphic="icon">
  2762. <span
  2763. >${e.title||this.hass.localize("ui.panel.config.integrations.config_entry.unnamed_entry")}</span
  2764. >
  2765. <span slot="secondary">${e.localized_domain_name}</span>
  2766. <img
  2767. slot="graphic"
  2768. src=${An({domain:e.domain,type:"icon",darkOptimized:null===(t=this.hass.themes)||void 0===t?void 0:t.darkMode})}
  2769. referrerpolicy="no-referrer"
  2770. @error=${this._onImageError}
  2771. @load=${this._onImageLoad}
  2772. />
  2773. </mwc-list-item>`}}},{kind:"method",key:"render",value:function(){return this._configEntries?x`
  2774. <ha-combo-box
  2775. .hass=${this.hass}
  2776. .label=${void 0===this.label&&this.hass?this.hass.localize("ui.components.config-entry-picker.config_entry"):this.label}
  2777. .value=${this._value}
  2778. .required=${this.required}
  2779. .disabled=${this.disabled}
  2780. .helper=${this.helper}
  2781. .renderer=${this._rowRenderer}
  2782. .items=${this._configEntries}
  2783. item-value-path="entry_id"
  2784. item-id-path="entry_id"
  2785. item-label-path="title"
  2786. @value-changed=${this._valueChanged}
  2787. ></ha-combo-box>
  2788. `:x``}},{kind:"method",key:"_onImageLoad",value:function(e){e.target.style.visibility="initial"}},{kind:"method",key:"_onImageError",value:function(e){e.target.style.visibility="hidden"}},{kind:"method",key:"_getConfigEntries",value:async function(){Sn(this.hass,{type:"integration",domain:this.integration}).then((e=>{this._configEntries=e.map((e=>({...e,localized_domain_name:Zc(this.hass.localize,e.domain)}))).sort(((e,t)=>ys(e.localized_domain_name+e.title,t.localized_domain_name+t.title)))}))}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value;t!==this._value&&this._setValue(t)}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{o(this,"value-changed",{value:e}),o(this,"change")}),0)}}]}}),g),f([A("ha-selector-config_entry")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`<ha-config-entry-picker
  2789. .hass=${this.hass}
  2790. .value=${this.value}
  2791. .label=${this.label}
  2792. .helper=${this.helper}
  2793. .disabled=${this.disabled}
  2794. .required=${this.required}
  2795. .integration=${this.selector.config_entry.integration}
  2796. allow-custom-entity
  2797. ></ha-config-entry-picker>`}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2798. ha-config-entry-picker {
  2799. width: 100%;
  2800. }
  2801. `}]}}),g);const Du=()=>import("./c.14dc9dca.js");f([A("ha-date-input")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"locale",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"method",key:"render",value:function(){return x`<ha-textfield
  2802. .label=${this.label}
  2803. .helper=${this.helper}
  2804. .disabled=${this.disabled}
  2805. iconTrailing
  2806. helperPersistent
  2807. @click=${this._openDialog}
  2808. .value=${this.value?(e=new Date(this.value),t=this.locale,os(t).format(e)):""}
  2809. .required=${this.required}
  2810. >
  2811. <ha-svg-icon slot="trailingIcon" .path=${T}></ha-svg-icon>
  2812. </ha-textfield>`;var e,t}},{kind:"method",key:"_openDialog",value:function(){var e,t;this.disabled||(e=this,t={min:"1970-01-01",value:this.value,onChange:e=>this._valueChanged(e),locale:this.locale.language},o(e,"show-dialog",{dialogTag:"ha-dialog-date-picker",dialogImport:Du,dialogParams:t}))}},{kind:"method",key:"_valueChanged",value:function(e){this.value!==e&&(this.value=e,o(this,"change"),o(this,"value-changed",{value:e}))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  2813. ha-svg-icon {
  2814. color: var(--secondary-text-color);
  2815. }
  2816. `}}]}}),g),f([A("ha-selector-date")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  2817. <ha-date-input
  2818. .label=${this.label}
  2819. .locale=${this.hass.locale}
  2820. .disabled=${this.disabled}
  2821. .value=${this.value}
  2822. .required=${this.required}
  2823. .helper=${this.helper}
  2824. >
  2825. </ha-date-input>
  2826. `}}]}}),g),f([A("ha-time-input")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"locale",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"enable-second"})],key:"enableSecond",value:()=>!1},{kind:"method",key:"render",value:function(){var e;const t=ss(this.locale),i=(null===(e=this.value)||void 0===e?void 0:e.split(":"))||[];let a=i[0];const n=Number(i[0]);return n&&t&&n>12&&n<24&&(a=String(n-12).padStart(2,"0")),t&&0===n&&(a="12"),x`
  2827. <ha-base-time-input
  2828. .label=${this.label}
  2829. .hours=${Number(a)}
  2830. .minutes=${Number(i[1])}
  2831. .seconds=${Number(i[2])}
  2832. .format=${t?12:24}
  2833. .amPm=${t&&n>=12?"PM":"AM"}
  2834. .disabled=${this.disabled}
  2835. @value-changed=${this._timeChanged}
  2836. .enableSecond=${this.enableSecond}
  2837. .required=${this.required}
  2838. .helper=${this.helper}
  2839. ></ha-base-time-input>
  2840. `}},{kind:"method",key:"_timeChanged",value:function(e){e.stopPropagation();const t=e.detail.value,i=ss(this.locale);let a=t.hours||0;t&&i&&("PM"===t.amPm&&a<12&&(a+=12),"AM"===t.amPm&&12===a&&(a=0));const n=`${a.toString().padStart(2,"0")}:${t.minutes?t.minutes.toString().padStart(2,"0"):"00"}:${t.seconds?t.seconds.toString().padStart(2,"0"):"00"}`;n!==this.value&&(this.value=n,o(this,"change"),o(this,"value-changed",{value:n}))}}]}}),g),f([A("ha-selector-datetime")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[y("ha-date-input")],key:"_dateInput",value:void 0},{kind:"field",decorators:[y("ha-time-input")],key:"_timeInput",value:void 0},{kind:"method",key:"render",value:function(){var e;const t=null===(e=this.value)||void 0===e?void 0:e.split(" ");return x`
  2841. <div class="input">
  2842. <ha-date-input
  2843. .label=${this.label}
  2844. .locale=${this.hass.locale}
  2845. .disabled=${this.disabled}
  2846. .required=${this.required}
  2847. .value=${null==t?void 0:t[0]}
  2848. @value-changed=${this._valueChanged}
  2849. >
  2850. </ha-date-input>
  2851. <ha-time-input
  2852. enable-second
  2853. .value=${(null==t?void 0:t[1])||"0:00:00"}
  2854. .locale=${this.hass.locale}
  2855. .disabled=${this.disabled}
  2856. .required=${this.required}
  2857. @value-changed=${this._valueChanged}
  2858. ></ha-time-input>
  2859. </div>
  2860. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  2861. `}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation(),o(this,"value-changed",{value:`${this._dateInput.value} ${this._timeInput.value}`})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2862. .input {
  2863. display: flex;
  2864. align-items: center;
  2865. flex-direction: row;
  2866. }
  2867. ha-date-input {
  2868. min-width: 150px;
  2869. margin-right: 4px;
  2870. }
  2871. `}]}}),g),f([A("ha-devices-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({attribute:"picked-device-label"}),_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",key:"pickedDeviceLabel",value:void 0},{kind:"field",decorators:[_({attribute:"pick-device-label"})],key:"pickDeviceLabel",value:void 0},{kind:"field",decorators:[_()],key:"deviceFilter",value:void 0},{kind:"method",key:"render",value:function(){if(!this.hass)return x``;const e=this._currentDevices;return x`
  2872. ${e.map((e=>x`
  2873. <div>
  2874. <ha-device-picker
  2875. allow-custom-entity
  2876. .curValue=${e}
  2877. .hass=${this.hass}
  2878. .deviceFilter=${this.deviceFilter}
  2879. .includeDomains=${this.includeDomains}
  2880. .excludeDomains=${this.excludeDomains}
  2881. .includeDeviceClasses=${this.includeDeviceClasses}
  2882. .value=${e}
  2883. .label=${this.pickedDeviceLabel}
  2884. .disabled=${this.disabled}
  2885. @value-changed=${this._deviceChanged}
  2886. ></ha-device-picker>
  2887. </div>
  2888. `))}
  2889. <div>
  2890. <ha-device-picker
  2891. allow-custom-entity
  2892. .hass=${this.hass}
  2893. .helper=${this.helper}
  2894. .deviceFilter=${this.deviceFilter}
  2895. .includeDomains=${this.includeDomains}
  2896. .excludeDomains=${this.excludeDomains}
  2897. .includeDeviceClasses=${this.includeDeviceClasses}
  2898. .label=${this.pickDeviceLabel}
  2899. .disabled=${this.disabled}
  2900. .required=${this.required&&!e.length}
  2901. @value-changed=${this._addDevice}
  2902. ></ha-device-picker>
  2903. </div>
  2904. `}},{kind:"get",key:"_currentDevices",value:function(){return this.value||[]}},{kind:"method",key:"_updateDevices",value:async function(e){o(this,"value-changed",{value:e}),this.value=e}},{kind:"method",key:"_deviceChanged",value:function(e){e.stopPropagation();const t=e.currentTarget.curValue,i=e.detail.value;i!==t&&""===i&&(""===i?this._updateDevices(this._currentDevices.filter((e=>e!==t))):this._updateDevices(this._currentDevices.map((e=>e===t?i:e))))}},{kind:"method",key:"_addDevice",value:async function(e){e.stopPropagation();const t=e.detail.value;if(e.currentTarget.value="",!t)return;const i=this._currentDevices;i.includes(t)||this._updateDevices([...i,t])}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2905. div {
  2906. margin-top: 8px;
  2907. }
  2908. `}]}}),g),f([A("ha-selector-device")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[Qi()],key:"_entitySources",value:void 0},{kind:"field",decorators:[Qi()],key:"_entities",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",key:"_deviceIntegrationLookup",value:()=>n(Lc)},{kind:"method",key:"hassSubscribe",value:function(){return[Pc(this.hass.connection,(e=>{this._entities=e.filter((e=>null!==e.device_id))}))]}},{kind:"method",key:"updated",value:function(e){k(b(i.prototype),"updated",this).call(this,e),e.has("selector")&&this.selector.device.integration&&!this._entitySources&&Ou(this.hass).then((e=>{this._entitySources=e}))}},{kind:"method",key:"render",value:function(){var e,t,i,a;return this.selector.device.integration&&!this._entitySources?x``:this.selector.device.multiple?x`
  2909. ${this.label?x`<label>${this.label}</label>`:""}
  2910. <ha-devices-picker
  2911. .hass=${this.hass}
  2912. .value=${this.value}
  2913. .helper=${this.helper}
  2914. .deviceFilter=${this._filterDevices}
  2915. .includeDeviceClasses=${null!==(e=this.selector.device.entity)&&void 0!==e&&e.device_class?[this.selector.device.entity.device_class]:void 0}
  2916. .includeDomains=${null!==(t=this.selector.device.entity)&&void 0!==t&&t.domain?[this.selector.device.entity.domain]:void 0}
  2917. .disabled=${this.disabled}
  2918. .required=${this.required}
  2919. ></ha-devices-picker>
  2920. `:x`
  2921. <ha-device-picker
  2922. .hass=${this.hass}
  2923. .value=${this.value}
  2924. .label=${this.label}
  2925. .helper=${this.helper}
  2926. .deviceFilter=${this._filterDevices}
  2927. .includeDeviceClasses=${null!==(i=this.selector.device.entity)&&void 0!==i&&i.device_class?[this.selector.device.entity.device_class]:void 0}
  2928. .includeDomains=${null!==(a=this.selector.device.entity)&&void 0!==a&&a.domain?[this.selector.device.entity.domain]:void 0}
  2929. .disabled=${this.disabled}
  2930. .required=${this.required}
  2931. allow-custom-entity
  2932. ></ha-device-picker>
  2933. `}},{kind:"field",key:"_filterDevices",value(){return e=>{const t=this._entitySources&&this._entities?this._deviceIntegrationLookup(this._entitySources,this._entities):void 0;return Mu(this.selector.device,e,t)}}}]}}),Fc(g)),f([A("ha-selector-duration")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  2934. <ha-duration-input
  2935. .label=${this.label}
  2936. .helper=${this.helper}
  2937. .data=${this.value}
  2938. .disabled=${this.disabled}
  2939. .required=${this.required}
  2940. ?enableDay=${this.selector.duration.enable_day}
  2941. ></ha-duration-input>
  2942. `}}]}}),g);const Bu=/^(\w+)\.(\w+)$/;f([A("ha-entities-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Array})],key:"value",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-unit-of-measurement"})],key:"includeUnitOfMeasurement",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-entities"})],key:"includeEntities",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"exclude-entities"})],key:"excludeEntities",value:void 0},{kind:"field",decorators:[_({attribute:"picked-entity-label"})],key:"pickedEntityLabel",value:void 0},{kind:"field",decorators:[_({attribute:"pick-entity-label"})],key:"pickEntityLabel",value:void 0},{kind:"field",decorators:[_()],key:"entityFilter",value:void 0},{kind:"method",key:"render",value:function(){if(!this.hass)return x``;const e=this._currentEntities;return x`
  2943. ${e.map((e=>x`
  2944. <div>
  2945. <ha-entity-picker
  2946. allow-custom-entity
  2947. .curValue=${e}
  2948. .hass=${this.hass}
  2949. .includeDomains=${this.includeDomains}
  2950. .excludeDomains=${this.excludeDomains}
  2951. .includeEntities=${this.includeEntities}
  2952. .excludeEntities=${this.excludeEntities}
  2953. .includeDeviceClasses=${this.includeDeviceClasses}
  2954. .includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
  2955. .entityFilter=${this._entityFilter}
  2956. .value=${e}
  2957. .label=${this.pickedEntityLabel}
  2958. .disabled=${this.disabled}
  2959. @value-changed=${this._entityChanged}
  2960. ></ha-entity-picker>
  2961. </div>
  2962. `))}
  2963. <div>
  2964. <ha-entity-picker
  2965. allow-custom-entity
  2966. .hass=${this.hass}
  2967. .includeDomains=${this.includeDomains}
  2968. .excludeDomains=${this.excludeDomains}
  2969. .includeEntities=${this.includeEntities}
  2970. .excludeEntities=${this.excludeEntities}
  2971. .includeDeviceClasses=${this.includeDeviceClasses}
  2972. .includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
  2973. .entityFilter=${this._entityFilter}
  2974. .label=${this.pickEntityLabel}
  2975. .helper=${this.helper}
  2976. .disabled=${this.disabled}
  2977. .required=${this.required&&!e.length}
  2978. @value-changed=${this._addEntity}
  2979. ></ha-entity-picker>
  2980. </div>
  2981. `}},{kind:"field",key:"_entityFilter",value(){return e=>(!this.value||!this.value.includes(e.entity_id))&&(!this.entityFilter||this.entityFilter(e))}},{kind:"get",key:"_currentEntities",value:function(){return this.value||[]}},{kind:"method",key:"_updateEntities",value:async function(e){this.value=e,o(this,"value-changed",{value:e})}},{kind:"method",key:"_entityChanged",value:function(e){e.stopPropagation();const t=e.currentTarget.curValue,i=e.detail.value;if(i===t||void 0!==i&&(a=i,!Bu.test(a)))return;var a;const n=this._currentEntities;i&&!n.includes(i)?this._updateEntities(n.map((e=>e===t?i:e))):this._updateEntities(n.filter((e=>e!==t)))}},{kind:"method",key:"_addEntity",value:async function(e){e.stopPropagation();const t=e.detail.value;if(!t)return;if(e.currentTarget.value="",!t)return;const i=this._currentEntities;i.includes(t)||this._updateEntities([...i,t])}},{kind:"field",static:!0,key:"styles",value:()=>r`
  2982. div {
  2983. margin-top: 8px;
  2984. }
  2985. `}]}}),g),f([A("ha-selector-entity")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[Qi()],key:"_entitySources",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return this.selector.entity.multiple?x`
  2986. ${this.label?x`<label>${this.label}</label>`:""}
  2987. <ha-entities-picker
  2988. .hass=${this.hass}
  2989. .value=${this.value}
  2990. .helper=${this.helper}
  2991. .includeEntities=${this.selector.entity.include_entities}
  2992. .excludeEntities=${this.selector.entity.exclude_entities}
  2993. .entityFilter=${this._filterEntities}
  2994. .disabled=${this.disabled}
  2995. .required=${this.required}
  2996. ></ha-entities-picker>
  2997. `:x`<ha-entity-picker
  2998. .hass=${this.hass}
  2999. .value=${this.value}
  3000. .label=${this.label}
  3001. .helper=${this.helper}
  3002. .includeEntities=${this.selector.entity.include_entities}
  3003. .excludeEntities=${this.selector.entity.exclude_entities}
  3004. .entityFilter=${this._filterEntities}
  3005. .disabled=${this.disabled}
  3006. .required=${this.required}
  3007. allow-custom-entity
  3008. ></ha-entity-picker>`}},{kind:"method",key:"updated",value:function(e){k(b(i.prototype),"updated",this).call(this,e),e.has("selector")&&this.selector.entity.integration&&!this._entitySources&&Ou(this.hass).then((e=>{this._entitySources=e}))}},{kind:"field",key:"_filterEntities",value(){return e=>Pu(this.selector.entity,e,this._entitySources)}}]}}),g);f([A("ha-file-upload")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"accept",value:void 0},{kind:"field",decorators:[_()],key:"icon",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:()=>null},{kind:"field",decorators:[_({type:Boolean})],key:"uploading",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"auto-open-file-dialog"})],key:"autoOpenFileDialog",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_drag",value:()=>!1},{kind:"field",decorators:[y("#input")],key:"_input",value:void 0},{kind:"method",key:"firstUpdated",value:function(e){k(b(i.prototype),"firstUpdated",this).call(this,e),this.autoOpenFileDialog&&this._openFilePicker()}},{kind:"method",key:"render",value:function(){var e;return x`
  3009. ${this.uploading?x`<ha-circular-progress
  3010. alt="Uploading"
  3011. size="large"
  3012. active
  3013. ></ha-circular-progress>`:x`
  3014. <label
  3015. for="input"
  3016. class="mdc-text-field mdc-text-field--filled ${ba({"mdc-text-field--focused":this._drag,"mdc-text-field--with-leading-icon":Boolean(this.icon),"mdc-text-field--with-trailing-icon":Boolean(this.value)})}"
  3017. @drop=${this._handleDrop}
  3018. @dragenter=${this._handleDragStart}
  3019. @dragover=${this._handleDragStart}
  3020. @dragleave=${this._handleDragEnd}
  3021. @dragend=${this._handleDragEnd}
  3022. >
  3023. <span class="mdc-text-field__ripple"></span>
  3024. <span
  3025. class="mdc-floating-label ${this.value||this._drag?"mdc-floating-label--float-above":""}"
  3026. id="label"
  3027. >${this.label}</span
  3028. >
  3029. ${this.icon?x`<span
  3030. class="mdc-text-field__icon mdc-text-field__icon--leading"
  3031. tabindex="-1"
  3032. >
  3033. <ha-icon-button
  3034. @click=${this._openFilePicker}
  3035. .path=${this.icon}
  3036. ></ha-icon-button>
  3037. </span>`:""}
  3038. <div class="value">${this.value}</div>
  3039. <input
  3040. id="input"
  3041. type="file"
  3042. class="mdc-text-field__input file"
  3043. accept=${this.accept}
  3044. @change=${this._handleFilePicked}
  3045. aria-labelledby="label"
  3046. />
  3047. ${this.value?x`<span
  3048. class="mdc-text-field__icon mdc-text-field__icon--trailing"
  3049. tabindex="1"
  3050. >
  3051. <ha-icon-button
  3052. slot="suffix"
  3053. @click=${this._clearValue}
  3054. .label=${(null===(e=this.hass)||void 0===e?void 0:e.localize("ui.common.close"))||"close"}
  3055. .path=${$}
  3056. ></ha-icon-button>
  3057. </span>`:""}
  3058. <span
  3059. class="mdc-line-ripple ${this._drag?"mdc-line-ripple--active":""}"
  3060. ></span>
  3061. </label>
  3062. `}
  3063. `}},{kind:"method",key:"_openFilePicker",value:function(){var e;null===(e=this._input)||void 0===e||e.click()}},{kind:"method",key:"_handleDrop",value:function(e){var t;e.preventDefault(),e.stopPropagation(),null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&o(this,"file-picked",{files:e.dataTransfer.files}),this._drag=!1}},{kind:"method",key:"_handleDragStart",value:function(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}},{kind:"method",key:"_handleDragEnd",value:function(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}},{kind:"method",key:"_handleFilePicked",value:function(e){o(this,"file-picked",{files:e.target.files})}},{kind:"method",key:"_clearValue",value:function(e){e.preventDefault(),this.value=null,o(this,"change")}},{kind:"get",static:!0,key:"styles",value:function(){return[kn,r`
  3064. :host {
  3065. display: block;
  3066. }
  3067. .mdc-text-field--filled {
  3068. height: auto;
  3069. padding-top: 16px;
  3070. cursor: pointer;
  3071. }
  3072. .mdc-text-field--filled.mdc-text-field--with-trailing-icon {
  3073. padding-top: 28px;
  3074. }
  3075. .mdc-text-field:not(.mdc-text-field--disabled) .mdc-text-field__icon {
  3076. color: var(--secondary-text-color);
  3077. }
  3078. .mdc-text-field--filled.mdc-text-field--with-trailing-icon
  3079. .mdc-text-field__icon {
  3080. align-self: flex-end;
  3081. }
  3082. .mdc-text-field__icon--leading {
  3083. margin-bottom: 12px;
  3084. inset-inline-start: initial;
  3085. inset-inline-end: 0px;
  3086. direction: var(--direction);
  3087. }
  3088. .mdc-text-field--filled .mdc-floating-label--float-above {
  3089. transform: scale(0.75);
  3090. top: 8px;
  3091. }
  3092. .mdc-floating-label {
  3093. inset-inline-start: 16px !important;
  3094. inset-inline-end: initial !important;
  3095. direction: var(--direction);
  3096. }
  3097. .mdc-text-field--filled .mdc-floating-label {
  3098. inset-inline-start: 48px !important;
  3099. inset-inline-end: initial !important;
  3100. direction: var(--direction);
  3101. }
  3102. .dragged:before {
  3103. position: var(--layout-fit_-_position);
  3104. top: var(--layout-fit_-_top);
  3105. right: var(--layout-fit_-_right);
  3106. bottom: var(--layout-fit_-_bottom);
  3107. left: var(--layout-fit_-_left);
  3108. background: currentColor;
  3109. content: "";
  3110. opacity: var(--dark-divider-opacity);
  3111. pointer-events: none;
  3112. border-radius: 4px;
  3113. }
  3114. .value {
  3115. width: 100%;
  3116. }
  3117. input.file {
  3118. display: none;
  3119. }
  3120. img {
  3121. max-width: 100%;
  3122. max-height: 125px;
  3123. }
  3124. ha-icon-button {
  3125. --mdc-icon-button-size: 24px;
  3126. --mdc-icon-size: 20px;
  3127. }
  3128. ha-circular-progress {
  3129. display: block;
  3130. text-align-last: center;
  3131. }
  3132. `]}}]}}),g),f([A("ha-selector-file")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_filename",value:void 0},{kind:"field",decorators:[Qi()],key:"_busy",value:()=>!1},{kind:"method",key:"render",value:function(){var e;return x`
  3133. <ha-file-upload
  3134. .hass=${this.hass}
  3135. .accept=${this.selector.file.accept}
  3136. .icon=${sn}
  3137. .label=${this.label}
  3138. .required=${this.required}
  3139. .disabled=${this.disabled}
  3140. .helper=${this.helper}
  3141. .uploading=${this._busy}
  3142. .value=${this.value?(null===(e=this._filename)||void 0===e?void 0:e.name)||"Unknown file":""}
  3143. @file-picked=${this._uploadFile}
  3144. @change=${this._removeFile}
  3145. ></ha-file-upload>
  3146. `}},{kind:"method",key:"willUpdate",value:function(e){k(b(i.prototype),"willUpdate",this).call(this,e),e.has("value")&&this._filename&&this.value!==this._filename.fileId&&(this._filename=void 0)}},{kind:"method",key:"_uploadFile",value:async function(e){this._busy=!0;const t=e.detail.files[0];try{const e=await(async(e,t)=>{const i=new FormData;i.append("file",t);const a=await e.fetchWithAuth("/api/file_upload",{method:"POST",body:i});if(413===a.status)throw new Error(`Uploaded file is too large (${t.name})`);if(200!==a.status)throw new Error("Unknown error");return(await a.json()).file_id})(this.hass,t);this._filename={fileId:e,name:t.name},o(this,"value-changed",{value:e})}catch(e){wn(this,{text:this.hass.localize("ui.components.selectors.file.upload_failed",{reason:e.message||e})})}finally{this._busy=!1}}},{kind:"field",key:"_removeFile",value(){return async()=>{this._busy=!0;try{await(async(e,t)=>e.callApi("DELETE","file_upload",{file_id:t}))(this.hass,this.value)}catch(e){}finally{this._busy=!1}this._filename=void 0,o(this,"value-changed",{value:""})}}}]}}),g),f([A("ha-selector-number")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"method",key:"render",value:function(){var e,t,i;const a="box"===this.selector.number.mode;return x`
  3147. <div class="input">
  3148. ${a?"":x`
  3149. ${this.label?x`${this.label}${this.required?" *":""}`:""}
  3150. <ha-slider
  3151. .min=${this.selector.number.min}
  3152. .max=${this.selector.number.max}
  3153. .value=${this._value}
  3154. .step=${null!==(e=this.selector.number.step)&&void 0!==e?e:1}
  3155. .disabled=${this.disabled}
  3156. .required=${this.required}
  3157. pin
  3158. ignore-bar-touch
  3159. @change=${this._handleSliderChange}
  3160. >
  3161. </ha-slider>
  3162. `}
  3163. <ha-textfield
  3164. inputMode="numeric"
  3165. pattern="[0-9]+([\\.][0-9]+)?"
  3166. .label=${"box"!==this.selector.number.mode?void 0:this.label}
  3167. .placeholder=${this.placeholder}
  3168. class=${ba({single:"box"===this.selector.number.mode})}
  3169. .min=${this.selector.number.min}
  3170. .max=${this.selector.number.max}
  3171. .value=${null!==(t=this.value)&&void 0!==t?t:""}
  3172. .step=${null!==(i=this.selector.number.step)&&void 0!==i?i:1}
  3173. helperPersistent
  3174. .helper=${a?this.helper:void 0}
  3175. .disabled=${this.disabled}
  3176. .required=${this.required}
  3177. .suffix=${this.selector.number.unit_of_measurement}
  3178. type="number"
  3179. autoValidate
  3180. ?no-spinner=${"box"!==this.selector.number.mode}
  3181. @input=${this._handleInputChange}
  3182. >
  3183. </ha-textfield>
  3184. </div>
  3185. ${!a&&this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  3186. `}},{kind:"get",key:"_value",value:function(){var e;return null!==(e=this.value)&&void 0!==e?e:this.selector.number.min||0}},{kind:"method",key:"_handleInputChange",value:function(e){e.stopPropagation();const t=""===e.target.value||isNaN(e.target.value)?this.required?this.selector.number.min||0:void 0:Number(e.target.value);this.value!==t&&o(this,"value-changed",{value:t})}},{kind:"method",key:"_handleSliderChange",value:function(e){e.stopPropagation();const t=Number(e.target.value);this.value!==t&&o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3187. .input {
  3188. display: flex;
  3189. justify-content: space-between;
  3190. align-items: center;
  3191. direction: ltr;
  3192. }
  3193. ha-slider {
  3194. flex: 1;
  3195. }
  3196. ha-textfield {
  3197. --ha-textfield-input-width: 40px;
  3198. }
  3199. .single {
  3200. --ha-textfield-input-width: unset;
  3201. flex: 1;
  3202. }
  3203. `}}]}}),g),f([A("ha-selector-object")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`<ha-yaml-editor
  3204. .hass=${this.hass}
  3205. .readonly=${this.disabled}
  3206. .label=${this.label}
  3207. .required=${this.required}
  3208. .placeholder=${this.placeholder}
  3209. .defaultValue=${this.value}
  3210. @value-changed=${this._handleChange}
  3211. ></ha-yaml-editor>
  3212. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""} `}},{kind:"method",key:"_handleChange",value:function(e){const t=e.target.value;e.target.isValid&&this.value!==t&&o(this,"value-changed",{value:t})}}]}}),g),ts&&await ts;const Nu=(e,t)=>Vu(t).format(e),Vu=n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{hour:"numeric",minute:"2-digit",hour12:ss(e)})));n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{hour:ss(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:ss(e)}))),n((e=>new Intl.DateTimeFormat("en"!==e.language||ss(e)?e.language:"en-u-hc-h23",{weekday:"long",hour:ss(e)?"numeric":"2-digit",minute:"2-digit",hour12:ss(e)}))),n((()=>new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!1})));const qu={s:1,min:60,h:3600,d:86400},ju=(e,t,i,a)=>Ru(e,i,t.entity_id,t.attributes,void 0!==a?a:t.state),Ru=(e,t,i,a,n)=>{if("unknown"===n||"unavailable"===n)return e(`state.default.${n}`);if((e=>!!e.unit_of_measurement||!!e.state_class)(a)){if("duration"===a.device_class&&a.unit_of_measurement&&qu[a.unit_of_measurement])try{return o=n,s=a.unit_of_measurement,yo(parseFloat(o)*qu[s])||"0"}catch(e){}if("monetary"===a.device_class)try{return ds(n,t,{style:"currency",currency:a.unit_of_measurement,minimumFractionDigits:2})}catch(e){}const e=a.unit_of_measurement?"%"===a.unit_of_measurement?"%":` ${a.unit_of_measurement}`:"";return`${ds(n,t)}${e}`}var o,s;const r=gs(i);if("input_datetime"===r){if(void 0===n){let e;return a.has_date&&a.has_time?(e=new Date(a.year,a.month-1,a.day,a.hour,a.minute),rs(e,t)):a.has_date?(e=new Date(a.year,a.month-1,a.day),as(e,t)):a.has_time?(e=new Date,e.setHours(a.hour,a.minute),Nu(e,t)):n}try{const e=n.split(" ");if(2===e.length)return rs(new Date(e.join("T")),t);if(1===e.length){if(n.includes("-"))return as(new Date(`${n}T00:00`),t);if(n.includes(":")){const e=new Date;return Nu(new Date(`${e.toISOString().split("T")[0]}T${n}`),t)}}return n}catch(e){return n}}if("humidifier"===r&&"on"===n&&a.humidity)return`${a.humidity} %`;if("counter"===r||"number"===r||"input_number"===r)return ds(n,t);if("button"===r||"input_button"===r||"scene"===r||"sensor"===r&&"timestamp"===a.device_class)try{return rs(new Date(n),t)}catch(e){return n}var l;return"update"===r?"on"===n?(e=>Jr(e)||!!e.in_progress)(a)?Qr(a,4)?e("ui.card.update.installing_with_progress",{progress:a.in_progress}):e("ui.card.update.installing"):a.latest_version:a.skipped_version===a.latest_version?null!==(l=a.latest_version)&&void 0!==l?l:e("state.default.unavailable"):e("ui.card.update.up_to_date"):a.device_class&&e(`component.${r}.state.${a.device_class}.${n}`)||e(`component.${r}.state._.${n}`)||n},Uu={alarm_control_panel:["armed_away","armed_custom_bypass","armed_home","armed_night","armed_vacation","arming","disarmed","disarming","pending","triggered"],automation:["on","off"],binary_sensor:["on","off"],button:[],calendar:["on","off"],camera:["idle","recording","streaming"],cover:["closed","closing","open","opening"],device_tracker:["home","not_home"],fan:["on","off"],humidifier:["on","off"],input_boolean:["on","off"],input_button:[],light:["on","off"],lock:["jammed","locked","locking","unlocked","unlocking"],media_player:["idle","off","paused","playing","standby"],person:["home","not_home"],remote:["on","off"],scene:[],schedule:["on","off"],script:["on","off"],siren:["on","off"],sun:["above_horizon","below_horizon"],switch:["on","off"],update:["on","off"],vacuum:["cleaning","docked","error","idle","paused","returning"],weather:["clear-night","cloudy","exceptional","fog","hail","lightning-rainy","lightning","partlycloudy","pouring","rainy","snowy-rainy","snowy","sunny","windy-variant","windy"]},Hu={alarm_control_panel:{code_format:["number","text"]},binary_sensor:{device_class:["battery","battery_charging","co","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","running","safety","smoke","sound","tamper","update","vibration","window"]},button:{device_class:["restart","update"]},camera:{frontend_stream_type:["hls","web_rtc"]},climate:{hvac_action:["off","idle","heating","cooling","drying","fan"]},cover:{device_class:["awning","blind","curtain","damper","door","garage","gate","shade","shutter","window"]},humidifier:{device_class:["humidifier","dehumidifier"]},media_player:{device_class:["tv","speaker","receiver"],media_content_type:["app","channel","episode","game","image","movie","music","playlist","tvshow","url","video"]},number:{device_class:["temperature"]},sensor:{device_class:["apparent_power","aqi","battery","carbon_dioxide","carbon_monoxide","current","date","duration","energy","frequency","gas","humidity","illuminance","monetary","nitrogen_dioxide","nitrogen_monoxide","nitrous_oxide","ozone","pm1","pm10","pm25","power_factor","power","pressure","reactive_power","signal_strength","sulphur_dioxide","temperature","timestamp","volatile_organic_compounds","voltage"],state_class:["measurement","total","total_increasing"]},switch:{device_class:["outlet","switch"]},update:{device_class:["firmware"]},water_heater:{away_mode:["on","off"]}};f([A("ha-entity-state-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"entityId",value:void 0},{kind:"field",decorators:[_()],key:"attribute",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autofocus",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"field",decorators:[_({type:Boolean,attribute:"allow-custom-value"})],key:"allowCustomValue",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"_opened",value:()=>!1},{kind:"field",decorators:[y("ha-combo-box",!0)],key:"_comboBox",value:void 0},{kind:"method",key:"shouldUpdate",value:function(e){return!(!e.has("_opened")&&this._opened)}},{kind:"method",key:"updated",value:function(e){if(e.has("_opened")&&this._opened){const e=this.entityId?this.hass.states[this.entityId]:void 0;this._comboBox.items=this.entityId&&e?((e,t)=>{const i=Hr(e),a=[];switch(!t&&i in Uu?a.push(...Uu[i]):t&&i in Hu&&t in Hu[i]&&a.push(...Hu[i][t]),i){case"climate":t?"fan_mode"===t?a.push(...e.attributes.fan_modes):"preset_mode"===t?a.push(...e.attributes.preset_modes):"swing_mode"===t&&a.push(...e.attributes.swing_modes):a.push(...e.attributes.hvac_modes);break;case"device_tracker":case"person":t||a.push("home","not_home");break;case"fan":"preset_mode"===t&&a.push(...e.attributes.preset_modes);break;case"humidifier":"mode"===t&&a.push(...e.attributes.available_modes);break;case"input_select":case"select":t||a.push(...e.attributes.options);break;case"light":"effect"===t?a.push(...e.attributes.effect_list):"color_mode"===t&&a.push(...e.attributes.color_modes);break;case"media_player":"sound_mode"===t?a.push(...e.attributes.sound_mode_list):"source"===t&&a.push(...e.attributes.source_list);break;case"remote":"current_activity"===t&&a.push(...e.attributes.activity_list);break;case"vacuum":"fan_speed"===t&&a.push(...e.attributes.fan_speed_list);break;case"water_heater":t&&"operation_mode"!==t||a.push(...e.attributes.operation_list)}return t||a.push(...Ur),[...new Set(a)]})(e,this.attribute).map((t=>({value:t,label:this.attribute?t:ju(this.hass.localize,e,this.hass.locale,t)}))):[]}}},{kind:"method",key:"render",value:function(){var e;return this.hass?x`
  3213. <ha-combo-box
  3214. .hass=${this.hass}
  3215. .value=${this.value?this.entityId&&this.hass.states[this.entityId]?ju(this.hass.localize,this.hass.states[this.entityId],this.hass.locale,this.value):this.value:""}
  3216. .autofocus=${this.autofocus}
  3217. .label=${null!==(e=this.label)&&void 0!==e?e:this.hass.localize("ui.components.entity.entity-state-picker.state")}
  3218. .disabled=${this.disabled||!this.entityId}
  3219. .required=${this.required}
  3220. .helper=${this.helper}
  3221. .allowCustomValue=${this.allowCustomValue}
  3222. item-value-path="value"
  3223. item-label-path="label"
  3224. @opened-changed=${this._openedChanged}
  3225. @value-changed=${this._valueChanged}
  3226. >
  3227. </ha-combo-box>
  3228. `:x``}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_valueChanged",value:function(e){this.value=e.detail.value}}]}}),g),f([A("ha-selector-state")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[_()],key:"context",value:void 0},{kind:"method",key:"render",value:function(){var e,t;return x`
  3229. <ha-entity-state-picker
  3230. .hass=${this.hass}
  3231. .entityId=${this.selector.state.entity_id||(null===(e=this.context)||void 0===e?void 0:e.filter_entity)}
  3232. .attribute=${this.selector.state.attribute||(null===(t=this.context)||void 0===t?void 0:t.filter_attribute)}
  3233. .value=${this.value}
  3234. .label=${this.label}
  3235. .helper=${this.helper}
  3236. .disabled=${this.disabled}
  3237. .required=${this.required}
  3238. allow-custom-value
  3239. ></ha-entity-state-picker>
  3240. `}}]}}),Fc(g)),f([A("ha-target-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[_({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[_()],key:"deviceFilter",value:void 0},{kind:"field",decorators:[_()],key:"entityRegFilter",value:void 0},{kind:"field",decorators:[_()],key:"entityFilter",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"horizontal",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_areas",value:void 0},{kind:"field",decorators:[Qi()],key:"_devices",value:void 0},{kind:"field",decorators:[Qi()],key:"_entities",value:void 0},{kind:"field",decorators:[Qi()],key:"_addMode",value:void 0},{kind:"field",decorators:[y("#input")],key:"_inputElement",value:void 0},{kind:"method",key:"hassSubscribe",value:function(){return[Ic(this.hass.connection,(e=>{const t={};for(const i of e)t[i.area_id]=i;this._areas=t})),Tc(this.hass.connection,(e=>{const t={};for(const i of e)t[i.id]=i;this._devices=t})),Pc(this.hass.connection,(e=>{this._entities=e}))]}},{kind:"method",key:"render",value:function(){return this._areas&&this._devices&&this._entities?x`
  3241. ${this.horizontal?x`
  3242. <div class="horizontal-container">
  3243. ${this._renderChips()} ${this._renderPicker()}
  3244. </div>
  3245. ${this._renderItems()}
  3246. `:x`
  3247. <div>
  3248. ${this._renderItems()} ${this._renderPicker()}
  3249. ${this._renderChips()}
  3250. </div>
  3251. `}
  3252. `:x``}},{kind:"method",key:"_renderItems",value:function(){var e,t,i;return x`
  3253. <div class="mdc-chip-set items">
  3254. ${null!==(e=this.value)&&void 0!==e&&e.area_id?ko(this.value.area_id).map((e=>{const t=this._areas[e];return this._renderChip("area_id",e,(null==t?void 0:t.name)||e,void 0,rn)})):""}
  3255. ${null!==(t=this.value)&&void 0!==t&&t.device_id?ko(this.value.device_id).map((e=>{const t=this._devices[e];return this._renderChip("device_id",e,t?Ec(t,this.hass):e,void 0,aa)})):""}
  3256. ${null!==(i=this.value)&&void 0!==i&&i.entity_id?ko(this.value.entity_id).map((e=>{const t=this.hass.states[e];return this._renderChip("entity_id",e,t?bo(t):e,t)})):""}
  3257. </div>
  3258. `}},{kind:"method",key:"_renderChips",value:function(){return x`
  3259. <div class="mdc-chip-set">
  3260. <div
  3261. class="mdc-chip area_id add"
  3262. .type=${"area_id"}
  3263. @click=${this._showPicker}
  3264. >
  3265. <div class="mdc-chip__ripple"></div>
  3266. <ha-svg-icon
  3267. class="mdc-chip__icon mdc-chip__icon--leading"
  3268. .path=${ta}
  3269. ></ha-svg-icon>
  3270. <span role="gridcell">
  3271. <span role="button" tabindex="0" class="mdc-chip__primary-action">
  3272. <span class="mdc-chip__text"
  3273. >${this.hass.localize("ui.components.target-picker.add_area_id")}</span
  3274. >
  3275. </span>
  3276. </span>
  3277. </div>
  3278. <div
  3279. class="mdc-chip device_id add"
  3280. .type=${"device_id"}
  3281. @click=${this._showPicker}
  3282. >
  3283. <div class="mdc-chip__ripple"></div>
  3284. <ha-svg-icon
  3285. class="mdc-chip__icon mdc-chip__icon--leading"
  3286. .path=${ta}
  3287. ></ha-svg-icon>
  3288. <span role="gridcell">
  3289. <span role="button" tabindex="0" class="mdc-chip__primary-action">
  3290. <span class="mdc-chip__text"
  3291. >${this.hass.localize("ui.components.target-picker.add_device_id")}</span
  3292. >
  3293. </span>
  3294. </span>
  3295. </div>
  3296. <div
  3297. class="mdc-chip entity_id add"
  3298. .type=${"entity_id"}
  3299. @click=${this._showPicker}
  3300. >
  3301. <div class="mdc-chip__ripple"></div>
  3302. <ha-svg-icon
  3303. class="mdc-chip__icon mdc-chip__icon--leading"
  3304. .path=${ta}
  3305. ></ha-svg-icon>
  3306. <span role="gridcell">
  3307. <span role="button" tabindex="0" class="mdc-chip__primary-action">
  3308. <span class="mdc-chip__text"
  3309. >${this.hass.localize("ui.components.target-picker.add_entity_id")}</span
  3310. >
  3311. </span>
  3312. </span>
  3313. </div>
  3314. </div>
  3315. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  3316. `}},{kind:"method",key:"_showPicker",value:async function(e){this._addMode=e.currentTarget.type,await this.updateComplete,setTimeout((()=>{var e,t;null===(e=this._inputElement)||void 0===e||e.open(),null===(t=this._inputElement)||void 0===t||t.focus()}),0)}},{kind:"method",key:"_renderChip",value:function(e,t,i,a,n){return x`
  3317. <div
  3318. class="mdc-chip ${ba({[e]:!0})}"
  3319. >
  3320. ${n?x`<ha-svg-icon
  3321. class="mdc-chip__icon mdc-chip__icon--leading"
  3322. .path=${n}
  3323. ></ha-svg-icon>`:""}
  3324. ${a?x`<ha-state-icon
  3325. class="mdc-chip__icon mdc-chip__icon--leading"
  3326. .state=${a}
  3327. ></ha-state-icon>`:""}
  3328. <span role="gridcell">
  3329. <span role="button" tabindex="0" class="mdc-chip__primary-action">
  3330. <span class="mdc-chip__text">${i}</span>
  3331. </span>
  3332. </span>
  3333. ${"entity_id"===e?"":x` <span role="gridcell">
  3334. <ha-icon-button
  3335. class="expand-btn mdc-chip__icon mdc-chip__icon--trailing"
  3336. tabindex="-1"
  3337. role="button"
  3338. .label=${this.hass.localize("ui.components.target-picker.expand")}
  3339. .path=${ln}
  3340. hideTooltip
  3341. .id=${t}
  3342. .type=${e}
  3343. @click=${this._handleExpand}
  3344. ></ha-icon-button>
  3345. <paper-tooltip class="expand" animation-delay="0"
  3346. >${this.hass.localize(`ui.components.target-picker.expand_${e}`)}</paper-tooltip
  3347. >
  3348. </span>`}
  3349. <span role="gridcell">
  3350. <ha-icon-button
  3351. class="mdc-chip__icon mdc-chip__icon--trailing"
  3352. tabindex="-1"
  3353. role="button"
  3354. .label=${this.hass.localize("ui.components.target-picker.remove")}
  3355. .path=${$}
  3356. hideTooltip
  3357. .id=${t}
  3358. .type=${e}
  3359. @click=${this._handleRemove}
  3360. ></ha-icon-button>
  3361. <paper-tooltip animation-delay="0"
  3362. >${this.hass.localize(`ui.components.target-picker.remove_${e}`)}</paper-tooltip
  3363. >
  3364. </span>
  3365. </div>
  3366. `}},{kind:"method",key:"_renderPicker",value:function(){switch(this._addMode){case"area_id":return x`
  3367. <ha-area-picker
  3368. .hass=${this.hass}
  3369. id="input"
  3370. .type=${"area_id"}
  3371. .label=${this.hass.localize("ui.components.target-picker.add_area_id")}
  3372. no-add
  3373. .deviceFilter=${this.deviceFilter}
  3374. .entityFilter=${this.entityRegFilter}
  3375. .includeDeviceClasses=${this.includeDeviceClasses}
  3376. .includeDomains=${this.includeDomains}
  3377. @value-changed=${this._targetPicked}
  3378. ></ha-area-picker>
  3379. `;case"device_id":return x`
  3380. <ha-device-picker
  3381. .hass=${this.hass}
  3382. id="input"
  3383. .type=${"device_id"}
  3384. .label=${this.hass.localize("ui.components.target-picker.add_device_id")}
  3385. .deviceFilter=${this.deviceFilter}
  3386. .entityFilter=${this.entityRegFilter}
  3387. .includeDeviceClasses=${this.includeDeviceClasses}
  3388. .includeDomains=${this.includeDomains}
  3389. @value-changed=${this._targetPicked}
  3390. ></ha-device-picker>
  3391. `;case"entity_id":return x`
  3392. <ha-entity-picker
  3393. .hass=${this.hass}
  3394. id="input"
  3395. .type=${"entity_id"}
  3396. .label=${this.hass.localize("ui.components.target-picker.add_entity_id")}
  3397. .entityFilter=${this.entityFilter}
  3398. .includeDeviceClasses=${this.includeDeviceClasses}
  3399. .includeDomains=${this.includeDomains}
  3400. @value-changed=${this._targetPicked}
  3401. allow-custom-entity
  3402. ></ha-entity-picker>
  3403. `}return x``}},{kind:"method",key:"_targetPicked",value:function(e){if(e.stopPropagation(),!e.detail.value)return;const t=e.detail.value,i=e.currentTarget;i.value="",this._addMode=void 0,o(this,"value-changed",{value:this.value?{...this.value,[i.type]:this.value[i.type]?[...ko(this.value[i.type]),t]:t}:{[i.type]:t}})}},{kind:"method",key:"_handleExpand",value:function(e){const t=e.currentTarget,i=[],a=[];if("area_id"===t.type)Object.values(this._devices).forEach((e=>{var a;e.area_id!==t.id||null!==(a=this.value.device_id)&&void 0!==a&&a.includes(e.id)||!this._deviceMeetsFilter(e)||i.push(e.id)})),this._entities.forEach((e=>{var i;e.area_id!==t.id||null!==(i=this.value.entity_id)&&void 0!==i&&i.includes(e.entity_id)||!this._entityRegMeetsFilter(e)||a.push(e.entity_id)}));else{if("device_id"!==t.type)return;this._entities.forEach((e=>{var i;e.device_id!==t.id||null!==(i=this.value.entity_id)&&void 0!==i&&i.includes(e.entity_id)||!this._entityRegMeetsFilter(e)||a.push(e.entity_id)}))}let n=this.value;a.length&&(n=this._addItems(n,"entity_id",a)),i.length&&(n=this._addItems(n,"device_id",i)),n=this._removeItem(n,t.type,t.id),o(this,"value-changed",{value:n})}},{kind:"method",key:"_handleRemove",value:function(e){const t=e.currentTarget;o(this,"value-changed",{value:this._removeItem(this.value,t.type,t.id)})}},{kind:"method",key:"_addItems",value:function(e,t,i){return{...e,[t]:e[t]?ko(e[t]).concat(i):i}}},{kind:"method",key:"_removeItem",value:function(e,t,i){const a=ko(e[t]).filter((e=>String(e)!==i));if(a.length)return{...e,[t]:a};const n={...e};return delete n[t],Object.keys(n).length?n:void 0}},{kind:"method",key:"_deviceMeetsFilter",value:function(e){var t;const i=null===(t=this._entities)||void 0===t?void 0:t.filter((t=>t.device_id===e.id));if(this.includeDomains){if(!i||!i.length)return!1;if(!i.some((e=>this.includeDomains.includes(gs(e.entity_id)))))return!1}if(this.includeDeviceClasses){if(!i||!i.length)return!1;if(!i.some((e=>{const t=this.hass.states[e.entity_id];return!!t&&(t.attributes.device_class&&this.includeDeviceClasses.includes(t.attributes.device_class))})))return!1}return!this.deviceFilter||this.deviceFilter(e)}},{kind:"method",key:"_entityRegMeetsFilter",value:function(e){if(e.entity_category)return!1;if(this.includeDomains&&!this.includeDomains.includes(gs(e.entity_id)))return!1;if(this.includeDeviceClasses){const t=this.hass.states[e.entity_id];if(!t)return!1;if(!t.attributes.device_class||!this.includeDeviceClasses.includes(t.attributes.device_class))return!1}return!this.entityRegFilter||this.entityRegFilter(e)}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3404. ${dn(En)}
  3405. .horizontal-container {
  3406. display: flex;
  3407. flex-wrap: wrap;
  3408. min-height: 56px;
  3409. align-items: center;
  3410. }
  3411. .mdc-chip {
  3412. color: var(--primary-text-color);
  3413. }
  3414. .items {
  3415. z-index: 2;
  3416. }
  3417. .mdc-chip-set {
  3418. padding: 4px 0;
  3419. }
  3420. .mdc-chip.add {
  3421. color: rgba(0, 0, 0, 0.87);
  3422. }
  3423. .mdc-chip:not(.add) {
  3424. cursor: default;
  3425. }
  3426. .mdc-chip ha-icon-button {
  3427. --mdc-icon-button-size: 24px;
  3428. display: flex;
  3429. align-items: center;
  3430. outline: none;
  3431. }
  3432. .mdc-chip ha-icon-button ha-svg-icon {
  3433. border-radius: 50%;
  3434. background: var(--secondary-text-color);
  3435. }
  3436. .mdc-chip__icon.mdc-chip__icon--trailing {
  3437. width: 16px;
  3438. height: 16px;
  3439. --mdc-icon-size: 14px;
  3440. color: var(--secondary-text-color);
  3441. margin-inline-start: 4px !important;
  3442. margin-inline-end: -4px !important;
  3443. direction: var(--direction);
  3444. }
  3445. .mdc-chip__icon--leading {
  3446. display: flex;
  3447. align-items: center;
  3448. justify-content: center;
  3449. --mdc-icon-size: 20px;
  3450. border-radius: 50%;
  3451. padding: 6px;
  3452. margin-left: -14px !important;
  3453. margin-inline-start: -14px !important;
  3454. margin-inline-end: 4px !important;
  3455. direction: var(--direction);
  3456. }
  3457. .expand-btn {
  3458. margin-right: 0;
  3459. }
  3460. .mdc-chip.area_id:not(.add) {
  3461. border: 2px solid #fed6a4;
  3462. background: var(--card-background-color);
  3463. }
  3464. .mdc-chip.area_id:not(.add) .mdc-chip__icon--leading,
  3465. .mdc-chip.area_id.add {
  3466. background: #fed6a4;
  3467. }
  3468. .mdc-chip.device_id:not(.add) {
  3469. border: 2px solid #a8e1fb;
  3470. background: var(--card-background-color);
  3471. }
  3472. .mdc-chip.device_id:not(.add) .mdc-chip__icon--leading,
  3473. .mdc-chip.device_id.add {
  3474. background: #a8e1fb;
  3475. }
  3476. .mdc-chip.entity_id:not(.add) {
  3477. border: 2px solid #d2e7b9;
  3478. background: var(--card-background-color);
  3479. }
  3480. .mdc-chip.entity_id:not(.add) .mdc-chip__icon--leading,
  3481. .mdc-chip.entity_id.add {
  3482. background: #d2e7b9;
  3483. }
  3484. .mdc-chip:hover {
  3485. z-index: 5;
  3486. }
  3487. paper-tooltip.expand {
  3488. min-width: 200px;
  3489. }
  3490. :host([disabled]) .mdc-chip {
  3491. opacity: var(--light-disabled-opacity);
  3492. pointer-events: none;
  3493. }
  3494. `}}]}}),Fc(g)),f([A("ha-selector-target")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[Qi()],key:"_entitySources",value:void 0},{kind:"field",decorators:[Qi()],key:"_entities",value:void 0},{kind:"field",key:"_deviceIntegrationLookup",value:()=>n(Lc)},{kind:"method",key:"hassSubscribe",value:function(){return[Pc(this.hass.connection,(e=>{this._entities=e.filter((e=>null!==e.device_id))}))]}},{kind:"method",key:"updated",value:function(e){var t,a;k(b(i.prototype),"updated",this).call(this,e),e.has("selector")&&(null!==(t=this.selector.target.device)&&void 0!==t&&t.integration||null!==(a=this.selector.target.entity)&&void 0!==a&&a.integration)&&!this._entitySources&&Ou(this.hass).then((e=>{this._entitySources=e}))}},{kind:"method",key:"render",value:function(){var e,t;return(null!==(e=this.selector.target.device)&&void 0!==e&&e.integration||null!==(t=this.selector.target.entity)&&void 0!==t&&t.integration)&&!this._entitySources?x``:x`<ha-target-picker
  3495. .hass=${this.hass}
  3496. .value=${this.value}
  3497. .helper=${this.helper}
  3498. .deviceFilter=${this._filterDevices}
  3499. .entityFilter=${this._filterEntities}
  3500. .disabled=${this.disabled}
  3501. ></ha-target-picker>`}},{kind:"field",key:"_filterEntities",value(){return e=>!this.selector.target.entity||Pu(this.selector.target.entity,e,this._entitySources)}},{kind:"field",key:"_filterDevices",value(){return e=>{if(!this.selector.target.device)return!0;const t=this._entitySources&&this._entities?this._deviceIntegrationLookup(this._entitySources,this._entities):void 0;return Mu(this.selector.target.device,e,t)}}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3502. ha-target-picker {
  3503. display: block;
  3504. }
  3505. `}}]}}),Fc(g)),f([A("ha-selector-template")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  3506. ${this.label?x`<p>${this.label}${this.required?" *":""}</p>`:""}
  3507. <ha-code-editor
  3508. mode="jinja2"
  3509. .hass=${this.hass}
  3510. .value=${this.value}
  3511. .readOnly=${this.disabled}
  3512. autofocus
  3513. autocomplete-entities
  3514. autocomplete-icons
  3515. @value-changed=${this._handleChange}
  3516. dir="ltr"
  3517. ></ha-code-editor>
  3518. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  3519. `}},{kind:"method",key:"_handleChange",value:function(e){const t=e.target.value;this.value!==t&&o(this,"value-changed",{value:t})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3520. p {
  3521. margin-top: 0;
  3522. }
  3523. `}}]}}),g),f([A("ha-selector-text")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[Qi()],key:"_unmaskedPassword",value:()=>!1},{kind:"method",key:"render",value:function(){var e,t,i,a,n;return null!==(e=this.selector.text)&&void 0!==e&&e.multiline?x`<ha-textarea
  3524. .label=${this.label}
  3525. .placeholder=${this.placeholder}
  3526. .value=${this.value||""}
  3527. .helper=${this.helper}
  3528. helperPersistent
  3529. .disabled=${this.disabled}
  3530. @input=${this._handleChange}
  3531. autocapitalize="none"
  3532. autocomplete="off"
  3533. spellcheck="false"
  3534. .required=${this.required}
  3535. autogrow
  3536. ></ha-textarea>`:x`<ha-textfield
  3537. .value=${this.value||""}
  3538. .placeholder=${this.placeholder||""}
  3539. .helper=${this.helper}
  3540. helperPersistent
  3541. .disabled=${this.disabled}
  3542. .type=${this._unmaskedPassword?"text":null===(t=this.selector.text)||void 0===t?void 0:t.type}
  3543. @input=${this._handleChange}
  3544. .label=${this.label||""}
  3545. .suffix=${"password"===(null===(i=this.selector.text)||void 0===i?void 0:i.type)?x`<div style="width: 24px"></div>`:null===(a=this.selector.text)||void 0===a?void 0:a.suffix}
  3546. .required=${this.required}
  3547. ></ha-textfield>
  3548. ${"password"===(null===(n=this.selector.text)||void 0===n?void 0:n.type)?x`<ha-icon-button
  3549. toggles
  3550. .label=${(this._unmaskedPassword?"Hide":"Show")+" password"}
  3551. @click=${this._toggleUnmaskedPassword}
  3552. .path=${this._unmaskedPassword?cn:ne}
  3553. ></ha-icon-button>`:""}`}},{kind:"method",key:"_toggleUnmaskedPassword",value:function(){this._unmaskedPassword=!this._unmaskedPassword}},{kind:"method",key:"_handleChange",value:function(e){let t=e.target.value;this.value!==t&&(""!==t||this.required||(t=void 0),o(this,"value-changed",{value:t}))}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3554. :host {
  3555. display: block;
  3556. position: relative;
  3557. }
  3558. ha-textarea,
  3559. ha-textfield {
  3560. width: 100%;
  3561. }
  3562. ha-icon-button {
  3563. position: absolute;
  3564. top: 16px;
  3565. right: 16px;
  3566. --mdc-icon-button-size: 24px;
  3567. --mdc-icon-size: 20px;
  3568. color: var(--secondary-text-color);
  3569. inset-inline-start: initial;
  3570. inset-inline-end: 16px;
  3571. direction: var(--direction);
  3572. }
  3573. `}}]}}),g),f([A("ha-selector-time")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"method",key:"render",value:function(){return x`
  3574. <ha-time-input
  3575. .value=${this.value}
  3576. .locale=${this.hass.locale}
  3577. .disabled=${this.disabled}
  3578. .required=${this.required}
  3579. .helper=${this.helper}
  3580. .label=${this.label}
  3581. enable-second
  3582. ></ha-time-input>
  3583. `}}]}}),g),f([A("ha-selector-icon")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  3584. <ha-icon-picker
  3585. .label=${this.label}
  3586. .value=${this.value}
  3587. .required=${this.required}
  3588. .disabled=${this.disabled}
  3589. .helper=${this.helper}
  3590. .fallbackPath=${this.selector.icon.fallbackPath}
  3591. .placeholder=${this.selector.icon.placeholder}
  3592. @value-changed=${this._valueChanged}
  3593. ></ha-icon-picker>
  3594. `}},{kind:"method",key:"_valueChanged",value:function(e){o(this,"value-changed",{value:e.detail.value})}}]}}),g),f([A("ha-theme-picker")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!1},{kind:"method",key:"render",value:function(){return x`
  3595. <ha-select
  3596. .label=${this.label||this.hass.localize("ui.components.theme-picker.theme")}
  3597. .value=${this.value}
  3598. .required=${this.required}
  3599. .disabled=${this.disabled}
  3600. @selected=${this._changed}
  3601. @closed=${Tn}
  3602. fixedMenuPosition
  3603. naturalMenuWidth
  3604. >
  3605. <mwc-list-item value="remove"
  3606. >${this.hass.localize("ui.components.theme-picker.no_theme")}</mwc-list-item
  3607. >
  3608. ${Object.keys(this.hass.themes.themes).sort().map((e=>x`<mwc-list-item .value=${e}>${e}</mwc-list-item>`))}
  3609. </ha-select>
  3610. `}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3611. ha-select {
  3612. width: 100%;
  3613. }
  3614. `}},{kind:"method",key:"_changed",value:function(e){this.hass&&""!==e.target.value&&(this.value="remove"===e.target.value?void 0:e.target.value,o(this,"value-changed",{value:this.value}))}}]}}),g),f([A("ha-selector-theme")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){return x`
  3615. <ha-theme-picker
  3616. .hass=${this.hass}
  3617. .value=${this.value}
  3618. .label=${this.label}
  3619. .disabled=${this.disabled}
  3620. .required=${this.required}
  3621. ></ha-theme-picker>
  3622. `}}]}}),g);const Gu=e=>e.tileLayer("https://basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}"+(e.Browser.retina?"@2x.png":".png"),{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>',subdomains:"abcd",minZoom:0,maxZoom:20}),Wu=async()=>{"function"!=typeof ResizeObserver&&(window.ResizeObserver=(await import("./c.004a7b01.js")).default)};let Ku=f(null,(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:"entity-id"})],key:"entityId",value:void 0},{kind:"field",decorators:[_({attribute:"entity-name"})],key:"entityName",value:void 0},{kind:"field",decorators:[_({attribute:"entity-picture"})],key:"entityPicture",value:void 0},{kind:"field",decorators:[_({attribute:"entity-color"})],key:"entityColor",value:void 0},{kind:"method",key:"render",value:function(){return x`
  3623. <div
  3624. class="marker"
  3625. style=${Ji({"border-color":this.entityColor})}
  3626. @click=${this._badgeTap}
  3627. >
  3628. ${this.entityPicture?x`<div
  3629. class="entity-picture"
  3630. style=${Ji({"background-image":`url(${this.entityPicture})`})}
  3631. ></div>`:this.entityName}
  3632. </div>
  3633. `}},{kind:"method",key:"_badgeTap",value:function(e){e.stopPropagation(),this.entityId&&o(this,"hass-more-info",{entityId:this.entityId})}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3634. .marker {
  3635. display: flex;
  3636. justify-content: center;
  3637. align-items: center;
  3638. box-sizing: border-box;
  3639. overflow: hidden;
  3640. width: 48px;
  3641. height: 48px;
  3642. font-size: var(--ha-marker-font-size, 1.5em);
  3643. border-radius: 50%;
  3644. border: 1px solid var(--ha-marker-color, var(--primary-color));
  3645. color: var(--primary-text-color);
  3646. background-color: var(--card-background-color);
  3647. }
  3648. .entity-picture {
  3649. background-size: cover;
  3650. height: 100%;
  3651. width: 100%;
  3652. }
  3653. `}}]}}),g);customElements.define("ha-entity-marker",Ku);const Yu=e=>"string"==typeof e?e:e.entity_id;f([A("ha-map")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"entities",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"paths",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"layers",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autoFit",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"fitZones",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"darkMode",value:void 0},{kind:"field",decorators:[_({type:Number})],key:"zoom",value:()=>14},{kind:"field",decorators:[Qi()],key:"_loaded",value:()=>!1},{kind:"field",key:"leafletMap",value:void 0},{kind:"field",key:"Leaflet",value:void 0},{kind:"field",key:"_resizeObserver",value:void 0},{kind:"field",key:"_mapItems",value:()=>[]},{kind:"field",key:"_mapZones",value:()=>[]},{kind:"field",key:"_mapPaths",value:()=>[]},{kind:"method",key:"connectedCallback",value:function(){k(b(i.prototype),"connectedCallback",this).call(this),this._loadMap(),this._attachObserver()}},{kind:"method",key:"disconnectedCallback",value:function(){k(b(i.prototype),"disconnectedCallback",this).call(this),this.leafletMap&&(this.leafletMap.remove(),this.leafletMap=void 0,this.Leaflet=void 0),this._loaded=!1,this._resizeObserver&&this._resizeObserver.unobserve(this)}},{kind:"method",key:"update",value:function(e){var t;if(k(b(i.prototype),"update",this).call(this,e),!this._loaded)return;const a=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities();else if(this._loaded&&a&&this.entities)for(const e of this.entities)if(a.states[Yu(e)]!==this.hass.states[Yu(e)]){this._drawEntities();break}if((e.has("_loaded")||e.has("paths"))&&this._drawPaths(),(e.has("_loaded")||e.has("layers"))&&this._drawLayers(e.get("layers")),(e.has("_loaded")||(e.has("entities")||e.has("layers"))&&this.autoFit)&&this.fitMap(),e.has("zoom")&&this.leafletMap.setZoom(this.zoom),!e.has("darkMode")&&(!e.has("hass")||a&&a.themes.darkMode===this.hass.themes.darkMode))return;const n=null!==(t=this.darkMode)&&void 0!==t?t:this.hass.themes.darkMode;this.shadowRoot.getElementById("map").classList.toggle("dark",n)}},{kind:"method",key:"_loadMap",value:async function(){var e;let t=this.shadowRoot.getElementById("map");t||(t=document.createElement("div"),t.id="map",this.shadowRoot.append(t));const i=null!==(e=this.darkMode)&&void 0!==e?e:this.hass.themes.darkMode;[this.leafletMap,this.Leaflet]=await(async e=>{if(!e.parentNode)throw new Error("Cannot setup Leaflet map on disconnected element");const t=(await import("./c.99c1c4ba.js")).default;t.Icon.Default.imagePath="/static/images/leaflet/images/";const i=t.map(e),a=document.createElement("link");return a.setAttribute("href","/static/images/leaflet/leaflet.css"),a.setAttribute("rel","stylesheet"),e.parentNode.appendChild(a),i.setView([52.3731339,4.8903147],13),[i,t,Gu(t).addTo(i)]})(t),this.shadowRoot.getElementById("map").classList.toggle("dark",i),this._loaded=!0}},{kind:"method",key:"fitMap",value:function(){var e,t;if(!this.leafletMap||!this.Leaflet||!this.hass)return;if(!(this._mapItems.length||null!==(e=this.layers)&&void 0!==e&&e.length))return void this.leafletMap.setView(new this.Leaflet.LatLng(this.hass.config.latitude,this.hass.config.longitude),this.zoom);let i=this.Leaflet.latLngBounds(this._mapItems?this._mapItems.map((e=>e.getLatLng())):[]);var a;this.fitZones&&(null===(a=this._mapZones)||void 0===a||a.forEach((e=>{i.extend("getBounds"in e?e.getBounds():e.getLatLng())})));null===(t=this.layers)||void 0===t||t.forEach((e=>{i.extend("getBounds"in e?e.getBounds():e.getLatLng())})),this.layers||(i=i.pad(.5)),this.leafletMap.fitBounds(i,{maxZoom:this.zoom})}},{kind:"method",key:"_drawLayers",value:function(e){if(e&&e.forEach((e=>e.remove())),!this.layers)return;const t=this.leafletMap;this.layers.forEach((e=>{t.addLayer(e)}))}},{kind:"method",key:"_drawPaths",value:function(){const e=this.hass,t=this.leafletMap,i=this.Leaflet;if(!e||!t||!i)return;if(this._mapPaths.length&&(this._mapPaths.forEach((e=>e.remove())),this._mapPaths=[]),!this.paths)return;const a=getComputedStyle(this).getPropertyValue("--dark-primary-color");this.paths.forEach((e=>{let n,o;e.gradualOpacity&&(n=e.gradualOpacity/(e.points.length-2),o=1-e.gradualOpacity);for(let t=0;t<e.points.length-1;t++){const s=e.gradualOpacity?o+t*n:void 0;this._mapPaths.push(i.circleMarker(e.points[t],{radius:3,color:e.color||a,opacity:s,fillOpacity:s,interactive:!1})),this._mapPaths.push(i.polyline([e.points[t],e.points[t+1]],{color:e.color||a,opacity:s,interactive:!1}))}const s=e.points.length-1;if(s>=0){const t=e.gradualOpacity?o+s*n:void 0;this._mapPaths.push(i.circleMarker(e.points[s],{radius:3,color:e.color||a,opacity:t,fillOpacity:t,interactive:!1}))}this._mapPaths.forEach((e=>t.addLayer(e)))}))}},{kind:"method",key:"_drawEntities",value:function(){var e;const t=this.hass,i=this.leafletMap,a=this.Leaflet;if(!t||!i||!a)return;if(this._mapItems.length&&(this._mapItems.forEach((e=>e.remove())),this._mapItems=[]),this._mapZones.length&&(this._mapZones.forEach((e=>e.remove())),this._mapZones=[]),!this.entities)return;const n=getComputedStyle(this),o=n.getPropertyValue("--accent-color"),s=n.getPropertyValue("--dark-primary-color"),r=(null!==(e=this.darkMode)&&void 0!==e?e:this.hass.themes.darkMode)?"dark":"light";for(const e of this.entities){const i=t.states[Yu(e)];if(!i)continue;const n=bo(i),{latitude:l,longitude:d,passive:c,icon:u,radius:h,entity_picture:p,gps_accuracy:v}=i.attributes;if(!l||!d)continue;if("zone"===Hr(i)){if(c)continue;let e="";if(u){const t=document.createElement("ha-icon");t.setAttribute("icon",u),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=n,e=t.outerHTML}this._mapZones.push(a.marker([l,d],{icon:a.divIcon({html:e,iconSize:[24,24],className:r}),interactive:!1,title:n})),this._mapZones.push(a.circle([l,d],{interactive:!1,color:o,radius:h}));continue}const m=n.split(" ").map((e=>e[0])).join("").substr(0,3);this._mapItems.push(a.marker([l,d],{icon:a.divIcon({html:`\n <ha-entity-marker\n entity-id="${Yu(e)}"\n entity-name="${m}"\n entity-picture="${p?this.hass.hassUrl(p):""}"\n ${"string"!=typeof e?`entity-color="${e.color}"`:""}\n ></ha-entity-marker>\n `,iconSize:[48,48],className:""}),title:bo(i)})),v&&this._mapItems.push(a.circle([l,d],{interactive:!1,color:s,radius:v}))}this._mapItems.forEach((e=>i.addLayer(e))),this._mapZones.forEach((e=>i.addLayer(e)))}},{kind:"method",key:"_attachObserver",value:async function(){this._resizeObserver||(await Wu(),this._resizeObserver=new ResizeObserver((()=>{var e;null===(e=this.leafletMap)||void 0===e||e.invalidateSize({debounceMoveend:!0})}))),this._resizeObserver.observe(this)}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3654. :host {
  3655. display: block;
  3656. height: 300px;
  3657. }
  3658. #map {
  3659. height: 100%;
  3660. }
  3661. #map.dark {
  3662. background: #090909;
  3663. --map-filter: invert(0.9) hue-rotate(170deg) grayscale(0.7);
  3664. }
  3665. .light {
  3666. color: #000000;
  3667. }
  3668. .dark {
  3669. color: #ffffff;
  3670. }
  3671. .leaflet-tile-pane {
  3672. filter: var(--map-filter);
  3673. }
  3674. .dark .leaflet-bar a {
  3675. background-color: var(--card-background-color, #1c1c1c);
  3676. color: #ffffff;
  3677. }
  3678. .leaflet-marker-draggable {
  3679. cursor: move !important;
  3680. }
  3681. .leaflet-edit-resize {
  3682. border-radius: 50%;
  3683. cursor: nesw-resize !important;
  3684. }
  3685. .named-icon {
  3686. display: flex;
  3687. align-items: center;
  3688. justify-content: center;
  3689. flex-direction: column;
  3690. text-align: center;
  3691. color: var(--primary-text-color);
  3692. }
  3693. .leaflet-pane {
  3694. z-index: 0 !important;
  3695. }
  3696. .leaflet-control,
  3697. .leaflet-top,
  3698. .leaflet-bottom {
  3699. z-index: 1 !important;
  3700. }
  3701. `}}]}}),ha),f([A("ha-locations-editor")],(function(e,t){class i extends t{constructor(){super(),e(this),import("./c.99c1c4ba.js").then((e=>{import("./c.bc53dda1.js").then((()=>{this.Leaflet=e.default,this._updateMarkers(),this.updateComplete.then((()=>this.fitMap()))}))}))}}return{F:i,d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"locations",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"autoFit",value:()=>!1},{kind:"field",decorators:[_({type:Number})],key:"zoom",value:()=>16},{kind:"field",decorators:[_({type:Boolean})],key:"darkMode",value:void 0},{kind:"field",decorators:[Qi()],key:"_locationMarkers",value:void 0},{kind:"field",decorators:[Qi()],key:"_circles",value:()=>({})},{kind:"field",decorators:[y("ha-map",!0)],key:"map",value:void 0},{kind:"field",key:"Leaflet",value:void 0},{kind:"method",key:"fitMap",value:function(){this.map.fitMap()}},{kind:"method",key:"fitMarker",value:function(e){if(!this.map.leafletMap||!this._locationMarkers)return;const t=this._locationMarkers[e];if(t)if("getBounds"in t)this.map.leafletMap.fitBounds(t.getBounds()),t.bringToFront();else{const i=this._circles[e];i?this.map.leafletMap.fitBounds(i.getBounds()):this.map.leafletMap.setView(t.getLatLng(),this.zoom)}}},{kind:"method",key:"render",value:function(){return x`
  3702. <ha-map
  3703. .hass=${this.hass}
  3704. .layers=${this._getLayers(this._circles,this._locationMarkers)}
  3705. .zoom=${this.zoom}
  3706. .autoFit=${this.autoFit}
  3707. .darkMode=${this.darkMode}
  3708. ></ha-map>
  3709. ${this.helper?x`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`:""}
  3710. `}},{kind:"field",key:"_getLayers",value:()=>n(((e,t)=>{const i=[];return Array.prototype.push.apply(i,Object.values(e)),t&&Array.prototype.push.apply(i,Object.values(t)),i}))},{kind:"method",key:"willUpdate",value:function(e){k(b(i.prototype),"willUpdate",this).call(this,e),this.Leaflet&&e.has("locations")&&this._updateMarkers()}},{kind:"method",key:"_updateLocation",value:function(e){const t=e.target,i=t.getLatLng();let a=i.lng;Math.abs(a)>180&&(a=(a%360+540)%360-180);const n=[i.lat,a];o(this,"location-updated",{id:t.id,location:n},{bubbles:!1})}},{kind:"method",key:"_updateRadius",value:function(e){const t=e.target,i=this._locationMarkers[t.id];o(this,"radius-updated",{id:t.id,radius:i.getRadius()},{bubbles:!1})}},{kind:"method",key:"_markerClicked",value:function(e){const t=e.target;o(this,"marker-clicked",{id:t.id},{bubbles:!1})}},{kind:"method",key:"_updateMarkers",value:function(){if(!this.locations||!this.locations.length)return this._circles={},void(this._locationMarkers=void 0);const e={},t={},i=getComputedStyle(this).getPropertyValue("--accent-color");this.locations.forEach((a=>{let n;if(a.icon){const e=document.createElement("div");e.className="named-icon",a.name&&(e.innerText=a.name);const t=document.createElement("ha-icon");t.setAttribute("icon",a.icon),e.prepend(t),n=this.Leaflet.divIcon({html:e.outerHTML,iconSize:[24,24],className:"light"})}if(a.radius){const o=this.Leaflet.circle([a.latitude,a.longitude],{color:a.radius_color||i,radius:a.radius});a.radius_editable||a.location_editable?(o.editing.enable(),o.addEventListener("add",(()=>{const e=o.editing._moveMarker,t=o.editing._resizeMarkers[0];n&&e.setIcon(n),t.id=e.id=a.id,e.addEventListener("dragend",(e=>this._updateLocation(e))).addEventListener("click",(e=>this._markerClicked(e))),a.radius_editable?t.addEventListener("dragend",(e=>this._updateRadius(e))):t.remove()})),e[a.id]=o):t[a.id]=o}if(!a.radius||!a.radius_editable&&!a.location_editable){const t={title:a.name,draggable:a.location_editable};n&&(t.icon=n);const i=this.Leaflet.marker([a.latitude,a.longitude],t).addEventListener("dragend",(e=>this._updateLocation(e))).addEventListener("click",(e=>this._markerClicked(e)));i.id=a.id,e[a.id]=i}})),this._circles=t,this._locationMarkers=e,o(this,"markers-updated")}},{kind:"get",static:!0,key:"styles",value:function(){return r`
  3711. ha-map {
  3712. display: block;
  3713. height: 100%;
  3714. }
  3715. `}}]}}),g),f([A("ha-selector-location")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[_({attribute:!1})],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"method",key:"render",value:function(){return x`
  3716. <ha-locations-editor
  3717. class="flex"
  3718. .hass=${this.hass}
  3719. .helper=${this.helper}
  3720. .locations=${this._location(this.selector,this.value)}
  3721. @location-updated=${this._locationChanged}
  3722. @radius-updated=${this._radiusChanged}
  3723. ></ha-locations-editor>
  3724. `}},{kind:"field",key:"_location",value(){return n(((e,t)=>{const i=getComputedStyle(this),a=e.location.radius?i.getPropertyValue("--zone-radius-color")||i.getPropertyValue("--accent-color"):void 0;return[{id:"location",latitude:(null==t?void 0:t.latitude)||this.hass.config.latitude,longitude:(null==t?void 0:t.longitude)||this.hass.config.longitude,radius:e.location.radius?(null==t?void 0:t.radius)||1e3:void 0,radius_color:a,icon:e.location.icon||e.location.radius?"mdi:map-marker-radius":"mdi:map-marker",location_editable:!0,radius_editable:!0}]}))}},{kind:"method",key:"_locationChanged",value:function(e){const[t,i]=e.detail.location;o(this,"value-changed",{value:{...this.value,latitude:t,longitude:i}})}},{kind:"method",key:"_radiusChanged",value:function(e){const t=e.detail.radius;o(this,"value-changed",{value:{...this.value,radius:t}})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  3725. :host {
  3726. display: block;
  3727. height: 400px;
  3728. }
  3729. `}]}}),g);customElements.define("ha-labeled-slider",class extends d{static get template(){return c`
  3730. <style>
  3731. :host {
  3732. display: block;
  3733. }
  3734. .title {
  3735. margin: 5px 0 8px;
  3736. color: var(--primary-text-color);
  3737. }
  3738. .slider-container {
  3739. display: flex;
  3740. }
  3741. ha-icon {
  3742. margin-top: 4px;
  3743. color: var(--secondary-text-color);
  3744. }
  3745. ha-slider {
  3746. flex-grow: 1;
  3747. background-image: var(--ha-slider-background);
  3748. border-radius: 4px;
  3749. }
  3750. </style>
  3751. <div class="title">[[_getTitle()]]</div>
  3752. <div class="extra-container"><slot name="extra"></slot></div>
  3753. <div class="slider-container">
  3754. <ha-icon icon="[[icon]]" hidden$="[[!icon]]"></ha-icon>
  3755. <ha-slider
  3756. min="[[min]]"
  3757. max="[[max]]"
  3758. step="[[step]]"
  3759. pin="[[pin]]"
  3760. disabled="[[disabled]]"
  3761. value="{{value}}"
  3762. ></ha-slider>
  3763. </div>
  3764. <template is="dom-if" if="[[helper]]">
  3765. <ha-input-helper-text>[[helper]]</ha-input-helper-text>
  3766. </template>
  3767. `}_getTitle(){return`${this.caption}${this.caption&&this.required?" *":""}`}static get properties(){return{caption:String,disabled:Boolean,required:Boolean,min:Number,max:Number,pin:Boolean,step:Number,helper:String,extra:{type:Boolean,value:!1},ignoreBarTouch:{type:Boolean,value:!0},icon:{type:String,value:""},value:{type:Number,notify:!0}}}}),f([A("ha-selector-color_temp")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"method",key:"render",value:function(){var e,t,i,a;return x`
  3768. <ha-labeled-slider
  3769. pin
  3770. icon="hass:thermometer"
  3771. .caption=${this.label||""}
  3772. .min=${null!==(e=null===(t=this.selector.color_temp)||void 0===t?void 0:t.min_mireds)&&void 0!==e?e:153}
  3773. .max=${null!==(i=null===(a=this.selector.color_temp)||void 0===a?void 0:a.max_mireds)&&void 0!==i?i:500}
  3774. .value=${this.value}
  3775. .disabled=${this.disabled}
  3776. .helper=${this.helper}
  3777. .required=${this.required}
  3778. @change=${this._valueChanged}
  3779. ></ha-labeled-slider>
  3780. `}},{kind:"method",key:"_valueChanged",value:function(e){o(this,"value-changed",{value:Number(e.target.value)})}},{kind:"field",static:!0,key:"styles",value:()=>r`
  3781. ha-labeled-slider {
  3782. --ha-slider-background: -webkit-linear-gradient(
  3783. right,
  3784. rgb(255, 160, 0) 0%,
  3785. white 50%,
  3786. rgb(166, 209, 255) 100%
  3787. );
  3788. /* The color temp minimum value shouldn't be rendered differently. It's not "off". */
  3789. --paper-slider-knob-start-border-color: var(--primary-color);
  3790. }
  3791. `}]}}),g);let Zu=f([A("ha-selector")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[_()],key:"hass",value:void 0},{kind:"field",decorators:[_()],key:"selector",value:void 0},{kind:"field",decorators:[_()],key:"value",value:void 0},{kind:"field",decorators:[_()],key:"label",value:void 0},{kind:"field",decorators:[_()],key:"helper",value:void 0},{kind:"field",decorators:[_()],key:"placeholder",value:void 0},{kind:"field",decorators:[_({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[_({type:Boolean})],key:"required",value:()=>!0},{kind:"field",decorators:[_()],key:"context",value:void 0},{kind:"method",key:"focus",value:function(){var e,t;null===(e=this.shadowRoot)||void 0===e||null===(t=e.getElementById("selector"))||void 0===t||t.focus()}},{kind:"get",key:"_type",value:function(){return Object.keys(this.selector)[0]}},{kind:"method",key:"render",value:function(){return x`
  3792. ${hn(`ha-selector-${this._type}`,{hass:this.hass,selector:this.selector,value:this.value,label:this.label,placeholder:this.placeholder,disabled:this.disabled,required:this.required,helper:this.helper,context:this.context,id:"selector"})}
  3793. `}}]}}),g);var Qu=Object.freeze({__proto__:null,HaSelector:Zu});export{Xc as B,eu as M,Ur as U,ys as a,tu as b,Nn as c,su as d,jo as e,Ro as f,Wr as g,qo as h,Wu as i,Qu as j,To as l,Yo as t};