import*as e from"lit/directives/style-map.js";import*as t from"lit";import*as r from"lit/directives/if-defined.js";import*as o from"lit/directives/class-map.js";import*as i from"highlight.js/lib/core";import*as a from"lit/decorators.js";var s,n,p,l,c,f={1156(t,r,o){var i,a;t.exports=(i={styleMap:()=>e.styleMap},a={},o.d(a,i),a)},2364(e,t,r){new WeakMap},2927(e,r,o){var i,a;e.exports=(i={LitElement:()=>t.LitElement,css:()=>t.css,html:()=>t.html,nothing:()=>t.nothing},a={},o.d(a,i),a)},3517(e,t,o){var i,a;e.exports=(i={ifDefined:()=>r.ifDefined},a={},o.d(a,i),a)},4955(e,t,r){var i,a;e.exports=(i={classMap:()=>o.classMap},a={},r.d(a,i),a)},6436(e,t,r){r.d(t,{b:()=>o}),r(5983);var o,i=r(7704),a=r(4084),s=r(6579),n=r(2927),p=r(8899),l=r(3517),c=r(3241),f=function(e,t,r,o){var i,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(s=(a<3?i(s):a>3?i(t,r,s):i(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s},u=function(e,t,r,o){return new(r||(r=Promise))(function(i,a){function s(e){try{p(o.next(e))}catch(e){a(e)}}function n(e){try{p(o.throw(e))}catch(e){a(e)}}function p(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,n)}p((o=o.apply(e,t||[])).next())})};!function(e){let t=class extends n.LitElement{constructor(){super(...arguments),this.acceptLanguage="javascript",this.getLocalization="Input File",this.acceptTypes="",this.fileName=""}static get styles(){return[a.A,c.A]}triggerFileLoad(e){e.preventDefault(),this.input.click()}handleFile(e){return u(this,void 0,void 0,function*(){e.preventDefault();const t=this.input.files;if(t&&0!==t.length)for(const e of t){this.fileName=e.name;try{yield this.readFile(e)}catch(e){console.error("Error reading file",e)}}})}readFile(e){return new Promise((t,r)=>{const o=new FileReader;o.onload=e=>{t(e.target.result)},o.onerror=e=>r(e),o.readAsText(e)})}importLanguage(e){return u(this,void 0,void 0,function*(){try{const{default:t}=yield r(2908)(`./${e}`);s.default.registerLanguage(`${e}`,t),this.setAcceptTypes()}catch(e){console.warn("Please set correct language name")}})}getAllAcceptTypes(){const e=s.default.listLanguages();return e.length?e.map(e=>s.default.getLanguage(`${e}`).aliases).map(e=>e.map(e=>`.${e}`)).join(","):""}setAcceptTypes(){this.acceptTypes=this.getAllAcceptTypes()}updated(e){super.updated(e),e.has("acceptLanguage")&&this.importLanguage(this.acceptLanguage)}render(){return n.html`
        <div class="md-input-file">
          <label for="file-input">
            <md-button color="blue" class="md-input-file-btn" @click=${this.triggerFileLoad}>
              ${this.getLocalization.trim()}
            </md-button>
            ${this.fileName.length?this.fileName:n.nothing}
          </label>
          <input
            type="file"
            id="file-input"
            name="file-input"
            accept=${(0,l.ifDefined)(this.acceptTypes||void 0)}
            @change=${e=>this.handleFile(e)}
          />
        </div>
      `}};f([(0,p.property)({type:String,attribute:"accept-language"})],t.prototype,"acceptLanguage",void 0),f([(0,p.property)({type:String})],t.prototype,"getLocalization",void 0),f([(0,p.query)("input[type='file']")],t.prototype,"input",void 0),f([(0,p.state)()],t.prototype,"acceptTypes",void 0),f([(0,p.state)()],t.prototype,"fileName",void 0),t=f([(0,i.wW)("md-input-file")],t),e.ELEMENT=t}(o||(o={}))},6579(e,t,r){var o,a;e.exports=(o={default:()=>i.default},a={},r.d(a,o),a)},7704(e,t,r){r.d(t,{wW:()=>o.w}),r(2364),r(3203),r(9938),r(5201),r(4781),r(608);var o=r(9609)},8899(e,t,r){var o,i;e.exports=(o={property:()=>a.property,query:()=>a.query,state:()=>a.state},i={},r.d(i,o),i)}},u={};function m(e){var t=u[e];if(void 0!==t)return t.exports;var r=u[e]={exports:{}};return f[e](r,r.exports,m),r.exports}m.m=f,s=[],m.O=(e,t,r,o)=>{if(!t){var i=1/0;for(l=0;l<s.length;l++){for(var[t,r,o]=s[l],a=!0,n=0;n<t.length;n++)(!1&o||i>=o)&&Object.keys(m.O).every(e=>m.O[e](t[n]))?t.splice(n--,1):(a=!1,o<i&&(i=o));if(a){s.splice(l--,1);var p=r();void 0!==p&&(e=p)}}return e}o=o||0;for(var l=s.length;l>0&&s[l-1][2]>o;l--)s[l]=s[l-1];s[l]=[t,r,o]},p=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,m.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var r=Object.create(null);m.r(r);var o={};n=n||[null,p({}),p([]),p(p)];for(var i=2&t&&e;("object"==typeof i||"function"==typeof i)&&!~n.indexOf(i);i=p(i))Object.getOwnPropertyNames(i).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,m.d(r,o),r},m.d=(e,t)=>{for(var r in t)m.o(t,r)&&!m.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},m.f={},m.e=e=>Promise.all(Object.keys(m.f).reduce((t,r)=>(m.f[r](e,t),t),[])),m.u=e=>"chunks/md-"+e+".js",m.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),m.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},m.p="/";export{m as __webpack_require__};l={502:0,561:0,1745:0,2364:0,2942:0,4545:0,4928:0,5323:0,5369:0,6060:0,7032:0,7704:0,8111:0,8180:0,8442:0,9983:0},c=e=>{var t,r,{__webpack_esm_ids__:o,__webpack_esm_modules__:i,__webpack_esm_runtime__:a}=e,s=0;for(t in i)m.o(i,t)&&(m.m[t]=i[t]);for(a&&a(m);s<o.length;s++)r=o[s],m.o(l,r)&&l[r]&&l[r][0](),l[o[s]]=0;m.O()},m.f.j=(e,t)=>{var r=m.o(l,e)?l[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var o=import(m.p+m.u(e)).then(c,t=>{throw 0!==l[e]&&(l[e]=void 0),t});o=Promise.race([o,new Promise(t=>r=l[e]=[t])]),t.push(r[1]=o)}},m.C=c,m.O.j=e=>0===l[e];import*as d from"../9609.js";m.C(d);import*as g from"../4084.js";m.C(g);import*as h from"../3305.js";m.C(h);import*as y from"../4739.js";m.C(y);import*as v from"../7154.js";m.C(v);import*as j from"../9773.js";m.C(j);import*as b from"../5983.js";m.C(b);import*as _ from"../9938.js";m.C(_);import*as O from"../4781.js";m.C(O);import*as w from"../5201.js";m.C(w);import*as L from"../8227.js";m.C(L);import*as x from"../2900.js";m.C(x);import*as C from"../3203.js";m.C(C);import*as P from"../5734.js";m.C(P);var T=m.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9938,4781,5201,8227,2900,3203,5734],()=>m(6436));const k=(T=m.O(T)).b;export{k as InputFile};