@modrinth/api-client 0.7.0 → 0.8.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,2 +1,2 @@
1
- var a=class{constructor(e){this.client=e}};var R=class extends a{getModuleID(){return"archon_backups_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"GET"})}async get(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"POST",body:r})}async restore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/restore`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"DELETE"})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/retry`,{api:"archon",version:1,method:"POST"})}async rename(e,t,r,i){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"PATCH",body:i})}};var C=class extends a{getModuleID(){return"archon_backups_queue_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"POST",body:r})}async ackCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async ackRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}`,{api:"archon",version:1,method:"DELETE"})}async deleteMany(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/delete-many`,{api:"archon",version:1,method:"POST",body:{backup_ids:r}})}async restore(e,t,r,i){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/restore`,{api:"archon",version:1,method:"POST",body:i})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/retry`,{api:"archon",version:1,method:"POST"})}};var q=class extends a{getModuleID(){return"archon_content_v1"}async getAddons(e,t,r){let i=new URLSearchParams;r?.from_modpack!==void 0&&i.set("from_modpack",String(r.from_modpack)),r?.disabled!==void 0&&i.set("disabled",String(r.disabled)),r?.addons!==void 0&&i.set("addons",String(r.addons)),r?.updates!==void 0&&i.set("updates",String(r.updates));let o=i.toString();return this.client.request(`/servers/${e}/worlds/${t}/addons${o?`?${o}`:""}`,{api:"archon",version:1,method:"GET"})}async addAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons`,{api:"archon",version:1,method:"POST",body:r})}async addAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/install-many`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete`,{api:"archon",version:1,method:"POST",body:r})}async disableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable`,{api:"archon",version:1,method:"POST",body:r})}async enableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async disableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async enableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async installContent(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content`,{api:"archon",version:1,method:"POST",body:r})}async repair(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/repair`,{api:"archon",version:1,method:"POST"})}async unlinkModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/unlink-modpack`,{api:"archon",version:1,method:"POST"})}async getAddonUpdate(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/addons/update?filename=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET"})}async updateAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update`,{api:"archon",version:1,method:"POST",body:r})}async updateAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update-many`,{api:"archon",version:1,method:"POST",body:{addons:r}})}async getModpackUpdate(e,t){return this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"GET"})}async updateModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"POST"})}async getUpdateGameVersionPreview(e,t,r,i){return this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET",timeout:1e3*1e3,signal:i})}async applyGameVersionUpdate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"POST"})}};var L=class extends a{getModuleID(){return"archon_options_v1"}async getStartup(e,t){return this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"GET"})}async patchStartup(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"PATCH",body:r})}};var w=class extends a{getModuleID(){return"archon_properties_v1"}async getProperties(e,t){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"GET"})}async patchProperties(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"PATCH",body:r})}};var k=class extends a{getModuleID(){return"archon_servers_v0"}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async list(e){let t=new URLSearchParams;e?.limit&&t.set("limit",e.limit.toString()),e?.offset&&t.set("offset",e.offset.toString());let r=t.toString()?`?${t.toString()}`:"";return this.client.request(`servers${r}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async checkStock(e,t){return this.client.request(`/stock?region=${e}`,{api:"archon",version:"modrinth/v0",method:"POST",body:t,skipAuth:!0})}async checkStockGlobal(e){return this.client.request("/stock",{api:"archon",version:"modrinth/v0",method:"POST",body:e,skipAuth:!0})}async getFilesystemAuth(e){return this.client.request(`/servers/${e}/fs`,{api:"archon",version:"modrinth/v0",method:"GET"})}async getWebSocketAuth(e){return this.client.request(`/servers/${e}/ws`,{api:"archon",version:"modrinth/v0",method:"GET"})}async power(e,t){await this.client.request(`/servers/${e}/power`,{api:"archon",method:"POST",version:"modrinth/v0",body:{action:t}})}async reinstall(e,t,r=!1){await this.client.request(`/servers/${e}/reinstall`,{api:"archon",method:"POST",version:"modrinth/v0",params:{hard:String(r)},body:t})}async getReinstallMrpackAuth(e){return this.client.request(`/servers/${e}/reinstallFromMrpack`,{api:"archon",version:"modrinth/v0",method:"GET"})}async reinstallFromMrpack(e,t,r=!1,i){let o=await this.getReinstallMrpackAuth(e),n=new FormData;return n.append("file",t),this.client.upload("",{api:`https://${o.url}`,version:"reinstallMrpackMultiparted",formData:n,params:{hard:String(r)},headers:{Authorization:`Bearer ${o.token}`},skipAuth:!0,onProgress:i?.onProgress,retry:!1})}async updateName(e,t){await this.client.request(`/servers/${e}/name`,{api:"archon",method:"POST",version:"modrinth/v0",body:{name:t}})}async getAllocations(e){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"GET",version:"modrinth/v0"})}async reserveAllocation(e,t){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"POST",version:"modrinth/v0",params:{name:t}})}async updateAllocation(e,t,r){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"PUT",version:"modrinth/v0",params:{name:r}})}async deleteAllocation(e,t){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"DELETE",version:"modrinth/v0"})}async checkSubdomainAvailability(e){return this.client.request(`/subdomains/${e}/isavailable`,{api:"archon",method:"GET",version:"modrinth/v0"})}async changeSubdomain(e,t){await this.client.request(`/servers/${e}/subdomain`,{api:"archon",method:"POST",version:"modrinth/v0",body:{subdomain:t}})}async getStartupConfig(e){return this.client.request(`/servers/${e}/startup`,{api:"archon",method:"GET",version:"modrinth/v0"})}async updateStartupConfig(e,t){await this.client.request(`/servers/${e}/startup`,{api:"archon",method:"POST",version:"modrinth/v0",body:t})}async dismissNotice(e,t){await this.client.request(`/servers/${e}/notices/${t}/dismiss`,{api:"archon",method:"POST",version:"modrinth/v0"})}};var $=class extends a{getModuleID(){return"archon_servers_v1"}async list(){return this.client.request("/servers",{api:"archon",version:1,method:"GET"})}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",version:1,method:"GET"})}async getRegions(){return this.client.request("/regions",{api:"archon",version:1,method:"GET",skipAuth:!0})}async endIntro(e){await this.client.request(`/servers/${e}/flows/intro`,{api:"archon",version:1,method:"DELETE"})}async resetToOnboarding(e,t){await this.client.request(`/servers/${e}/worlds/${t}/onboard`,{api:"archon",version:1,method:"POST"})}};import{$fetch as we}from"ofetch";var ke="https://raw.githubusercontent.com/ipregistry/iso3166/master";function $e(s){let e=s.trim().split(`
2
- `).filter(i=>i.trim()!=="");if(e.length===0)return[];let t=e[0],r=(t.startsWith("#")?t.slice(1):t).split(",");return e.slice(1).map(i=>{let o=i.split(","),n={};return r.forEach((c,l)=>{n[c]=o[l]||""}),n})}var x=class extends a{getModuleID(){return"iso3166_data"}async build(){try{let[e,t]=await Promise.all([we(`${ke}/countries.csv`,{responseType:"text"}),we(`${ke}/subdivisions.csv`,{responseType:"text"})]),r=$e(e),i=$e(t),o=r.map(c=>({alpha2:c.country_code_alpha2,alpha3:c.country_code_alpha3,numeric:c.numeric_code,nameShort:c.name_short,nameLong:c.name_long})),n=i.reduce((c,l)=>{let u=l.country_code_alpha2;return!u||typeof u!="string"||u.trim()===""||(c[u]||(c[u]=[]),c[u].push({code:l["subdivision_code_iso3166-2"],name:l.subdivision_name,localVariant:l.localVariant||null,category:l.category,parent:l.parent_subdivision||null,language:l.language_code})),c},{});return{countries:o,subdivisions:n}}catch(e){return console.error("Error fetching ISO3166 data:",e),{countries:[],subdivisions:{}}}}};var _=class extends a{getModuleID(){return"kyros_content_v1"}uploadAddonFile(e,t,r){let i=new FormData;for(let o of t)i.append("file",o,o instanceof File?o.name:"file");return this.client.upload(`/worlds/${e}/content/upload-addon-file`,{api:"",version:"v1",formData:i,onProgress:r?.onProgress,useNodeAuth:!0})}uploadModpackFile(e,t,r,i){let o=new FormData;return o.append("file",t,t instanceof File?t.name:"file"),o.append("properties",JSON.stringify(r)),this.client.upload(`/worlds/${e}/content/upload-modpack-file`,{api:"",version:"v1",formData:o,params:i?.softOverride!==void 0?{soft_override:String(i.softOverride)}:void 0,onProgress:i?.onProgress,useNodeAuth:!0})}};var M=class extends a{getModuleID(){return"kyros_files_v0"}getNodeBaseUrl(e){return`https://${e.url.replace(/\/modrinth\/v\d+\/fs\/?$/,"")}`}async listDirectory(e,t=1,r=100){return this.client.request("/fs/list",{api:"",version:"modrinth/v0",method:"GET",params:{path:e,page:t,page_size:r},useNodeAuth:!0})}async createFileOrFolder(e,t){return this.client.request("/fs/create",{api:"",version:"modrinth/v0",method:"POST",params:{path:e,type:t},headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async downloadFile(e){return this.client.request("/fs/download",{api:"",version:"modrinth/v0",method:"GET",params:{path:e},useNodeAuth:!0})}async downloadFileWithAuth(e,t){return this.client.request("/fs/download",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"GET",params:{path:t},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}uploadFile(e,t,r){return this.client.upload("/fs/create",{api:"",version:"modrinth/v0",file:t,params:{path:e,type:"file"},onProgress:r?.onProgress,retry:r?.retry,useNodeAuth:!0})}uploadFileWithAuth(e,t,r,i){return this.client.upload("/fs/create",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",file:r,params:{path:t,type:"file"},headers:{Authorization:`Bearer ${e.token}`},onProgress:i?.onProgress,retry:i?.retry,skipAuth:!0})}async updateFile(e,t){let r=typeof t=="string"?new Blob([t]):t;return this.client.request("/fs/update",{api:"",version:"modrinth/v0",method:"PUT",params:{path:e},body:r,headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async moveFileOrFolder(e,t){return this.client.request("/fs/move",{api:"",version:"modrinth/v0",method:"POST",body:{source:e,destination:t},useNodeAuth:!0})}async renameFileOrFolder(e,t){let r=e.split("/").slice(0,-1).join("/")+"/"+t;return this.moveFileOrFolder(e,r)}async deleteFileOrFolder(e,t){return this.client.request("/fs/delete",{api:"",version:"modrinth/v0",method:"DELETE",params:{path:e,recursive:t},useNodeAuth:!0})}async deleteFileOrFolderWithAuth(e,t,r){return this.client.request("/fs/delete",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"DELETE",params:{path:t,recursive:r},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}async extractFile(e,t=!0,r=!1){return this.client.request("/fs/unarchive",{api:"",version:"v1",method:"POST",params:{src:e,trg:"/",override:t,dry:r},useNodeAuth:!0})}async modifyOperation(e,t){return this.client.request(`/fs/ops/${t}`,{api:"",version:"v1",method:"POST",params:{id:e},useNodeAuth:!0})}};var O=class extends a{getModuleID(){return"kyros_logs_v1"}async clear(){return this.client.request("/logs/clear",{api:"",version:"v1",method:"POST",useNodeAuth:!0})}};var I=class extends a{getModuleID(){return"kyros_upload_sessions_v1"}async create(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async get(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"GET",useNodeAuth:!0})}uploadFiles(e,t,r,i,o){let n=new FormData;for(let{file:c,filename:l}of i)n.append("file",c,l);return this.client.upload(`/worlds/${t}/files/upload-session/${r}/files`,{api:"",version:"v1",formData:n,onProgress:o?.onProgress,retry:o?.retry,useNodeAuth:!0})}async finalize(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}/finalize`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async cancel(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}`,{api:"",version:"v1",method:"DELETE",useNodeAuth:!0})}};var U=class extends a{getModuleID(){return"labrinth_auth_internal"}async getNewsletterStatus(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"GET"})}async subscribeNewsletter(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"POST"})}};var j=class extends a{getModuleID(){return"labrinth_auth_v2"}async login(e){return this.client.request("/auth/login",{api:"labrinth",version:2,method:"POST",body:e})}async login2FA(e){return this.client.request("/auth/login/2fa",{api:"labrinth",version:2,method:"POST",body:e})}async createAccount(e){return this.client.request("/auth/create",{api:"labrinth",version:2,method:"POST",body:e})}async resetPasswordBegin(e){return this.client.request("/auth/password/reset",{api:"labrinth",version:2,method:"POST",body:e})}async changePassword(e){return this.client.request("/auth/password",{api:"labrinth",version:2,method:"PATCH",body:e})}};var D=class extends a{getModuleID(){return"labrinth_billing_internal"}async getSubscriptions(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/subscriptions${t}`,{api:"labrinth",version:"internal",method:"GET"})}async getProducts(){return this.client.request("/billing/products",{api:"labrinth",version:"internal",method:"GET"})}async getCustomer(){return this.client.request("/billing/customer",{api:"labrinth",version:"internal",method:"GET"})}async editSubscription(e,t,r){let i=r?"?dry=true":"";return this.client.request(`/billing/subscription/${e}${i}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async getPaymentMethods(){return this.client.request("/billing/payment_methods",{api:"labrinth",version:"internal",method:"GET"})}async addPaymentMethodFlow(){return this.client.request("/billing/payment_method",{api:"labrinth",version:"internal",method:"POST"})}async editPaymentMethod(e,t){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async removePaymentMethod(e){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async getPayments(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/payments${t}`,{api:"labrinth",version:"internal",method:"GET"})}async initiatePayment(e){return this.client.request("/billing/payment",{api:"labrinth",version:"internal",method:"POST",body:e})}async refundCharge(e,t){return this.client.request(`/billing/charge/${e}/refund`,{api:"labrinth",version:"internal",method:"POST",body:t})}async credit(e){return this.client.request("/billing/credit",{api:"labrinth",version:"internal",method:"POST",body:e})}};var N=class extends a{getModuleID(){return"labrinth_collections"}async get(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/collections",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async editIcon(e,t,r){return this.client.request(`/collection/${e}/icon?ext=${r}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteIcon(e){return this.client.request(`/collection/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var G=class extends a{getModuleID(){return"labrinth_external_projects_internal"}async search(e){return this.client.request("/moderation/external-license/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getBySha1(e){return this.client.request(`/moderation/external-license/by-sha1/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async update(e,t){return this.client.request(`/moderation/external-license/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var B=class extends a{getModuleID(){return"labrinth_globals_internal"}async get(){return this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};var F=class extends a{getModuleID(){return"labrinth_limits_v3"}async getProjectLimits(){return this.client.request("/limits/projects",{api:"labrinth",version:3,method:"GET"})}async getOrganizationLimits(){return this.client.request("/limits/organizations",{api:"labrinth",version:3,method:"GET"})}async getCollectionLimits(){return this.client.request("/limits/collections",{api:"labrinth",version:3,method:"GET"})}};var V=class extends a{getModuleID(){return"labrinth_moderation_internal"}async acquireLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"POST"})}async overrideLock(e){return this.client.request(`/moderation/lock/${e}/override`,{api:"labrinth",version:"internal",method:"POST"})}async releaseLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async checkLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var W=class extends a{getModuleID(){return"labrinth_notifications_v2"}async getUserNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/notifications?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async markAsRead(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"PATCH"})}async markMultipleAsRead(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify([...new Set(e)])}})}async delete(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async deleteMultiple(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"DELETE",params:{ids:JSON.stringify([...new Set(e)])}})}};var H=class extends a{getModuleID(){return"labrinth_oauth_internal"}async getUserApps(e){return this.client.request(`/user/${e}/oauth_apps`,{api:"labrinth",version:3,method:"GET"})}async getApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getApps(e){return this.client.request(`/oauth/apps?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:"internal",method:"GET"})}async createApp(e){return this.client.request("/oauth/app",{api:"labrinth",version:"internal",method:"POST",body:e})}async editApp(e,t){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async deleteApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}uploadAppIcon(e,t,r){return this.client.upload(`/oauth/app/${e}/icon`,{api:"labrinth",version:"internal",file:t,params:{ext:r}})}async getAuthorizations(){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"GET"})}async revokeAuthorization(e){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"DELETE",params:{client_id:e}})}async authorize(e){return this.client.request("/oauth/authorize",{api:"labrinth",version:"internal",method:"GET",params:e})}async accept(e){return this.client.request("/oauth/accept",{api:"labrinth",version:"internal",method:"POST",body:e})}async reject(e){return this.client.request("/oauth/reject",{api:"labrinth",version:"internal",method:"POST",body:e})}};var z=class extends a{getModuleID(){return"labrinth_organizations_v3"}async get(e){return this.client.request(`/organization/${e}`,{api:"labrinth",version:3,method:"GET"})}async getProjects(e){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/organizations?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async addProject(e,t){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"POST",body:t})}async removeProject(e,t,r){return this.client.request(`/organization/${e}/projects/${t}`,{api:"labrinth",version:3,method:"DELETE",body:r})}};var K=class extends a{getModuleID(){return"labrinth_pats_v2"}async list(){return this.client.request("/pat",{api:"labrinth",version:2,method:"GET"})}async create(e){return this.client.request("/pat",{api:"labrinth",version:2,method:"POST",body:e})}async modify(e,t){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var J=class extends a{getModuleID(){return"labrinth_payout_v3"}async getBalance(){let e=await this.client.request("/payout/balance",{api:"labrinth",version:3,method:"GET"});return{...e,available:Number(e.available),withdrawn_lifetime:Number(e.withdrawn_lifetime),withdrawn_ytd:Number(e.withdrawn_ytd),pending:Number(e.pending),dates:Object.fromEntries(Object.entries(e.dates).map(([t,r])=>[t,Number(r)]))}}async getHistory(){return(await this.client.request("/payout/history",{api:"labrinth",version:3,method:"GET"})).map(t=>t.type==="withdrawal"?{...t,amount:Number(t.amount),fee:t.fee===null?null:Number(t.fee)}:{...t,amount:Number(t.amount)})}async getMethods(e){return this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET",params:e?{country:e}:void 0})}async cancel(e){return this.client.request(`/payout/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var X=class extends a{getModuleID(){return"labrinth_payouts_v3"}async getPlatformRevenue(e){return this.client.request("/payout/platform_revenue",{api:"labrinth",version:3,method:"GET",params:e})}};var Q=class extends a{getModuleID(){return"labrinth_projects_v2"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"GET"})}async check(e){let t=encodeURIComponent(e);return this.client.request(`/project/${t}/check`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async search(e){return this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{...e,facets:e.facets?JSON.stringify(e.facets):void 0,new_filters:e.new_filters??void 0}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:2,method:"GET"})}async createGalleryImage(e,t,r){let i={ext:r.ext,featured:String(r.featured)};return r.title&&(i.title=r.title),r.description&&(i.description=r.description),r.ordering!==void 0&&(i.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"POST",params:i,body:t})}async editGalleryImage(e,t,r){let i={url:t,featured:String(r.featured)};return r.title&&(i.title=r.title),r.description&&(i.description=r.description),r.ordering!==void 0&&(i.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"PATCH",params:i})}async deleteGalleryImage(e,t){return this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"DELETE",params:{url:t}})}async getRandom(e){return this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:String(e)}})}async bulkEdit(e,t){return this.client.request("/projects",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify(e)},body:t})}};function fe(s){if(typeof s!="object"||s===null)return!1;let e=s;return typeof e.error=="string"&&typeof e.description=="string"}var h=class s extends Error{constructor(e,t){super(e),this.name="ModrinthApiError",this.statusCode=t?.statusCode,this.originalError=t?.originalError,this.responseData=t?.responseData,this.context=t?.context,Error.captureStackTrace&&Error.captureStackTrace(this,s)}static fromUnknown(e,t){return e instanceof s?e:e instanceof Error?new s(e.message,{originalError:e,context:t}):new s(String(e),{context:t})}},P=class s extends h{constructor(e,t){let r=e;t?.v1Error&&(r=`[${t.v1Error.error}] ${t.v1Error.description}`,t.v1Error.context&&(r=`${t.v1Error.context}: ${r}`)),super(r,t),this.name="ModrinthServerError",this.v1Error=t?.v1Error,Error.captureStackTrace&&Error.captureStackTrace(this,s)}static fromResponse(e,t,r){let i=fe(t)?t:void 0,o=`HTTP ${e}`;return i?o=i.description:typeof t=="string"&&(o=t),new s(o,{statusCode:e,responseData:t,context:r,v1Error:i})}static fromUnknown(e,t){return e instanceof s?e:e instanceof h?new s(e.message,{statusCode:e.statusCode,originalError:e.originalError,responseData:e.responseData,context:t??e.context}):e instanceof Error?new s(e.message,{originalError:e,context:t}):new s(String(e),{context:t})}};var Y=class extends a{getModuleID(){return"labrinth_projects_v3"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"GET"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async getOrganization(e){try{return await this.client.request(`/project/${e}/organization`,{api:"labrinth",version:3,method:"GET"})}catch(t){if(t instanceof h&&t.statusCode===404)return null;throw t}}async getMembers(e){return this.client.request(`/project/${e}/members`,{api:"labrinth",version:3,method:"GET"})}async createServerProject(e){return this.client.request("/project",{api:"labrinth",version:3,method:"PUT",body:e})}async deleteProject(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async changeIcon(e,t,r){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"PATCH",params:{ext:r},body:t})}async deleteIcon(e){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var Z=class extends a{getModuleID(){return"labrinth_reports_v3"}async get(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"GET"})}async list(e){let t={};return e?.count!=null&&(t.count=String(e.count)),e?.offset!=null&&(t.offset=String(e.offset)),e?.all!=null&&(t.all=String(e.all)),this.client.request("/report",{api:"labrinth",version:3,method:"GET",params:Object.keys(t).length>0?t:void 0})}async getMultiple(e){return this.client.request(`/reports?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async create(e){return this.client.request("/report",{api:"labrinth",version:3,method:"POST",body:e})}async edit(e,t){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var ee=class extends a{getModuleID(){return"labrinth_server_ping_internal"}async pingMinecraftJava(e){return this.client.request("/server-ping/minecraft-java",{api:"labrinth",version:"internal",method:"POST",body:e})}};var te=class extends a{getModuleID(){return"labrinth_sessions_v2"}async list(){return this.client.request("/session/list",{api:"labrinth",version:2,method:"GET"})}async delete(e){return this.client.request(`/session/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var re=class extends a{getModuleID(){return"labrinth_state"}async build(){let e=[],t=(d,Ne,Ge)=>(console.error("Error fetching state data:",d),e.push({endpoint:Ge,error:d}),Ne),[r,i,o,n,c,l,u,p,m,b,y,Ue,je]=await Promise.all([this.client.request("/tag/category",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/category")),this.client.request("/tag/loader",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/loader")),this.client.request("/tag/game_version",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/game_version")),this.client.request("/tag/donation_platform",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/donation_platform")),this.client.request("/tag/report_type",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/report_type")),this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:"60"}}).catch(d=>t(d,[],"/v2/projects_random")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"leave",index:"relevance"}}).catch(d=>t(d,{},"/v2/search")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"",index:"updated"}}).catch(d=>t(d,{},"/v2/search")),this.client.labrinth.billing_internal.getProducts().catch(d=>t(d,[],"/_internal/billing/products")),this.client.request("/mural/bank-details",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/mural/bank-details")),this.client.iso3166.data.build().catch(d=>t(d,{countries:[],subdivisions:{}},"iso3166/data")),this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET"}).catch(d=>t(d,[],"/v3/payout/methods")),this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/globals"))]),De=Object.fromEntries(Ue.filter(d=>d.type==="tremendous").map(d=>[d.id,{name:d.name,image_url:d.image_logo_url}]));return{categories:r,loaders:i,gameVersions:o,donationPlatforms:n,reportTypes:c,homePageProjects:l,homePageSearch:u,homePageNotifs:p,products:m,muralBankDetails:b?.bankDetails,tremendousIdMap:De,countries:y.countries,subdivisions:y.subdivisions,taxComplianceThresholds:je?.tax_compliance_thresholds,errors:e}}};var ie=class extends a{getModuleID(){return"labrinth_tech_review_internal"}async searchProjects(e){return this.client.request("/moderation/tech-review/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getReport(e){return this.client.request(`/moderation/tech-review/report/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getIssue(e){return this.client.request(`/moderation/tech-review/issue/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async updateIssueDetail(e,t){return this.client.request(`/moderation/tech-review/issue-detail/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async submitProject(e,t){return this.client.request(`/moderation/tech-review/submit/${e}`,{api:"labrinth",version:"internal",method:"POST",body:t})}async getProjectReport(e){return this.client.request(`/moderation/tech-review/project/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var ne=class extends a{getModuleID(){return"labrinth_threads_v3"}async getThread(e){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/threads?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async sendMessage(e,t){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"POST",body:t})}async deleteMessage(e){return this.client.request(`/message/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var se=class extends a{getModuleID(){return"labrinth_users_v2"}async get(e){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/users?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async getProjects(e){return this.client.request(`/user/${e}/projects`,{api:"labrinth",version:2,method:"GET"})}async getOrganizations(e){return this.client.request(`/user/${e}/organizations`,{api:"labrinth",version:3,method:"GET"})}async getCollections(e){return this.client.request(`/user/${e}/collections`,{api:"labrinth",version:3,method:"GET"})}async getNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getFollowedProjects(e){return this.client.request(`/user/${e}/follows`,{api:"labrinth",version:2,method:"GET"})}async patch(e,t){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var oe=class extends a{getModuleID(){return"labrinth_versions_v2"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:2,method:"GET"})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var ae=class extends a{getModuleID(){return"labrinth_versions_v3"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:t?.apiVersion??2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:3,method:"GET"})}createVersion(e,t,r=null){let i=new FormData,o=t.map(p=>p.file),n=t.map(p=>p.fileType||null),c=o.map((p,m)=>`${p.name}-${m===0?"primary":m}`),l=c.reduce((p,m,b)=>(p[m]=n[b],p),{}),u={project_id:e.project_id,version_number:e.version_number,name:e.name||e.version_number,changelog:e.changelog,dependencies:e.dependencies||[],game_versions:e.game_versions,version_type:e.version_type,featured:!!e.featured,file_parts:c,file_types:l,primary_file:c[0],environment:e.environment,loaders:e.loaders};return r==="modpack"&&(u.mrpack_loaders=e.loaders,u.loaders=["mrpack"]),i.append("data",JSON.stringify(u)),o.forEach((p,m)=>{i.append(c[m],p,p.name)}),this.client.upload("/version",{api:"labrinth",version:3,formData:i,timeout:300*1e3})}async modifyVersion(e,t){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}addFilesToVersion(e,t){let r=new FormData,i=t.map(l=>l.file),o=t.map(l=>l.fileType||null),n=i.map((l,u)=>`${l.name}-${u}`),c=n.reduce((l,u,p)=>(l[u]=o[p],l),{});return r.append("data",JSON.stringify({file_types:c})),i.forEach((l,u)=>{r.append(n[u],l,l.name)}),this.client.upload(`/version/${e}/file`,{api:"labrinth",version:2,formData:r,timeout:300*1e3})}};var ce=class extends a{getModuleID(){return"labrinth_affiliate_internal"}async getAll(){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"GET"})}async create(e){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"PUT",body:e})}async get(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async delete(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async patch(e,t){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var le=class extends a{getModuleID(){return"labrinth_tags_v2"}async getLicenseText(e){return this.client.request(`/tag/license/${e}`,{api:"labrinth",version:2,method:"GET"})}};var ue=class extends a{getModuleID(){return"labrinth_teams_v2"}async addMember(e,t){return this.client.request(`/team/${e}/members`,{api:"labrinth",version:2,method:"POST",body:t})}async editMember(e,t,r){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"PATCH",body:r})}async removeMember(e,t){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"DELETE"})}async transferOwnership(e,t){return this.client.request(`/team/${e}/owner`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var pe=class extends a{getModuleID(){return"labrinth_teams_v3"}async getMultiple(e){return this.client.request(`/teams?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}};var Be="https://launcher-meta.modrinth.com",de=class extends a{getModuleID(){return"launchermeta_manifest_v0"}async getManifest(e){return this.client.request("/manifest.json",{api:Be,version:`${e}/v0`,method:"GET",skipAuth:!0,headers:{"Content-Type":""}})}};var he=class extends a{getModuleID(){return"mclogs_insights_v1"}async analyse(e){return this.client.request("/analyse",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var me=class extends a{getModuleID(){return"mclogs_logs_v1"}async create(e){return this.client.request("/log",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var xe="https://fill.papermc.io",be=class extends a{getModuleID(){return"paper_versions_v3"}async getProject(){return this.client.request("/projects/paper",{api:xe,version:"v3",method:"GET",skipAuth:!0})}async getBuilds(e){return{builds:await this.client.request(`/projects/paper/versions/${e}/builds`,{api:xe,version:"v3",method:"GET",skipAuth:!0})}}};var _e="https://api.purpurmc.org",ge=class extends a{getModuleID(){return"purpur_versions_v2"}async getProject(){return this.client.request("/purpur",{api:_e,version:"v2",method:"GET",skipAuth:!0})}async getBuilds(e){return this.client.request(`/purpur/${e}`,{api:_e,version:"v2",method:"GET",skipAuth:!0})}};var Fe={archon_backups_queue_v1:C,archon_backups_v1:R,archon_content_v1:q,archon_options_v1:L,archon_properties_v1:w,archon_servers_v0:k,archon_servers_v1:$,iso3166_data:x,mclogs_insights_v1:he,mclogs_logs_v1:me,launchermeta_manifest_v0:de,kyros_content_v1:_,kyros_files_v0:M,kyros_logs_v1:O,kyros_upload_sessions_v1:I,labrinth_affiliate_internal:ce,labrinth_auth_internal:U,labrinth_auth_v2:j,labrinth_billing_internal:D,labrinth_collections:N,labrinth_external_projects_internal:G,labrinth_globals_internal:B,labrinth_moderation_internal:V,labrinth_notifications_v2:W,labrinth_oauth_internal:H,labrinth_organizations_v3:z,labrinth_pats_v2:K,labrinth_limits_v3:F,labrinth_payout_v3:J,labrinth_payouts_v3:X,labrinth_projects_v2:Q,labrinth_projects_v3:Y,labrinth_reports_v3:Z,labrinth_server_ping_internal:ee,labrinth_sessions_v2:te,labrinth_state:re,labrinth_tags_v2:le,labrinth_teams_v2:ue,labrinth_teams_v3:pe,labrinth_tech_review_internal:ie,labrinth_threads_v3:ne,labrinth_users_v2:se,labrinth_versions_v2:oe,labrinth_versions_v3:ae,paper_versions_v3:be,purpur_versions_v2:ge};function Ve(s){let e=s.split("_");if(e.length<2)throw new Error(`Invalid module ID "${s}". Expected format: <api>_<module> (e.g., "labrinth_projects_v2")`);let t=e[0],r=e.slice(1).join("_");return[t,r]}function Me(){let s={};for(let[e,t]of Object.entries(Fe)){let[r,i]=Ve(e);s[r]||(s[r]={}),s[r][i]=t}return s}var A=class{};var T=class extends A{constructor(t){super();this._moduleInstances=new Map;this._moduleNamespaces=new Map;this.config={timeout:1e4,labrinthBaseUrl:"https://api.modrinth.com",archonBaseUrl:"https://archon.modrinth.com",...t},this.features=t.features??[],this.initializeModules()}initializeModules(){let t=Me();for(let[r,i]of Object.entries(t)){let o={};for(let[n,c]of Object.entries(i)){let l=`${r}_${n}`;Object.defineProperty(o,n,{get:()=>{if(!this._moduleInstances.has(l)){let u=new c(this),p=u.getModuleID();if(p!==l)throw new Error(`Module ID mismatch: registry expects "${l}" but module declares "${p}"`);this._moduleInstances.set(l,u)}return this._moduleInstances.get(l)},enumerable:!0,configurable:!1})}Object.defineProperty(this,r,{value:o,writable:!1,enumerable:!0,configurable:!1}),this._moduleNamespaces.set(r,o)}}async request(t,r){let i;r.api==="labrinth"?i=this.config.labrinthBaseUrl:r.api==="archon"?i=this.config.archonBaseUrl:i=r.api;let o=this.buildUrl(t,i,r.version),n=await this.buildDefaultHeaders(),c={method:"GET",timeout:this.config.timeout,...r,headers:{...n,...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=c.headers;l&&"Content-Type"in l&&l["Content-Type"]===""&&delete l["Content-Type"];let u=this.buildContext(o,t,c);try{let p=await this.executeFeatureChain(u);return await this.config.hooks?.onResponse?.(p,u),p}catch(p){let m=this.normalizeError(p,u);throw await this.config.hooks?.onError?.(m,u),m}}async executeFeatureChain(t){let r=this.features.filter(n=>n.shouldApply(t)),i=r.length,o=async()=>(i--,i>=0?r[i].execute(o,t):(await this.config.hooks?.onRequest?.(t),this.executeRequest(t.url,t.options)));return o()}async executeUploadFeatureChain(t,r,i){let o=this.features.filter(l=>l.shouldApply(t)),n=o.length,c=async()=>(n--,n>=0?o[n].execute(c,t):(await this.config.hooks?.onRequest?.(t),this.executeXHRUpload(t,r,i)));return c()}buildUrl(t,r,i){let o=r.replace(/\/$/,""),n="";i==="internal"?n="/_internal":typeof i=="number"?n=`/v${i}`:typeof i=="string"&&(n=`/${i}`);let c=t.startsWith("/")?t:`/${t}`;return`${o}${n}${c}`}buildContext(t,r,i){return{url:t,path:r,options:i,attempt:1,startTime:Date.now()}}buildUploadContext(t,r,i){let o,n;if("formData"in i&&i.formData)o={isUpload:!0,formData:i.formData,onProgress:i.onProgress},n=i.formData;else if("file"in i&&i.file)o={isUpload:!0,file:i.file,onProgress:i.onProgress},n=i.file;else throw new Error("Upload options must include either file or formData");return{url:t,path:r,options:{...i,method:"POST",body:n},attempt:1,startTime:Date.now(),metadata:o}}async buildDefaultHeaders(){let t={"Content-Type":"application/json",...this.config.headers},r=await this.resolveUserAgent();return r&&(t["User-Agent"]=r),t}async resolveUserAgent(){let t=this.config.userAgent;return typeof t=="function"?await t():t}attachArchonSentryCaptureHeader(t){t.api!=="archon"||!t.headers||!this.shouldCaptureArchonRequests()||(t.headers["modrinth-sentry-capture"]="1")}shouldCaptureArchonRequests(){let t=this.config.archonSentryCapture;return typeof t=="function"?t():t===!0}normalizeError(t,r){return t instanceof h?t:h.fromUnknown(t,r?.path)}createNormalizedError(t,r,i){return r&&i?P.fromResponse(r,i):new h(t.message,{statusCode:r,originalError:t,responseData:i})}addFeature(t){return this.features.push(t),this}removeFeature(t){let r=this.features.indexOf(t);return r!==-1&&this.features.splice(r,1),this}getFeatures(){return[...this.features]}};var g=class{constructor(e){this.config={enabled:!0,...e}}shouldApply(e){return this.config.enabled!==!1}get name(){return this.config.name??this.constructor.name}get enabled(){return this.config.enabled!==!1}};var E=class{constructor(e){this.client=e;this.connections=new Map;this.MAX_RECONNECT_ATTEMPTS=10;this.RECONNECT_BASE_DELAY=1e3;this.RECONNECT_MAX_DELAY=3e4}async safeConnect(e,t){let r=this.getStatus(e);if(r?.connected&&!t?.force||r&&!r.connected&&!t?.force)return;t?.force&&r&&this.disconnect(e);let i=await this.client.archon.servers_v0.getWebSocketAuth(e);await this.connect(e,i)}on(e,t,r){let i=`${e}:${t}`;return this.emitter.on(i,r),()=>{this.emitter.off(i,r)}}getStatus(e){let t=this.connections.get(e);return t?{connected:t.socket.readyState===WebSocket.OPEN,reconnecting:t.isReconnecting,reconnectAttempts:t.reconnectAttempts}:null}getReconnectDelay(e){return Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,e),this.RECONNECT_MAX_DELAY)+Math.random()*1e3}};var ye=class extends g{async execute(e,t){let r=await this.getToken();if(r){let i=this.config.headerName??"Authorization",o=this.config.tokenPrefix??"Bearer",n=o?`${o} ${r}`:r;t.options.headers={...t.options.headers,[i]:n}}return e()}shouldApply(e){if(e.options.skipAuth)return!1;let t=this.config.headerName??"Authorization";return e.options.headers?.[t]?!1:super.shouldApply(e)}async getToken(){let{token:e}=this.config;return typeof e=="function"?await e():e}};var ve=class{constructor(){this.state=new Map}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Pe=class extends g{constructor(e){super(e),this.config={enabled:!0,name:"circuit-breaker",maxFailures:3,resetTimeout:3e4,failureStatusCodes:[500,502,503,504],...e},this.storage=e?.storage??new ve}async execute(e,t){let r=this.getCircuitKey(t);if(this.isCircuitOpen(r))throw new h("Circuit breaker open - too many recent failures",{statusCode:503,context:t.path});try{let i=await e();return this.recordSuccess(r),i}catch(i){throw this.isFailureError(i)&&this.recordFailure(r),i}}shouldApply(e){return e.options.circuitBreaker===!1?!1:super.shouldApply(e)}getCircuitKey(e){if(this.config.getCircuitKey)return this.config.getCircuitKey(e.url,e.options.method??"GET");let t=e.options.method??"GET",r=e.path.split("?")[0];return`${t}_${r}`}isCircuitOpen(e){let t=this.storage.get(e);return t?Date.now()-t.lastFailure>this.config.resetTimeout?(this.storage.clear?.(e),!1):t.failures>=this.config.maxFailures:!1}recordSuccess(e){this.storage.clear?.(e)}recordFailure(e){let t=Date.now(),r=this.storage.get(e);r?this.storage.set(e,{failures:r.failures+1,lastFailure:t}):this.storage.set(e,{failures:1,lastFailure:t})}isFailureError(e){return e instanceof h&&e.statusCode?this.config.failureStatusCodes.includes(e.statusCode):!1}getCircuitState(e){return this.storage.get(e)}resetCircuit(e){this.storage.clear?.(e)}};var Ae=class extends g{constructor(){super(...arguments);this.refreshPromise=null}shouldApply(t){return t.options.useNodeAuth===!0&&this.config.enabled!==!1}async refreshAuthWithLock(){return this.refreshPromise?this.refreshPromise:(this.refreshPromise=this.config.refreshAuth().finally(()=>{this.refreshPromise=null}),this.refreshPromise)}async execute(t,r){let o=0,n=this.config.getAuth();if((!n||this.isTokenExpired(n.token))&&(await this.refreshAuthWithLock(),n=this.config.getAuth()),!n)throw new Error("Failed to obtain node authentication");for(this.applyAuth(r,n);;)try{return await t()}catch(c){if(c instanceof h&&c.statusCode===401){if(o++,o>=3)throw new Error("Node authentication failed after 3 retries. Please re-authenticate.");if(await this.refreshAuthWithLock(),n=this.config.getAuth(),!n)throw new Error("Failed to refresh node authentication");this.applyAuth(r,n);continue}throw c}}applyAuth(t,r){let i=`https://${r.url.replace(/\/modrinth\/v\d+\/fs\/?$/,"")}`;t.url=this.buildUrl(t.path,i,t.options.version),t.options.headers={...t.options.headers,Authorization:`Bearer ${r.token}`},t.options.skipAuth=!0}buildUrl(t,r,i){let o=r.replace(/\/$/,""),n="";i==="internal"?n="/_internal":typeof i=="number"?n=`/v${i}`:typeof i=="string"&&(n=`/${i}`);let c=t.startsWith("/")?t:`/${t}`;return`${o}${n}${c}`}isTokenExpired(t){try{let r=JSON.parse(atob(t.split(".")[1]));if(!r.exp)return!1;let i=r.exp*1e3;return Date.now()>=i-1e4}catch{return!1}}};var Oe=1,Te=class extends g{async execute(e,t){return t.options.headers={...t.options.headers,"X-Panel-Version":String(Oe)},e()}shouldApply(e){return e.options.api==="labrinth"||e.options.api==="archon"}};var Ee=class extends g{constructor(e){super(e),this.config={enabled:!0,name:"retry",maxAttempts:3,backoffStrategy:"exponential",initialDelay:1e3,maxDelay:15e3,retryableStatusCodes:[408,429,500,502,503,504],retryOnNetworkError:!0,...e}}async execute(e,t){let r=null,i=this.getMaxAttempts(t);for(let o=1;o<=i;o++){t.attempt=o;try{return await e()}catch(n){if(r=n,!this.shouldRetryError(n,o,i)||o>=i)throw n;let l=this.calculateDelay(o);console.warn(`[${this.name}] Retrying request to ${t.path} (attempt ${o+1}/${i}) after ${l}ms`),await this.sleep(l)}}throw r??new Error("Max retry attempts reached")}shouldApply(e){return e.options.retry===!1?!1:super.shouldApply(e)}shouldRetryError(e,t,r){return this.config.shouldRetry?this.config.shouldRetry(e,t):this.config.retryOnNetworkError&&this.isNetworkError(e)?!0:e instanceof h&&e.statusCode?this.config.retryableStatusCodes.includes(e.statusCode):!1}isNetworkError(e){let t=[/network/i,/timeout/i,/ECONNREFUSED/i,/ENOTFOUND/i,/ETIMEDOUT/i,/ECONNRESET/i],r=e instanceof Error?e.message:String(e);return t.some(i=>i.test(r))}getMaxAttempts(e){return typeof e.options.retry=="number"?e.options.retry:this.config.maxAttempts}calculateDelay(e){let{backoffStrategy:t,initialDelay:r,maxDelay:i}=this.config,o;switch(t){case"exponential":o=r*Math.pow(2,e-1);break;case"linear":o=r*e;break;case"constant":o=r;break;default:o=r}return o+=Math.random()*1e3,Math.min(o,i)}sleep(e){return new Promise(t=>setTimeout(t,e))}};var Se=class extends g{async execute(e,t){let r=t.options.method??"GET",i=t.options.api,o=t.options.version,n=`[${r}] [${i}_v${o}]`;console.debug(`${n} ${t.url} SENT`);try{let c=await e();try{let l=c?JSON.stringify(c).length:0;console.debug(`${n} ${t.url} RECEIVED ${l} bytes`)}catch{console.debug(`${n} ${t.url} RECEIVED`)}return c}catch(c){let l=We(c);throw console.debug(`${n} ${t.url} FAILED${l?` \u2014 ${l}`:""}`),c}}};function We(s){if(!s||typeof s!="object")return typeof s=="string"?s:"";let e=s,t=e.status??e.statusCode??e.response?.status,r=e.statusText??e.response?.statusText,i=e.responseData??e.data??e.response?._data,o=[];return t!==void 0&&o.push(r?`${t} ${r}`:String(t)),i!==void 0?o.push(`body: ${He(i)}`):e.message&&o.push(e.message),o.join(" ")}function He(s){if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}import{$fetch as Ke,FetchError as Je}from"ofetch";import ze from"mitt";var Ie=1e3,f=class extends E{constructor(){super(...arguments);this.emitter=ze()}async connect(t,r){return this.connections.has(t)&&this.closeConnection(t),new Promise((i,o)=>{try{let n=new WebSocket(`wss://${r.url}`),c={serverId:t,socket:n,reconnectAttempts:0,reconnectTimer:void 0,isReconnecting:!1};this.connections.set(t,c),n.onopen=()=>{n.send(JSON.stringify({event:"auth",jwt:r.token})),c.reconnectAttempts=0,c.isReconnecting=!1,i()},n.onmessage=l=>{try{let u=JSON.parse(l.data),p=`${t}:${u.event}`;this.emitter.emit(p,u),(u.event==="auth-expiring"||u.event==="auth-incorrect")&&this.handleAuthExpiring(t).catch(console.error)}catch(u){console.error("[WebSocket] Failed to parse message:",u)}},n.onclose=l=>{console.debug(`[WebSocket] Closed for server ${t}:`,{code:l.code,reason:l.reason,wasClean:l.wasClean}),l.code!==Ie&&this.scheduleReconnect(t,r)},n.onerror=l=>{let u=n.url,p=n.readyState;console.error(`[WebSocket] Error for server ${t}:`,{url:u,readyState:p,readyStateLabel:["CONNECTING","OPEN","CLOSING","CLOSED"][p],type:l.type}),o(new Error(`WebSocket connection failed for server ${t} (readyState: ${p})`))}}catch(n){o(n)}})}disconnect(t){this.closeConnection(t),this.emitter.all.forEach((r,i)=>{i.toString().startsWith(`${t}:`)&&this.emitter.all.delete(i)})}closeConnection(t){let r=this.connections.get(t);r&&(r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),(r.socket.readyState===WebSocket.OPEN||r.socket.readyState===WebSocket.CONNECTING)&&r.socket.close(Ie,"Client disconnecting"),this.connections.delete(t))}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}send(t,r){let i=this.connections.get(t);if(!i||i.socket.readyState!==WebSocket.OPEN){console.warn(`Cannot send message: WebSocket not connected for server ${t}`);return}i.socket.send(JSON.stringify(r))}scheduleReconnect(t,r){let i=this.connections.get(t);if(!i)return;if(i.reconnectAttempts>=this.MAX_RECONNECT_ATTEMPTS){this.disconnect(t);return}i.isReconnecting=!0,i.reconnectAttempts++;let o=this.getReconnectDelay(i.reconnectAttempts);i.reconnectTimer=setTimeout(()=>{this.connect(t,r).catch(n=>{console.error(`[WebSocket] Reconnection failed for server ${t}:`,n)})},o)}async handleAuthExpiring(t){try{let r=await this.client.archon.servers_v0.getWebSocketAuth(t),i=this.connections.get(t);i&&i.socket.readyState===WebSocket.OPEN&&i.socket.send(JSON.stringify({event:"auth",jwt:r.token}))}catch(r){console.error(`[WebSocket] Failed to refresh auth for server ${t}:`,r),this.disconnect(t)}}};var v=class extends T{upload(e,t){let r;t.api==="labrinth"?r=this.config.labrinthBaseUrl:t.api==="archon"?r=this.config.archonBaseUrl:r=t.api;let i=this.buildUrl(e,r,t.version),o=[];t.onProgress&&o.push(t.onProgress);let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let c,l={promise:(async()=>{let u="formData"in t&&t.formData instanceof FormData,p=await this.buildDefaultHeaders();u?delete p["Content-Type"]:p["Content-Type"]="application/octet-stream";let m={retry:!1,...t,headers:{...p,...t.headers}};this.attachArchonSentryCaptureHeader(m);let b=this.buildUploadContext(i,e,m);if(c=b,n.signal.aborted)throw new h("Upload cancelled");let y=await this.executeUploadFeatureChain(b,o,n);return await this.config.hooks?.onResponse?.(y,b),y})().catch(async u=>{let p=this.normalizeError(u,c);throw c&&await this.config.hooks?.onError?.(p,c),p}),onProgress:u=>(o.push(u),l),cancel:()=>n.abort()};return l}executeXHRUpload(e,t,r){return new Promise((i,o)=>{let n=new XMLHttpRequest,c=e.metadata;n.upload.addEventListener("progress",p=>{if(p.lengthComputable){let m={loaded:p.loaded,total:p.total,progress:p.loaded/p.total};t.forEach(b=>b(m))}}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{i(n.response?JSON.parse(n.response):void 0)}catch{i(void 0)}else o(this.createUploadError(n))}),n.addEventListener("error",()=>o(new h("Upload failed"))),n.addEventListener("abort",()=>o(new h("Upload cancelled")));let l=e.url;if(e.options.params){let p=new URLSearchParams(Object.entries(e.options.params).map(([m,b])=>[m,String(b)])).toString();l+=(l.includes("?")?"&":"?")+p}n.open("POST",l);for(let[p,m]of Object.entries(e.options.headers??{}))n.setRequestHeader(p,m);let u="formData"in c?c.formData:c.file;n.send(u),r.signal.addEventListener("abort",()=>n.abort())})}createUploadError(e){let t;try{t=e.response?JSON.parse(e.response):void 0}catch{t=e.responseText}return this.createNormalizedError(new Error(`Upload failed with status ${e.status}`),e.status,t)}};var Re=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{return await Ke(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal})}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Je?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}};import{FetchError as Xe}from"ofetch";var Ce=class{constructor(){let e=useState("circuit-breaker-state",()=>new Map);this.state=e.value}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},qe=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async resolveRateLimitKey(){if(this.rateLimitKeyResolved!==void 0)return this.rateLimitKeyResolved;let e=this.config.rateLimitKey;return typeof e=="string"?this.rateLimitKeyResolved=e:typeof e=="function"&&(this.rateLimitKeyPromise||(this.rateLimitKeyPromise=e()),this.rateLimitKeyResolved=await this.rateLimitKeyPromise),this.rateLimitKeyResolved}async request(e,t){return import.meta.server&&await this.resolveRateLimitKey(),super.request(e,t)}upload(e,t){if(import.meta.server)throw new h("upload() is not supported during SSR");return super.upload(e,t)}async executeRequest(e,t){try{return await $fetch(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal,cache:import.meta.server?void 0:"no-store"})}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Xe?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}async buildDefaultHeaders(){let e={...await super.buildDefaultHeaders()};return import.meta.server&&this.rateLimitKeyResolved&&(e["x-ratelimit-key"]=this.rateLimitKeyResolved),e}};var Le=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),i;if(t.body){let u=t.body;typeof u=="object"&&!(u instanceof FormData)&&!(u instanceof URLSearchParams)&&!(u instanceof Blob)&&!(u instanceof ArrayBuffer)&&!ArrayBuffer.isView(u)?i=JSON.stringify(u):i=u}let o=e;if(t.params){let u={};for(let[m,b]of Object.entries(t.params))b!=null&&(u[m]=String(b));let p=new URLSearchParams(u).toString();p&&(o=`${e}?${p}`)}let n=await r(o,{method:t.method??"GET",headers:t.headers,body:i});if(!n.ok){let u;try{u=await n.json()}catch{u=void 0}let p=new Error(`HTTP ${n.status}: ${n.statusText}`);throw p.statusCode=n.status,p.responseData=u,p}let c=n.headers.get("content-type")?.toLowerCase()??"";if(o.includes("/fs/download"))return await n.blob();if(c.startsWith("image/")||c.startsWith("audio/")||c.startsWith("video/")||c.includes("application/octet-stream"))return await n.blob();if(n.status===204||n.status===205)return;if(c.includes("application/json")||c.includes("+json"))return await n.json();let l=await n.text();if(!l)return;try{return JSON.parse(l)}catch{return l}}catch(r){throw this.normalizeError(r)}}normalizeError(e){if(e instanceof Error){let t=e,r=t.statusCode,i=t.responseData;return this.createNormalizedError(e,r,i)}return super.normalizeError(e)}};var S={getAuth:null,refreshAuth:null};function Qe(s,e){S.getAuth=s,S.refreshAuth=e}function Ye(){S.getAuth=null,S.refreshAuth=null}async function Ze(s,e){try{return await s()}catch(t){if(t instanceof h&&t.statusCode===401)return await e(),await s();throw t}}export{g as AbstractFeature,T as AbstractModrinthClient,A as AbstractUploadClient,E as AbstractWebSocketClient,ye as AuthFeature,Pe as CircuitBreakerFeature,Re as GenericModrinthClient,ve as InMemoryCircuitBreakerStorage,h as ModrinthApiError,P as ModrinthServerError,Ae as NodeAuthFeature,Ce as NuxtCircuitBreakerStorage,qe as NuxtModrinthClient,Oe as PANEL_VERSION,Te as PanelVersionFeature,Ee as RetryFeature,Le as TauriModrinthClient,Se as VerboseLoggingFeature,v as XHRUploadClient,Ye as clearNodeAuthState,fe as isModrinthErrorResponse,S as nodeAuthState,Qe as setNodeAuthState,Ze as withJWTRetry};
1
+ var o=class{constructor(e){this.client=e}};var R=class extends o{getModuleID(){return"archon_backups_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"GET"})}async get(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"POST",body:r})}async restore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/restore`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"DELETE"})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/retry`,{api:"archon",version:1,method:"POST"})}async rename(e,t,r,i){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"PATCH",body:i})}};var L=class extends o{getModuleID(){return"archon_backups_queue_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"POST",body:r})}async ackCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async ackRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}`,{api:"archon",version:1,method:"DELETE"})}async deleteMany(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/delete-many`,{api:"archon",version:1,method:"POST",body:{backup_ids:r}})}async restore(e,t,r,i){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/restore`,{api:"archon",version:1,method:"POST",body:i})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/retry`,{api:"archon",version:1,method:"POST"})}};var q=class extends o{getModuleID(){return"archon_content_v1"}async getAddons(e,t,r){let i=new URLSearchParams;r?.from_modpack!==void 0&&i.set("from_modpack",String(r.from_modpack)),r?.disabled!==void 0&&i.set("disabled",String(r.disabled)),r?.addons!==void 0&&i.set("addons",String(r.addons)),r?.updates!==void 0&&i.set("updates",String(r.updates));let a=i.toString();return this.client.request(`/servers/${e}/worlds/${t}/addons${a?`?${a}`:""}`,{api:"archon",version:1,method:"GET"})}async addAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons`,{api:"archon",version:1,method:"POST",body:r})}async addAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/install-many`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete`,{api:"archon",version:1,method:"POST",body:r})}async disableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable`,{api:"archon",version:1,method:"POST",body:r})}async enableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async disableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async enableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async installContent(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content`,{api:"archon",version:1,method:"POST",body:r})}async repair(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/repair`,{api:"archon",version:1,method:"POST"})}async unlinkModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/unlink-modpack`,{api:"archon",version:1,method:"POST"})}async getAddonUpdate(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/addons/update?filename=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET"})}async updateAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update`,{api:"archon",version:1,method:"POST",body:r})}async updateAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update-many`,{api:"archon",version:1,method:"POST",body:{addons:r}})}async getModpackUpdate(e,t){return this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"GET"})}async updateModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"POST"})}async getUpdateGameVersionPreview(e,t,r,i){return this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET",timeout:1e3*1e3,signal:i})}async applyGameVersionUpdate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"POST"})}};var C=class extends o{getModuleID(){return"archon_options_v1"}async getStartup(e,t){return this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"GET"})}async patchStartup(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"PATCH",body:r})}};var w=class extends o{getModuleID(){return"archon_properties_v1"}async getProperties(e,t){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"GET"})}async patchProperties(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"PATCH",body:r})}};var k=class extends o{getModuleID(){return"archon_servers_v0"}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async list(e){let t=new URLSearchParams;e?.limit&&t.set("limit",e.limit.toString()),e?.offset&&t.set("offset",e.offset.toString());let r=t.toString()?`?${t.toString()}`:"";return this.client.request(`servers${r}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async checkStock(e,t){return this.client.request(`/stock?region=${e}`,{api:"archon",version:"modrinth/v0",method:"POST",body:t,skipAuth:!0})}async checkStockGlobal(e){return this.client.request("/stock",{api:"archon",version:"modrinth/v0",method:"POST",body:e,skipAuth:!0})}async getFilesystemAuth(e){return this.client.request(`/servers/${e}/fs`,{api:"archon",version:"modrinth/v0",method:"GET"})}async getWebSocketAuth(e){return this.client.request(`/servers/${e}/ws`,{api:"archon",version:"modrinth/v0",method:"GET"})}async power(e,t){await this.client.request(`/servers/${e}/power`,{api:"archon",method:"POST",version:"modrinth/v0",body:{action:t}})}async reinstall(e,t,r=!1){await this.client.request(`/servers/${e}/reinstall`,{api:"archon",method:"POST",version:"modrinth/v0",params:{hard:String(r)},body:t})}async getReinstallMrpackAuth(e){return this.client.request(`/servers/${e}/reinstallFromMrpack`,{api:"archon",version:"modrinth/v0",method:"GET"})}async reinstallFromMrpack(e,t,r=!1,i){let a=await this.getReinstallMrpackAuth(e),n=new FormData;return n.append("file",t),this.client.upload("",{api:`https://${a.url}`,version:"reinstallMrpackMultiparted",formData:n,params:{hard:String(r)},headers:{Authorization:`Bearer ${a.token}`},skipAuth:!0,onProgress:i?.onProgress,retry:!1})}async updateName(e,t){await this.client.request(`/servers/${e}/name`,{api:"archon",method:"POST",version:"modrinth/v0",body:{name:t}})}async getAllocations(e){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"GET",version:"modrinth/v0"})}async reserveAllocation(e,t){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"POST",version:"modrinth/v0",params:{name:t}})}async updateAllocation(e,t,r){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"PUT",version:"modrinth/v0",params:{name:r}})}async deleteAllocation(e,t){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"DELETE",version:"modrinth/v0"})}async checkSubdomainAvailability(e){return this.client.request(`/subdomains/${e}/isavailable`,{api:"archon",method:"GET",version:"modrinth/v0"})}async changeSubdomain(e,t){await this.client.request(`/servers/${e}/subdomain`,{api:"archon",method:"POST",version:"modrinth/v0",body:{subdomain:t}})}async getStartupConfig(e){return this.client.request(`/servers/${e}/startup`,{api:"archon",method:"GET",version:"modrinth/v0"})}async updateStartupConfig(e,t){await this.client.request(`/servers/${e}/startup`,{api:"archon",method:"POST",version:"modrinth/v0",body:t})}async dismissNotice(e,t){await this.client.request(`/servers/${e}/notices/${t}/dismiss`,{api:"archon",method:"POST",version:"modrinth/v0"})}};var x=class extends o{getModuleID(){return"archon_servers_v1"}async list(){return this.client.request("/servers",{api:"archon",version:1,method:"GET"})}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",version:1,method:"GET"})}async getRegions(){return this.client.request("/regions",{api:"archon",version:1,method:"GET",skipAuth:!0})}async endIntro(e){await this.client.request(`/servers/${e}/flows/intro`,{api:"archon",version:1,method:"DELETE"})}async resetToOnboarding(e,t){await this.client.request(`/servers/${e}/worlds/${t}/onboard`,{api:"archon",version:1,method:"POST"})}};import{$fetch as xe}from"ofetch";var $e="https://raw.githubusercontent.com/ipregistry/iso3166/master";function _e(s){let e=s.trim().split(`
2
+ `).filter(i=>i.trim()!=="");if(e.length===0)return[];let t=e[0],r=(t.startsWith("#")?t.slice(1):t).split(",");return e.slice(1).map(i=>{let a=i.split(","),n={};return r.forEach((c,l)=>{n[c]=a[l]||""}),n})}var $=class extends o{getModuleID(){return"iso3166_data"}async build(){try{let[e,t]=await Promise.all([xe(`${$e}/countries.csv`,{responseType:"text"}),xe(`${$e}/subdivisions.csv`,{responseType:"text"})]),r=_e(e),i=_e(t),a=r.map(c=>({alpha2:c.country_code_alpha2,alpha3:c.country_code_alpha3,numeric:c.numeric_code,nameShort:c.name_short,nameLong:c.name_long})),n=i.reduce((c,l)=>{let u=l.country_code_alpha2;return!u||typeof u!="string"||u.trim()===""||(c[u]||(c[u]=[]),c[u].push({code:l["subdivision_code_iso3166-2"],name:l.subdivision_name,localVariant:l.localVariant||null,category:l.category,parent:l.parent_subdivision||null,language:l.language_code})),c},{});return{countries:a,subdivisions:n}}catch(e){return console.error("Error fetching ISO3166 data:",e),{countries:[],subdivisions:{}}}}};var _=class extends o{getModuleID(){return"kyros_content_v1"}uploadAddonFile(e,t,r){let i=new FormData;for(let a of t)i.append("file",a,a instanceof File?a.name:"file");return this.client.upload(`/worlds/${e}/content/upload-addon-file`,{api:"",version:"v1",formData:i,onProgress:r?.onProgress,useNodeAuth:!0})}uploadModpackFile(e,t,r,i){let a=new FormData;return a.append("file",t,t instanceof File?t.name:"file"),a.append("properties",JSON.stringify(r)),this.client.upload(`/worlds/${e}/content/upload-modpack-file`,{api:"",version:"v1",formData:a,params:i?.softOverride!==void 0?{soft_override:String(i.softOverride)}:void 0,onProgress:i?.onProgress,useNodeAuth:!0})}};var M=class extends o{getModuleID(){return"kyros_files_v0"}getNodeBaseUrl(e){return`https://${e.url.replace(/\/modrinth\/v\d+\/fs\/?$/,"")}`}async listDirectory(e,t=1,r=100){return this.client.request("/fs/list",{api:"",version:"modrinth/v0",method:"GET",params:{path:e,page:t,page_size:r},useNodeAuth:!0})}async createFileOrFolder(e,t){return this.client.request("/fs/create",{api:"",version:"modrinth/v0",method:"POST",params:{path:e,type:t},headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async downloadFile(e){return this.client.request("/fs/download",{api:"",version:"modrinth/v0",method:"GET",params:{path:e},useNodeAuth:!0})}async downloadFileWithAuth(e,t){return this.client.request("/fs/download",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"GET",params:{path:t},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}uploadFile(e,t,r){return this.client.upload("/fs/create",{api:"",version:"modrinth/v0",file:t,params:{path:e,type:"file"},onProgress:r?.onProgress,retry:r?.retry,useNodeAuth:!0})}uploadFileWithAuth(e,t,r,i){return this.client.upload("/fs/create",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",file:r,params:{path:t,type:"file"},headers:{Authorization:`Bearer ${e.token}`},onProgress:i?.onProgress,retry:i?.retry,skipAuth:!0})}async updateFile(e,t){let r=typeof t=="string"?new Blob([t]):t;return this.client.request("/fs/update",{api:"",version:"modrinth/v0",method:"PUT",params:{path:e},body:r,headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async moveFileOrFolder(e,t){return this.client.request("/fs/move",{api:"",version:"modrinth/v0",method:"POST",body:{source:e,destination:t},useNodeAuth:!0})}async renameFileOrFolder(e,t){let r=e.split("/").slice(0,-1).join("/")+"/"+t;return this.moveFileOrFolder(e,r)}async deleteFileOrFolder(e,t){return this.client.request("/fs/delete",{api:"",version:"modrinth/v0",method:"DELETE",params:{path:e,recursive:t},useNodeAuth:!0})}async deleteFileOrFolderWithAuth(e,t,r){return this.client.request("/fs/delete",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"DELETE",params:{path:t,recursive:r},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}async extractFile(e,t=!0,r=!1){return this.client.request("/fs/unarchive",{api:"",version:"v1",method:"POST",params:{src:e,trg:"/",override:t,dry:r},useNodeAuth:!0})}async modifyOperation(e,t){return this.client.request(`/fs/ops/${t}`,{api:"",version:"v1",method:"POST",params:{id:e},useNodeAuth:!0})}};var O=class extends o{getModuleID(){return"kyros_logs_v1"}async clear(){return this.client.request("/logs/clear",{api:"",version:"v1",method:"POST",useNodeAuth:!0})}};var I=class extends o{getModuleID(){return"kyros_upload_sessions_v1"}async create(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async get(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"GET",useNodeAuth:!0})}uploadFiles(e,t,r,i,a){let n=new FormData;for(let{file:c,filename:l}of i)n.append("file",c,l);return this.client.upload(`/worlds/${t}/files/upload-session/${r}/files`,{api:"",version:"v1",formData:n,onProgress:a?.onProgress,retry:a?.retry,useNodeAuth:!0})}async finalize(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}/finalize`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async cancel(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}`,{api:"",version:"v1",method:"DELETE",useNodeAuth:!0})}};var U=class extends o{getModuleID(){return"labrinth_analytics_v3"}async fetch(e){return this.client.request("/analytics",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async fetchFacets(e){return this.client.request("/analytics/facets",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async getEvents(){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"GET"})}async createEvent(e){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"POST",body:e})}async editEvent(e,t){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteEvent(e){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var j=class extends o{getModuleID(){return"labrinth_auth_internal"}async getNewsletterStatus(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"GET"})}async subscribeNewsletter(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"POST"})}};var D=class extends o{getModuleID(){return"labrinth_auth_v2"}async login(e){return this.client.request("/auth/login",{api:"labrinth",version:2,method:"POST",body:e})}async login2FA(e){return this.client.request("/auth/login/2fa",{api:"labrinth",version:2,method:"POST",body:e})}async createAccount(e){return this.client.request("/auth/create",{api:"labrinth",version:2,method:"POST",body:e})}async resetPasswordBegin(e){return this.client.request("/auth/password/reset",{api:"labrinth",version:2,method:"POST",body:e})}async changePassword(e){return this.client.request("/auth/password",{api:"labrinth",version:2,method:"PATCH",body:e})}};var N=class extends o{getModuleID(){return"labrinth_billing_internal"}async getSubscriptions(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/subscriptions${t}`,{api:"labrinth",version:"internal",method:"GET"})}async getProducts(){return this.client.request("/billing/products",{api:"labrinth",version:"internal",method:"GET"})}async getCustomer(){return this.client.request("/billing/customer",{api:"labrinth",version:"internal",method:"GET"})}async editSubscription(e,t,r){let i=r?"?dry=true":"";return this.client.request(`/billing/subscription/${e}${i}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async getPaymentMethods(){return this.client.request("/billing/payment_methods",{api:"labrinth",version:"internal",method:"GET"})}async addPaymentMethodFlow(){return this.client.request("/billing/payment_method",{api:"labrinth",version:"internal",method:"POST"})}async editPaymentMethod(e,t){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async removePaymentMethod(e){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async getPayments(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/payments${t}`,{api:"labrinth",version:"internal",method:"GET"})}async initiatePayment(e){return this.client.request("/billing/payment",{api:"labrinth",version:"internal",method:"POST",body:e})}async refundCharge(e,t){return this.client.request(`/billing/charge/${e}/refund`,{api:"labrinth",version:"internal",method:"POST",body:t})}async credit(e){return this.client.request("/billing/credit",{api:"labrinth",version:"internal",method:"POST",body:e})}};var F=class extends o{getModuleID(){return"labrinth_collections"}async get(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/collections",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async editIcon(e,t,r){return this.client.request(`/collection/${e}/icon?ext=${r}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteIcon(e){return this.client.request(`/collection/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var G=class extends o{getModuleID(){return"labrinth_external_projects_internal"}async search(e){return this.client.request("/moderation/external-license/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getBySha1(e){return this.client.request(`/moderation/external-license/by-sha1/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async update(e,t){return this.client.request(`/moderation/external-license/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var B=class extends o{getModuleID(){return"labrinth_globals_internal"}async get(){return this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};var V=class extends o{getModuleID(){return"labrinth_limits_v3"}async getProjectLimits(){return this.client.request("/limits/projects",{api:"labrinth",version:3,method:"GET"})}async getOrganizationLimits(){return this.client.request("/limits/organizations",{api:"labrinth",version:3,method:"GET"})}async getCollectionLimits(){return this.client.request("/limits/collections",{api:"labrinth",version:3,method:"GET"})}};var W=class extends o{getModuleID(){return"labrinth_moderation_internal"}async acquireLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"POST"})}async overrideLock(e){return this.client.request(`/moderation/lock/${e}/override`,{api:"labrinth",version:"internal",method:"POST"})}async releaseLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async checkLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var H=class extends o{getModuleID(){return"labrinth_notifications_v2"}async getUserNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/notifications?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async markAsRead(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"PATCH"})}async markMultipleAsRead(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify([...new Set(e)])}})}async delete(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async deleteMultiple(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"DELETE",params:{ids:JSON.stringify([...new Set(e)])}})}};var z=class extends o{getModuleID(){return"labrinth_oauth_internal"}async getUserApps(e){return this.client.request(`/user/${e}/oauth_apps`,{api:"labrinth",version:3,method:"GET"})}async getApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getApps(e){return this.client.request(`/oauth/apps?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:"internal",method:"GET"})}async createApp(e){return this.client.request("/oauth/app",{api:"labrinth",version:"internal",method:"POST",body:e})}async editApp(e,t){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async deleteApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}uploadAppIcon(e,t,r){return this.client.upload(`/oauth/app/${e}/icon`,{api:"labrinth",version:"internal",file:t,params:{ext:r}})}async getAuthorizations(){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"GET"})}async revokeAuthorization(e){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"DELETE",params:{client_id:e}})}async authorize(e){return this.client.request("/oauth/authorize",{api:"labrinth",version:"internal",method:"GET",params:e})}async accept(e){return this.client.request("/oauth/accept",{api:"labrinth",version:"internal",method:"POST",body:e})}async reject(e){return this.client.request("/oauth/reject",{api:"labrinth",version:"internal",method:"POST",body:e})}};var K=class extends o{getModuleID(){return"labrinth_organizations_v3"}async get(e){return this.client.request(`/organization/${e}`,{api:"labrinth",version:3,method:"GET"})}async getProjects(e){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/organizations?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async addProject(e,t){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"POST",body:t})}async removeProject(e,t,r){return this.client.request(`/organization/${e}/projects/${t}`,{api:"labrinth",version:3,method:"DELETE",body:r})}};var J=class extends o{getModuleID(){return"labrinth_pats_v2"}async list(){return this.client.request("/pat",{api:"labrinth",version:2,method:"GET"})}async create(e){return this.client.request("/pat",{api:"labrinth",version:2,method:"POST",body:e})}async modify(e,t){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var X=class extends o{getModuleID(){return"labrinth_payout_v3"}async getBalance(){let e=await this.client.request("/payout/balance",{api:"labrinth",version:3,method:"GET"});return{...e,available:Number(e.available),withdrawn_lifetime:Number(e.withdrawn_lifetime),withdrawn_ytd:Number(e.withdrawn_ytd),pending:Number(e.pending),dates:Object.fromEntries(Object.entries(e.dates).map(([t,r])=>[t,Number(r)]))}}async getHistory(){return(await this.client.request("/payout/history",{api:"labrinth",version:3,method:"GET"})).map(t=>t.type==="withdrawal"?{...t,amount:Number(t.amount),fee:t.fee===null?null:Number(t.fee)}:{...t,amount:Number(t.amount)})}async getMethods(e){return this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET",params:e?{country:e}:void 0})}async cancel(e){return this.client.request(`/payout/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var Q=class extends o{getModuleID(){return"labrinth_payouts_v3"}async getPlatformRevenue(e){return this.client.request("/payout/platform_revenue",{api:"labrinth",version:3,method:"GET",params:e})}};var Y=class extends o{getModuleID(){return"labrinth_projects_v2"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"GET"})}async check(e){let t=encodeURIComponent(e);return this.client.request(`/project/${t}/check`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async search(e){return this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{...e,facets:e.facets?JSON.stringify(e.facets):void 0,new_filters:e.new_filters??void 0}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:2,method:"GET"})}async createGalleryImage(e,t,r){let i={ext:r.ext,featured:String(r.featured)};return r.title&&(i.title=r.title),r.description&&(i.description=r.description),r.ordering!==void 0&&(i.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"POST",params:i,body:t})}async editGalleryImage(e,t,r){let i={url:t,featured:String(r.featured)};return r.title&&(i.title=r.title),r.description&&(i.description=r.description),r.ordering!==void 0&&(i.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"PATCH",params:i})}async deleteGalleryImage(e,t){return this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"DELETE",params:{url:t}})}async getRandom(e){return this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:String(e)}})}async bulkEdit(e,t){return this.client.request("/projects",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify(e)},body:t})}};function Pe(s){if(typeof s!="object"||s===null)return!1;let e=s;return typeof e.error=="string"&&typeof e.description=="string"}var h=class s extends Error{constructor(e,t){super(e),this.name="ModrinthApiError",this.statusCode=t?.statusCode,this.originalError=t?.originalError,this.responseData=t?.responseData,this.context=t?.context,Error.captureStackTrace&&Error.captureStackTrace(this,s)}static fromUnknown(e,t){return e instanceof s?e:e instanceof Error?new s(e.message,{originalError:e,context:t}):new s(String(e),{context:t})}},P=class s extends h{constructor(e,t){let r=e;t?.v1Error&&(r=`[${t.v1Error.error}] ${t.v1Error.description}`,t.v1Error.context&&(r=`${t.v1Error.context}: ${r}`)),super(r,t),this.name="ModrinthServerError",this.v1Error=t?.v1Error,Error.captureStackTrace&&Error.captureStackTrace(this,s)}static fromResponse(e,t,r){let i=Pe(t)?t:void 0,a=`HTTP ${e}`;return i?a=i.description:typeof t=="string"&&(a=t),new s(a,{statusCode:e,responseData:t,context:r,v1Error:i})}static fromUnknown(e,t){return e instanceof s?e:e instanceof h?new s(e.message,{statusCode:e.statusCode,originalError:e.originalError,responseData:e.responseData,context:t??e.context}):e instanceof Error?new s(e.message,{originalError:e,context:t}):new s(String(e),{context:t})}};var Z=class extends o{getModuleID(){return"labrinth_projects_v3"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"GET"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async getOrganization(e){try{return await this.client.request(`/project/${e}/organization`,{api:"labrinth",version:3,method:"GET"})}catch(t){if(t instanceof h&&t.statusCode===404)return null;throw t}}async getMembers(e){return this.client.request(`/project/${e}/members`,{api:"labrinth",version:3,method:"GET"})}async createServerProject(e){return this.client.request("/project",{api:"labrinth",version:3,method:"PUT",body:e})}async deleteProject(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async changeIcon(e,t,r){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"PATCH",params:{ext:r},body:t})}async deleteIcon(e){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var ee=class extends o{getModuleID(){return"labrinth_reports_v3"}async get(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"GET"})}async list(e){let t={};return e?.count!=null&&(t.count=String(e.count)),e?.offset!=null&&(t.offset=String(e.offset)),e?.all!=null&&(t.all=String(e.all)),this.client.request("/report",{api:"labrinth",version:3,method:"GET",params:Object.keys(t).length>0?t:void 0})}async getMultiple(e){return this.client.request(`/reports?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async create(e){return this.client.request("/report",{api:"labrinth",version:3,method:"POST",body:e})}async edit(e,t){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var te=class extends o{getModuleID(){return"labrinth_server_ping_internal"}async pingMinecraftJava(e){return this.client.request("/server-ping/minecraft-java",{api:"labrinth",version:"internal",method:"POST",body:e})}};var re=class extends o{getModuleID(){return"labrinth_sessions_v2"}async list(){return this.client.request("/session/list",{api:"labrinth",version:2,method:"GET"})}async delete(e){return this.client.request(`/session/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var ie=class extends o{getModuleID(){return"labrinth_state"}async build(){let e=[],t=(d,Ge,Be)=>(console.error("Error fetching state data:",d),e.push({endpoint:Be,error:d}),Ge),[r,i,a,n,c,l,u,p,m,b,y,De,Ne]=await Promise.all([this.client.request("/tag/category",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/category")),this.client.request("/tag/loader",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/loader")),this.client.request("/tag/game_version",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/game_version")),this.client.request("/tag/donation_platform",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/donation_platform")),this.client.request("/tag/report_type",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/report_type")),this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:"60"}}).catch(d=>t(d,[],"/v2/projects_random")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"leave",index:"relevance"}}).catch(d=>t(d,{},"/v2/search")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"",index:"updated"}}).catch(d=>t(d,{},"/v2/search")),this.client.labrinth.billing_internal.getProducts().catch(d=>t(d,[],"/_internal/billing/products")),this.client.request("/mural/bank-details",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/mural/bank-details")),this.client.iso3166.data.build().catch(d=>t(d,{countries:[],subdivisions:{}},"iso3166/data")),this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET"}).catch(d=>t(d,[],"/v3/payout/methods")),this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/globals"))]),Fe=Object.fromEntries(De.filter(d=>d.type==="tremendous").map(d=>[d.id,{name:d.name,image_url:d.image_logo_url}]));return{categories:r,loaders:i,gameVersions:a,donationPlatforms:n,reportTypes:c,homePageProjects:l,homePageSearch:u,homePageNotifs:p,products:m,muralBankDetails:b?.bankDetails,tremendousIdMap:Fe,countries:y.countries,subdivisions:y.subdivisions,taxComplianceThresholds:Ne?.tax_compliance_thresholds,errors:e}}};var ne=class extends o{getModuleID(){return"labrinth_tech_review_internal"}async searchProjects(e){return this.client.request("/moderation/tech-review/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getReport(e){return this.client.request(`/moderation/tech-review/report/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getIssue(e){return this.client.request(`/moderation/tech-review/issue/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async updateIssueDetail(e,t){return this.client.request(`/moderation/tech-review/issue-detail/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async submitProject(e,t){return this.client.request(`/moderation/tech-review/submit/${e}`,{api:"labrinth",version:"internal",method:"POST",body:t})}async getProjectReport(e){return this.client.request(`/moderation/tech-review/project/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var se=class extends o{getModuleID(){return"labrinth_threads_v3"}async getThread(e){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/threads?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async sendMessage(e,t){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"POST",body:t})}async deleteMessage(e){return this.client.request(`/message/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var oe=class extends o{getModuleID(){return"labrinth_users_v2"}async get(e){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/users?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async getProjects(e){return this.client.request(`/user/${e}/projects`,{api:"labrinth",version:2,method:"GET"})}async getOrganizations(e){return this.client.request(`/user/${e}/organizations`,{api:"labrinth",version:3,method:"GET"})}async getCollections(e){return this.client.request(`/user/${e}/collections`,{api:"labrinth",version:3,method:"GET"})}async getNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getFollowedProjects(e){return this.client.request(`/user/${e}/follows`,{api:"labrinth",version:2,method:"GET"})}async patch(e,t){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var ae=class extends o{getModuleID(){return"labrinth_users_v3"}async getAllProjects(e){return this.client.request(`/user/${encodeURIComponent(e)}/all-projects`,{api:"labrinth",version:3,method:"GET"})}};var ce=class extends o{getModuleID(){return"labrinth_versions_v2"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:2,method:"GET"})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var le=class extends o{getModuleID(){return"labrinth_versions_v3"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:t?.apiVersion??2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:3,method:"GET"})}createVersion(e,t,r=null){let i=new FormData,a=t.map(p=>p.file),n=t.map(p=>p.fileType||null),c=a.map((p,m)=>`${p.name}-${m===0?"primary":m}`),l=c.reduce((p,m,b)=>(p[m]=n[b],p),{}),u={project_id:e.project_id,version_number:e.version_number,name:e.name||e.version_number,changelog:e.changelog,dependencies:e.dependencies||[],game_versions:e.game_versions,version_type:e.version_type,featured:!!e.featured,file_parts:c,file_types:l,primary_file:c[0],environment:e.environment,loaders:e.loaders};return r==="modpack"&&(u.mrpack_loaders=e.loaders,u.loaders=["mrpack"]),i.append("data",JSON.stringify(u)),a.forEach((p,m)=>{i.append(c[m],p,p.name)}),this.client.upload("/version",{api:"labrinth",version:3,formData:i,timeout:300*1e3})}async modifyVersion(e,t){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}addFilesToVersion(e,t){let r=new FormData,i=t.map(l=>l.file),a=t.map(l=>l.fileType||null),n=i.map((l,u)=>`${l.name}-${u}`),c=n.reduce((l,u,p)=>(l[u]=a[p],l),{});return r.append("data",JSON.stringify({file_types:c})),i.forEach((l,u)=>{r.append(n[u],l,l.name)}),this.client.upload(`/version/${e}/file`,{api:"labrinth",version:2,formData:r,timeout:300*1e3})}};var ue=class extends o{getModuleID(){return"labrinth_affiliate_internal"}async getAll(){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"GET"})}async create(e){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"PUT",body:e})}async get(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async delete(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async patch(e,t){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var pe=class extends o{getModuleID(){return"labrinth_tags_v2"}async getLicenseText(e){return this.client.request(`/tag/license/${e}`,{api:"labrinth",version:2,method:"GET"})}};var de=class extends o{getModuleID(){return"labrinth_teams_v2"}async addMember(e,t){return this.client.request(`/team/${e}/members`,{api:"labrinth",version:2,method:"POST",body:t})}async editMember(e,t,r){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"PATCH",body:r})}async removeMember(e,t){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"DELETE"})}async transferOwnership(e,t){return this.client.request(`/team/${e}/owner`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var he=class extends o{getModuleID(){return"labrinth_teams_v3"}async getMultiple(e){return this.client.request(`/teams?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}};var Ve="https://launcher-meta.modrinth.com",me=class extends o{getModuleID(){return"launchermeta_manifest_v0"}async getManifest(e){return this.client.request("/manifest.json",{api:Ve,version:`${e}/v0`,method:"GET",skipAuth:!0,headers:{"Content-Type":""}})}};var be=class extends o{getModuleID(){return"mclogs_insights_v1"}async analyse(e){return this.client.request("/analyse",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var ge=class extends o{getModuleID(){return"mclogs_logs_v1"}async create(e){return this.client.request("/log",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var Me="https://fill.papermc.io",ve=class extends o{getModuleID(){return"paper_versions_v3"}async getProject(){return this.client.request("/projects/paper",{api:Me,version:"v3",method:"GET",skipAuth:!0})}async getBuilds(e){return{builds:await this.client.request(`/projects/paper/versions/${e}/builds`,{api:Me,version:"v3",method:"GET",skipAuth:!0})}}};var Oe="https://api.purpurmc.org",fe=class extends o{getModuleID(){return"purpur_versions_v2"}async getProject(){return this.client.request("/purpur",{api:Oe,version:"v2",method:"GET",skipAuth:!0})}async getBuilds(e){return this.client.request(`/purpur/${e}`,{api:Oe,version:"v2",method:"GET",skipAuth:!0})}};var We={archon_backups_queue_v1:L,archon_backups_v1:R,archon_content_v1:q,archon_options_v1:C,archon_properties_v1:w,archon_servers_v0:k,archon_servers_v1:x,iso3166_data:$,mclogs_insights_v1:be,mclogs_logs_v1:ge,launchermeta_manifest_v0:me,kyros_content_v1:_,kyros_files_v0:M,kyros_logs_v1:O,kyros_upload_sessions_v1:I,labrinth_affiliate_internal:ue,labrinth_analytics_v3:U,labrinth_auth_internal:j,labrinth_auth_v2:D,labrinth_billing_internal:N,labrinth_collections:F,labrinth_external_projects_internal:G,labrinth_globals_internal:B,labrinth_moderation_internal:W,labrinth_notifications_v2:H,labrinth_oauth_internal:z,labrinth_organizations_v3:K,labrinth_pats_v2:J,labrinth_limits_v3:V,labrinth_payout_v3:X,labrinth_payouts_v3:Q,labrinth_projects_v2:Y,labrinth_projects_v3:Z,labrinth_reports_v3:ee,labrinth_server_ping_internal:te,labrinth_sessions_v2:re,labrinth_state:ie,labrinth_tags_v2:pe,labrinth_teams_v2:de,labrinth_teams_v3:he,labrinth_tech_review_internal:ne,labrinth_threads_v3:se,labrinth_users_v2:oe,labrinth_users_v3:ae,labrinth_versions_v2:ce,labrinth_versions_v3:le,paper_versions_v3:ve,purpur_versions_v2:fe};function He(s){let e=s.split("_");if(e.length<2)throw new Error(`Invalid module ID "${s}". Expected format: <api>_<module> (e.g., "labrinth_projects_v2")`);let t=e[0],r=e.slice(1).join("_");return[t,r]}function Ie(){let s={};for(let[e,t]of Object.entries(We)){let[r,i]=He(e);s[r]||(s[r]={}),s[r][i]=t}return s}var A=class{};var E=class extends A{constructor(t){super();this._moduleInstances=new Map;this._moduleNamespaces=new Map;this.config={timeout:1e4,labrinthBaseUrl:"https://api.modrinth.com",archonBaseUrl:"https://archon.modrinth.com",...t},this.features=t.features??[],this.initializeModules()}initializeModules(){let t=Ie();for(let[r,i]of Object.entries(t)){let a={};for(let[n,c]of Object.entries(i)){let l=`${r}_${n}`;Object.defineProperty(a,n,{get:()=>{if(!this._moduleInstances.has(l)){let u=new c(this),p=u.getModuleID();if(p!==l)throw new Error(`Module ID mismatch: registry expects "${l}" but module declares "${p}"`);this._moduleInstances.set(l,u)}return this._moduleInstances.get(l)},enumerable:!0,configurable:!1})}Object.defineProperty(this,r,{value:a,writable:!1,enumerable:!0,configurable:!1}),this._moduleNamespaces.set(r,a)}}async request(t,r){let i;r.api==="labrinth"?i=this.config.labrinthBaseUrl:r.api==="archon"?i=this.config.archonBaseUrl:i=r.api;let a=this.buildUrl(t,i,r.version),n=await this.buildDefaultHeaders(),c={method:"GET",timeout:this.config.timeout,...r,headers:{...n,...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=c.headers;l&&"Content-Type"in l&&l["Content-Type"]===""&&delete l["Content-Type"];let u=this.buildContext(a,t,c);try{let p=await this.executeFeatureChain(u);return await this.config.hooks?.onResponse?.(p,u),p}catch(p){let m=this.normalizeError(p,u);throw await this.config.hooks?.onError?.(m,u),m}}async executeFeatureChain(t){let r=this.features.filter(n=>n.shouldApply(t)),i=r.length,a=async()=>(i--,i>=0?r[i].execute(a,t):(await this.config.hooks?.onRequest?.(t),this.executeRequest(t.url,t.options)));return a()}async executeUploadFeatureChain(t,r,i){let a=this.features.filter(l=>l.shouldApply(t)),n=a.length,c=async()=>(n--,n>=0?a[n].execute(c,t):(await this.config.hooks?.onRequest?.(t),this.executeXHRUpload(t,r,i)));return c()}buildUrl(t,r,i){let a=r.replace(/\/$/,""),n="";i==="internal"?n="/_internal":typeof i=="number"?n=`/v${i}`:typeof i=="string"&&(n=`/${i}`);let c=t.startsWith("/")?t:`/${t}`;return`${a}${n}${c}`}buildContext(t,r,i){return{url:t,path:r,options:i,attempt:1,startTime:Date.now()}}buildUploadContext(t,r,i){let a,n;if("formData"in i&&i.formData)a={isUpload:!0,formData:i.formData,onProgress:i.onProgress},n=i.formData;else if("file"in i&&i.file)a={isUpload:!0,file:i.file,onProgress:i.onProgress},n=i.file;else throw new Error("Upload options must include either file or formData");return{url:t,path:r,options:{...i,method:"POST",body:n},attempt:1,startTime:Date.now(),metadata:a}}async buildDefaultHeaders(){let t={"Content-Type":"application/json",...this.config.headers},r=await this.resolveUserAgent();return r&&(t["User-Agent"]=r),t}async resolveUserAgent(){let t=this.config.userAgent;return typeof t=="function"?await t():t}attachArchonSentryCaptureHeader(t){t.api!=="archon"||!t.headers||!this.shouldCaptureArchonRequests()||(t.headers["modrinth-sentry-capture"]="1")}shouldCaptureArchonRequests(){let t=this.config.archonSentryCapture;return typeof t=="function"?t():t===!0}normalizeError(t,r){return t instanceof h?t:h.fromUnknown(t,r?.path)}createNormalizedError(t,r,i){return r&&i?P.fromResponse(r,i):new h(t.message,{statusCode:r,originalError:t,responseData:i})}addFeature(t){return this.features.push(t),this}removeFeature(t){let r=this.features.indexOf(t);return r!==-1&&this.features.splice(r,1),this}getFeatures(){return[...this.features]}};var g=class{constructor(e){this.config={enabled:!0,...e}}shouldApply(e){return this.config.enabled!==!1}get name(){return this.config.name??this.constructor.name}get enabled(){return this.config.enabled!==!1}};var T=class{constructor(e){this.client=e;this.connections=new Map;this.MAX_RECONNECT_ATTEMPTS=10;this.RECONNECT_BASE_DELAY=1e3;this.RECONNECT_MAX_DELAY=3e4}async safeConnect(e,t){let r=this.getStatus(e);if(r?.connected&&!t?.force||r&&!r.connected&&!t?.force)return;t?.force&&r&&this.disconnect(e);let i=await this.client.archon.servers_v0.getWebSocketAuth(e);await this.connect(e,i)}on(e,t,r){let i=`${e}:${t}`;return this.emitter.on(i,r),()=>{this.emitter.off(i,r)}}getStatus(e){let t=this.connections.get(e);return t?{connected:t.socket.readyState===WebSocket.OPEN,reconnecting:t.isReconnecting,reconnectAttempts:t.reconnectAttempts}:null}getReconnectDelay(e){return Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,e),this.RECONNECT_MAX_DELAY)+Math.random()*1e3}};var Ae=class extends g{async execute(e,t){let r=await this.getToken();if(r){let i=this.config.headerName??"Authorization",a=this.config.tokenPrefix??"Bearer",n=a?`${a} ${r}`:r;t.options.headers={...t.options.headers,[i]:n}}return e()}shouldApply(e){if(e.options.skipAuth)return!1;let t=this.config.headerName??"Authorization";return e.options.headers?.[t]?!1:super.shouldApply(e)}async getToken(){let{token:e}=this.config;return typeof e=="function"?await e():e}};var ye=class{constructor(){this.state=new Map}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Ee=class extends g{constructor(e){super(e),this.config={enabled:!0,name:"circuit-breaker",maxFailures:3,resetTimeout:3e4,failureStatusCodes:[500,502,503,504],...e},this.storage=e?.storage??new ye}async execute(e,t){let r=this.getCircuitKey(t);if(this.isCircuitOpen(r))throw new h("Circuit breaker open - too many recent failures",{statusCode:503,context:t.path});try{let i=await e();return this.recordSuccess(r),i}catch(i){throw this.isFailureError(i)&&this.recordFailure(r),i}}shouldApply(e){return e.options.circuitBreaker===!1?!1:super.shouldApply(e)}getCircuitKey(e){if(this.config.getCircuitKey)return this.config.getCircuitKey(e.url,e.options.method??"GET");let t=e.options.method??"GET",r=e.path.split("?")[0];return`${t}_${r}`}isCircuitOpen(e){let t=this.storage.get(e);return t?Date.now()-t.lastFailure>this.config.resetTimeout?(this.storage.clear?.(e),!1):t.failures>=this.config.maxFailures:!1}recordSuccess(e){this.storage.clear?.(e)}recordFailure(e){let t=Date.now(),r=this.storage.get(e);r?this.storage.set(e,{failures:r.failures+1,lastFailure:t}):this.storage.set(e,{failures:1,lastFailure:t})}isFailureError(e){return e instanceof h&&e.statusCode?this.config.failureStatusCodes.includes(e.statusCode):!1}getCircuitState(e){return this.storage.get(e)}resetCircuit(e){this.storage.clear?.(e)}};var Te=class extends g{constructor(){super(...arguments);this.refreshPromise=null}shouldApply(t){return t.options.useNodeAuth===!0&&this.config.enabled!==!1}async refreshAuthWithLock(){return this.refreshPromise?this.refreshPromise:(this.refreshPromise=this.config.refreshAuth().finally(()=>{this.refreshPromise=null}),this.refreshPromise)}async execute(t,r){let a=0,n=this.config.getAuth();if((!n||this.isTokenExpired(n.token))&&(await this.refreshAuthWithLock(),n=this.config.getAuth()),!n)throw new Error("Failed to obtain node authentication");for(this.applyAuth(r,n);;)try{return await t()}catch(c){if(c instanceof h&&c.statusCode===401){if(a++,a>=3)throw new Error("Node authentication failed after 3 retries. Please re-authenticate.");if(await this.refreshAuthWithLock(),n=this.config.getAuth(),!n)throw new Error("Failed to refresh node authentication");this.applyAuth(r,n);continue}throw c}}applyAuth(t,r){let i=`https://${r.url.replace(/\/modrinth\/v\d+\/fs\/?$/,"")}`;t.url=this.buildUrl(t.path,i,t.options.version),t.options.headers={...t.options.headers,Authorization:`Bearer ${r.token}`},t.options.skipAuth=!0}buildUrl(t,r,i){let a=r.replace(/\/$/,""),n="";i==="internal"?n="/_internal":typeof i=="number"?n=`/v${i}`:typeof i=="string"&&(n=`/${i}`);let c=t.startsWith("/")?t:`/${t}`;return`${a}${n}${c}`}isTokenExpired(t){try{let r=JSON.parse(atob(t.split(".")[1]));if(!r.exp)return!1;let i=r.exp*1e3;return Date.now()>=i-1e4}catch{return!1}}};var Ue=1,Se=class extends g{async execute(e,t){return t.options.headers={...t.options.headers,"X-Panel-Version":String(Ue)},e()}shouldApply(e){return e.options.api==="labrinth"||e.options.api==="archon"}};var Re=class extends g{constructor(e){super(e),this.config={enabled:!0,name:"retry",maxAttempts:3,backoffStrategy:"exponential",initialDelay:1e3,maxDelay:15e3,retryableStatusCodes:[408,429,500,502,503,504],retryOnNetworkError:!0,...e}}async execute(e,t){let r=null,i=this.getMaxAttempts(t);for(let a=1;a<=i;a++){t.attempt=a;try{return await e()}catch(n){if(r=n,!this.shouldRetryError(n,a,i)||a>=i)throw n;let l=this.calculateDelay(a);console.warn(`[${this.name}] Retrying request to ${t.path} (attempt ${a+1}/${i}) after ${l}ms`),await this.sleep(l)}}throw r??new Error("Max retry attempts reached")}shouldApply(e){return e.options.retry===!1?!1:super.shouldApply(e)}shouldRetryError(e,t,r){return this.config.shouldRetry?this.config.shouldRetry(e,t):this.config.retryOnNetworkError&&this.isNetworkError(e)?!0:e instanceof h&&e.statusCode?this.config.retryableStatusCodes.includes(e.statusCode):!1}isNetworkError(e){let t=[/network/i,/timeout/i,/ECONNREFUSED/i,/ENOTFOUND/i,/ETIMEDOUT/i,/ECONNRESET/i],r=e instanceof Error?e.message:String(e);return t.some(i=>i.test(r))}getMaxAttempts(e){return typeof e.options.retry=="number"?e.options.retry:this.config.maxAttempts}calculateDelay(e){let{backoffStrategy:t,initialDelay:r,maxDelay:i}=this.config,a;switch(t){case"exponential":a=r*Math.pow(2,e-1);break;case"linear":a=r*e;break;case"constant":a=r;break;default:a=r}return a+=Math.random()*1e3,Math.min(a,i)}sleep(e){return new Promise(t=>setTimeout(t,e))}};var Le=class extends g{async execute(e,t){let r=t.options.method??"GET",i=t.options.api,a=t.options.version,n=`[${r}] [${i}_v${a}]`;console.debug(`${n} ${t.url} SENT`);try{let c=await e();try{let l=c?JSON.stringify(c).length:0;console.debug(`${n} ${t.url} RECEIVED ${l} bytes`)}catch{console.debug(`${n} ${t.url} RECEIVED`)}return c}catch(c){let l=ze(c);throw console.debug(`${n} ${t.url} FAILED${l?` \u2014 ${l}`:""}`),c}}};function ze(s){if(!s||typeof s!="object")return typeof s=="string"?s:"";let e=s,t=e.status??e.statusCode??e.response?.status,r=e.statusText??e.response?.statusText,i=e.responseData??e.data??e.response?._data,a=[];return t!==void 0&&a.push(r?`${t} ${r}`:String(t)),i!==void 0?a.push(`body: ${Ke(i)}`):e.message&&a.push(e.message),a.join(" ")}function Ke(s){if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}import{$fetch as Xe,FetchError as Qe}from"ofetch";import Je from"mitt";var je=1e3,f=class extends T{constructor(){super(...arguments);this.emitter=Je()}async connect(t,r){return this.connections.has(t)&&this.closeConnection(t),new Promise((i,a)=>{try{let n=new WebSocket(`wss://${r.url}`),c={serverId:t,socket:n,reconnectAttempts:0,reconnectTimer:void 0,isReconnecting:!1};this.connections.set(t,c),n.onopen=()=>{n.send(JSON.stringify({event:"auth",jwt:r.token})),c.reconnectAttempts=0,c.isReconnecting=!1,i()},n.onmessage=l=>{try{let u=JSON.parse(l.data),p=`${t}:${u.event}`;this.emitter.emit(p,u),(u.event==="auth-expiring"||u.event==="auth-incorrect")&&this.handleAuthExpiring(t).catch(console.error)}catch(u){console.error("[WebSocket] Failed to parse message:",u)}},n.onclose=l=>{console.debug(`[WebSocket] Closed for server ${t}:`,{code:l.code,reason:l.reason,wasClean:l.wasClean}),l.code!==je&&this.scheduleReconnect(t,r)},n.onerror=l=>{let u=n.url,p=n.readyState;console.error(`[WebSocket] Error for server ${t}:`,{url:u,readyState:p,readyStateLabel:["CONNECTING","OPEN","CLOSING","CLOSED"][p],type:l.type}),a(new Error(`WebSocket connection failed for server ${t} (readyState: ${p})`))}}catch(n){a(n)}})}disconnect(t){this.closeConnection(t),this.emitter.all.forEach((r,i)=>{i.toString().startsWith(`${t}:`)&&this.emitter.all.delete(i)})}closeConnection(t){let r=this.connections.get(t);r&&(r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),(r.socket.readyState===WebSocket.OPEN||r.socket.readyState===WebSocket.CONNECTING)&&r.socket.close(je,"Client disconnecting"),this.connections.delete(t))}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}send(t,r){let i=this.connections.get(t);if(!i||i.socket.readyState!==WebSocket.OPEN){console.warn(`Cannot send message: WebSocket not connected for server ${t}`);return}i.socket.send(JSON.stringify(r))}scheduleReconnect(t,r){let i=this.connections.get(t);if(!i)return;if(i.reconnectAttempts>=this.MAX_RECONNECT_ATTEMPTS){this.disconnect(t);return}i.isReconnecting=!0,i.reconnectAttempts++;let a=this.getReconnectDelay(i.reconnectAttempts);i.reconnectTimer=setTimeout(()=>{this.connect(t,r).catch(n=>{console.error(`[WebSocket] Reconnection failed for server ${t}:`,n)})},a)}async handleAuthExpiring(t){try{let r=await this.client.archon.servers_v0.getWebSocketAuth(t),i=this.connections.get(t);i&&i.socket.readyState===WebSocket.OPEN&&i.socket.send(JSON.stringify({event:"auth",jwt:r.token}))}catch(r){console.error(`[WebSocket] Failed to refresh auth for server ${t}:`,r),this.disconnect(t)}}};var v=class extends E{upload(e,t){let r;t.api==="labrinth"?r=this.config.labrinthBaseUrl:t.api==="archon"?r=this.config.archonBaseUrl:r=t.api;let i=this.buildUrl(e,r,t.version),a=[];t.onProgress&&a.push(t.onProgress);let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let c,l={promise:(async()=>{let u="formData"in t&&t.formData instanceof FormData,p=await this.buildDefaultHeaders();u?delete p["Content-Type"]:p["Content-Type"]="application/octet-stream";let m={retry:!1,...t,headers:{...p,...t.headers}};this.attachArchonSentryCaptureHeader(m);let b=this.buildUploadContext(i,e,m);if(c=b,n.signal.aborted)throw new h("Upload cancelled");let y=await this.executeUploadFeatureChain(b,a,n);return await this.config.hooks?.onResponse?.(y,b),y})().catch(async u=>{let p=this.normalizeError(u,c);throw c&&await this.config.hooks?.onError?.(p,c),p}),onProgress:u=>(a.push(u),l),cancel:()=>n.abort()};return l}executeXHRUpload(e,t,r){return new Promise((i,a)=>{let n=new XMLHttpRequest,c=e.metadata;n.upload.addEventListener("progress",p=>{if(p.lengthComputable){let m={loaded:p.loaded,total:p.total,progress:p.loaded/p.total};t.forEach(b=>b(m))}}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{i(n.response?JSON.parse(n.response):void 0)}catch{i(void 0)}else a(this.createUploadError(n))}),n.addEventListener("error",()=>a(new h("Upload failed"))),n.addEventListener("abort",()=>a(new h("Upload cancelled")));let l=e.url;if(e.options.params){let p=new URLSearchParams(Object.entries(e.options.params).map(([m,b])=>[m,String(b)])).toString();l+=(l.includes("?")?"&":"?")+p}n.open("POST",l);for(let[p,m]of Object.entries(e.options.headers??{}))n.setRequestHeader(p,m);let u="formData"in c?c.formData:c.file;n.send(u),r.signal.addEventListener("abort",()=>n.abort())})}createUploadError(e){let t;try{t=e.response?JSON.parse(e.response):void 0}catch{t=e.responseText}return this.createNormalizedError(new Error(`Upload failed with status ${e.status}`),e.status,t)}};var qe=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{return await Xe(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal})}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Qe?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}};import{FetchError as Ye}from"ofetch";var Ce=class{constructor(){let e=useState("circuit-breaker-state",()=>new Map);this.state=e.value}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},we=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async resolveRateLimitKey(){if(this.rateLimitKeyResolved!==void 0)return this.rateLimitKeyResolved;let e=this.config.rateLimitKey;return typeof e=="string"?this.rateLimitKeyResolved=e:typeof e=="function"&&(this.rateLimitKeyPromise||(this.rateLimitKeyPromise=e()),this.rateLimitKeyResolved=await this.rateLimitKeyPromise),this.rateLimitKeyResolved}async request(e,t){return import.meta.server&&await this.resolveRateLimitKey(),super.request(e,t)}upload(e,t){if(import.meta.server)throw new h("upload() is not supported during SSR");return super.upload(e,t)}async executeRequest(e,t){try{return await $fetch(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal,cache:import.meta.server?void 0:"no-store"})}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Ye?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}async buildDefaultHeaders(){let e={...await super.buildDefaultHeaders()};return import.meta.server&&this.rateLimitKeyResolved&&(e["x-ratelimit-key"]=this.rateLimitKeyResolved),e}};var ke=class extends v{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),i;if(t.body){let u=t.body;typeof u=="object"&&!(u instanceof FormData)&&!(u instanceof URLSearchParams)&&!(u instanceof Blob)&&!(u instanceof ArrayBuffer)&&!ArrayBuffer.isView(u)?i=JSON.stringify(u):i=u}let a=e;if(t.params){let u={};for(let[m,b]of Object.entries(t.params))b!=null&&(u[m]=String(b));let p=new URLSearchParams(u).toString();p&&(a=`${e}?${p}`)}let n=await r(a,{method:t.method??"GET",headers:t.headers,body:i});if(!n.ok){let u;try{u=await n.json()}catch{u=void 0}let p=new Error(`HTTP ${n.status}: ${n.statusText}`);throw p.statusCode=n.status,p.responseData=u,p}let c=n.headers.get("content-type")?.toLowerCase()??"";if(a.includes("/fs/download"))return await n.blob();if(c.startsWith("image/")||c.startsWith("audio/")||c.startsWith("video/")||c.includes("application/octet-stream"))return await n.blob();if(n.status===204||n.status===205)return;if(c.includes("application/json")||c.includes("+json"))return await n.json();let l=await n.text();if(!l)return;try{return JSON.parse(l)}catch{return l}}catch(r){throw this.normalizeError(r)}}normalizeError(e){if(e instanceof Error){let t=e,r=t.statusCode,i=t.responseData;return this.createNormalizedError(e,r,i)}return super.normalizeError(e)}};var S={getAuth:null,refreshAuth:null};function Ze(s,e){S.getAuth=s,S.refreshAuth=e}function et(){S.getAuth=null,S.refreshAuth=null}async function tt(s,e){try{return await s()}catch(t){if(t instanceof h&&t.statusCode===401)return await e(),await s();throw t}}export{g as AbstractFeature,E as AbstractModrinthClient,A as AbstractUploadClient,T as AbstractWebSocketClient,Ae as AuthFeature,Ee as CircuitBreakerFeature,qe as GenericModrinthClient,ye as InMemoryCircuitBreakerStorage,h as ModrinthApiError,P as ModrinthServerError,Te as NodeAuthFeature,Ce as NuxtCircuitBreakerStorage,we as NuxtModrinthClient,Ue as PANEL_VERSION,Se as PanelVersionFeature,Re as RetryFeature,ke as TauriModrinthClient,Le as VerboseLoggingFeature,v as XHRUploadClient,et as clearNodeAuthState,Pe as isModrinthErrorResponse,S as nodeAuthState,Ze as setNodeAuthState,tt as withJWTRetry};
@@ -14,6 +14,7 @@ import { KyrosLogsV1Module } from './kyros/logs/v1';
14
14
  import { KyrosUploadSessionsV1Module } from './kyros/upload-sessions/v1';
15
15
  import { LabrinthVersionsV2Module, LabrinthVersionsV3Module } from './labrinth';
16
16
  import { LabrinthAffiliateInternalModule } from './labrinth/affiliate/internal';
17
+ import { LabrinthAnalyticsV3Module } from './labrinth/analytics/v3';
17
18
  import { LabrinthAuthInternalModule } from './labrinth/auth/internal';
18
19
  import { LabrinthAuthV2Module } from './labrinth/auth/v2';
19
20
  import { LabrinthBillingInternalModule } from './labrinth/billing/internal';
@@ -40,6 +41,7 @@ import { LabrinthTeamsV3Module } from './labrinth/teams/v3';
40
41
  import { LabrinthTechReviewInternalModule } from './labrinth/tech-review/internal';
41
42
  import { LabrinthThreadsV3Module } from './labrinth/threads/v3';
42
43
  import { LabrinthUsersV2Module } from './labrinth/users/v2';
44
+ import { LabrinthUsersV3Module } from './labrinth/users/v3';
43
45
  import { LauncherMetaManifestV0Module } from './launcher-meta/v0';
44
46
  import { MclogsInsightsV1Module } from './mclogs/insights/v1';
45
47
  import { MclogsLogsV1Module } from './mclogs/logs/v1';
@@ -72,6 +74,7 @@ export declare const MODULE_REGISTRY: {
72
74
  readonly kyros_logs_v1: typeof KyrosLogsV1Module;
73
75
  readonly kyros_upload_sessions_v1: typeof KyrosUploadSessionsV1Module;
74
76
  readonly labrinth_affiliate_internal: typeof LabrinthAffiliateInternalModule;
77
+ readonly labrinth_analytics_v3: typeof LabrinthAnalyticsV3Module;
75
78
  readonly labrinth_auth_internal: typeof LabrinthAuthInternalModule;
76
79
  readonly labrinth_auth_v2: typeof LabrinthAuthV2Module;
77
80
  readonly labrinth_billing_internal: typeof LabrinthBillingInternalModule;
@@ -98,6 +101,7 @@ export declare const MODULE_REGISTRY: {
98
101
  readonly labrinth_tech_review_internal: typeof LabrinthTechReviewInternalModule;
99
102
  readonly labrinth_threads_v3: typeof LabrinthThreadsV3Module;
100
103
  readonly labrinth_users_v2: typeof LabrinthUsersV2Module;
104
+ readonly labrinth_users_v3: typeof LabrinthUsersV3Module;
101
105
  readonly labrinth_versions_v2: typeof LabrinthVersionsV2Module;
102
106
  readonly labrinth_versions_v3: typeof LabrinthVersionsV3Module;
103
107
  readonly paper_versions_v3: typeof PaperVersionsV3Module;
@@ -0,0 +1,56 @@
1
+ import { AbstractModule } from '../../../core/abstract-module';
2
+ import type { Labrinth } from '../types';
3
+ export declare class LabrinthAnalyticsV3Module extends AbstractModule {
4
+ getModuleID(): string;
5
+ /**
6
+ * Fetch analytics data for the authenticated user's accessible projects
7
+ * and affiliate codes.
8
+ *
9
+ * @param data - Analytics request body defining time range and requested metrics
10
+ * @returns Promise resolving to the analytics response, with time slices in `metrics`
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const response = await client.labrinth.analytics_v3.fetch({
15
+ * time_range: {
16
+ * start: '2026-01-01T00:00:00Z',
17
+ * end: '2026-02-01T00:00:00Z',
18
+ * resolution: { slices: 31 },
19
+ * },
20
+ * project_ids: ['A1B2C3D4'],
21
+ * return_metrics: {
22
+ * project_views: { bucket_by: ['project_id'] },
23
+ * },
24
+ * })
25
+ * const timeSlices = response.metrics
26
+ * ```
27
+ */
28
+ fetch(data: Labrinth.Analytics.v3.FetchRequest): Promise<Labrinth.Analytics.v3.FetchResponse>;
29
+ /**
30
+ * Fetch available analytics filter facets for the authenticated user's
31
+ * accessible projects.
32
+ *
33
+ * POST /v3/analytics/facets
34
+ */
35
+ fetchFacets(data: Labrinth.Analytics.v3.FetchRequest): Promise<Labrinth.Analytics.v3.FacetsResponse>;
36
+ /**
37
+ * Fetch all analytics events.
38
+ * GET /v3/analytics-event
39
+ */
40
+ getEvents(): Promise<Labrinth.Analytics.v3.AnalyticsEvent[]>;
41
+ /**
42
+ * Create an analytics event.
43
+ * POST /v3/analytics-event
44
+ */
45
+ createEvent(data: Labrinth.Analytics.v3.AnalyticsEventUpsert): Promise<Labrinth.Analytics.v3.AnalyticsEvent>;
46
+ /**
47
+ * Edit an analytics event.
48
+ * PATCH /v3/analytics-event/{id}
49
+ */
50
+ editEvent(id: Labrinth.Analytics.v3.AnalyticsEventId, data: Labrinth.Analytics.v3.AnalyticsEventUpsert): Promise<Labrinth.Analytics.v3.AnalyticsEvent>;
51
+ /**
52
+ * Delete an analytics event.
53
+ * DELETE /v3/analytics-event/{id}
54
+ */
55
+ deleteEvent(id: Labrinth.Analytics.v3.AnalyticsEventId): Promise<void>;
56
+ }
@@ -1,3 +1,4 @@
1
+ export * from './analytics/v3';
1
2
  export * from './auth/internal';
2
3
  export * from './auth/v2';
3
4
  export * from './billing/internal';
@@ -21,5 +22,6 @@ export * from './state';
21
22
  export * from './tech-review/internal';
22
23
  export * from './threads/v3';
23
24
  export * from './users/v2';
25
+ export * from './users/v3';
24
26
  export * from './versions/v2';
25
27
  export * from './versions/v3';
@@ -221,6 +221,209 @@ export declare namespace Labrinth {
221
221
  };
222
222
  }
223
223
  }
224
+ namespace Analytics {
225
+ namespace v3 {
226
+ type AnalyticsEventId = number;
227
+ type AnalyticsEventMetricKind = 'views' | 'revenue' | 'downloads' | 'playtime';
228
+ type AnalyticsEvent = {
229
+ announcement_url: string | null;
230
+ for_metric_kind: AnalyticsEventMetricKind[] | null;
231
+ title: string;
232
+ ends: string;
233
+ id: AnalyticsEventId;
234
+ starts: string;
235
+ };
236
+ type AnalyticsEventUpsert = {
237
+ announcement_url: string | null;
238
+ for_metric_kind: AnalyticsEventMetricKind[] | null;
239
+ title: string;
240
+ ends: string;
241
+ starts: string;
242
+ };
243
+ type FetchRequest = {
244
+ time_range: TimeRange;
245
+ return_metrics: ReturnMetrics;
246
+ project_ids?: string[];
247
+ };
248
+ type TimeRange = {
249
+ start: string;
250
+ end: string;
251
+ resolution: TimeRangeResolution;
252
+ };
253
+ type TimeRangeResolution = {
254
+ slices: number;
255
+ } | {
256
+ minutes: number;
257
+ };
258
+ type ReturnMetrics = {
259
+ project_views?: Metrics<ProjectViewsField, ProjectViewsFilters>;
260
+ project_downloads?: Metrics<ProjectDownloadsField, ProjectDownloadsFilters>;
261
+ project_playtime?: Metrics<ProjectPlaytimeField, ProjectPlaytimeFilters>;
262
+ project_revenue?: Metrics<ProjectRevenueField, ProjectRevenueFilters>;
263
+ affiliate_code_clicks?: Metrics<AffiliateCodeClicksField, AffiliateCodeClicksFilters>;
264
+ affiliate_code_conversions?: Metrics<AffiliateCodeConversionsField, AffiliateCodeConversionsFilters>;
265
+ affiliate_code_revenue?: Metrics<AffiliateCodeRevenueField, AffiliateCodeRevenueFilters>;
266
+ };
267
+ type Metrics<BucketBy, FilterBy> = {
268
+ bucket_by?: BucketBy[];
269
+ filter_by?: FilterBy;
270
+ };
271
+ type ProjectViewsField = 'project_id' | 'domain' | 'site_path' | 'monetized' | 'country';
272
+ type ProjectDownloadsField = 'project_id' | 'version_id' | 'user_agent' | 'domain' | 'country' | 'monetized' | 'reason' | 'game_version' | 'loader';
273
+ type ProjectPlaytimeField = 'project_id' | 'version_id' | 'loader' | 'game_version' | 'country';
274
+ type ProjectRevenueField = 'project_id';
275
+ type DownloadReason = 'standalone' | 'dependency' | 'modpack' | 'update';
276
+ type AffiliateCodeClicksField = 'affiliate_code_id';
277
+ type AffiliateCodeConversionsField = 'affiliate_code_id';
278
+ type AffiliateCodeRevenueField = 'affiliate_code_id';
279
+ type ProjectViewsFilters = {
280
+ domain?: string[];
281
+ site_path?: string[];
282
+ monetized?: boolean[];
283
+ country?: string[];
284
+ };
285
+ type ProjectDownloadsFilters = {
286
+ version_id?: string[];
287
+ domain?: string[];
288
+ user_agent?: string[];
289
+ monetized?: boolean[];
290
+ country?: string[];
291
+ reason?: DownloadReason[];
292
+ game_version?: string[];
293
+ loader?: string[];
294
+ };
295
+ type ProjectPlaytimeFilters = {
296
+ version_id?: string[];
297
+ loader?: string[];
298
+ game_version?: string[];
299
+ country?: string[];
300
+ };
301
+ type ProjectRevenueFilters = Record<string, never>;
302
+ type AffiliateCodeClicksFilters = {
303
+ affiliate_code_id?: string[];
304
+ };
305
+ type AffiliateCodeConversionsFilters = {
306
+ affiliate_code_id?: string[];
307
+ };
308
+ type AffiliateCodeRevenueFilters = {
309
+ affiliate_code_id?: string[];
310
+ };
311
+ type FetchResponse = {
312
+ metrics: TimeSlice[];
313
+ project_events: ProjectAnalyticsEvent[];
314
+ };
315
+ type FacetsResponse = {
316
+ facets: AnalyticsFacets;
317
+ };
318
+ type AnalyticsFacet<T> = {
319
+ value: T;
320
+ downloads: number;
321
+ };
322
+ type AnalyticsFacets = {
323
+ project_views: ProjectViewsFacets;
324
+ project_downloads: ProjectDownloadsFacets;
325
+ project_playtime: ProjectPlaytimeFacets;
326
+ };
327
+ type ProjectViewsFacets = {
328
+ domain: AnalyticsFacet<string>[];
329
+ site_path: AnalyticsFacet<string>[];
330
+ monetized: AnalyticsFacet<boolean>[];
331
+ country: AnalyticsFacet<string>[];
332
+ };
333
+ type ProjectDownloadsFacets = {
334
+ project_id: AnalyticsFacet<string>[];
335
+ domain: AnalyticsFacet<string>[];
336
+ user_agent: AnalyticsFacet<string>[];
337
+ version_id: AnalyticsFacet<string>[];
338
+ monetized: AnalyticsFacet<boolean>[];
339
+ country: AnalyticsFacet<string>[];
340
+ reason: AnalyticsFacet<DownloadReason>[];
341
+ game_version: AnalyticsFacet<string>[];
342
+ loader: AnalyticsFacet<string>[];
343
+ };
344
+ type ProjectPlaytimeFacets = {
345
+ version_id: AnalyticsFacet<string>[];
346
+ loader: AnalyticsFacet<string>[];
347
+ game_version: AnalyticsFacet<string>[];
348
+ country: AnalyticsFacet<string>[];
349
+ };
350
+ type TimeSlice = AnalyticsData[];
351
+ type ProjectAnalyticsEvent = {
352
+ project_id: string;
353
+ timestamp: string;
354
+ } & ProjectAnalyticsEventKind;
355
+ type ProjectAnalyticsEventKind = {
356
+ kind: 'version_uploaded';
357
+ version_id: string;
358
+ version_name: string;
359
+ version_number: string;
360
+ } | {
361
+ kind: 'status_changed';
362
+ status_from: Projects.v2.ProjectStatus;
363
+ status_to: Projects.v2.ProjectStatus;
364
+ };
365
+ type AnalyticsData = ProjectAnalytics | AffiliateCodeAnalytics;
366
+ type ProjectAnalytics = {
367
+ source_project: string;
368
+ } & ProjectMetrics;
369
+ type ProjectMetrics = ({
370
+ metric_kind: 'views';
371
+ } & ProjectViews) | ({
372
+ metric_kind: 'downloads';
373
+ } & ProjectDownloads) | ({
374
+ metric_kind: 'playtime';
375
+ } & ProjectPlaytime) | ({
376
+ metric_kind: 'revenue';
377
+ } & ProjectRevenue);
378
+ type ProjectViews = {
379
+ domain?: string;
380
+ site_path?: string;
381
+ monetized?: boolean;
382
+ country?: string;
383
+ views: number;
384
+ };
385
+ type ProjectDownloads = {
386
+ user_agent?: string;
387
+ domain?: string;
388
+ version_id?: string;
389
+ country?: string;
390
+ monetized?: boolean;
391
+ reason?: DownloadReason;
392
+ game_version?: string;
393
+ loader?: string;
394
+ downloads: number;
395
+ };
396
+ type ProjectPlaytime = {
397
+ version_id?: string;
398
+ loader?: string;
399
+ game_version?: string;
400
+ country?: string;
401
+ seconds: number;
402
+ };
403
+ type ProjectRevenue = {
404
+ revenue: string;
405
+ };
406
+ type AffiliateCodeAnalytics = {
407
+ source_affiliate_code: string;
408
+ } & AffiliateCodeMetrics;
409
+ type AffiliateCodeMetrics = ({
410
+ metric_kind: 'clicks';
411
+ } & AffiliateCodeClicks) | ({
412
+ metric_kind: 'conversions';
413
+ } & AffiliateCodeConversions) | ({
414
+ metric_kind: 'revenue';
415
+ } & AffiliateCodeRevenue);
416
+ type AffiliateCodeClicks = {
417
+ clicks: number;
418
+ };
419
+ type AffiliateCodeConversions = {
420
+ conversions: number;
421
+ };
422
+ type AffiliateCodeRevenue = {
423
+ revenue: string;
424
+ };
425
+ }
426
+ }
224
427
  namespace Auth {
225
428
  namespace Internal {
226
429
  type SubscriptionStatus = {
@@ -896,6 +1099,10 @@ export declare namespace Labrinth {
896
1099
  allow_friend_requests?: boolean;
897
1100
  github_id?: number;
898
1101
  };
1102
+ type AllProjectsResponse = {
1103
+ projects: Projects.v3.Project[];
1104
+ organizations: Record<string, Organizations.v3.Organization>;
1105
+ };
899
1106
  }
900
1107
  export {};
901
1108
  }
@@ -0,0 +1,14 @@
1
+ import { AbstractModule } from '../../../core/abstract-module';
2
+ import type { Labrinth } from '../types';
3
+ export declare class LabrinthUsersV3Module extends AbstractModule {
4
+ getModuleID(): string;
5
+ /**
6
+ * Get all projects the authenticated user can access directly or through
7
+ * their organizations.
8
+ *
9
+ * @param idOrUsername - User ID or username. Must be the authenticated user.
10
+ *
11
+ * GET /v3/user/{id}/all-projects
12
+ */
13
+ getAllProjects(idOrUsername: string): Promise<Labrinth.Users.v3.AllProjectsResponse>;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modrinth/api-client",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "An API client for Modrinth's API for use in nuxt, tauri and plain node/browser environments.",
5
5
  "license": "LGPL-3.0-only",
6
6
  "type": "module",