@cyberskill/shared 1.72.0 → 1.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(t){if(Array.isArray(t))return e(t)}function n(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,t,r,n,s,i,o){try{var a=e[i](o);var c=a.value}catch(e){r(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(n,s)}}function i(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,c,"next",e)}function c(e){s(o,n,i,a,c,"throw",e)}a(undefined)})}}function o(e,t,r){t=d(t);return A(e,D()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function u(e,t,r){if(t)c(e.prototype,t);if(r)c(e,r);return e}function l(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function d(e){d=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return d(e)}function f(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)N(e,t)}function p(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function E(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function m(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var s=true;var i=false;var o,a;try{for(r=r.call(e);!(s=(o=r.next()).done);s=true){n.push(o.value);if(t&&n.length===t)break}}catch(e){i=true;a=e}finally{try{if(!s&&r["return"]!=null)r["return"]()}finally{if(i)throw a}}return n}function g(){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 h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){l(e,t,r[t])})}return e}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function _(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{y(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function S(e,t){if(e==null)return{};var r=O(e,t);var n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++){n=i[s];if(t.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function O(e,t){if(e==null)return{};var r={};var n=Object.keys(e);var s,i;for(i=0;i<n.length;i++){s=n[i];if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function A(e,t){if(t&&(T(t)==="object"||typeof t==="function")){return t}return n(e)}function N(e,t){N=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return N(e,t)}function I(e,r){return t(e)||m(e,r)||R(e,r)||g()}function C(e){return r(e)||E(e)||R(e)||h()}function T(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function R(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function b(e,t){var r,n,s,i,o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");while(o)try{if(r=1,n&&(s=i[0]&2?n["return"]:i[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;if(n=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;n=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){o.label=i[1];break}if(i[0]===6&&o.label<s[1]){o.label=s[1];s=i;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(i);break}if(s[2])o.ops.pop();o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e];n=0}finally{r=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var w={extends:["@commitlint/config-conventional"]};var x=function(e){return e.ESLINT="eslint",e.COMMITLINT="commitlint",e.LINT_STAGED="lint-staged",e.VITEST_REACT_E2E="vitest-react-e2e",e.VITEST_REACT_UNIT="vitest-react-unit",e}(x||{});import L from"@antfu/eslint-config";import P from"@vitejs/plugin-react-swc";import{defineConfig as M}from"vitest/config";function j(e){return M(v({plugins:[P()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}},e))}import G from"@vitejs/plugin-react-swc";import{defineConfig as k}from"vitest/config";import U from"node:process";var F=function(e){return e.PNPM_ADD_AND_EXEC="PNPM_ADD_AND_EXEC",e.PNPM_ADD_DEV_AND_EXEC="PNPM_ADD_DEV_AND_EXEC",e.RAW="RAW",e}(F||{});import{exec as q}from"node:child_process";import K from"node:process";import*as H from"node:util";import Y from"node:process";var B=Y.env.DEBUG==="true";var V=function(e){return e.Error="error",e.Warning="warning",e}(V||{});import Q from"chalk";import J from"consola";import{GraphQLError as W}from"graphql";var X={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function z(e){var t=e.message,r=e.status,n=r===void 0?X.INTERNAL_SERVER_ERROR:r,s=e.type,i=s===void 0?"graphql":s;var o;var a=(o=t!==null&&t!==void 0?t:n.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw i==="graphql"?new W(a,{extensions:{code:n.CODE}}):new Error(a)}B||(J.level=4);function $(e){var t=Q[e];return typeof t=="function"?t:Q.green}var Z={silent:J.silent,level:J.level,fatal:J.fatal,error:J.error,warn:J.warn,log:J.log,info:J.info,success:J.success,ready:J.ready,start:J.start,box:J.box,debug:J.debug,trace:J.trace,verbose:J.verbose,printBoxedLog:function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){J.box(Q.green(e));return}t.forEach(function(e){var t=e.file,n=e.position,s=e.rule,i=e.message;J.log("".concat(Q.gray("File:")," ").concat(Q.blue("".concat(t).concat(n?":".concat(n):"")))),s&&J.log(" ".concat($(r)("Rule:")," ").concat(s)),J.log(" ".concat($(r)("Message:")," ").concat(i))}),J.box($(r)("".concat(e," : ").concat(t.length))),J.log(Q.gray("─".repeat(40)))}};var ee={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};import et from"node-fetch";import*as er from"node:fs";function en(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return t.every(function(e){return er.existsSync(e)})}function es(e,t){var r=er.readFileSync(e,"utf-8");if(t===null||t===void 0?void 0:t.asJson)try{var n=JSON.parse(r);if((typeof n==="undefined"?"undefined":T(n))=="object"&&n!==null)return n;throw new Error("Parsed JSON is not an object or array")}catch(t){throw new Error("Failed to parse JSON from file: ".concat(e))}return r}function ei(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=r.isJson,s=n===void 0?!1:n,i=s&&(typeof t==="undefined"?"undefined":T(t))=="object"?JSON.stringify(t,null,4):String(t);er.writeFileSync(e,i,"utf-8")}function eo(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=r.isJson,s=n===void 0?!1:n,i=s&&(typeof t==="undefined"?"undefined":T(t))=="object"?JSON.stringify(t,null,4):String(t);er.appendFileSync(e,i,"utf-8")}function ea(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}t.forEach(function(e){en(e)&&er.rmSync(e,{recursive:!0,force:!0})})}var ec={};function eu(e){if(e in ec)return ec[e];var t=eq(eK,eQ);if(!en(t))return ec[e]=!1;try{var r,n;var s=es(t,{asJson:!0}),i=s.name===e,o=!!((r=s.dependencies)===null||r===void 0?void 0:r[e]),a=!!((n=s.devDependencies)===null||n===void 0?void 0:n[e]);return i||o||a?ec[e]={path:t,file:s,isCurrentProject:i,isDepend:o,isDevDepend:a}:ec[e]=!1}catch(t){return Z.warn("Failed to read package.json: ".concat(t.message)),ec[e]=!1}}function el(e){return ed.apply(this,arguments)}function ed(){ed=i(function(e){var t,r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,et("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=i.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:r=i.sent(),n=r.version;return[2,n];case 3:s=i.sent();throw Z.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})});return ed.apply(this,arguments)}function ef(e,t){return ep.apply(this,arguments)}function ep(){ep=i(function(e,t){var r,n,s,i,o,a,c,u,d,f,p,E,m,g,h;return b(this,function(y){switch(y.label){case 0:y.trys.push([0,4,,5]);o=eu(e);if(!o)return[2,v({},ee)];a=o.path,c=o.file,u=o.isCurrentProject,d=o.isDepend,f=o.isDevDepend,p="0.0.0";u&&c.version?p=c.version:d&&((r=c.dependencies)===null||r===void 0?void 0:r[e])?p=(n=c.dependencies)===null||n===void 0?void 0:n[e]:f&&((s=c.devDependencies)===null||s===void 0?void 0:s[e])&&(p=(i=c.devDependencies)===null||i===void 0?void 0:i[e]);if(!u)return[3,1];g=p;return[3,3];case 1:return[4,el(e)];case 2:g=y.sent();y.label=3;case 3:E=g,m=u||p===E;return[2,(!m&&(t===null||t===void 0?void 0:t.update)&&(d?c.dependencies=_(v({},c.dependencies||{}),l({},e,E)):f&&(c.devDependencies=_(v({},c.devDependencies||{}),l({},e,E))),Z.info('Updating package "'.concat(e,'" to version ').concat(E)),ei(a,c,{isJson:!0})),{isCurrentProject:u,installedPath:a,file:c,isUpToDate:m})];case 4:h=y.sent();return[2,(Z.error('Error checking package "'.concat(e,'": ').concat(h.message)),v({},ee))];case 5:return[2]}})});return ep.apply(this,arguments)}import eE from"node-persist";import em from"node:os";import eg from"node:process";function eh(){return eg.env.CYBERSKILL_STORAGE_DIR||eq(em.homedir(),eY)}function ev(){return ey.apply(this,arguments)}function ey(){ey=i(function(){var e;return b(this,function(t){switch(t.label){case 0:e=eE.defaultInstance;if(e)return[3,2];return[4,eE.init({dir:eh(),stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return ey.apply(this,arguments)}var e_={get:function e(e){return i(function(){var t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ev()];case 1:n.sent();return[4,eE.getItem(e)];case 2:return[2,(t=n.sent())!==null&&t!==void 0?t:null];case 3:r=n.sent();return[2,(Z.error('[Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ev()];case 1:n.sent();return[4,eE.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();Z.error('[Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ev()];case 1:r.sent();return[4,eE.removeItem(e)];case 2:r.sent();return[3,4];case 3:t=r.sent();Z.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ev()];case 1:r.sent();return[4,eE.keys()];case 2:e=r.sent();return[2,Array.isArray(e)?e:(Z.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=r.sent();return[2,(Z.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return b(this,function(t){try{return[2,"".concat(eh()," (key: ").concat(e,")")]}catch(e){return[2,(Z.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var eS=H.promisify(q);function eO(e){return"error_list:".concat(e)}function eA(e){return eN.apply(this,arguments)}function eN(){eN=i(function(e){var t,r,n;return b(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];t=Date.now(),r=eO(t);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,e_.set(r,{errors:e,timestamp:t})];case 2:s.sent(),setTimeout(/*#__PURE__*/i(function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,e_.getLogLink(r)];case 1:e=t.sent();e&&Z.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:n=s.sent();Z.error("Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return eN.apply(this,arguments)}function eI(){return eC.apply(this,arguments)}function eC(){eC=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e_.keys()];case 1:e=n.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=i(function(e){var t;return b(this,function(r){switch(r.label){case 0:return[4,e_.get(e)];case 1:return[2,((t=r.sent())===null||t===void 0?void 0:t.errors)||[]]}})});return function(t){return e.apply(this,arguments)}}()))];case 2:return[2,n.sent().flat()];case 3:r=n.sent();return[2,(Z.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return eC.apply(this,arguments)}function eT(){return eR.apply(this,arguments)}function eR(){eR=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e_.keys()];case 1:e=n.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return e_.remove(e)}))];case 2:n.sent();return[3,4];case 3:r=n.sent();Z.error("Failed to clear error lists: ".concat(r.message));return[3,4];case 4:return[2]}})});return eR.apply(this,arguments)}function eD(e){var t=[],r=[],n="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,i=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var a=s.exec(e)||[],c=i.exec(e)||[],u=o.exec(e)||[];a.length&&n?t.push({file:n,position:"".concat(a[1],":").concat(a[2]),type:a[3]==="error"?"error":"warning",message:a[4].trim(),rule:a[5].trim()}):c.length?t.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):r.push(e.trim())}}),t.length&&eA(t),B&&r.length&&(Z.warn("Unmatched lines:"),r.forEach(function(e){return Z.info(" ".concat(e))}))}function eb(e){try{var t=JSON.parse(e),r=[];t.forEach(function(e){var t=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,s=e.line,i=e.column,o=e.ruleId,a=e.message;r.push({type:n===2?"error":"warning",file:t,position:"".concat(s,":").concat(i),rule:o,message:a})})}),r.length&&eA(r)}catch(t){eD(e)}}function ew(e){return ex.apply(this,arguments)}function ex(){ex=i(function(e){var t,r,n,s,i,o,a,c,u;var l=arguments;return b(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:eb;r=new AbortController;K.on("SIGINT",function(){Z.warn("Process interrupted. Terminating..."),r.abort(),K.exit()});d.label=1;case 1:d.trys.push([1,3,,4]);return[4,eS(e,{maxBuffer:0x6400000,signal:r.signal})];case 2:n=d.sent(),s=n.stdout,i=n.stderr;[s,i].forEach(function(e){return e&&t(e)});return[3,4];case 3:o=d.sent();a=o.stdout,c=o.stderr,u=o.message;[a,c].forEach(function(e){return e&&t(e)}),!c&&!a&&Z.error("Command failed: ".concat(u));return[3,4];case 4:return[2]}})});return ex.apply(this,arguments)}function eL(e){return{raw:!0,cmd:e}}function eP(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(tc," ").concat(eH," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tc," ").concat(ti," ").concat(e3," ").concat(e):"".concat(tc," ").concat(e2," ").concat(e)}function eM(e,t){return typeof e=="function"?eP(e(t),t):(typeof e==="undefined"?"undefined":T(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?eP(e,t):e}function ej(e){return eG.apply(this,arguments)}function eG(){eG=i(function(e){var t,r,n,s,i,o,a;var c=arguments;return b(this,function(u){switch(u.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:{};n=(r=t===null||t===void 0?void 0:t.isRemote)!==null&&r!==void 0?r:!1;if(!n)return[3,1];a=!1;return[3,3];case 1:return[4,ef(eH)];case 2:a=u.sent().isCurrentProject;u.label=3;case 3:s=a,i={isRemote:n,isCurrentProject:s},o=typeof e=="function"?e(i):e;return[2,Object.fromEntries(Object.entries(o).map(function(e){var t=I(e,2),r=t[0],n=t[1];return[r,eM(n,i)]}))]}})});return eG.apply(this,arguments)}import*as ek from"node:path";function eU(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).resolve.apply(n,[eK].concat(C(t)))}function eF(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).resolve.apply(n,C(t))}function eq(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).join.apply(n,C(t))}var eK=U.env.INIT_CWD||U.cwd(),eH="@cyberskill/shared",eY=".cyberskill-storage",eB="node_modules",eV="dist",eQ="package.json",eJ="package-lock.json",eW="tsconfig.json",eX=".gitignore",ez=".simple-git-hooks.json",e$="pnpm-lock.yaml",eZ=".git/hooks/",e0=".git/COMMIT_EDITMSG",e1=eq(eK,eB,eH,eV),e2="cyberskill",e3="src/nodejs/cli/index.ts",e4="eslint",e5="eslint",e8="vitest",e6="playwright",e7="vitest",e9="@commitlint/cli",te="commitlint",tt="lint-staged",tr="lint-staged",tn="typescript",ts="tsc",ti="tsx",to="git",ta="pnpm",tc="pnpm exec",tu="simple-git-hooks",tl="simple-git-hooks",td="@eslint/config-inspector",tf="eslint-config-inspector",tp="node-modules-inspector",tE="node-modules-inspector",tm={CYBERSKILL_DIRECTORY:e1,WORKING_DIRECTORY:eK,TS_CONFIG:eU(eW),GIT_IGNORE:eU(eX),GIT_HOOK:eU(eZ),GIT_COMMIT_MSG:eU(e0),SIMPLE_GIT_HOOKS_JSON:eU(ez),PACKAGE_JSON:eU(eQ),PACKAGE_LOCK_JSON:eU(eJ),PNPM_LOCK_YAML:eU(e$),NODE_MODULES:eU(eB),CYBERSKILL:{LINT_STAGED_CONFIG:eU("".concat(e1,"/configs/lint-staged/base.js")),COMMITLINT_CONFIG:eU("".concat(e1,"/configs/commitlint/base.js")),UNIT_TEST_CONFIG:eU("".concat(e1,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:eU("".concat(e1,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:eU("".concat(e1,"/react/vitest/vitest.e2e.js"))}};function tg(e){var t=e.isCurrentProject;return v({"pre-commit":tr,"commit-msg":te},t&&{"pre-push":eL("".concat(to," pull"))})}function th(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}var s=I(r,2),i=s[0],o=s[1],a=e==="RAW"?!0:en.apply(void 0,C(i.split(" ").map(function(e){return eq(tm.NODE_MODULES,e)})));switch(e){case"PNPM_ADD_AND_EXEC":return eM(eL("".concat(a?"":"".concat(ta," add ").concat(i," && ")).concat(tc," ").concat(o)));case"PNPM_ADD_DEV_AND_EXEC":return eM(eL("".concat(a?"":"".concat(ta," add -D ").concat(i," && ")).concat(tc," ").concat(o)));case"RAW":return eM(eL(i))}}var tv={SIMPLE_GIT_HOOKS:th("PNPM_ADD_DEV_AND_EXEC",tu,tl),ESLINT_INSPECT:th("PNPM_ADD_DEV_AND_EXEC",td,tf),NODE_MODULES_INSPECT:th("PNPM_ADD_DEV_AND_EXEC",tp,tE),ESLINT_CHECK:th("PNPM_ADD_DEV_AND_EXEC",e4,"".concat(e5," ").concat(tm.WORKING_DIRECTORY)),ESLINT_FIX:th("PNPM_ADD_DEV_AND_EXEC",e4,"".concat(e5," ").concat(tm.WORKING_DIRECTORY," --fix")),TYPESCRIPT_CHECK:th("PNPM_ADD_AND_EXEC",tn,"".concat(ts," -p ").concat(tm.TS_CONFIG," --noEmit")),CONFIGURE_GIT_HOOK:th("RAW","".concat(to," config core.hooksPath ").concat(tm.GIT_HOOK)),BUILD:th("RAW","".concat(ta," run build")),STAGE_BUILD_DIRECTORY:th("RAW","".concat(to," add ").concat(eV)),PNPM_INSTALL_STANDARD:th("RAW","".concat(ta," install")),PNPM_INSTALL_LEGACY:th("RAW","".concat(ta," install --legacy-peer-deps")),PNPM_INSTALL_FORCE:th("RAW","".concat(ta," install --force")),CYBERSKILL:{TEST_UNIT:th("PNPM_ADD_AND_EXEC",e8,"".concat(e7," --config ").concat(tm.CYBERSKILL.UNIT_TEST_CONFIG)),TEST_E2E:th("PNPM_ADD_AND_EXEC","".concat(e8," ").concat(e6),"".concat(e7," --config ").concat(tm.CYBERSKILL.E2E_TEST_CONFIG)),COMMIT_LINT:th("PNPM_ADD_DEV_AND_EXEC",e9,"".concat(te," --edit ").concat(tm.GIT_COMMIT_MSG," --config ").concat(tm.CYBERSKILL.COMMITLINT_CONFIG)),LINT_STAGED:th("PNPM_ADD_DEV_AND_EXEC",tt,"".concat(tr," --config ").concat(tm.CYBERSKILL.LINT_STAGED_CONFIG))}};function ty(e){return k(v({plugins:[G()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:[tm.CYBERSKILL.UNIT_TEST_SETUP_CONFIG]}},e))}function t_(e){try{return JSON.parse(e),!0}catch(e){return!1}}function tS(e){return!!e&&(typeof e==="undefined"?"undefined":T(e))=="object"&&!Array.isArray(e)}function tO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return t.flat().reduce(function(e,t){var r=true,n=false,s=undefined;try{for(var i=Object.entries(t)[Symbol.iterator](),o;!(r=(o=i.next()).done);r=true){var a=I(o.value,2),c=a[0],u=a[1];var l=e[c];Array.isArray(u)?e[c]=Array.from(new Set(C(Array.isArray(l)?l:[]).concat(C(u)))):tS(u)?e[c]=tO(tS(l)?l:{},u):e[c]=u}}catch(e){n=true;s=e}finally{try{if(!r&&i.return!=null){i.return()}}finally{if(n){throw s}}}return e},{})}import*as tA from"globals";var tN=[{languageOptions:{globals:v({},tA.node,tA.browser)},rules:{"perfectionist/sort-imports":["error",{internalPattern:["^#.*","^@/.*"]}]},ignores:["build","dist"]}];var tI=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return tO.apply(void 0,C(t))},tC=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n=tO.apply(void 0,[tN].concat(C(t))),s=n.ignores,i=S(n,["ignores"]),o=Array.isArray(s)&&s.every(function(e){return typeof e=="string"})?{ignores:s}:void 0,a=[i].concat(C(o?[o]:[]));return L.apply(void 0,[{stylistic:{semi:!0,indent:4,quotes:"single"},formatters:{css:!0,html:!0,markdown:"prettier"},yaml:!1,react:!0}].concat(C(a)))},tT=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return j.apply(void 0,C(t))},tR=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return ty.apply(void 0,C(t))},tD={eslint:tC,commitlint:tI,"lint-staged":tI,"vitest-react-e2e":tT,"vitest-react-unit":tR};function tb(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}var s=tD[e];if(!s)throw new Error("Unknown config type: ".concat(e));return s.apply(void 0,C(r))}function tw(e){var t=e.uri,r=e.from,n=e.to,s=e.withComponent,i=e.withHOC,o=e.withHooks,a=e.withMutationFn,c=e.withRefetchFn,u=e.federation;var d=v({},s&&{withComponent:s},i&&{withHOC:i},o&&{withHooks:o},a&&{withMutationFn:a},c&&{withRefetchFn:c},u&&{config:{federation:!0}});return{schema:t,documents:[r],generates:l({},n,v({plugins:["typescript","typescript-operations","typescript-react-apollo"]},Object.keys(d).length>0&&{config:d})),hooks:{afterAllFileWrite:[tv.ESLINT_FIX]}}}var tx={"*":["eslint --fix"]};var tL=(typeof window==="undefined"?"undefined":T(window))<"u";var tP={lint:"Check code for linting issues","lint:fix":"Fix linting issues automatically","lint:inspect":"View active ESLint configuration","lint-staged":"Run lint checks on staged files",commitlint:"Validate commit message format",setup:"Initialize project setup and dependencies",reset:"Reset the project and reinstall dependencies",inspect:"Analyze installed project dependencies","test:unit":"Run unit test suite","test:e2e":"Run end-to-end test suite"};import tM from"node:process";import{hideBin as tj}from"yargs/helpers";import tG from"yargs/yargs";var tk={name:"@cyberskill/shared",type:"module",version:"1.71.0",description:"CyberSkill Shared",author:"Stephen Cheng",license:"MIT",homepage:"https://github.com/cyberskill-world/shared#readme",repository:{type:"git",url:"git+https://github.com/cyberskill-world/shared.git"},bugs:{url:"https://github.com/cyberskill-world/shared/issues"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./configs":{types:"./dist/configs/index.d.ts",import:"./dist/configs/index.js",require:"./dist/configs/index.cjs"},"./configs/commitlint":{types:"./dist/configs/commitlint/index.d.ts",import:"./dist/configs/commitlint/index.js",require:"./dist/configs/commitlint/index.cjs"},"./configs/eslint":{types:"./dist/configs/eslint/index.d.ts",import:"./dist/configs/eslint/index.js",require:"./dist/configs/eslint/index.cjs"},"./configs/graphql-codegen":{types:"./dist/configs/graphql-codegen/index.d.ts",import:"./dist/configs/graphql-codegen/index.js",require:"./dist/configs/graphql-codegen/index.cjs"},"./configs/lint-staged":{types:"./dist/configs/lint-staged/index.d.ts",import:"./dist/configs/lint-staged/index.js",require:"./dist/configs/lint-staged/index.cjs"},"./configs/vitest/react/e2e":{types:"./dist/configs/vitest/react/e2e.d.ts",import:"./dist/configs/vitest/react/e2e.js",require:"./dist/configs/vitest/react/e2e.cjs"},"./configs/vitest/react/unit":{types:"./dist/configs/vitest/react/unit.d.ts",import:"./dist/configs/vitest/react/unit.js",require:"./dist/configs/vitest/react/unit.cjs"},"./constants":{types:"./dist/constants/index.d.ts",import:"./dist/constants/index.js",require:"./dist/constants/index.cjs"},"./nodejs":{types:"./dist/nodejs/index.d.ts",import:"./dist/nodejs/index.js",require:"./dist/nodejs/index.cjs"},"./nodejs/cli":{types:"./dist/nodejs/cli/index.d.ts",import:"./dist/nodejs/cli/index.js",require:"./dist/nodejs/cli/index.cjs"},"./nodejs/command":{types:"./dist/nodejs/command/index.d.ts",import:"./dist/nodejs/command/index.js",require:"./dist/nodejs/command/index.cjs"},"./nodejs/fs":{types:"./dist/nodejs/fs/index.d.ts",import:"./dist/nodejs/fs/index.js",require:"./dist/nodejs/fs/index.cjs"},"./nodejs/log":{types:"./dist/nodejs/log/index.d.ts",import:"./dist/nodejs/log/index.js",require:"./dist/nodejs/log/index.cjs"},"./nodejs/mongo":{types:"./dist/nodejs/mongo/index.d.ts",import:"./dist/nodejs/mongo/index.js",require:"./dist/nodejs/mongo/index.cjs"},"./nodejs/package":{types:"./dist/nodejs/package/index.d.ts",import:"./dist/nodejs/package/index.js",require:"./dist/nodejs/package/index.cjs"},"./nodejs/path":{types:"./dist/nodejs/path/index.d.ts",import:"./dist/nodejs/path/index.js",require:"./dist/nodejs/path/index.cjs"},"./nodejs/storage":{types:"./dist/nodejs/storage/index.d.ts",import:"./dist/nodejs/storage/index.js",require:"./dist/nodejs/storage/index.cjs"},"./react":{types:"./dist/react/index.d.ts",import:"./dist/react/index.js",require:"./dist/react/index.cjs"},"./react/apollo-client":{types:"./dist/react/apollo-client/index.d.ts",import:"./dist/react/apollo-client/index.js",require:"./dist/react/apollo-client/index.cjs"},"./react/apollo-error":{types:"./dist/react/apollo-error/index.d.ts",import:"./dist/react/apollo-error/index.js",require:"./dist/react/apollo-error/index.cjs"},"./react/i18next":{types:"./dist/react/i18next/index.d.ts",import:"./dist/react/i18next/index.js",require:"./dist/react/i18next/index.cjs"},"./react/loading":{types:"./dist/react/loading/index.d.ts",import:"./dist/react/loading/index.js",require:"./dist/react/loading/index.cjs"},"./react/log":{types:"./dist/react/log/index.d.ts",import:"./dist/react/log/index.js",require:"./dist/react/log/index.cjs"},"./react/next-intl":{types:"./dist/react/next-intl/index.d.ts",import:"./dist/react/next-intl/index.js",require:"./dist/react/next-intl/index.cjs"},"./react/storage":{types:"./dist/react/storage/index.d.ts",import:"./dist/react/storage/index.js",require:"./dist/react/storage/index.cjs"},"./react/toast":{types:"./dist/react/toast/index.d.ts",import:"./dist/react/toast/index.js",require:"./dist/react/toast/index.cjs"},"./react/vitest":{types:"./dist/react/vitest/index.d.ts",import:"./dist/react/vitest/index.js",require:"./dist/react/vitest/index.cjs"},"./styles/reset.css":{import:"./dist/styles/reset.css",require:"./dist/styles/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./utils":{types:"./dist/utils/index.d.ts",import:"./dist/utils/index.js",require:"./dist/utils/index.cjs"}},main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",bin:{cyberskill:"./dist/nodejs/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"dotenv -e .env -- tsup --watch",lint:"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint","lint:fix":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint:fix","lint:inspect":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint:inspect",reset:"dotenv -e .env -- tsx src/nodejs/cli/index.ts reset",setup:"dotenv -e .env -- tsx src/nodejs/cli/index.ts setup",inspect:"dotenv -e .env -- tsx src/nodejs/cli/index.ts inspect","test:unit":"dotenv -e .env -- tsx src/nodejs/cli/index.ts test:unit","test:e2e":"dotenv -e .env -- tsx src/nodejs/cli/index.ts test:e2e",commitlint:"dotenv -e .env -- tsx src/nodejs/cli/index.ts commitlint","lint-staged":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint-staged"},dependencies:{"@antfu/eslint-config":"4.11.0","@apollo/client":"3.13.6","@eslint-react/eslint-plugin":"1.42.1","@graphql-codegen/cli":"5.0.5","@graphql-codegen/client-preset":"4.8.0","@graphql-codegen/typescript-react-apollo":"4.3.2","@microsoft/api-extractor":"7.52.3","@next/eslint-plugin-next":"15.2.5","@swc/core":"1.11.18","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.8.1","@vitest/browser":"3.1.1",chalk:"5.4.1",classnames:"2.5.1",consola:"3.4.2","crypto-js":"4.2.0","date-fns":"4.1.0","dotenv-cli":"8.0.0","eslint-config-next":"15.2.5","eslint-plugin-format":"1.0.1","eslint-plugin-react-hooks":"5.2.0","eslint-plugin-react-refresh":"0.4.19",globals:"16.0.0",graphql:"16.10.0","graphql-ws":"6.0.4",i18next:"24.2.3",jsdom:"26.0.0",localforage:"1.10.0","modern-normalize":"3.0.1",mongodb:"6.15.0",mongoose:"8.13.2","mongoose-aggregate-paginate-v2":"1.1.4","mongoose-paginate-v2":"1.9.0","next-intl":"4.0.2","node-fetch":"3.3.2","node-persist":"4.0.4",ora:"8.2.0",playwright:"1.51.1","postcss-modules":"6.0.1",qs:"6.14.0",react:"19.1.0","react-dom":"19.1.0","react-hot-toast":"2.5.2","react-i18next":"15.4.1","react-icons":"5.5.0",sass:"1.86.3",slugify:"1.6.6",tsup:"8.4.0",tsx:"4.19.3",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.2.5",vitest:"3.1.1","vitest-browser-react":"0.1.1",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.0","@eslint/config-inspector":"1.0.2","@types/crypto-js":"4.2.2","@types/mongoose-aggregate-paginate-v2":"1.0.12","@types/node-persist":"3.1.8","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/yargs":"17.0.33",eslint:"9.24.0","lint-staged":"15.5.0","node-modules-inspector":"0.6.3","simple-git-hooks":"2.12.1"}};function tU(e,t){return tF.apply(this,arguments)}function tF(){tF=i(function(e,t){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);Z.start("".concat(e)),B&&Z.info("→ ".concat(t));return[4,ew(t)];case 1:n.sent(),Z.success("".concat(e," done."));return[3,3];case 2:r=n.sent();throw Z.error("".concat(e," failed: ").concat(r.message)),r;case 3:return[2]}})});return tF.apply(this,arguments)}function tq(){return tK.apply(this,arguments)}function tK(){tK=i(function(){var e;return b(this,function(t){switch(t.label){case 0:if(!en(tm.TS_CONFIG))return[3,2];return[4,tU("Performing TypeScript validation",tv.TYPESCRIPT_CHECK)];case 1:e=t.sent();return[3,3];case 2:e=Z.warn("No TypeScript configuration found. Skipping type check.");t.label=3;case 3:e;return[2]}})});return tK.apply(this,arguments)}function tH(){return tY.apply(this,arguments)}function tY(){tY=i(function(){var e,t;var r=arguments;return b(this,function(n){switch(n.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:!1;if(!e)return[3,2];return[4,tU("Running ESLint with auto-fix",tv.ESLINT_FIX)];case 1:t=n.sent();return[3,4];case 2:return[4,tU("Running ESLint check",tv.ESLINT_CHECK)];case 3:t=n.sent();n.label=4;case 4:t;return[2]}})});return tY.apply(this,arguments)}function tB(e,t){if(!t.length)return;var r=e==="Errors"?"red":"yellow";Z.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,r)}function tV(){return tQ.apply(this,arguments)}function tQ(){tQ=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:return[4,eI()];case 1:e=n.sent(),t=e.filter(function(e){return e.type==="error"}),r=e.filter(function(e){return e.type==="warning"});!t.length&&!r.length?Z.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tB("Warnings",r),tB("Errors",t));return[2]}})});return tQ.apply(this,arguments)}function tJ(){return tW.apply(this,arguments)}function tW(){tW=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:return[4,eT()];case 1:n.sent();return[4,ef(eH)];case 2:e=n.sent(),t=e.isCurrentProject;if(!t)return[3,7];n.label=3;case 3:n.trys.push([3,6,,7]);return[4,tU("Building package: ".concat(eH),tv.BUILD)];case 4:n.sent();return[4,tU("Staging build artifacts",tv.STAGE_BUILD_DIRECTORY)];case 5:n.sent();return[3,7];case 6:r=n.sent();throw Z.error("Error building and staging ".concat(eH,": ").concat(r.message)),r;case 7:return[4,tU("Executing lint-staged",tv.CYBERSKILL.LINT_STAGED)];case 8:n.sent(),tV();return[2]}})});return tW.apply(this,arguments)}function tX(){return tz.apply(this,arguments)}function tz(){tz=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Inspecting ESLint configuration",tv.ESLINT_INSPECT)];case 1:e.sent();return[2]}})});return tz.apply(this,arguments)}function t$(){return tZ.apply(this,arguments)}function tZ(){tZ=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,Promise.all([tq(),tH()])];case 2:e.sent(),tV();return[2]}})});return tZ.apply(this,arguments)}function t0(){return t1.apply(this,arguments)}function t1(){t1=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,Promise.all([tq(),tH(!0)])];case 2:e.sent(),tV();return[2]}})});return t1.apply(this,arguments)}function t2(){return t3.apply(this,arguments)}function t3(){t3=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,tU("Validating commit message",tv.CYBERSKILL.COMMIT_LINT)];case 2:e.sent(),tV();return[2]}})});return t3.apply(this,arguments)}function t4(){return t5.apply(this,arguments)}function t5(){t5=i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:return[4,tU("Configuring Git hooks",tv.CONFIGURE_GIT_HOOK)];case 1:r.sent(),ea(tm.GIT_HOOK);return[4,ej(tg)];case 2:e=r.sent();ei(tm.SIMPLE_GIT_HOOKS_JSON,e,{isJson:!0});t="\n".concat(ez,"\n");en(tm.GIT_IGNORE)?es(tm.GIT_IGNORE).split("\n").includes(ez)||eo(tm.GIT_IGNORE,t):ei(tm.GIT_IGNORE,t);return[4,tU("Setting up simple-git-hooks",tv.SIMPLE_GIT_HOOKS)];case 3:r.sent();return[2]}})});return t5.apply(this,arguments)}function t8(){return t6.apply(this,arguments)}function t6(){t6=i(function(){var e,t,r,n,s,i,o,a,c,u,l;return b(this,function(d){switch(d.label){case 0:e=[{command:tv.PNPM_INSTALL_STANDARD,message:"Installing dependencies (standard)"},{command:tv.PNPM_INSTALL_LEGACY,message:"Retrying with legacy peer dependencies"},{command:tv.PNPM_INSTALL_FORCE,message:"Retrying with force install"}];t=true,r=false,n=undefined;d.label=1;case 1:d.trys.push([1,8,9,10]);s=e[Symbol.iterator]();d.label=2;case 2:if(!!(t=(i=s.next()).done))return[3,7];o=i.value,a=o.command,c=o.message;d.label=3;case 3:d.trys.push([3,5,,6]);return[4,tU("".concat(c," using: ").concat(a),a)];case 4:d.sent();return[2];case 5:u=d.sent();Z.warn("Installation attempt failed: ".concat(a)),Z.error("Details: ".concat(u.message));return[3,6];case 6:t=true;return[3,2];case 7:return[3,10];case 8:l=d.sent();r=true;n=l;return[3,10];case 9:try{if(!t&&s.return!=null){s.return()}}finally{if(r){throw n}}return[7];case 10:throw new Error("All dependency installation strategies failed.")}})});return t6.apply(this,arguments)}function t7(e,t){return t9.apply(this,arguments)}function t9(){t9=i(function(e,t){var r,n,s,i,o,a,c,u,l,d,f,p;return b(this,function(E){switch(E.label){case 0:if(!en(tm.PACKAGE_JSON)){Z.error("package.json not found. Aborting setup.");return[2]}E.label=1;case 1:E.trys.push([1,14,,15]);return[4,ef(e,{update:t===null||t===void 0?void 0:t.update})];case 2:r=E.sent(),n=r.isUpToDate;s=n;if(s)return[3,5];return[4,t8()];case 3:E.sent();return[4,t0()];case 4:s=E.sent();E.label=5;case 5:s;o=true,a=false,c=undefined;E.label=6;case 6:E.trys.push([6,11,12,13]);u=((i=t===null||t===void 0?void 0:t.postInstallActions)!==null&&i!==void 0?i:[])[Symbol.iterator]();E.label=7;case 7:if(!!(o=(l=u.next()).done))return[3,10];d=l.value;return[4,d()];case 8:E.sent();E.label=9;case 9:o=true;return[3,7];case 10:return[3,13];case 11:f=E.sent();a=true;c=f;return[3,13];case 12:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 13:Z.success('"'.concat(e,'" setup completed.'));return[3,15];case 14:p=E.sent();throw Z.error('Failed to setup "'.concat(e,'": ').concat(p.message)),p;case 15:return[2]}})});return t9.apply(this,arguments)}function re(){return rt.apply(this,arguments)}function rt(){rt=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,t7(eH,{update:!0,postInstallActions:[t4]})];case 1:e.sent();return[2]}})});return rt.apply(this,arguments)}function rr(){return rn.apply(this,arguments)}function rn(){rn=i(function(){return b(this,function(e){switch(e.label){case 0:ea(tm.NODE_MODULES,tm.PNPM_LOCK_YAML);return[4,t8()];case 1:e.sent();return[4,t4()];case 2:e.sent();return[2]}})});return rn.apply(this,arguments)}function rs(){return ri.apply(this,arguments)}function ri(){ri=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Inspecting project dependencies",tv.NODE_MODULES_INSPECT)];case 1:e.sent();return[2]}})});return ri.apply(this,arguments)}function ro(){return ra.apply(this,arguments)}function ra(){ra=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Running unit tests",tv.CYBERSKILL.TEST_UNIT)];case 1:e.sent();return[2]}})});return ra.apply(this,arguments)}function rc(){return ru.apply(this,arguments)}function ru(){ru=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Running end-to-end tests",tv.CYBERSKILL.TEST_E2E)];case 1:e.sent();return[2]}})});return ru.apply(this,arguments)}i(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,tG(tj(tM.argv)).scriptName(e2).usage("$0 <command> [options]").command("lint",tP.lint,t$).command("lint:fix",tP["lint:fix"],t0).command("lint:inspect",tP["lint:inspect"],tX).command("lint-staged",tP["lint-staged"],tJ).command("commitlint",tP.commitlint,t2).command("setup",tP.setup,re).command("reset",tP.reset,rr).command("inspect",tP.inspect,rs).command("test:unit",tP["test:unit"],ro).command("test:e2e",tP["test:e2e"],rc).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(tk.version).epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse()];case 1:t.sent();return[3,3];case 2:e=t.sent();Z.error("Fatal: ".concat(e.message)),tM.exit(1);return[3,3];case 3:return[2]}})})();import{format as rl}from"date-fns";import{Document as rd}from"mongoose";import rf from"mongoose-aggregate-paginate-v2";import rp from"mongoose-paginate-v2";import{v4 as rE}from"uuid";import rm from"crypto-js";import rg from"slugify";var rh=rg.default||rg;function rv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var r=t||{},n=r.lower,s=n===void 0?!0:n,i=r.locale,o=i===void 0?"vi":i,a=S(r,["lower","locale"]);return rh(e,v({lower:s,locale:o},a))}function ry(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return rm.SHA256(e).toString(rm.enc.Hex).slice(0,t)}var r_={isEmpty:function e(e){return e==null?!0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":T(e))=="object"?p(e,Date)?!1:Object.keys(e).length===0:typeof e=="string"?e.trim().length===0:!1}};var rS={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return rl(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,r=t===void 0?"string":t;var n=r==="string"?rS.getDateTime():new Date;return{id:rE(),isDel:!1,createdAt:n,updatedAt:n}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var r=t.method,n=t.pre,s=t.post;r&&n&&e.pre(r,n),r&&s&&e.post(r,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:rE,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,r=e.schema,n=e.virtuals,s=n===void 0?[]:n,i=e.standalone,o=i===void 0?!1:i;var a=new t.Schema(r,{strict:!0});return s.forEach(function(e){var t=e.name,r=e.options,n=e.get;var s=a.virtual(t,r);n&&s.get(n)}),o||a.add(rS.createGenericSchema(t)),a},createModel:function e(e){var t=e.mongoose,r=e.name,n=e.schema,s=e.pagination,i=s===void 0?!1:s,o=e.aggregate,a=o===void 0?!1:o,c=e.virtuals,u=c===void 0?[]:c,l=e.middlewares,d=l===void 0?[]:l;if(!r)throw new Error("Model name is required.");if(t.models[r])return t.models[r];var f=rS.createSchema({mongoose:t,schema:n,virtuals:u});return rS.applyPlugins(f,[i&&rp,a&&rf]),rS.applyMiddlewares(f,d),t.model(r,f)},createSlugQuery:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return _(v({},t,r&&{id:{$ne:r}}),{$or:[{slug:e},{slugHistory:e}]})},validator:{isEmpty:function e(){return /*#__PURE__*/function(){var e=i(function(e){return b(this,function(t){return[2,!r_.isEmpty(e)]})});return function(t){return e.apply(this,arguments)}}()},isUnique:function e(e){return /*#__PURE__*/function(){var t=i(function(t){var r;return b(this,function(n){switch(n.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");r={$or:e.map(function(e){return l({},e,t)})};return[4,this.constructor.findOne(r)];case 1:return[2,!n.sent()]}})});return function(e){return t.apply(this,arguments)}}()},matchesRegex:function e(e){return /*#__PURE__*/function(){var t=i(function(t){return b(this,function(r){if(!Array.isArray(e)||e.some(function(e){return!p(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(t)})]})});return function(e){return t.apply(this,arguments)}}()}}},rO=/*#__PURE__*/function(){"use strict";function e(t,r){a(this,e);this.collection=t.collection(r)}u(e,[{key:"createOne",value:function e(e){var t=this;return i(function(){var r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);r=v({},rS.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,t.collection.insertOne(r)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var t=this;return i(function(){var r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);r=e.map(function(e){return v({},rS.createGenericFields(),e)});return[4,t.collection.insertMany(r)];case 1:n=i.sent();return[2,n.insertedCount===0?{success:!1,message:"No documents were inserted"}:{success:!0,message:"".concat(n.insertedCount," documents created successfully"),result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"findOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.findOne(e)];case 1:r=s.sent();return[2,r?{success:!0,message:"Document found",result:r}:{success:!1,message:"Document not found"}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0,message:"Documents retrieved successfully"};return[4,t.collection.find(e).toArray()];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0,message:"Count retrieved successfully"};return[4,t.collection.countDocuments(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(e,t){var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.collection.updateOne(e,{$set:t})];case 1:n=i.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(e,t){var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.collection.updateMany(e,{$set:t})];case 1:n=i.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.deleteOne(e)];case 1:r=s.sent();return[2,r.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document deleted successfully",result:r}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.deleteMany(e)];case 1:r=s.sent();return[2,r.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents deleted successfully",result:r}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}}]);return e}(),rA=/*#__PURE__*/function(){"use strict";function e(t){a(this,e);this.model=t}u(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return i(function(){var i,o,a;return b(this,function(c){switch(c.label){case 0:c.trys.push([0,2,,3]);i=s.model.findOne(e,t,r);n&&i.populate(n);return[4,i.exec()];case 1:o=c.sent();return[2,o?{success:!0,result:o}:{success:!1,message:"No ".concat(s.getModelName()," found."),code:X.NOT_FOUND.CODE}];case 2:a=c.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return i(function(){var i,o,a;return b(this,function(c){switch(c.label){case 0:c.trys.push([0,2,,3]);i=s.model.find(e,t,r);n&&i.populate(n);o={success:!0};return[4,i.exec()];case 1:return[2,(o.result=c.sent(),o)];case 2:a=c.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPaging",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.paginate(e,t)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPagingAggregate",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.aggregatePaginate(r.model.aggregate(e),t)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.countDocuments(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.create(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.insertMany(e,t)];case 1:return[2,(n.result=i.sent().map(function(e){return p(e,rd)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,i;return b(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,n.model.findOneAndUpdate(e,t,v({new:!0},r)).exec()];case 1:s=o.sent();return[2,s?{success:!0,result:s}:{success:!1,message:"Failed to update ".concat(n.getModelName(),"."),code:X.NOT_FOUND.CODE}];case 2:i=o.sent();return[2,{success:!1,message:i.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,i;return b(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);s={success:!0};return[4,n.model.updateMany(e,t,r).exec()];case 1:return[2,(s.result=o.sent(),s)];case 2:i=o.sent();return[2,{success:!1,message:i.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.model.findOneAndDelete(e,t).exec()];case 1:n=i.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(r.getModelName()," found to delete."),code:X.NOT_FOUND.CODE}];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.model.deleteMany(e,t).exec()];case 1:n=i.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:X.NOT_FOUND.CODE}:{success:!0,result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;var r=this;return i(function(){var n,s,i,o;return b(this,function(a){switch(a.label){case 0:n=new Set;s=0;a.label=1;case 1:if(!(s<10))return[3,5];i=ry(e,s+t);o=!n.has(i);if(!o)return[3,3];n.add(i);return[4,r.model.exists({shortId:i})];case 2:o=!a.sent();a.label=3;case 3:if(o)return[2,{success:!0,result:i}];a.label=4;case 4:s++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:X.INTERNAL_SERVER_ERROR.CODE}]}})})()}},{key:"createSlug",value:function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,o,a,c,u,l,d,f,p,E,m;return b(this,function(g){switch(g.label){case 0:g.trys.push([0,8,,9]);s=t[e],o=/*#__PURE__*/function(){var e=i(function(e){var s,i,o;return b(this,function(a){switch(a.label){case 0:return[4,n.model.findOne(rS.createSlugQuery(e,r,t.id))];case 1:s=a.sent();if(!s)return[2,e];i=1;a.label=2;case 2:o="".concat(e,"-").concat(i);return[4,n.model.findOne(rS.createSlugQuery(o,r,t.id))];case 3:s=a.sent(),i++;a.label=4;case 4:if(s)return[3,2];a.label=5;case 5:return[2,o]}})});return function t(t){return e.apply(this,arguments)}}();if(!((typeof s==="undefined"?"undefined":T(s))=="object"))return[3,5];a={};c=[];for(u in s)c.push(u);l=0;g.label=1;case 1:if(!(l<c.length))return[3,4];d=c[l];f=rv(s[d]);return[4,o(f)];case 2:a[d]=g.sent();g.label=3;case 3:l++;return[3,1];case 4:return[2,{success:!0,result:a}];case 5:p=rv(s);E={success:!0};return[4,o(p)];case 6:return[2,(E.result=g.sent(),E)];case 7:return[3,9];case 8:m=g.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(m.message),code:X.INTERNAL_SERVER_ERROR.CODE}];case 9:return[2]}})})()}},{key:"aggregate",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.aggregate(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}}]);return e}();import{Collection as rN,Db as rI}from"mongodb";import{Document as rC,Model as rT}from"mongoose";var rR=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rI),rD=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rC),rb=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rT),rw=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rN);import{ApolloClient as rx,ApolloError as rL,ApolloLink as rP,ApolloProvider as rM,from as rj,HttpLink as rG,InMemoryCache as rk,split as rU}from"@apollo/client";import{onError as rF}from"@apollo/client/link/error";import{removeTypenameFromVariables as rq}from"@apollo/client/link/remove-typename";import{GraphQLWsLink as rK}from"@apollo/client/link/subscriptions";import{getMainDefinition as rH}from"@apollo/client/utilities";import{createClient as rY}from"graphql-ws";import{useMemo as rB}from"react";import{FaInfo as rV}from"react-icons/fa6";import{use as rQ}from"react";import{FaRepeat as rJ}from"react-icons/fa6";import{createContext as rW}from"react";var rX=rW(void 0);import rz from"./react/apollo-error/apollo-error.module.scss";import{jsx as r$,jsxs as rZ}from"react/jsx-runtime";function r0(){var e=rQ(rX),t=e===null||e===void 0?void 0:e.error;if(!t)return null;var r=function(e,t){return(t===null||t===void 0?void 0:t.length)?rZ("div",{children:[rZ("strong",{children:[e,":"]}),r$("ul",{children:t.map(function(e){return r$("li",{children:e.message},e.message)})})]}):null};return r$("div",{className:rz["modal-backdrop"],children:rZ("div",{className:rz["modal-content"],children:[r$("button",{type:"button",className:rz["btn-close"],onClick:e.hideError,children:"✕"}),rZ("div",{className:rz["error-title"],children:[r$("button",{type:"button",className:rz["btn-retry"],onClick:function(){return window.location.reload()},children:r$(rJ,{})})," ",t.message]}),rZ("div",{className:rz["error-details"],children:[t.networkError&&rZ("pre",{className:"network",children:[r$("strong",{children:"Network Error:"})," ",t.networkError.message]}),r("GraphQL Errors",C(t.graphQLErrors)),r("Protocol Errors",C(t.protocolErrors)),r("Client Errors",C(t.clientErrors)),t.extraInfo&&rZ("pre",{className:"extra",children:[r$("strong",{children:"Extra Info:"})," ",JSON.stringify(t.extraInfo,null,4)]})]})]})})}import{use as r1}from"react";function r2(){var e=r1(rX);if(!e)throw new Error("useApolloError must be used within ApolloErrorProvider");return e}import{useEffect as r3,useMemo as r4,useState as r5}from"react";import{jsx as r8}from"react/jsx-runtime";var r6=null;function r7(e){r6===null||r6===void 0?void 0:r6(e)}function r9(e){var t=e.children;var r=I(r5(null),2),n=r[0],s=r[1];r3(function(){r6=s},[]);var i=r4(function(){return{error:n,showError:s,hideError:function(){return s(null)}}},[n]);return r8(rX,{value:i,children:t})}import{consola as ne}from"consola/browser";var nt={silent:ne.silent,level:ne.level,fatal:ne.fatal,error:ne.error,warn:ne.warn,log:ne.log,info:ne.info,success:ne.success,ready:ne.ready,start:ne.start,box:ne.box,debug:ne.debug,trace:ne.trace,verbose:ne.verbose};import{toast as nr,Toaster as nn}from"react-hot-toast";var ns="/graphql";import{Fragment as ni,jsx as no,jsxs as na}from"react/jsx-runtime";var nc=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);var e;e=o(this,t,arguments);e.count=0;return e}u(t,[{key:"request",value:function e(e,t){var r=this;var n=Date.now();return this.count+=1,t(e).map(function(t){var s=Date.now()-n,i=e.operationName||"Unnamed";return nt.info("[Apollo] #".concat(r.count,": ").concat(i," (").concat(s,"ms)")),t})}}]);return t}(rP);function nu(e){var t=e||{},r=t.uri,n=t.wsUrl,s=t.customLinks,i=new nc,o=rF(function(e){var t=e.graphQLErrors,r=e.networkError,n=e.protocolErrors,s=e.operation;var i=(s===null||s===void 0?void 0:s.operationName)||"Unknown";if(t&&t.forEach(function(e){var t=e.message,r=e.locations,n=e.path;nt.error("[GraphQL error] ".concat(i,": ").concat(t,", Location: ").concat(JSON.stringify(r),", Path: ").concat(n))}),n&&n.forEach(function(e){var t=e.message,r=e.extensions;nt.error("[Protocol error]: ".concat(t,", Extensions: ").concat(JSON.stringify(r)))}),r&&nt.error("[Network error]: ".concat(r)),t||n||r){var o,a;var c=(t===null||t===void 0?void 0:(o=t[0])===null||o===void 0?void 0:o.message)||(n===null||n===void 0?void 0:(a=n[0])===null||a===void 0?void 0:a.message)||(r===null||r===void 0?void 0:r.message)||"Unexpected error",u=new rL({graphQLErrors:t||[],protocolErrors:n||[],clientErrors:[],networkError:r||null,errorMessage:c,extraInfo:{operation:s}});nr.error(function(e){return na(ni,{children:[c,"\xa0",no(rV,{cursor:"pointer",onClick:function(){setTimeout(function(){r7(u)},0),nr.dismiss(e.id)}})]})})}}),a=rq();r||nt.warn('[Apollo] No GraphQL URI provided — using "'.concat(ns,'" as default'));var c=new rG({uri:r!==null&&r!==void 0?r:ns,credentials:"include"}),u=n?new rK(rY({url:n})):rP.empty(),l=p(u,rP)?rU(function(e){var t=e.query;var r=rH(t);return r.kind==="OperationDefinition"&&r.operation==="subscription"},u,c):c;return l===c&&n&&nt.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[i,o,a].concat(C(s!==null&&s!==void 0?s:[]),[l])}function nl(e){var t=e.isNextJS,r=e.options,n=e.children,s=e.client,i=e.provider,o=e.cache;var a=r||{},c=a.uri,u=a.wsUrl,l=a.customLinks,d=S(a,["uri","wsUrl","customLinks"]),f=s!==null&&s!==void 0?s:rx;if(typeof f!="function")throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");var E=i||rM,m=rB(function(){return rj(nu({uri:c,wsUrl:u,customLinks:l}))},[c,u,l]),g=rB(function(){return new f(v({link:m,cache:p(o,rk)?o:new rk},d))},[f,m,o,d]),h=t?no(E,{makeClient:function(){return g},children:n}):no(E,{client:g,children:n});return t?no(E,{makeClient:function(){return g},children:n}):na(ni,{children:[na(r9,{children:[h,no(r0,{})]}),no(nn,{position:"top-right"})]})}import{useTranslation as nd}from"react-i18next";var nf=nd;import np from"i18next";import{initReactI18next as nE}from"react-i18next";function nm(e){return np.use(nE).init(e)}import ng from"classnames";import nh from"./react/loading/loading.module.scss";import{jsx as nv,jsxs as ny}from"react/jsx-runtime";function n_(e){var t=e.full,r=t===void 0?!1:t,n=e.block,s=n===void 0?!1:n,i=e.className,o=i===void 0?"":i,a=e.message,c=a===void 0?"Loading":a,u=S(e,["full","block","className","message"]);function l(){return ny("div",_(v({className:nh.container},u),{children:[nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),c&&nv("div",{className:nh.message,children:c})]}))}return r?nv("div",{className:ng(nh.fullscreen,o),children:l()}):s?nv("div",{className:ng(nh.block,o),children:l()}):l()}import{createContext as nS}from"react";var nO=nS(void 0);import{use as nA}from"react";function nN(){var e=nA(nO);if(!e)throw new Error("useLoading must be used within a LoadingProvider");return e}import{useCallback as nI,useMemo as nC,useState as nT}from"react";import{jsx as nR}from"react/jsx-runtime";function nD(e){var t=e.children;var r=I(nT(!1),2),n=r[0],s=r[1],i=I(nT(!1),2),o=i[0],a=i[1],c=nI(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;s(!0),a(e)},[]),u=nI(function(){s(!1),a(!1)},[]),l=nC(function(){return{isLoading:n,isGlobalLoading:o,showLoading:c,hideLoading:u}},[n,o,c,u]);return nR(nO,{value:l,children:n?nR(n_,{full:o}):t})}import{createContext as nb}from"react";var nw=nb(void 0);import{NextIntlClientProvider as nx}from"next-intl";import{useTranslations as nL}from"next-intl";import{use as nP}from"react";function nM(){var e=nP(nw);if(!e)throw new Error("useNextIntl must be used within a NextIntlProvider");return e}var nj=nL;import{jsx as nG}from"react/jsx-runtime";function nk(e){var t=function(t){var r;var n=nM(),s=n.currentLanguage,i=t.messages,o=t.languages,a="en",c=i[(s===null||s===void 0?void 0:s.value)||a],u=(r=o.find(function(e){return e.value===(s===null||s===void 0?void 0:s.value)}))===null||r===void 0?void 0:r.timezone;return i?nG(nx,{locale:(s===null||s===void 0?void 0:s.value)||a,messages:c,timeZone:u,children:nG(e,v({},t))}):(nt.warn("Missing messages for language: ".concat((s===null||s===void 0?void 0:s.value)||a)),null)};return t.displayName="withNextIntl(".concat(e.displayName||e.name||"Component",")"),t}import{useMemo as nU}from"react";import{useCallback as nF,useEffect as nq,useState as nK}from"react";var nH={serialize:function(e){return JSON.stringify(e,function(e,t){return p(t,Date)?{__type:"Date",value:t.toISOString()}:t})},deserialize:function(e){return JSON.parse(e,function(e,t){return(t===null||t===void 0?void 0:t.__type)==="Date"?new Date(t.value):t})}};import nY from"localforage";var nB={get:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.getItem(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(nt.error('[Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 3:return[2]}})})()},set:function e(e,t){return i(function(){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,nY.setItem(e,t)];case 1:n.sent();return[3,3];case 2:r=n.sent();nt.error('[Storage:set] Error setting key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},remove:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.removeItem(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();nt.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},keys:function e(){return i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.keys()];case 1:return[2,(e=r.sent())!==null&&e!==void 0?e:[]];case 2:t=r.sent();return[2,(nt.error("[Storage:keys] Error getting keys:",t),[])];case 3:return[2]}})})()}};function nV(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nH;var n=I(nK(t),2),s=n[0],o=n[1],a=I(nK(!1),2),c=a[0],u=a[1];nq(function(){var n=!0;return i(function(){var s,i,a,c;return b(this,function(l){switch(l.label){case 0:l.trys.push([0,6,7,8]);return[4,nB.get(e)];case 1:s=l.sent();if(!n)return[3,5];if(!(s!==null))return[3,2];i=r.deserialize(s);o(i);return[3,5];case 2:if(!(t!==void 0))return[3,4];a=r.serialize(t);return[4,nB.set(e,a)];case 3:l.sent(),o(t);return[3,5];case 4:o(void 0);l.label=5;case 5:return[3,8];case 6:c=l.sent();nt.error('Error loading value for key "'.concat(e,'":'),c),n&&o(t);return[3,8];case 7:n&&u(!0);return[7];case 8:return[2]}})})(),function(){n=!1,u(!1)}},[e,t,r]),nq(function(){if(!c)return;i(function(){var t,n;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);if(!(s!==void 0))return[3,2];t=r.serialize(s);return[4,nB.set(e,t)];case 1:i.sent();i.label=2;case 2:return[3,4];case 3:n=i.sent();nt.error('Error saving value for key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},[s,e,r,c]);var l=nF(function(e){o(function(t){return typeof e=="function"?e(t):e})},[]),d=nF(/*#__PURE__*/i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nB.remove(e)];case 1:r.sent(),o(void 0);return[3,3];case 2:t=r.sent();nt.error('Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})}),[e]);return{value:s,set:l,remove:d}}import{Fragment as nQ,jsx as nJ}from"react/jsx-runtime";function nW(e){var t=e.children;return nJ(nQ,{children:t})}var nX=nk(nW);function nz(e){var t=e.children,r=e.languages,n=e.messages;var s;var i=nV("lang",(s=r===null||r===void 0?void 0:r[0])!==null&&s!==void 0?s:{}),o=i.value,a=i.set,c=nU(function(){return{languages:r,currentLanguage:o,setCurrentLanguage:a}},[r,a,o]);return nJ(nw,{value:c,children:nJ(nX,{languages:r,messages:n,children:t})})}import n$ from"unorm";var nZ={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},n0=Object.entries(nZ).reduce(function(e,t){var r=I(t,2),n=r[0],s=r[1];return e[n.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function n1(e){e=n$.nfkc(e);var t=v({},nZ,n0);var r=true,n=false,s=undefined;try{for(var i=Object.entries(t)[Symbol.iterator](),o;!(r=(o=i.next()).done);r=true){var a=I(o.value,2),c=a[0],u=a[1];var l="[".concat(c).concat(u.join(""),"]"),d="(".concat([c].concat(C(u)).join("|"),")");e=e.replace(new RegExp(l,"g"),d)}}catch(e){n=true;s=e}finally{try{if(!r&&i.return!=null){i.return()}}finally{if(n){throw s}}}return e}function n2(e){return e.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}export{r0 as ApolloError,rX as ApolloErrorContext,r9 as ApolloErrorProvider,nl as ApolloProvider,eV as BUILD_DIRECTORY,ee as CHECK_PACKAGE_EMPTY_RESULT,tv as COMMAND,tP as COMMAND_DESCRIPTIONS,te as COMMIT_LINT_CLI,e9 as COMMIT_LINT_PACKAGE_NAME,e2 as CYBERSKILL_CLI,e3 as CYBERSKILL_CLI_PATH,e1 as CYBERSKILL_DIRECTORY,eH as CYBERSKILL_PACKAGE_NAME,eY as CYBERSKILL_STORAGE,rw as C_Collection,rR as C_Db,rD as C_Document,rb as C_Model,B as DEBUG,e5 as ESLINT_CLI,tf as ESLINT_INSPECT_CLI,td as ESLINT_INSPECT_PACKAGE_NAME,e4 as ESLINT_PACKAGE_NAME,F as E_CommandType,x as E_ConfigType,V as E_IssueType,to as GIT_CLI,e0 as GIT_COMMIT_EDITMSG,eZ as GIT_HOOK,eX as GIT_IGNORE,ns as GRAPHQL_URI_DEFAULT,tg as HOOK,tL as IS_BROWSER,tr as LINT_STAGED_CLI,tt as LINT_STAGED_PACKAGE_NAME,n_ as Loading,nO as LoadingContext,nD as LoadingProvider,rO as MongoController,rA as MongooseController,eB as NODE_MODULES,tE as NODE_MODULES_INSPECT_CLI,tp as NODE_MODULES_INSPECT_PACKAGE_NAME,nw as NextIntlContext,nz as NextIntlProvider,eQ as PACKAGE_JSON,eJ as PACKAGE_LOCK_JSON,tm as PATH,e6 as PLAYWRIGHT_PACKAGE_NAME,ta as PNPM_CLI,tc as PNPM_EXEC_CLI,e$ as PNPM_LOCK_YAML,X as RESPONSE_STATUS,tu as SIMPLE_GIT_HOOKS_PACKAGE_NAME,tl as SIMPLE_GIT_HOOK_CLI,ez as SIMPLE_GIT_HOOK_JSON,eW as TSCONFIG_JSON,ts as TSC_CLI,tn as TSC_PACKAGE_NAME,ti as TSX_CLI,nn as Toaster,e7 as VITEST_CLI,e8 as VITEST_PACKAGE_NAME,eK as WORKING_DIRECTORY,rf as aggregatePaginate,eo as appendFileSync,ef as checkPackage,eT as clearAllErrorLists,w as commitlintConfig,tw as createGraphqlCodegenConfig,tO as deepMerge,tN as eslintConfig,ew as executeCommand,en as existsSync,eM as formatCommand,ry as generateShortId,rv as generateSlug,el as getLatestPackageVersion,eu as getPackage,eI as getStoredErrorLists,nm as initI18next,t_ as isJson,tS as isPlainObject,eq as join,tx as lintStagedConfig,nt as log,Z as logNodeJS,tb as mergeConfigs,rS as mongo,rp as mongoosePaginate,eL as rawCommand,es as readFileSync,n1 as regexSearchMapper,n2 as removeAccent,eF as resolve,ej as resolveCommands,eU as resolveWorkingPath,ea as rmSync,nH as serializer,r7 as showGlobalApolloError,nB as storage,e_ as storageNodeJS,z as throwError,nr as toast,r2 as useApolloError,nN as useLoading,nM as useNextIntl,nV as useStorage,nf as useTranslateI18next,nj as useTranslateNextIntl,r_ as validate,j as vitestE2E,ty as vitestUnit,nk as withNextIntl,ei as writeFileSync};
1
+ function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(t){if(Array.isArray(t))return e(t)}function n(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,t,r,n,s,i,o){try{var a=e[i](o);var c=a.value}catch(e){r(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(n,s)}}function i(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,c,"next",e)}function c(e){s(o,n,i,a,c,"throw",e)}a(undefined)})}}function o(e,t,r){t=d(t);return A(e,D()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function u(e,t,r){if(t)c(e.prototype,t);if(r)c(e,r);return e}function l(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function d(e){d=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return d(e)}function f(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)N(e,t)}function p(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function E(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function m(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var s=true;var i=false;var o,a;try{for(r=r.call(e);!(s=(o=r.next()).done);s=true){n.push(o.value);if(t&&n.length===t)break}}catch(e){i=true;a=e}finally{try{if(!s&&r["return"]!=null)r["return"]()}finally{if(i)throw a}}return n}function g(){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 h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){l(e,t,r[t])})}return e}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function _(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{y(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function S(e,t){if(e==null)return{};var r=O(e,t);var n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++){n=i[s];if(t.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function O(e,t){if(e==null)return{};var r={};var n=Object.keys(e);var s,i;for(i=0;i<n.length;i++){s=n[i];if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function A(e,t){if(t&&(T(t)==="object"||typeof t==="function")){return t}return n(e)}function N(e,t){N=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return N(e,t)}function I(e,r){return t(e)||m(e,r)||R(e,r)||g()}function C(e){return r(e)||E(e)||R(e)||h()}function T(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function R(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function b(e,t){var r,n,s,i,o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");while(o)try{if(r=1,n&&(s=i[0]&2?n["return"]:i[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;if(n=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;n=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){o.label=i[1];break}if(i[0]===6&&o.label<s[1]){o.label=s[1];s=i;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(i);break}if(s[2])o.ops.pop();o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e];n=0}finally{r=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var w={extends:["@commitlint/config-conventional"]};var x=function(e){return e.ESLINT="eslint",e.COMMITLINT="commitlint",e.LINT_STAGED="lint-staged",e.VITEST_REACT_E2E="vitest-react-e2e",e.VITEST_REACT_UNIT="vitest-react-unit",e}(x||{});import L from"@antfu/eslint-config";import P from"@vitejs/plugin-react-swc";import{defineConfig as M}from"vitest/config";function j(e){return M(v({plugins:[P()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}},e))}import G from"@vitejs/plugin-react-swc";import{defineConfig as k}from"vitest/config";import U from"node:process";var F=function(e){return e.PNPM_ADD_AND_EXEC="PNPM_ADD_AND_EXEC",e.PNPM_ADD_DEV_AND_EXEC="PNPM_ADD_DEV_AND_EXEC",e.RAW="RAW",e}(F||{});import{exec as q}from"node:child_process";import K from"node:process";import*as H from"node:util";import Y from"node:process";var B=Y.env.DEBUG==="true";var V=function(e){return e.Error="error",e.Warning="warning",e}(V||{});import Q from"chalk";import J from"consola";import{GraphQLError as W}from"graphql";var X={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function z(e){var t=e.message,r=e.status,n=r===void 0?X.INTERNAL_SERVER_ERROR:r,s=e.type,i=s===void 0?"graphql":s;var o;var a=(o=t!==null&&t!==void 0?t:n.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw i==="graphql"?new W(a,{extensions:{code:n.CODE}}):new Error(a)}B||(J.level=4);function $(e){var t=Q[e];return typeof t=="function"?t:Q.green}var Z={silent:J.silent,level:J.level,fatal:J.fatal,error:J.error,warn:J.warn,log:J.log,info:J.info,success:J.success,ready:J.ready,start:J.start,box:J.box,debug:J.debug,trace:J.trace,verbose:J.verbose,printBoxedLog:function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){J.box(Q.green(e));return}t.forEach(function(e){var t=e.file,n=e.position,s=e.rule,i=e.message;J.log("".concat(Q.gray("File:")," ").concat(Q.blue("".concat(t).concat(n?":".concat(n):"")))),s&&J.log(" ".concat($(r)("Rule:")," ").concat(s)),J.log(" ".concat($(r)("Message:")," ").concat(i))}),J.box($(r)("".concat(e," : ").concat(t.length))),J.log(Q.gray("─".repeat(40)))}};var ee={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};import et from"node-fetch";import*as er from"node:fs";function en(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return t.every(function(e){return er.existsSync(e)})}function es(e,t){var r=er.readFileSync(e,"utf-8");if(t===null||t===void 0?void 0:t.asJson)try{var n=JSON.parse(r);if((typeof n==="undefined"?"undefined":T(n))=="object"&&n!==null)return n;throw new Error("Parsed JSON is not an object or array")}catch(t){throw new Error("Failed to parse JSON from file: ".concat(e))}return r}function ei(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=r.isJson,s=n===void 0?!1:n,i=s&&(typeof t==="undefined"?"undefined":T(t))=="object"?JSON.stringify(t,null,4):String(t);er.writeFileSync(e,i,"utf-8")}function eo(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=r.isJson,s=n===void 0?!1:n,i=s&&(typeof t==="undefined"?"undefined":T(t))=="object"?JSON.stringify(t,null,4):String(t);er.appendFileSync(e,i,"utf-8")}function ea(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}t.forEach(function(e){en(e)&&er.rmSync(e,{recursive:!0,force:!0})})}var ec={};function eu(e){if(e in ec)return ec[e];var t=eq(eK,eQ);if(!en(t))return ec[e]=!1;try{var r,n;var s=es(t,{asJson:!0}),i=s.name===e,o=!!((r=s.dependencies)===null||r===void 0?void 0:r[e]),a=!!((n=s.devDependencies)===null||n===void 0?void 0:n[e]);return i||o||a?ec[e]={path:t,file:s,isCurrentProject:i,isDepend:o,isDevDepend:a}:ec[e]=!1}catch(t){return Z.warn("Failed to read package.json: ".concat(t.message)),ec[e]=!1}}function el(e){return ed.apply(this,arguments)}function ed(){ed=i(function(e){var t,r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,et("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=i.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:r=i.sent(),n=r.version;return[2,n];case 3:s=i.sent();throw Z.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})});return ed.apply(this,arguments)}function ef(e,t){return ep.apply(this,arguments)}function ep(){ep=i(function(e,t){var r,n,s,i,o,a,c,u,d,f,p,E,m,g,h;return b(this,function(y){switch(y.label){case 0:y.trys.push([0,4,,5]);o=eu(e);if(!o)return[2,v({},ee)];a=o.path,c=o.file,u=o.isCurrentProject,d=o.isDepend,f=o.isDevDepend,p="0.0.0";u&&c.version?p=c.version:d&&((r=c.dependencies)===null||r===void 0?void 0:r[e])?p=(n=c.dependencies)===null||n===void 0?void 0:n[e]:f&&((s=c.devDependencies)===null||s===void 0?void 0:s[e])&&(p=(i=c.devDependencies)===null||i===void 0?void 0:i[e]);if(!u)return[3,1];g=p;return[3,3];case 1:return[4,el(e)];case 2:g=y.sent();y.label=3;case 3:E=g,m=u||p===E;return[2,(!m&&(t===null||t===void 0?void 0:t.update)&&(d?c.dependencies=_(v({},c.dependencies||{}),l({},e,E)):f&&(c.devDependencies=_(v({},c.devDependencies||{}),l({},e,E))),Z.info('Updating package "'.concat(e,'" to version ').concat(E)),ei(a,c,{isJson:!0})),{isCurrentProject:u,installedPath:a,file:c,isUpToDate:m})];case 4:h=y.sent();return[2,(Z.error('Error checking package "'.concat(e,'": ').concat(h.message)),v({},ee))];case 5:return[2]}})});return ep.apply(this,arguments)}import eE from"node-persist";import em from"node:os";import eg from"node:process";function eh(){return eg.env.CYBERSKILL_STORAGE_DIR||eq(em.homedir(),eY)}function ev(){return ey.apply(this,arguments)}function ey(){ey=i(function(){var e;return b(this,function(t){switch(t.label){case 0:e=eE.defaultInstance;if(e)return[3,2];return[4,eE.init({dir:eh(),stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return ey.apply(this,arguments)}var e_={get:function e(e){return i(function(){var t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ev()];case 1:n.sent();return[4,eE.getItem(e)];case 2:return[2,(t=n.sent())!==null&&t!==void 0?t:null];case 3:r=n.sent();return[2,(Z.error('[Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ev()];case 1:n.sent();return[4,eE.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();Z.error('[Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ev()];case 1:r.sent();return[4,eE.removeItem(e)];case 2:r.sent();return[3,4];case 3:t=r.sent();Z.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ev()];case 1:r.sent();return[4,eE.keys()];case 2:e=r.sent();return[2,Array.isArray(e)?e:(Z.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=r.sent();return[2,(Z.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return b(this,function(t){try{return[2,"".concat(eh()," (key: ").concat(e,")")]}catch(e){return[2,(Z.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var eS=H.promisify(q);function eO(e){return"error_list:".concat(e)}function eA(e){return eN.apply(this,arguments)}function eN(){eN=i(function(e){var t,r,n;return b(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];t=Date.now(),r=eO(t);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,e_.set(r,{errors:e,timestamp:t})];case 2:s.sent(),setTimeout(/*#__PURE__*/i(function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,e_.getLogLink(r)];case 1:e=t.sent();e&&Z.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:n=s.sent();Z.error("Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return eN.apply(this,arguments)}function eI(){return eC.apply(this,arguments)}function eC(){eC=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e_.keys()];case 1:e=n.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=i(function(e){var t;return b(this,function(r){switch(r.label){case 0:return[4,e_.get(e)];case 1:return[2,((t=r.sent())===null||t===void 0?void 0:t.errors)||[]]}})});return function(t){return e.apply(this,arguments)}}()))];case 2:return[2,n.sent().flat()];case 3:r=n.sent();return[2,(Z.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return eC.apply(this,arguments)}function eT(){return eR.apply(this,arguments)}function eR(){eR=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e_.keys()];case 1:e=n.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return e_.remove(e)}))];case 2:n.sent();return[3,4];case 3:r=n.sent();Z.error("Failed to clear error lists: ".concat(r.message));return[3,4];case 4:return[2]}})});return eR.apply(this,arguments)}function eD(e){var t=[],r=[],n="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,i=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var a=s.exec(e)||[],c=i.exec(e)||[],u=o.exec(e)||[];a.length&&n?t.push({file:n,position:"".concat(a[1],":").concat(a[2]),type:a[3]==="error"?"error":"warning",message:a[4].trim(),rule:a[5].trim()}):c.length?t.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):r.push(e.trim())}}),t.length&&eA(t),B&&r.length&&(Z.warn("Unmatched lines:"),r.forEach(function(e){return Z.info(" ".concat(e))}))}function eb(e){try{var t=JSON.parse(e),r=[];t.forEach(function(e){var t=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,s=e.line,i=e.column,o=e.ruleId,a=e.message;r.push({type:n===2?"error":"warning",file:t,position:"".concat(s,":").concat(i),rule:o,message:a})})}),r.length&&eA(r)}catch(t){eD(e)}}function ew(e){return ex.apply(this,arguments)}function ex(){ex=i(function(e){var t,r,n,s,i,o,a,c,u;var l=arguments;return b(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:eb;r=new AbortController;K.on("SIGINT",function(){Z.warn("Process interrupted. Terminating..."),r.abort(),K.exit()});d.label=1;case 1:d.trys.push([1,3,,4]);return[4,eS(e,{maxBuffer:0x6400000,signal:r.signal})];case 2:n=d.sent(),s=n.stdout,i=n.stderr;[s,i].forEach(function(e){return e&&t(e)});return[3,4];case 3:o=d.sent();a=o.stdout,c=o.stderr,u=o.message;[a,c].forEach(function(e){return e&&t(e)}),!c&&!a&&Z.error("Command failed: ".concat(u));return[3,4];case 4:return[2]}})});return ex.apply(this,arguments)}function eL(e){return{raw:!0,cmd:e}}function eP(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(tc," ").concat(eH," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tc," ").concat(ti," ").concat(e3," ").concat(e):"".concat(tc," ").concat(e2," ").concat(e)}function eM(e,t){return typeof e=="function"?eP(e(t),t):(typeof e==="undefined"?"undefined":T(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?eP(e,t):e}function ej(e){return eG.apply(this,arguments)}function eG(){eG=i(function(e){var t,r,n,s,i,o,a;var c=arguments;return b(this,function(u){switch(u.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:{};n=(r=t===null||t===void 0?void 0:t.isRemote)!==null&&r!==void 0?r:!1;if(!n)return[3,1];a=!1;return[3,3];case 1:return[4,ef(eH)];case 2:a=u.sent().isCurrentProject;u.label=3;case 3:s=a,i={isRemote:n,isCurrentProject:s},o=typeof e=="function"?e(i):e;return[2,Object.fromEntries(Object.entries(o).map(function(e){var t=I(e,2),r=t[0],n=t[1];return[r,eM(n,i)]}))]}})});return eG.apply(this,arguments)}import*as ek from"node:path";function eU(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).resolve.apply(n,[eK].concat(C(t)))}function eF(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).resolve.apply(n,C(t))}function eq(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n;return(n=ek).join.apply(n,C(t))}var eK=U.env.INIT_CWD||U.cwd(),eH="@cyberskill/shared",eY=".cyberskill-storage",eB="node_modules",eV="dist",eQ="package.json",eJ="package-lock.json",eW="tsconfig.json",eX=".gitignore",ez=".simple-git-hooks.json",e$="pnpm-lock.yaml",eZ=".git/hooks/",e0=".git/COMMIT_EDITMSG",e1=eq(eK,eB,eH,eV),e2="cyberskill",e3="src/nodejs/cli/index.ts",e4="eslint",e5="eslint",e8="vitest",e6="playwright",e7="vitest",e9="@commitlint/cli",te="commitlint",tt="lint-staged",tr="lint-staged",tn="typescript",ts="tsc",ti="tsx",to="git",ta="pnpm",tc="pnpm exec",tu="simple-git-hooks",tl="simple-git-hooks",td="@eslint/config-inspector",tf="eslint-config-inspector",tp="node-modules-inspector",tE="node-modules-inspector",tm={CYBERSKILL_DIRECTORY:e1,WORKING_DIRECTORY:eK,TS_CONFIG:eU(eW),GIT_IGNORE:eU(eX),GIT_HOOK:eU(eZ),GIT_COMMIT_MSG:eU(e0),SIMPLE_GIT_HOOKS_JSON:eU(ez),PACKAGE_JSON:eU(eQ),PACKAGE_LOCK_JSON:eU(eJ),PNPM_LOCK_YAML:eU(e$),NODE_MODULES:eU(eB),CYBERSKILL:{LINT_STAGED_CONFIG:eU("".concat(e1,"/configs/lint-staged/base.js")),COMMITLINT_CONFIG:eU("".concat(e1,"/configs/commitlint/base.js")),UNIT_TEST_CONFIG:eU("".concat(e1,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:eU("".concat(e1,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:eU("".concat(e1,"/react/vitest/vitest.e2e.js"))}};function tg(e){var t=e.isCurrentProject;return v({"pre-commit":tr,"commit-msg":te},t&&{"pre-push":eL("".concat(to," pull"))})}function th(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}var s=I(r,2),i=s[0],o=s[1],a=e==="RAW"?!0:en.apply(void 0,C(i.split(" ").map(function(e){return eq(tm.NODE_MODULES,e)})));switch(e){case"PNPM_ADD_AND_EXEC":return eM(eL("".concat(a?"":"".concat(ta," add ").concat(i," && ")).concat(tc," ").concat(o)));case"PNPM_ADD_DEV_AND_EXEC":return eM(eL("".concat(a?"":"".concat(ta," add -D ").concat(i," && ")).concat(tc," ").concat(o)));case"RAW":return eM(eL(i))}}var tv={SIMPLE_GIT_HOOKS:th("PNPM_ADD_DEV_AND_EXEC",tu,tl),ESLINT_INSPECT:th("PNPM_ADD_DEV_AND_EXEC",td,tf),NODE_MODULES_INSPECT:th("PNPM_ADD_DEV_AND_EXEC",tp,tE),ESLINT_CHECK:th("PNPM_ADD_DEV_AND_EXEC",e4,"".concat(e5," ").concat(tm.WORKING_DIRECTORY)),ESLINT_FIX:th("PNPM_ADD_DEV_AND_EXEC",e4,"".concat(e5," ").concat(tm.WORKING_DIRECTORY," --fix")),TYPESCRIPT_CHECK:th("PNPM_ADD_AND_EXEC",tn,"".concat(ts," -p ").concat(tm.TS_CONFIG," --noEmit")),CONFIGURE_GIT_HOOK:th("RAW","".concat(to," config core.hooksPath ").concat(tm.GIT_HOOK)),BUILD:th("RAW","".concat(ta," run build")),STAGE_BUILD_DIRECTORY:th("RAW","".concat(to," add ").concat(eV)),PNPM_INSTALL_STANDARD:th("RAW","".concat(ta," install")),PNPM_INSTALL_LEGACY:th("RAW","".concat(ta," install --legacy-peer-deps")),PNPM_INSTALL_FORCE:th("RAW","".concat(ta," install --force")),CYBERSKILL:{TEST_UNIT:th("PNPM_ADD_AND_EXEC",e8,"".concat(e7," --config ").concat(tm.CYBERSKILL.UNIT_TEST_CONFIG)),TEST_E2E:th("PNPM_ADD_AND_EXEC","".concat(e8," ").concat(e6),"".concat(e7," --config ").concat(tm.CYBERSKILL.E2E_TEST_CONFIG)),COMMIT_LINT:th("PNPM_ADD_DEV_AND_EXEC",e9,"".concat(te," --edit ").concat(tm.GIT_COMMIT_MSG," --config ").concat(tm.CYBERSKILL.COMMITLINT_CONFIG)),LINT_STAGED:th("PNPM_ADD_DEV_AND_EXEC",tt,"".concat(tr," --config ").concat(tm.CYBERSKILL.LINT_STAGED_CONFIG))}};function ty(e){return k(v({plugins:[G()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:[tm.CYBERSKILL.UNIT_TEST_SETUP_CONFIG]}},e))}function t_(e){try{return JSON.parse(e),!0}catch(e){return!1}}function tS(e){return!!e&&(typeof e==="undefined"?"undefined":T(e))=="object"&&!Array.isArray(e)}function tO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return t.flat().reduce(function(e,t){var r=true,n=false,s=undefined;try{for(var i=Object.entries(t)[Symbol.iterator](),o;!(r=(o=i.next()).done);r=true){var a=I(o.value,2),c=a[0],u=a[1];var l=e[c];Array.isArray(u)?e[c]=Array.from(new Set(C(Array.isArray(l)?l:[]).concat(C(u)))):tS(u)?e[c]=tO(tS(l)?l:{},u):e[c]=u}}catch(e){n=true;s=e}finally{try{if(!r&&i.return!=null){i.return()}}finally{if(n){throw s}}}return e},{})}import*as tA from"globals";var tN=[{languageOptions:{globals:v({},tA.node,tA.browser)},rules:{"perfectionist/sort-imports":["error",{internalPattern:["^#.*","^@/.*"]}]},ignores:["build","dist"]}];var tI=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return tO.apply(void 0,C(t))},tC=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n=tO.apply(void 0,[tN].concat(C(t))),s=n.ignores,i=S(n,["ignores"]),o=Array.isArray(s)&&s.every(function(e){return typeof e=="string"})?{ignores:s}:void 0,a=[i].concat(C(o?[o]:[]));return L.apply(void 0,[{stylistic:{semi:!0,indent:4,quotes:"single"},formatters:{css:!0,html:!0,markdown:"prettier"},yaml:!1,react:!0}].concat(C(a)))},tT=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return j.apply(void 0,C(t))},tR=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}return ty.apply(void 0,C(t))},tD={eslint:tC,commitlint:tI,"lint-staged":tI,"vitest-react-e2e":tT,"vitest-react-unit":tR};function tb(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}var s=tD[e];if(!s)throw new Error("Unknown config type: ".concat(e));return s.apply(void 0,C(r))}function tw(e){var t=e.uri,r=e.from,n=e.to,s=e.withComponent,i=e.withHOC,o=e.withHooks,a=e.withMutationFn,c=e.withRefetchFn,u=e.federation;var d=v({},s&&{withComponent:s},i&&{withHOC:i},o&&{withHooks:o},a&&{withMutationFn:a},c&&{withRefetchFn:c},u&&{config:{federation:!0}});return{schema:t,documents:[r],generates:l({},n,v({plugins:["typescript","typescript-operations","typescript-react-apollo"]},Object.keys(d).length>0&&{config:d})),hooks:{afterAllFileWrite:[tv.ESLINT_FIX]}}}var tx={"*":["eslint --fix"]};var tL=(typeof window==="undefined"?"undefined":T(window))<"u";var tP={lint:"Check code for linting issues","lint:fix":"Fix linting issues automatically","lint:inspect":"View active ESLint configuration","lint-staged":"Run lint checks on staged files",commitlint:"Validate commit message format",setup:"Initialize project setup and dependencies",reset:"Reset the project and reinstall dependencies",inspect:"Analyze installed project dependencies","test:unit":"Run unit test suite","test:e2e":"Run end-to-end test suite"};import tM from"node:process";import{hideBin as tj}from"yargs/helpers";import tG from"yargs/yargs";var tk={name:"@cyberskill/shared",type:"module",version:"1.72.0",description:"CyberSkill Shared",author:"Stephen Cheng",license:"MIT",homepage:"https://github.com/cyberskill-world/shared#readme",repository:{type:"git",url:"git+https://github.com/cyberskill-world/shared.git"},bugs:{url:"https://github.com/cyberskill-world/shared/issues"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./configs":{types:"./dist/configs/index.d.ts",import:"./dist/configs/index.js",require:"./dist/configs/index.cjs"},"./configs/commitlint":{types:"./dist/configs/commitlint/index.d.ts",import:"./dist/configs/commitlint/index.js",require:"./dist/configs/commitlint/index.cjs"},"./configs/eslint":{types:"./dist/configs/eslint/index.d.ts",import:"./dist/configs/eslint/index.js",require:"./dist/configs/eslint/index.cjs"},"./configs/graphql-codegen":{types:"./dist/configs/graphql-codegen/index.d.ts",import:"./dist/configs/graphql-codegen/index.js",require:"./dist/configs/graphql-codegen/index.cjs"},"./configs/lint-staged":{types:"./dist/configs/lint-staged/index.d.ts",import:"./dist/configs/lint-staged/index.js",require:"./dist/configs/lint-staged/index.cjs"},"./configs/vitest/react/e2e":{types:"./dist/configs/vitest/react/e2e.d.ts",import:"./dist/configs/vitest/react/e2e.js",require:"./dist/configs/vitest/react/e2e.cjs"},"./configs/vitest/react/unit":{types:"./dist/configs/vitest/react/unit.d.ts",import:"./dist/configs/vitest/react/unit.js",require:"./dist/configs/vitest/react/unit.cjs"},"./constants":{types:"./dist/constants/index.d.ts",import:"./dist/constants/index.js",require:"./dist/constants/index.cjs"},"./nodejs":{types:"./dist/nodejs/index.d.ts",import:"./dist/nodejs/index.js",require:"./dist/nodejs/index.cjs"},"./nodejs/cli":{types:"./dist/nodejs/cli/index.d.ts",import:"./dist/nodejs/cli/index.js",require:"./dist/nodejs/cli/index.cjs"},"./nodejs/command":{types:"./dist/nodejs/command/index.d.ts",import:"./dist/nodejs/command/index.js",require:"./dist/nodejs/command/index.cjs"},"./nodejs/fs":{types:"./dist/nodejs/fs/index.d.ts",import:"./dist/nodejs/fs/index.js",require:"./dist/nodejs/fs/index.cjs"},"./nodejs/log":{types:"./dist/nodejs/log/index.d.ts",import:"./dist/nodejs/log/index.js",require:"./dist/nodejs/log/index.cjs"},"./nodejs/mongo":{types:"./dist/nodejs/mongo/index.d.ts",import:"./dist/nodejs/mongo/index.js",require:"./dist/nodejs/mongo/index.cjs"},"./nodejs/package":{types:"./dist/nodejs/package/index.d.ts",import:"./dist/nodejs/package/index.js",require:"./dist/nodejs/package/index.cjs"},"./nodejs/path":{types:"./dist/nodejs/path/index.d.ts",import:"./dist/nodejs/path/index.js",require:"./dist/nodejs/path/index.cjs"},"./nodejs/storage":{types:"./dist/nodejs/storage/index.d.ts",import:"./dist/nodejs/storage/index.js",require:"./dist/nodejs/storage/index.cjs"},"./react":{types:"./dist/react/index.d.ts",import:"./dist/react/index.js",require:"./dist/react/index.cjs"},"./react/apollo-client":{types:"./dist/react/apollo-client/index.d.ts",import:"./dist/react/apollo-client/index.js",require:"./dist/react/apollo-client/index.cjs"},"./react/apollo-error":{types:"./dist/react/apollo-error/index.d.ts",import:"./dist/react/apollo-error/index.js",require:"./dist/react/apollo-error/index.cjs"},"./react/i18next":{types:"./dist/react/i18next/index.d.ts",import:"./dist/react/i18next/index.js",require:"./dist/react/i18next/index.cjs"},"./react/loading":{types:"./dist/react/loading/index.d.ts",import:"./dist/react/loading/index.js",require:"./dist/react/loading/index.cjs"},"./react/log":{types:"./dist/react/log/index.d.ts",import:"./dist/react/log/index.js",require:"./dist/react/log/index.cjs"},"./react/next-intl":{types:"./dist/react/next-intl/index.d.ts",import:"./dist/react/next-intl/index.js",require:"./dist/react/next-intl/index.cjs"},"./react/storage":{types:"./dist/react/storage/index.d.ts",import:"./dist/react/storage/index.js",require:"./dist/react/storage/index.cjs"},"./react/toast":{types:"./dist/react/toast/index.d.ts",import:"./dist/react/toast/index.js",require:"./dist/react/toast/index.cjs"},"./react/vitest":{types:"./dist/react/vitest/index.d.ts",import:"./dist/react/vitest/index.js",require:"./dist/react/vitest/index.cjs"},"./styles/reset.css":{import:"./dist/styles/reset.css",require:"./dist/styles/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./utils":{types:"./dist/utils/index.d.ts",import:"./dist/utils/index.js",require:"./dist/utils/index.cjs"}},main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",bin:{cyberskill:"./dist/nodejs/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"dotenv -e .env -- tsup --watch",lint:"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint","lint:fix":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint:fix","lint:inspect":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint:inspect",reset:"dotenv -e .env -- tsx src/nodejs/cli/index.ts reset",setup:"dotenv -e .env -- tsx src/nodejs/cli/index.ts setup",inspect:"dotenv -e .env -- tsx src/nodejs/cli/index.ts inspect","test:unit":"dotenv -e .env -- tsx src/nodejs/cli/index.ts test:unit","test:e2e":"dotenv -e .env -- tsx src/nodejs/cli/index.ts test:e2e",commitlint:"dotenv -e .env -- tsx src/nodejs/cli/index.ts commitlint","lint-staged":"dotenv -e .env -- tsx src/nodejs/cli/index.ts lint-staged"},dependencies:{"@antfu/eslint-config":"4.11.0","@apollo/client":"3.13.6","@eslint-react/eslint-plugin":"1.43.0","@graphql-codegen/cli":"5.0.5","@graphql-codegen/client-preset":"4.8.0","@graphql-codegen/typescript-react-apollo":"4.3.2","@microsoft/api-extractor":"7.52.3","@next/eslint-plugin-next":"15.2.5","@swc/core":"1.11.18","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.8.1","@vitest/browser":"3.1.1",chalk:"5.4.1",classnames:"2.5.1",consola:"3.4.2","crypto-js":"4.2.0","date-fns":"4.1.0","dotenv-cli":"8.0.0","eslint-config-next":"15.2.5","eslint-plugin-format":"1.0.1","eslint-plugin-react-hooks":"5.2.0","eslint-plugin-react-refresh":"0.4.19",globals:"16.0.0",graphql:"16.10.0","graphql-ws":"6.0.4",i18next:"24.2.3",jsdom:"26.0.0",localforage:"1.10.0","modern-normalize":"3.0.1",mongodb:"6.15.0",mongoose:"8.13.2","mongoose-aggregate-paginate-v2":"1.1.4","mongoose-paginate-v2":"1.9.0","next-intl":"4.0.2","node-fetch":"3.3.2","node-persist":"4.0.4",ora:"8.2.0",playwright:"1.51.1","postcss-modules":"6.0.1",qs:"6.14.0",react:"19.1.0","react-dom":"19.1.0","react-hot-toast":"2.5.2","react-i18next":"15.4.1","react-icons":"5.5.0",sass:"1.86.3",slugify:"1.6.6",tsup:"8.4.0",tsx:"4.19.3",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.2.5",vitest:"3.1.1","vitest-browser-react":"0.1.1",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.0","@eslint/config-inspector":"1.0.2","@types/crypto-js":"4.2.2","@types/mongoose-aggregate-paginate-v2":"1.0.12","@types/node-persist":"3.1.8","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/yargs":"17.0.33",eslint:"9.24.0","lint-staged":"15.5.0","node-modules-inspector":"0.6.3","simple-git-hooks":"2.12.1"}};function tU(e,t){return tF.apply(this,arguments)}function tF(){tF=i(function(e,t){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);Z.start("".concat(e)),B&&Z.info("→ ".concat(t));return[4,ew(t)];case 1:n.sent(),Z.success("".concat(e," done."));return[3,3];case 2:r=n.sent();throw Z.error("".concat(e," failed: ").concat(r.message)),r;case 3:return[2]}})});return tF.apply(this,arguments)}function tq(){return tK.apply(this,arguments)}function tK(){tK=i(function(){var e;return b(this,function(t){switch(t.label){case 0:if(!en(tm.TS_CONFIG))return[3,2];return[4,tU("Performing TypeScript validation",tv.TYPESCRIPT_CHECK)];case 1:e=t.sent();return[3,3];case 2:e=Z.warn("No TypeScript configuration found. Skipping type check.");t.label=3;case 3:e;return[2]}})});return tK.apply(this,arguments)}function tH(){return tY.apply(this,arguments)}function tY(){tY=i(function(){var e,t;var r=arguments;return b(this,function(n){switch(n.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:!1;if(!e)return[3,2];return[4,tU("Running ESLint with auto-fix",tv.ESLINT_FIX)];case 1:t=n.sent();return[3,4];case 2:return[4,tU("Running ESLint check",tv.ESLINT_CHECK)];case 3:t=n.sent();n.label=4;case 4:t;return[2]}})});return tY.apply(this,arguments)}function tB(e,t){if(!t.length)return;var r=e==="Errors"?"red":"yellow";Z.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,r)}function tV(){return tQ.apply(this,arguments)}function tQ(){tQ=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:return[4,eI()];case 1:e=n.sent(),t=e.filter(function(e){return e.type==="error"}),r=e.filter(function(e){return e.type==="warning"});!t.length&&!r.length?Z.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tB("Warnings",r),tB("Errors",t));return[2]}})});return tQ.apply(this,arguments)}function tJ(){return tW.apply(this,arguments)}function tW(){tW=i(function(){var e,t,r;return b(this,function(n){switch(n.label){case 0:return[4,eT()];case 1:n.sent();return[4,ef(eH)];case 2:e=n.sent(),t=e.isCurrentProject;if(!t)return[3,7];n.label=3;case 3:n.trys.push([3,6,,7]);return[4,tU("Building package: ".concat(eH),tv.BUILD)];case 4:n.sent();return[4,tU("Staging build artifacts",tv.STAGE_BUILD_DIRECTORY)];case 5:n.sent();return[3,7];case 6:r=n.sent();throw Z.error("Error building and staging ".concat(eH,": ").concat(r.message)),r;case 7:return[4,tU("Executing lint-staged",tv.CYBERSKILL.LINT_STAGED)];case 8:n.sent(),tV();return[2]}})});return tW.apply(this,arguments)}function tX(){return tz.apply(this,arguments)}function tz(){tz=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Inspecting ESLint configuration",tv.ESLINT_INSPECT)];case 1:e.sent();return[2]}})});return tz.apply(this,arguments)}function t$(){return tZ.apply(this,arguments)}function tZ(){tZ=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,Promise.all([tq(),tH()])];case 2:e.sent(),tV();return[2]}})});return tZ.apply(this,arguments)}function t0(){return t1.apply(this,arguments)}function t1(){t1=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,Promise.all([tq(),tH(!0)])];case 2:e.sent(),tV();return[2]}})});return t1.apply(this,arguments)}function t2(){return t3.apply(this,arguments)}function t3(){t3=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,eT()];case 1:e.sent();return[4,tU("Validating commit message",tv.CYBERSKILL.COMMIT_LINT)];case 2:e.sent(),tV();return[2]}})});return t3.apply(this,arguments)}function t4(){return t5.apply(this,arguments)}function t5(){t5=i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:return[4,tU("Configuring Git hooks",tv.CONFIGURE_GIT_HOOK)];case 1:r.sent(),ea(tm.GIT_HOOK);return[4,ej(tg)];case 2:e=r.sent();ei(tm.SIMPLE_GIT_HOOKS_JSON,e,{isJson:!0});t="\n".concat(ez,"\n");en(tm.GIT_IGNORE)?es(tm.GIT_IGNORE).split("\n").includes(ez)||eo(tm.GIT_IGNORE,t):ei(tm.GIT_IGNORE,t);return[4,tU("Setting up simple-git-hooks",tv.SIMPLE_GIT_HOOKS)];case 3:r.sent();return[2]}})});return t5.apply(this,arguments)}function t8(){return t6.apply(this,arguments)}function t6(){t6=i(function(){var e,t,r,n,s,i,o,a,c,u,l;return b(this,function(d){switch(d.label){case 0:e=[{command:tv.PNPM_INSTALL_STANDARD,message:"Installing dependencies (standard)"},{command:tv.PNPM_INSTALL_LEGACY,message:"Retrying with legacy peer dependencies"},{command:tv.PNPM_INSTALL_FORCE,message:"Retrying with force install"}];t=true,r=false,n=undefined;d.label=1;case 1:d.trys.push([1,8,9,10]);s=e[Symbol.iterator]();d.label=2;case 2:if(!!(t=(i=s.next()).done))return[3,7];o=i.value,a=o.command,c=o.message;d.label=3;case 3:d.trys.push([3,5,,6]);return[4,tU("".concat(c," using: ").concat(a),a)];case 4:d.sent();return[2];case 5:u=d.sent();Z.warn("Installation attempt failed: ".concat(a)),Z.error("Details: ".concat(u.message));return[3,6];case 6:t=true;return[3,2];case 7:return[3,10];case 8:l=d.sent();r=true;n=l;return[3,10];case 9:try{if(!t&&s.return!=null){s.return()}}finally{if(r){throw n}}return[7];case 10:throw new Error("All dependency installation strategies failed.")}})});return t6.apply(this,arguments)}function t7(e,t){return t9.apply(this,arguments)}function t9(){t9=i(function(e,t){var r,n,s,i,o,a,c,u,l,d,f,p;return b(this,function(E){switch(E.label){case 0:if(!en(tm.PACKAGE_JSON)){Z.error("package.json not found. Aborting setup.");return[2]}E.label=1;case 1:E.trys.push([1,14,,15]);return[4,ef(e,{update:t===null||t===void 0?void 0:t.update})];case 2:r=E.sent(),n=r.isUpToDate;s=n;if(s)return[3,5];return[4,t8()];case 3:E.sent();return[4,t0()];case 4:s=E.sent();E.label=5;case 5:s;o=true,a=false,c=undefined;E.label=6;case 6:E.trys.push([6,11,12,13]);u=((i=t===null||t===void 0?void 0:t.postInstallActions)!==null&&i!==void 0?i:[])[Symbol.iterator]();E.label=7;case 7:if(!!(o=(l=u.next()).done))return[3,10];d=l.value;return[4,d()];case 8:E.sent();E.label=9;case 9:o=true;return[3,7];case 10:return[3,13];case 11:f=E.sent();a=true;c=f;return[3,13];case 12:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 13:Z.success('"'.concat(e,'" setup completed.'));return[3,15];case 14:p=E.sent();throw Z.error('Failed to setup "'.concat(e,'": ').concat(p.message)),p;case 15:return[2]}})});return t9.apply(this,arguments)}function re(){return rt.apply(this,arguments)}function rt(){rt=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,t7(eH,{update:!0,postInstallActions:[t4]})];case 1:e.sent();return[2]}})});return rt.apply(this,arguments)}function rr(){return rn.apply(this,arguments)}function rn(){rn=i(function(){return b(this,function(e){switch(e.label){case 0:ea(tm.NODE_MODULES,tm.PNPM_LOCK_YAML);return[4,t8()];case 1:e.sent();return[4,t4()];case 2:e.sent();return[2]}})});return rn.apply(this,arguments)}function rs(){return ri.apply(this,arguments)}function ri(){ri=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Inspecting project dependencies",tv.NODE_MODULES_INSPECT)];case 1:e.sent();return[2]}})});return ri.apply(this,arguments)}function ro(){return ra.apply(this,arguments)}function ra(){ra=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Running unit tests",tv.CYBERSKILL.TEST_UNIT)];case 1:e.sent();return[2]}})});return ra.apply(this,arguments)}function rc(){return ru.apply(this,arguments)}function ru(){ru=i(function(){return b(this,function(e){switch(e.label){case 0:return[4,tU("Running end-to-end tests",tv.CYBERSKILL.TEST_E2E)];case 1:e.sent();return[2]}})});return ru.apply(this,arguments)}i(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,tG(tj(tM.argv)).scriptName(e2).usage("$0 <command> [options]").command("lint",tP.lint,t$).command("lint:fix",tP["lint:fix"],t0).command("lint:inspect",tP["lint:inspect"],tX).command("lint-staged",tP["lint-staged"],tJ).command("commitlint",tP.commitlint,t2).command("setup",tP.setup,re).command("reset",tP.reset,rr).command("inspect",tP.inspect,rs).command("test:unit",tP["test:unit"],ro).command("test:e2e",tP["test:e2e"],rc).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(tk.version).epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse()];case 1:t.sent();return[3,3];case 2:e=t.sent();Z.error("Fatal: ".concat(e.message)),tM.exit(1);return[3,3];case 3:return[2]}})})();import{format as rl}from"date-fns";import{Document as rd}from"mongoose";import rf from"mongoose-aggregate-paginate-v2";import rp from"mongoose-paginate-v2";import{v4 as rE}from"uuid";import rm from"crypto-js";import rg from"slugify";var rh=rg.default||rg;function rv(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var r=t||{},n=r.lower,s=n===void 0?!0:n,i=r.locale,o=i===void 0?"vi":i,a=S(r,["lower","locale"]);return rh(e,v({lower:s,locale:o},a))}function ry(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return rm.SHA256(e).toString(rm.enc.Hex).slice(0,t)}var r_={isEmpty:function e(e){return e==null?!0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":T(e))=="object"?p(e,Date)?!1:Object.keys(e).length===0:typeof e=="string"?e.trim().length===0:!1}};var rS={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return rl(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,r=t===void 0?"string":t;var n=r==="string"?rS.getDateTime():new Date;return{id:rE(),isDel:!1,createdAt:n,updatedAt:n}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var r=t.method,n=t.pre,s=t.post;r&&n&&e.pre(r,n),r&&s&&e.post(r,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:rE,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,r=e.schema,n=e.virtuals,s=n===void 0?[]:n,i=e.standalone,o=i===void 0?!1:i;var a=new t.Schema(r,{strict:!0});return s.forEach(function(e){var t=e.name,r=e.options,n=e.get;var s=a.virtual(t,r);n&&s.get(n)}),o||a.add(rS.createGenericSchema(t)),a},createModel:function e(e){var t=e.mongoose,r=e.name,n=e.schema,s=e.pagination,i=s===void 0?!1:s,o=e.aggregate,a=o===void 0?!1:o,c=e.virtuals,u=c===void 0?[]:c,l=e.middlewares,d=l===void 0?[]:l;if(!r)throw new Error("Model name is required.");if(t.models[r])return t.models[r];var f=rS.createSchema({mongoose:t,schema:n,virtuals:u});return rS.applyPlugins(f,[i&&rp,a&&rf]),rS.applyMiddlewares(f,d),t.model(r,f)},createSlugQuery:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return _(v({},t,r&&{id:{$ne:r}}),{$or:[{slug:e},{slugHistory:e}]})},validator:{isEmpty:function e(){return /*#__PURE__*/function(){var e=i(function(e){return b(this,function(t){return[2,!r_.isEmpty(e)]})});return function(t){return e.apply(this,arguments)}}()},isUnique:function e(e){return /*#__PURE__*/function(){var t=i(function(t){var r;return b(this,function(n){switch(n.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");r={$or:e.map(function(e){return l({},e,t)})};return[4,this.constructor.findOne(r)];case 1:return[2,!n.sent()]}})});return function(e){return t.apply(this,arguments)}}()},matchesRegex:function e(e){return /*#__PURE__*/function(){var t=i(function(t){return b(this,function(r){if(!Array.isArray(e)||e.some(function(e){return!p(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(t)})]})});return function(e){return t.apply(this,arguments)}}()}}},rO=/*#__PURE__*/function(){"use strict";function e(t,r){a(this,e);this.collection=t.collection(r)}u(e,[{key:"createOne",value:function e(e){var t=this;return i(function(){var r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);r=v({},rS.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,t.collection.insertOne(r)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var t=this;return i(function(){var r,n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);r=e.map(function(e){return v({},rS.createGenericFields(),e)});return[4,t.collection.insertMany(r)];case 1:n=i.sent();return[2,n.insertedCount===0?{success:!1,message:"No documents were inserted"}:{success:!0,message:"".concat(n.insertedCount," documents created successfully"),result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"findOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.findOne(e)];case 1:r=s.sent();return[2,r?{success:!0,message:"Document found",result:r}:{success:!1,message:"Document not found"}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0,message:"Documents retrieved successfully"};return[4,t.collection.find(e).toArray()];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0,message:"Count retrieved successfully"};return[4,t.collection.countDocuments(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(e,t){var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.collection.updateOne(e,{$set:t})];case 1:n=i.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(e,t){var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.collection.updateMany(e,{$set:t})];case 1:n=i.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.deleteOne(e)];case 1:r=s.sent();return[2,r.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document deleted successfully",result:r}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,t.collection.deleteMany(e)];case 1:r=s.sent();return[2,r.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents deleted successfully",result:r}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}}]);return e}(),rA=/*#__PURE__*/function(){"use strict";function e(t){a(this,e);this.model=t}u(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return i(function(){var i,o,a;return b(this,function(c){switch(c.label){case 0:c.trys.push([0,2,,3]);i=s.model.findOne(e,t,r);n&&i.populate(n);return[4,i.exec()];case 1:o=c.sent();return[2,o?{success:!0,result:o}:{success:!1,message:"No ".concat(s.getModelName()," found."),code:X.NOT_FOUND.CODE}];case 2:a=c.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return i(function(){var i,o,a;return b(this,function(c){switch(c.label){case 0:c.trys.push([0,2,,3]);i=s.model.find(e,t,r);n&&i.populate(n);o={success:!0};return[4,i.exec()];case 1:return[2,(o.result=c.sent(),o)];case 2:a=c.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPaging",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.paginate(e,t)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPagingAggregate",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.aggregatePaginate(r.model.aggregate(e),t)];case 1:return[2,(n.result=i.sent(),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.countDocuments(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createOne",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.create(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);n={success:!0};return[4,r.model.insertMany(e,t)];case 1:return[2,(n.result=i.sent().map(function(e){return p(e,rd)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,i;return b(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,n.model.findOneAndUpdate(e,t,v({new:!0},r)).exec()];case 1:s=o.sent();return[2,s?{success:!0,result:s}:{success:!1,message:"Failed to update ".concat(n.getModelName(),"."),code:X.NOT_FOUND.CODE}];case 2:i=o.sent();return[2,{success:!1,message:i.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,i;return b(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);s={success:!0};return[4,n.model.updateMany(e,t,r).exec()];case 1:return[2,(s.result=o.sent(),s)];case 2:i=o.sent();return[2,{success:!1,message:i.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.model.findOneAndDelete(e,t).exec()];case 1:n=i.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(r.getModelName()," found to delete."),code:X.NOT_FOUND.CODE}];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r=this;return i(function(){var n,s;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);return[4,r.model.deleteMany(e,t).exec()];case 1:n=i.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:X.NOT_FOUND.CODE}:{success:!0,result:n}];case 2:s=i.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;var r=this;return i(function(){var n,s,i,o;return b(this,function(a){switch(a.label){case 0:n=new Set;s=0;a.label=1;case 1:if(!(s<10))return[3,5];i=ry(e,s+t);o=!n.has(i);if(!o)return[3,3];n.add(i);return[4,r.model.exists({shortId:i})];case 2:o=!a.sent();a.label=3;case 3:if(o)return[2,{success:!0,result:i}];a.label=4;case 4:s++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:X.INTERNAL_SERVER_ERROR.CODE}]}})})()}},{key:"createSlug",value:function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return i(function(){var s,o,a,c,u,l,d,f,p,E,m;return b(this,function(g){switch(g.label){case 0:g.trys.push([0,8,,9]);s=t[e],o=/*#__PURE__*/function(){var e=i(function(e){var s,i,o;return b(this,function(a){switch(a.label){case 0:return[4,n.model.findOne(rS.createSlugQuery(e,r,t.id))];case 1:s=a.sent();if(!s)return[2,e];i=1;a.label=2;case 2:o="".concat(e,"-").concat(i);return[4,n.model.findOne(rS.createSlugQuery(o,r,t.id))];case 3:s=a.sent(),i++;a.label=4;case 4:if(s)return[3,2];a.label=5;case 5:return[2,o]}})});return function t(t){return e.apply(this,arguments)}}();if(!((typeof s==="undefined"?"undefined":T(s))=="object"))return[3,5];a={};c=[];for(u in s)c.push(u);l=0;g.label=1;case 1:if(!(l<c.length))return[3,4];d=c[l];f=rv(s[d]);return[4,o(f)];case 2:a[d]=g.sent();g.label=3;case 3:l++;return[3,1];case 4:return[2,{success:!0,result:a}];case 5:p=rv(s);E={success:!0};return[4,o(p)];case 6:return[2,(E.result=g.sent(),E)];case 7:return[3,9];case 8:m=g.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(m.message),code:X.INTERNAL_SERVER_ERROR.CODE}];case 9:return[2]}})})()}},{key:"aggregate",value:function e(e){var t=this;return i(function(){var r,n;return b(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);r={success:!0};return[4,t.model.aggregate(e)];case 1:return[2,(r.result=s.sent(),r)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}}]);return e}();import{Collection as rN,Db as rI}from"mongodb";import{Document as rC,Model as rT}from"mongoose";var rR=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rI),rD=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rC),rb=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rT),rw=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(rN);import{ApolloClient as rx,ApolloError as rL,ApolloLink as rP,ApolloProvider as rM,from as rj,HttpLink as rG,InMemoryCache as rk,split as rU}from"@apollo/client";import{onError as rF}from"@apollo/client/link/error";import{removeTypenameFromVariables as rq}from"@apollo/client/link/remove-typename";import{GraphQLWsLink as rK}from"@apollo/client/link/subscriptions";import{getMainDefinition as rH}from"@apollo/client/utilities";import{createClient as rY}from"graphql-ws";import{useMemo as rB}from"react";import{FaInfo as rV}from"react-icons/fa6";import{use as rQ}from"react";import{FaRepeat as rJ}from"react-icons/fa6";import{createContext as rW}from"react";var rX=rW(void 0);import rz from"./react/apollo-error/apollo-error.module.scss";import{jsx as r$,jsxs as rZ}from"react/jsx-runtime";function r0(){var e=rQ(rX),t=e===null||e===void 0?void 0:e.error;if(!t)return null;var r=function(e,t){return(t===null||t===void 0?void 0:t.length)?rZ("div",{children:[rZ("strong",{children:[e,":"]}),r$("ul",{children:t.map(function(e){return r$("li",{children:e.message},e.message)})})]}):null};return r$("div",{className:rz["modal-backdrop"],children:rZ("div",{className:rz["modal-content"],children:[r$("button",{type:"button",className:rz["btn-close"],onClick:e.hideError,children:"✕"}),rZ("div",{className:rz["error-title"],children:[r$("button",{type:"button",className:rz["btn-retry"],onClick:function(){return window.location.reload()},children:r$(rJ,{})})," ",t.message]}),rZ("div",{className:rz["error-details"],children:[t.networkError&&rZ("pre",{className:"network",children:[r$("strong",{children:"Network Error:"})," ",t.networkError.message]}),r("GraphQL Errors",C(t.graphQLErrors)),r("Protocol Errors",C(t.protocolErrors)),r("Client Errors",C(t.clientErrors)),t.extraInfo&&rZ("pre",{className:"extra",children:[r$("strong",{children:"Extra Info:"})," ",JSON.stringify(t.extraInfo,null,4)]})]})]})})}import{use as r1}from"react";function r2(){var e=r1(rX);if(!e)throw new Error("useApolloError must be used within ApolloErrorProvider");return e}import{useEffect as r3,useMemo as r4,useState as r5}from"react";import{jsx as r8}from"react/jsx-runtime";var r6=null;function r7(e){r6===null||r6===void 0?void 0:r6(e)}function r9(e){var t=e.children;var r=I(r5(null),2),n=r[0],s=r[1];r3(function(){r6=s},[]);var i=r4(function(){return{error:n,showError:s,hideError:function(){return s(null)}}},[n]);return r8(rX,{value:i,children:t})}import{consola as ne}from"consola/browser";var nt={silent:ne.silent,level:ne.level,fatal:ne.fatal,error:ne.error,warn:ne.warn,log:ne.log,info:ne.info,success:ne.success,ready:ne.ready,start:ne.start,box:ne.box,debug:ne.debug,trace:ne.trace,verbose:ne.verbose};import{toast as nr,Toaster as nn}from"react-hot-toast";var ns="/graphql";import{Fragment as ni,jsx as no,jsxs as na}from"react/jsx-runtime";var nc=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);var e;e=o(this,t,arguments);e.count=0;return e}u(t,[{key:"request",value:function e(e,t){var r=this;var n=Date.now();return this.count+=1,t(e).map(function(t){var s=Date.now()-n,i=e.operationName||"Unnamed";return nt.info("[Apollo] #".concat(r.count,": ").concat(i," (").concat(s,"ms)")),t})}}]);return t}(rP);function nu(e){var t=e||{},r=t.uri,n=t.wsUrl,s=t.customLinks,i=new nc,o=rF(function(e){var t=e.graphQLErrors,r=e.networkError,n=e.protocolErrors,s=e.operation;var i=(s===null||s===void 0?void 0:s.operationName)||"Unknown";if(t&&t.forEach(function(e){var t=e.message,r=e.locations,n=e.path;nt.error("[GraphQL error] ".concat(i,": ").concat(t,", Location: ").concat(JSON.stringify(r),", Path: ").concat(n))}),n&&n.forEach(function(e){var t=e.message,r=e.extensions;nt.error("[Protocol error]: ".concat(t,", Extensions: ").concat(JSON.stringify(r)))}),r&&nt.error("[Network error]: ".concat(r)),t||n||r){var o,a;var c=(t===null||t===void 0?void 0:(o=t[0])===null||o===void 0?void 0:o.message)||(n===null||n===void 0?void 0:(a=n[0])===null||a===void 0?void 0:a.message)||(r===null||r===void 0?void 0:r.message)||"Unexpected error",u=new rL({graphQLErrors:t||[],protocolErrors:n||[],clientErrors:[],networkError:r||null,errorMessage:c,extraInfo:{operation:s}});nr.error(function(e){return na(ni,{children:[c,"\xa0",no(rV,{cursor:"pointer",onClick:function(){setTimeout(function(){r7(u)},0),nr.dismiss(e.id)}})]})})}}),a=rq();r||nt.warn('[Apollo] No GraphQL URI provided — using "'.concat(ns,'" as default'));var c=new rG({uri:r!==null&&r!==void 0?r:ns,credentials:"include"}),u=n?new rK(rY({url:n})):rP.empty(),l=p(u,rP)?rU(function(e){var t=e.query;var r=rH(t);return r.kind==="OperationDefinition"&&r.operation==="subscription"},u,c):c;return l===c&&n&&nt.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[i,o,a].concat(C(s!==null&&s!==void 0?s:[]),[l])}function nl(e){var t=e.isNextJS,r=e.options,n=e.children,s=e.client,i=e.provider,o=e.cache;var a=r||{},c=a.uri,u=a.wsUrl,l=a.customLinks,d=S(a,["uri","wsUrl","customLinks"]),f=s!==null&&s!==void 0?s:rx;if(typeof f!="function")throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");var E=i||rM,m=rB(function(){return rj(nu({uri:c,wsUrl:u,customLinks:l}))},[c,u,l]),g=rB(function(){return p(o,rk)?o:new rk},[o]),h=rB(function(){return new f(v({link:m,cache:g},d))},[f,m,g,d]);return na(ni,{children:[na(r9,{children:[t?no(E,{makeClient:function(){return h},children:n}):no(E,{client:h,children:n}),no(r0,{})]}),no(nn,{position:"top-right"})]})}import{useTranslation as nd}from"react-i18next";var nf=nd;import np from"i18next";import{initReactI18next as nE}from"react-i18next";function nm(e){return np.use(nE).init(e)}import ng from"classnames";import nh from"./react/loading/loading.module.scss";import{jsx as nv,jsxs as ny}from"react/jsx-runtime";function n_(e){var t=e.full,r=t===void 0?!1:t,n=e.block,s=n===void 0?!1:n,i=e.className,o=i===void 0?"":i,a=e.message,c=a===void 0?"Loading":a,u=S(e,["full","block","className","message"]);function l(){return ny("div",_(v({className:nh.container},u),{children:[nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),nv("div",{className:nh.ring}),c&&nv("div",{className:nh.message,children:c})]}))}return r?nv("div",{className:ng(nh.fullscreen,o),children:l()}):s?nv("div",{className:ng(nh.block,o),children:l()}):l()}import{createContext as nS}from"react";var nO=nS(void 0);import{use as nA}from"react";function nN(){var e=nA(nO);if(!e)throw new Error("useLoading must be used within a LoadingProvider");return e}import{useCallback as nI,useMemo as nC,useState as nT}from"react";import{jsx as nR}from"react/jsx-runtime";function nD(e){var t=e.children;var r=I(nT(!1),2),n=r[0],s=r[1],i=I(nT(!1),2),o=i[0],a=i[1],c=nI(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;s(!0),a(e)},[]),u=nI(function(){s(!1),a(!1)},[]),l=nC(function(){return{isLoading:n,isGlobalLoading:o,showLoading:c,hideLoading:u}},[n,o,c,u]);return nR(nO,{value:l,children:n?nR(n_,{full:o}):t})}import{createContext as nb}from"react";var nw=nb(void 0);import{NextIntlClientProvider as nx}from"next-intl";import{useTranslations as nL}from"next-intl";import{use as nP}from"react";function nM(){var e=nP(nw);if(!e)throw new Error("useNextIntl must be used within a NextIntlProvider");return e}var nj=nL;import{jsx as nG}from"react/jsx-runtime";function nk(e){var t=function(t){var r;var n=nM(),s=n.currentLanguage,i=t.messages,o=t.languages,a="en",c=i[(s===null||s===void 0?void 0:s.value)||a],u=(r=o.find(function(e){return e.value===(s===null||s===void 0?void 0:s.value)}))===null||r===void 0?void 0:r.timezone;return i?nG(nx,{locale:(s===null||s===void 0?void 0:s.value)||a,messages:c,timeZone:u,children:nG(e,v({},t))}):(nt.warn("Missing messages for language: ".concat((s===null||s===void 0?void 0:s.value)||a)),null)};return t.displayName="withNextIntl(".concat(e.displayName||e.name||"Component",")"),t}import{useMemo as nU}from"react";import{useCallback as nF,useEffect as nq,useState as nK}from"react";var nH={serialize:function(e){return JSON.stringify(e,function(e,t){return p(t,Date)?{__type:"Date",value:t.toISOString()}:t})},deserialize:function(e){return JSON.parse(e,function(e,t){return(t===null||t===void 0?void 0:t.__type)==="Date"?new Date(t.value):t})}};import nY from"localforage";var nB={get:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.getItem(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(nt.error('[Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 3:return[2]}})})()},set:function e(e,t){return i(function(){var r;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,nY.setItem(e,t)];case 1:n.sent();return[3,3];case 2:r=n.sent();nt.error('[Storage:set] Error setting key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},remove:function e(e){return i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.removeItem(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();nt.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},keys:function e(){return i(function(){var e,t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nY.keys()];case 1:return[2,(e=r.sent())!==null&&e!==void 0?e:[]];case 2:t=r.sent();return[2,(nt.error("[Storage:keys] Error getting keys:",t),[])];case 3:return[2]}})})()}};function nV(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nH;var n=I(nK(t),2),s=n[0],o=n[1],a=I(nK(!1),2),c=a[0],u=a[1];nq(function(){var n=!0;return i(function(){var s,i,a,c;return b(this,function(l){switch(l.label){case 0:l.trys.push([0,6,7,8]);return[4,nB.get(e)];case 1:s=l.sent();if(!n)return[3,5];if(!(s!==null))return[3,2];i=r.deserialize(s);o(i);return[3,5];case 2:if(!(t!==void 0))return[3,4];a=r.serialize(t);return[4,nB.set(e,a)];case 3:l.sent(),o(t);return[3,5];case 4:o(void 0);l.label=5;case 5:return[3,8];case 6:c=l.sent();nt.error('Error loading value for key "'.concat(e,'":'),c),n&&o(t);return[3,8];case 7:n&&u(!0);return[7];case 8:return[2]}})})(),function(){n=!1,u(!1)}},[e,t,r]),nq(function(){if(!c)return;i(function(){var t,n;return b(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);if(!(s!==void 0))return[3,2];t=r.serialize(s);return[4,nB.set(e,t)];case 1:i.sent();i.label=2;case 2:return[3,4];case 3:n=i.sent();nt.error('Error saving value for key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},[s,e,r,c]);var l=nF(function(e){o(function(t){return typeof e=="function"?e(t):e})},[]),d=nF(/*#__PURE__*/i(function(){var t;return b(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,nB.remove(e)];case 1:r.sent(),o(void 0);return[3,3];case 2:t=r.sent();nt.error('Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})}),[e]);return{value:s,set:l,remove:d}}import{Fragment as nQ,jsx as nJ}from"react/jsx-runtime";function nW(e){var t=e.children;return nJ(nQ,{children:t})}var nX=nk(nW);function nz(e){var t=e.children,r=e.languages,n=e.messages;var s;var i=nV("lang",(s=r===null||r===void 0?void 0:r[0])!==null&&s!==void 0?s:{}),o=i.value,a=i.set,c=nU(function(){return{languages:r,currentLanguage:o,setCurrentLanguage:a}},[r,a,o]);return nJ(nw,{value:c,children:nJ(nX,{languages:r,messages:n,children:t})})}import n$ from"unorm";var nZ={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},n0=Object.entries(nZ).reduce(function(e,t){var r=I(t,2),n=r[0],s=r[1];return e[n.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function n1(e){e=n$.nfkc(e);var t=v({},nZ,n0);var r=true,n=false,s=undefined;try{for(var i=Object.entries(t)[Symbol.iterator](),o;!(r=(o=i.next()).done);r=true){var a=I(o.value,2),c=a[0],u=a[1];var l="[".concat(c).concat(u.join(""),"]"),d="(".concat([c].concat(C(u)).join("|"),")");e=e.replace(new RegExp(l,"g"),d)}}catch(e){n=true;s=e}finally{try{if(!r&&i.return!=null){i.return()}}finally{if(n){throw s}}}return e}function n2(e){return e.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}export{r0 as ApolloError,rX as ApolloErrorContext,r9 as ApolloErrorProvider,nl as ApolloProvider,eV as BUILD_DIRECTORY,ee as CHECK_PACKAGE_EMPTY_RESULT,tv as COMMAND,tP as COMMAND_DESCRIPTIONS,te as COMMIT_LINT_CLI,e9 as COMMIT_LINT_PACKAGE_NAME,e2 as CYBERSKILL_CLI,e3 as CYBERSKILL_CLI_PATH,e1 as CYBERSKILL_DIRECTORY,eH as CYBERSKILL_PACKAGE_NAME,eY as CYBERSKILL_STORAGE,rw as C_Collection,rR as C_Db,rD as C_Document,rb as C_Model,B as DEBUG,e5 as ESLINT_CLI,tf as ESLINT_INSPECT_CLI,td as ESLINT_INSPECT_PACKAGE_NAME,e4 as ESLINT_PACKAGE_NAME,F as E_CommandType,x as E_ConfigType,V as E_IssueType,to as GIT_CLI,e0 as GIT_COMMIT_EDITMSG,eZ as GIT_HOOK,eX as GIT_IGNORE,ns as GRAPHQL_URI_DEFAULT,tg as HOOK,tL as IS_BROWSER,tr as LINT_STAGED_CLI,tt as LINT_STAGED_PACKAGE_NAME,n_ as Loading,nO as LoadingContext,nD as LoadingProvider,rO as MongoController,rA as MongooseController,eB as NODE_MODULES,tE as NODE_MODULES_INSPECT_CLI,tp as NODE_MODULES_INSPECT_PACKAGE_NAME,nw as NextIntlContext,nz as NextIntlProvider,eQ as PACKAGE_JSON,eJ as PACKAGE_LOCK_JSON,tm as PATH,e6 as PLAYWRIGHT_PACKAGE_NAME,ta as PNPM_CLI,tc as PNPM_EXEC_CLI,e$ as PNPM_LOCK_YAML,X as RESPONSE_STATUS,tu as SIMPLE_GIT_HOOKS_PACKAGE_NAME,tl as SIMPLE_GIT_HOOK_CLI,ez as SIMPLE_GIT_HOOK_JSON,eW as TSCONFIG_JSON,ts as TSC_CLI,tn as TSC_PACKAGE_NAME,ti as TSX_CLI,nn as Toaster,e7 as VITEST_CLI,e8 as VITEST_PACKAGE_NAME,eK as WORKING_DIRECTORY,rf as aggregatePaginate,eo as appendFileSync,ef as checkPackage,eT as clearAllErrorLists,w as commitlintConfig,tw as createGraphqlCodegenConfig,tO as deepMerge,tN as eslintConfig,ew as executeCommand,en as existsSync,eM as formatCommand,ry as generateShortId,rv as generateSlug,el as getLatestPackageVersion,eu as getPackage,eI as getStoredErrorLists,nm as initI18next,t_ as isJson,tS as isPlainObject,eq as join,tx as lintStagedConfig,nt as log,Z as logNodeJS,tb as mergeConfigs,rS as mongo,rp as mongoosePaginate,eL as rawCommand,es as readFileSync,n1 as regexSearchMapper,n2 as removeAccent,eF as resolve,ej as resolveCommands,eU as resolveWorkingPath,ea as rmSync,nH as serializer,r7 as showGlobalApolloError,nB as storage,e_ as storageNodeJS,z as throwError,nr as toast,r2 as useApolloError,nN as useLoading,nM as useNextIntl,nV as useStorage,nf as useTranslateI18next,nj as useTranslateNextIntl,r_ as validate,j as vitestE2E,ty as vitestUnit,nk as withNextIntl,ei as writeFileSync};