/** * ███████╗██╗ ██╗██████╗ ███████╗████████╗ ██████╗ ██████╗ ███████╗ * ██╔════╝██║ ██║██╔══██╗ ██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝ * ███████╗██║ ██║██████╔╝█████╗███████╗ ██║ ██║ ██║██████╔╝█████╗ * ╚════██║██║ ██║██╔══██╗╚════╝╚════██║ ██║ ██║ ██║██╔══██╗██╔══╝ * ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗ * ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ * Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket! * @updated: 2022/9/10 00:46:41 * @version: 2.13.2 * @author: Peng-YM * @github: https://github.com/Peng-YM/Sub-Store * @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46 */ !function(){var _$package_1={version:"2.13.2"},_$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=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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 c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).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,c,"next",t)}function c(t){asyncGeneratorStep(a,n,o,i,c,"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;r0&&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 c=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(c,"\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",s(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,s(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)||{},c=Object.values(i);function s(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,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(c)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 c=i.args,s=c.key,u=c.value;switch(s){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(c,_$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);r1&&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 c,s=extractURL(o),u=s.path,_=s.query,f=null,l=0;for(c=r;cl&&(f=handlers[c],l=p.split("/").length)}if(f){var h=function(){t(n,o,c)},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]:"",c={status:r?i[t]:t,body:e,headers:a};r?$done(c):(n||o)&&$done({response:c})}},{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=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,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function ___arrayLikeToArray_6(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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 c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).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.0.30 (iPhone14,2; iOS 15.6)"}});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,c,"next",t)}function c(t){__asyncGeneratorStep_14(a,n,o,i,c,"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 c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch($){c=function(t,e,r){return t[e]=r}}function s(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 c=b(i,r);if(c){if(c===_)continue;return c}}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 s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===_)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.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=s;var _={};function f(){}function l(){}function p(){}var h={};c(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){c(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,c){var s=u(t[o],t,a);if("throw"!==s.type){var _=s.arg,f=_.value;return f&&"object"==___typeof_12(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,c)}))}c(s.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=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function ___arrayLikeToArray_12(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function ___arrayLikeToArray_15(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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 c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).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,c,"next",t)}function c(t){__asyncGeneratorStep_10(a,n,o,i,c,"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,c=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(s){c=!0,o=s}finally{try{i||null==r.return||r.return()}finally{if(c)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);rt.expires&&(___app_17.default.delete("#".concat(o)),delete t.resourceCache[o],e=!0)})),e&&this._persist()}},{key:"revokeAll",value:function(){Object.keys(this.resourceCache).forEach((function(t){___app_17.default.delete("#".concat(t))})),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];return e&&(new Date).getTime()-e<=this.expires?___app_17.default.read("#".concat(t)):null}},{key:"set",value:function(t,e){this.resourceCache[t]=(new Date).getTime(),this._persist(),___app_17.default.write(e,"#".concat(t))}}])&&___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 c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch($){c=function(t,e,r){return t[e]=r}}function s(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 c=b(i,r);if(c){if(c===_)continue;return c}}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 s=u(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===_)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.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=s;var _={};function f(){}function l(){}function p(){}var h={};c(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){c(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,c){var s=u(t[o],t,a);if("throw"!==s.type){var _=s.arg,f=_.value;return f&&"object"==___typeof_8(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(f).then((function(t){_.value=t,i(_)}),(function(t){return n("throw",t,i,c)}))}c(s.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=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=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 c=t[a](i),s=c.value}catch(u){return void r(u)}c.done?e(s):Promise.resolve(s).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,c,"next",t)}function c(t){__asyncGeneratorStep_8(a,n,o,i,c,"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,c,s,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,s=___app_8.default.read(_$constants_2.SETTINGS_KEY),u=s.syncTime,t.t0=n,t.next="upload"===t.t0?13:"download"===t.t0?29:37;break;case 13:return s.syncTime=(new Date).getTime(),___app_8.default.write(s,_$constants_2.SETTINGS_KEY),c=___app_8.default.read("#sub-store"),___app_8.default.env.isNode&&(c=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:c},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),s.syncTime=u,___app_8.default.write(s,_$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 c=t.sent,___app_8.default.write(c,"#sub-store"),___app_8.default.env.isNode&&(c=JSON.parse(c),___app_8.default.cache=c,___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()}();