!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/download/aria2-output"]=t():e["video/download/aria2-output"]=t()}(self,(function(){return function(){var e={308:function(e,t,n){var o=n(645)((function(e){return e[1]}));o.push([e.id,".rpc-config.download-video-config-section {\n display: flex;\n align-items: center;\n flex-direction: column;\n grid-gap: 0;\n gap: 0;\n align-items: stretch;\n}\n.rpc-config.download-video-config-section > * {\n display: flex;\n align-items: center;\n grid-gap: 0;\n gap: 0;\n}\n.rpc-config.download-video-config-section > *:not(:last-child) {\n margin-bottom: 12px;\n}\n.rpc-config.download-video-config-section .profile-item-name {\n margin-right: 8px;\n}\n.rpc-config.download-video-config-section .profile-other .profile-item-name {\n align-self: flex-start;\n}\n.rpc-config.download-video-config-section .profile-select .be-textbox,\n.rpc-config.download-video-config-section .profile-select .be-dropdown {\n margin-right: 8px;\n}\n.rpc-config.download-video-config-section .profile-select .be-button {\n padding: 4px;\n}\n.rpc-config.download-video-config-section .profile-method {\n align-self: flex-start;\n}",""]),e.exports=o},645:function(e){"use strict"; // eslint-disable-next-line func-names e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")}, // eslint-disable-next-line func-names t.i=function(e,n,o){"string"==typeof e&&( // eslint-disable-next-line no-param-reassign e=[[null,e,""]]);var r={};if(o)for(var i=0;ie.name===l.selectedRpcProfileName))??(l.rpcProfiles.length<1?(l.rpcProfiles.push(a),a):l.rpcProfiles[0]);console.log(l,d);var p=Vue.extend({components:{TextBox:s.TextBox,VButton:s.VButton,VIcon:s.VIcon,VDropdown:s.VDropdown,TextArea:s.TextArea},data:()=>({isRenaming:!1,profileRename:"",rpcProfiles:l.rpcProfiles,selectedRpcProfile:d}),methods:{saveSettings(){l.selectedRpcProfileName=this.selectedRpcProfile.name,l.rpcProfiles=this.rpcProfiles,Object.assign(c,l)},async startRename(){this.profileRename=this.selectedRpcProfile.name,this.isRenaming=!0,await this.$nextTick(),this.$refs.renameInput?.focus()},endRename(){const e=this.profileRename;e?l.rpcProfiles.some((t=>t.name!==this.selectedRpcProfile.name&&t.name===e))?i.Toast.error("名称不得与其他预设重复","重命名 RPC 预设",2e3):(this.selectedRpcProfile.name=this.profileRename,this.isRenaming=!1,this.saveSettings()):i.Toast.error("名称不得为空","重命名 RPC 预设",2e3)},newProfile(){const e={...this.selectedRpcProfile},t={num:1,toString(){return`未命名${this.num}`}};for(;l.rpcProfiles.some((e=>e.name===t.toString()));)t.num++;e.name=t.toString(),l.rpcProfiles.push(e),this.selectedRpcProfile=e},deleteProfile(){if(l.rpcProfiles.length<2)return;const e=l.rpcProfiles.findIndex((e=>e.name===this.selectedRpcProfile.name));-1!==e&&confirm(`确认删除 RPC 预设 "${this.selectedRpcProfile.name}" 吗?`)&&(l.rpcProfiles.splice(e,1),this.selectedRpcProfile=l.rpcProfiles[0])}}}),f=n(379),u=n.n(f),m=n(308),h=n.n(m),v={insert:"head",singleton:!1};u()(h(),v),h().locals;var g=function(e,t,n,o,r,i,s,a){var c,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),o&&(l.functional=!0),i&&(l._scopeId="data-v-"+i),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):r&&(c=a?function(){r.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:r),c)if(l.functional){l._injectStyles=c;var d=l.render;l.render=function(e,t){return c.call(t),d(e,t)}}else{var p=l.beforeCreate;l.beforeCreate=p?[].concat(p,c):[c]}return{exports:e,options:l}}(p,o,[],!1,null,null,null);g.options.__file="registry/lib/plugins/video/download/aria2-output/RpcConfig.vue";var P=g.exports},141:function(e){"use strict";e.exports=coreApis.toast}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,exports:{}};return e[o](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){"use strict";n.d(o,{plugin:function(){return h}});var e=coreApis.download,t=coreApis.utils.constants,r=coreApis.utils.title;const i={name:"aria2",displayName:"aria2 Input",description:"使用 aria2 命令行输入文件开始下载. (aria2c -i xxx.txt)",runAction:async n=>{const{infos:o}=n,i=document.URL.replace(window.location.search,""),s=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${o.map((e=>e.titledFragments.map((e=>({url:e.url,params:{referer:i,userAgent:t.UserAgent,out:e.title}}))).flat().map((e=>{const t=Object.entries(e.params).map((([e,t])=>` ${lodash.kebabCase(e)}=${t}`)).join("\n");return`${e.url}\n${t}`})))).flat().join("\n")}`.trim();await e.DownloadPackage.single(`${(0,r.getFriendlyTitle)()}.txt`,s)}};var s=coreApis.ajax,a=n(141),c=coreApis.utils.log;const l=e=>{const t=e.host.match(/^http[s]?:\/\//)?e.host:`http://${e.host}`;return{option:e,host:t,methodName:"aria2.addUri"}},d=async(e,t)=>{try{let n=await t();return"string"==typeof n&&(n=JSON.parse(n)),void 0!==n.error?1===n.error.code?{param:e,success:!1,message:"请求遭到拒绝, 请检查您的密钥相关设置."}:{param:e,success:!1,message:`请求发生错误, code = ${n.error.code}, message = ${n.error.message}`}:{param:e,success:!0,message:n.result}}catch(t){return{param:e,success:!1,message:`无法连接到RPC主机, error = ${t.toString()}`}}},p=async(e,t)=>{const{option:n,host:o,methodName:r}=l(e);return d(t,(async()=>{const e=window.btoa(unescape(encodeURIComponent(JSON.stringify(t.params)))),i=`${o}:${n.port}/jsonrpc?method=${r}&id=${t.id}¶ms=${e}`;return console.log(`RPC request: ${i}`),i.startsWith("http:")?(0,s.monkey)({method:"GET",url:i,responseType:"json"}):(0,s.getJson)(i)}))},f=async(e,t)=>{const{option:n,host:o,methodName:r}=l(e);return d(t,(async()=>{const e=`${o}:${n.port}/jsonrpc`,i={method:r,id:t.id,params:t.params};return e.startsWith("http:")?(0,s.monkey)({method:"POST",url:e,responseType:"json",data:JSON.stringify(i)}):(0,s.postJson)(e,i)}))},u=e=>{if(!e)return{};const t=e.split("\n").map((e=>{const[t,...n]=e.trim().split("=");return[t.trim(),n.join("=").trim()]})).filter((e=>Boolean(e[1])));return Object.fromEntries(t)},m={name:"aria2Rpc",displayName:"aria2 RPC",description:"使用 aria2 RPC 功能发送下载请求.",runAction:async(e,n)=>{const{infos:o}=e,{selectedRpcProfile:r}=n,{secretKey:i,dir:s,other:l}=r,d=document.URL.replace(window.location.search,""),m=o.map((e=>e.titledFragments.map((e=>{const n=[];i&&n.push(`token:${i}`),n.push([e.url]),n.push({referer:d,"user-agent":t.UserAgent,out:e.title,dir:s||void 0,...u(l)});return{params:n,id:encodeURIComponent(e.title)}})))).flat(),h=await(async(e,t)=>{const n=[];for(const o of t){let t;t="get"===e.method?await p(e,o):await f(e,o),n.push(t)}return n})(r,m);if(console.table(h),1===h.length){const e=h[0];e.success?a.Toast.success(`成功发送了请求, GID = ${e.message}`,"aria2 RPC",5e3):(0,c.logError)(e.message)}else{const e=h.filter((e=>e.success)).length,t=h.length-e;a.Toast.info(`发送了 ${h.length} 个请求, 成功 ${e} 个, 失败 ${t} 个.`,"aria2 RPC",5e3)}},component:()=>Promise.resolve().then(n.bind(n,302)).then((e=>e.default))},h={name:"downloadVideo.outputs.aria2",displayName:"下载视频 - aria2 输出支持",description:"为下载视频增加 aria2 文件导出和 RPC 输出支持.",setup:({addData:e})=>{e("downloadVideo.outputs",(e=>{e.push(i),e.push(m)}))},commitHash:"2acf9c591c1b55e3ef8e8e20becca001a39dc13f"}}(),o=o.plugin}()}));