iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 51.8 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[92700],{45434:function(e,t,i){i(62953);var n=i(40445),a=i(5124),o=i(67576);i(42653);let r,l,s,c=e=>e;class u extends a.WF{render(){return(0,a.qy)(r||(r=c` ${0} <ha-code-editor-completion-items .items="${0}"></ha-code-editor-completion-items> `),this.heading?(0,a.qy)(l||(l=c`<div class="heading">${0}</div>`),this.heading):a.s6,this.items)}constructor(...e){super(...e),this.items=[]}}u.styles=(0,a.AH)(s||(s=c`:host{display:block;padding:6px 10px;max-width:360px}.heading{font-weight:var(--ha-font-weight-bold);margin-bottom:4px}`)),(0,n.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"heading",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"items",void 0),u=(0,n.Cg)([(0,o.EM)("ha-code-editor-jinja-arg-hover")],u)},42267:function(e,t,i){i(62953);var n=i(40445),a=i(5124),o=i(67576);i(67094);let r,l,s,c,u,d=e=>e;class f extends a.WF{render(){const e="string"==typeof this.completion.info?this.completion.info:void 0;return(0,a.qy)(r||(r=d` <div class="header"> <div class="sig"> <strong>${0}</strong> ${0} </div> ${0} </div> ${0} `),this.completion.label,this.completion.detail?(0,a.qy)(l||(l=d`<span class="detail">(${0})</span>`),this.completion.detail):a.s6,this.docUrl?(0,a.qy)(s||(s=d`<a class="doc-link" href="${0}" target="_blank" rel="noreferrer" title="${0}"><ha-svg-icon .path="${0}"></ha-svg-icon></a>`),this.docUrl,this.openDocumentation,"M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z"):a.s6,e?(0,a.qy)(c||(c=d`<div class="desc">${0}</div>`),e):a.s6)}constructor(...e){super(...e),this.openDocumentation="Open documentation"}}f.styles=(0,a.AH)(u||(u=d`:host{display:block;padding:6px 10px;max-width:360px;line-height:1.5}.header{display:flex;align-items:center;gap:6px;margin-bottom:4px}.sig{font-family:var(--ha-font-family-code);font-size:.9em;flex:1;min-width:0}.detail{color:var(--secondary-text-color)}.doc-link{flex-shrink:0;display:inline-flex;align-items:center;color:var(--secondary-text-color);opacity:.7;line-height:1}.doc-link:hover{opacity:1;color:var(--primary-color)}.doc-link ha-svg-icon{width:16px;height:16px}.desc{font-size:.9em;color:var(--secondary-text-color)}`)),(0,n.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"completion",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"docUrl",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"openDocumentation",void 0),f=(0,n.Cg)([(0,o.EM)("ha-code-editor-jinja-hover")],f)},61527:function(e,t,i){i.a(e,async function(e,n){try{i.r(t),i.d(t,{EditorState:function(){return s.$t},EditorView:function(){return c.Lz},JINJA_FUNCTION_ARG_TYPES:function(){return v.n1},autocompletion:function(){return f.yU},bracketMatching:function(){return o.SG},closeBrackets:function(){return f.wm},closeBracketsKeymap:function(){return f.Bc},closeBracketsOverride:function(){return x},closePercentBrace:function(){return r.z0},closeSearchPanel:function(){return p.jO},crosshairCursor:function(){return c.HJ},defaultKeymap:function(){return a.pw},drawSelection:function(){return c.VH},dropCursor:function(){return c.A},foldGutter:function(){return o.Lv},haJinjaCompletionSource:function(){return v.RY},haJinjaHoverSource:function(){return v.ff},haSyntaxHighlighting:function(){return B},haTheme:function(){return F},highlightActiveLine:function(){return c.dz},highlightSelectionMatches:function(){return p.gN},highlightingFor:function(){return o.GY},history:function(){return a.b6},historyKeymap:function(){return a.cL},hoverTooltip:function(){return c.Ux},indentationMarkers:function(){return b.h},keymap:function(){return c.w4},langCompartment:function(){return w},langs:function(){return _},lineNumbers:function(){return c.$K},linewrapCompartment:function(){return $},lintGutter:function(){return m.pJ},lintKeymap:function(){return m.$w},openSearchPanel:function(){return p.pi},readonlyCompartment:function(){return k},rectangularSelection:function(){return c.D4},search:function(){return p.$P},searchKeymap:function(){return p.Eo},selectedCompletion:function(){return f.gC},setDiagnostics:function(){return m.LH},syntaxTree:function(){return o.mv},tabKeyBindings:function(){return z},tags:function(){return u._A},tooltips:function(){return c.vX},yamlLintCompartment:function(){return R},yamlScalarHighlightStyle:function(){return D},yamlScalarHighlighter:function(){return N}});i(27495),i(62953);var a=i(9657),o=i(85745),r=i(67844),l=i(1659),s=i(18668),c=i(57644),u=i(53603),d=i(48992),f=i(28099),p=i(5507),m=i(17748),b=i(67715),v=i(21555),h=e([f,p,m,b,v,r,l,a,c,o]);[f,p,m,b,v,r,l,a,c,o]=h.then?(await h)():h;const y=(0,r.Rt)({base:(0,l.oQ)()}),_={jinja2:y,yaml:y},x=s.Nb.highest(s.$t.languageData.of(()=>[{closeBrackets:{brackets:["(","[","{","'",'"']}}])),w=new s.xx,k=new s.xx,$=new s.xx,R=new s.xx,A=c.NZ.mark({class:"yaml-bool"}),C=c.NZ.mark({class:"yaml-number"}),T=c.NZ.mark({class:"yaml-null"}),S=c.NZ.mark({class:"yaml-string"}),E=/^(?:true|True|TRUE|false|False|FALSE|yes|Yes|YES|no|No|NO|on|On|ON|off|Off|OFF)$/,I=/^(?:~|null|Null|NULL)$/,j=/^(?:[+-]?(?:0|[1-9][0-9]*)(?:_[0-9]+)*|0o[0-7]+|0x[0-9a-fA-F]+)$/,M=/^(?:[+-]?(?:[0-9][0-9_]*)?\.[0-9.]*(?:[eE][+-]?[0-9]+)?|[+-]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;function q(e){const t=new s.vB,{doc:i}=e.state,n=(0,o.mv)(e.state);for(const{from:a,to:o}of e.visibleRanges)n.iterate({from:a,to:o,enter(e){var n;if("Template"===e.name||"Text"===e.name){const n=e.node.tree,r=n?n.prop(d.uY.mounted):null;if(r){const n=e.from,l=Math.max(a,e.from)-n,s=Math.min(o,e.to)-n;r.tree.iterate({from:l,to:s,enter(e){var a;if("Literal"!==e.name)return;if("Key"===(null===(a=e.node.parent)||void 0===a?void 0:a.name))return;const o=e.from+n,r=e.to+n,l=i.sliceString(o,r);let s;s=E.test(l)?A:I.test(l)?T:j.test(l)||M.test(l)?C:S,t.add(o,r,s)}})}return!1}if("Literal"!==e.name)return;if("Key"===(null===(n=e.node.parent)||void 0===n?void 0:n.name))return;const r=i.sliceString(e.from,e.to);let l;l=E.test(r)?A:I.test(r)?T:j.test(r)||M.test(r)?C:S,t.add(e.from,e.to,l)}});return t.finish()}const N=c.Z9.fromClass(class{update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=q(e.view))}constructor(e){this.decorations=q(e)}},{decorations:e=>e.decorations}),D=c.Lz.baseTheme({".yaml-bool":{color:"var(--codemirror-atom, #F90)"},".yaml-null":{color:"var(--codemirror-atom, #F90)"},".yaml-number":{color:"var(--codemirror-number, #ca7841)"},".yaml-string":{color:"var(--codemirror-string, #07a)"}}),z=[{key:"Tab",run:a.UY},{key:"Shift-Tab",run:a.Mg}],F=c.Lz.theme({"&":{color:"var(--primary-text-color)",backgroundColor:"var(--code-editor-background-color, var(--card-background-color))",borderRadius:"var(--mdc-shape-small, 4px) var(--mdc-shape-small, 4px) 0px 0px",caretColor:"var(--secondary-text-color)",height:"var(--code-mirror-height, auto)",maxHeight:"var(--code-mirror-max-height, unset)"},"&.cm-editor":{"--indent-marker-active-bg-color":"var(--divider-color)"},"&.cm-editor.cm-focused":{outline:"none"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--primary-color)"},".cm-dropCursor":{borderLeftColor:"var(--secondary-text-color)"},".cm-selectionBackground, ::selection":{backgroundColor:"rgba(var(--rgb-primary-color), 0.1)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{backgroundColor:"rgba(var(--rgb-primary-color), 0.2)"},".cm-activeLine":{backgroundColor:"rgba(var(--rgb-secondary-text-color), 0.1)"},".cm-scroller":{outline:"none"},".cm-content":{caretColor:"var(--secondary-text-color)",paddingTop:"16px",paddingBottom:"16px"},".cm-panels":{backgroundColor:"var(--primary-background-color)",color:"var(--primary-text-color)"},".cm-panels.top":{borderBottom:"1px solid var(--divider-color)"},".cm-panels.bottom":{borderTop:"1px solid var(--divider-color)"},".cm-button":{border:"1px solid var(--primary-color)",padding:"0px 16px",textTransform:"uppercase",margin:"4px",background:"none",color:"var(--primary-color)",fontFamily:"var(--mdc-typography-button-font-family, var(--mdc-typography-font-family, var(--ha-font-family-body)))",fontSize:"var(--mdc-typography-button-font-size, 0.875rem)",height:"36px",fontWeight:"var(--mdc-typography-button-font-weight, 500)",borderRadius:"4px",letterSpacing:"var(--mdc-typography-button-letter-spacing, 0.0892857em)"},".cm-textfield":{padding:"4px 0px 5px",borderRadius:"0",fontSize:"16px",color:"var(--primary-text-color)",border:"0",background:"none",fontFamily:"Roboto",borderBottom:"1px solid var(--secondary-text-color)",margin:"4px 4px 0","& ::placeholder":{color:"var(--secondary-text-color)"},"&:focus":{outline:"none",borderBottom:"2px solid var(--primary-color)",paddingBottom:"4px"}},".cm-tooltip":{color:"var(--primary-text-color)",backgroundColor:"var(--code-editor-background-color, var(--card-background-color))",border:"1px solid var(--divider-color)",borderRadius:"var(--mdc-shape-medium, 4px)",maxWidth:"min(420px, calc(var(--safe-width) - var(--ha-space-8)))",boxSizing:"border-box",boxShadow:"0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)"},".cm-tooltip.cm-tooltip-autocomplete":{maxWidth:"min(420px, calc(var(--safe-width) - var(--ha-space-8)), calc(100% - var(--ha-space-2)))"},".cm-tooltip-autocomplete > ul":{maxWidth:"100%",boxSizing:"border-box"},"& .cm-tooltip.cm-tooltip-autocomplete > ul > li":{padding:"4px 8px"},"& .cm-tooltip-autocomplete ul li[aria-selected]":{background:"var(--primary-color)",color:"var(--text-primary-color)"},".cm-completionIcon":{display:"none"},".cm-completionDetail":{fontFamily:"Roboto",color:"var(--secondary-text-color)"},"li[aria-selected] .cm-completionDetail":{color:"var(--text-primary-color)"},".cm-selectionMatch":{backgroundColor:"rgba(var(--rgb-primary-color), 0.1)"},".cm-searchMatch":{backgroundColor:"rgba(var(--rgb-accent-color), .2)",outline:"1px solid rgba(var(--rgb-accent-color), .4)"},".cm-searchMatch.selected":{backgroundColor:"rgba(var(--rgb-accent-color), .4)",outline:"1px solid var(--accent-color)"},".cm-gutters":{backgroundColor:"var(--code-editor-gutter-color, var(--secondary-background-color, whitesmoke))",color:"var(--secondary-text-color)",border:"none",borderRight:"1px solid var(--secondary-text-color)",paddingRight:"1px"},"&.cm-focused .cm-gutters":{borderRight:"2px solid var(--primary-color)",paddingRight:"0"},".cm-gutterElement.lineNumber":{color:"inherit"},".cm-lint-marker-error":{color:"var(--error-color)"},".cm-lint-marker-warning":{color:"var(--warning-color)"},".cm-lint-marker-info":{color:"var(--info-color, var(--primary-color))"},".cm-diagnostic":{fontFamily:"var(--mdc-typography-font-family, var(--ha-font-family-body))"},".cm-diagnostic.cm-diagnostic-error":{borderLeft:"3px solid var(--error-color)"},".cm-diagnostic.cm-diagnostic-warning":{borderLeft:"3px solid var(--warning-color)"}}),L=o.cr.define([{tag:u._A.keyword,color:"var(--codemirror-keyword, #6262FF)"},{tag:[u._A.name,u._A.deleted,u._A.character,u._A.propertyName,u._A.macroName],color:"var(--codemirror-property, #905)"},{tag:[u._A.function(u._A.variableName),u._A.labelName],color:"var(--codemirror-variable, #07a)"},{tag:[u._A.color,u._A.constant(u._A.name),u._A.standard(u._A.name)],color:"var(--codemirror-qualifier, #690)"},{tag:[u._A.definition(u._A.name),u._A.separator],color:"var(--codemirror-def, #8DA6CE)"},{tag:[u._A.typeName,u._A.className,u._A.number,u._A.changed,u._A.annotation,u._A.modifier,u._A.self,u._A.namespace],color:"var(--codemirror-number, #ca7841)"},{tag:[u._A.operator,u._A.operatorKeyword,u._A.url,u._A.escape,u._A.regexp,u._A.link,u._A.special(u._A.string)],color:"var(--codemirror-operator, #cda869)"},{tag:u._A.comment,color:"var(--codemirror-comment, #777)"},{tag:u._A.meta,color:"var(--codemirror-meta, var(--primary-text-color))"},{tag:u._A.strong,fontWeight:"bold"},{tag:u._A.emphasis,fontStyle:"italic"},{tag:u._A.link,color:"var(--primary-color)",textDecoration:"underline"},{tag:u._A.heading,fontWeight:"bold"},{tag:u._A.atom,color:"var(--codemirror-atom, #F90)"},{tag:u._A.bool,color:"var(--codemirror-atom, #F90)"},{tag:u._A.special(u._A.variableName),color:"var(--codemirror-variable-2, #690)"},{tag:u._A.processingInstruction,color:"var(--secondary-text-color)"},{tag:u._A.string,color:"var(--codemirror-string, #07a)"},{tag:u._A.inserted,color:"var(--codemirror-string2, #07a)"},{tag:u._A.invalid,color:"var(--error-color)"},{tag:[u._A.squareBracket,u._A.brace,u._A.punctuation],color:"var(--codemirror-def, #8DA6CE)"}]),B=(0,o.y9)(L);n()}catch(g){n(g)}})},21555:function(e,t,i){i.a(e,async function(e,n){try{i.d(t,{RY:function(){return A},ff:function(){return N},n1:function(){return p}});i(89463),i(78350),i(44114),i(30237),i(18111),i(7588),i(61701),i(45367),i(92731),i(27495),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(42762),i(62953);var a=i(28099),o=i(85745),r=(i(42267),i(45434),e([a,o]));[a,o]=r.then?(await r)():r;const s=[{label:"raw",type:"keyword",info:"Marks a block whose content is output as-is, without Jinja2 processing."},{label:"endraw",type:"keyword",info:"Ends a {% raw %} block."},{label:"filter",type:"keyword",detail:"filter_name",info:"Applies a filter to the content of the block."},{label:"endfilter",type:"keyword",info:"Ends a {% filter %} block."},{label:"trans",type:"keyword",info:"Marks a block for translation."},{label:"pluralize",type:"keyword",info:"Provides plural and singular forms inside a {% trans %} block."},{label:"endtrans",type:"keyword",info:"Ends a {% trans %} block."},{label:"with",type:"keyword",info:"Creates a new inner scope where variables can be set."},{label:"endwith",type:"keyword",info:"Ends a {% with %} block."},{label:"autoescape",type:"keyword",detail:"true|false",info:"Enables or disables HTML autoescaping for the block."},{label:"endautoescape",type:"keyword",info:"Ends an {% autoescape %} block."},{label:"if",type:"keyword",detail:"condition",info:"Renders the block only when the condition is true."},{label:"elif",type:"keyword",detail:"condition",info:"Alternative condition in an {% if %} block."},{label:"else",type:"keyword",info:"Fallback branch in an {% if %} or {% for %} block."},{label:"endif",type:"keyword",info:"Ends an {% if %} block."},{label:"for",type:"keyword",detail:"variable in iterable",info:"Iterates over a list or other iterable. Provides loop.index, loop.first, loop.last, etc."},{label:"endfor",type:"keyword",info:"Ends a {% for %} block."},{label:"call",type:"keyword",detail:"macro_name(args)",info:"Calls a macro and passes the call block's content as caller()."},{label:"endcall",type:"keyword",info:"Ends a {% call %} block."},{label:"block",type:"keyword",detail:"block_name",info:"Defines a named block that child templates can override."},{label:"endblock",type:"keyword",info:"Ends a {% block %} definition."},{label:"set",type:"keyword",detail:"variable = value",info:"Assigns a value to a variable in the current scope."},{label:"endset",type:"keyword",info:"Ends a block {% set %} that captures rendered content."},{label:"macro",type:"keyword",detail:"name(args)",info:"Defines a reusable template function (macro)."},{label:"endmacro",type:"keyword",info:"Ends a {% macro %} definition."},{label:"import",type:"keyword",detail:"template as name",info:"Imports macros from another template."},{label:"include",type:"keyword",detail:"template",info:"Inserts another template inline at this point."},{label:"break",type:"keyword",info:"Exits the current {% for %} loop early."},{label:"continue",type:"keyword",info:"Skips the rest of the current loop iteration and continues with the next."},{label:"debug",type:"keyword",info:"Dumps debug information about the current context."},{label:"do",type:"keyword",detail:"expression",info:"Evaluates an expression without printing its result."},{label:"extends",type:"keyword",detail:"template",info:"Makes the current template extend a parent template."}],c=[{label:"abs",type:"function",info:"Returns the absolute value of a number."},{label:"attr",type:"function",detail:"name",info:"Returns an attribute of an object. Similar to getattr."},{label:"batch",type:"function",detail:"linecount, fill_with?",info:"Collects items into batches of a given size, optionally filled with a placeholder."},{label:"capitalize",type:"function",info:"Capitalizes the first character of a string and lowercases the rest."},{label:"center",type:"function",detail:"width=80",info:"Centers a string in a field of a given width."},{label:"count",type:"function",info:"Returns the number of items in a sequence or mapping. Alias for length."},{label:"default",type:"function",detail:"value, boolean=false",info:"Returns the value if it is defined and not empty, otherwise returns the provided default."},{label:"d",type:"function",detail:"value, boolean=false",info:"Shorthand alias for the default filter."},{label:"dictsort",type:"function",detail:"case_sensitive=false, by='key', reverse=false",info:"Sorts a dictionary by key or value and returns a list of (key, value) pairs."},{label:"e",type:"function",info:"Escapes HTML special characters. Shorthand alias for escape."},{label:"escape",type:"function",info:"Escapes HTML special characters (<, >, &, ', \") in a string."},{label:"filesizeformat",type:"function",detail:"binary=false",info:"Formats a byte count into a human-readable file size like '1.2 MB'."},{label:"first",type:"function",info:"Returns the first item of a sequence."},{label:"float",type:"function",detail:"default=0.0",info:"Converts a value to a floating-point number."},{label:"forceescape",type:"function",info:"Enforces HTML escaping even on values already marked safe."},{label:"format",type:"function",detail:"*args, **kwargs",info:"Applies Python's % string formatting using the given arguments."},{label:"groupby",type:"function",detail:"attribute, default?, case_sensitive=false",info:"Groups a sequence of objects by a common attribute."},{label:"indent",type:"function",detail:"width=4, first=false, blank=false",info:"Indents all lines of a string by the given number of spaces."},{label:"int",type:"function",detail:"default=0, base=10",info:"Converts a value to an integer."},{label:"items",type:"function",info:"Returns an iterable of (key, value) pairs for a dictionary."},{label:"join",type:"function",detail:"d='', attribute?",info:"Joins elements of a sequence into a string with an optional separator."},{label:"last",type:"function",info:"Returns the last item of a sequence."},{label:"length",type:"function",info:"Returns the number of items in a sequence or mapping."},{label:"list",type:"function",info:"Converts a value to a list. Useful to iterate over strings character by character."},{label:"tuple",type:"function",info:"Converts an iterable to a tuple. Similar to list, but the result is immutable."},{label:"lower",type:"function",info:"Converts a string to lowercase."},{label:"map",type:"function",detail:"attribute?, default?",info:"Applies a filter or looks up an attribute on each item of a sequence."},{label:"max",type:"function",detail:"attribute?",info:"Returns the largest item in a sequence."},{label:"min",type:"function",detail:"attribute?",info:"Returns the smallest item in a sequence."},{label:"pprint",type:"function",info:"Pretty-prints a variable for debugging purposes."},{label:"random",type:"function",info:"Returns a random item from a sequence."},{label:"reject",type:"function",detail:"test, *args",info:"Filters a sequence by rejecting items for which a test returns true."},{label:"rejectattr",type:"function",detail:"attribute, test?, *args",info:"Filters a sequence of objects by rejecting those where an attribute test passes."},{label:"replace",type:"function",detail:"old, new, count?",info:"Replaces occurrences of a substring. Optionally limits the number of replacements."},{label:"reverse",type:"function",info:"Reverses a sequence or string."},{label:"round",type:"function",detail:"precision=0, method='common'",info:"Rounds a number to a given precision. Method can be 'common', 'ceil', or 'floor'."},{label:"safe",type:"function",info:"Marks a string as safe HTML so it is not escaped on output."},{label:"select",type:"function",detail:"test, *args",info:"Filters a sequence to include only items for which a test returns true."},{label:"selectattr",type:"function",detail:"attribute, test?, *args",info:"Filters a sequence of objects to include only those where an attribute test passes."},{label:"slice",type:"function",detail:"slices, fill_with?",info:"Slices a sequence into a given number of parts."},{label:"sort",type:"function",detail:"reverse=false, case_sensitive=false, attribute?",info:"Sorts a sequence. Optionally in reverse, case-sensitive, or by an attribute."},{label:"string",type:"function",info:"Converts an object to a string."},{label:"striptags",type:"function",info:"Strips HTML/XML tags from a string and normalizes whitespace."},{label:"sum",type:"function",detail:"attribute?, start=0",info:"Returns the sum of a sequence of numbers, optionally summing an attribute."},{label:"title",type:"function",info:"Converts a string to title case."},{label:"tojson",type:"function",detail:"indent?",info:"Serializes an object to a JSON string. Safe to use inside HTML."},{label:"trim",type:"function",detail:"chars?",info:"Strips leading and trailing whitespace (or specified characters) from a string."},{label:"truncate",type:"function",detail:"length=255, killwords=false, end='...', leeway?",info:"Truncates a string to the given length, appending an ellipsis."},{label:"unique",type:"function",detail:"case_sensitive=false, attribute?",info:"Returns a sequence with duplicate items removed."},{label:"upper",type:"function",info:"Converts a string to uppercase."},{label:"urlencode",type:"function",info:"URL-encodes a string or a mapping."},{label:"urlize",type:"function",detail:"trim_url_limit?, nofollow?, target?, rel?, extra_schemes?",info:"Converts URLs in plain text into clickable HTML links."},{label:"wordcount",type:"function",info:"Counts the number of words in a string."},{label:"wordwrap",type:"function",detail:"width=79, break_long_words=true, wrapstring?",info:"Wraps words in a string at the given column width."},{label:"xmlattr",type:"function",detail:"autospace=true",info:"Builds an HTML attribute string from a dictionary of values."}],u=[{label:"boolean",type:"function",info:"Test: returns true if the value is a boolean."},{label:"callable",type:"function",info:"Test: returns true if the value is callable (a function or macro)."},{label:"defined",type:"function",info:"Test: returns true if the variable is defined."},{label:"divisibleby",type:"function",detail:"number",info:"Test: returns true if the value is divisible by the given number."},{label:"eq",type:"function",detail:"other",info:"Test: returns true if the value equals other. Equivalent to ==."},{label:"escaped",type:"function",info:"Test: returns true if the value has been marked as safe (escaped)."},{label:"even",type:"function",info:"Test: returns true if the value is an even number."},{label:"filter",type:"function",detail:"name",info:"Test: returns true if a filter with the given name exists."},{label:"float",type:"function",info:"Test: returns true if the value is a float."},{label:"ge",type:"function",detail:"other",info:"Test: returns true if the value is greater than or equal to other."},{label:"gt",type:"function",detail:"other",info:"Test: returns true if the value is greater than other."},{label:"in",type:"function",detail:"sequence",info:"Test: returns true if the value is contained in the given sequence."},{label:"integer",type:"function",info:"Test: returns true if the value is an integer."},{label:"iterable",type:"function",info:"Test: returns true if the value can be iterated over."},{label:"le",type:"function",detail:"other",info:"Test: returns true if the value is less than or equal to other."},{label:"lower",type:"function",info:"Test: returns true if the value is a lowercase string."},{label:"lt",type:"function",detail:"other",info:"Test: returns true if the value is less than other."},{label:"mapping",type:"function",info:"Test: returns true if the value is a mapping (dictionary)."},{label:"ne",type:"function",detail:"other",info:"Test: returns true if the value is not equal to other."},{label:"none",type:"function",info:"Test: returns true if the value is None."},{label:"number",type:"function",info:"Test: returns true if the value is a number."},{label:"odd",type:"function",info:"Test: returns true if the value is an odd number."},{label:"sameas",type:"function",detail:"other",info:"Test: returns true if the value is the same object as other (identity check)."},{label:"sequence",type:"function",info:"Test: returns true if the value is a sequence (list, string, etc.)."},{label:"string",type:"function",info:"Test: returns true if the value is a string."},{label:"test",type:"function",detail:"name",info:"Test: returns true if a test with the given name exists."},{label:"undefined",type:"function",info:"Test: returns true if the variable is undefined."},{label:"upper",type:"function",info:"Test: returns true if the value is an uppercase string."},{label:"range",type:"function",detail:"start, stop?, step?",info:"Returns a list of numbers from start to stop (exclusive), similar to Python's range()."},{label:"lipsum",type:"function",detail:"n=5, html=true, min=20, max=100",info:"Generates n paragraphs of lorem ipsum placeholder text."},{label:"dict",type:"function",detail:"**kwargs",info:"Creates a dictionary from keyword arguments. Useful when key names are not valid identifiers."},{label:"cycler",type:"function",detail:"*items",info:"Creates an object that cycles through a sequence of values. Call .next() to advance, .current for the current value, .reset() to restart."},{label:"joiner",type:"function",detail:"sep=', '",info:"Returns an empty string the first time it is called, then the separator on subsequent calls. Useful for joining in loops."},{label:"namespace",type:"function",detail:"**kwargs",info:"Creates an object that allows variable assignment across scopes inside a loop."},{label:"loop",type:"variable",info:"Special variable inside a {% for %} block. Provides loop.index, loop.index0, loop.first, loop.last, loop.length, loop.depth, etc."},{label:"super",type:"function",info:"Renders the contents of the parent block inside a {% block %} override."},{label:"self",type:"variable",info:"Reference to the current template, allowing access to its block contents."},{label:"true",type:"keyword",info:"Boolean true literal."},{label:"false",type:"keyword",info:"Boolean false literal."},{label:"varargs",type:"variable",info:"Inside a macro, holds extra positional arguments not explicitly declared."},{label:"kwargs",type:"variable",info:"Inside a macro, holds extra keyword arguments not explicitly declared."},{label:"caller",type:"function",info:"Inside a macro called via {% call %}, renders the body of the call block."},{label:"name",type:"variable",info:"Inside a macro, holds the name of the macro itself."},{label:"arguments",type:"variable",info:"Inside a macro, holds the declared argument names."},{label:"catch_kwargs",type:"variable",info:"Inside a macro, indicates whether the macro accepts extra keyword arguments via kwargs."},{label:"catch_varargs",type:"variable",info:"Inside a macro, indicates whether the macro accepts extra positional arguments via varargs."}],d=[{snippet:'states("${entity_id}")',detail:"entity_id, rounded?, with_unit?",info:"Returns the state of an entity as a string."},{snippet:'is_state("${entity_id}", "${value}")',detail:"entity_id, value",info:"Returns true if the entity state matches the given value (or one of the values in a list)."},{snippet:'state_attr("${entity_id}", "${attribute}")',detail:"entity_id, attribute",info:"Returns the value of the given attribute for the entity, or None if it doesn't exist."},{snippet:'is_state_attr("${entity_id}", "${attribute}", ${value})',detail:"entity_id, attribute, value",info:"Returns true if the entity attribute matches the given value."},{snippet:'state_attr_translated("${entity_id}", "${attribute}")',detail:"entity_id, attribute",info:"Returns the translated value of the given attribute for the entity."},{snippet:'state_translated("${entity_id}")',detail:"entity_id",info:"Returns the translated state of an entity."},{snippet:'expand("${entity_id}")',detail:"entity_id, ...",info:"Expands groups and returns a list of all entities in the group and their states."},{snippet:'area_id("${entity_id_or_name}")',detail:"entity_id or area name",info:"Returns the area ID for a given entity ID or area name."},{snippet:'area_name("${area_id_or_entity}")',detail:"area_id or entity_id",info:"Returns the area name for a given area ID or entity ID."},{snippet:'area_entities("${area_id_or_name}")',detail:"area_id or area name",info:"Returns a list of entity IDs that belong to the given area."},{snippet:'area_devices("${area_id_or_name}")',detail:"area_id or area name",info:"Returns a list of device IDs that belong to the given area."},{snippet:'device_id("${entity_id}")',detail:"entity_id",info:"Returns the device ID for the given entity ID."},{snippet:'device_name("${device_id_or_entity}")',detail:"device_id or entity_id",info:"Returns the device name for the given device ID or entity ID."},{snippet:'device_attr("${device_id_or_entity}", "${attribute}")',detail:"device_id or entity_id, attribute",info:"Returns the value of the given attribute for the device."},{snippet:'device_entities("${device_id}")',detail:"device_id",info:"Returns a list of entity IDs for the given device."},{snippet:'entity_name("${entity_id}")',detail:"entity_id",info:"Returns the name of the entity."},{snippet:'config_entry_id("${entity_id}")',detail:"entity_id",info:"Returns the config entry ID associated with the entity."},{snippet:'config_entry_attr("${entity_id}", "${attribute}")',detail:"entity_id, attribute",info:"Returns the value of the given config entry attribute for the entity."},{snippet:'integration_entities("${integration}")',detail:"integration",info:"Returns a list of entity IDs belonging to the given integration."},{snippet:'floor_id("${area_id_or_name}")',detail:"area_id or area name",info:"Returns the floor ID for a given area."},{snippet:'floor_name("${floor_id}")',detail:"floor_id",info:"Returns the floor name for the given floor ID."},{snippet:'floor_areas("${floor_id}")',detail:"floor_id",info:"Returns a list of area IDs that belong to the given floor."},{snippet:'floor_entities("${floor_id}")',detail:"floor_id",info:"Returns a list of entity IDs that belong to the given floor."},{snippet:'label_id("${label_name}")',detail:"label name",info:"Returns the label ID for the given label name."},{snippet:'label_name("${label_id}")',detail:"label_id",info:"Returns the label name for the given label ID."},{snippet:'label_description("${label_id}")',detail:"label_id",info:"Returns the description of the given label."},{snippet:'label_areas("${label_id}")',detail:"label_id",info:"Returns a list of area IDs that have the given label."},{snippet:'label_devices("${label_id}")',detail:"label_id",info:"Returns a list of device IDs that have the given label."},{snippet:'label_entities("${label_id}")',detail:"label_id",info:"Returns a list of entity IDs that have the given label."},{snippet:"now()",detail:"",info:"Returns the current local datetime."},{snippet:"utcnow()",detail:"",info:"Returns the current UTC datetime."},{snippet:'today_at("${time_str}")',detail:"time_str",info:'Returns a datetime object for the given time string (e.g. "08:00") today in local time.'},{snippet:"as_datetime(${value})",detail:"value",info:"Converts a timestamp or string to a datetime object."},{snippet:"as_local(${datetime})",detail:"datetime",info:"Converts a UTC datetime to the local timezone."},{snippet:'as_timedelta("${string}")',detail:"string",info:"Parses an ISO 8601 duration string into a timedelta object."},{snippet:"as_timestamp(${value})",detail:"value, default?",info:"Converts a datetime or string to a Unix timestamp."},{snippet:'strptime("${string}", "${format}")',detail:"string, format, default?",info:"Parses a date/time string using the given format."},{snippet:"timedelta(${days})",detail:"days?, seconds?, microseconds?, milliseconds?, minutes?, hours?, weeks?",info:"Creates a timedelta object."},{snippet:'timestamp_custom(${timestamp}, "${format}")',detail:"timestamp, format, local_time?",info:"Formats a Unix timestamp using a custom strftime format string."},{snippet:"timestamp_local(${timestamp})",detail:"timestamp, default?",info:"Converts a Unix timestamp to a local time string."},{snippet:"timestamp_utc(${timestamp})",detail:"timestamp, default?",info:"Converts a Unix timestamp to a UTC time string."},{snippet:"time_since(${datetime})",detail:"datetime",info:"Returns a human-readable string of how long ago the datetime was."},{snippet:"time_until(${datetime})",detail:"datetime",info:"Returns a human-readable string of how long until the datetime."},{snippet:"log(${value})",detail:"value, base?",info:"Returns the logarithm of value. Defaults to natural log; optionally specify base."},{snippet:"sin(${value})",detail:"value",info:"Returns the sine of value (in radians)."},{snippet:"cos(${value})",detail:"value",info:"Returns the cosine of value (in radians)."},{snippet:"tan(${value})",detail:"value",info:"Returns the tangent of value (in radians)."},{snippet:"asin(${value})",detail:"value",info:"Returns the arcsine of value in radians."},{snippet:"acos(${value})",detail:"value",info:"Returns the arccosine of value in radians."},{snippet:"atan(${value})",detail:"value",info:"Returns the arctangent of value in radians."},{snippet:"atan2(${y}, ${x})",detail:"y, x",info:"Returns atan(y/x) in radians."},{snippet:"sqrt(${value})",detail:"value",info:"Returns the square root of value."},{snippet:"average(${value}, ${default})",detail:"value, ...",info:"Returns the average of a list of numbers."},{snippet:"median(${value})",detail:"value, ...",info:"Returns the median of a list of numbers."},{snippet:"statistical_mode(${value})",detail:"value, ...",info:"Returns the statistical mode (most common value) of a list."},{snippet:"clamp(${value}, ${min}, ${max})",detail:"value, min, max",info:"Clamps value between min and max."},{snippet:"remap(${value}, ${in_min}, ${in_max}, ${out_min}, ${out_max})",detail:"value, in_min, in_max, out_min, out_max",info:"Re-maps a number from one range to another."},{snippet:"wrap(${value}, ${min}, ${max})",detail:"value, min, max",info:"Wraps value into the range [min, max)."},{snippet:"bitwise_and(${value}, ${mask})",detail:"value, mask",info:"Bitwise AND of two integers."},{snippet:"bitwise_or(${value}, ${mask})",detail:"value, mask",info:"Bitwise OR of two integers."},{snippet:"bitwise_xor(${value}, ${mask})",detail:"value, mask",info:"Bitwise XOR of two integers."},{snippet:"int(${value})",detail:"value, default?",info:"Converts value to integer. Returns default (0) on error."},{snippet:"float(${value})",detail:"value, default?",info:"Converts value to float. Returns default (0.0) on error."},{snippet:"bool(${value})",detail:"value, default?",info:"Converts value to boolean. Returns default on error."},{snippet:"is_number(${value})",detail:"value",info:"Returns true if value can be interpreted as a number."},{snippet:"typeof(${value})",detail:"value",info:"Returns a string representing the type of value."},{snippet:'regex_search("${pattern}", "${string}")',detail:"pattern, string, ignorecase?",info:"Returns true if pattern matches anywhere in string."},{snippet:'regex_match("${pattern}", "${string}")',detail:"pattern, string, ignorecase?",info:"Returns true if pattern matches at the start of string."},{snippet:'regex_replace("${pattern}", "${replacement}", "${string}")',detail:"pattern, replacement, string, ignorecase?",info:"Replaces all matches of pattern in string with replacement."},{snippet:'regex_findall("${pattern}", "${string}")',detail:"pattern, string, ignorecase?",info:"Returns a list of all non-overlapping matches of pattern in string."},{snippet:'regex_findall_index("${pattern}", "${string}", ${index})',detail:"pattern, string, index, ignorecase?",info:"Returns the match at the given group index from regex_findall."},{snippet:"combine(${dict1}, ${dict2})",detail:"dict, ..., recursive?, list_merge?",info:"Merges two or more dictionaries."},{snippet:"flatten(${list})",detail:"list, levels?",info:"Flattens a nested list."},{snippet:"intersect(${list1}, ${list2})",detail:"list1, list2",info:"Returns the intersection of two lists."},{snippet:"union(${list1}, ${list2})",detail:"list1, list2",info:"Returns the union of two lists."},{snippet:"difference(${list1}, ${list2})",detail:"list1, list2",info:"Returns elements in list1 that are not in list2."},{snippet:"symmetric_difference(${list1}, ${list2})",detail:"list1, list2",info:"Returns elements in either list but not both."},{snippet:'from_json("${string}")',detail:"string",info:"Parses a JSON string into a Python object."},{snippet:"to_json(${value})",detail:"value, ensure_ascii?, sort_keys?, indent?",info:"Serializes a value to a JSON string."},{snippet:"merge_response(${response1}, ${response2})",detail:"response, ...",info:"Merges multiple service response dictionaries."},{snippet:"shuffle(${list})",detail:"list",info:"Returns a copy of the list in a random order."},{snippet:'base64_encode("${string}")',detail:"string",info:"Encodes a string using Base64."},{snippet:'base64_decode("${string}")',detail:"string",info:"Decodes a Base64-encoded string."},{snippet:'from_hex("${string}")',detail:"string",info:"Converts a hex string to an integer."},{snippet:'md5("${string}")',detail:"string",info:"Returns the MD5 hash of a string."},{snippet:'sha1("${string}")',detail:"string",info:"Returns the SHA-1 hash of a string."},{snippet:'sha256("${string}")',detail:"string",info:"Returns the SHA-256 hash of a string."},{snippet:'sha512("${string}")',detail:"string",info:"Returns the SHA-512 hash of a string."},{snippet:'pack("${format}", ${value})',detail:"format, value, ...",info:"Packs values into a bytes object using struct.pack format."},{snippet:'unpack("${format}", ${bytes})',detail:"format, bytes, offset?",info:"Unpacks values from a bytes object using struct.unpack format."},{snippet:"iif(${condition}, ${if_true}, ${if_false})",detail:"condition, if_true, if_false?",info:"Inline if: returns if_true when condition is truthy, otherwise if_false."},{snippet:"as_function(${value})",detail:"value",info:"Converts a value to a callable template function."},{snippet:"apply(${function}, ${args})",detail:"function, args?, kwargs?",info:"Calls the given function with the provided arguments."},{snippet:"zip(${list1}, ${list2})",detail:"list1, list2, ...",info:"Returns a list of tuples pairing elements from each list."},{snippet:'ord("${character}")',detail:"character",info:"Returns the Unicode code point for the given character."},{snippet:"closest(${lat}, ${lon}, ${entities})",detail:"lat, lon, entities",info:"Returns the closest entity to the given coordinates."},{snippet:"distance(${lat1}, ${lon1}, ${lat2}, ${lon2})",detail:"lat1, lon1, lat2, lon2",info:"Returns the distance in kilometers between two points."}],f={"${entity_id}":"entity_id","${entity_id_or_name}":"entity_id","${area_id_or_name}":"area_id","${area_id_or_entity}":"area_id","${device_id}":"device_id","${device_id_or_entity}":"device_id","${floor_id}":"floor_id","${label_id}":"label_id","${integration}":"integration","${attribute}":"attribute"},p=new Map(d.flatMap(e=>{const t=e.snippet.split("(")[0],i=e.snippet.slice(e.snippet.indexOf("(")+1,e.snippet.lastIndexOf(")")).split(",").map(e=>e.trim()),n=new Map;return i.forEach((e,t)=>{const i=e.match(/\$\{[^}]+\}/);if(i){const e=f[i[0]];e&&n.set(t,e)}}),n.size>0?[[t,n]]:[]})),m=d.map(e=>(0,a.Gw)(e.snippet,{label:e.snippet.split("(")[0],detail:e.detail,info:e.info,type:"function"})),b=[{label:"areas",type:"variable",info:"A list of all area IDs in ioBroker."},{label:"floors",type:"variable",info:"A list of all floor IDs in ioBroker."},{label:"labels",type:"variable",info:"A list of all label IDs in ioBroker."},{label:"now",type:"variable",info:"The current local datetime object."},{label:"utcnow",type:"variable",info:"The current UTC datetime object."},{label:"e",type:"variable",info:"Euler's number (approximately 2.71828)."},{label:"pi",type:"variable",info:"The mathematical constant π (approximately 3.14159)."},{label:"tau",type:"variable",info:"The mathematical constant τ = 2π (approximately 6.28318)."},{label:"version",type:"variable",info:"The current ioBroker version as a string."},{label:"relative_time",type:"variable",info:"When used as a filter, converts a datetime to a human-readable relative string like '2 minutes ago'."},{label:"issue",type:"variable",info:"The current repair issue object, available inside repair issue templates."},{label:"issues",type:"variable",info:"A list of all active repair issues."}],v=[{label:"contains",type:"function",detail:"value",info:"Test: returns true if the sequence contains the given value."},{label:"false",type:"function",info:"Test: returns true if the value is boolean false."},{label:"has_value",type:"function",info:"Test: returns true if the entity exists and does not have an unknown or unavailable state."},{label:"is_device_attr",type:"function",detail:"device_id, attribute, value",info:"Test: returns true if the device attribute matches the given value."},{label:"is_hidden_entity",type:"function",info:"Test: returns true if the entity is hidden."},{label:"is_number",type:"function",info:"Test: returns true if the value can be interpreted as a number."},{label:"is_state",type:"function",detail:"entity_id, state",info:"Test: returns true if the entity's state matches the given value."},{label:"is_state_attr",type:"function",detail:"entity_id, attribute, value",info:"Test: returns true if the entity attribute matches the given value."},{label:"match",type:"function",detail:"pattern",info:"Test: returns true if the value matches the given regular expression pattern."},{label:"search",type:"function",detail:"pattern",info:"Test: returns true if the pattern is found anywhere in the value."},{label:"true",type:"function",info:"Test: returns true if the value is boolean true."}],h=[{label:"is_defined",type:"function",info:"Returns true if the value is defined (not undefined or None)."},{label:"add",type:"function",detail:"amount, default?",info:"Adds the given amount to a numeric value. Returns the default if the value cannot be converted to a number."},{label:"multiply",type:"function",detail:"factor",info:"Multiplies the value by the given factor."},{label:"ordinal",type:"function",info:"Converts an integer to its ordinal string representation (e.g. 1 → '1st', 2 → '2nd')."},{label:"relative_time",type:"function",info:"Converts a datetime to a human-readable relative time string like '2 minutes ago'."},{label:"slugify",type:"function",detail:"separator='-'",info:"Converts a string to a URL-friendly slug."},{label:"version",type:"function",info:"Converts a version string to a comparable version object."}],g=new Set(["now","utcnow"]),y=[...h,...d.filter(e=>{const t=e.snippet.split("(")[0];return!g.has(t)}).map(e=>({label:e.snippet.split("(")[0],type:"function",detail:e.detail||void 0,info:e.info}))],_=[...c,...y],x=[...u,...m,...b,...v],w=s,k=/^[\w\u00c0-\uffff]*$/,$=new Set(["Interpolation","VariableName","MemberExpression","CallExpression","FilterExpression","BinaryExpression","NotExpression","ConditionalExpression","ArrayExpression","TupleExpression","ParenthesizedExpression","DictExpression","ArgumentList","NamedArgument","IfStatement","ForStatement","SetStatement","BlockStatement","MacroStatement","CallStatement","FilterStatement","WithStatement","TransStatement","AutoescapeStatement","Tag"]);function R(e){let t=e;for(;t;){if($.has(t.name))return!0;t=t.parent}return!1}function A(e){var t,i,n;const{state:a,pos:r}=e,l=(0,o.mv)(a).resolveInner(r,-1).enterUnfinishedNodesBefore(r),s=null!==(t=null===(i=l.childBefore(r))||void 0===i?void 0:i.name)&&void 0!==t?t:l.name;if("FilterName"===l.name)return{options:_,from:l.from,validFor:k};if(e.explicit&&("FilterOp"===s||"filter"===s))return{options:_,from:r,validFor:k};if("TagName"===l.name)return{options:w,from:l.from,validFor:k};if(e.explicit&&"{%"===s)return{options:w,from:r,validFor:k};if("StringLiteral"===l.name||"StringLiteral"===(null===(n=l.parent)||void 0===n?void 0:n.name))return null;if("VariableName"===l.name)return{options:x,from:l.from,validFor:k};const c=e.matchBefore(/[\w\u00c0-\uffff]+$/);return c&&R(l)?{options:x,from:c.from,validFor:k}:null}const C=new Set(["abs","acos","add","add","apply","area_devices","area_entities","area_id","area_name","areas","as_datetime","as_function","as_local","as_timedelta","as_timestamp","asin","atan","atan2","attr","average","base64_decode","base64_encode","batch","bitwise_and","bitwise_or","bitwise_xor","bool","boolean","callable","capitalize","center","clamp","closest","combine","config_entry_attr","config_entry_id","contains","cos","cycler","default","defined","device_attr","device_entities","device_id","device_name","dict","dictsort","difference","distance","divisibleby","e","entity_name","eq","escape","even","expand","false","filesizeformat","first","flatten","float","floor_areas","floor_entities","floor_id","floor_name","floors","forceescape","format","from_hex","from_json","ge","groupby","gt","has_value","iif","in","indent","int","integer","integration_entities","intersect","is_defined","is_device_attr","is_hidden_entity","is_number","is_state","is_state_attr","issue","issues","items","iterable","join","joiner","label_areas","label_description","label_devices","label_entities","label_id","label_name","labels","last","le","length","lipsum","list","log","lower","lt","map","mapping","match","max","md5","median","merge_response","min","multiply","namespace","ne","none","now","number","odd","ord","ordinal","pack","pi","pprint","random","range","regex_findall","regex_findall_index","regex_match","regex_replace","regex_search","reject","rejectattr","relative_time","remap","replace","reverse","round","safe","sameas","search","select","selectattr","sequence","set","sha1","sha256","sha512","shuffle","sin","slice","slugify","sort","sqrt","state_attr","state_attr_translated","state_translated","states","statistical_mode","string","striptags","strptime","sum","symmetric_difference","tan","tau","time_since","time_until","timedelta","timestamp_custom","timestamp_local","timestamp_utc","title","to_json","today_at","tojson","trim","true","truncate","tuple","typeof","undefined","union","unique","unpack","upper","urlencode","urlize","utcnow","version","wordcount","wordwrap","wrap","xmlattr","zip"]),T=new Map(_.map(e=>[e.label,e])),S=new Map(w.map(e=>[e.label,e])),E=new Map(x.map(e=>[e.label,e]));function I(e,t,i){if(!("string"==typeof e.info?e.info:void 0)&&!e.detail)return null;const n=document.createElement("ha-code-editor-jinja-hover");return n.completion=e,t&&(n.docUrl=t),i&&(n.openDocumentation=i),n}function j(e,t,i,n){let a;const o=[];if("entity_id"===e){var r;const e=i.states[t];if(!e)return null;a=null!==(r=i.formatEntityName(t))&&void 0!==r?r:t;const n=i.formatEntityState(t);o.push({label:i.localize("ui.components.entity.entity-state-picker.state"),value:n,subValue:e.state===n?void 0:e.state});const s=i.entities[t];if(s){var l;const e=s.device_id,t=e?i.devices[e]:void 0,n=t?null===(l=t.name_by_user||t.name)||void 0===l?void 0:l.trim():void 0;n&&o.push({label:i.localize("ui.components.device-picker.device"),value:n});const a=s.area_id||(null==t?void 0:t.area_id)||void 0,r=a?i.areas[a]:void 0;if(null!=r&&r.name){o.push({label:i.localize("ui.components.area-picker.area"),value:r.name});const e=r.floor_id?i.floors[r.floor_id]:void 0;null!=e&&e.name&&o.push({label:i.localize("ui.components.floor-picker.floor"),value:e.name})}}}else if("device_id"===e){var s;const e=i.devices[t];if(!e)return null;if(a=null===(s=e.name_by_user||e.name)||void 0===s?void 0:s.trim(),!a)return null;const n=e.area_id||void 0,r=n?i.areas[n]:void 0;if(null!=r&&r.name){o.push({label:i.localize("ui.components.area-picker.area"),value:r.name});const e=r.floor_id?i.floors[r.floor_id]:void 0;null!=e&&e.name&&o.push({label:i.localize("ui.components.floor-picker.floor"),value:e.name})}}else if("area_id"===e){const e=i.areas[t];if(null==e||!e.name)return null;a=e.name;const n=e.floor_id?i.floors[e.floor_id]:void 0;null!=n&&n.name&&o.push({label:i.localize("ui.components.floor-picker.floor"),value:n.name})}else if("floor_id"===e){const e=i.floors[t];if(null==e||!e.name)return null;a=e.name}else if("label_id"===e){const e=i.labels[t];if(null==e||!e.name)return null;a=e.name,e.description&&o.push({label:i.localize("ui.panel.config.labels.headers.description"),value:e.description})}else{if("attribute"!==e)return null;{if(!n)return null;const e=i.states[n];if(!e||!(t in e.attributes))return null;a=i.formatAttributeName(n,t);const r=i.formatAttributeValue(n,t),l=e.attributes[t],s=null!=l?String(l):void 0;o.push({label:i.localize("ui.components.entity.entity-state-picker.state"),value:r,subValue:void 0!==s&&s!==r?s:void 0})}}if(!a&&!o.length)return null;const c=document.createElement("ha-code-editor-jinja-arg-hover");return a&&(c.heading=a),c.items=o,c}function M(e,t){var i;const n=(0,o.mv)(e).resolveInner(t);if("StringLiteral"!==n.name)return null;const a=e.doc.sliceString(n.from,n.to);if(a.length<2)return null;const r=a.slice(1,-1);if(!r)return null;const l=n.from,s=n.to,c=n.parent;if("SubscriptExpression"===(null==c?void 0:c.name)){const t=c.firstChild;if(t&&"states"===e.doc.sliceString(t.from,t.to))return{argType:"entity_id",value:r,from:l,to:s}}const u=n.parent;if("ArgumentList"!==(null==u?void 0:u.name))return null;const d=u.parent;if("CallExpression"!==(null==d?void 0:d.name))return null;const f=d.firstChild;if(!f)return null;const m=e.doc.sliceString(f.from,f.to),b=p.get(m);if(!b)return null;let v=0,h=null===(i=u.firstChild)||void 0===i?void 0:i.nextSibling;for(;h&&")"!==h.name;){if(","!==h.name){if(h.from===n.from)break;v++}h=h.nextSibling}const g=b.get(v);if(!g)return null;if("attribute"===g){let t;for(const[e,n]of b)if("entity_id"===n){t=e;break}let i=null;if(void 0!==t){var y;let n=0,a=null===(y=u.firstChild)||void 0===y?void 0:y.nextSibling;for(;a&&")"!==a.name;){if(","!==a.name){if(n===t&&"StringLiteral"===a.name){i=e.doc.sliceString(a.from,a.to).slice(1,-1);break}n++}a=a.nextSibling}}return{argType:g,value:r,from:l,to:s,siblingEntityId:i}}return{argType:g,value:r,from:l,to:s}}const q=/[\w\u00c0-\uffff]+/;function N(e,t,i,n){const{state:a}=e;if(n){const e=M(a,t);if(e){const t=j(e.argType,e.value,n,e.siblingEntityId);if(t)return{pos:e.from,end:e.to,above:!0,create:()=>({dom:t})}}}const r=(0,o.mv)(a).resolveInner(t),l=a.doc.lineAt(t).text,s=a.doc.lineAt(t).from,c=t-s;let u=c,d=c;for(;u>0&&q.test(l[u-1]);)u--;for(;d<l.length&&q.test(l[d]);)d++;if(u===d)return null;const f=l.slice(u,d),p=s+u,m=s+d;let b,v=!1;if("FilterName"===r.name)b=T.get(f);else if("TagName"===r.name)b=S.get(f),v=!0;else if(R(r)){const e=a.doc.sliceString(Math.max(0,p-20),p);b=/\|\s*$/.test(e)?T.get(f):E.get(f)}if(!b)return null;const h=I(b,i&&!v&&C.has(b.label)?`${i}/template-functions/${b.label}/`:void 0,null==n?void 0:n.localize("ui.components.codemirror.open_documentation"));return h?{pos:p,end:m,above:!0,create:()=>({dom:h})}:null}n()}catch(l){n(l)}})}}]);