text: (()=>{"use strict";var e={5059:(e,t,n)=>{var r=n(3935),a=n(7294),o=n(9669),l=n.n(o),c=n(2692),i=n(4599),u=n(3987),s=n(3520),f=n(1718);function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const b=function(e){var t=e.keyName,n=e.value,r=e.refFunction,o=void 0===r?null:r,l=m((0,a.useState)(!1),2),c=l[0],i=l[1],u=m((0,a.useState)(""),2),s=u[0],f=u[1];(0,a.useEffect)((function(){f(n)}),[n]);var d=function(){i(!1),null!==o&&o(function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},t,s))};return a.createElement("tr",null,a.createElement("td",null,t),a.createElement("td",null,c?a.createElement("form",{onSubmit:function(e){e.preventDefault(),d()}},a.createElement("input",{onChange:function(e){return f(e.target.value)},value:s,placeholder:"Change the setting",type:"text",className:"form-control default-input",style:{fontSize:"medium",paddingLeft:10,backgroundColor:"#AAAAAA",color:"#000000"},"aria-label":"Change the setting","aria-describedby":"Change the setting",autoFocus:!0})):a.createElement("span",null,n)),a.createElement("td",null,c?a.createElement("button",{onClick:function(){return d()},className:"btn btn-sm btn-light"},"Save"):a.createElement("button",{onClick:function(){return i(!0)},className:"btn btn-sm btn-outline-light"},"Change")))};var h=n(5211),y=n(1388),v=n(6210);function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const E=function(e){var t=e.settings,n=e.fetchSettings,r=p((0,a.useState)(""),2),o=r[0],i=r[1],s=p((0,a.useState)(""),2),f=s[0],m=s[1],d=function(e){m(""),(0,v.xb)(e)||l().post("/panel/api/global-settings",{dotenv:e},{headers:{"X-CSRFToken":(0,h.m)()}}).then((function(t){m("".concat(Object.keys(e)[0]," setting has been saved.")),setTimeout((function(){return n()}),2e3)})).catch((function(e){i((0,c.b)(e))}))};return a.createElement("div",null,a.createElement("h2",null,"Environment Settings"),a.createElement("h4",{style:{color:"#FFFF00"}},"Changing these settings may cause the system to not work properly. Be very cautious."),a.createElement("p",null,"Some of these settings requires the system to be restarted in order to take affect."),function(){if(""!==o)return a.createElement(u.Z,null,o)}(),function(){if(""!==f)return a.createElement(y.Z,null,f)}(),a.createElement("table",{className:"table table-dark table-hover"},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",{scope:"col"},"Setting"),a.createElement("th",{scope:"col"},"Value"),a.createElement("th",{scope:"col"},"Action"))),function(){if(void 0!==t&&!(0,v.xb)(t))return a.createElement("tbody",null,Object.keys(t).map((function(e,n){return a.createElement(b,{key:n,keyName:e,value:t[e],refFunction:d})})))}()))};function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||A(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){if(e){if("string"==typeof e)return w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const C=function(){var e=S((0,a.useState)(!1),2),t=e[0],n=e[1],r=S((0,a.useState)([]),2),o=r[0],i=r[1],s=S((0,a.useState)([]),2),f=s[0],m=s[1],d=S((0,a.useState)(""),2),b=d[0],v=d[1],p=S((0,a.useState)(""),2),g=p[0],E=p[1],C=S((0,a.useState)(""),2),k=C[0],N=C[1];(0,a.useEffect)((function(){x()}),[]);var x=function(){l().get("/api/movies").then((function(e){e.data&&e.data.movies&&m(e.data.movies),n(!0)})).catch((function(e){n(!0),v((0,c.b)(e)),console.error(e)}))},j=function(e){return void 0!==o.find((function(t){return t===e}))};return a.createElement("div",null,a.createElement("h2",null,"Re-download subtitles"),a.createElement("h4",{style:{color:"#FFFF00"}},"This is an intensive operation. Be cautious."),a.createElement("div",{className:"container my-4"},a.createElement("h4",{style:{display:"inline-block"}},o.length," Selected  ",0!==o.length?a.createElement("button",{onClick:function(){return E(""),v(""),console.log("redownloading..."),void l().post("/panel/api/redownload-subtitles",{movieIds:o},{headers:{"X-CSRFToken":(0,h.m)()}}).then((function(e){E("Subtitles are being re-downloaded.")})).catch((function(e){v((0,c.b)(e))}))},className:"btn btn-sm btn-outline-light mx-2 mb-2"},"Redownload Subtitles"):null)),function(){if(""!==b)return a.createElement(u.Z,null,b)}(),function(){if(""!==g)return a.createElement(y.Z,null,g)}(),a.createElement("div",{style:{maxWidth:700,paddingBottom:10},className:"d-flex justify-content-end"},a.createElement("input",{onChange:function(e){return N(e.target.value)},value:k,placeholder:"Search a movie",type:"text",className:"form-control default-input",style:{paddingLeft:10},"aria-label":"Search a movie","aria-describedby":"Search a movie",autoFocus:!0}),a.createElement("button",{onClick:function(){return i([])},className:"btn btn-dark btn-sm mx-2"},"Select None"),a.createElement("button",{onClick:function(){var e=[];f.map((function(t){return e.push(t.id)})),i(e.slice())},className:"btn btn-dark btn-sm"},"Select All")),t?0===f.length?a.createElement("h2",null,"No movies"):a.createElement("div",null,f.filter((function(e){return e.title.toLowerCase().includes(k.toLowerCase())})).map((function(e){return a.createElement("div",{key:e.id,onClick:function(){var t,n;j(e.id)?function(e){if(j(e)){var t=o,n=t.indexOf(e);n>-1&&t.splice(n,1),i(t.slice())}}(e.id):(t=e.id,o.find((function(e){return e===t}))||i([].concat(function(e){if(Array.isArray(e))return w(e)}(n=o)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(n)||A(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[t])))},className:"d-flex justify-content-between px-3 py-2 border-bottom",style:{backgroundColor:j(e.id)?"#828282":"#232323",maxWidth:700}},a.createElement("div",{style:{display:"inline"}},a.createElement("input",{type:"checkbox",checked:j(e.id),readOnly:!0,onClick:function(){return null}}),"  ",a.createElement("a",{title:"Add ".concat(e.title)},e.title)),a.createElement("span",null,e.release_date.slice(0,4)))}))):a.createElement("h2",null,"Loading..."))};var k=n(18),N=n(2188);const x=function(e){var t=e.source,n=e.deleteFunc;return a.createElement(a.Fragment,null,a.createElement("div",{className:"row mb-3"},a.createElement("div",{className:"col"},t.name),a.createElement("div",{className:"col-1"},a.createElement(N.Z,{title:"Delete the source?",body:"Are you sure you want to delete this source?",buttonText:"Delete",refFunc:n,refFuncArgs:{sourceId:t.id}},a.createElement("button",{className:"btn btn-secondary btn-sm",onClick:function(){return null}},a.createElement(k.TrashSvg,{width:16,height:16}))))),a.createElement("div",{className:"row"},a.createElement("hr",null)))};var j=n(3094);function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const T=function(e){var t=e.setPage,n=void 0===t?null:t,r=I((0,a.useState)(""),2),o=r[0],i=r[1],s=I((0,a.useState)(""),2),f=s[0],m=s[1],d=I((0,a.useState)(""),2),b=d[0],v=d[1],p=I((0,a.useState)(""),2),g=p[0],E=(p[1],I((0,a.useState)(!1),2)),S=E[0],A=E[1];return(0,a.useEffect)((function(){if(v(""),""!==f)try{(0,j.checkMudSchema)(JSON.parse(f)),""!==o&&A(!0)}catch(e){v((0,c.b)(e)),A(!1)}""===o&&A(!1)}),[f,o]),a.createElement("div",null,a.createElement("button",{onClick:function(){return null!==n&&n("list")},className:"btn btn-sm btn-secondary mb-3"},a.createElement("div",{className:"d-flex align-items-center"},a.createElement(k.ArrowLeftCircleSvg,null),"  Go back to the list")),a.createElement("div",{className:"my-1"},"You can find sources at"," ",a.createElement("a",{href:"https://vigiliosources.docaine.com",target:"_blank"},"Vigilio sources"),". Be cautious of the contents of the sources since they may include illegal content."),a.createElement("div",{className:"my-2"},function(){if(""!==b)return a.createElement(u.Z,null,b)}(),function(){if(""!==g)return a.createElement(y.Z,null,g)}()),a.createElement("input",{onChange:function(e){return i(e.target.value)},value:o,placeholder:"*Give a name to this source",type:"text",className:"form-control default-input","aria-label":"Give a name to the source","aria-describedby":"Give a name to the source",autoFocus:!0}),a.createElement("textarea",{onChange:function(e){return m(e.target.value)},value:f,className:"form-control default-input my-2",name:"Schema",cols:"40",rows:"1",placeholder:"*Copy the source","aria-label":"Copy the source","aria-describedby":"Copy the source",style:{width:"100%"},required:!0,id:"id_schema"}," "),a.createElement("button",{className:"btn btn-light "+(S?"":"disabled"),onClick:function(){return function(){if(""!==o&&""!==f){try{(0,j.checkMudSchema)(JSON.parse(f))}catch(e){return}l().post("/panel/api/mud-sources",{name:o,source:f},{headers:{"X-CSRFToken":(0,h.m)()}}).then((function(e){n("list")})).catch((function(e){console.log(e),v((0,c.b)(e))}))}}()}},"Save"))};function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const P=function(){var e=F((0,a.useState)(!1),2),t=e[0],n=e[1],r=F((0,a.useState)([]),2),o=r[0],i=r[1],s=F((0,a.useState)(""),2),f=s[0],m=s[1],d=F((0,a.useState)(""),2),b=d[0],v=d[1],p=F((0,a.useState)("list"),2),g=p[0],E=p[1];(0,a.useEffect)((function(){S()}),[g]);var S=function(){l().get("/panel/api/mud-sources").then((function(e){i(e.data),n(!0)})).catch((function(e){m((0,c.b)(e)),n(!0)}))},A=function(e){var t=e.sourceId;if(null==t)return console.log("Source ID ".concat(t," is invalid.")),void m("Could not delete the source.");l().delete("/panel/api/mud-source/".concat(t),{headers:{"X-CSRFToken":(0,h.m)()}}).then((function(e){v("The source has been deleted."),S()})).catch((function(e){console.log(e),m((0,c.b)(e))}))};return a.createElement("div",null,t?"add"===g?a.createElement(T,{setPage:E}):0===o.length?a.createElement("div",{className:"container-fluid"},a.createElement("button",{className:"btn btn-sm btn-secondary mb-3",onClick:function(){return E("add")}},a.createElement("div",{className:"d-flex align-items-center"},a.createElement(k.PlusSvg,null)," Add a source")),a.createElement("h2",null,"There are no sources")):a.createElement("div",null,function(){if(""!==f)return a.createElement(u.Z,null,f)}(),function(){if(""!==b)return a.createElement(y.Z,null,b)}(),a.createElement("div",{className:"container-fluid"},a.createElement("button",{className:"btn btn-sm btn-secondary mb-3",onClick:function(){return E("add")}},a.createElement("div",{className:"d-flex align-items-center"},a.createElement(k.PlusSvg,null)," Add a source")),a.createElement("h3",null,"Existing sources")),a.createElement("hr",null),a.createElement("div",{className:"container-fluid"},o.map((function(e){return a.createElement(x,{key:e.id,source:e,deleteFunc:A})})))):a.createElement("h2",null,"Loading..."))};function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const L=function(e){var t,n,r=e.fetchSettings,o=e.settings,l=["Environment Settings","Search Sources","Subtitle Languages","Redownload Subtitles"],c=(t=(0,a.useState)((0,v.tv)("settingsTabPref",l[0])),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(t,n)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=c[0],u=c[1];return o.dotenv&&void 0!==o.dotenv.MOVIEDB_API&&l.push("MovieDB Key"),(0,a.useEffect)((function(){(0,v.co)("settingsTabPref",i)}),[i]),a.createElement("div",null,a.createElement("ul",{className:"nav nav-tabs mb-4"},l.map((function(e){var t=e===i?"active":"";return a.createElement("li",{key:e,className:"nav-item"},a.createElement("a",{onClick:function(){return u(e)},className:"nav-link "+t,"aria-current":"page",href:"#"},e))}))),function(){switch(i){case"Environment Settings":return a.createElement(E,{fetchSettings:r,settings:o.dotenv});case"MovieDB Key":return a.createElement(s.Z,{fetchSettings:r,movieDbKey:o.dotenv&&o.dotenv.MOVIEDB_API,message:"The API Key has been stored."});case"Subtitle Languages":return a.createElement(f.Z,{fetchSettings:r,subtitles:o.dotenv&&o.dotenv.SUBTITLE_LANGS});case"Search Sources":return a.createElement(P,null);case"Redownload Subtitles":return a.createElement(C,null);default:return a.createElement(E,{fetchSettings:r,settings:o.dotenv})}}())};function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var l,c=e[Symbol.iterator]();!(r=(l=c.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var D=function(){var e=B((0,a.useState)({}),2),t=e[0],n=e[1],r=B((0,a.useState)(!1),2),o=r[0],m=r[1],d=B((0,a.useState)(""),2),b=d[0],h=d[1];(0,a.useEffect)((function(){y()}),[]);var y=function(){l().get("/panel/api/global-settings").then((function(e){n(e.data),m(!0)})).catch((function(e){console.log(e),h((0,c.b)(e)),m(!0)}))};return a.createElement("div",{className:"mb-5"},function(){if(""!==b)return a.createElement(u.Z,null,b)}(),!o&&(0,v.xb)(t)?a.createElement("h3",null,"Loading..."):o&&(0,v.xb)(t)?a.createElement("h3",null,"There is a problem. No settings are fetched."):t.forcePasswordChange?a.createElement(i.Z,null):t.dotenv&&""===t.dotenv.MOVIEDB_API?a.createElement(s.Z,{fetchSettings:y,message:"The API Key has been stored. Moving to the next step."}):t.dotenv&&""===t.dotenv.SUBTITLE_LANGS?a.createElement(f.Z,{fetchSettings:y}):a.createElement(L,{fetchSettings:y,settings:t}))};(0,r.render)(a.createElement(D,null),document.getElementById("root"))}},t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.m=e,n.x=e=>{},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.j=265,(()=>{var e={265:0},t=[[5059,622]],r=e=>{},a=(a,o)=>{for(var l,c,[i,u,s,f]=o,m=0,d=[];m<i.length;m++)c=i[m],n.o(e,c)&&e[c]&&d.push(e[c][0]),e[c]=0;for(l in u)n.o(u,l)&&(n.m[l]=u[l]);for(s&&s(n),a&&a(o);d.length;)d.shift()();return f&&t.push.apply(t,f),r()},o=self.webpackChunkfrontend=self.webpackChunkfrontend||[];function l(){for(var r,a=0;a<t.length;a++){for(var o=t[a],l=!0,c=1;c<o.length;c++){var i=o[c];0!==e[i]&&(l=!1)}l&&(t.splice(a--,1),r=n(n.s=o[0]))}return 0===t.length&&(n.x(),n.x=e=>{}),r}o.forEach(a.bind(null,0)),o.push=a.bind(null,o.push.bind(o));var c=n.x;n.x=()=>(n.x=c||(e=>{}),(r=l)())})(),n.x()})();