-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathsub-store-0.min.js
18 lines (17 loc) · 106 KB
/
sub-store-0.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* ███████╗██╗ ██╗██████╗ ███████╗████████╗ ██████╗ ██████╗ ███████╗
* ██╔════╝██║ ██║██╔══██╗ ██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝
* ███████╗██║ ██║██████╔╝█████╗███████╗ ██║ ██║ ██║██████╔╝█████╗
* ╚════██║██║ ██║██╔══██╗╚════╝╚════██║ ██║ ██║ ██║██╔══██╗██╔══╝
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
* @updated: 2023/6/5 22:51:26
* @version: 2.13.6
* @author: Peng-YM
* @github: https://github.com/Peng-YM/Sub-Store
* @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46
* SCRIPT_CACHE_EXPIRATION_TIME_MS = TIMEDKEY time-cache: cache time for cname
*/
const cnamet=$persistentStore.read("time-cache"),readcachet=cnamet ? JSON.parse(cnamet) : 1728e5,loonkey=typeof $loon !== 'undefined';let TIMEDKEY="";if(cnamet !== ""){TIMEDKEY=readcachet;} if(loonkey){const loont={ "1\u5206\u949f": 6e4,"5\u5206\u949f": 3e5,"10\u5206\u949f": 6e5,"30\u5206\u949f": 18e5,"1\u5c0f\u65f6": 36e5,"2\u5c0f\u65f6": 72e5,"3\u5c0f\u65f6": 108e5,"6\u5c0f\u65f6": 216e5,"12\u5c0f\u65f6": 432e5,"24\u5c0f\u65f6": 864e5,"48\u5c0f\u65f6": 1728e5,"72\u5c0f\u65f6": 2592e5,"\u53c2\u6570\u4f20\u5165": "readcachets",};let intimed=$persistentStore.read("\u8282\u70b9\u7f13\u5b58\u6709\u6548\u671f");if(loont.hasOwnProperty(intimed)){TIMEDKEY=loont[intimed];if(TIMEDKEY == "readcachets"){TIMEDKEY=readcachet;}}}
!function(){var _$package_1={version:"2.13.6"},_$constants_2={};Object.defineProperty(_$constants_2,"__esModule",{value:!0}),_$constants_2.SUBS_KEY=_$constants_2.SETTINGS_KEY=_$constants_2.SCHEMA_VERSION_KEY=_$constants_2.RULES_KEY=_$constants_2.RESOURCE_CACHE_KEY=_$constants_2.GIST_BACKUP_KEY=_$constants_2.GIST_BACKUP_FILE_NAME=_$constants_2.COLLECTIONS_KEY=_$constants_2.CACHE_EXPIRATION_TIME_MS=_$constants_2.ARTIFACT_REPOSITORY_KEY=_$constants_2.ARTIFACTS_KEY=void 0,_$constants_2.SCHEMA_VERSION_KEY="schemaVersion",_$constants_2.SETTINGS_KEY="settings",_$constants_2.SUBS_KEY="subs",_$constants_2.COLLECTIONS_KEY="collections",_$constants_2.ARTIFACTS_KEY="artifacts",_$constants_2.RULES_KEY="rules",_$constants_2.GIST_BACKUP_KEY="Auto Generated Sub-Store Backup",_$constants_2.GIST_BACKUP_FILE_NAME="Sub-Store",_$constants_2.ARTIFACT_REPOSITORY_KEY="Sub-Store Artifacts Repository",_$constants_2.RESOURCE_CACHE_KEY="#sub-store-cached-resource",_$constants_2.CACHE_EXPIRATION_TIME_MS=36e5;var _$openApi_19={};function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach((function(e){_defineProperty(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==_typeof(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function asyncGeneratorStep(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){asyncGeneratorStep(a,n,o,i,s,"next",t)}function s(t){asyncGeneratorStep(a,n,o,i,s,"throw",t)}i(void 0)}))}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}Object.defineProperty(_$openApi_19,"__esModule",{value:!0}),_$openApi_19.ENV=ENV,_$openApi_19.HTTP=HTTP,_$openApi_19.OpenAPI=void 0;var isQX="undefined"!=typeof $task,isLoon="undefined"!=typeof $loon,isSurge="undefined"!=typeof $httpClient&&!isLoon,isNode=eval('typeof process !== "undefined"'),isStash="undefined"!=typeof $environment&&$environment["stash-version"],isShadowRocket="undefined"!=typeof $rocket,OpenAPI=function(){function OpenAPI(){var name=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"untitled",debug=arguments.length>1&&void 0!==arguments[1]&&arguments[1];_classCallCheck(this,OpenAPI),this.name=name,this.debug=debug,this.http=HTTP(),this.env=ENV(),this.node=function(){if(isNode){var fs=eval("require('fs')");return{fs:fs}}return null}(),this.initCache();var delay=function(t,e){return new Promise((function(r){setTimeout(r.bind(null,e),t)}))},_ref;Promise.prototype.delay=(_ref=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this;case 2:return r=t.sent,t.next=5,delay(e,r);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return _ref.apply(this,arguments)})}return _createClass(OpenAPI,[{key:"initCache",value:function(){if(isQX&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(isLoon||isSurge)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),isNode){var t="root.json";this.node.fs.existsSync(t)?this.root=JSON.parse(this.node.fs.readFileSync("".concat(t))):(this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"}),this.root={}),t="".concat(this.name,".json"),this.node.fs.existsSync(t)?this.cache=JSON.parse(this.node.fs.readFileSync("".concat(this.name,".json"))):(this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"}),this.cache={})}}},{key:"persistCache",value:function(){var t=JSON.stringify(this.cache,null,2);isQX&&$prefs.setValueForKey(t,this.name),(isLoon||isSurge)&&$persistentStore.write(t,this.name),isNode&&(this.node.fs.writeFileSync("".concat(this.name,".json"),t,{flag:"w"},(function(t){return console.log(t)})),this.node.fs.writeFileSync("root.json",JSON.stringify(this.root,null,2),{flag:"w"},(function(t){return console.log(t)})))}},{key:"write",value:function(t,e){if(this.log("SET ".concat(e)),-1!==e.indexOf("#")){if(e=e.substr(1),isSurge||isLoon)return $persistentStore.write(t,e);if(isQX)return $prefs.setValueForKey(t,e);isNode&&(this.root[e]=t)}else this.cache[e]=t;this.persistCache()}},{key:"read",value:function(t){return this.log("READ ".concat(t)),-1===t.indexOf("#")?this.cache[t]:(t=t.substr(1),isSurge||isLoon?$persistentStore.read(t):isQX?$prefs.valueForKey(t):isNode?this.root[t]:void 0)}},{key:"delete",value:function(t){if(this.log("DELETE ".concat(t)),-1!==t.indexOf("#")){if(t=t.substr(1),isSurge||isLoon)return $persistentStore.write(null,t);if(isQX)return $prefs.removeValueForKey(t);isNode&&delete this.root[t]}else delete this.cache[t];this.persistCache()}},{key:"notify",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=n["open-url"],a=n["media-url"];if(isQX&&$notify(t,e,r,n),isSurge&&$notification.post(t,e,r+"".concat(a?"\n\u591a\u5a92\u4f53:"+a:""),{url:o}),isLoon){var i={};o&&(i.openUrl=o),a&&(i.mediaUrl=a),"{}"===JSON.stringify(i)?$notification.post(t,e,r):$notification.post(t,e,r,i)}if(isNode){var s=r+(o?"\n\u70b9\u51fb\u8df3\u8f6c: ".concat(o):"")+(a?"\n\u591a\u5a92\u4f53: ".concat(a):"");console.log("".concat(t,"\n").concat(e,"\n").concat(s,"\n\n"))}}},{key:"log",value:function(t){this.debug&&console.log("[".concat(this.name,"] LOG: ").concat(t))}},{key:"info",value:function(t){console.log("[".concat(this.name,"] INFO: ").concat(t))}},{key:"error",value:function(t){console.log("[".concat(this.name,"] ERROR: ").concat(t))}},{key:"wait",value:function(t){return new Promise((function(e){return setTimeout(e,t)}))}},{key:"done",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};isQX||isLoon||isSurge?$done(t):isNode&&"undefined"!=typeof $context&&($context.headers=t.headers,$context.statusCode=t.statusCode,$context.body=t.body)}}]),OpenAPI}();function ENV(){return{isQX:isQX,isLoon:isLoon,isSurge:isSurge,isNode:isNode,isStash:isStash,isShadowRocket:isShadowRocket}}function HTTP(){var defaultOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{baseURL:""},_ENV=ENV(),isQX=_ENV.isQX,isLoon=_ENV.isLoon,isSurge=_ENV.isSurge,isNode=_ENV.isNode,methods=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH"],URL_REGEX=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;function send(method,options){options="string"==typeof options?{url:options}:options;var baseURL=defaultOptions.baseURL;baseURL&&!URL_REGEX.test(options.url||"")&&(options.url=baseURL?baseURL+options.url:options.url),options=_objectSpread(_objectSpread({},defaultOptions),options);var timeout=options.timeout,events=_objectSpread(_objectSpread({},{onRequest:function(){},onResponse:function(t){return t},onTimeout:function(){}}),options.events),worker,timeoutid;if(events.onRequest(method,options),options.node&&isSurge){var build=$environment["surge-build"];build&&parseInt(build)>=2407&&(options["policy-descriptor"]=options.node,delete options.node)}isQX?worker=$task.fetch({method:method,url:options.url,headers:options.headers,body:options.body}):(isLoon||isSurge||isNode)&&(worker=new Promise((function(resolve,reject){var request=isNode?eval("require('request')"):$httpClient;request[method.toLowerCase()](options,(function(t,e,r){t?reject(t):resolve({statusCode:e.status||e.statusCode,headers:e.headers,body:r})}))})));var timer=timeout?new Promise((function(t,e){timeoutid=setTimeout((function(){return events.onTimeout(),e("".concat(method," URL: ").concat(options.url," exceeds the timeout ").concat(timeout," ms"))}),timeout)})):null;return(timer?Promise.race([timer,worker]).then((function(t){return clearTimeout(timeoutid),t})):worker).then((function(t){return events.onResponse(t)}))}var http={};return methods.forEach((function(t){return http[t.toLowerCase()]=function(e){return send(t,e)}})),http}_$openApi_19.OpenAPI=OpenAPI;var _$app_3={};Object.defineProperty(_$app_3,"__esModule",{value:!0}),_$app_3.default=void 0;var _default=new _$openApi_19.OpenAPI("sub-store");_$app_3.default=_default;var _$migration_16={};Object.defineProperty(_$migration_16,"__esModule",{value:!0}),_$migration_16.default=function(){var t;(t=_app.default.read(_$constants_2.SCHEMA_VERSION_KEY))||function(){_app.default.info("Start migrating...");var t=_app.default.read(_$constants_2.SUBS_KEY)||{},e=Object.values(t).map((function(t){return t.source=t.source||"remote",c(t),u(t),t}));_app.default.write(e,_$constants_2.SUBS_KEY);var r=_app.default.read(_$constants_2.COLLECTIONS_KEY)||{},n=Object.values(r).map((function(t){return delete t.ua,c(t),u(t),t}));_app.default.write(n,_$constants_2.COLLECTIONS_KEY);var o=_app.default.read(_$constants_2.ARTIFACTS_KEY)||{},a=Object.values(o);_app.default.write(a,_$constants_2.ARTIFACTS_KEY);var i=_app.default.read(_$constants_2.RULES_KEY)||{},s=Object.values(i);function c(t){var e=t["display-name"];e&&(t.displayName=e,delete t["display-name"])}function u(t){var e=t.process;if(e&&0!==e.length){var r,n=[],o={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}},a=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,void 0):void 0}}(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}(e);try{for(a.s();!(r=a.n()).done;){var i=r.value;if(i.type)if("Useless Filter"===i.type)o.args.useless="ENABLED";else if("Set Property Operator"===i.type){var s=i.args,c=s.key,u=s.value;switch(c){case"udp":o.args.udp=u?"ENABLED":"DISABLED";break;case"tfo":o.args.tfo=u?"ENABLED":"DISABLED";break;case"skip-cert-verify":o.args.scert=u?"ENABLED":"DISABLED";break;case"aead":o.args["vmess aead"]=u?"ENABLED":"DISABLED"}}else if(-1!==i.type.indexOf("Keyword"));else if("Flag Operator"===i.type){var _=void 0===i.args||i.args;i.args={mode:_?"add":"remove"},n.push(i)}else n.push(i)}}catch(f){a.e(f)}finally{a.f()}n.unshift(o),t.process=n}}_app.default.write(s,_$constants_2.RULES_KEY),delete _app.default.cache.builtin,_app.default.info("Migration complete!")}(),"2.0"!==t&&_app.default.write("2.0",_$constants_2.SCHEMA_VERSION_KEY)};var obj,_app=(obj=_$app_3)&&obj.__esModule?obj:{default:obj};function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var _$express_18={};function ___classCallCheck_18(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ___defineProperties_18(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ___createClass_18(t,e,r){return e&&___defineProperties_18(t.prototype,e),r&&___defineProperties_18(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function express(_ref){var $=_ref.substore,port=_ref.port;port=port||3e3;var _ENV=(0,_$openApi_19.ENV)(),isNode=_ENV.isNode,DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept"};if(isNode){var express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),_app=express_();return _app.use(bodyParser.json({verify:rawBodySaver})),_app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),_app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),_app.use((function(t,e,r){e.set(DEFAULT_HEADERS),r()})),_app.start=function(){_app.listen(port,(function(){$.info("Express started on port: ".concat(port))}))},_app}var handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e.method,o=e.url,a=e.headers,i=e.body;a=formatHeaders(a),/json/i.test(a["content-type"])&&(i=JSON.parse(i)),n=n.toUpperCase();var s,c=extractURL(o),u=c.path,_=c.query,f=null,l=0;for(s=r;s<handlers.length;s++)if("ALL"===handlers[s].method||n===handlers[s].method){var p=handlers[s].pattern;patternMatched(p,u)&&p.split("/").length>l&&(f=handlers[s],l=p.split("/").length)}if(f){var h=function(){t(n,o,s)},d={method:n,url:o,path:u,query:_,params:extractPathParams(f.pattern,u),headers:a,body:i},y=Response(),v=f.callback,m=function(t){y.status(500).json({status:"failed",message:"Internal Server Error: ".concat(t)})};if("AsyncFunction"===v.constructor.name)v(d,y,h).catch(m);else try{v(d,y,h)}catch(g){m(g)}}else Response().status(404).json({status:"failed",message:"ERROR: 404 not found"})},app={};return METHODS_NAMES.forEach((function(t){app[t.toLowerCase()]=function(e,r){handlers.push({method:t,pattern:e,callback:r})}})),app.route=function(t){var e={};return METHODS_NAMES.forEach((function(r){e[r.toLowerCase()]=function(n){return handlers.push({method:r,pattern:t,callback:n}),e}})),e},app.start=function(){dispatch($request)},app;function rawBodySaver(t,e,r,n){r&&r.length&&(t.rawBody=r.toString(n||"utf8"))}function Response(){var t=200,e=(0,_$openApi_19.ENV)(),r=e.isQX,n=e.isLoon,o=e.isSurge,a=DEFAULT_HEADERS,i={200:"HTTP/1.1 200 OK",201:"HTTP/1.1 201 Created",302:"HTTP/1.1 302 Found",307:"HTTP/1.1 307 Temporary Redirect",308:"HTTP/1.1 308 Permanent Redirect",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new(function(){function e(){___classCallCheck_18(this,e)}return ___createClass_18(e,[{key:"status",value:function(e){return t=e,this}},{key:"send",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",s={status:r?i[t]:t,body:e,headers:a};r?$done(s):(n||o)&&$done({response:s})}},{key:"end",value:function(){this.send()}},{key:"html",value:function(t){this.set("Content-Type","text/html;charset=UTF-8"),this.send(t)}},{key:"json",value:function(t){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(t))}},{key:"set",value:function(t,e){return a[t]=e,this}}]),e}())}}function formatHeaders(t){for(var e={},r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];e[o.toLowerCase()]=t[o]}return e}function patternMatched(t,e){if(t instanceof RegExp&&t.test(e))return!0;if("/"===t)return!0;if(-1===t.indexOf(":")){for(var r=e.split("/"),n=t.split("/"),o=0;o<n.length;o++)if(r[o]!==n[o])return!1;return!0}return!!extractPathParams(t,e)}function extractURL(t){var e=(t.match(/https?:\/\/[^/]+(\/[^?]*)/)||[])[1]||"/",r={};if(-1!==t.indexOf("?"))for(var n=t.slice(t.indexOf("?")+1).split("&"),o=0;o<n.length;o++){var a=n[o].split("=");r[a[0]]=a[1]}return{path:e,query:r}}function extractPathParams(t,e){if(-1===t.indexOf(":"))return null;for(var r={},n=0,o=0;n<t.length;n++,o++)if(":"===t[n]){for(var a=[],i=[];"/"!==t[++n]&&n<t.length;)a.push(t[n]);for(;"/"!==e[o]&&o<e.length;)i.push(e[o++]);r[a.join("")]=i.join("")}else if(t[n]!==e[o])return null;return r}Object.defineProperty(_$express_18,"__esModule",{value:!0}),_$express_18.default=express;var _$database_13={};function findIndexByName(t,e){return t.findIndex((function(t){return t.name===e}))}Object.defineProperty(_$database_13,"__esModule",{value:!0}),_$database_13.deleteByName=function(t,e){var r=findIndexByName(t,e);t.splice(r,1)},_$database_13.findByName=function(t,e){return t.find((function(t){return t.name===e}))},_$database_13.updateByName=function(t,e,r){t[findIndexByName(t,e)]=r};var _$response_9={};Object.defineProperty(_$response_9,"__esModule",{value:!0}),_$response_9.failed=function(t,e,r){t.status(r||500).json({status:"failed",error:{code:e.code,type:e.type,message:e.message,details:e.details}})},_$response_9.success=function(t,e,r){t.status(r||200).json({status:"success",data:e})};var _$errors_7={};function ___typeof_7(t){return(___typeof_7="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _createSuper(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=_getPrototypeOf(t);if(e){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(t,e){if(e&&("object"===___typeof_7(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,r)}}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function ___defineProperties_7(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function ___createClass_7(t,e,r){return e&&___defineProperties_7(t.prototype,e),r&&___defineProperties_7(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ___classCallCheck_7(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(_$errors_7,"__esModule",{value:!0}),_$errors_7.ResourceNotFoundError=_$errors_7.RequestInvalidError=_$errors_7.NetworkError=_$errors_7.InternalServerError=void 0;var BaseError=___createClass_7((function t(e,r,n){___classCallCheck_7(this,t),this.code=e,this.message=r,this.details=n})),InternalServerError=function(t){_inherits(r,BaseError);var e=_createSuper(r);function r(t,n,o){var a;return ___classCallCheck_7(this,r),(a=e.call(this,t,n,o)).type="InternalServerError",a}return ___createClass_7(r)}();_$errors_7.InternalServerError=InternalServerError;var RequestInvalidError=function(t){_inherits(r,BaseError);var e=_createSuper(r);function r(t,n,o){var a;return ___classCallCheck_7(this,r),(a=e.call(this,t,n,o)).type="RequestInvalidError",a}return ___createClass_7(r)}();_$errors_7.RequestInvalidError=RequestInvalidError;var ResourceNotFoundError=function(t){_inherits(r,BaseError);var e=_createSuper(r);function r(t,n,o){var a;return ___classCallCheck_7(this,r),(a=e.call(this,t,n,o)).type="ResourceNotFoundError",a}return ___createClass_7(r)}();_$errors_7.ResourceNotFoundError=ResourceNotFoundError;var NetworkError=function(t){_inherits(r,BaseError);var e=_createSuper(r);function r(t,n,o){var a;return ___classCallCheck_7(this,r),(a=e.call(this,t,n,o)).type="NetworkError",a}return ___createClass_7(r)}();_$errors_7.NetworkError=NetworkError;var _$collections_6={};Object.defineProperty(_$collections_6,"__esModule",{value:!0}),_$collections_6.default=function(t){___app_6.default.read(_$constants_2.COLLECTIONS_KEY)||___app_6.default.write({},_$constants_2.COLLECTIONS_KEY),t.route("/api/collection/:name").get(getCollection).patch(updateCollection).delete(deleteCollection),t.route("/api/collections").get(getAllCollections).post(createCollection)};var __obj_6,___app_6=(__obj_6=_$app_3)&&__obj_6.__esModule?__obj_6:{default:__obj_6};function _createForOfIteratorHelper(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ___arrayLikeToArray_6(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?___arrayLikeToArray_6(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function ___arrayLikeToArray_6(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function __ownKeys_6(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ___objectSpread_6(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?__ownKeys_6(Object(r),!0).forEach((function(e){___defineProperty_6(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):__ownKeys_6(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ___defineProperty_6(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function createCollection(t,e){var r=t.body;___app_6.default.info("\u6b63\u5728\u521b\u5efa\u7ec4\u5408\u8ba2\u9605\uff1a".concat(r.name));var n=___app_6.default.read(_$constants_2.COLLECTIONS_KEY);(0,_$database_13.findByName)(n,r.name)&&(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("DUPLICATE_KEY","Collection ".concat(r.name," already exists."))),n.push(r),___app_6.default.write(n,_$constants_2.COLLECTIONS_KEY),(0,_$response_9.success)(e,r,201)}function getCollection(t,e){var r=t.params.name;r=decodeURIComponent(r);var n=___app_6.default.read(_$constants_2.COLLECTIONS_KEY),o=(0,_$database_13.findByName)(n,r);o?(0,_$response_9.success)(e,o):(0,_$response_9.failed)(e,new _$errors_7.ResourceNotFoundError("SUBSCRIPTION_NOT_FOUND","Collection ".concat(r," does not exist"),404))}function updateCollection(t,e){var r=t.params.name;r=decodeURIComponent(r);var n=t.body,o=___app_6.default.read(_$constants_2.COLLECTIONS_KEY),a=(0,_$database_13.findByName)(o,r);if(a){var i=___objectSpread_6(___objectSpread_6({},a),n);if(___app_6.default.info("\u6b63\u5728\u66f4\u65b0\u7ec4\u5408\u8ba2\u9605\uff1a".concat(r,"...")),r!==i.name){var s,c=___app_6.default.read(_$constants_2.ARTIFACTS_KEY)||[],u=_createForOfIteratorHelper(c);try{for(u.s();!(s=u.n()).done;){var _=s.value;"collection"===_.type&&_.source===a.name&&(_.source=i.name)}}catch(f){u.e(f)}finally{u.f()}___app_6.default.write(c,_$constants_2.ARTIFACTS_KEY)}(0,_$database_13.updateByName)(o,r,i),___app_6.default.write(o,_$constants_2.COLLECTIONS_KEY),(0,_$response_9.success)(e,i)}else(0,_$response_9.failed)(e,new _$errors_7.ResourceNotFoundError("RESOURCE_NOT_FOUND","Collection ".concat(r," does not exist!")),404)}function deleteCollection(t,e){var r=t.params.name;r=decodeURIComponent(r),___app_6.default.info("\u6b63\u5728\u5220\u9664\u7ec4\u5408\u8ba2\u9605\uff1a".concat(r));var n=___app_6.default.read(_$constants_2.COLLECTIONS_KEY);(0,_$database_13.deleteByName)(n,r),___app_6.default.write(n,_$constants_2.COLLECTIONS_KEY),(0,_$response_9.success)(e)}function getAllCollections(t,e){var r=___app_6.default.read(_$constants_2.COLLECTIONS_KEY);(0,_$response_9.success)(e,r)}var _$flow_14={};function ___typeof_14(t){return(___typeof_14="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ___regeneratorRuntime_14(){___regeneratorRuntime_14=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_14(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function __asyncGeneratorStep_14(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function _getFlowHeaders(){var t;return t=___regeneratorRuntime_14().mark((function t(e){var r,n,o,a;return ___regeneratorRuntime_14().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(0,_$openApi_19.HTTP)(),t.next=3,r.get({url:e,headers:{"User-Agent":"Quantumult%20X/1.3.0 (iPhone14,5; iOS 16.5)"}});case 3:return n=t.sent,o=n.headers,a=Object.keys(o).filter((function(t){return/SUBSCRIPTION-USERINFO/i.test(t)}))[0],t.abrupt("return",o[a]);case 7:case"end":return t.stop()}}),t)})),(_getFlowHeaders=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_14(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_14(a,n,o,i,s,"throw",t)}i(void 0)}))}).apply(this,arguments)}Object.defineProperty(_$flow_14,"__esModule",{value:!0}),_$flow_14.getFlowHeaders=function(t){return _getFlowHeaders.apply(this,arguments)};var _$subscriptions_12={};function ___typeof_12(t){return(___typeof_12="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(_$subscriptions_12,"__esModule",{value:!0}),_$subscriptions_12.default=function(t){t.get("/api/sub/flow/:name",getFlowInfo),t.route("/api/sub/:name").get(getSubscription).patch(updateSubscription).delete(deleteSubscription),t.route("/api/subs").get(getAllSubscriptions).post(createSubscription)};var __obj_12,___app_12=(__obj_12=_$app_3)&&__obj_12.__esModule?__obj_12:{default:__obj_12};function ___regeneratorRuntime_12(){___regeneratorRuntime_12=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_12(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function ___createForOfIteratorHelper_12(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ___arrayLikeToArray_12(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?___arrayLikeToArray_12(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function ___arrayLikeToArray_12(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function __ownKeys_12(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ___objectSpread_12(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?__ownKeys_12(Object(r),!0).forEach((function(e){___defineProperty_12(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):__ownKeys_12(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ___defineProperty_12(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function __asyncGeneratorStep_12(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function getFlowInfo(t,e){return _getFlowInfo.apply(this,arguments)}function _getFlowInfo(){var t;return t=___regeneratorRuntime_12().mark((function t(e,r){var n,o,a,i,s,c,u,_,f,l,p;return ___regeneratorRuntime_12().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.params.name,n=decodeURIComponent(n),o=___app_12.default.read(_$constants_2.SUBS_KEY),a=(0,_$database_13.findByName)(o,n)){t.next=7;break}return(0,_$response_9.failed)(r,new _$errors_7.ResourceNotFoundError("RESOURCE_NOT_FOUND","Subscription ".concat(n," does not exist!")),404),t.abrupt("return");case 7:if("local"!==a.source){t.next=10;break}return(0,_$response_9.failed)(r,new _$errors_7.RequestInvalidError("NO_FLOW_INFO","N/A","Local subscription ".concat(n," has no flow information!"))),t.abrupt("return");case 10:return t.prev=10,t.next=13,(0,_$flow_14.getFlowHeaders)(a.url);case 13:if(i=t.sent){t.next=17;break}return(0,_$response_9.failed)(r,new _$errors_7.InternalServerError("NO_FLOW_INFO","No flow info","Failed to fetch flow headers")),t.abrupt("return");case 17:s=i.match(/upload=(-?)(\d+)/),c=Number(s[1]+s[2]),u=i.match(/download=(-?)(\d+)/),_=Number(u[1]+u[2]),f=Number(i.match(/total=(\d+)/)[1]),l=i.match(/expire=(\d+)/),p=l?Number(l[1]):void 0,(0,_$response_9.success)(r,{expires:p,total:f,usage:{upload:c,download:_}}),t.next=30;break;case 27:t.prev=27,t.t0=t.catch(10),(0,_$response_9.failed)(r,new _$errors_7.NetworkError("URL_NOT_ACCESSIBLE","The URL for subscription ".concat(n," is inaccessible.")));case 30:case"end":return t.stop()}}),t,null,[[10,27]])})),(_getFlowInfo=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_12(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_12(a,n,o,i,s,"throw",t)}i(void 0)}))}).apply(this,arguments)}function createSubscription(t,e){var r=t.body;___app_12.default.info("\u6b63\u5728\u521b\u5efa\u8ba2\u9605\uff1a ".concat(r.name));var n=___app_12.default.read(_$constants_2.SUBS_KEY);(0,_$database_13.findByName)(n,r.name)&&(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("DUPLICATE_KEY","Subscription ".concat(r.name," already exists."))),n.push(r),___app_12.default.write(n,_$constants_2.SUBS_KEY),(0,_$response_9.success)(e,r,201)}function getSubscription(t,e){var r=t.params.name;r=decodeURIComponent(r);var n=___app_12.default.read(_$constants_2.SUBS_KEY),o=(0,_$database_13.findByName)(n,r);o?(0,_$response_9.success)(e,o):(0,_$response_9.failed)(e,new _$errors_7.ResourceNotFoundError("SUBSCRIPTION_NOT_FOUND","Subscription ".concat(r," does not exist"),404))}function updateSubscription(t,e){var r=t.params.name;r=decodeURIComponent(r);var n=t.body,o=___app_12.default.read(_$constants_2.SUBS_KEY),a=(0,_$database_13.findByName)(o,r);if(a){var i=___objectSpread_12(___objectSpread_12({},a),n);if(___app_12.default.info("\u6b63\u5728\u66f4\u65b0\u8ba2\u9605\uff1a ".concat(r)),r!==n.name){var s,c=___app_12.default.read(_$constants_2.COLLECTIONS_KEY)||[],u=___createForOfIteratorHelper_12(c);try{for(u.s();!(s=u.n()).done;){var _=s.value,f=_.subscriptions.indexOf(r);-1!==f&&(_.subscriptions[f]=n.name)}}catch(y){u.e(y)}finally{u.f()}var l,p=___app_12.default.read(_$constants_2.ARTIFACTS_KEY)||[],h=___createForOfIteratorHelper_12(p);try{for(h.s();!(l=h.n()).done;){var d=l.value;"subscription"===d.type&&d.source==r&&(d.source=n.name)}}catch(y){h.e(y)}finally{h.f()}___app_12.default.write(c,_$constants_2.COLLECTIONS_KEY),___app_12.default.write(p,_$constants_2.ARTIFACTS_KEY)}(0,_$database_13.updateByName)(o,r,i),___app_12.default.write(o,_$constants_2.SUBS_KEY),(0,_$response_9.success)(e,i)}else(0,_$response_9.failed)(e,new _$errors_7.ResourceNotFoundError("RESOURCE_NOT_FOUND","Subscription ".concat(r," does not exist!")),404)}function deleteSubscription(t,e){var r=t.params.name;r=decodeURIComponent(r),___app_12.default.info("\u5220\u9664\u8ba2\u9605\uff1a".concat(r,"..."));var n=___app_12.default.read(_$constants_2.SUBS_KEY);(0,_$database_13.deleteByName)(n,r),___app_12.default.write(n,_$constants_2.SUBS_KEY);var o,a=___app_12.default.read(_$constants_2.COLLECTIONS_KEY),i=___createForOfIteratorHelper_12(a);try{for(i.s();!(o=i.n()).done;){var s=o.value;s.subscriptions=s.subscriptions.filter((function(t){return t!==r}))}}catch(c){i.e(c)}finally{i.f()}___app_12.default.write(a,_$constants_2.COLLECTIONS_KEY),(0,_$response_9.success)(e)}function getAllSubscriptions(t,e){var r=___app_12.default.read(_$constants_2.SUBS_KEY);(0,_$response_9.success)(e,r)}___app_12.default.read(_$constants_2.SUBS_KEY)||___app_12.default.write({},_$constants_2.SUBS_KEY);var _$gist_15={};function ___typeof_15(t){return(___typeof_15="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ___regeneratorRuntime_15(){___regeneratorRuntime_15=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_15(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function ___createForOfIteratorHelper_15(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ___arrayLikeToArray_15(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?___arrayLikeToArray_15(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function ___arrayLikeToArray_15(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function __asyncGeneratorStep_15(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function ___asyncToGenerator_15(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_15(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_15(a,n,o,i,s,"throw",t)}i(void 0)}))}}function ___defineProperties_15(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Object.defineProperty(_$gist_15,"__esModule",{value:!0}),_$gist_15.default=void 0;var Gist=function(){function t(e){var r=e.token,n=e.key;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.http=(0,_$openApi_19.HTTP)({baseURL:"https://api.github.com",headers:{Authorization:"token ".concat(r),"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},events:{onResponse:function(t){return/^[45]/.test(String(t.statusCode))?Promise.reject("ERROR: ".concat(JSON.parse(t.body).message)):t}}}),this.key=n}var e,r,n,o,a;return e=t,(r=[{key:"locate",value:(a=___asyncToGenerator_15(___regeneratorRuntime_15().mark((function t(){var e=this;return ___regeneratorRuntime_15().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.http.get("/gists").then((function(t){var r,n=___createForOfIteratorHelper_15(JSON.parse(t.body));try{for(n.s();!(r=n.n()).done;){var o=r.value;if(o.description===e.key)return o.id}}catch(a){n.e(a)}finally{n.f()}return-1})));case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"upload",value:(o=___asyncToGenerator_15(___regeneratorRuntime_15().mark((function t(e){var r;return ___regeneratorRuntime_15().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.locate();case 2:if(-1!==(r=t.sent)){t.next=7;break}return t.abrupt("return",this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:e})}));case 7:return t.abrupt("return",this.http.patch({url:"/gists/".concat(r),body:JSON.stringify({files:e})}));case 8:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"download",value:(n=___asyncToGenerator_15(___regeneratorRuntime_15().mark((function t(e){var r,n,o,a;return ___regeneratorRuntime_15().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.locate();case 2:if(-1!==(r=t.sent)){t.next=7;break}return t.abrupt("return",Promise.reject("\u672a\u627e\u5230Gist\u5907\u4efd\uff01"));case 7:return t.prev=7,t.next=10,this.http.get("/gists/".concat(r)).then((function(t){return JSON.parse(t.body)}));case 10:return n=t.sent,o=n.files,a=o[e].raw_url,t.next=15,this.http.get(a).then((function(t){return t.body}));case 15:return t.abrupt("return",t.sent);case 18:return t.prev=18,t.t0=t.catch(7),t.abrupt("return",Promise.reject(t.t0));case 21:case"end":return t.stop()}}),t,this,[[7,18]])}))),function(t){return n.apply(this,arguments)})}])&&___defineProperties_15(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();_$gist_15.default=Gist;var _$artifacts_5={};function ___typeof_5(t){return(___typeof_5="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(_$artifacts_5,"__esModule",{value:!0}),_$artifacts_5.default=function(t){___app_5.default.read(_$constants_2.ARTIFACTS_KEY)||___app_5.default.write({},_$constants_2.ARTIFACTS_KEY),t.route("/api/artifacts").get(getAllArtifacts).post(createArtifact),t.route("/api/artifact/:name").get(getArtifact).patch(updateArtifact).delete(deleteArtifact)},_$artifacts_5.syncToGist=syncToGist;var ___app_5=_interopRequireDefault(_$app_3),_gist=_interopRequireDefault(_$gist_15);function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function ___regeneratorRuntime_5(){___regeneratorRuntime_5=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_5(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function __ownKeys_5(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ___objectSpread_5(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?__ownKeys_5(Object(r),!0).forEach((function(e){___defineProperty_5(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):__ownKeys_5(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ___defineProperty_5(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function __asyncGeneratorStep_5(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function ___asyncToGenerator_5(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_5(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_5(a,n,o,i,s,"throw",t)}i(void 0)}))}}function getAllArtifacts(t,e){var r=___app_5.default.read(_$constants_2.ARTIFACTS_KEY);(0,_$response_9.success)(e,r)}function getArtifact(t,e){return _getArtifact.apply(this,arguments)}function _getArtifact(){return(_getArtifact=___asyncToGenerator_5(___regeneratorRuntime_5().mark((function t(e,r){var n,o,a;return ___regeneratorRuntime_5().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.params.name,n=decodeURIComponent(n),o=___app_5.default.read(_$constants_2.ARTIFACTS_KEY),(a=(0,_$database_13.findByName)(o,n))?(0,_$response_9.success)(r,a):(0,_$response_9.failed)(r,new _$errors_7.ResourceNotFoundError("RESOURCE_NOT_FOUND","Artifact ".concat(n," does not exist!")),404);case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function createArtifact(t,e){var r=t.body;if(validateArtifactName(r.name)){___app_5.default.info("\u6b63\u5728\u521b\u5efa\u8fdc\u7a0b\u914d\u7f6e\uff1a".concat(r.name));var n=___app_5.default.read(_$constants_2.ARTIFACTS_KEY);(0,_$database_13.findByName)(n,r.name)?(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("DUPLICATE_KEY","Artifact ".concat(r.name," already exists."))):(n.push(r),___app_5.default.write(n,_$constants_2.ARTIFACTS_KEY),(0,_$response_9.success)(e,r,201))}else(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("INVALID_ARTIFACT_NAME","Artifact name ".concat(r.name," is invalid.")))}function updateArtifact(t,e){var r=___app_5.default.read(_$constants_2.ARTIFACTS_KEY),n=t.params.name;n=decodeURIComponent(n);var o=(0,_$database_13.findByName)(r,n);if(o){___app_5.default.info("\u6b63\u5728\u66f4\u65b0\u8fdc\u7a0b\u914d\u7f6e\uff1a".concat(o.name));var a=___objectSpread_5(___objectSpread_5({},o),t.body);if(!validateArtifactName(a.name))return void(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("INVALID_ARTIFACT_NAME","Artifact name ".concat(a.name," is invalid.")));(0,_$database_13.updateByName)(r,n,a),___app_5.default.write(r,_$constants_2.ARTIFACTS_KEY),(0,_$response_9.success)(e,a)}else(0,_$response_9.failed)(e,new _$errors_7.RequestInvalidError("DUPLICATE_KEY","Artifact ".concat(n," already exists.")))}function deleteArtifact(t,e){return _deleteArtifact.apply(this,arguments)}function _deleteArtifact(){return(_deleteArtifact=___asyncToGenerator_5(___regeneratorRuntime_5().mark((function t(e,r){var n,o,a,i;return ___regeneratorRuntime_5().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.params.name,n=decodeURIComponent(n),___app_5.default.info("\u6b63\u5728\u5220\u9664\u8fdc\u7a0b\u914d\u7f6e\uff1a".concat(n)),o=___app_5.default.read(_$constants_2.ARTIFACTS_KEY),t.prev=4,a=(0,_$database_13.findByName)(o,n)){t.next=8;break}throw new Error("\u8fdc\u7a0b\u914d\u7f6e\uff1a".concat(n,"\u4e0d\u5b58\u5728\uff01"));case 8:if(!a.updated){t.next=13;break}return(i={})[encodeURIComponent(a.name)]={content:""},t.next=13,syncToGist(i);case 13:(0,_$database_13.deleteByName)(o,n),___app_5.default.write(o,_$constants_2.ARTIFACTS_KEY),(0,_$response_9.success)(r),t.next=22;break;case 18:t.prev=18,t.t0=t.catch(4),___app_5.default.error("\u65e0\u6cd5\u5220\u9664\u8fdc\u7a0b\u914d\u7f6e\uff1a".concat(n,"\uff0c\u539f\u56e0\uff1a").concat(t.t0)),(0,_$response_9.failed)(r,new _$errors_7.InternalServerError("FAILED_TO_DELETE_ARTIFACT","Failed to delete artifact ".concat(n),"Reason: ".concat(t.t0)));case 22:case"end":return t.stop()}}),t,null,[[4,18]])})))).apply(this,arguments)}function validateArtifactName(t){return/^[a-zA-Z0-9._-]*$/.test(t)}function syncToGist(t){return _syncToGist.apply(this,arguments)}function _syncToGist(){return(_syncToGist=___asyncToGenerator_5(___regeneratorRuntime_5().mark((function t(e){var r,n,o;return ___regeneratorRuntime_5().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=___app_5.default.read(_$constants_2.SETTINGS_KEY),n=r.gistToken){t.next=3;break}return t.abrupt("return",Promise.reject("\u672a\u8bbe\u7f6eGist Token\uff01"));case 3:return o=new _gist.default({token:n,key:_$constants_2.ARTIFACT_REPOSITORY_KEY}),t.abrupt("return",o.upload(e));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var _$settings_10={};Object.defineProperty(_$settings_10,"__esModule",{value:!0}),_$settings_10.default=function(t){___app_10.default.read(_$constants_2.SETTINGS_KEY)||___app_10.default.write({},_$constants_2.SETTINGS_KEY),t.route("/api/settings").get(getSettings).patch(updateSettings)},_$settings_10.updateArtifactStore=updateArtifactStore,_$settings_10.updateGitHubAvatar=updateGitHubAvatar;var ___app_10=___interopRequireDefault_10(_$app_3),___gist_10=___interopRequireDefault_10(_$gist_15);function ___interopRequireDefault_10(t){return t&&t.__esModule?t:{default:t}}function ___typeof_10(t){return(___typeof_10="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function __ownKeys_10(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ___objectSpread_10(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?__ownKeys_10(Object(r),!0).forEach((function(e){___defineProperty_10(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):__ownKeys_10(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ___defineProperty_10(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ___regeneratorRuntime_10(){___regeneratorRuntime_10=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_10(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function __asyncGeneratorStep_10(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function ___asyncToGenerator_10(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_10(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_10(a,n,o,i,s,"throw",t)}i(void 0)}))}}function getSettings(t,e){return _getSettings.apply(this,arguments)}function _getSettings(){return(_getSettings=___asyncToGenerator_10(___regeneratorRuntime_10().mark((function t(e,r){var n;return ___regeneratorRuntime_10().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=___app_10.default.read(_$constants_2.SETTINGS_KEY)).avatarUrl){t.next=4;break}return t.next=4,updateGitHubAvatar();case 4:if(n.artifactStore){t.next=7;break}return t.next=7,updateArtifactStore();case 7:(0,_$response_9.success)(r,n);case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function updateSettings(t,e){return _updateSettings.apply(this,arguments)}function _updateSettings(){return(_updateSettings=___asyncToGenerator_10(___regeneratorRuntime_10().mark((function t(e,r){var n,o;return ___regeneratorRuntime_10().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=___app_10.default.read(_$constants_2.SETTINGS_KEY),o=___objectSpread_10(___objectSpread_10({},n),e.body),___app_10.default.write(o,_$constants_2.SETTINGS_KEY),t.next=5,updateGitHubAvatar();case 5:return t.next=7,updateArtifactStore();case 7:(0,_$response_9.success)(r,o);case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function updateGitHubAvatar(){return _updateGitHubAvatar.apply(this,arguments)}function _updateGitHubAvatar(){return(_updateGitHubAvatar=___asyncToGenerator_10(___regeneratorRuntime_10().mark((function t(){var e,r,n;return ___regeneratorRuntime_10().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=___app_10.default.read(_$constants_2.SETTINGS_KEY),!(r=e.githubUser)){t.next=14;break}return t.prev=3,t.next=6,___app_10.default.http.get({url:"https://api.github.com/users/".concat(r),headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"}}).then((function(t){return JSON.parse(t.body)}));case 6:n=t.sent,e.avatarUrl=n.avatar_url,___app_10.default.write(e,_$constants_2.SETTINGS_KEY),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(3),___app_10.default.error("Failed to fetch GitHub avatar for User: "+r);case 14:case"end":return t.stop()}}),t,null,[[3,11]])})))).apply(this,arguments)}function updateArtifactStore(){return _updateArtifactStore.apply(this,arguments)}function _updateArtifactStore(){return(_updateArtifactStore=___asyncToGenerator_10(___regeneratorRuntime_10().mark((function t(){var e,r,n,o,a;return ___regeneratorRuntime_10().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(___app_10.default.log("Updating artifact store"),e=___app_10.default.read(_$constants_2.SETTINGS_KEY),r=e.githubUser,n=e.gistToken,!r||!n){t.next=15;break}return o=new ___gist_10.default({token:n,key:_$constants_2.ARTIFACT_REPOSITORY_KEY}),t.prev=5,t.next=8,o.locate();case 8:-1!==(a=t.sent)&&(e.artifactStore="https://gist.github.com/".concat(r,"/").concat(a),___app_10.default.write(e,_$constants_2.SETTINGS_KEY)),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(5),___app_10.default.error("Failed to fetch artifact store for User: "+r);case 15:case"end":return t.stop()}}),t,null,[[5,12]])})))).apply(this,arguments)}var _$resourceCache_17={};Object.defineProperty(_$resourceCache_17,"__esModule",{value:!0}),_$resourceCache_17.default=void 0;var __obj_17,___app_17=(__obj_17=_$app_3)&&__obj_17.__esModule?__obj_17:{default:__obj_17};function _slicedToArray(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a=[],i=!0,s=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(c){s=!0,o=c}finally{try{i||null==r.return||r.return()}finally{if(s)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ___arrayLikeToArray_17(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?___arrayLikeToArray_17(t,e):void 0}}(t,e)||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 ___arrayLikeToArray_17(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ___defineProperties_17(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ___default_17=new(function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.expires=e,___app_17.default.read(_$constants_2.RESOURCE_CACHE_KEY)||___app_17.default.write("{}",_$constants_2.RESOURCE_CACHE_KEY),this.resourceCache=JSON.parse(___app_17.default.read(_$constants_2.RESOURCE_CACHE_KEY)),this._cleanup()}var e,r;return e=t,(r=[{key:"_cleanup",value:function(){var t=this,e=!1;Object.entries(this.resourceCache).forEach((function(r){var n=_slicedToArray(r,2),o=n[0],a=n[1];a.time||(delete t.resourceCache[o],___app_17.default.delete("#".concat(o)),e=!0),(new Date).getTime()-a.time>t.expires&&(delete t.resourceCache[o],e=!0)})),e&&this._persist()}},{key:"revokeAll",value:function(){this.resourceCache={},this._persist()}},{key:"_persist",value:function(){___app_17.default.write(JSON.stringify(this.resourceCache),_$constants_2.RESOURCE_CACHE_KEY)}},{key:"get",value:function(t){var e=this.resourceCache[t]&&this.resourceCache[t].time;return e&&(new Date).getTime()-e<=this.expires?this.resourceCache[t].data:null}},{key:"set",value:function(t,e){this.resourceCache[t]={time:(new Date).getTime(),data:e},this._persist()}}])&&___defineProperties_17(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}())(_$constants_2.CACHE_EXPIRATION_TIME_MS);_$resourceCache_17.default=___default_17;var _$miscs_8={};function ___typeof_8(t){return(___typeof_8="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(_$miscs_8,"__esModule",{value:!0}),_$miscs_8.default=function(t){var e,r;t.get("/api/utils/env",getEnv),t.get("/api/utils/backup",gistBackup),t.get("/api/utils/refresh",refresh),t.route("/api/storage").get((function(t,e){e.json(___app_8.default.read("#sub-store"))})).post((function(t,e){var r=t.body;___app_8.default.write(JSON.stringify(r),"#sub-store"),e.end()})),t.get("/",(r=___asyncToGenerator_8(___regeneratorRuntime_8().mark((function t(e,r){return ___regeneratorRuntime_8().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.set("location","https://sub-store.vercel.app/").status(302).end();case 1:case"end":return t.stop()}}),t)}))),function(t,e){return r.apply(this,arguments)})),(0,_$openApi_19.ENV)().isQX&&t.options("/",(e=___asyncToGenerator_8(___regeneratorRuntime_8().mark((function t(e,r){return ___regeneratorRuntime_8().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.status(200).end();case 1:case"end":return t.stop()}}),t)}))),function(t,r){return e.apply(this,arguments)})),t.all("/",(function(t,e){e.send("Hello from sub-store, made with \u2764\ufe0f by Peng-YM")}))};var ___app_8=___interopRequireDefault_8(_$app_3),_resourceCache=___interopRequireDefault_8(_$resourceCache_17),___gist_8=___interopRequireDefault_8(_$gist_15),_migration=___interopRequireDefault_8(_$migration_16);function ___interopRequireDefault_8(t){return t&&t.__esModule?t:{default:t}}function ___regeneratorRuntime_8(){___regeneratorRuntime_8=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch($){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new S(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=b(i,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch($){return{type:"throw",arg:$}}}t.wrap=c;var _={};function f(){}function l(){}function p(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,y=d&&d(d(O([])));y&&y!==e&&r.call(y,o)&&(h=y);var v=p.prototype=f.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,s){var c=u(t[o],t,a);if("throw"!==c.type){var _=c.arg,f=_.value;return f&&"object"==___typeof_8(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,_;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,_):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=p,s(v,"constructor",p),s(p,"constructor",l),l.displayName=s(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},m(g.prototype),s(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new g(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(v),s(v,i,"Generator"),s(v,o,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),_}},t}function __asyncGeneratorStep_8(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(u){return void r(u)}s.done?e(c):Promise.resolve(c).then(n,o)}function ___asyncToGenerator_8(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){__asyncGeneratorStep_8(a,n,o,i,s,"next",t)}function s(t){__asyncGeneratorStep_8(a,n,o,i,s,"throw",t)}i(void 0)}))}}function getEnv(t,e){var r=(0,_$openApi_19.ENV)(),n="Node";r.isNode&&(n="Node"),r.isQX&&(n="QX"),r.isLoon&&(n="Loon"),r.isSurge&&(n="Surge"),r.isStash&&(n="Stash"),r.isShadowRocket&&(n="ShadowRocket"),(0,_$response_9.success)(e,{backend:n,version:_$package_1.version})}function refresh(t,e){return _refresh.apply(this,arguments)}function _refresh(){return(_refresh=___asyncToGenerator_8(___regeneratorRuntime_8().mark((function t(e,r){return ___regeneratorRuntime_8().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,_$settings_10.updateGitHubAvatar)();case 2:return t.next=4,(0,_$settings_10.updateArtifactStore)();case 4:_resourceCache.default.revokeAll(),(0,_$response_9.success)(r);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function gistBackup(t,e){return _gistBackup.apply(this,arguments)}function _gistBackup(){return(_gistBackup=___asyncToGenerator_8(___regeneratorRuntime_8().mark((function t(e,r){var n,o,a,i,s,c,u;return ___regeneratorRuntime_8().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.query.action,o=___app_8.default.read(_$constants_2.SETTINGS_KEY),a=o.gistToken){t.next=6;break}(0,_$response_9.failed)(r,new _$errors_7.RequestInvalidError("GIST_TOKEN_NOT_FOUND","GitHub Token is required for backup!")),t.next=43;break;case 6:i=new ___gist_8.default({token:a,key:_$constants_2.GIST_BACKUP_KEY}),t.prev=7,c=___app_8.default.read(_$constants_2.SETTINGS_KEY),u=c.syncTime,t.t0=n,t.next="upload"===t.t0?13:"download"===t.t0?29:37;break;case 13:return c.syncTime=(new Date).getTime(),___app_8.default.write(c,_$constants_2.SETTINGS_KEY),s=___app_8.default.read("#sub-store"),___app_8.default.env.isNode&&(s=JSON.stringify(___app_8.default.cache,null," ")),___app_8.default.info("\u4e0a\u4f20\u5907\u4efd\u4e2d..."),t.prev=18,t.next=21,i.upload((_={},f=_$constants_2.GIST_BACKUP_FILE_NAME,l={content:s},f in _?Object.defineProperty(_,f,{value:l,enumerable:!0,configurable:!0,writable:!0}):_[f]=l,_));case 21:t.next=28;break;case 23:throw t.prev=23,t.t1=t.catch(18),c.syncTime=u,___app_8.default.write(c,_$constants_2.SETTINGS_KEY),t.t1;case 28:return t.abrupt("break",37);case 29:return ___app_8.default.info("\u8fd8\u539f\u5907\u4efd\u4e2d..."),t.next=32,i.download(_$constants_2.GIST_BACKUP_FILE_NAME);case 32:return s=t.sent,___app_8.default.write(s,"#sub-store"),___app_8.default.env.isNode&&(s=JSON.parse(s),___app_8.default.cache=s,___app_8.default.persistCache()),(0,_migration.default)(),t.abrupt("break",37);case 37:(0,_$response_9.success)(r),t.next=43;break;case 40:t.prev=40,t.t2=t.catch(7),(0,_$response_9.failed)(r,new _$errors_7.InternalServerError("BACKUP_FAILED","Failed to ".concat(n," data to gist!"),"Reason: ".concat(JSON.stringify(t.t2))));case 43:case"end":return t.stop()}var _,f,l}),t,null,[[7,40],[18,23]])})))).apply(this,arguments)}var _$sort_11={};Object.defineProperty(_$sort_11,"__esModule",{value:!0}),_$sort_11.default=function(t){t.post("/api/sort/subs",sortSubs),t.post("/api/sort/collections",sortCollections),t.post("/api/sort/artifacts",sortArtifacts)};var __obj_11,___app_11=(__obj_11=_$app_3)&&__obj_11.__esModule?__obj_11:{default:__obj_11};function sortSubs(t,e){var r=t.body,n=___app_11.default.read(_$constants_2.SUBS_KEY);n.sort((function(t,e){return r.indexOf(t)-r.indexOf(e)})),___app_11.default.write(n,_$constants_2.SUBS_KEY),(0,_$response_9.success)(e,n)}function sortCollections(t,e){var r=t.body,n=___app_11.default.read(_$constants_2.COLLECTIONS_KEY);n.sort((function(t,e){return r.indexOf(t)-r.indexOf(e)})),___app_11.default.write(n,_$constants_2.COLLECTIONS_KEY),(0,_$response_9.success)(e,n)}function sortArtifacts(t,e){var r=t.body,n=___app_11.default.read(_$constants_2.ARTIFACTS_KEY);n.sort((function(t,e){return r.indexOf(t)-r.indexOf(e)})),___app_11.default.write(n,_$constants_2.ARTIFACTS_KEY),(0,_$response_9.success)(e,n)}var _$subStore0_4={},$app,___migration_4=___interopRequireDefault_4(_$migration_16),_express=___interopRequireDefault_4(_$express_18),___app_4=___interopRequireDefault_4(_$app_3),_collections=___interopRequireDefault_4(_$collections_6),_subscriptions=___interopRequireDefault_4(_$subscriptions_12),_artifacts=___interopRequireDefault_4(_$artifacts_5),___settings_4=___interopRequireDefault_4(_$settings_10),_miscs=___interopRequireDefault_4(_$miscs_8),_sort=___interopRequireDefault_4(_$sort_11);function ___interopRequireDefault_4(t){return t&&t.__esModule?t:{default:t}}console.log("\n\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\n Sub-Store -- v".concat(_$package_1.version,"\n\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\n")),(0,___migration_4.default)(),$app=(0,_express.default)({substore:___app_4.default}),(0,_collections.default)($app),(0,_subscriptions.default)($app),(0,_artifacts.default)($app),(0,___settings_4.default)($app),(0,_sort.default)($app),(0,_miscs.default)($app),$app.start()}();