c.9afde0cb.js 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  1. import{am as e,X as t,an as i,ao as a,ap as o,V as s,W as l,a5 as r,_ as n,j as c,e as d,i as h,y as u,aq as f,I as p,J as b,d as m,n as _,t as v,E as g,G as y,k,C as w,p as x,ar as $,as as R,ad as z,a4 as C,at as T,h as S,R as D,au as H,af as E,av as F,N as L,aw as M,ax as P,ay as B,az as j,aA as A,aB as O,ae as N,aC as I,c as W}from"./main-ec7846c8.js";import{c as U,b as q}from"./c.eea05cf6.js";import{p as K}from"./c.aaeac12d.js";import{L as V}from"./c.840a95b4.js";import{d as G,s as Y}from"./c.0e3055bd.js";import"./c.fbbe4b73.js";import{b as X}from"./c.07e395f8.js";import{m as Z}from"./c.551b8e45.js";import{a as J}from"./c.cb96fbc8.js";import{r as Q,a as ee}from"./c.0193255c.js";import"./c.27e9c060.js";import{d as te}from"./c.10855172.js";import{i as ie}from"./c.21c042d4.js";import"./c.8e28b461.js";import"./c.743a15a1.js";import"./c.2610e8cd.js";import"./c.a0946910.js";import"./c.55291b50.js";import"./c.48e5c8c7.js";import"./c.f2bb3724.js";var ae=new Set;const oe=[{properties:{_parentResizable:{type:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:!1}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"},created:function(){this._interestedResizables=[],this._boundNotifyResize=this.notifyResize.bind(this),this._boundOnDescendantIronResize=this._onDescendantIronResize.bind(this)},attached:function(){this._requestResizeNotifications()},detached:function(){this._parentResizable?this._parentResizable.stopResizeNotificationsFor(this):(ae.delete(this),window.removeEventListener("resize",this._boundNotifyResize)),this._parentResizable=null},notifyResize:function(){this.isAttached&&(this._interestedResizables.forEach((function(e){this.resizerShouldNotify(e)&&this._notifyDescendant(e)}),this),this._fireResize())},assignParentResizable:function(e){this._parentResizable&&this._parentResizable.stopResizeNotificationsFor(this),this._parentResizable=e,e&&-1===e._interestedResizables.indexOf(this)&&(e._interestedResizables.push(this),e._subscribeIronResize(this))},stopResizeNotificationsFor:function(e){var t=this._interestedResizables.indexOf(e);t>-1&&(this._interestedResizables.splice(t,1),this._unsubscribeIronResize(e))},_subscribeIronResize:function(e){e.addEventListener("iron-resize",this._boundOnDescendantIronResize)},_unsubscribeIronResize:function(e){e.removeEventListener("iron-resize",this._boundOnDescendantIronResize)},resizerShouldNotify:function(e){return!0},_onDescendantIronResize:function(t){this._notifyingDescendant?t.stopPropagation():e||this._fireResize()},_fireResize:function(){this.fire("iron-resize",null,{node:this,bubbles:!1})},_onIronRequestResizeNotifications:function(e){var i=t(e).rootTarget;i!==this&&(i.assignParentResizable(this),this._notifyDescendant(i),e.stopPropagation())},_parentResizableChanged:function(e){e&&window.removeEventListener("resize",this._boundNotifyResize)},_notifyDescendant:function(e){this.isAttached&&(this._notifyingDescendant=!0,e.notifyResize(),this._notifyingDescendant=!1)},_requestResizeNotifications:function(){if(this.isAttached)if("loading"===document.readyState){var e=this._requestResizeNotifications.bind(this);document.addEventListener("readystatechange",(function t(){document.removeEventListener("readystatechange",t),e()}))}else this._findParent(),this._parentResizable?this._parentResizable._interestedResizables.forEach((function(e){e!==this&&e._findParent()}),this):(ae.forEach((function(e){e!==this&&e._findParent()}),this),window.addEventListener("resize",this._boundNotifyResize),this.notifyResize())},_findParent:function(){this.assignParentResizable(null),this.fire("iron-request-resize-notifications",null,{node:this,bubbles:!0,cancelable:!0}),this._parentResizable?ae.delete(this):ae.add(this)}},{listeners:{"app-reset-layout":"_appResetLayoutHandler","iron-resize":"resetLayout"},attached:function(){this.fire("app-reset-layout")},_appResetLayoutHandler:function(e){t(e).path[0]!==this&&(this.resetLayout(),e.stopPropagation())},_updateLayoutStates:function(){console.error("unimplemented")},resetLayout:function(){var e=this._updateLayoutStates.bind(this);this._layoutDebouncer=i.debounce(this._layoutDebouncer,a,e),o(this._layoutDebouncer),this._notifyDescendantResize()},_notifyLayoutChanged:function(){var e=this;requestAnimationFrame((function(){e.fire("app-reset-layout")}))},_notifyDescendantResize:function(){this.isAttached&&this._interestedResizables.forEach((function(e){this.resizerShouldNotify(e)&&this._notifyDescendant(e)}),this)}}],se={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:!0,_scrollTargetChanged:function(e,i){if(this._oldScrollTarget&&(this._toggleScrollListener(!1,this._oldScrollTarget),this._oldScrollTarget=null),i)if("document"===e)this.scrollTarget=this._doc;else if("string"==typeof e){var a=this.domHost;this.scrollTarget=a&&a.$?a.$[e]:t(this.ownerDocument).querySelector("#"+e)}else this._isValidScrollTarget()&&(this._oldScrollTarget=e,this._toggleScrollListener(this._shouldHaveListener,e))},_scrollHandler:function(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop:0},get _scrollLeft(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft:0},set _scrollTop(e){this.scrollTarget===this._doc?window.scrollTo(window.pageXOffset,e):this._isValidScrollTarget()&&(this.scrollTarget.scrollTop=e)},set _scrollLeft(e){this.scrollTarget===this._doc?window.scrollTo(e,window.pageYOffset):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=e)},scroll:function(e,t){var i;"object"==typeof e?(i=e.left,t=e.top):i=e,i=i||0,t=t||0,this.scrollTarget===this._doc?window.scrollTo(i,t):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=i,this.scrollTarget.scrollTop=t)},get _scrollTargetWidth(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth:0},get _scrollTargetHeight(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight:0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(e,t){var i=t===this._doc?window:t;e?this._boundScrollHandler||(this._boundScrollHandler=this._scrollHandler.bind(this),i.addEventListener("scroll",this._boundScrollHandler)):this._boundScrollHandler&&(i.removeEventListener("scroll",this._boundScrollHandler),this._boundScrollHandler=null)},toggleScrollListener:function(e){this._shouldHaveListener=e,this._toggleScrollListener(e,this.scrollTarget)}},le={},re=[se,{properties:{effects:{type:String},effectsConfig:{type:Object,value:function(){return{}}},disabled:{type:Boolean,reflectToAttribute:!0,value:!1},threshold:{type:Number,value:0},thresholdTriggered:{type:Boolean,notify:!0,readOnly:!0,reflectToAttribute:!0}},observers:["_effectsChanged(effects, effectsConfig, isAttached)"],_updateScrollState:function(e){},isOnScreen:function(){return!1},isContentBelow:function(){return!1},_effectsRunFn:null,_effects:null,get _clampedScrollTop(){return Math.max(0,this._scrollTop)},attached:function(){this._scrollStateChanged()},detached:function(){this._tearDownEffects()},createEffect:function(e,t){var i=le[e];if(!i)throw new ReferenceError(this._getUndefinedMsg(e));var a=this._boundEffect(i,t||{});return a.setUp(),a},_effectsChanged:function(e,t,i){this._tearDownEffects(),e&&i&&(e.split(" ").forEach((function(e){var i;""!==e&&((i=le[e])?this._effects.push(this._boundEffect(i,t[e])):console.warn(this._getUndefinedMsg(e)))}),this),this._setUpEffect())},_layoutIfDirty:function(){return this.offsetWidth},_boundEffect:function(e,t){t=t||{};var i=parseFloat(t.startsAt||0),a=parseFloat(t.endsAt||1),o=a-i,s=function(){},l=0===i&&1===a?e.run:function(t,a){e.run.call(this,Math.max(0,(t-i)/o),a)};return{setUp:e.setUp?e.setUp.bind(this,t):s,run:e.run?l.bind(this):s,tearDown:e.tearDown?e.tearDown.bind(this):s}},_setUpEffect:function(){this.isAttached&&this._effects&&(this._effectsRunFn=[],this._effects.forEach((function(e){!1!==e.setUp()&&this._effectsRunFn.push(e.run)}),this))},_tearDownEffects:function(){this._effects&&this._effects.forEach((function(e){e.tearDown()})),this._effectsRunFn=[],this._effects=[]},_runEffects:function(e,t){this._effectsRunFn&&this._effectsRunFn.forEach((function(i){i(e,t)}))},_scrollHandler:function(){this._scrollStateChanged()},_scrollStateChanged:function(){if(!this.disabled){var e=this._clampedScrollTop;this._updateScrollState(e),this.threshold>0&&this._setThresholdTriggered(e>=this.threshold)}},_getDOMRef:function(e){console.warn("_getDOMRef","`"+e+"` is undefined")},_getUndefinedMsg:function(e){return"Scroll effect `"+e+"` is undefined. Did you forget to import app-layout/app-scroll-effects/effects/"+e+".html ?"}}];s({_template:l`
  2. <style>
  3. :host {
  4. position: relative;
  5. display: block;
  6. transition-timing-function: linear;
  7. transition-property: -webkit-transform;
  8. transition-property: transform;
  9. }
  10. :host::before {
  11. position: absolute;
  12. right: 0px;
  13. bottom: -5px;
  14. left: 0px;
  15. width: 100%;
  16. height: 5px;
  17. content: "";
  18. transition: opacity 0.4s;
  19. pointer-events: none;
  20. opacity: 0;
  21. box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
  22. will-change: opacity;
  23. @apply --app-header-shadow;
  24. }
  25. :host([shadow])::before {
  26. opacity: 1;
  27. }
  28. #background {
  29. @apply --layout-fit;
  30. overflow: hidden;
  31. }
  32. #backgroundFrontLayer,
  33. #backgroundRearLayer {
  34. @apply --layout-fit;
  35. height: 100%;
  36. pointer-events: none;
  37. background-size: cover;
  38. }
  39. #backgroundFrontLayer {
  40. @apply --app-header-background-front-layer;
  41. }
  42. #backgroundRearLayer {
  43. opacity: 0;
  44. @apply --app-header-background-rear-layer;
  45. }
  46. #contentContainer {
  47. position: relative;
  48. width: 100%;
  49. height: 100%;
  50. }
  51. :host([disabled]),
  52. :host([disabled])::after,
  53. :host([disabled]) #backgroundFrontLayer,
  54. :host([disabled]) #backgroundRearLayer,
  55. /* Silent scrolling should not run CSS transitions */
  56. :host([silent-scroll]),
  57. :host([silent-scroll])::after,
  58. :host([silent-scroll]) #backgroundFrontLayer,
  59. :host([silent-scroll]) #backgroundRearLayer {
  60. transition: none !important;
  61. }
  62. :host([disabled]) ::slotted(app-toolbar:first-of-type),
  63. :host([disabled]) ::slotted([sticky]),
  64. /* Silent scrolling should not run CSS transitions */
  65. :host([silent-scroll]) ::slotted(app-toolbar:first-of-type),
  66. :host([silent-scroll]) ::slotted([sticky]) {
  67. transition: none !important;
  68. }
  69. </style>
  70. <div id="contentContainer">
  71. <slot id="slot"></slot>
  72. </div>
  73. `,is:"app-header",behaviors:[re,oe],properties:{condenses:{type:Boolean,value:!1},fixed:{type:Boolean,value:!1},reveals:{type:Boolean,value:!1},shadow:{type:Boolean,reflectToAttribute:!0,value:!1}},observers:["_configChanged(isAttached, condenses, fixed)"],_height:0,_dHeight:0,_stickyElTop:0,_stickyElRef:null,_top:0,_progress:0,_wasScrollingDown:!1,_initScrollTop:0,_initTimestamp:0,_lastTimestamp:0,_lastScrollTop:0,get _maxHeaderTop(){return this.fixed?this._dHeight:this._height+5},get _stickyEl(){if(this._stickyElRef)return this._stickyElRef;for(var e,i=t(this.$.slot).getDistributedNodes(),a=0;e=i[a];a++)if(e.nodeType===Node.ELEMENT_NODE){if(e.hasAttribute("sticky")){this._stickyElRef=e;break}this._stickyElRef||(this._stickyElRef=e)}return this._stickyElRef},_configChanged:function(){this.resetLayout(),this._notifyLayoutChanged()},_updateLayoutStates:function(){if(0!==this.offsetWidth||0!==this.offsetHeight){var e=this._clampedScrollTop,t=0===this._height||0===e,i=this.disabled;this._height=this.offsetHeight,this._stickyElRef=null,this.disabled=!0,t||this._updateScrollState(0,!0),this._mayMove()?this._dHeight=this._stickyEl?this._height-this._stickyEl.offsetHeight:0:this._dHeight=0,this._stickyElTop=this._stickyEl?this._stickyEl.offsetTop:0,this._setUpEffect(),t?this._updateScrollState(e,!0):(this._updateScrollState(this._lastScrollTop,!0),this._layoutIfDirty()),this.disabled=i}},_updateScrollState:function(e,t){if(0!==this._height){var i=0,a=0,o=this._top;this._lastScrollTop;var s=this._maxHeaderTop,l=e-this._lastScrollTop,r=Math.abs(l),n=e>this._lastScrollTop,c=performance.now();if(this._mayMove()&&(a=this._clamp(this.reveals?o+l:e,0,s)),e>=this._dHeight&&(a=this.condenses&&!this.fixed?Math.max(this._dHeight,a):a,this.style.transitionDuration="0ms"),this.reveals&&!this.disabled&&r<100&&((c-this._initTimestamp>300||this._wasScrollingDown!==n)&&(this._initScrollTop=e,this._initTimestamp=c),e>=s))if(Math.abs(this._initScrollTop-e)>30||r>10){n&&e>=s?a=s:!n&&e>=this._dHeight&&(a=this.condenses&&!this.fixed?this._dHeight:0);var d=l/(c-this._lastTimestamp);this.style.transitionDuration=this._clamp((a-o)/d,0,300)+"ms"}else a=this._top;i=0===this._dHeight?e>0?1:0:a/this._dHeight,t||(this._lastScrollTop=e,this._top=a,this._wasScrollingDown=n,this._lastTimestamp=c),(t||i!==this._progress||o!==a||0===e)&&(this._progress=i,this._runEffects(i,a),this._transformHeader(a))}},_mayMove:function(){return this.condenses||!this.fixed},willCondense:function(){return this._dHeight>0&&this.condenses},isOnScreen:function(){return 0!==this._height&&this._top<this._height},isContentBelow:function(){return 0===this._top?this._clampedScrollTop>0:this._clampedScrollTop-this._maxHeaderTop>=0},_transformHeader:function(e){this.translate3d(0,-e+"px",0),this._stickyEl&&this.translate3d(0,this.condenses&&e>=this._stickyElTop?Math.min(e,this._dHeight)-this._stickyElTop+"px":0,0,this._stickyEl)},_clamp:function(e,t,i){return Math.min(i,Math.max(t,e))},_ensureBgContainers:function(){this._bgContainer||(this._bgContainer=document.createElement("div"),this._bgContainer.id="background",this._bgRear=document.createElement("div"),this._bgRear.id="backgroundRearLayer",this._bgContainer.appendChild(this._bgRear),this._bgFront=document.createElement("div"),this._bgFront.id="backgroundFrontLayer",this._bgContainer.appendChild(this._bgFront),t(this.root).insertBefore(this._bgContainer,this.$.contentContainer))},_getDOMRef:function(e){switch(e){case"backgroundFrontLayer":return this._ensureBgContainers(),this._bgFront;case"backgroundRearLayer":return this._ensureBgContainers(),this._bgRear;case"background":return this._ensureBgContainers(),this._bgContainer;case"mainTitle":return t(this).querySelector("[main-title]");case"condensedTitle":return t(this).querySelector("[condensed-title]")}return null},getScrollState:function(){return{progress:this._progress,top:this._top}}});const ne={second:45,minute:45,hour:22,day:5,week:4,month:11};K&&await K;const ce=r((e=>new Intl.RelativeTimeFormat(e.language,{numeric:"auto"}))),de=(e,t,i,a=!0)=>{const o=function(e,t=Date.now(),i={}){const a={...ne,...i||{}},o=(+e-+t)/1e3;if(Math.abs(o)<a.second)return{value:Math.round(o),unit:"second"};const s=o/60;if(Math.abs(s)<a.minute)return{value:Math.round(s),unit:"minute"};const l=o/3600;if(Math.abs(l)<a.hour)return{value:Math.round(l),unit:"hour"};const r=o/86400;if(Math.abs(r)<a.day)return{value:Math.round(r),unit:"day"};const n=o/604800;if(Math.abs(n)<a.week)return{value:Math.round(n),unit:"week"};const c=new Date(e),d=new Date(t),h=c.getFullYear()-d.getFullYear(),u=12*h+c.getMonth()-d.getMonth();return Math.round(Math.abs(u))<a.month?{value:Math.round(u),unit:"month"}:{value:Math.round(h),unit:"year"}}(e,i);return a?ce(t).format(o.value,o.unit):Intl.NumberFormat(t.language,{style:"unit",unit:o.unit,unitDisplay:"long"}).format(Math.abs(o.value))};n([_("search-input")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[d({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[d()],key:"filter",value:void 0},{kind:"field",decorators:[d({type:Boolean})],key:"suffix",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"autofocus",value:()=>!1},{kind:"field",decorators:[d({type:String})],key:"label",value:void 0},{kind:"method",key:"focus",value:function(){var e;null===(e=this._input)||void 0===e||e.focus()}},{kind:"field",decorators:[h("ha-textfield",!0)],key:"_input",value:void 0},{kind:"method",key:"render",value:function(){return u`
  74. <ha-textfield
  75. .autofocus=${this.autofocus}
  76. .label=${this.label||"Search"}
  77. .value=${this.filter||""}
  78. icon
  79. .iconTrailing=${this.filter||this.suffix}
  80. @input=${this._filterInputChanged}
  81. >
  82. <slot name="prefix" slot="leadingIcon">
  83. <ha-svg-icon
  84. tabindex="-1"
  85. class="prefix"
  86. .path=${f}
  87. ></ha-svg-icon>
  88. </slot>
  89. <div class="trailing" slot="trailingIcon">
  90. ${this.filter&&u`
  91. <ha-icon-button
  92. @click=${this._clearSearch}
  93. .label=${this.hass.localize("ui.common.clear")}
  94. .path=${p}
  95. class="clear-button"
  96. ></ha-icon-button>
  97. `}
  98. <slot name="suffix"></slot>
  99. </div>
  100. </ha-textfield>
  101. `}},{kind:"method",key:"_filterChanged",value:async function(e){b(this,"value-changed",{value:String(e)})}},{kind:"method",key:"_filterInputChanged",value:async function(e){this._filterChanged(e.target.value)}},{kind:"method",key:"_clearSearch",value:async function(){this._filterChanged("")}},{kind:"get",static:!0,key:"styles",value:function(){return m`
  102. :host {
  103. display: inline-flex;
  104. }
  105. ha-svg-icon,
  106. ha-icon-button {
  107. color: var(--primary-text-color);
  108. }
  109. ha-svg-icon {
  110. outline: none;
  111. }
  112. .clear-button {
  113. --mdc-icon-size: 20px;
  114. }
  115. ha-textfield {
  116. display: inherit;
  117. }
  118. .trailing {
  119. display: flex;
  120. align-items: center;
  121. }
  122. `}}]}}),c);const he=Symbol("Comlink.proxy"),ue=Symbol("Comlink.endpoint"),fe=Symbol("Comlink.releaseProxy"),pe=Symbol("Comlink.thrown"),be=e=>"object"==typeof e&&null!==e||"function"==typeof e,me=new Map([["proxy",{canHandle:e=>be(e)&&e[he],serialize(e){const{port1:t,port2:i}=new MessageChannel;return _e(e,t),[i,[i]]},deserialize:e=>(e.start(),ge(e))}],["throw",{canHandle:e=>be(e)&&pe in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function _e(e,t=self){t.addEventListener("message",(function i(a){if(!a||!a.data)return;const{id:o,type:s,path:l}=Object.assign({path:[]},a.data),r=(a.data.argumentList||[]).map(Re);let n;try{const t=l.slice(0,-1).reduce(((e,t)=>e[t]),e),i=l.reduce(((e,t)=>e[t]),e);switch(s){case"GET":n=i;break;case"SET":t[l.slice(-1)[0]]=Re(a.data.value),n=!0;break;case"APPLY":n=i.apply(t,r);break;case"CONSTRUCT":n=function(e){return Object.assign(e,{[he]:!0})}(new i(...r));break;case"ENDPOINT":{const{port1:t,port2:i}=new MessageChannel;_e(e,i),n=function(e,t){return xe.set(e,t),e}(t,[t])}break;case"RELEASE":n=void 0;break;default:return}}catch(e){n={value:e,[pe]:0}}Promise.resolve(n).catch((e=>({value:e,[pe]:0}))).then((e=>{const[a,l]=$e(e);t.postMessage(Object.assign(Object.assign({},a),{id:o}),l),"RELEASE"===s&&(t.removeEventListener("message",i),ve(t))}))})),t.start&&t.start()}function ve(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function ge(e,t){return ke(e,[],t)}function ye(e){if(e)throw new Error("Proxy has been released and is not useable")}function ke(e,t=[],i=function(){}){let a=!1;const o=new Proxy(i,{get(i,s){if(ye(a),s===fe)return()=>ze(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{ve(e),a=!0}));if("then"===s){if(0===t.length)return{then:()=>o};const i=ze(e,{type:"GET",path:t.map((e=>e.toString()))}).then(Re);return i.then.bind(i)}return ke(e,[...t,s])},set(i,o,s){ye(a);const[l,r]=$e(s);return ze(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:l},r).then(Re)},apply(i,o,s){ye(a);const l=t[t.length-1];if(l===ue)return ze(e,{type:"ENDPOINT"}).then(Re);if("bind"===l)return ke(e,t.slice(0,-1));const[r,n]=we(s);return ze(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:r},n).then(Re)},construct(i,o){ye(a);const[s,l]=we(o);return ze(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:s},l).then(Re)}});return o}function we(e){const t=e.map($e);return[t.map((e=>e[0])),(i=t.map((e=>e[1])),Array.prototype.concat.apply([],i))];var i}const xe=new WeakMap;function $e(e){for(const[t,i]of me)if(i.canHandle(e)){const[a,o]=i.serialize(e);return[{type:"HANDLER",name:t,value:a},o]}return[{type:"RAW",value:e},xe.get(e)||[]]}function Re(e){switch(e.type){case"HANDLER":return me.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ze(e,t,i){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(i){i.data&&i.data.id&&i.data.id===o&&(e.removeEventListener("message",t),a(i.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),i)}))}let Ce;let Te=n([_("ha-data-table")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[d({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[d({type:Object})],key:"columns",value:()=>({})},{kind:"field",decorators:[d({type:Array})],key:"data",value:()=>[]},{kind:"field",decorators:[d({type:Boolean})],key:"selectable",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"clickable",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"hasFab",value:()=>!1},{kind:"field",decorators:[d({attribute:!1})],key:"appendRow",value:void 0},{kind:"field",decorators:[d({type:Boolean,attribute:"auto-height"})],key:"autoHeight",value:()=>!1},{kind:"field",decorators:[d({type:String})],key:"id",value:()=>"id"},{kind:"field",decorators:[d({type:String})],key:"noDataText",value:void 0},{kind:"field",decorators:[d({type:String})],key:"searchLabel",value:void 0},{kind:"field",decorators:[d({type:Boolean,attribute:"no-label-float"})],key:"noLabelFloat",value:()=>!1},{kind:"field",decorators:[d({type:String})],key:"filter",value:()=>""},{kind:"field",decorators:[v()],key:"_filterable",value:()=>!1},{kind:"field",decorators:[v()],key:"_filter",value:()=>""},{kind:"field",decorators:[v()],key:"_sortColumn",value:void 0},{kind:"field",decorators:[v()],key:"_sortDirection",value:()=>null},{kind:"field",decorators:[v()],key:"_filteredData",value:()=>[]},{kind:"field",decorators:[v()],key:"_headerHeight",value:()=>0},{kind:"field",decorators:[h("slot[name='header']")],key:"_header",value:void 0},{kind:"field",decorators:[v()],key:"_items",value:()=>[]},{kind:"field",key:"_checkableRowsCount",value:void 0},{kind:"field",key:"_checkedRows",value:()=>[]},{kind:"field",key:"_sortColumns",value:()=>({})},{kind:"field",key:"curRequest",value:()=>0},{kind:"field",decorators:[Q(".scroller")],key:"_savedScrollPos",value:void 0},{kind:"field",key:"_debounceSearch",value(){return G((e=>{this._filter=e}),100,!1)}},{kind:"method",key:"clearSelection",value:function(){this._checkedRows=[],this._checkedRowsChanged()}},{kind:"method",key:"connectedCallback",value:function(){g(y(i.prototype),"connectedCallback",this).call(this),this._items.length&&(this._items=[...this._items])}},{kind:"method",key:"firstUpdated",value:function(){this.updateComplete.then((()=>this._calcTableHeight()))}},{kind:"method",key:"willUpdate",value:function(e){if(g(y(i.prototype),"willUpdate",this).call(this,e),e.has("columns")){this._filterable=Object.values(this.columns).some((e=>e.filterable));for(const e in this.columns)if(this.columns[e].direction){this._sortDirection=this.columns[e].direction,this._sortColumn=e;break}const e=te(this.columns);Object.values(e).forEach((e=>{delete e.title,delete e.type,delete e.template})),this._sortColumns=e}e.has("filter")&&this._debounceSearch(this.filter),e.has("data")&&(this._checkableRowsCount=this.data.filter((e=>!1!==e.selectable)).length),(e.has("data")||e.has("columns")||e.has("_filter")||e.has("_sortColumn")||e.has("_sortDirection"))&&this._sortFilterData()}},{kind:"method",key:"render",value:function(){return u`
  123. <div class="mdc-data-table">
  124. <slot name="header" @slotchange=${this._calcTableHeight}>
  125. ${this._filterable?u`
  126. <div class="table-header">
  127. <search-input
  128. .hass=${this.hass}
  129. @value-changed=${this._handleSearchChange}
  130. .label=${this.searchLabel}
  131. .noLabelFloat=${this.noLabelFloat}
  132. ></search-input>
  133. </div>
  134. `:""}
  135. </slot>
  136. <div
  137. class="mdc-data-table__table ${k({"auto-height":this.autoHeight})}"
  138. role="table"
  139. aria-rowcount=${this._filteredData.length+1}
  140. style=${w({height:this.autoHeight?53*(this._filteredData.length||1)+53+"px":`calc(100% - ${this._headerHeight}px)`})}
  141. >
  142. <div class="mdc-data-table__header-row" role="row" aria-rowindex="1">
  143. ${this.selectable?u`
  144. <div
  145. class="mdc-data-table__header-cell mdc-data-table__header-cell--checkbox"
  146. role="columnheader"
  147. >
  148. <ha-checkbox
  149. class="mdc-data-table__row-checkbox"
  150. @change=${this._handleHeaderRowCheckboxClick}
  151. .indeterminate=${this._checkedRows.length&&this._checkedRows.length!==this._checkableRowsCount}
  152. .checked=${this._checkedRows.length&&this._checkedRows.length===this._checkableRowsCount}
  153. >
  154. </ha-checkbox>
  155. </div>
  156. `:""}
  157. ${Object.entries(this.columns).map((([e,t])=>{if(t.hidden)return"";const i=e===this._sortColumn,a={"mdc-data-table__header-cell--numeric":"numeric"===t.type,"mdc-data-table__header-cell--icon":"icon"===t.type,"mdc-data-table__header-cell--icon-button":"icon-button"===t.type,"mdc-data-table__header-cell--overflow-menu":"overflow-menu"===t.type,sortable:Boolean(t.sortable),"not-sorted":Boolean(t.sortable&&!i),grows:Boolean(t.grows)};return u`
  158. <div
  159. aria-label=${t.label}
  160. class="mdc-data-table__header-cell ${k(a)}"
  161. style=${t.width?w({[t.grows?"minWidth":"width"]:t.width,maxWidth:t.maxWidth||""}):""}
  162. role="columnheader"
  163. aria-sort=${x(i?"desc"===this._sortDirection?"descending":"ascending":void 0)}
  164. @click=${this._handleHeaderClick}
  165. .columnId=${e}
  166. >
  167. ${t.sortable?u`
  168. <ha-svg-icon
  169. .path=${i&&"desc"===this._sortDirection?$:R}
  170. ></ha-svg-icon>
  171. `:""}
  172. <span>${t.title}</span>
  173. </div>
  174. `}))}
  175. </div>
  176. ${this._filteredData.length?u`
  177. <lit-virtualizer
  178. scroller
  179. class="mdc-data-table__content scroller ha-scrollbar"
  180. @scroll=${this._saveScrollPos}
  181. .items=${this._items}
  182. .renderItem=${this._renderRow}
  183. ></lit-virtualizer>
  184. `:u`
  185. <div class="mdc-data-table__content">
  186. <div class="mdc-data-table__row" role="row">
  187. <div class="mdc-data-table__cell grows center" role="cell">
  188. ${this.noDataText||"No data"}
  189. </div>
  190. </div>
  191. </div>
  192. `}
  193. </div>
  194. </div>
  195. `}},{kind:"field",key:"_renderRow",value(){return(e,t)=>e?e.append?u` <div class="mdc-data-table__row">${e.content}</div> `:e.empty?u` <div class="mdc-data-table__row"></div> `:u`
  196. <div
  197. aria-rowindex=${t+2}
  198. role="row"
  199. .rowId=${e[this.id]}
  200. @click=${this._handleRowClick}
  201. class="mdc-data-table__row ${k({"mdc-data-table__row--selected":this._checkedRows.includes(String(e[this.id])),clickable:this.clickable})}"
  202. aria-selected=${x(!!this._checkedRows.includes(String(e[this.id]))||void 0)}
  203. .selectable=${!1!==e.selectable}
  204. >
  205. ${this.selectable?u`
  206. <div
  207. class="mdc-data-table__cell mdc-data-table__cell--checkbox"
  208. role="cell"
  209. >
  210. <ha-checkbox
  211. class="mdc-data-table__row-checkbox"
  212. @change=${this._handleRowCheckboxClick}
  213. .rowId=${e[this.id]}
  214. .disabled=${!1===e.selectable}
  215. .checked=${this._checkedRows.includes(String(e[this.id]))}
  216. >
  217. </ha-checkbox>
  218. </div>
  219. `:""}
  220. ${Object.entries(this.columns).map((([t,i])=>i.hidden?"":u`
  221. <div
  222. role=${i.main?"rowheader":"cell"}
  223. class="mdc-data-table__cell ${k({"mdc-data-table__cell--numeric":"numeric"===i.type,"mdc-data-table__cell--icon":"icon"===i.type,"mdc-data-table__cell--icon-button":"icon-button"===i.type,"mdc-data-table__cell--overflow-menu":"overflow-menu"===i.type,grows:Boolean(i.grows),forceLTR:Boolean(i.forceLTR)})}"
  224. style=${i.width?w({[i.grows?"minWidth":"width"]:i.width,maxWidth:i.maxWidth?i.maxWidth:""}):""}
  225. >
  226. ${i.template?i.template(e[t],e):e[t]}
  227. </div>
  228. `))}
  229. </div>
  230. `:u``}},{kind:"method",key:"_sortFilterData",value:async function(){const e=(new Date).getTime();this.curRequest++;const t=this.curRequest;let i=this.data;this._filter&&(i=await this._memFilterData(this.data,this._sortColumns,this._filter));const a=this._sortColumn?(async(e,t,i,a)=>(Ce||(Ce=ge(new Worker(new URL("./sort_filter_worker",import.meta.url)))),Ce.sortData(e,t,i,a)))(i,this._sortColumns[this._sortColumn],this._sortDirection,this._sortColumn):i,[o]=await Promise.all([a,z]),s=(new Date).getTime()-e;if(s<100&&await new Promise((e=>setTimeout(e,100-s))),this.curRequest===t){if(this.appendRow||this.hasFab){const e=[...o];this.appendRow&&e.push({append:!0,content:this.appendRow}),this.hasFab&&e.push({empty:!0}),this._items=e}else this._items=o;this._filteredData=o}}},{kind:"field",key:"_memFilterData",value:()=>r((async(e,t,i)=>(async(e,t,i)=>(Ce||(Ce=ge(new Worker(new URL("./sort_filter_worker",import.meta.url)))),Ce.filterData(e,t,i)))(e,t,i)))},{kind:"method",key:"_handleHeaderClick",value:function(e){const t=e.currentTarget.columnId;this.columns[t].sortable&&(this._sortDirection&&this._sortColumn===t?"asc"===this._sortDirection?this._sortDirection="desc":this._sortDirection=null:this._sortDirection="asc",this._sortColumn=null===this._sortDirection?void 0:t,b(this,"sorting-changed",{column:t,direction:this._sortDirection}))}},{kind:"method",key:"_handleHeaderRowCheckboxClick",value:function(e){e.target.checked?(this._checkedRows=this._filteredData.filter((e=>!1!==e.selectable)).map((e=>e[this.id])),this._checkedRowsChanged()):(this._checkedRows=[],this._checkedRowsChanged())}},{kind:"field",key:"_handleRowCheckboxClick",value(){return e=>{const t=e.currentTarget,i=t.rowId;if(t.checked){if(this._checkedRows.includes(i))return;this._checkedRows=[...this._checkedRows,i]}else this._checkedRows=this._checkedRows.filter((e=>e!==i));this._checkedRowsChanged()}}},{kind:"field",key:"_handleRowClick",value(){return e=>{const t=e.target;if(["HA-CHECKBOX","MWC-BUTTON"].includes(t.tagName))return;const i=e.currentTarget.rowId;b(this,"row-click",{id:i},{bubbles:!1})}}},{kind:"method",key:"_checkedRowsChanged",value:function(){this._items.length&&(this._items=[...this._items]),b(this,"selection-changed",{value:this._checkedRows})}},{kind:"method",key:"_handleSearchChange",value:function(e){this.filter||this._debounceSearch(e.detail.value)}},{kind:"method",key:"_calcTableHeight",value:async function(){this.autoHeight||(await this.updateComplete,this._headerHeight=this._header.clientHeight)}},{kind:"method",decorators:[C({passive:!0})],key:"_saveScrollPos",value:function(e){this._savedScrollPos=e.target.scrollTop}},{kind:"get",static:!0,key:"styles",value:function(){return[T,m`
  231. /* default mdc styles, colors changed, without checkbox styles */
  232. :host {
  233. height: 100%;
  234. }
  235. .mdc-data-table__content {
  236. font-family: Roboto, sans-serif;
  237. -moz-osx-font-smoothing: grayscale;
  238. -webkit-font-smoothing: antialiased;
  239. font-size: 0.875rem;
  240. line-height: 1.25rem;
  241. font-weight: 400;
  242. letter-spacing: 0.0178571429em;
  243. text-decoration: inherit;
  244. text-transform: inherit;
  245. }
  246. .mdc-data-table {
  247. background-color: var(--data-table-background-color);
  248. border-radius: 4px;
  249. border-width: 1px;
  250. border-style: solid;
  251. border-color: var(--divider-color);
  252. display: inline-flex;
  253. flex-direction: column;
  254. box-sizing: border-box;
  255. overflow: hidden;
  256. }
  257. .mdc-data-table__row--selected {
  258. background-color: rgba(var(--rgb-primary-color), 0.04);
  259. }
  260. .mdc-data-table__row {
  261. display: flex;
  262. width: 100%;
  263. height: 52px;
  264. }
  265. .mdc-data-table__row ~ .mdc-data-table__row {
  266. border-top: 1px solid var(--divider-color);
  267. }
  268. .mdc-data-table__row:not(.mdc-data-table__row--selected):hover {
  269. background-color: rgba(var(--rgb-primary-text-color), 0.04);
  270. }
  271. .mdc-data-table__header-cell {
  272. color: var(--primary-text-color);
  273. }
  274. .mdc-data-table__cell {
  275. color: var(--primary-text-color);
  276. }
  277. .mdc-data-table__header-row {
  278. height: 56px;
  279. display: flex;
  280. width: 100%;
  281. border-bottom: 1px solid var(--divider-color);
  282. overflow-x: auto;
  283. }
  284. .mdc-data-table__header-row::-webkit-scrollbar {
  285. display: none;
  286. }
  287. .mdc-data-table__cell,
  288. .mdc-data-table__header-cell {
  289. padding-right: 16px;
  290. padding-left: 16px;
  291. align-self: center;
  292. overflow: hidden;
  293. text-overflow: ellipsis;
  294. flex-shrink: 0;
  295. box-sizing: border-box;
  296. }
  297. .mdc-data-table__cell.mdc-data-table__cell--icon {
  298. overflow: initial;
  299. }
  300. .mdc-data-table__header-cell--checkbox,
  301. .mdc-data-table__cell--checkbox {
  302. /* @noflip */
  303. padding-left: 16px;
  304. /* @noflip */
  305. padding-right: 0;
  306. width: 60px;
  307. }
  308. :host([dir="rtl"]) .mdc-data-table__header-cell--checkbox,
  309. :host([dir="rtl"]) .mdc-data-table__cell--checkbox {
  310. /* @noflip */
  311. padding-left: 0;
  312. /* @noflip */
  313. padding-right: 16px;
  314. }
  315. .mdc-data-table__table {
  316. height: 100%;
  317. width: 100%;
  318. border: 0;
  319. white-space: nowrap;
  320. }
  321. .mdc-data-table__cell {
  322. font-family: Roboto, sans-serif;
  323. -moz-osx-font-smoothing: grayscale;
  324. -webkit-font-smoothing: antialiased;
  325. font-size: 0.875rem;
  326. line-height: 1.25rem;
  327. font-weight: 400;
  328. letter-spacing: 0.0178571429em;
  329. text-decoration: inherit;
  330. text-transform: inherit;
  331. }
  332. .mdc-data-table__cell a {
  333. color: inherit;
  334. text-decoration: none;
  335. }
  336. .mdc-data-table__cell--numeric {
  337. text-align: right;
  338. }
  339. :host([dir="rtl"]) .mdc-data-table__cell--numeric {
  340. /* @noflip */
  341. text-align: left;
  342. }
  343. .mdc-data-table__cell--icon {
  344. color: var(--secondary-text-color);
  345. text-align: center;
  346. }
  347. .mdc-data-table__header-cell--icon,
  348. .mdc-data-table__cell--icon {
  349. width: 54px;
  350. }
  351. .mdc-data-table__header-cell.mdc-data-table__header-cell--icon {
  352. text-align: center;
  353. }
  354. .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover,
  355. .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not(.not-sorted) {
  356. text-align: left;
  357. }
  358. :host([dir="rtl"])
  359. .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover,
  360. :host([dir="rtl"])
  361. .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not(.not-sorted) {
  362. text-align: right;
  363. }
  364. .mdc-data-table__cell--icon:first-child ha-icon,
  365. .mdc-data-table__cell--icon:first-child ha-state-icon,
  366. .mdc-data-table__cell--icon:first-child ha-svg-icon {
  367. margin-left: 8px;
  368. }
  369. :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child ha-icon,
  370. :host([dir="rtl"])
  371. .mdc-data-table__cell--icon:first-child
  372. ha-state-icon,
  373. :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child ha-svg-icon {
  374. margin-left: auto;
  375. margin-right: 8px;
  376. }
  377. .mdc-data-table__cell--icon:first-child state-badge {
  378. margin-right: -8px;
  379. }
  380. :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child state-badge {
  381. margin-right: auto;
  382. margin-left: -8px;
  383. }
  384. .mdc-data-table__cell--overflow-menu,
  385. .mdc-data-table__header-cell--overflow-menu,
  386. .mdc-data-table__header-cell--icon-button,
  387. .mdc-data-table__cell--icon-button {
  388. padding: 8px;
  389. }
  390. .mdc-data-table__header-cell--icon-button,
  391. .mdc-data-table__cell--icon-button {
  392. width: 56px;
  393. }
  394. .mdc-data-table__cell--overflow-menu,
  395. .mdc-data-table__cell--icon-button {
  396. color: var(--secondary-text-color);
  397. text-overflow: clip;
  398. }
  399. .mdc-data-table__header-cell--icon-button:first-child,
  400. .mdc-data-table__cell--icon-button:first-child,
  401. .mdc-data-table__header-cell--icon-button:last-child,
  402. .mdc-data-table__cell--icon-button:last-child {
  403. width: 64px;
  404. }
  405. .mdc-data-table__cell--overflow-menu:first-child,
  406. .mdc-data-table__header-cell--overflow-menu:first-child,
  407. .mdc-data-table__header-cell--icon-button:first-child,
  408. .mdc-data-table__cell--icon-button:first-child {
  409. padding-left: 16px;
  410. }
  411. :host([dir="rtl"])
  412. .mdc-data-table__header-cell--overflow-menu:first-child,
  413. :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:first-child,
  414. :host([dir="rtl"])
  415. .mdc-data-table__header-cell--overflow-menu:first-child,
  416. :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:first-child {
  417. padding-left: 8px;
  418. padding-right: 16px;
  419. }
  420. .mdc-data-table__cell--overflow-menu:last-child,
  421. .mdc-data-table__header-cell--overflow-menu:last-child,
  422. .mdc-data-table__header-cell--icon-button:last-child,
  423. .mdc-data-table__cell--icon-button:last-child {
  424. padding-right: 16px;
  425. }
  426. :host([dir="rtl"])
  427. .mdc-data-table__header-cell--overflow-menu:last-child,
  428. :host([dir="rtl"]) .mdc-data-table__cell--overflow-menu:last-child,
  429. :host([dir="rtl"]) .mdc-data-table__header-cell--icon-button:last-child,
  430. :host([dir="rtl"]) .mdc-data-table__cell--icon-button:last-child {
  431. padding-right: 8px;
  432. padding-left: 16px;
  433. }
  434. .mdc-data-table__cell--overflow-menu,
  435. .mdc-data-table__header-cell--overflow-menu {
  436. overflow: initial;
  437. }
  438. .mdc-data-table__cell--icon-button a {
  439. color: var(--secondary-text-color);
  440. }
  441. .mdc-data-table__header-cell {
  442. font-family: Roboto, sans-serif;
  443. -moz-osx-font-smoothing: grayscale;
  444. -webkit-font-smoothing: antialiased;
  445. font-size: 0.875rem;
  446. line-height: 1.375rem;
  447. font-weight: 500;
  448. letter-spacing: 0.0071428571em;
  449. text-decoration: inherit;
  450. text-transform: inherit;
  451. text-align: left;
  452. }
  453. :host([dir="rtl"]) .mdc-data-table__header-cell {
  454. /* @noflip */
  455. text-align: right;
  456. }
  457. .mdc-data-table__header-cell--numeric {
  458. text-align: right;
  459. }
  460. .mdc-data-table__header-cell--numeric.sortable:hover,
  461. .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) {
  462. text-align: left;
  463. }
  464. :host([dir="rtl"]) .mdc-data-table__header-cell--numeric {
  465. /* @noflip */
  466. text-align: left;
  467. }
  468. :host([dir="rtl"]) .mdc-data-table__header-cell--numeric.sortable:hover,
  469. :host([dir="rtl"])
  470. .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) {
  471. text-align: right;
  472. }
  473. /* custom from here */
  474. :host {
  475. display: block;
  476. }
  477. .mdc-data-table {
  478. display: block;
  479. border-width: var(--data-table-border-width, 1px);
  480. height: 100%;
  481. }
  482. .mdc-data-table__header-cell {
  483. overflow: hidden;
  484. position: relative;
  485. }
  486. .mdc-data-table__header-cell span {
  487. position: relative;
  488. left: 0px;
  489. }
  490. :host([dir="rtl"]) .mdc-data-table__header-cell span {
  491. left: auto;
  492. right: 0px;
  493. }
  494. .mdc-data-table__header-cell.sortable {
  495. cursor: pointer;
  496. }
  497. .mdc-data-table__header-cell > * {
  498. transition: left 0.2s ease;
  499. }
  500. :host([dir="rtl"]) .mdc-data-table__header-cell > * {
  501. transition: right 0.2s ease;
  502. }
  503. .mdc-data-table__header-cell ha-svg-icon {
  504. top: -3px;
  505. position: absolute;
  506. }
  507. .mdc-data-table__header-cell.not-sorted ha-svg-icon {
  508. left: -20px;
  509. }
  510. :host([dir="rtl"]) .mdc-data-table__header-cell.not-sorted ha-svg-icon {
  511. right: -20px;
  512. }
  513. .mdc-data-table__header-cell.sortable:not(.not-sorted) span,
  514. .mdc-data-table__header-cell.sortable.not-sorted:hover span {
  515. left: 24px;
  516. }
  517. :host([dir="rtl"])
  518. .mdc-data-table__header-cell.sortable:not(.not-sorted)
  519. span,
  520. :host([dir="rtl"])
  521. .mdc-data-table__header-cell.sortable.not-sorted:hover
  522. span {
  523. left: auto;
  524. right: 24px;
  525. }
  526. .mdc-data-table__header-cell.sortable:not(.not-sorted) ha-svg-icon,
  527. .mdc-data-table__header-cell.sortable:hover.not-sorted ha-svg-icon {
  528. left: 12px;
  529. }
  530. :host([dir="rtl"])
  531. .mdc-data-table__header-cell.sortable:not(.not-sorted)
  532. ha-svg-icon,
  533. :host([dir="rtl"])
  534. .mdc-data-table__header-cell.sortable:hover.not-sorted
  535. ha-svg-icon {
  536. left: auto;
  537. right: 12px;
  538. }
  539. .table-header {
  540. border-bottom: 1px solid var(--divider-color);
  541. }
  542. search-input {
  543. display: block;
  544. flex: 1;
  545. }
  546. slot[name="header"] {
  547. display: block;
  548. }
  549. .center {
  550. text-align: center;
  551. }
  552. .secondary {
  553. color: var(--secondary-text-color);
  554. }
  555. .scroller {
  556. height: calc(100% - 57px);
  557. overflow: overlay !important;
  558. }
  559. .mdc-data-table__table.auto-height .scroller {
  560. overflow-y: hidden !important;
  561. }
  562. .grows {
  563. flex-grow: 1;
  564. flex-shrink: 1;
  565. }
  566. .forceLTR {
  567. direction: ltr;
  568. }
  569. .clickable {
  570. cursor: pointer;
  571. }
  572. lit-virtualizer {
  573. contain: size layout !important;
  574. }
  575. `]}}]}}),c);n([_("ha-tab")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"active",value:()=>!1},{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[d()],key:"name",value:void 0},{kind:"field",decorators:[S("mwc-ripple")],key:"_ripple",value:void 0},{kind:"field",decorators:[v()],key:"_shouldRenderRipple",value:()=>!1},{kind:"method",key:"render",value:function(){return u`
  576. <div
  577. tabindex="0"
  578. role="tab"
  579. aria-selected=${this.active}
  580. aria-label=${x(this.name)}
  581. @focus=${this.handleRippleFocus}
  582. @blur=${this.handleRippleBlur}
  583. @mousedown=${this.handleRippleActivate}
  584. @mouseup=${this.handleRippleDeactivate}
  585. @mouseenter=${this.handleRippleMouseEnter}
  586. @mouseleave=${this.handleRippleMouseLeave}
  587. @touchstart=${this.handleRippleActivate}
  588. @touchend=${this.handleRippleDeactivate}
  589. @touchcancel=${this.handleRippleDeactivate}
  590. @keydown=${this._handleKeyDown}
  591. >
  592. ${this.narrow?u`<slot name="icon"></slot>`:""}
  593. <span class="name">${this.name}</span>
  594. ${this._shouldRenderRipple?u`<mwc-ripple></mwc-ripple>`:""}
  595. </div>
  596. `}},{kind:"field",key:"_rippleHandlers",value(){return new D((()=>(this._shouldRenderRipple=!0,this._ripple)))}},{kind:"method",key:"_handleKeyDown",value:function(e){13===e.keyCode&&e.target.click()}},{kind:"method",decorators:[C({passive:!0})],key:"handleRippleActivate",value:function(e){this._rippleHandlers.startPress(e)}},{kind:"method",key:"handleRippleDeactivate",value:function(){this._rippleHandlers.endPress()}},{kind:"method",key:"handleRippleMouseEnter",value:function(){this._rippleHandlers.startHover()}},{kind:"method",key:"handleRippleMouseLeave",value:function(){this._rippleHandlers.endHover()}},{kind:"method",key:"handleRippleFocus",value:function(){this._rippleHandlers.startFocus()}},{kind:"method",key:"handleRippleBlur",value:function(){this._rippleHandlers.endFocus()}},{kind:"get",static:!0,key:"styles",value:function(){return m`
  597. div {
  598. padding: 0 32px;
  599. display: flex;
  600. flex-direction: column;
  601. text-align: center;
  602. box-sizing: border-box;
  603. align-items: center;
  604. justify-content: center;
  605. width: 100%;
  606. height: var(--header-height);
  607. cursor: pointer;
  608. position: relative;
  609. outline: none;
  610. }
  611. .name {
  612. white-space: nowrap;
  613. overflow: hidden;
  614. text-overflow: ellipsis;
  615. max-width: 100%;
  616. }
  617. :host([active]) {
  618. color: var(--primary-color);
  619. }
  620. :host(:not([narrow])[active]) div {
  621. border-bottom: 2px solid var(--primary-color);
  622. }
  623. :host([narrow]) {
  624. min-width: 0;
  625. display: flex;
  626. justify-content: center;
  627. overflow: hidden;
  628. }
  629. :host([narrow]) div {
  630. padding: 0 4px;
  631. }
  632. `}}]}}),c),n([_("hass-tabs-subpage")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[d({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[d({type:Boolean})],key:"supervisor",value:()=>!1},{kind:"field",decorators:[d({attribute:!1})],key:"localizeFunc",value:void 0},{kind:"field",decorators:[d({type:String,attribute:"back-path"})],key:"backPath",value:void 0},{kind:"field",decorators:[d()],key:"backCallback",value:void 0},{kind:"field",decorators:[d({type:Boolean,attribute:"main-page"})],key:"mainPage",value:()=>!1},{kind:"field",decorators:[d({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[d({attribute:!1})],key:"tabs",value:void 0},{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[d({type:Boolean,reflect:!0,attribute:"is-wide"})],key:"isWide",value:()=>!1},{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"rtl",value:()=>!1},{kind:"field",decorators:[v()],key:"_activeTab",value:void 0},{kind:"field",decorators:[Q(".content")],key:"_savedScrollPos",value:void 0},{kind:"field",key:"_getTabs",value(){return r(((e,t,i,a,o,s,l)=>{const r=e.filter((e=>(!e.component||e.core||ie(this.hass,e.component))&&(!e.advancedOnly||i)));if(r.length<2){if(1===r.length){const e=r[0];return[e.translationKey?l(e.translationKey):e.name]}return[""]}return r.map((e=>u`
  633. <a href=${e.path}>
  634. <ha-tab
  635. .hass=${this.hass}
  636. .active=${e.path===(null==t?void 0:t.path)}
  637. .narrow=${this.narrow}
  638. .name=${e.translationKey?l(e.translationKey):e.name}
  639. >
  640. ${e.iconPath?u`<ha-svg-icon
  641. slot="icon"
  642. .path=${e.iconPath}
  643. ></ha-svg-icon>`:""}
  644. </ha-tab>
  645. </a>
  646. `))}))}},{kind:"method",key:"willUpdate",value:function(e){if(e.has("route")&&(this._activeTab=this.tabs.find((e=>`${this.route.prefix}${this.route.path}`.includes(e.path)))),e.has("hass")){const t=e.get("hass");t&&t.language===this.hass.language||(this.rtl=U(this.hass))}g(y(i.prototype),"willUpdate",this).call(this,e)}},{kind:"method",key:"render",value:function(){var e,t;const i=this._getTabs(this.tabs,this._activeTab,null===(e=this.hass.userData)||void 0===e?void 0:e.showAdvanced,this.hass.config.components,this.hass.language,this.narrow,this.localizeFunc||this.hass.localize),a=i.length>1;return u`
  647. <div class="toolbar">
  648. ${this.mainPage||!this.backPath&&null!==(t=history.state)&&void 0!==t&&t.root?u`
  649. <ha-menu-button
  650. .hassio=${this.supervisor}
  651. .hass=${this.hass}
  652. .narrow=${this.narrow}
  653. ></ha-menu-button>
  654. `:this.backPath?u`
  655. <a href=${this.backPath}>
  656. <ha-icon-button-arrow-prev
  657. .hass=${this.hass}
  658. ></ha-icon-button-arrow-prev>
  659. </a>
  660. `:u`
  661. <ha-icon-button-arrow-prev
  662. .hass=${this.hass}
  663. @click=${this._backTapped}
  664. ></ha-icon-button-arrow-prev>
  665. `}
  666. ${this.narrow||!a?u`<div class="main-title">
  667. <slot name="header">${a?"":i[0]}</slot>
  668. </div>`:""}
  669. ${a?u`
  670. <div id="tabbar" class=${k({"bottom-bar":this.narrow})}>
  671. ${i}
  672. </div>
  673. `:""}
  674. <div id="toolbar-icon">
  675. <slot name="toolbar-icon"></slot>
  676. </div>
  677. </div>
  678. <div
  679. class="content ${k({tabs:a})}"
  680. @scroll=${this._saveScrollPos}
  681. >
  682. <slot></slot>
  683. </div>
  684. <div id="fab" class=${k({tabs:a})}>
  685. <slot name="fab"></slot>
  686. </div>
  687. `}},{kind:"method",decorators:[C({passive:!0})],key:"_saveScrollPos",value:function(e){this._savedScrollPos=e.target.scrollTop}},{kind:"method",key:"_backTapped",value:function(){this.backCallback?this.backCallback():history.back()}},{kind:"get",static:!0,key:"styles",value:function(){return m`
  688. :host {
  689. display: block;
  690. height: 100%;
  691. background-color: var(--primary-background-color);
  692. }
  693. :host([narrow]) {
  694. width: 100%;
  695. position: fixed;
  696. }
  697. ha-menu-button {
  698. margin-right: 24px;
  699. }
  700. .toolbar {
  701. display: flex;
  702. align-items: center;
  703. font-size: 20px;
  704. height: var(--header-height);
  705. background-color: var(--sidebar-background-color);
  706. font-weight: 400;
  707. border-bottom: 1px solid var(--divider-color);
  708. padding: 0 16px;
  709. box-sizing: border-box;
  710. }
  711. .toolbar a {
  712. color: var(--sidebar-text-color);
  713. text-decoration: none;
  714. }
  715. .bottom-bar a {
  716. width: 25%;
  717. }
  718. #tabbar {
  719. display: flex;
  720. font-size: 14px;
  721. overflow: hidden;
  722. }
  723. #tabbar > a {
  724. overflow: hidden;
  725. max-width: 45%;
  726. }
  727. #tabbar.bottom-bar {
  728. position: absolute;
  729. bottom: 0;
  730. left: 0;
  731. padding: 0 16px;
  732. box-sizing: border-box;
  733. background-color: var(--sidebar-background-color);
  734. border-top: 1px solid var(--divider-color);
  735. justify-content: space-around;
  736. z-index: 2;
  737. font-size: 12px;
  738. width: 100%;
  739. padding-bottom: env(safe-area-inset-bottom);
  740. }
  741. #tabbar:not(.bottom-bar) {
  742. flex: 1;
  743. justify-content: center;
  744. }
  745. :host(:not([narrow])) #toolbar-icon {
  746. min-width: 40px;
  747. }
  748. ha-menu-button,
  749. ha-icon-button-arrow-prev,
  750. ::slotted([slot="toolbar-icon"]) {
  751. display: flex;
  752. flex-shrink: 0;
  753. pointer-events: auto;
  754. color: var(--sidebar-icon-color);
  755. }
  756. .main-title {
  757. flex: 1;
  758. max-height: var(--header-height);
  759. line-height: 20px;
  760. color: var(--sidebar-text-color);
  761. margin: var(--main-title-margin, 0 0 0 24px);
  762. }
  763. .content {
  764. position: relative;
  765. width: calc(
  766. 100% - env(safe-area-inset-left) - env(safe-area-inset-right)
  767. );
  768. margin-left: env(safe-area-inset-left);
  769. margin-right: env(safe-area-inset-right);
  770. height: calc(100% - 1px - var(--header-height));
  771. height: calc(
  772. 100% - 1px - var(--header-height) - env(safe-area-inset-bottom)
  773. );
  774. overflow: auto;
  775. -webkit-overflow-scrolling: touch;
  776. }
  777. :host([narrow]) .content.tabs {
  778. height: calc(100% - 2 * var(--header-height));
  779. height: calc(
  780. 100% - 2 * var(--header-height) - env(safe-area-inset-bottom)
  781. );
  782. }
  783. #fab {
  784. position: fixed;
  785. right: calc(16px + env(safe-area-inset-right));
  786. bottom: calc(16px + env(safe-area-inset-bottom));
  787. z-index: 1;
  788. }
  789. :host([narrow]) #fab.tabs {
  790. bottom: calc(84px + env(safe-area-inset-bottom));
  791. }
  792. #fab[is-wide] {
  793. bottom: 24px;
  794. right: 24px;
  795. }
  796. :host([rtl]) #fab {
  797. right: auto;
  798. left: calc(16px + env(safe-area-inset-left));
  799. }
  800. :host([rtl][is-wide]) #fab {
  801. bottom: 24px;
  802. left: 24px;
  803. right: auto;
  804. }
  805. `}}]}}),c);let Se=n([_("hass-tabs-subpage-data-table")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[d({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[d({attribute:!1})],key:"localizeFunc",value:void 0},{kind:"field",decorators:[d({type:Boolean})],key:"isWide",value:()=>!1},{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"supervisor",value:()=>!1},{kind:"field",decorators:[d({type:Boolean,attribute:"main-page"})],key:"mainPage",value:()=>!1},{kind:"field",decorators:[d({type:Object})],key:"columns",value:()=>({})},{kind:"field",decorators:[d({type:Array})],key:"data",value:()=>[]},{kind:"field",decorators:[d({type:Boolean})],key:"selectable",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"clickable",value:()=>!1},{kind:"field",decorators:[d({type:Boolean})],key:"hasFab",value:()=>!1},{kind:"field",decorators:[d({attribute:!1})],key:"appendRow",value:void 0},{kind:"field",decorators:[d({type:String})],key:"id",value:()=>"id"},{kind:"field",decorators:[d({type:String})],key:"filter",value:()=>""},{kind:"field",decorators:[d()],key:"searchLabel",value:void 0},{kind:"field",decorators:[d({type:Array})],key:"activeFilters",value:void 0},{kind:"field",decorators:[d()],key:"hiddenLabel",value:void 0},{kind:"field",decorators:[d({type:Number})],key:"numHidden",value:()=>0},{kind:"field",decorators:[d({type:String,attribute:"back-path"})],key:"backPath",value:void 0},{kind:"field",decorators:[d()],key:"backCallback",value:void 0},{kind:"field",decorators:[d({type:String})],key:"noDataText",value:void 0},{kind:"field",decorators:[d()],key:"route",value:void 0},{kind:"field",decorators:[d()],key:"tabs",value:()=>[]},{kind:"field",decorators:[d({type:Boolean})],key:"hideFilterMenu",value:()=>!1},{kind:"field",decorators:[h("ha-data-table",!0)],key:"_dataTable",value:void 0},{kind:"method",key:"clearSelection",value:function(){this._dataTable.clearSelection()}},{kind:"method",key:"render",value:function(){const e=this.numHidden?this.hiddenLabel||this.hass.localize("ui.components.data-table.hidden","number",this.numHidden)||this.numHidden:void 0,t=this.activeFilters?u`${this.hass.localize("ui.components.data-table.filtering_by")}
  806. ${this.activeFilters.join(", ")}
  807. ${e?`(${e})`:""}`:e,i=u`<search-input
  808. .hass=${this.hass}
  809. .filter=${this.filter}
  810. .suffix=${!this.narrow}
  811. @value-changed=${this._handleSearchChange}
  812. .label=${this.searchLabel||this.hass.localize("ui.components.data-table.search")}
  813. >
  814. ${this.narrow?"":u`<div
  815. class="filters"
  816. slot="suffix"
  817. @click=${this._preventDefault}
  818. >
  819. ${t?u`<div class="active-filters">
  820. ${t}
  821. <mwc-button @click=${this._clearFilter}>
  822. ${this.hass.localize("ui.components.data-table.clear")}
  823. </mwc-button>
  824. </div>`:""}
  825. <slot name="filter-menu"></slot>
  826. </div>`}
  827. </search-input>`;return u`
  828. <hass-tabs-subpage
  829. .hass=${this.hass}
  830. .localizeFunc=${this.localizeFunc}
  831. .narrow=${this.narrow}
  832. .isWide=${this.isWide}
  833. .backPath=${this.backPath}
  834. .backCallback=${this.backCallback}
  835. .route=${this.route}
  836. .tabs=${this.tabs}
  837. .mainPage=${this.mainPage}
  838. .supervisor=${this.supervisor}
  839. >
  840. ${this.hideFilterMenu?"":u`
  841. <div slot="toolbar-icon">
  842. ${this.narrow?u`
  843. <div class="filter-menu">
  844. ${this.numHidden||this.activeFilters?u`<span class="badge"
  845. >${this.numHidden||"!"}</span
  846. >`:""}
  847. <slot name="filter-menu"></slot>
  848. </div>
  849. `:""}<slot name="toolbar-icon"></slot>
  850. </div>
  851. `}
  852. ${this.narrow?u`
  853. <div slot="header">
  854. <slot name="header">
  855. <div class="search-toolbar">${i}</div>
  856. </slot>
  857. </div>
  858. `:""}
  859. <ha-data-table
  860. .hass=${this.hass}
  861. .columns=${this.columns}
  862. .data=${this.data}
  863. .filter=${this.filter}
  864. .selectable=${this.selectable}
  865. .hasFab=${this.hasFab}
  866. .id=${this.id}
  867. .noDataText=${this.noDataText}
  868. .dir=${q(this.hass)}
  869. .clickable=${this.clickable}
  870. .appendRow=${this.appendRow}
  871. >
  872. ${this.narrow?u` <div slot="header"></div> `:u`
  873. <div slot="header">
  874. <slot name="header">
  875. <div class="table-header">${i}</div>
  876. </slot>
  877. </div>
  878. `}
  879. </ha-data-table>
  880. <div slot="fab"><slot name="fab"></slot></div>
  881. </hass-tabs-subpage>
  882. `}},{kind:"method",key:"_preventDefault",value:function(e){e.preventDefault()}},{kind:"method",key:"_handleSearchChange",value:function(e){this.filter!==e.detail.value&&(this.filter=e.detail.value,b(this,"search-changed",{value:this.filter}))}},{kind:"method",key:"_clearFilter",value:function(){b(this,"clear-filter")}},{kind:"get",static:!0,key:"styles",value:function(){return m`
  883. ha-data-table {
  884. width: 100%;
  885. height: 100%;
  886. --data-table-border-width: 0;
  887. }
  888. :host(:not([narrow])) ha-data-table {
  889. height: calc(100vh - 1px - var(--header-height));
  890. display: block;
  891. }
  892. :host([narrow]) hass-tabs-subpage {
  893. --main-title-margin: 0;
  894. }
  895. .table-header {
  896. display: flex;
  897. align-items: center;
  898. --mdc-shape-small: 0;
  899. height: 56px;
  900. }
  901. .search-toolbar {
  902. display: flex;
  903. align-items: center;
  904. color: var(--secondary-text-color);
  905. }
  906. search-input {
  907. --mdc-text-field-fill-color: var(--sidebar-background-color);
  908. --mdc-text-field-idle-line-color: var(--divider-color);
  909. --text-field-overflow: visible;
  910. z-index: 5;
  911. }
  912. .table-header search-input {
  913. display: block;
  914. position: absolute;
  915. top: 0;
  916. right: 0;
  917. left: 0;
  918. }
  919. .search-toolbar search-input {
  920. display: block;
  921. width: 100%;
  922. color: var(--secondary-text-color);
  923. --mdc-ripple-color: transparant;
  924. }
  925. .filters {
  926. --mdc-text-field-fill-color: var(--input-fill-color);
  927. --mdc-text-field-idle-line-color: var(--input-idle-line-color);
  928. --mdc-shape-small: 4px;
  929. --text-field-overflow: initial;
  930. display: flex;
  931. justify-content: flex-end;
  932. margin-right: 8px;
  933. color: var(--primary-text-color);
  934. }
  935. .active-filters {
  936. color: var(--primary-text-color);
  937. position: relative;
  938. display: flex;
  939. align-items: center;
  940. padding: 2px 2px 2px 8px;
  941. margin-left: 4px;
  942. font-size: 14px;
  943. width: max-content;
  944. cursor: initial;
  945. }
  946. .active-filters ha-svg-icon {
  947. color: var(--primary-color);
  948. }
  949. .active-filters mwc-button {
  950. margin-left: 8px;
  951. }
  952. .active-filters::before {
  953. background-color: var(--primary-color);
  954. opacity: 0.12;
  955. border-radius: 4px;
  956. position: absolute;
  957. top: 0;
  958. right: 0;
  959. bottom: 0;
  960. left: 0;
  961. content: "";
  962. }
  963. .badge {
  964. min-width: 20px;
  965. box-sizing: border-box;
  966. border-radius: 50%;
  967. font-weight: 400;
  968. background-color: var(--primary-color);
  969. line-height: 20px;
  970. text-align: center;
  971. padding: 0px 4px;
  972. color: var(--text-primary-color);
  973. position: absolute;
  974. right: 0;
  975. top: 4px;
  976. font-size: 0.65em;
  977. }
  978. .filter-menu {
  979. position: relative;
  980. }
  981. `}}]}}),c);const De=r(((e,t,i)=>(i=i.toUpperCase(),e.filter((e=>Object.entries(t).some((t=>{const[a,o]=t;return!(!o.filterable||!String(o.filterKey?e[o.valueColumn||a][o.filterKey]:e[o.valueColumn||a]).toUpperCase().includes(i))}))))))),He=r(((e,t,i,a)=>e.sort(((e,o)=>{let s=1;"desc"===i&&(s=-1);let l=t.filterKey?e[t.valueColumn||a][t.filterKey]:e[t.valueColumn||a],r=t.filterKey?o[t.valueColumn||a][t.filterKey]:o[t.valueColumn||a];return"string"==typeof l&&(l=l.toUpperCase()),"string"==typeof r&&(r=r.toUpperCase()),void 0===l&&void 0!==r?1:void 0===r&&void 0!==l?-1:l<r?-1*s:l>r?1*s:0}))));n([_("hacs-data-table")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"method",key:"_sortFilterData",value:async function(){const e=(new Date).getTime();this.curRequest++;const t=this.curRequest;let i=this.data;this._filter&&(i=await this._memFilterData(this.data,this._sortColumns,this._filter));const a=this._sortColumn?He(i,this._sortColumns[this._sortColumn],this._sortDirection,this._sortColumn):i,o=(new Date).getTime()-e;if(o<100&&await new Promise((e=>setTimeout(e,100-o))),this.curRequest===t){if(this.appendRow||this.hasFab){const e=[...a];this.appendRow&&e.push({append:!0,content:this.appendRow}),this.hasFab&&e.push({empty:!0}),this._items=e}else this._items=a;this._filteredData=a}}},{kind:"field",key:"_memFilterData",value:()=>r((async(e,t,i)=>De(e,t,i)))}]}}),Te),n([_("hacs-tabs-subpage-data-table")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"method",key:"render",value:function(){const e=this.numHidden?this.hiddenLabel||this.hass.localize("ui.components.data-table.hidden","number",this.numHidden)||this.numHidden:void 0,t=this.activeFilters?u`${this.hass.localize("ui.components.data-table.filtering_by")}
  982. ${this.activeFilters.join(", ")} ${e?`(${e})`:""}`:e,i=u`<search-input
  983. .hass=${this.hass}
  984. .filter=${this.filter}
  985. .suffix=${!this.narrow}
  986. @value-changed=${this._handleSearchChange}
  987. .label=${this.searchLabel||this.hass.localize("ui.components.data-table.search")}
  988. >
  989. ${this.narrow?"":u`<div class="filters" slot="suffix" @click=${this._preventDefault}>
  990. ${t?u`<div class="active-filters">
  991. ${t}
  992. <mwc-button @click=${this._clearFilter}>
  993. ${this.hass.localize("ui.components.data-table.clear")}
  994. </mwc-button>
  995. </div>`:""}
  996. <slot name="filter-menu"></slot>
  997. </div>`}
  998. </search-input>`;return u`
  999. <hass-tabs-subpage
  1000. .hass=${this.hass}
  1001. .localizeFunc=${this.localizeFunc}
  1002. .narrow=${this.narrow}
  1003. .isWide=${this.isWide}
  1004. .backPath=${this.backPath}
  1005. .backCallback=${this.backCallback}
  1006. .route=${this.route}
  1007. .tabs=${this.tabs}
  1008. .mainPage=${this.mainPage}
  1009. .supervisor=${this.supervisor}
  1010. >
  1011. ${this.hideFilterMenu?"":u`
  1012. <div slot="toolbar-icon">
  1013. ${this.narrow?u`
  1014. <div class="filter-menu">
  1015. ${this.numHidden||this.activeFilters?u`<span class="badge">${this.numHidden||"!"}</span>`:""}
  1016. <slot name="filter-menu"></slot>
  1017. </div>
  1018. `:""}<slot name="toolbar-icon"></slot>
  1019. </div>
  1020. `}
  1021. ${this.narrow?u`
  1022. <div slot="header">
  1023. <slot name="header">
  1024. <div class="search-toolbar">${i}</div>
  1025. </slot>
  1026. </div>
  1027. `:""}
  1028. <hacs-data-table
  1029. .hass=${this.hass}
  1030. .columns=${this.columns}
  1031. .data=${this.data}
  1032. .filter=${this.filter}
  1033. .selectable=${this.selectable}
  1034. .hasFab=${this.hasFab}
  1035. .id=${this.id}
  1036. .noDataText=${this.noDataText}
  1037. .dir=${q(this.hass)}
  1038. .clickable=${this.clickable}
  1039. .appendRow=${this.appendRow}
  1040. >
  1041. ${this.narrow?u` <div slot="header"></div> `:u`
  1042. <div slot="header">
  1043. <slot name="header">
  1044. <div class="table-header">${i}</div>
  1045. </slot>
  1046. </div>
  1047. `}
  1048. </hacs-data-table>
  1049. <div slot="fab"><slot name="fab"></slot></div>
  1050. </hass-tabs-subpage>
  1051. `}},{kind:"get",static:!0,key:"styles",value:function(){return[g(y(i),"styles",this),m`
  1052. hacs-data-table {
  1053. width: 100%;
  1054. height: 100%;
  1055. --data-table-border-width: 0;
  1056. }
  1057. :host(:not([narrow])) hacs-data-table {
  1058. height: calc(100vh - 1px - var(--header-height));
  1059. display: block;
  1060. }
  1061. `]}}]}}),Se);const Ee={entry:{name:!0,downloads:!1,stars:!1,last_updated:!1,category:!0},explore:{name:!0,downloads:!1,stars:!1,last_updated:!1,category:!0}},Fe={title:"",hidden:!0,filterable:!0};let Le=n([_("hacs-experimental-panel")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[d({attribute:!1})],key:"hacs",value:void 0},{kind:"field",decorators:[d({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[d({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[d({type:Boolean,reflect:!0})],key:"narrow",value:void 0},{kind:"field",decorators:[d({type:Boolean})],key:"isWide",value:void 0},{kind:"field",decorators:[d({attribute:!1})],key:"section",value:void 0},{kind:"field",decorators:[V("hacs-table-filters",!0,!1)],key:"activeFilters",value:void 0},{kind:"field",decorators:[V("hacs-table-columns",!0,!1)],key:"_tableColumns",value:()=>Ee},{kind:"field",key:"render",value(){return()=>{var e;const t=this._filterRepositories(this.hacs.repositories,"entry"===this.section,this.activeFilters),i=t.filter((e=>e.new)),a=t.filter((e=>!e.new)),o="explore"===this.section&&0!==i.length;return u`<hacs-tabs-subpage-data-table
  1062. .tabs=${[{name:"entry"===this.section?"Home Assistant Community Store - Downloaded":"Home Assistant Community Store - Explore",path:"/hacs/entry",iconPath:"m 20.064849,22.306912 c -0.0319,0.369835 -0.280561,0.707789 -0.656773,0.918212 -0.280572,0.153036 -0.605773,0.229553 -0.950094,0.229553 -0.0765,0 -0.146661,-0.0064 -0.216801,-0.01275 -0.605774,-0.05739 -1.135016,-0.344329 -1.402827,-0.7588 l 0.784304,-0.516495 c 0.0893,0.146659 0.344331,0.312448 0.707793,0.34433 0.235931,0.02551 0.471852,-0.01913 0.637643,-0.108401 0.101998,-0.05101 0.172171,-0.127529 0.17854,-0.191295 0.0065,-0.08289 -0.0255,-0.369835 -0.733293,-0.439975 -1.013854,-0.09565 -1.645127,-0.688661 -1.568606,-1.460214 0.0319,-0.382589 0.280561,-0.714165 0.663153,-0.930965 0.331571,-0.172165 0.752423,-0.25506 1.166895,-0.210424 0.599382,0.05739 1.128635,0.344329 1.402816,0.7588 l -0.784304,0.510118 c -0.0893,-0.140282 -0.344331,-0.299694 -0.707782,-0.331576 -0.235932,-0.02551 -0.471863,0.01913 -0.637654,0.10202 -0.0956,0.05739 -0.165791,0.133906 -0.17216,0.191295 -0.0255,0.293317 0.465482,0.420847 0.726913,0.439976 v 0.0064 c 1.020234,0.09565 1.638757,0.66953 1.562237,1.460213 z m -7.466854,-0.988354 c 0,-1.192401 0.962855,-2.155249 2.15525,-2.155249 0.599393,0 1.179645,0.25506 1.594117,0.707789 l -0.695033,0.624895 c -0.235931,-0.25506 -0.561133,-0.401718 -0.899084,-0.401718 -0.675903,0 -1.217906,0.542 -1.217906,1.217906 0,0.66953 0.542003,1.217908 1.217906,1.217908 0.337951,0 0.663153,-0.140283 0.899084,-0.401718 l 0.695033,0.631271 c -0.414472,0.452729 -0.988355,0.707788 -1.594117,0.707788 -1.192395,0 -2.15525,-0.969224 -2.15525,-2.148872 z M 8.6573365,23.461054 10.353474,19.14418 h 0.624893 l 1.568618,4.316874 H 11.52037 L 11.265308,22.734136 H 9.964513 l -0.274192,0.726918 z m 1.6833885,-1.68339 h 0.580263 L 10.646796,21.012487 Z M 8.1089536,19.156932 v 4.297745 H 7.1461095 v -1.645131 h -1.606867 v 1.645131 H 4.5763876 v -4.297745 h 0.9628549 v 1.696143 h 1.606867 V 19.156932 Z M 20.115859,4.2997436 C 20.090359,4.159461 19.969198,4.0574375 19.822548,4.0574375 H 14.141102 10.506516 4.8250686 c -0.14665,0 -0.2678112,0.1020202 -0.2933108,0.2423061 L 3.690064,8.8461703 c -0.00651,0.01913 -0.00651,0.03826 -0.00651,0.057391 v 1.5239797 c 0,0.165789 0.133911,0.299694 0.2996911,0.299694 H 4.5762579 20.0711 20.664112 c 0.165781,0 0.299691,-0.133905 0.299691,-0.299694 V 8.8971848 c 0,-0.01913 0,-0.03826 -0.0065,-0.05739 z M 4.5763876,17.358767 c 0,0.184917 0.1466608,0.331577 0.3315819,0.331577 h 5.5985465 3.634586 0.924594 c 0.184911,0 0.331571,-0.14666 0.331571,-0.331577 v -4.744098 c 0,-0.184918 0.146661,-0.331577 0.331582,-0.331577 h 2.894913 c 0.184921,0 0.331582,0.146659 0.331582,0.331577 v 4.744098 c 0,0.184917 0.146661,0.331577 0.331571,0.331577 h 0.446363 c 0.18491,0 0.331571,-0.14666 0.331571,-0.331577 v -5.636804 c 0,-0.184918 -0.146661,-0.331577 -0.331571,-0.331577 H 4.9079695 c -0.1849211,0 -0.3315819,0.146659 -0.3315819,0.331577 z m 1.6578879,-4.852498 h 5.6495565 c 0.15303,0 0.280561,0.12753 0.280561,0.280564 v 3.513438 c 0,0.153036 -0.127531,0.280566 -0.280561,0.280566 H 6.2342755 c -0.1530412,0 -0.2805719,-0.12753 -0.2805719,-0.280566 v -3.513438 c 0,-0.159411 0.1275307,-0.280564 0.2805719,-0.280564 z M 19.790657,3.3879075 H 4.8569594 c -0.1530412,0 -0.2805718,-0.1275296 -0.2805718,-0.2805642 V 1.3665653 C 4.5763876,1.2135296 4.7039182,1.086 4.8569594,1.086 H 19.790657 c 0.153041,0 0.280572,0.1275296 0.280572,0.2805653 v 1.740778 c 0,0.1530346 -0.127531,0.2805642 -0.280572,0.2805642 z"}]}
  1063. .columns=${this._columns(this.narrow,o,this._tableColumns)}
  1064. .data=${i.concat(a)}
  1065. .hass=${this.hass}
  1066. isWide=${this.isWide}
  1067. .localizeFunc=${this.hass.localize}
  1068. .mainPage=${"entry"===this.section}
  1069. .narrow=${this.narrow}
  1070. .route=${this.route}
  1071. clickable
  1072. .activeFilters=${this.activeFilters}
  1073. .hasFab=${"entry"===this.section}
  1074. .noDataText=${"entry"===this.section?"No downloaded repositories":"No repositories matching search"}
  1075. @row-click=${this._handleRowClicked}
  1076. @clear-filter=${this._handleClearFilter}
  1077. >
  1078. <ha-icon-overflow-menu
  1079. narrow
  1080. slot="toolbar-icon"
  1081. .hass=${this.hass}
  1082. .items=${[{path:H,label:this.hacs.localize("menu.documentation"),action:()=>E.open("https://hacs.xyz/","_blank","noreferrer=true")},{path:F,label:"GitHub",action:()=>E.open("https://github.com/hacs","_blank","noreferrer=true")},{path:L,label:this.hacs.localize("menu.open_issue"),action:()=>E.open("https://hacs.xyz/docs/issues","_blank","noreferrer=true")},{path:M,disabled:Boolean(this.hacs.info.disabled_reason),label:this.hacs.localize("menu.custom_repositories"),action:()=>{this.dispatchEvent(new CustomEvent("hacs-dialog",{detail:{type:"custom-repositories",repositories:this.hacs.repositories},bubbles:!0,composed:!0}))}},o?{path:P,label:this.hacs.localize("menu.dismiss"),action:()=>{B(this.hass,this.hacs)}}:void 0,{path:j,label:this.hacs.localize("menu.about"),action:()=>{(async(e,t)=>{J(e,{title:"Home Assistant Community Store",confirmText:t.localize("common.close"),text:Z.html(`\n **${t.localize("dialog_about.integration_version")}:** | ${t.info.version}\n --|--\n **${t.localize("dialog_about.frontend_version")}:** | 20221022143238\n **${t.localize("common.repositories")}:** | ${t.repositories.length}\n **${t.localize("dialog_about.downloaded_repositories")}:** | ${t.repositories.filter((e=>e.installed)).length}\n\n **${t.localize("dialog_about.useful_links")}:**\n\n - [General documentation](https://hacs.xyz/)\n - [Configuration](https://hacs.xyz/docs/configuration/start)\n - [FAQ](https://hacs.xyz/docs/faq/what)\n - [GitHub](https://github.com/hacs)\n - [Discord](https://discord.gg/apgchf8)\n - [Become a GitHub sponsor? ❤️](https://github.com/sponsors/ludeeus)\n - [BuyMe~~Coffee~~Beer? 🍺🙈](https://buymeacoffee.com/ludeeus)\n\n ***\n\n _Everything you find in HACS is **not** tested by Home Assistant, that includes HACS itself.\n The HACS and Home Assistant teams do not support **anything** you find here._`)})})(this,this.hacs)}}].filter((e=>void 0!==e))}
  1083. >
  1084. </ha-icon-overflow-menu>
  1085. ${this.narrow?" ":u` <ha-button-menu slot="filter-menu" corner="BOTTOM_START" multi>
  1086. <ha-icon-button
  1087. slot="trigger"
  1088. .label=${this.hass.localize("ui.panel.config.entities.picker.filter.filter")}
  1089. .path=${A}
  1090. >
  1091. </ha-icon-button>
  1092. <ha-select
  1093. label="Category filter"
  1094. @selected=${this._handleCategoryFilterChange}
  1095. @closed=${Y}
  1096. naturalMenuWidth
  1097. .value=${(null===(e=this.activeFilters)||void 0===e?void 0:e.find((e=>e.startsWith(`${this.hacs.localize("dialog_custom_repositories.category")}: `))))||""}
  1098. >
  1099. ${this.hacs.info.categories.map((e=>u`
  1100. <mwc-list-item
  1101. .value="${this.hacs.localize("dialog_custom_repositories.category")}: ${this.hacs.localize(`common.${e}`)}"
  1102. >
  1103. ${this.hacs.localize(`common.${e}`)}
  1104. </mwc-list-item>
  1105. `))}
  1106. </ha-select>
  1107. <div class="divider"></div>
  1108. <p class="menu_header">Columns</p>
  1109. ${Object.keys(Ee[this.section]).map((e=>u`
  1110. <ha-check-list-item
  1111. @request-selected=${this._handleColumnChange}
  1112. graphic="control"
  1113. .column=${e}
  1114. .selected=${this._tableColumns[this.section][e]||Ee[this.section][e]}
  1115. left
  1116. >
  1117. ${this.hacs.localize(`column.${e}`)}
  1118. </ha-check-list-item>
  1119. `))}
  1120. </ha-button-menu>`}
  1121. ${"entry"===this.section?u`
  1122. <a href="/hacs/explore" slot="fab">
  1123. <ha-fab .label=${this.hacs.localize("common.explore")} .extended=${!this.narrow}>
  1124. <ha-svg-icon slot="icon" .path=${O}></ha-svg-icon> </ha-fab
  1125. ></a>
  1126. `:""}
  1127. </hacs-tabs-subpage-data-table>`}}},{kind:"field",key:"_filterRepositories",value(){return r(((e,t,i)=>e.filter((e=>!(i&&!i.includes(`${this.hacs.localize("dialog_custom_repositories.category")}: ${this.hacs.localize(`common.${e.category}`)}`))&&(!t&&!e.installed||t&&e.installed))).sort(((e,t)=>e.stars<t.stars?1:-1))))}},{kind:"field",key:"_columns",value(){return r(((e,t,i)=>({icon:{title:"",label:this.hass.localize("ui.panel.config.lovelace.dashboards.picker.headers.icon"),hidden:this.narrow||"entry"!==this.section,type:"icon",template:(e,t)=>{var i;return u`
  1128. <img
  1129. style="height: 32px; width: 32px"
  1130. slot="item-icon"
  1131. src=${X({domain:t.domain||"github",type:"icon",useFallback:!0,darkOptimized:null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode})}
  1132. referrerpolicy="no-referrer"
  1133. />
  1134. `}},name:{...Fe,title:this.hacs.localize("column.name"),main:!0,sortable:!0,direction:"explore"===this.section||t?void 0:"asc",hidden:!i[this.section].name,grows:!0,template:(t,i)=>u`
  1135. ${i.new?u`<ha-svg-icon
  1136. style="color: var(--primary-color); margin-right: 4px;"
  1137. .path=${P}
  1138. ></ha-svg-icon>`:""}${t}<br />
  1139. <div class="secondary">
  1140. ${e?this.hacs.localize(`common.${i.category}`):i.description}
  1141. </div>
  1142. `},downloads:{...Fe,title:this.hacs.localize("column.downloads"),hidden:e||!i[this.section].downloads,sortable:!0,width:"10%",template:e=>u`${e||"-"}`},stars:{...Fe,title:this.hacs.localize("column.stars"),hidden:e||!i[this.section].stars,direction:"entry"===this.section||t?void 0:"desc",sortable:!0,width:"10%"},last_updated:{...Fe,title:this.hacs.localize("column.last_updated"),hidden:e||!i[this.section].last_updated,sortable:!0,width:"15%",template:e=>de(new Date(e),this.hass.locale)},category:{...Fe,title:this.hacs.localize("column.category"),hidden:e||!i[this.section].category,sortable:!0,width:"10%",template:e=>this.hacs.localize(`common.${e}`)},authors:Fe,description:Fe,domain:Fe,full_name:Fe,id:Fe,topics:Fe,actions:{title:"",width:this.narrow?void 0:"10%",hidden:"entry"!==this.section,type:"overflow-menu",template:(e,t)=>u`
  1143. <ha-icon-overflow-menu
  1144. .hass=${this.hass}
  1145. .items=${ee(this,t)}
  1146. narrow
  1147. >
  1148. </ha-icon-overflow-menu>
  1149. `}})))}},{kind:"method",key:"_handleRowClicked",value:function(e){N(`/hacs/repository/${e.detail.id}`)}},{kind:"method",key:"_handleCategoryFilterChange",value:function(e){e.stopPropagation();const t=e.target.value;t&&(this.activeFilters=[t])}},{kind:"method",key:"_handleColumnChange",value:function(e){e.stopPropagation();const t={...this._tableColumns[this.section],[e.currentTarget.column]:e.detail.selected};this._tableColumns={...this._tableColumns,[this.section]:Object.keys(Ee[this.section]).reduce(((e,i)=>({...e,[i]:t[i]||Ee[this.section][i]})),{})}}},{kind:"method",key:"_handleClearFilter",value:function(){this.activeFilters=void 0}},{kind:"get",static:!0,key:"styles",value:function(){return[I,W,m`
  1150. .menu_header {
  1151. font-size: 14px;
  1152. margin: 8px;
  1153. }
  1154. .divider {
  1155. bottom: 112px;
  1156. padding: 10px 0px;
  1157. }
  1158. .divider::before {
  1159. content: " ";
  1160. display: block;
  1161. height: 1px;
  1162. background-color: var(--divider-color);
  1163. }
  1164. ha-select {
  1165. margin: 0 8px;
  1166. }
  1167. `]}}]}}),c);export{Le as HacsExperimentalPanel};