function _(e){Object.defineProperty(e,"__esModule",{value:!0,configurable:!0})}function O(e,a,s,r){Object.defineProperty(e,a,{get:s,set:r,enumerable:!0,configurable:!0})}var R={};_(R);O(R,"default",()=>z);class z extends Error{constructor(a,s,r,m,o){super(a+":"+r+":"+m+": "+s),this.reason=s,this.filename=a,this.line=r,this.column=m,this.source=o}}var H={};_(H);O(H,"default",()=>Q);class Q{constructor(a,s,r){this.start=a,this.end=s,this.source=r}}var oe={};O(oe,"CssTypes",()=>p);var p=function(e){return e.stylesheet="stylesheet",e.rule="rule",e.declaration="declaration",e.comment="comment",e.container="container",e.charset="charset",e.document="document",e.customMedia="custom-media",e.fontFace="font-face",e.host="host",e.import="import",e.keyframes="keyframes",e.keyframe="keyframe",e.layer="layer",e.media="media",e.namespace="namespace",e.page="page",e.startingStyle="starting-style",e.supports="supports",e}({});const V=1e4,F=(e,a,s)=>{let r=s,m=V;do{const o=a.map($=>e.indexOf($,r));o.push(e.indexOf("\\",r));const g=o.filter($=>$!==-1);if(g.length===0)return-1;const c=Math.min(...g);if(e[c]==="\\")r=c+2,m--;else return c}while(m>0);throw new Error("Too many escaping")},E=(e,a,s)=>{let r=s,m=V;do{const o=a.map(u=>e.indexOf(u,r));o.push(e.indexOf("(",r)),o.push(e.indexOf('"',r)),o.push(e.indexOf("'",r)),o.push(e.indexOf("\\",r));const g=o.filter(u=>u!==-1);if(g.length===0)return-1;const c=Math.min(...g);switch(e[c]){case"\\":r=c+2;break;case"(":{const u=E(e,[")"],c+1);if(u===-1)return-1;r=u+1}break;case'"':{const u=F(e,['"'],c+1);if(u===-1)return-1;r=u+1}break;case"'":{const u=F(e,["'"],c+1);if(u===-1)return-1;r=u+1}break;default:return c}m--}while(m>0);throw new Error("Too many escaping")},ce=(e,a)=>{const s=[];let r=0;for(;r{a=a||{};let s=1,r=1;function m(n){const t=n.match(/\n/g);t&&(s+=t.length);const i=n.lastIndexOf(` `);r=~i?n.length-i:r+n.length}function o(){const n={line:s,column:r};return function(t){return t.position=new Q(n,{line:s,column:r},a?.source||""),I(),t}}const g=[];function c(n){const t=new z(a?.source||"",n,s,r,e);if(a?.silent)g.push(t);else throw t}function $(){const n=b();return{type:p.stylesheet,stylesheet:{source:a?.source,rules:n,parsingErrors:g}}}function u(){const n=/^{\s*/.exec(e);return n?(l(n),!0):!1}function y(){const n=/^}/.exec(e);return n?(l(n),!0):!1}function b(){let n;const t=[];for(I(),h(t);e.length&&e.charAt(0)!=="}"&&(n=ne()||re());)n&&(t.push(n),h(t));return t}function l(n){const t=n[0];return m(t),e=e.slice(t.length),n}function I(){const n=/^\s*/.exec(e);n&&l(n)}function h(n){let t;for(n=n||[];t=B();)t&&n.push(t);return n}function B(){const n=o();if(e.charAt(0)!=="/"||e.charAt(1)!=="*")return;const t=/^\/\*[^]*?\*\//.exec(e);return t?(l(t),n({type:p.comment,comment:t[0].slice(2,-2)})):c("End of comment missing")}function L(){const n=/^([^{]+)/.exec(e);if(!n)return;l(n);const t=x(n[0]).replace(P,"");return ce(t,[","]).map(i=>x(i))}function M(){const n=o(),t=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!t)return;l(t);const i=x(t[0]),f=/^:\s*/.exec(e);if(!f)return c("property missing ':'");l(f);let d="";const w=E(e,[";","}"]);w!==-1&&(d=e.substring(0,w),l([d]),d=x(d).replace(P,""));const v=n({type:p.declaration,property:i.replace(P,""),value:d}),S=/^[;\s]*/.exec(e);return S&&l(S),v}function N(){const n=[];if(!u())return c("missing '{'");h(n);let t;for(;t=M();)t&&(n.push(t),h(n));return y()?n:c("missing '}'")}function U(){let n;const t=[],i=o();for(;n=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);){const f=l(n);t.push(f[1]);const d=/^,\s*/.exec(e);d&&l(d)}if(t.length)return i({type:p.keyframe,values:t,declarations:N()||[]})}function W(){const n=o(),t=/^@([-\w]+)?keyframes\s*/.exec(e);if(!t)return;const i=l(t)[1],f=/^([-\w]+)\s*/.exec(e);if(!f)return c("@keyframes missing name");const d=l(f)[1];if(!u())return c("@keyframes missing '{'");let w,v=h();for(;w=U();)v.push(w),v=v.concat(h());return y()?n({type:p.keyframes,name:d,vendor:i,keyframes:v}):c("@keyframes missing '}'")}function q(){const n=o(),t=/^@supports *([^{]+)/.exec(e);if(!t)return;const i=x(l(t)[1]);if(!u())return c("@supports missing '{'");const f=h().concat(b());return y()?n({type:p.supports,supports:i,rules:f}):c("@supports missing '}'")}function D(){const n=o(),t=/^@host\s*/.exec(e);if(!t)return;if(l(t),!u())return c("@host missing '{'");const i=h().concat(b());return y()?n({type:p.host,rules:i}):c("@host missing '}'")}function G(){const n=o(),t=/^@container *([^{]+)/.exec(e);if(!t)return;const i=x(l(t)[1]);if(!u())return c("@container missing '{'");const f=h().concat(b());return y()?n({type:p.container,container:i,rules:f}):c("@container missing '}'")}function J(){const n=o(),t=/^@layer *([^{;@]+)/.exec(e);if(!t)return;const i=x(l(t)[1]);if(!u()){const d=/^[;\s]*/.exec(e);return d&&l(d),n({type:p.layer,layer:i})}const f=h().concat(b());return y()?n({type:p.layer,layer:i,rules:f}):c("@layer missing '}'")}function K(){const n=o(),t=/^@media *([^{]+)/.exec(e);if(!t)return;const i=x(l(t)[1]);if(!u())return c("@media missing '{'");const f=h().concat(b());return y()?n({type:p.media,media:i,rules:f}):c("@media missing '}'")}function X(){const n=o(),t=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!t)return;const i=l(t);return n({type:p.customMedia,name:x(i[1]),media:x(i[2])})}function Y(){const n=o(),t=/^@page */.exec(e);if(!t)return;l(t);const i=L()||[];if(!u())return c("@page missing '{'");let f=h(),d;for(;d=M();)f.push(d),f=f.concat(h());return y()?n({type:p.page,selectors:i,declarations:f}):c("@page missing '}'")}function Z(){const n=o(),t=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!t)return;const i=l(t),f=x(i[1]),d=x(i[2]);if(!u())return c("@document missing '{'");const w=h().concat(b());return y()?n({type:p.document,document:d,vendor:f,rules:w}):c("@document missing '}'")}function j(){const n=o(),t=/^@font-face\s*/.exec(e);if(!t)return;if(l(t),!u())return c("@font-face missing '{'");let i=h(),f;for(;f=M();)i.push(f),i=i.concat(h());return y()?n({type:p.fontFace,declarations:i}):c("@font-face missing '}'")}function T(){const n=o(),t=/^@starting-style\s*/.exec(e);if(!t)return;if(l(t),!u())return c("@starting-style missing '{'");const i=h().concat(b());return y()?n({type:p.startingStyle,rules:i}):c("@starting-style missing '}'")}const C=k("import"),ee=k("charset"),te=k("namespace");function k(n){const t=new RegExp("^@"+n+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return function(){const i=o(),f=t.exec(e);if(!f)return;const d=l(f),w={type:n};return w[n]=d[1].trim(),i(w)}}function ne(){if(e[0]==="@")return W()||K()||X()||q()||C()||ee()||te()||Z()||Y()||D()||j()||G()||T()||J()}function re(){const n=o(),t=L();return t?(h(),n({type:p.rule,selectors:t,declarations:N()||[]})):c("selector missing")}return A($())};function x(e){return e?e.trim():""}function A(e,a){const s=e&&typeof e.type=="string",r=s?e:a;for(const m in e){const o=e[m];Array.isArray(o)?o.forEach(g=>{A(g,r)}):o&&typeof o=="object"&&A(o,r)}return s&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:a||null}),e}var ie=se;const ae=ie,ue=(e,a,s)=>Math.min(Math.max(e,a),s),fe=async()=>await fetch("/fontawesome/css/fontawesome.min.css").then(a=>a.text()),le=await fe();function me(){const e=new Map;return ae(le).stylesheet.rules.forEach(s=>{if(s.type===p.rule){const r=s.declarations[0];if(r.type===p.declaration){if(r.property!=="--fa")return;s.selectors[0];const m=r.value.slice(1,-1);try{const o=String.fromCodePoint(parseInt(m.slice(1),16));if(!Number.isNaN(parseInt(o)))return;e.set(o,m)}catch{}}}}),e}const de=[...me().keys()],pe=new RegExp(de.map(e=>`\\${e}`).join("|"),"g"),he=e=>e.replace(pe,s=>`${s}`),ge=e=>{const a=()=>{if(e.config)return e.config?.format||void 0},s=document.createElement("span");return e.update&&setInterval(e.update,e.interval),{element:s,set:o=>{const g=a();if(!g)return console.error("No format found"),"N/A";const c=g.replace(/\{(\w+)\}/g,($,u)=>o[u]!==void 0?o[u]:$);s.innerHTML=he(c)},getIcon:(o,g,c=0)=>{const $=e.config?.["format-icons"],u=$?.length||0,y=ue(o/((c==0?100:c)/u),0,u-1),b=$?.[Math.round(y)];return b||""}}},xe=(e,a)=>{const s=ge({interval:1e3,update:()=>r(),config:a});e.element.appendChild(s.element);const r=async()=>{const m={level:Math.random(),charging:Math.random()>.5},o=m.charging,g=Math.round(m.level*100);o?e.element.classList.add("charging"):e.element.classList.remove("charging"),s.set({capacity:g,icon:s.getIcon(g)})};r()};export{xe as createBatteryModule};