/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const e=globalThis,t=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),i=new WeakMap;
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */let o=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const n=this.t;if(t&&void 0===e){const t=void 0!==n&&1===n.length;t&&(e=i.get(n)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&i.set(n,e))}return e}toString(){return this.cssText}};const s=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1]),e[0]);return new o(i,e,n)},r=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,n))(t)})(e):e
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */,{is:a,defineProperty:l,getOwnPropertyDescriptor:c,getOwnPropertyNames:h,getOwnPropertySymbols:p,getPrototypeOf:d}=Object,u=globalThis,g=u.trustedTypes,f=g?g.emptyScript:"",b=u.reactiveElementPolyfillSupport,y=(e,t)=>e,v={toAttribute(e,t){switch(t){case Boolean:e=e?f:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},m=(e,t)=>!a(e,t),_={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:m};Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;let $=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=_){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&l(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){const{get:i,set:o}=c(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get(){return i?.call(this)},set(t){const s=i?.call(this);o.call(this,t),this.requestUpdate(e,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_}static _$Ei(){if(this.hasOwnProperty(y("elementProperties")))return;const e=d(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(y("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y("properties"))){const e=this.properties,t=[...h(e),...p(e)];for(const n of t)this.createProperty(n,e[n])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const n=this._$Eu(e,t);void 0!==n&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(r(e))}else void 0!==e&&t.push(r(e));return t}static _$Eu(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$E_??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$E_?.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const n=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((n,i)=>{if(t)n.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const t of i){const i=document.createElement("style"),o=e.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=t.cssText,n.appendChild(i)}})(n,this.constructor.elementStyles),n}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$E_?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$EO(e,t){const n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){const o=(void 0!==n.converter?.toAttribute?n.converter:v).toAttribute(t,n.type);this._$Em=e,null==o?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,t){const n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){const e=n.getPropertyOptions(i),o="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:v;this._$Em=i,this[i]=o.fromAttribute(t,e.type),this._$Em=null}}requestUpdate(e,t,n){if(void 0!==e){if(n??=this.constructor.getPropertyOptions(e),!(n.hasChanged??m)(this[e],t))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(e,t,n){this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$Em!==e&&(this._$ET??=new Set).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,n]of e)!0!==n.wrapped||this._$AL.has(t)||void 0===this[t]||this.C(t,this[t],n)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$E_?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$Ej()}catch(t){throw e=!1,this._$Ej(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$E_?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$ET&&=this._$ET.forEach((e=>this._$EO(e,this[e]))),this._$Ej()}updated(e){}firstUpdated(e){}};$.elementStyles=[],$.shadowRootOptions={mode:"open"},$[y("elementProperties")]=new Map,$[y("finalized")]=new Map,b?.({ReactiveElement:$}),(u.reactiveElementVersions??=[]).push("2.0.3");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const w={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:m},x=(e=w,t,n)=>{const{kind:i,metadata:o}=n;let s=globalThis.litPropertyMetadata.get(o);if(void 0===s&&globalThis.litPropertyMetadata.set(o,s=new Map),s.set(n.name,e),"accessor"===i){const{name:i}=n;return{set(n){const o=t.get.call(this);t.set.call(this,n),this.requestUpdate(i,o,e)},init(t){return void 0!==t&&this.C(i,void 0,e),t}}}if("setter"===i){const{name:i}=n;return function(n){const o=this[i];t.call(this,n),this.requestUpdate(i,o,e)}}throw Error("Unsupported decorator location: "+i)};function A(e){return(t,n)=>"object"==typeof n?x(e,t,n):((e,t,n)=>{const i=t.hasOwnProperty(n);return t.constructor.createProperty(n,i?{...e,wrapped:!0}:e),i?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */}function E(e){return A({...e,state:!0,attribute:!1})}function S(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function k(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const n=e[t],i=typeof n;"object"!==i&&"function"!==i||Object.isFrozen(n)||k(n)})),e}class C{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function O(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function R(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t];return t.forEach((function(e){for(const t in e)n[t]=e[t]})),n}const P=e=>!!e.scope;class M{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=O(e)}openNode(e){if(!P(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){P(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const N=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class j{constructor(){this.rootNode=N(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=N({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{j._collapse(e)})))}}class T extends j{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new M(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function I(e){return e?"string"==typeof e?e:e.source:null}function L(e){return U("(?=",e,")")}function H(e){return U("(?:",e,")*")}function B(e){return U("(?:",e,")?")}function U(...e){const t=e.map((e=>I(e))).join("");return t}function D(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e),n="("+(t.capture?"":"?:")+e.map((e=>I(e))).join("|")+")";return n}function z(e){return new RegExp(e.toString()+"|").exec("").length-1}const W=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function G(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n;let i=I(e),o="";for(;i.length>0;){const e=W.exec(i);if(!e){o+=i;break}o+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?o+="\\"+String(Number(e[1])+t):(o+=e[0],"("===e[0]&&n++)}return o})).map((e=>`(${e})`)).join(t)}const V="[a-zA-Z]\\w*",K="[a-zA-Z_]\\w*",F="\\b\\d+(\\.\\d+)?",X="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Z="\\b(0b[01]+)",q={begin:"\\\\[\\s\\S]",relevance:0},J={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[q]},Y={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[q]},Q=function(e,t,n={}){const i=R({scope:"comment",begin:e,end:t,contains:[]},n);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const o=D("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:U(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},ee=Q("//","$"),te=Q("/\\*","\\*/"),ne=Q("#","$"),ie={scope:"number",begin:F,relevance:0},oe={scope:"number",begin:X,relevance:0},se={scope:"number",begin:Z,relevance:0},re={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[q,{begin:/\[/,end:/\]/,relevance:0,contains:[q]}]},ae={scope:"title",begin:V,relevance:0},le={scope:"title",begin:K,relevance:0},ce={begin:"\\.\\s*"+K,relevance:0};var he=Object.freeze({__proto__:null,APOS_STRING_MODE:J,BACKSLASH_ESCAPE:q,BINARY_NUMBER_MODE:se,BINARY_NUMBER_RE:Z,COMMENT:Q,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:ee,C_NUMBER_MODE:oe,C_NUMBER_RE:X,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:ne,IDENT_RE:V,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:ce,NUMBER_MODE:ie,NUMBER_RE:F,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:Y,REGEXP_MODE:re,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=U(t,/.*\b/,e.binary,/\b.*/)),R({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:ae,UNDERSCORE_IDENT_RE:K,UNDERSCORE_TITLE_MODE:le});function pe(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function de(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function ue(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=pe,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function ge(e,t){Array.isArray(e.illegal)&&(e.illegal=D(...e.illegal))}function fe(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function be(e,t){void 0===e.relevance&&(e.relevance=1)}const ye=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=n.keywords,e.begin=U(n.beforeMatch,L(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},ve=["of","and","for","in","not","or","if","then","parent","list","value"],me="keyword";function _e(e,t,n=me){const i=Object.create(null);return"string"==typeof e?o(n,e.split(" ")):Array.isArray(e)?o(n,e):Object.keys(e).forEach((function(n){Object.assign(i,_e(e[n],t,n))})),i;function o(e,n){t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((function(t){const n=t.split("|");i[n[0]]=[e,$e(n[0],n[1])]}))}}function $e(e,t){return t?Number(t):function(e){return ve.includes(e.toLowerCase())}(e)?0:1}const we={},xe=e=>{console.error(e)},Ae=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Ee=(e,t)=>{we[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),we[`${e}/${t}`]=!0)},Se=new Error;function ke(e,t,{key:n}){let i=0;const o=e[n],s={},r={};for(let e=1;e<=t.length;e++)r[e+i]=o[e],s[e+i]=!0,i+=z(t[e-1]);e[n]=r,e[n]._emit=s,e[n]._multi=!0}function Ce(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw xe("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Se;if("object"!=typeof e.beginScope||null===e.beginScope)throw xe("beginScope must be object"),Se;ke(e,e.begin,{key:"beginScope"}),e.begin=G(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw xe("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Se;if("object"!=typeof e.endScope||null===e.endScope)throw xe("endScope must be object"),Se;ke(e,e.end,{key:"endScope"}),e.end=G(e.end,{joinWith:""})}}(e)}function Oe(e){function t(t,n){return new RegExp(I(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=z(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(G(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,i)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language.  See documentation.");return e.classNameAliases=R(e.classNameAliases||{}),function n(o,s){const r=o;if(o.isCompiled)return r;[de,fe,Ce,ye].forEach((e=>e(o,s))),e.compilerExtensions.forEach((e=>e(o,s))),o.__beforeBegin=null,[ue,ge,be].forEach((e=>e(o,s))),o.isCompiled=!0;let a=null;return"object"==typeof o.keywords&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),a=o.keywords.$pattern,delete o.keywords.$pattern),a=a||/\w+/,o.keywords&&(o.keywords=_e(o.keywords,e.case_insensitive)),r.keywordPatternRe=t(a,!0),s&&(o.begin||(o.begin=/\B|\b/),r.beginRe=t(r.begin),o.end||o.endsWithParent||(o.end=/\B|\b/),o.end&&(r.endRe=t(r.end)),r.terminatorEnd=I(r.end)||"",o.endsWithParent&&s.terminatorEnd&&(r.terminatorEnd+=(o.end?"|":"")+s.terminatorEnd)),o.illegal&&(r.illegalRe=t(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map((function(e){return function(e){e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return R(e,{variants:null},t)})));if(e.cachedVariants)return e.cachedVariants;if(Re(e))return R(e,{starts:e.starts?R(e.starts):null});if(Object.isFrozen(e))return R(e);return e}("self"===e?o:e)}))),o.contains.forEach((function(e){n(e,r)})),o.starts&&n(o.starts,s),r.matcher=function(e){const t=new i;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(r),r}(e)}function Re(e){return!!e&&(e.endsWithParent||Re(e.starts))}class Pe extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const Me=O,Ne=R,je=Symbol("nomatch"),Te=function(e){const t=Object.create(null),n=Object.create(null),i=[];let o=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",r={disableAutodetect:!0,name:"Plain text",contains:[]};let a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:T};function l(e){return a.noHighlightRe.test(e)}function c(e,t,n){let i="",o="";"object"==typeof t?(i=e,n=t.ignoreIllegals,o=t.language):(Ee("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ee("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),o=e,i=t),void 0===n&&(n=!0);const s={code:i,language:o};v("before:highlight",s);const r=s.result?s.result:h(s.language,s.code,n);return r.code=s.code,v("after:highlight",r),r}function h(e,n,i,r){const l=Object.create(null);function c(){if(!E.keywords)return void k.addText(O);let e=0;E.keywordPatternRe.lastIndex=0;let t=E.keywordPatternRe.exec(O),n="";for(;t;){n+=O.substring(e,t.index);const o=w.case_insensitive?t[0].toLowerCase():t[0],s=(i=o,E.keywords[i]);if(s){const[e,i]=s;if(k.addText(n),n="",l[o]=(l[o]||0)+1,l[o]<=7&&(R+=i),e.startsWith("_"))n+=t[0];else{const n=w.classNameAliases[e]||e;u(t[0],n)}}else n+=t[0];e=E.keywordPatternRe.lastIndex,t=E.keywordPatternRe.exec(O)}var i;n+=O.substring(e),k.addText(n)}function d(){null!=E.subLanguage?function(){if(""===O)return;let e=null;if("string"==typeof E.subLanguage){if(!t[E.subLanguage])return void k.addText(O);e=h(E.subLanguage,O,!0,S[E.subLanguage]),S[E.subLanguage]=e._top}else e=p(O,E.subLanguage.length?E.subLanguage:null);E.relevance>0&&(R+=e.relevance),k.__addSublanguage(e._emitter,e.language)}():c(),O=""}function u(e,t){""!==e&&(k.startScope(t),k.addText(e),k.endScope())}function g(e,t){let n=1;const i=t.length-1;for(;n<=i;){if(!e._emit[n]){n++;continue}const i=w.classNameAliases[e[n]]||e[n],o=t[n];i?u(o,i):(O=o,c(),O=""),n++}}function b(e,t){return e.scope&&"string"==typeof e.scope&&k.openNode(w.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(u(O,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),O=""):e.beginScope._multi&&(g(e.beginScope,t),O="")),E=Object.create(e,{parent:{value:E}}),E}function y(e,t,n){let i=function(e,t){const n=e&&e.exec(t);return n&&0===n.index}(e.endRe,n);if(i){if(e["on:end"]){const n=new C(e);e["on:end"](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return y(e.parent,t,n)}function v(e){return 0===E.matcher.regexIndex?(O+=e[0],1):(N=!0,0)}function m(e){const t=e[0],i=n.substring(e.index),o=y(E,e,i);if(!o)return je;const s=E;E.endScope&&E.endScope._wrap?(d(),u(t,E.endScope._wrap)):E.endScope&&E.endScope._multi?(d(),g(E.endScope,e)):s.skip?O+=t:(s.returnEnd||s.excludeEnd||(O+=t),d(),s.excludeEnd&&(O=t));do{E.scope&&k.closeNode(),E.skip||E.subLanguage||(R+=E.relevance),E=E.parent}while(E!==o.parent);return o.starts&&b(o.starts,e),s.returnEnd?0:t.length}let _={};function $(t,s){const r=s&&s[0];if(O+=t,null==r)return d(),0;if("begin"===_.type&&"end"===s.type&&_.index===s.index&&""===r){if(O+=n.slice(s.index,s.index+1),!o){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=_.rule,t}return 1}if(_=s,"begin"===s.type)return function(e){const t=e[0],n=e.rule,i=new C(n),o=[n.__beforeBegin,n["on:begin"]];for(const n of o)if(n&&(n(e,i),i.isMatchIgnored))return v(t);return n.skip?O+=t:(n.excludeBegin&&(O+=t),d(),n.returnBegin||n.excludeBegin||(O=t)),b(n,e),n.returnBegin?0:t.length}(s);if("illegal"===s.type&&!i){const e=new Error('Illegal lexeme "'+r+'" for mode "'+(E.scope||"<unnamed>")+'"');throw e.mode=E,e}if("end"===s.type){const e=m(s);if(e!==je)return e}if("illegal"===s.type&&""===r)return 1;if(M>1e5&&M>3*s.index){throw new Error("potential infinite loop, way more iterations than matches")}return O+=r,r.length}const w=f(e);if(!w)throw xe(s.replace("{}",e)),new Error('Unknown language: "'+e+'"');const x=Oe(w);let A="",E=r||x;const S={},k=new a.__emitter(a);!function(){const e=[];for(let t=E;t!==w;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>k.openNode(e)))}();let O="",R=0,P=0,M=0,N=!1;try{if(w.__emitTokens)w.__emitTokens(n,k);else{for(E.matcher.considerAll();;){M++,N?N=!1:E.matcher.considerAll(),E.matcher.lastIndex=P;const e=E.matcher.exec(n);if(!e)break;const t=$(n.substring(P,e.index),e);P=e.index+t}$(n.substring(P))}return k.finalize(),A=k.toHTML(),{language:e,value:A,relevance:R,illegal:!1,_emitter:k,_top:E}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:Me(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:P,context:n.slice(P-100,P+100),mode:t.mode,resultSoFar:A},_emitter:k};if(o)return{language:e,value:Me(n),illegal:!1,relevance:0,errorRaised:t,_emitter:k,_top:E};throw t}}function p(e,n){n=n||a.languages||Object.keys(t);const i=function(e){const t={value:Me(e),illegal:!1,relevance:0,_top:r,_emitter:new a.__emitter(a)};return t._emitter.addText(e),t}(e),o=n.filter(f).filter(y).map((t=>h(t,e,!1)));o.unshift(i);const s=o.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(f(e.language).supersetOf===t.language)return 1;if(f(t.language).supersetOf===e.language)return-1}return 0})),[l,c]=s,p=l;return p.secondBest=c,p}function d(e){let t=null;const i=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=a.languageDetectRe.exec(t);if(n){const t=f(n[1]);return t||(Ae(s.replace("{}",n[1])),Ae("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>l(e)||f(e)))}(e);if(l(i))return;if(v("before:highlightElement",{el:e,language:i}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),a.throwUnescapedHTML)){throw new Pe("One of your code blocks includes unescaped HTML.",e.innerHTML)}t=e;const o=t.textContent,r=i?c(o,{language:i,ignoreIllegals:!0}):p(o);e.innerHTML=r.value,e.dataset.highlighted="yes",function(e,t,i){const o=t&&n[t]||i;e.classList.add("hljs"),e.classList.add(`language-${o}`)}(e,i,r.language),e.result={language:r.language,re:r.relevance,relevance:r.relevance},r.secondBest&&(e.secondBest={language:r.secondBest.language,relevance:r.secondBest.relevance}),v("after:highlightElement",{el:e,result:r,text:o})}let u=!1;function g(){if("loading"===document.readyState)return void(u=!0);document.querySelectorAll(a.cssSelector).forEach(d)}function f(e){return e=(e||"").toLowerCase(),t[e]||t[n[e]]}function b(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{n[e.toLowerCase()]=t}))}function y(e){const t=f(e);return t&&!t.disableAutodetect}function v(e,t){const n=e;i.forEach((function(e){e[n]&&e[n](t)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){u&&g()}),!1),Object.assign(e,{highlight:c,highlightAuto:p,highlightAll:g,highlightElement:d,highlightBlock:function(e){return Ee("10.7.0","highlightBlock will be removed entirely in v12.0"),Ee("10.7.0","Please use highlightElement now."),d(e)},configure:function(e){a=Ne(a,e)},initHighlighting:()=>{g(),Ee("10.6.0","initHighlighting() deprecated.  Use highlightAll() now.")},initHighlightingOnLoad:function(){g(),Ee("10.6.0","initHighlightingOnLoad() deprecated.  Use highlightAll() now.")},registerLanguage:function(n,i){let s=null;try{s=i(e)}catch(e){if(xe("Language definition for '{}' could not be registered.".replace("{}",n)),!o)throw e;xe(e),s=r}s.name||(s.name=n),t[n]=s,s.rawDefinition=i.bind(null,e),s.aliases&&b(s.aliases,{languageName:n})},unregisterLanguage:function(e){delete t[e];for(const t of Object.keys(n))n[t]===e&&delete n[t]},listLanguages:function(){return Object.keys(t)},getLanguage:f,registerAliases:b,autoDetection:y,inherit:Ne,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),i.push(e)},removePlugin:function(e){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString="11.9.0",e.regex={concat:U,lookahead:L,either:D,optional:B,anyNumberOfTimes:H};for(const e in he)"object"==typeof he[e]&&k(he[e]);return Object.assign(e,he),e},Ie=Te({});Ie.newInstance=()=>Te({});var Le=Ie;Ie.HighlightJS=Ie,Ie.default=Ie;var He=S(Le);
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const Be=globalThis,Ue=Be.trustedTypes,De=Ue?Ue.createPolicy("lit-html",{createHTML:e=>e}):void 0,ze="$lit$",We=`lit$${(Math.random()+"").slice(9)}$`,Ge="?"+We,Ve=`<${Ge}>`,Ke=document,Fe=()=>Ke.createComment(""),Xe=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Ze=Array.isArray,qe="[ \t\n\f\r]",Je=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ye=/-->/g,Qe=/>/g,et=RegExp(`>|${qe}(?:([^\\s"'>=/]+)(${qe}*=${qe}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),tt=/'/g,nt=/"/g,it=/^(?:script|style|textarea|title)$/i,ot=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),st=ot(1),rt=ot(2),at=Symbol.for("lit-noChange"),lt=Symbol.for("lit-nothing"),ct=new WeakMap,ht=Ke.createTreeWalker(Ke,129);function pt(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==De?De.createHTML(t):t}const dt=(e,t)=>{const n=e.length-1,i=[];let o,s=2===t?"<svg>":"",r=Je;for(let t=0;t<n;t++){const n=e[t];let a,l,c=-1,h=0;for(;h<n.length&&(r.lastIndex=h,l=r.exec(n),null!==l);)h=r.lastIndex,r===Je?"!--"===l[1]?r=Ye:void 0!==l[1]?r=Qe:void 0!==l[2]?(it.test(l[2])&&(o=RegExp("</"+l[2],"g")),r=et):void 0!==l[3]&&(r=et):r===et?">"===l[0]?(r=o??Je,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?et:'"'===l[3]?nt:tt):r===nt||r===tt?r=et:r===Ye||r===Qe?r=Je:(r=et,o=void 0);const p=r===et&&e[t+1].startsWith("/>")?" ":"";s+=r===Je?n+Ve:c>=0?(i.push(a),n.slice(0,c)+ze+n.slice(c)+We+p):n+We+(-2===c?t:p)}return[pt(e,s+(e[n]||"<?>")+(2===t?"</svg>":"")),i]};class ut{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let o=0,s=0;const r=e.length-1,a=this.parts,[l,c]=dt(e,t);if(this.el=ut.createElement(l,n),ht.currentNode=this.el.content,2===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(i=ht.nextNode())&&a.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const e of i.getAttributeNames())if(e.endsWith(ze)){const t=c[s++],n=i.getAttribute(e).split(We),r=/([.?@])?(.*)/.exec(t);a.push({type:1,index:o,name:r[2],strings:n,ctor:"."===r[1]?vt:"?"===r[1]?mt:"@"===r[1]?_t:yt}),i.removeAttribute(e)}else e.startsWith(We)&&(a.push({type:6,index:o}),i.removeAttribute(e));if(it.test(i.tagName)){const e=i.textContent.split(We),t=e.length-1;if(t>0){i.textContent=Ue?Ue.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],Fe()),ht.nextNode(),a.push({type:2,index:++o});i.append(e[t],Fe())}}}else if(8===i.nodeType)if(i.data===Ge)a.push({type:2,index:o});else{let e=-1;for(;-1!==(e=i.data.indexOf(We,e+1));)a.push({type:7,index:o}),e+=We.length-1}o++}}static createElement(e,t){const n=Ke.createElement("template");return n.innerHTML=e,n}}function gt(e,t,n=e,i){if(t===at)return t;let o=void 0!==i?n._$Co?.[i]:n._$Cl;const s=Xe(t)?void 0:t._$litDirective$;return o?.constructor!==s&&(o?._$AO?.(!1),void 0===s?o=void 0:(o=new s(e),o._$AT(e,n,i)),void 0!==i?(n._$Co??=[])[i]=o:n._$Cl=o),void 0!==o&&(t=gt(e,o._$AS(e,t.values),o,i)),t}class ft{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,i=(e?.creationScope??Ke).importNode(t,!0);ht.currentNode=i;let o=ht.nextNode(),s=0,r=0,a=n[0];for(;void 0!==a;){if(s===a.index){let t;2===a.type?t=new bt(o,o.nextSibling,this,e):1===a.type?t=new a.ctor(o,a.name,a.strings,this,e):6===a.type&&(t=new $t(o,this,e)),this._$AV.push(t),a=n[++r]}s!==a?.index&&(o=ht.nextNode(),s++)}return ht.currentNode=Ke,i}p(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class bt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,i){this.type=2,this._$AH=lt,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=gt(this,e,t),Xe(e)?e===lt||null==e||""===e?(this._$AH!==lt&&this._$AR(),this._$AH=lt):e!==this._$AH&&e!==at&&this._(e):void 0!==e._$litType$?this.g(e):void 0!==e.nodeType?this.$(e):(e=>Ze(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==lt&&Xe(this._$AH)?this._$AA.nextSibling.data=e:this.$(Ke.createTextNode(e)),this._$AH=e}g(e){const{values:t,_$litType$:n}=e,i="number"==typeof n?this._$AC(e):(void 0===n.el&&(n.el=ut.createElement(pt(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(t);else{const e=new ft(i,this),n=e.u(this.options);e.p(t),this.$(n),this._$AH=e}}_$AC(e){let t=ct.get(e.strings);return void 0===t&&ct.set(e.strings,t=new ut(e)),t}T(e){Ze(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const o of e)i===t.length?t.push(n=new bt(this.k(Fe()),this.k(Fe()),this,this.options)):n=t[i],n._$AI(o),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class yt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,o){this.type=1,this._$AH=lt,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=lt}_$AI(e,t=this,n,i){const o=this.strings;let s=!1;if(void 0===o)e=gt(this,e,t,0),s=!Xe(e)||e!==this._$AH&&e!==at,s&&(this._$AH=e);else{const i=e;let r,a;for(e=o[0],r=0;r<o.length-1;r++)a=gt(this,i[n+r],t,r),a===at&&(a=this._$AH[r]),s||=!Xe(a)||a!==this._$AH[r],a===lt?e=lt:e!==lt&&(e+=(a??"")+o[r+1]),this._$AH[r]=a}s&&!i&&this.O(e)}O(e){e===lt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class vt extends yt{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===lt?void 0:e}}class mt extends yt{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==lt)}}class _t extends yt{constructor(e,t,n,i,o){super(e,t,n,i,o),this.type=5}_$AI(e,t=this){if((e=gt(this,e,t,0)??lt)===at)return;const n=this._$AH,i=e===lt&&n!==lt||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,o=e!==lt&&(n===lt||i);i&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class $t{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){gt(this,e)}}const wt=Be.litHtmlPolyfillSupport;wt?.(ut,bt),(Be.litHtmlVersions??=[]).push("3.1.1");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
let xt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{const i=n?.renderBefore??t;let o=i._$litPart$;if(void 0===o){const e=n?.renderBefore??null;i._$litPart$=o=new bt(t.insertBefore(Fe(),e),e,void 0,n??{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return at}};xt._$litElement$=!0,xt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:xt});const At=globalThis.litElementPolyfillSupport;At?.({LitElement:xt}),(globalThis.litElementVersions??=[]).push("4.0.3");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const Et=1,St=2,kt=e=>(...t)=>({_$litDirective$:e,values:t});let Ct=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},Ot=class extends Ct{constructor(e){if(super(e),this.et=lt,e.type!==St)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===lt||null==e)return this.vt=void 0,this.et=e;if(e===at)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.et)return this.vt;this.et=e;const t=[e];return t.raw=t,this.vt={_$litType$:this.constructor.resultType,strings:t,values:[]}}};
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */Ot.directiveName="unsafeHTML",Ot.resultType=1;const Rt=kt(Ot),Pt="important",Mt=" !"+Pt,Nt=kt(class extends Ct{constructor(e){if(super(e),e.type!==Et||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{const i=e[n];return null==i?t:t+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:n}=e.element;if(void 0===this.ut)return this.ut=new Set(Object.keys(t)),this.render(t);for(const e of this.ut)null==t[e]&&(this.ut.delete(e),e.includes("-")?n.removeProperty(e):n[e]=null);for(const e in t){const i=t[e];if(null!=i){this.ut.add(e);const t="string"==typeof i&&i.endsWith(Mt);e.includes("-")||t?n.setProperty(e,t?i.slice(0,-11):i,t?Pt:""):n[e]=i}}return at}}),jt=(e,t)=>{const n=e._$AN;if(void 0===n)return!1;for(const e of n)e._$AO?.(t,!1),jt(e,t);return!0},Tt=e=>{let t,n;do{if(void 0===(t=e._$AM))break;n=t._$AN,n.delete(e),e=t}while(0===n?.size)},It=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(void 0===n)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),Bt(t)}};
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */function Lt(e){void 0!==this._$AN?(Tt(this),this._$AM=e,It(this)):this._$AM=e}function Ht(e,t=!1,n=0){const i=this._$AH,o=this._$AN;if(void 0!==o&&0!==o.size)if(t)if(Array.isArray(i))for(let e=n;e<i.length;e++)jt(i[e],!1),Tt(i[e]);else null!=i&&(jt(i,!1),Tt(i));else jt(this,e)}const Bt=e=>{e.type==St&&(e._$AP??=Ht,e._$AQ??=Lt)};class Ut extends Ct{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),It(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(jt(this,e),Tt(this))}setValue(e){if((e=>void 0===e.strings)
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}
/**
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const Dt=()=>new zt;class zt{}const Wt=new WeakMap,Gt=kt(class extends Ut{render(e){return lt}update(e,[t]){const n=t!==this.G;return n&&void 0!==this.G&&this.ot(void 0),(n||this.rt!==this.lt)&&(this.G=t,this.ct=e.options?.host,this.ot(this.lt=e.element)),lt}ot(e){if("function"==typeof this.G){const t=this.ct??globalThis;let n=Wt.get(t);void 0===n&&(n=new WeakMap,Wt.set(t,n)),void 0!==n.get(this.G)&&this.G.call(this.ct,void 0),n.set(this.G,e),void 0!==e&&this.G.call(this.ct,e)}else this.G.value=e}get rt(){return"function"==typeof this.G?Wt.get(this.ct??globalThis)?.get(this.G):this.G?.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}}),Vt=(e,t,n)=>{const i=e.split(t);return i[i.length-1].split(n)[0]},Kt=(e,t=25)=>{try{const n=e.startsWith("rgba(")?"rgba(":"rgb(",i=parseInt(Vt(e,n,","));if(isNaN(i))throw"NaN Error";const o=i<127.5?i+t:i-t;return`rgb(${o}, ${o}, ${o})`}catch(e){return"rgb(127.5, 127.5, 127.5)"}},Ft={type:"string",value:"",animation:"background",isEditable:!0},Xt={fontSize:16,backgroundColor:"rgb(255, 255, 255)",width:0,height:0,paddingLeft:0,paddingRight:0},Zt={backgroundColor:"",borderColor:"",textColor:"",inputBorderColor:""},qt=kt(class extends Ct{constructor(e){if(super(e),e.type!==Et||"class"!==e.name||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter((t=>e[t])).join(" ")+" "}update(e,[t]){if(void 0===this.it){this.it=new Set,void 0!==e.strings&&(this.st=new Set(e.strings.join(" ").split(/\s/).filter((e=>""!==e))));for(const e in t)t[e]&&!this.st?.has(e)&&this.it.add(e);return this.render(t)}const n=e.element.classList;for(const e of this.it)e in t||(n.remove(e),this.it.delete(e));for(const e in t){const i=!!t[e];i===this.it.has(e)||this.st?.has(e)||(i?(n.add(e),this.it.add(e)):(n.remove(e),this.it.delete(e)))}return at}}),Jt=s`
  @keyframes background-animation {
    0% {
      background-color: rgba(0, 0, 0, 0.1);
    }
    100% {
      background-color: rgba(255, 255, 255, 0.1);
    }
  }
`,Yt=s`
  @keyframes underline-animation {
    0% {
      border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    }
    100% {
      border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    }
  }
`,Qt=s`
  #popup {
    cursor: default;
    position: absolute;
    width: 0;
    height: fit-content;
    opacity: 0;

    transform: translateX(-9999px);

    transition: width 0s 0.2s, padding 0s 0.2s, transform 0s 0.2s, opacity 0.2s;
  }
  #popup.fade-in {
    padding: 6px 0;
    width: 50vw;
    max-width: 640px;
    opacity: 1;

    transform: translateX(0);

    transition: width 0s, transform 0s, opacity 0.2s;
  }
  #popup-inner {
    position: relative;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    padding: 6px;
    overflow-wrap: break-word;
    overflow-y: scroll;
  }
  #popup-inner::-webkit-scrollbar {
    display: none;
  }
  .popup-line-break {
    opacity: 0.2;
    border-right: none;
    border-bottom: none;
    border-left: none;
    border-top: 1px solid;
  }
  .popup-description {
    white-space: pre-wrap;
    padding-top: 0.5em;
  }
`;var en=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class tn extends xt{constructor(){super(...arguments),this.checked=!1,this.onChange=()=>{}}render(){return st`
      <label class="toggle">
        <input
          class="toggle-checkbox"
          type="checkbox"
          .checked=${this.checked}
          @change=${this.onChange}
        />
        <div class="toggle-switch"></div>
      </label>
    `}}tn.styles=[s`
      .toggle {
        cursor: pointer;
        display: inline-block;
      }

      .toggle-switch {
        display: inline-block;
        background: #ccc;
        border-radius: 12px;
        width: 42px;
        height: 24px;
        position: relative;
        vertical-align: middle;
        transition: background 0.25s;
      }
      .toggle-switch:before,
      .toggle-switch:after {
        content: '';
      }
      .toggle-switch:before {
        display: block;
        background: linear-gradient(to bottom, #fff 0%, #eee 100%);
        border-radius: 50%;
        width: 18px;
        height: 18px;
        position: absolute;
        top: 3px;
        left: 3px;
        transition: left 0.25s;
      }
      .toggle:hover .toggle-switch:before {
        background: linear-gradient(to bottom, #fff 0%, #fff 100%);
      }
      .toggle-checkbox:checked + .toggle-switch {
        background: #56c080;
      }
      .toggle-checkbox:checked + .toggle-switch:before {
        left: 21px;
      }

      .toggle-checkbox {
        position: absolute;
        visibility: hidden;
      }

      .toggle-label {
        margin-left: 5px;
        position: relative;
        top: 2px;
      }
    `],en([A({attribute:"checked"})],tn.prototype,"checked",void 0),en([A({attribute:"onChange"})],tn.prototype,"onChange",void 0),customElements.get("annotative-code-knob-switch")||customElements.define("annotative-code-knob-switch",tn);const nn=s`
  input,
  select,
  textarea {
    background-color: rgba(0, 0, 0, 0);
    padding: 6px 8px;
    border-radius: 16px;
    min-width: 120px;
  }
`;var on=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class sn extends xt{constructor(){super(...arguments),this.type="number",this.config={max:null,min:null},this.popupStyle=Zt,this.value=0,this.onChange=()=>{}}render(){const e="range"===this.type;return st`
      ${e&&0!==this.config.min&&this.config.min?st`<div class="min-max-label">${this.config.min}</div>`:""}
      <input
        class="number"
        type=${this.type}
        style=${Nt({color:this.popupStyle.textColor,border:`1px solid ${this.popupStyle.inputBorderColor}`})}
        min=${this.config.min}
        max=${this.config.max}
        .value=${this.value}
        @change=${this.onChange}
      />
      ${e&&0!==this.config.max&&this.config.max?st`<div class="min-max-label">${this.config.max}</div>`:""}
    `}}sn.styles=[nn,s`
      .min-max-label {
        display: inline-block;
        vertical-align: top;
        transform: translateY(8px);
      }
    `],on([A({attribute:"type"})],sn.prototype,"type",void 0),on([A({attribute:"config"})],sn.prototype,"config",void 0),on([A({attribute:"popupStyle"})],sn.prototype,"popupStyle",void 0),on([A({attribute:"value"})],sn.prototype,"value",void 0),on([A({attribute:"onChange"})],sn.prototype,"onChange",void 0),customElements.get("annotative-code-knob-number-date-time")||customElements.define("annotative-code-knob-number-date-time",sn);var rn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class an extends xt{constructor(){super(...arguments),this.type="string",this.popupStyle=Zt,this.value=0,this.onChange=()=>{}}render(){return st`<input
      type=${"color"===this.type?"color":"text"}
      style=${Nt({color:this.popupStyle.textColor,border:`1px solid ${this.popupStyle.inputBorderColor}`,"min-width":"200px"})}
      .value=${this.value}
      @change=${this.onChange}
    />`}}an.styles=[nn],rn([A({attribute:"type"})],an.prototype,"type",void 0),rn([A({attribute:"popupStyle"})],an.prototype,"popupStyle",void 0),rn([A({attribute:"value"})],an.prototype,"value",void 0),rn([A({attribute:"onChange"})],an.prototype,"onChange",void 0),customElements.get("annotative-code-knob-string")||customElements.define("annotative-code-knob-string",an);var ln=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class cn extends xt{constructor(){super(...arguments),this.config={options:[]},this.popupStyle=Zt,this.value=0,this.onChange=()=>{}}render(){const e=this.config.options;return e&&0!==e.length?st`
      <select
        @change=${this.onChange}
        .value=${this.value}
        style=${Nt({color:this.popupStyle.textColor,border:`1px solid ${this.popupStyle.inputBorderColor}`,"min-width":"200px",appearance:"none"})}
      >
        ${e.map((e=>st`<option>${e}</option>`))}
      </select>
    `:""}}cn.styles=[nn],ln([A({attribute:"config"})],cn.prototype,"config",void 0),ln([A({attribute:"popupStyle"})],cn.prototype,"popupStyle",void 0),ln([A({attribute:"value"})],cn.prototype,"value",void 0),ln([A({attribute:"onChange"})],cn.prototype,"onChange",void 0),customElements.get("annotative-code-knob-select")||customElements.define("annotative-code-knob-select",cn);var hn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class pn extends xt{constructor(){super(...arguments),this.key="",this.config={type:"string",value:""},this.popupStyle=Zt,this.onChange=(e,t)=>{}}render(){const{isEditable:e,type:t,knob:n="",value:i}=this.config,o=((e,t)=>{const n=["string","number","integer","boolean"].indexOf(e)>0;return t||(n?e:"string")})(t,n);return st`<div>
      ${e?["string"].includes(o)?st`<annotative-code-knob-string
            .type=${o}
            .popupStyle=${this.popupStyle}
            .value=${i}
            .onChange=${e=>this.onChange(this.key,e)}
          />`:["number","integer","date","time","datetime-local","range"].includes(o)?st`<annotative-code-knob-number-date-time
            .type=${o}
            .config=${this.config}
            .popupStyle=${this.popupStyle}
            .value=${i}
            .onChange=${e=>this.onChange(this.key,e)}
          />`:["boolean"].includes(o)?st`<annotative-code-knob-switch
            .config=${this.config}
            .checked=${!0===i}
            .onChange=${e=>this.onChange(this.key,e)}
          />`:["select"].includes(o)?st`<annotative-code-knob-select
            .config=${this.config}
            .popupStyle=${this.popupStyle}
            .value=${i}
            .onChange=${e=>this.onChange(this.key,e)}
          />`:["color"].includes(o)?st`<input
            type="color"
            .value=${i}
            @change=${e=>this.onChange(this.key,e)}
          />`:"":""}
    </div>`}}pn.styles=[],hn([A({attribute:"key"})],pn.prototype,"key",void 0),hn([A({attribute:"config"})],pn.prototype,"config",void 0),hn([A({attribute:"popupStyle"})],pn.prototype,"popupStyle",void 0),hn([A({attribute:"onChange"})],pn.prototype,"onChange",void 0),customElements.get("annotative-code-knob")||customElements.define("annotative-code-knob",pn);var dn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class un extends xt{constructor(){super(...arguments),this.annotationRef=Dt(),this.popupRef=Dt(),this._showPopup=!1,this._popupStyle={},this.key="",this.config=Ft,this.isBgLight=!0,this.onChange=()=>{},this.popupStyle=Zt,this.renderPopup=({html:e,key:t,config:n,isBgLight:i,popupStyle:o=this.popupStyle})=>{const{type:s,title:r,description:a,isEditable:l,renderDescription:c}=n;return e`<div>
      <div class="">
        <span>${s}</span>
        <span style="color: ${o.textColor}">${r??t}</span>
      </div>
      <div style="color: ${o.textColor}">
        ${a||l?e`<hr
              class="popup-line-break"
              style="border-color: ${o.textColor}"
            />`:""}
        <annotative-code-knob
          .key=${t}
          .config=${n}
          .popupStyle=${o}
          .onChange=${this.onChange}
        ></annotative-code-knob>
        <div class="popup-description">${c?c({html:e,key:t,config:n,isBgLight:i,popupStyle:o}):a?e`${a}`:""}</div>
      </div>
    </div>`}}async _togglePopup(){const e=this.annotationRef;if(!e.value)return;if(this._showPopup)return this._showPopup=!1,void(e.value.offsetParent.style.zIndex="100");const{style:t}=(e=>{const{x:t,y:n,width:i,height:o}=e.getBoundingClientRect(),s=window.innerWidth<640,r=(n+o/2)/window.innerHeight>.5?"bottom":"top",a=(t+i/2)/window.innerWidth>.5?"right":"left",l=`${r}-${a}`;return s?{pos:l,style:{[r]:o+"px",left:18-t-8+"px",width:"calc(100vw - 36px)"},isSmall:s}:{pos:`${r}-${a}`,style:"top-left"===l?{top:o+"px",left:0}:"top-right"===l?{top:o+"px",right:0}:"bottom-left"===l?{bottom:o+"px",left:0}:{bottom:o+"px",right:0},isSmall:s}})(e.value);this._showPopup=!0,this._popupStyle=t,e.value.offsetParent.style.zIndex="110"}render(){const e={...Ft,...this.config},{animation:t,value:n,formatValue:i,renderPopup:o=this.renderPopup}=e;return st`<div
      ${Gt(this.annotationRef)}
      id="annotation"
      class=${qt({...t?{[t]:!0}:null})}
      @mouseover=${this._togglePopup}
      @mouseout=${this._togglePopup}
    >
      <div>${i?i(n):n}</div>
      <div
        id="popup"
        ${Gt(this.popupRef)}
        class=${qt({"fade-in":this._showPopup})}
        style=${Nt(this._popupStyle)}
      >
        <div
          id="popup-inner"
          style=${Nt({"color-scheme":this.isBgLight?"dark":"light","background-color":this.popupStyle.backgroundColor,border:`1px solid ${this.popupStyle.borderColor}`})}
        >
          ${o({html:st,key:this.key,config:e,isBgLight:this.isBgLight,popupStyle:this.popupStyle})}
        </div>
      </div>
    </div>`}}un.styles=[Jt,Yt,Qt,s`
      :host {
        position: relative;
        display: inline-block;
        vertical-align: top;
        white-space: initial;
        cursor: pointer;
        z-index: 100;
        overflow: visible;
      }
      #annotation {
        position: relative;
        display: inline-block;
        vertical-align: top;
        padding: 0px 4px;
      }
      div.background {
        border-radius: 4px;
        animation: background-animation 1s infinite alternate-reverse;
      }
      div.underline {
        animation: underline-animation 1s infinite alternate-reverse;
      }
    `],dn([A({state:!0})],un.prototype,"_showPopup",void 0),dn([A({state:!0})],un.prototype,"_popupStyle",void 0),dn([A({attribute:"key"})],un.prototype,"key",void 0),dn([A({attribute:"config"})],un.prototype,"config",void 0),dn([A({attribute:"isBgLight"})],un.prototype,"isBgLight",void 0),dn([A({attribute:"onChange"})],un.prototype,"onChange",void 0),dn([A({attribute:"popupStyle"})],un.prototype,"popupStyle",void 0),dn([A({attribute:"renderPopup"})],un.prototype,"renderPopup",void 0),customElements.get("annotative-code-annotation")||customElements.define("annotative-code-annotation",un);var gn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class fn extends xt{constructor(){super(...arguments),this.popupStyle=Zt,this.value=""}render(){return st`<textarea
      style=${Nt({color:this.popupStyle.textColor,border:`1px solid ${this.popupStyle.inputBorderColor}`,"min-width":"200px","border-radius":"4px",width:"calc(100% - 8px - 8px)","margin-top":"8px",resize:"vertical"})}
      .value=${this.value}
    ></textarea>`}}fn.styles=[nn],gn([A({attribute:"popupStyle"})],fn.prototype,"popupStyle",void 0),gn([A({attribute:"value"})],fn.prototype,"value",void 0),customElements.get("annotative-code-knob-textarea")||customElements.define("annotative-code-knob-textarea",fn);const bn=rt`<svg
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-x"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M18 6l-12 12" />
<path d="M6 6l12 12" />
</svg>`;var yn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};class vn extends xt{constructor(){super(),this.annotativeInnerRef=Dt(),this.parentStyle=Xt,this._showPopup=!1,this._copyValue="",this.contentsWithAnnotations=[],this.content="",this.annotation={},this.themeCss="",this.annotationMask="{{{{____annotation____}}}}",this.encloser="____",this.styleMap={},this._computeNewValueObj=(e,t)=>Object.entries(this.annotation).reduce(((n,i)=>{const[o,s]=i;return{...n,[o]:o===e?t:s.value}}),{}),this._onChange=(e,t)=>{const n=t.target,i=this.annotation[e],o="boolean"===i.type?n.checked:"number"===i.type?parseFloat(n.value?.replace(/[^\d.-]/g,"")):"integer"===i.type?parseInt(n.value?.replace(/[^\d.-]/g,"")):n.value,s=this._computeNewValueObj(e,o);this.annotation={...this.annotation,[e]:{...this.annotation[e],value:o}};const r={updatedKey:e,valueObj:s};this.onValueChange?this.onValueChange({detail:r}):this.dispatchEvent(new CustomEvent("valuechange",{detail:r,bubbles:!0,composed:!0}))},this._onTriggerCopyPopup=e=>{if(e.stopPropagation(),!this._showPopup){const e=this._computeNewValueObj(),t=Object.entries(e).reduce(((e,t)=>{const[n,i]=t,o=`${this.encloser}${n}${this.encloser}`;return e.replaceAll(o,i)}),this.content);this._copyValue=t,window.navigator.clipboard.writeText(t)}this._showPopup=!this._showPopup}}async _loadAndHighlightSyntax(){}async _loadCss(){this.parentStyle=this._getComputedStyle(this.annotativeInnerRef),this.requestUpdate()}updated(e){const t=new Map(e);t.delete("contentsWithAnnotations"),t.delete("themeCss"),t.delete("parentStyle"),t.size>0&&this._loadAndHighlightSyntax(),e.has("themeCss")&&this._loadCss()}_getComputedStyle(e){return{backgroundColor:(window&&e?.value?window.getComputedStyle(e.value):{}).backgroundColor||""}}connectedCallback(){super.connectedCallback(),this._handleResize=()=>{const e=this._getComputedStyle(this.annotativeInnerRef);this.parentStyle=e},window.addEventListener("resize",this._handleResize),setTimeout(this._handleResize,1)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize)}_insertAnnotationKeysAndGetKeyIndexes(e={}){const t=Object.keys(e);let n=this.content,i=[];for(let e=0;e<t.length;e++){const r=t[e],a=`${this.encloser}${r}${this.encloser}`,l=(o=this.content,s=a,[...o.matchAll(new RegExp("\\b"+s+"\\b","gi"))].map((e=>e.index)));i=[...i,...l.map((e=>({annotationKey:r,index:e})))],n=n.replaceAll(a,this.annotationMask)}var o,s;return i=i.sort(((e,t)=>e.index-t.index)),{contentWithAnnotations:n,keyIndexes:i}}_highlight(e){return He.highlight(e,{language:"language"}).value}_createContentsWithAnnotations(){const e=this.annotation||{};let{contentWithAnnotations:t,keyIndexes:n}=this._insertAnnotationKeysAndGetKeyIndexes(e),i=[],o=this._highlight(t).split(this.annotationMask),s=o.map((e=>{return n='class="',i='">',(t=e).lastIndexOf("</span>")>t.lastIndexOf('">')?"":Vt(t,n,i);var t,n,i}));s.pop();for(let t=0;t<o.length;t++){const r=o[t];if(i.push((0!==t?`<span class="${s[t-1]}">`:"")+r+"</span>"),t!==o.length-1){const{annotationKey:o,index:s}=n[t];i.push({key:o,config:e[o]})}}return i}render(){const e=this.parentStyle,t=(e=>{const t=e.startsWith("rgba(")?"rgba(":"rgb(";return parseInt(Vt(e,t,","))<127.5})(e.backgroundColor),n=t?"rgb(237, 237, 237)":"rgb(18, 18, 18)",i=Kt(n),o={backgroundColor:Kt(e.backgroundColor,8),borderColor:Kt(e.backgroundColor,24),textColor:n,inputBorderColor:i},s={backgroundColor:o.backgroundColor,borderColor:o.borderColor,color:o.textColor};return st`
      <div id="annotative-code">
        <style>
          ${this.themeCss}
        </style>
        <div
          id="annotative-code-inner"
          ${Gt(this.annotativeInnerRef)}
          class="hljs"
          style="${Nt(this.styleMap??{})}"
          @click=${()=>this._showPopup=!1}
        >${this.contentsWithAnnotations?.map((e=>{const{key:n,config:i}=e;return n?st`<span
                class="hljs-${s=i.type,{boolean:"literal",integer:"number"}[s]||s} annotative-code-annotation-container"
              >
                <annotative-code-annotation
                  .key="${n}"
                  .config="${i}"
                  .isBgLight=${t}
                  .popupStyle=${o}
                  .onChange="${this._onChange}"
                />
              </span>`:Rt(e);var s}))}</div>
        <div
          id="copy-button"
          style="${Nt({backgroundColor:o.borderColor,color:o.textColor})}"
          @click=${this._onTriggerCopyPopup}
        >
          Copy
        </div>
        <div
          id="copy-popup"
          class="${this._showPopup?"show":""}"
          style="${Nt(s)}"
        >
          <div class="inner">
            <div class="copy">Copied</div>
            <div>
              <annotative-code-knob-textarea
                .popupStyle=${o}
                .value=${this._copyValue}
              />
            </div>
          </div>
          <div class="close" @click=${this._onTriggerCopyPopup}>${bn}</div>
        </div>
      </div>
    `}}vn.styles=[s`
      #annotative-code {
        position: relative;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
          Liberation Mono, Courier New, monospace;
      }
      #annotative-code-inner {
        position: relative;
        white-space: pre;
        text-wrap: wrap;
        line-height: 1.25;
      }
      .annotative-code-annotation-container {
        display: inline-block;
        white-space: initial;
      }

      #copy-button {
        position: absolute;
        top: 0;
        right: 0;
        padding: 4px 6px;
        cursor: pointer;
      }

      #copy-popup {
        position: absolute;
        top: 32px;
        right: 6px;
        width: 0;
        border-radius: 12px;
        overflow: hidden;
      }

      #copy-popup.show {
        width: 240px;
        padding: 4px;
      }

      #copy-popup .inner {
        padding: 6px;
      }

      #copy-popup .inner .copy {
        padding-bottom: 6px;
        border-bottom: 1px solid;
      }

      #copy-popup .inner .icons div {
        padding: 6px;
        border: 1px solid;
        width: 24px;
        height: 24px;
      }

      #copy-popup .close {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 24px;
        height: 24px;
        cursor: pointer;
      }
    `],yn([A()],vn.prototype,"parentStyle",void 0),yn([E()],vn.prototype,"_showPopup",void 0),yn([E()],vn.prototype,"_copyValue",void 0),yn([E()],vn.prototype,"hljs",void 0),yn([E()],vn.prototype,"contentsWithAnnotations",void 0),yn([A({attribute:!1})],vn.prototype,"languageFn",void 0),yn([A({attribute:"content"})],vn.prototype,"content",void 0),yn([A({attribute:!1})],vn.prototype,"annotation",void 0),yn([A({attribute:"themeCss"})],vn.prototype,"themeCss",void 0),yn([A({attribute:"annotationMask"})],vn.prototype,"annotationMask",void 0),yn([A({attribute:"encloser"})],vn.prototype,"encloser",void 0),yn([A({attribute:!1})],vn.prototype,"styleMap",void 0),yn([A({attribute:!1})],vn.prototype,"onValueChange",void 0);var mn=function(e,t,n,i){var o,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,n,r):o(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r};let _n=class extends vn{constructor(){super(),this.hljs=He}async _loadAndHighlightSyntax(){this.languageFn&&(this.hljs.registerLanguage("language",this.languageFn),this.contentsWithAnnotations=super._createContentsWithAnnotations(),this.requestUpdate())}};_n=mn([(e=>(t,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)})("annotative-code")],_n);export{_n as AnnotativeCode};
