chrome-devtools-frontend
Version:
Chrome DevTools UI
50 lines (49 loc) • 15.3 kB
JavaScript
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const t=globalThis,e=t=>t,s=t.trustedTypes,i=s?s.createPolicy("lit-html",{createHTML:t=>t}):void 0,n="$lit$",r=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+r,h=`<${o}>`,l=document,c=()=>l.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,u=t=>d(t)||"function"==typeof t?.[Symbol.iterator],$="[ \t\n\f\r]",_=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A=/-->/g,f=/>/g,p=RegExp(`>|${$}(?:([^\\s"'>=/]+)(${$}*=${$}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),v=/'/g,g=/"/g,y=/^(?:script|style|textarea|title)$/i,m=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),C=new WeakMap,x=l.createTreeWalker(l,129);function w(t,e){if(!d(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==i?i.createHTML(e):e}const H=(t,e)=>{const s=t.length-1,i=[];let o,l=2===e?"<svg>":3===e?"<math>":"",c=_;for(let e=0;e<s;e++){const s=t[e];let a,d,u=-1,$=0;for(;$<s.length&&(c.lastIndex=$,d=c.exec(s),null!==d);)$=c.lastIndex,c===_?"!--"===d[1]?c=A:void 0!==d[1]?c=f:void 0!==d[2]?(y.test(d[2])&&(o=RegExp("</"+d[2],"g")),c=p):void 0!==d[3]&&(c=p):c===p?">"===d[0]?(c=o??_,u=-1):void 0===d[1]?u=-2:(u=c.lastIndex-d[2].length,a=d[1],c=void 0===d[3]?p:'"'===d[3]?g:v):c===g||c===v?c=p:c===A||c===f?c=_:(c=p,o=void 0);const m=c===p&&t[e+1].startsWith("/>")?" ":"";l+=c===_?s+h:u>=0?(i.push(a),s.slice(0,u)+n+s.slice(u)+r+m):s+r+(-2===u?e:m)}return[w(t,l+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class N{constructor({strings:t,_$litType$:e},i){let h;this.parts=[];let l=0,a=0;const d=t.length-1,u=this.parts,[$,_]=H(t,e);if(this.el=N.createElement($,i),x.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(h=x.nextNode())&&u.length<d;){if(1===h.nodeType){if(h.hasAttributes())for(const t of h.getAttributeNames())if(t.endsWith(n)){const e=_[a++],s=h.getAttribute(t).split(r),i=/([.?@])?(.*)/.exec(e);u.push({type:1,index:l,name:i[2],strings:s,ctor:"."===i[1]?G:"?"===i[1]?U:"@"===i[1]?I:E}),h.removeAttribute(t)}else t.startsWith(r)&&(u.push({type:6,index:l}),h.removeAttribute(t));if(y.test(h.tagName)){const t=h.textContent.split(r),e=t.length-1;if(e>0){h.textContent=s?s.emptyScript:"";for(let s=0;s<e;s++)h.append(t[s],c()),x.nextNode(),u.push({type:2,index:++l});h.append(t[e],c())}}}else if(8===h.nodeType)if(h.data===o)u.push({type:2,index:l});else{let t=-1;for(;-1!==(t=h.data.indexOf(r,t+1));)u.push({type:7,index:l}),t+=r.length-1}l++}}static createElement(t,e){const s=l.createElement("template");return s.innerHTML=t,s}}function M(t,e,s=t,i){if(e===m)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const r=a(e)?void 0:e._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=M(t,n._$AS(t,e.values),n,i)),e}class T{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??l).importNode(e,!0);x.currentNode=i;let n=x.nextNode(),r=0,o=0,h=s[0];for(;void 0!==h;){if(r===h.index){let e;2===h.type?e=new S(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new k(n,this,t)),this._$AV.push(e),h=s[++o]}r!==h?.index&&(n=x.nextNode(),r++)}return x.currentNode=l,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class S{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=M(this,t,e),a(t)?t===b||null==t||""===t?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==m&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(w(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new T(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=C.get(t.strings);return void 0===e&&C.set(t.strings,e=new N(t)),e}k(t){d(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new S(this.O(c()),this.O(c()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){const s=e(t).nextSibling;e(t).remove(),t=s}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class E{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=b}_$AI(t,e=this,s,i){const n=this.strings;let r=!1;if(void 0===n)t=M(this,t,e,0),r=!a(t)||t!==this._$AH&&t!==m,r&&(this._$AH=t);else{const i=t;let o,h;for(t=n[0],o=0;o<n.length-1;o++)h=M(this,i[s+o],e,o),h===m&&(h=this._$AH[o]),r||=!a(h)||h!==this._$AH[o],h===b?t=b:t!==b&&(t+=(h??"")+n[o+1]),this._$AH[o]=h}r&&!i&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class G extends E{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}}class U extends E{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}}class I extends E{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=M(this,t,e,0)??b)===m)return;const s=this._$AH,i=t===b&&s!==b||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==b&&(s===b||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class k{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const O={M:n,P:r,A:o,C:1,L:H,R:T,D:u,V:M,I:S,H:E,N:U,U:I,B:G,F:k},P=t.litHtmlPolyfillSupport;P?.(N,S),(t.litHtmlVersions??=[]).push("3.3.2");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const B=1,j=2,L=3,R=4,D=t=>(...e)=>({_$litDirective$:t,values:e});let W=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const V=D(class extends W{constructor(t){if(super(t),t.type!==B||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const i=!!e[t];i===this.st.has(t)||this.nt?.has(t)||(i?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return m}}),Z=t=>t??b,{I:z}=O,K=t=>t,X=t=>void 0===t.strings,Y=()=>document.createComment(""),F=(t,e,s)=>{const i=t._$AA.parentNode,n=void 0===e?t._$AB:e._$AA;if(void 0===s){const e=i.insertBefore(Y(),n),r=i.insertBefore(Y(),n);s=new z(e,r,t,t.options)}else{const e=s._$AB.nextSibling,r=s._$AM,o=r!==t;if(o){let e;s._$AQ?.(t),s._$AM=t,void 0!==s._$AP&&(e=t._$AU)!==r._$AU&&s._$AP(e)}if(e!==n||o){let t=s._$AA;for(;t!==e;){const e=K(t).nextSibling;K(i).insertBefore(t,n),t=e}}}return s},Q=(t,e,s=t)=>(t._$AI(e,s),t),q={},J=(t,e=q)=>t._$AH=e,tt=t=>{t._$AR(),t._$AA.remove()},et=D(class extends W{constructor(t){if(super(t),t.type!==L&&t.type!==B&&t.type!==R)throw Error("The `live` directive is not allowed on child or event bindings");if(!X(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===m||e===b)return e;const s=t.element,i=t.name;if(t.type===L){if(e===s[i])return m}else if(t.type===R){if(!!e===s.hasAttribute(i))return m}else if(t.type===B&&s.getAttribute(i)===e+"")return m;return J(t),e}}),st=(t,e,s)=>{const i=new Map;for(let n=e;n<=s;n++)i.set(t[n],n);return i},it=D(class extends W{constructor(t){if(super(t),t.type!==j)throw Error("repeat() can only be used in text expressions")}dt(t,e,s){let i;void 0===s?s=e:void 0!==e&&(i=e);const n=[],r=[];let o=0;for(const e of t)n[o]=i?i(e,o):o,r[o]=s(e,o),o++;return{values:r,keys:n}}render(t,e,s){return this.dt(t,e,s).values}update(t,[e,s,i]){const n=(t=>t._$AH)(t),{values:r,keys:o}=this.dt(e,s,i);if(!Array.isArray(n))return this.ut=o,r;const h=this.ut??=[],l=[];let c,a,d=0,u=n.length-1,$=0,_=r.length-1;for(;d<=u&&$<=_;)if(null===n[d])d++;else if(null===n[u])u--;else if(h[d]===o[$])l[$]=Q(n[d],r[$]),d++,$++;else if(h[u]===o[_])l[_]=Q(n[u],r[_]),u--,_--;else if(h[d]===o[_])l[_]=Q(n[d],r[_]),F(t,l[_+1],n[d]),d++,_--;else if(h[u]===o[$])l[$]=Q(n[u],r[$]),F(t,n[d],n[u]),u--,$++;else if(void 0===c&&(c=st(o,$,_),a=st(h,d,u)),c.has(h[d]))if(c.has(h[u])){const e=a.get(o[$]),s=void 0!==e?n[e]:null;if(null===s){const e=F(t,n[d]);Q(e,r[$]),l[$]=e}else l[$]=Q(s,r[$]),F(t,n[d],s),n[e]=null;$++}else tt(n[u]),u--;else tt(n[d]),d++;for(;$<=_;){const e=F(t,l[_+1]);Q(e,r[$]),l[$++]=e}for(;d<=u;){const t=n[d++];null!==t&&tt(t)}return this.ut=o,J(t,l),m}}),nt="important",rt=" !"+nt,ot=D(class extends W{constructor(t){if(super(t),t.type!==B||"style"!==t.name||t.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(t){return Object.keys(t).reduce((e,s)=>{const i=t[s];return null==i?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const i=e[t];if(null!=i){this.ft.add(t);const e="string"==typeof i&&i.endsWith(rt);t.includes("-")||e?s.setProperty(t,e?i.slice(0,-11):i,e?nt:""):s[t]=i}}return m}});
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let ht=class extends W{constructor(t){if(super(t),this.it=b,t.type!==j)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===b||null==t)return this._t=void 0,this.it=t;if(t===m)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ht.directiveName="unsafeHTML",ht.resultType=1;const lt=D(ht),ct=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ct(t,e);return!0},at=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},dt=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),_t(e)}};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function ut(t){void 0!==this._$AN?(at(this),this._$AM=t,dt(this)):this._$AM=t}function $t(t,e=!1,s=0){const i=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(i))for(let t=s;t<i.length;t++)ct(i[t],!1),at(i[t]);else null!=i&&(ct(i,!1),at(i));else ct(this,t)}const _t=t=>{t.type==j&&(t._$AP??=$t,t._$AQ??=ut)};class At extends W{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),dt(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ct(this,t),at(this))}setValue(t){if(X(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class ft{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}class pt{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const vt=t=>!(t=>null===t||"object"!=typeof t&&"function"!=typeof t)(t)&&"function"==typeof t.then,gt=1073741823;class yt extends At{constructor(){super(...arguments),this._$Cwt=gt,this._$Cbt=[],this._$CK=new ft(this),this._$CX=new pt}render(...t){return t.find(t=>!vt(t))??m}update(t,e){const s=this._$Cbt;let i=s.length;this._$Cbt=e;const n=this._$CK,r=this._$CX;this.isConnected||this.disconnected();for(let t=0;t<e.length&&!(t>this._$Cwt);t++){const o=e[t];if(!vt(o))return this._$Cwt=t,o;t<i&&o===s[t]||(this._$Cwt=gt,i=0,Promise.resolve(o).then(async t=>{for(;r.get();)await r.get();const e=n.deref();if(void 0!==e){const s=e._$Cbt.indexOf(o);s>-1&&s<e._$Cwt&&(e._$Cwt=s,e.setValue(t))}}))}return m}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const mt=D(yt),bt=()=>new Ct;
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class Ct{}const xt=new WeakMap,wt=D(class extends At{render(t){return b}update(t,[e]){const s=e!==this.G;return s&&void 0!==this.G&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),b}rt(t){if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let s=xt.get(e);void 0===s&&(s=new WeakMap,xt.set(e,s)),void 0!==s.get(this.G)&&this.G.call(this.ht,void 0),s.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return"function"==typeof this.G?xt.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});export{ht as UnsafeHTMLDirective,yt as UntilDirective,V as classMap,bt as createRef,Z as ifDefined,et as live,wt as ref,it as repeat,ot as styleMap,lt as unsafeHTML,mt as until};
//# sourceMappingURL=directives.js.map