UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 30.1 kB
export const __rspack_esm_id=79662;export const __rspack_esm_ids=[79662];export const __webpack_modules__={20058(e,t,i){i.a(e,async function(e,a){try{i.d(t,{QL:()=>p,ZQ:()=>h,ZV:()=>c,ty:()=>d,x:()=>r});var s=i(74487),n=(i(74423),i(18111),i(61701),i(46927)),o=e([s]);s=(o.then?(await o)():o)[0];const r=e=>d(e.attributes),d=(e,t)=>!!e.unit_of_measurement||!!e.state_class||(t||[]).includes(e.device_class||""),l=e=>{switch(e.number_format){case n.jG.comma_decimal:return["en-US","en"];case n.jG.decimal_comma:return["de","es","it"];case n.jG.space_comma:return["fr","sv","cs"];case n.jG.quote_decimal:return["de-CH"];case n.jG.system:return;default:return e.language}},c=(e,t,i)=>p(e,t,i).map(e=>e.value).join(""),p=(e,t,i)=>{const a=t?l(t):void 0;return t?.number_format===n.jG.none||Number.isNaN(Number(e))?Number.isNaN(Number(e))||""===e||t?.number_format!==n.jG.none?[{type:"literal",value:e}]:new Intl.NumberFormat("en-US",u(e,{...i,useGrouping:!1})).formatToParts(Number(e)):new Intl.NumberFormat(a,u(e,i)).formatToParts(Number(e))},h=(e,t)=>{const i=t?.display_precision;return null!=i?{maximumFractionDigits:i,minimumFractionDigits:i}:Number.isInteger(Number(e?.attributes?.step))&&Number.isInteger(Number(e?.state))?{maximumFractionDigits:0}:void 0},u=(e,t)=>{const i={maximumFractionDigits:2,...t};if("string"!=typeof e)return i;if(!t||void 0===t.minimumFractionDigits&&void 0===t.maximumFractionDigits){const t=e.indexOf(".")>-1?e.split(".")[1].length:0;i.minimumFractionDigits=t,i.maximumFractionDigits=t}return i};a()}catch(e){a(e)}})},63130(e,t,i){i.d(t,{l:()=>s});var a=i(50248);const s=async(e,t)=>{if(navigator.clipboard)try{return void await navigator.clipboard.writeText(e)}catch{}const i=t||(0,a.n)()?.getRootNode()||document.body,s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.opacity="0",i.appendChild(s),s.select(),document.execCommand("copy"),i.removeChild(s)}},11382(e,t,i){var a=i(62826),s=i(5124),n=i(22441),o=i(6412),r=i(1087),d=i(12587);i(67094);class l extends s.WF{render(){const e=this.noCollapse?s.s6:s.qy` <ha-svg-icon .path="${"M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"}" class="summary-icon ${(0,o.H)({expanded:this.expanded})}"></ha-svg-icon> `;return s.qy` <div class="top ${(0,o.H)({expanded:this.expanded})}"> <div id="summary" class="${(0,o.H)({noCollapse:this.noCollapse})}" @click="${this._toggleContainer}" @keydown="${this._toggleContainer}" @focus="${this._focusChanged}" @blur="${this._focusChanged}" role="button" tabindex="${this.noCollapse?-1:0}" aria-expanded="${this.expanded}" aria-controls="sect1" part="summary"> ${this.leftChevron?e:s.s6} <slot name="leading-icon"></slot> <slot name="header"> <div class="header"> ${this.header} <slot class="secondary" name="secondary">${this.secondary}</slot> </div> </slot> <slot name="event"></slot> ${this.leftChevron?s.s6:e} <slot name="icons"></slot> </div> </div> <div class="container ${(0,o.H)({expanded:this.expanded})}" @transitionend="${this._handleTransitionEnd}" role="region" aria-labelledby="summary" aria-hidden="${!this.expanded}" tabindex="-1"> ${this._showContent?s.qy`<slot></slot>`:""} </div> `}willUpdate(e){super.willUpdate(e),e.has("expanded")&&(this._showContent=this.expanded,setTimeout(()=>{this._container.style.overflow=this.expanded?"initial":"hidden"},300))}_handleTransitionEnd(){this._container.style.removeProperty("height"),this._container.style.overflow=this.expanded?"initial":"hidden",this._showContent=this.expanded}async _toggleContainer(e){if(e.defaultPrevented)return;if("keydown"===e.type&&"Enter"!==e.key&&" "!==e.key)return;if(e.preventDefault(),this.noCollapse)return;const t=!this.expanded;(0,r.r)(this,"expanded-will-change",{expanded:t}),this._container.style.overflow="hidden",t&&(this._showContent=!0,await(0,d.E)());const i=this._container.scrollHeight;this._container.style.height=`${i}px`,t||setTimeout(()=>{this._container.style.height="0px"},0),this.expanded=t,(0,r.r)(this,"expanded-changed",{expanded:this.expanded})}_focusChanged(e){this.noCollapse||this.shadowRoot.querySelector(".top").classList.toggle("focused","focus"===e.type)}constructor(...e){super(...e),this.expanded=!1,this.outlined=!1,this.leftChevron=!1,this.noCollapse=!1,this._showContent=this.expanded}}l.styles=s.AH`:host{display:block}.top{display:flex;align-items:center;border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg))}.top.expanded{border-bottom-left-radius:0px;border-bottom-right-radius:0px}.top.focused{background:var(--input-fill-color)}:host([outlined]){box-shadow:none;border-width:1px;border-style:solid;border-color:var(--outline-color);border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg))}.summary-icon{transition:transform 150ms cubic-bezier(.4, 0, .2, 1);direction:var(--direction);margin-left:8px;margin-inline-start:8px;margin-inline-end:initial;border-radius:var(--ha-border-radius-circle)}#summary:focus-visible ha-svg-icon.summary-icon{background-color:var(--ha-color-fill-neutral-normal-active)}::slotted([slot=leading-icon]),:host([left-chevron]) .summary-icon{margin-left:0;margin-right:8px;margin-inline-start:0;margin-inline-end:8px}#summary{flex:1;display:flex;padding:var(--expansion-panel-summary-padding,0 8px);min-height:48px;align-items:center;cursor:pointer;overflow:hidden;font-weight:var(--ha-font-weight-medium);outline:0}#summary.noCollapse{cursor:default}.summary-icon.expanded{transform:rotate(180deg)}.header,::slotted([slot=header]){flex:1;overflow-wrap:anywhere;color:var(--primary-text-color)}.container{padding:var(--expansion-panel-content-padding,0 8px);overflow:hidden;transition:height .3s cubic-bezier(.4, 0, .2, 1);height:0px}.container.expanded{height:auto}.secondary{display:block;color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}`,(0,a.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],l.prototype,"expanded",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],l.prototype,"outlined",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"left-chevron",type:Boolean,reflect:!0})],l.prototype,"leftChevron",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"no-collapse",type:Boolean,reflect:!0})],l.prototype,"noCollapse",void 0),(0,a.Cg)([(0,n.MZ)()],l.prototype,"header",void 0),(0,a.Cg)([(0,n.MZ)()],l.prototype,"secondary",void 0),(0,a.Cg)([(0,n.wk)()],l.prototype,"_showContent",void 0),(0,a.Cg)([(0,n.P)(".container")],l.prototype,"_container",void 0),l=(0,a.Cg)([(0,n.EM)("ha-expansion-panel")],l)},47680(e,t,i){i.r(t),i.d(t,{HaIcon:()=>w});i(74423);var a=i(62826),s=i(5124),n=i(22441),o=i(1087),r=i(9899),d=i(700),l=(i(44114),i(18111),i(7588),i(95192)),c=i(7553);const p=JSON.parse('{"version":"7.4.47","parts":[{"file":"7a7139d465f1f41cb26ab851a17caa21a9331234"},{"start":"account-supervisor-circle-","file":"9561286c4c1021d46b9006596812178190a7cc1c"},{"start":"alpha-r-c","file":"eb466b7087fb2b4d23376ea9bc86693c45c500fa"},{"start":"arrow-decision-o","file":"4b3c01b7e0723b702940c5ac46fb9e555646972b"},{"start":"baby-f","file":"2611401d85450b95ab448ad1d02c1a432b409ed2"},{"start":"battery-hi","file":"89bcd31855b34cd9d31ac693fb073277e74f1f6a"},{"start":"blur-r","file":"373709cd5d7e688c2addc9a6c5d26c2d57c02c48"},{"start":"briefcase-account-","file":"a75956cf812ee90ee4f656274426aafac81e1053"},{"start":"calendar-question-","file":"3253f2529b5ebdd110b411917bacfacb5b7063e6"},{"start":"car-lig","file":"74566af3501ad6ae58ad13a8b6921b3cc2ef879d"},{"start":"cellphone-co","file":"7677f1cfb2dd4f5562a2aa6d3ae43a2e6997b21a"},{"start":"circle-slice-2","file":"70d08c50ec4522dd75d11338db57846588263ee2"},{"start":"cloud-co","file":"141d2bfa55ca4c83f4bae2812a5da59a84fec4ff"},{"start":"cog-s","file":"5a640365f8e47c609005d5e098e0e8104286d120"},{"start":"cookie-l","file":"dd85b8eb8581b176d3acf75d1bd82e61ca1ba2fc"},{"start":"currency-eur-","file":"15362279f4ebfc3620ae55f79d2830ad86d5213e"},{"start":"delete-o","file":"239434ab8df61237277d7599ebe066c55806c274"},{"start":"draw-","file":"5605918a592070803ba2ad05a5aba06263da0d70"},{"start":"emoticon-po","file":"a838cfcec34323946237a9f18e66945f55260f78"},{"start":"fan","file":"effd56103b37a8c7f332e22de8e4d67a69b70db7"},{"start":"file-question-","file":"b2424b50bd465ae192593f1c3d086c5eec893af8"},{"start":"flask-off-","file":"3b76295cde006a18f0301dd98eed8c57e1d5a425"},{"start":"food-s","file":"1c6941474cbeb1755faaaf5771440577f4f1f9c6"},{"start":"gamepad-u","file":"c6efe18db6bc9654ae3540c7dee83218a5450263"},{"start":"google-f","file":"df341afe6ad4437457cf188499cb8d2df8ac7b9e"},{"start":"head-c","file":"282121c9e45ed67f033edcc1eafd279334c00f46"},{"start":"home-pl","file":"27e8e38fc7adcacf2a210802f27d841b49c8c508"},{"start":"inbox-","file":"0f0316ec7b1b7f7ce3eaabce26c9ef619b5a1694"},{"start":"key-v","file":"ea33462be7b953ff1eafc5dac2d166b210685a60"},{"start":"leaf-circle-","file":"33db9bbd66ce48a2db3e987fdbd37fb0482145a4"},{"start":"lock-p","file":"b89e27ed39e9d10c44259362a4b57f3c579d3ec8"},{"start":"message-s","file":"7b5ab5a5cadbe06e3113ec148f044aa701eac53a"},{"start":"moti","file":"01024d78c248d36805b565e343dd98033cc3bcaf"},{"start":"newspaper-variant-o","file":"22a6ec4a4fdd0a7c0acaf805f6127b38723c9189"},{"start":"on","file":"c73d55b412f394e64632e2011a59aa05e5a1f50d"},{"start":"paw-ou","file":"3f669bf26d16752dc4a9ea349492df93a13dcfbf"},{"start":"pigg","file":"0c24edb27eb1c90b6e33fc05f34ef3118fa94256"},{"start":"printer-pos-sy","file":"41a55cda866f90b99a64395c3bb18c14983dcf0a"},{"start":"read","file":"c7ed91552a3a64c9be88c85e807404cf705b7edf"},{"start":"robot-vacuum-variant-o","file":"917d2a35d7268c0ea9ad9ecab2778060e19d90e0"},{"start":"sees","file":"6e82d9861d8fac30102bafa212021b819f303bdb"},{"start":"shoe-f","file":"e2fe7ce02b5472301418cc90a0e631f187b9f238"},{"start":"snowflake-m","file":"a28ba9f5309090c8b49a27ca20ff582a944f6e71"},{"start":"st","file":"7e92d03f095ec27e137b708b879dfd273bd735ab"},{"start":"su","file":"61c74913720f9de59a379bdca37f1d2f0dc1f9db"},{"start":"tag-plus-","file":"8f3184156a4f38549cf4c4fffba73a6a941166ae"},{"start":"timer-a","file":"baab470d11cfb3a3cd3b063ee6503a77d12a80d0"},{"start":"transit-d","file":"8561c0d9b1ac03fab360fd8fe9729c96e8693239"},{"start":"vector-arrange-b","file":"c9a3439257d4bab33d3355f1f2e11842e8171141"},{"start":"water-ou","file":"02dbccfb8ca35f39b99f5a085b095fc1275005a0"},{"start":"webc","file":"57bafd4b97341f4f2ac20a609d023719f23a619c"},{"start":"zip","file":"65ae094e8263236fa50486584a08c03497a38d93"}]}');let h;const u=()=>(h||(h=f().catch(e=>{throw h=void 0,e})),h),f=async()=>{const e=(0,l.y$)("hass-icon-db","mdi-icon-store"),t=await(0,l.Jt)("_version",e);return t?t!==p.version&&(await(0,l.IU)(e),(0,l.hZ)("_version",p.version,e)):(0,l.hZ)("_version",p.version,e),e},v=["mdi","hass","hassio","hademo"];let g=[];i(67094);const m={},y={},b=(0,r.s)(()=>(async e=>{const t=Object.keys(e),i=await Promise.allSettled(Object.values(e));(await u())("readwrite",a=>{i.forEach((i,s)=>{"fulfilled"===i.status&&Object.entries(i.value).forEach(([e,t])=>{a.put(t,e)}),delete e[t[s]]})})})(y),2e3),_={},x={"home-assistant":()=>i.e(58781).then(i.bind(i,53580)).then(e=>e.mdiHomeAssistant),"music-assistant":()=>i.e(56009).then(i.bind(i,10576)).then(e=>e.mdiMusicAssistant),esphome:()=>i.e(88800).then(i.bind(i,45091)).then(e=>e.mdiEsphomeLogo)};class w extends s.WF{willUpdate(e){super.willUpdate(e),e.has("icon")&&(this._path=void 0,this._secondaryPath=void 0,this._viewBox=void 0,this._loadIcon())}render(){return this.icon?this._legacy?s.qy` <iron-icon .icon="${this.icon}"></iron-icon>`:s.qy`<ha-svg-icon .path="${this._path}" .secondaryPath="${this._secondaryPath}" .viewBox="${this._viewBox}"></ha-svg-icon>`:s.s6}async _loadIcon(){if(!this.icon)return;const e=this.icon,[t,i]=this.icon.split(":",2);let a,s=i;if(!t||!s)return;if(!v.includes(t)){const i=d.y[t];return i?void(i&&"function"==typeof i.getIcon&&this._setCustomPath(i.getIcon(s),e)):void(this._legacy=!0)}if(this._legacy=!1,s in m){const e=m[s];let i;e.newName?(i=`Icon ${t}:${s} was renamed to ${t}:${e.newName}, please change your config, it will be removed in version ${e.removeIn}.`,s=e.newName):i=`Icon ${t}:${s} was removed from MDI, please replace this icon with an other icon in your config, it will be removed in version ${e.removeIn}.`,console.warn(i),(0,o.r)(this,"write_log",{level:"warning",message:i})}if(s in _)return void(this._path=_[s]);if(s in x){const t=await x[s]();return this.icon===e&&(this._path=t),void(_[s]=t)}try{a=await(e=>new Promise((t,i)=>{if(g.push([e,t,i]),g.length>1)return;const a=u();(0,c.h)(1e3,(async()=>{(await a)("readonly",e=>{for(const[t,i,a]of g)(0,l.Yd)(e.get(t)).then(e=>i(e)).catch(e=>a(e));g=[]})})()).catch(e=>{for(const[,,t]of g)t(e);g=[]})}))(s)}catch(e){a=void 0}if(a)return this.icon===e&&(this._path=a),void(_[s]=a);const n=(e=>{let t;for(const i of p.parts){if(void 0!==i.start&&e<i.start)break;t=i}return t.file})(s);if(n in y)return void this._setPath(y[n],s,e);const r=fetch(`/static/mdi/${n}.json`).then(e=>e.json());y[n]=r,this._setPath(r,s,e),r.catch(()=>{delete y[n]}),b()}async _setCustomPath(e,t){const i=await e;this.icon===t&&(this._path=i.path,this._secondaryPath=i.secondaryPath,this._viewBox=i.viewBox)}async _setPath(e,t,i){try{const a=await e;this.icon===i&&(this._path=a[t]),_[t]=a[t]}catch(e){}}constructor(...e){super(...e),this._legacy=!1}}w.styles=s.AH`:host{fill:currentcolor}`,(0,a.Cg)([(0,n.MZ)()],w.prototype,"icon",void 0),(0,a.Cg)([(0,n.wk)()],w.prototype,"_path",void 0),(0,a.Cg)([(0,n.wk)()],w.prototype,"_secondaryPath",void 0),(0,a.Cg)([(0,n.wk)()],w.prototype,"_viewBox",void 0),(0,a.Cg)([(0,n.wk)()],w.prototype,"_legacy",void 0),w=(0,a.Cg)([(0,n.EM)("ha-icon")],w)},10763(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(53289),n=i(5124),o=i(22441),r=i(35211),d=i(1087),l=i(63130),c=i(14503),p=i(81619),h=i(18350),u=i(15717),f=i(22792),v=e([h,u]);[h,u]=v.then?(await v)():v;const g=e=>{if("object"!=typeof e||null===e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0};class m extends n.WF{setValue(e){try{this._yaml=g(e)?"":(0,s.dump)(e,{schema:this.yamlSchema,quotingType:'"',noRefs:!0})}catch(t){console.error(t,e),alert(`There was an error converting to YAML: ${t}`)}}firstUpdated(){void 0!==this.defaultValue&&this.setValue(this.defaultValue)}willUpdate(e){super.willUpdate(e),this.autoUpdate&&e.has("value")&&this.setValue(this.value)}focus(){this._codeEditor?.codemirror&&this._codeEditor?.codemirror.focus()}disableCodeEditorFullscreen(){this.disableFullscreen=!0,this._codeEditor&&(this._codeEditor.disableFullscreen=!0)}render(){return void 0===this._yaml?n.s6:n.qy` ${this.label?n.qy`<p>${this.label}${this.required?" *":""}</p>`:n.s6} <ha-code-editor .value="${this._yaml}" .readOnly="${this.readOnly}" .disableFullscreen="${this.disableFullscreen}" .inDialog="${this.inDialog}" mode="yaml" lint autocomplete-entities autocomplete-icons .error="${!1===this.isValid}" @value-changed="${this._onChange}" @editor-save="${this._onEditorSave}" dir="ltr"></ha-code-editor> ${this.copyClipboard||this.hasExtraActions?n.qy` <div class="card-actions"> ${this.copyClipboard?n.qy` <ha-button appearance="plain" @click="${this._copyYaml}"> ${this._i18n.localize("ui.components.yaml-editor.copy_to_clipboard")} </ha-button> `:n.s6} <slot name="extra-actions"></slot> </div> `:n.s6} `}_onChange(e){let t;e.stopPropagation(),this._yaml=e.detail.value;let i,a=!0,n=null;if(this._yaml)try{t=(0,s.Hh)(this._yaml,{schema:this.yamlSchema})}catch(e){a=!1,n=e,i=`${this._i18n.localize("ui.components.yaml-editor.error",{reason:e.reason})}${e.mark?` (${this._i18n.localize("ui.components.yaml-editor.error_location",{line:e.mark.line+1,column:e.mark.column+1})})`:""}`}else t={};this._codeEditor?.setYamlError(n),this.value=t,this.isValid=a,(0,d.r)(this,"value-changed",{value:t,isValid:a,errorMsg:i})}get yaml(){return this._yaml}get codemirror(){return this._codeEditor?.codemirror}get hasComments(){return this._codeEditor?.hasComments??!1}_onEditorSave(e){(0,d.r)(this,"editor-save"),e.stopPropagation()}async _copyYaml(){this.yaml&&(await(0,l.l)(this.yaml),(0,p.P)(this,{message:this._i18n.localize("ui.common.copied_clipboard")}))}static get styles(){return[c.RF,n.AH`.card-actions{border-radius:var(--actions-border-radius,var(--ha-border-radius-square) var(--ha-border-radius-square) var(--ha-card-border-radius,var(--ha-border-radius-lg)) var(--ha-card-border-radius,var(--ha-border-radius-lg)));border:1px solid var(--divider-color);padding:5px 16px}ha-code-editor{flex-grow:1;min-height:0}`]}constructor(...e){super(...e),this.yamlSchema=s.my,this.isValid=!0,this.autoUpdate=!1,this.readOnly=!1,this.disableFullscreen=!1,this.inDialog=!1,this.required=!1,this.copyClipboard=!1,this.hasExtraActions=!1,this._yaml=""}}(0,a.Cg)([(0,o.MZ)()],m.prototype,"value",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"yamlSchema",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"defaultValue",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"is-valid",type:Boolean})],m.prototype,"isValid",void 0),(0,a.Cg)([(0,o.MZ)()],m.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"auto-update",type:Boolean})],m.prototype,"autoUpdate",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"read-only",type:Boolean})],m.prototype,"readOnly",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,attribute:"disable-fullscreen"})],m.prototype,"disableFullscreen",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,attribute:"in-dialog"})],m.prototype,"inDialog",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"required",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"copy-clipboard",type:Boolean})],m.prototype,"copyClipboard",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"has-extra-actions",type:Boolean})],m.prototype,"hasExtraActions",void 0),(0,a.Cg)([(0,o.wk)()],m.prototype,"_yaml",void 0),(0,a.Cg)([(0,o.wk)(),(0,r.Fg)({context:f.D5,subscribe:!0})],m.prototype,"_i18n",void 0),(0,a.Cg)([(0,o.P)("ha-code-editor")],m.prototype,"_codeEditor",void 0),m=(0,a.Cg)([(0,o.EM)("ha-yaml-editor")],m),t()}catch(e){t(e)}})},700(e,t,i){i.d(t,{y:()=>o});const a=window;"customIconsets"in a||(a.customIconsets={});const s=a.customIconsets,n=window;"customIcons"in n||(n.customIcons={});const o=new Proxy(n.customIcons,{get:(e,t)=>e[t]??(s[t]?{getIcon:s[t]}:void 0)})},90056(e,t,i){i.a(e,async function(e,t){try{i(18111),i(7588),i(33110);var a=i(62826),s=i(5124),n=i(22441),o=i(22786),r=i(69150),d=i(7724),l=e([d]);d=(l.then?(await l)():l)[0];class c extends s.WF{render(){const e=this._processEvents(this.events);return e?s.qy` <assist-render-pipeline-run .hass="${this.hass}" .pipelineRun="${e}" .chatLog="${this.chatLog}"></assist-render-pipeline-run> `:this.events.length?s.qy`<ha-alert alert-type="error">${this.hass.localize("ui.panel.config.voice_assistants.debug.error.showing_run")}</ha-alert> <ha-card> <ha-expansion-panel> <span slot="header">${this.hass.localize("ui.panel.config.voice_assistants.debug.raw")}</span> <pre>${JSON.stringify(this.events,null,2)}</pre> </ha-expansion-panel> </ha-card>`:s.qy`<ha-alert alert-type="warning">${this.hass.localize("ui.panel.config.voice_assistants.debug.no_events")}</ha-alert>`}constructor(...e){super(...e),this._processEvents=(0,o.A)(e=>{let t;return e.forEach(e=>{t=(0,r.QC)(t,e)}),t})}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"events",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"chatLog",void 0),c=(0,a.Cg)([(0,n.EM)("assist-render-pipeline-events")],c),t()}catch(e){t(e)}})},7724(e,t,i){i.a(e,async function(e,t){try{i(74423),i(44114),i(18111),i(22489),i(20116),i(61701);var a=i(62826),s=i(5124),n=i(22441),o=i(20058),r=i(38962),d=i(18350),l=(i(76776),i(11382),i(65829)),c=i(10763),p=i(65063),h=e([r,d,l,c,o]);[r,d,l,c,o]=h.then?(await h)():h;const u=["pipeline","language"],f=["engine"],v=["engine"],g=["engine","language","intent_input"],m=["engine","language","voice","tts_input"],y={ready:0,wake_word:1,stt:2,intent:3,tts:4,done:5,error:6},b=(e,t)=>e.init_options?y[e.init_options.start_stage]<=y[t]&&y[t]<=y[e.init_options.end_stage]:t in e,_=(e,t,i)=>"error"in e&&i===t?s.qy` <ha-alert alert-type="error"> ${e.error.message} (${e.error.code}) </ha-alert> `:"",x=(e,t,i,a="-start")=>{const n=t.events.find(e=>e.type===`${i}`+a),r=t.events.find(e=>e.type===`${i}-end`);if(!n)return"";if(!r)return"error"in t?s.qy`❌`:s.qy` <ha-spinner size="small"></ha-spinner> `;const d=new Date(r.timestamp).getTime()-new Date(n.timestamp).getTime(),l=(0,o.ZV)(d/1e3,e.locale,{maximumFractionDigits:2});return s.qy`${l}s ✅`},w=(e,t,i)=>i.map(i=>{const a=e.localize(`ui.panel.config.voice_assistants.debug.stages.${i}`);return s.qy` <div class="row"> <div>${a}</div> <div>${t[i]}</div> </div> `}),$=(e,t,i)=>{const a={};let n=!1;for(const e in t)i.includes(e)||"done"===e||(n=!0,a[e]=t[e]);return n?s.qy`<ha-expansion-panel class="yaml-expansion"> <span slot="header">${e.localize("ui.panel.config.voice_assistants.debug.raw")}</span> <ha-yaml-editor readOnly="readOnly" autoUpdate .value="${a}"></ha-yaml-editor> </ha-expansion-panel>`:""};class C extends s.WF{get _isPlaying(){return null!=this._audioElement&&!this._audioElement.paused}render(){const e=this.pipelineRun&&["tts","intent","stt","wake_word"].find(e=>e in this.pipelineRun)||"ready";let t;if(this.chatLog)t=this.chatLog.content.filter(this.pipelineRun.finished?e=>"system"===e.role||e.created>=this.pipelineRun.started&&e.created<=this.pipelineRun.finished:e=>"system"===e.role||e.created>=this.pipelineRun.started);else{t=[];const e=(this.pipelineRun.init_options&&"text"in this.pipelineRun.init_options.input?this.pipelineRun.init_options.input.text:void 0)||this.pipelineRun?.stt?.stt_output?.text||this.pipelineRun?.intent?.intent_input;e&&t.push({role:"user",content:e}),this.pipelineRun?.intent?.intent_output?.response?.speech?.plain?.speech&&t.push({role:"assistant",content:this.pipelineRun.intent.intent_output.response.speech.plain.speech})}return s.qy` <ha-card> <div class="card-content"> <div class="row heading"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.run")} </div> <div>${this.pipelineRun.stage}</div> </div> ${w(this.hass,this.pipelineRun.run,u)} ${t.length>0?s.qy` <div class="messages"> ${t.map(e=>"system"===e.role?e.content?s.qy` <ha-expansion-panel class="content-expansion ${e.role}"> <div slot="header">System</div> <pre>${e.content}</pre> </ha-expansion-panel> `:s.s6:"tool_result"===e.role?s.qy` <ha-expansion-panel class="content-expansion ${e.role}"> <div slot="header"> Result for ${e.tool_name} </div> <ha-yaml-editor read-only auto-update .value="${e}"></ha-yaml-editor> </ha-expansion-panel> `:s.qy` ${e.content?s.qy` <div class="${`message ${e.role}`}"> ${e.content} </div> `:s.s6} ${"assistant"===e.role&&e.tool_calls?.length?s.qy` <ha-expansion-panel class="content-expansion assistant"> <span slot="header"> Call ${1===e.tool_calls.length?e.tool_calls[0].tool_name:`${e.tool_calls.length} tools`} </span> <ha-yaml-editor read-only auto-update .value="${e.tool_calls}"></ha-yaml-editor> </ha-expansion-panel> `:s.s6} `)} </div> <div style="clear:both"></div> `:""} </div> </ha-card> ${_(this.pipelineRun,"ready",e)} ${b(this.pipelineRun,"wake_word")?s.qy` <ha-card> <div class="card-content"> <div class="row heading"> <span>${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.wake_word")}</span> ${x(this.hass,this.pipelineRun,"wake_word")} </div> ${this.pipelineRun.wake_word?s.qy` <div class="card-content"> ${w(this.hass,this.pipelineRun.wake_word,f)} ${this.pipelineRun.wake_word.wake_word_output?s.qy`<div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.model")} </div> <div> ${this.pipelineRun.wake_word.wake_word_output.ww_id} </div> </div> <div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.timestamp")} </div> <div> ${this.pipelineRun.wake_word.wake_word_output.timestamp} </div> </div>`:""} ${$(this.hass,this.pipelineRun.wake_word,f)} </div> `:""} </div> </ha-card> `:""} ${_(this.pipelineRun,"wake_word",e)} ${b(this.pipelineRun,"stt")?s.qy` <ha-card> <div class="card-content"> <div class="row heading"> <span>${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.speech_to_text")}</span> ${x(this.hass,this.pipelineRun,"stt","-vad-end")} </div> ${this.pipelineRun.stt?s.qy` <div class="card-content"> ${w(this.hass,this.pipelineRun.stt,v)} <div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.language")} </div> <div>${this.pipelineRun.stt.metadata.language}</div> </div> ${this.pipelineRun.stt.stt_output?s.qy`<div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.output")} </div> <div>${this.pipelineRun.stt.stt_output.text}</div> </div>`:""} ${$(this.hass,this.pipelineRun.stt,v)} </div> `:""} </div> </ha-card> `:""} ${_(this.pipelineRun,"stt",e)} ${b(this.pipelineRun,"intent")?s.qy` <ha-card> <div class="card-content"> <div class="row heading"> <span>${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.natural_language_processing")}</span> ${x(this.hass,this.pipelineRun,"intent")} </div> ${this.pipelineRun.intent?s.qy` <div class="card-content"> ${w(this.hass,this.pipelineRun.intent,g)} ${this.pipelineRun.intent.intent_output?s.qy`<div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.response_type")} </div> <div> ${this.pipelineRun.intent.intent_output.response.response_type} </div> </div> ${"error"===this.pipelineRun.intent.intent_output.response.response_type?s.qy`<div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.error.code")} </div> <div> ${this.pipelineRun.intent.intent_output.response.data.code} </div> </div>`:""}`:""} <div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.prefer_local")} </div> <div> ${this.pipelineRun.intent.prefer_local_intents} </div> </div> <div class="row"> <div> ${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.processed_locally")} </div> <div> ${this.pipelineRun.intent.processed_locally} </div> </div> ${$(this.hass,this.pipelineRun.intent,g)} </div> `:""} </div> </ha-card> `:""} ${_(this.pipelineRun,"intent",e)} ${b(this.pipelineRun,"tts")?s.qy` <ha-card> <div class="card-content"> <div class="row heading"> <span>${this.hass.localize("ui.panel.config.voice_assistants.debug.stages.text_to_speech")}</span> ${x(this.hass,this.pipelineRun,"tts")} </div> ${this.pipelineRun.tts?s.qy` <div class="card-content"> ${w(this.hass,this.pipelineRun.tts,m)} ${$(this.hass,this.pipelineRun.tts,m)} </div> `:""} </div> ${this.pipelineRun?.tts?.tts_output?s.qy` <div class="card-actions"> <ha-button .variant="${this._isPlaying?"danger":"brand"}" @click="${this._isPlaying?this._stopTTS:this._playTTS}"> ${this._isPlaying?this.hass.localize("ui.panel.config.voice_assistants.debug.stop_audio"):this.hass.localize("ui.panel.config.voice_assistants.debug.play_audio")} </ha-button> </div> `:""} </ha-card> `:""} ${_(this.pipelineRun,"tts",e)} <ha-card> <ha-expansion-panel class="yaml-expansion"> <span slot="header">${this.hass.localize("ui.panel.config.voice_assistants.debug.raw")}</span> <ha-yaml-editor read-only auto-update .value="${this.pipelineRun}"></ha-yaml-editor> </ha-expansion-panel> </ha-card> `}_playTTS(){this._stopTTS();const e=this.pipelineRun.tts.tts_output.url;this._audioElement=new Audio(e),this._audioElement.addEventListener("error",()=>{(0,p.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.voice_assistants.debug.error.title"),text:this.hass.localize("ui.panel.config.voice_assistants.debug.error.playing_audio")})}),this._audioElement.addEventListener("play",()=>{this.requestUpdate()}),this._audioElement.addEventListener("ended",()=>{this.requestUpdate()}),this._audioElement.addEventListener("canplaythrough",()=>{this._audioElement.play()})}_stopTTS(){this._audioElement&&(this._audioElement.pause(),this._audioElement.currentTime=0,this._audioElement=void 0,this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this._stopTTS()}}C.styles=s.AH`:host{display:block}ha-alert,ha-card{display:block;margin-bottom:16px}.row{display:flex;justify-content:space-between}.row>div:last-child{text-align:right}.yaml-expansion{padding-left:8px;padding-inline-start:8px;padding-inline-end:initial}.card-content .yaml-expansion{padding-left:0px;padding-inline-start:0px;padding-inline-end:initial;--expansion-panel-summary-padding:0px;--expansion-panel-content-padding:0px}.heading{font-weight:var(--ha-font-weight-medium);margin-bottom:16px}.messages{margin-top:8px}.content-expansion{margin:8px 0;border-radius:var(--ha-border-radius-xl);clear:both;padding:0 8px;--input-fill-color:none;max-width:calc(100% - 24px);--expansion-panel-summary-padding:0px;--expansion-panel-content-padding:0px}.content-expansion [slot=header]{font-weight:var(--ha-font-weight-normal)}.system{background-color:var(--success-color)}.message{padding:8px}.content-expansion,.message{font-size:var(--ha-font-size-l);margin:8px 0;border-radius:var(--ha-border-radius-xl);clear:both}.messages pre{white-space:pre-wrap}.tool_result,.user{margin-left:24px;margin-inline-start:24px;margin-inline-end:initial;float:var(--float-end);border-bottom-right-radius:0px;background-color:var(--light-primary-color);color:var(--text-light-primary-color,var(--primary-text-color));direction:var(--direction)}.tool_result [slot=header]{color:var(--text-light-primary-color,var(--primary-text-color))}.content-expansion div[slot=header],.message.user{text-align:right}.assistant{margin-right:24px;margin-inline-end:24px;margin-inline-start:initial;float:var(--float-start);border-bottom-left-radius:0px;background-color:var(--primary-color);color:var(--text-primary-color);direction:var(--direction)}`,(0,a.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"pipelineRun",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"chatLog",void 0),C=(0,a.Cg)([(0,n.EM)("assist-render-pipeline-run")],C),t()}catch(e){t(e)}})}};