@undefineds.co/xpod 0.4.25 → 0.4.28

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.
Files changed (155) hide show
  1. package/dist/api/ApiServer.d.ts +1 -0
  2. package/dist/api/ApiServer.js +38 -0
  3. package/dist/api/ai-config/AiConfigStore.js +18 -6
  4. package/dist/api/ai-gateway/connect/index.d.ts +1 -0
  5. package/dist/api/ai-gateway/connect/index.js +39 -18
  6. package/dist/api/ai-gateway/models/ProviderModelsAdapter.js +5 -2
  7. package/dist/api/container/common.js +8 -2
  8. package/dist/api/container/index.js +2 -2
  9. package/dist/api/container/local.js +6 -3
  10. package/dist/api/handlers/AiGatewayHandler.d.ts +1 -0
  11. package/dist/api/handlers/AiGatewayHandler.js +53 -3
  12. package/dist/api/handlers/AiGatewayManagementHandler.js +9 -0
  13. package/dist/api/handlers/TaskHandler.js +15 -10
  14. package/dist/api/network/NetworkEnvironmentConfigurationStore.js +1 -1
  15. package/dist/api/runs/ManagedRunWorker.d.ts +0 -1
  16. package/dist/api/runs/ManagedRunWorker.js +2 -14
  17. package/dist/api/runs/PiAgentRuntimeDriver.d.ts +0 -8
  18. package/dist/api/runs/PiAgentRuntimeDriver.js +65 -21
  19. package/dist/api/runs/RunStateCenter.js +1 -0
  20. package/dist/api/runs/store.d.ts +1 -0
  21. package/dist/api/runs/store.js +13 -0
  22. package/dist/api/tasks/TaskMaterializer.js +13 -6
  23. package/dist/api/tasks/TaskResumeDiagnostics.d.ts +28 -0
  24. package/dist/api/tasks/TaskResumeDiagnostics.js +148 -0
  25. package/dist/api/tasks/TaskService.js +40 -23
  26. package/dist/storage/conditions/StorageETagHandler.d.ts +1 -1
  27. package/dist/storage/conditions/StorageETagHandler.js +13 -4
  28. package/dist/util/task-model-diagnostics.d.ts +67 -0
  29. package/dist/util/task-model-diagnostics.js +118 -0
  30. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.d.ts +1 -0
  31. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +2 -1
  32. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.d.ts +1 -0
  33. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +1 -0
  34. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +10 -10
  35. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +3 -1
  36. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.js +2 -2
  37. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +77 -23
  38. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +1 -0
  39. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +59 -59
  40. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +2 -0
  41. package/node_modules/@undefineds.co/ai-connections/dist/collections.js +14 -6
  42. package/node_modules/@undefineds.co/ai-connections/dist/contract/ai-connections-client.d.ts +2 -1
  43. package/node_modules/@undefineds.co/ai-connections/dist/contract/ai-connections-client.js +1 -0
  44. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/gateway-model-roles.d.ts +11 -0
  45. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/gateway-model-roles.js +11 -0
  46. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.d.ts +2 -1
  47. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.js +12 -5
  48. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/request.js +10 -2
  49. package/node_modules/@undefineds.co/ai-connections/dist/contract/client/types.d.ts +10 -0
  50. package/node_modules/@undefineds.co/ai-connections/package.json +1 -1
  51. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +1 -0
  52. package/node_modules/@undefineds.co/extension-sdk/package.json +1 -1
  53. package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +60 -13
  54. package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +16 -1
  55. package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +51 -0
  56. package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +14 -18
  57. package/node_modules/@undefineds.co/pod-collections/package.json +1 -1
  58. package/node_modules/@undefineds.co/shared-ui/dist/list.d.ts +8 -1
  59. package/node_modules/@undefineds.co/shared-ui/dist/list.js +4 -1
  60. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.d.ts +1 -1
  61. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.js +2 -2
  62. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpViews.js +2 -2
  63. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.d.ts +3 -3
  64. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.js +5 -5
  65. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.d.ts +5 -5
  66. package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.js +5 -5
  67. package/node_modules/@undefineds.co/shared-ui/dist/section-header.js +1 -1
  68. package/node_modules/@undefineds.co/shared-ui/dist/theme.css +5 -32
  69. package/node_modules/@undefineds.co/shared-ui/package.json +1 -1
  70. package/node_modules/@undefineds.co/solid-sdk/package.json +1 -1
  71. package/package.json +2 -2
  72. package/static/app/assets/main.css +1 -1
  73. package/static/app/assets/main.js +1 -1
  74. package/static/dashboard/assets/AccountAuthBoundary-Dv52SZc6.js +1 -0
  75. package/static/dashboard/assets/DesktopOidcCallback-DaT_Rumf.js +1 -0
  76. package/static/dashboard/assets/DevicePages-HjclpIVm.js +2 -0
  77. package/static/dashboard/assets/ModelsPage-Be2TPd-x.js +11 -0
  78. package/static/dashboard/assets/{PaneListHeader-Dn5O0mwy.js → PaneListHeader-DtvnRmFq.js} +1 -1
  79. package/static/dashboard/assets/{PodDeletionAuthorizationPanel-D3NOG6ZM.js → PodDeletionAuthorizationPanel-BJk_8rJq.js} +3 -3
  80. package/static/dashboard/assets/PodPage-C4gzEspV.js +1 -0
  81. package/static/dashboard/assets/{SystemSettingsPage-BNQP_Yuc.js → SystemSettingsPage-HaNrP1H1.js} +1 -1
  82. package/static/dashboard/assets/TasksPage-BdO5K2L7.js +1 -0
  83. package/static/dashboard/assets/{WebDesktopEntry-vnb4CZWp.js → WebDesktopEntry-Cj9_ZfJU.js} +1 -1
  84. package/static/dashboard/assets/XpodAiConnectionsPodStore-B7gmXBmC.js +3 -0
  85. package/static/dashboard/assets/XpodShellApp-D_KY4nCW.js +4 -0
  86. package/static/dashboard/assets/{account-session-DCUmCop1.js → account-session-DlcKNG7k.js} +1 -1
  87. package/static/dashboard/assets/{button-By5Bgvmb.js → button-wslF55uZ.js} +1 -1
  88. package/static/dashboard/assets/collection-runtime-uxxgEu13.js +1 -0
  89. package/static/dashboard/assets/{createLucideIcon-bunMzPms.js → createLucideIcon-BJQl82Qk.js} +1 -1
  90. package/static/dashboard/assets/dashboard-CbJ-JkrI.css +1 -0
  91. package/static/dashboard/assets/{dashboard-mlsg3yaw.js → dashboard-Or0gnkou.js} +2 -2
  92. package/static/dashboard/assets/index-BqFeOML9.js +1 -0
  93. package/static/dashboard/assets/{index-DvMG5pHk.js → index-DgKn1twH.js} +2 -2
  94. package/static/dashboard/assets/{label-Bj03L9xs.js → label-CS6Sx6Zb.js} +1 -1
  95. package/static/dashboard/assets/list-UyhlCFKk.js +1 -0
  96. package/static/dashboard/assets/{nav-item-style-BNqWQY6p.js → nav-item-style-CW1Nnorq.js} +1 -1
  97. package/static/dashboard/assets/{pod-collections-host-KnnGFZHL.js → pod-collections-host-DjK2xf-b.js} +6 -6
  98. package/static/dashboard/assets/{safe-continuation-D9AhcWiB.js → safe-continuation-ClWAhcma.js} +1 -1
  99. package/static/dashboard/assets/{section-header-CLCzbOp_.js → section-header-CEIEcco-.js} +1 -1
  100. package/static/dashboard/assets/{setting-row-DTCec8A2.js → setting-row-CaYv3dfF.js} +1 -1
  101. package/static/dashboard/assets/xpod-remembered-login-BUF9fin1.js +310 -0
  102. package/static/dashboard/dashboard.html +2 -2
  103. package/static/settings/assets/{AccountAuthBoundary-C0og_gIA.js → AccountAuthBoundary-Chqd38oU.js} +1 -1
  104. package/static/settings/assets/{DesktopOidcCallback-C5q4oFZ0.js → DesktopOidcCallback-VUrOSM_q.js} +1 -1
  105. package/static/settings/assets/DevicePages-C6qwvWwu.js +2 -0
  106. package/static/settings/assets/ModelsPage-Ry_dObRQ.js +11 -0
  107. package/static/settings/assets/{PaneListHeader-DqVlMe2D.js → PaneListHeader-B5RkRqr4.js} +1 -1
  108. package/static/settings/assets/{PodDeletionAuthorizationPanel-DgVvarVY.js → PodDeletionAuthorizationPanel-DPM-5Izt.js} +3 -3
  109. package/static/settings/assets/PodPage-CxND6wwc.js +1 -0
  110. package/static/settings/assets/{SystemSettingsPage-Crzm_DrI.js → SystemSettingsPage-C8EdMkW7.js} +1 -1
  111. package/static/settings/assets/TasksPage-DuqptEm8.js +1 -0
  112. package/static/settings/assets/{WebDesktopEntry-BGC5eRF2.js → WebDesktopEntry-BRcyktkv.js} +1 -1
  113. package/static/settings/assets/XpodAiConnectionsPodStore-CyA_BJVC.js +3 -0
  114. package/static/settings/assets/XpodShellApp-CsivHJl0.js +4 -0
  115. package/static/settings/assets/XpodThemeProvider-CbJ-JkrI.css +1 -0
  116. package/static/settings/assets/{XpodThemeProvider-CB6LepTA.js → XpodThemeProvider-DK3pIdRG.js} +2 -2
  117. package/static/settings/assets/{account-session-BcLjCj0x.js → account-session-DJOZ03xr.js} +1 -1
  118. package/static/settings/assets/auth-callback-GIBYEz_7.js +1 -0
  119. package/static/settings/assets/{button-BObT8pTE.js → button-D3yW-2o1.js} +1 -1
  120. package/static/settings/assets/collection-runtime-DfGo25mh.js +1 -0
  121. package/static/settings/assets/{createLucideIcon-BVsUxXpZ.js → createLucideIcon-CacwLsmB.js} +1 -1
  122. package/static/settings/assets/{index-ktjMkj7-.js → index-r5KRYsKC.js} +1 -1
  123. package/static/settings/assets/{label-BrqO8_m_.js → label-MJjUmvzG.js} +1 -1
  124. package/static/settings/assets/list-Ce-5k1MX.js +1 -0
  125. package/static/settings/assets/{nav-item-style-Di2CxkDU.js → nav-item-style-ZUbL8KOZ.js} +1 -1
  126. package/static/settings/assets/{pod-collections-host-KnnGFZHL.js → pod-collections-host-DjK2xf-b.js} +6 -6
  127. package/static/settings/assets/{safe-continuation-Dx6ceJpY.js → safe-continuation-vlBZFSlU.js} +1 -1
  128. package/static/settings/assets/{section-header-Dtl7yjVr.js → section-header-DGJdEvQw.js} +1 -1
  129. package/static/settings/assets/{setting-row-BL6Hhe8N.js → setting-row-C7tuFiho.js} +1 -1
  130. package/static/settings/assets/{settings-DaRBxoZk.js → settings-CyQPih1O.js} +1 -1
  131. package/static/settings/assets/xpod-remembered-login-D-TzzT5K.js +567 -0
  132. package/static/settings/auth-callback.html +3 -3
  133. package/static/settings/settings.html +3 -3
  134. package/static/dashboard/assets/AccountAuthBoundary-BvoDydRz.js +0 -1
  135. package/static/dashboard/assets/DesktopOidcCallback-BwIj874x.js +0 -1
  136. package/static/dashboard/assets/DevicePages-jOjMcvsr.js +0 -2
  137. package/static/dashboard/assets/ModelsPage-CMTdfqBR.js +0 -11
  138. package/static/dashboard/assets/PodPage-BueBdJ9_.js +0 -1
  139. package/static/dashboard/assets/TasksPage-CxtLJiSF.js +0 -1
  140. package/static/dashboard/assets/XpodAiConnectionsPodStore-wx3Ttupm.js +0 -18
  141. package/static/dashboard/assets/XpodShellApp-5FWY8-d5.js +0 -4
  142. package/static/dashboard/assets/collection-runtime-BnomuB0E.js +0 -1
  143. package/static/dashboard/assets/dashboard-C64R553B.css +0 -1
  144. package/static/dashboard/assets/xpod-remembered-login-Dr69A0Rv.js +0 -295
  145. package/static/settings/assets/DevicePages-fyHjjucT.js +0 -2
  146. package/static/settings/assets/ModelsPage-EyOByLyE.js +0 -11
  147. package/static/settings/assets/PodPage-DY4Oi9wg.js +0 -1
  148. package/static/settings/assets/TasksPage-CfXJbnlt.js +0 -1
  149. package/static/settings/assets/XpodAiConnectionsPodStore-CXcmgKmQ.js +0 -3
  150. package/static/settings/assets/XpodShellApp-D1PS3Iut.js +0 -4
  151. package/static/settings/assets/XpodThemeProvider-C64R553B.css +0 -1
  152. package/static/settings/assets/auth-callback-DSPQ28ar.js +0 -1
  153. package/static/settings/assets/collection-runtime-DzNbdZGe.js +0 -1
  154. package/static/settings/assets/index-browser-3WfrNbcG.js +0 -273
  155. package/static/settings/assets/xpod-remembered-login-Q66DH12t.js +0 -295
@@ -1,18 +0,0 @@
1
- import{ae as ic,ai as $e,aj as Pt,ak as at,al as Et,am as st,an as gl,ao as oc,a as _e,ap as tt,c as os}from"./xpod-remembered-login-Dr69A0Rv.js";import{QueryEngine as ac}from"@comunica/query-sparql-solid";import{g as wl}from"./dashboard-mlsg3yaw.js";const Tn=["openai","anthropic","kimi","bailian","deepseek","zhipu","ollama","custom"],ml={openai:"OpenAI",anthropic:"Anthropic",kimi:"Kimi",bailian:"百炼",deepseek:"DeepSeek",zhipu:"智谱 AI",ollama:"Ollama",custom:"Custom"},Sl=[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"]}],sc={id:"api-key",authMode:"apiKey",lifecycle:"active"},uc={id:"browser-login",authMode:"apiKey",connectMode:"browserAssistedApiKey",lifecycle:"active"},yr=[sc,uc],ln=[{id:"openai-compatible",label:"OpenAI Compatible",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],runtimeProviderIds:["custom"],consoleUrl:"https://undefineds.co",subscriptionUrl:"https://undefineds.co",endpoints:[{protocol:"chatCompletions",baseUrl:"https://example.invalid/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"unsupported",url:"https://undefineds.co"}},{id:"anthropic-compatible",label:"Anthropic Compatible",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],runtimeProviderIds:["custom"],consoleUrl:"https://undefineds.co",subscriptionUrl:"https://undefineds.co",endpoints:[{protocol:"anthropic",baseUrl:"https://example.invalid/v1"}],modelDiscovery:{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"unsupported",url:"https://undefineds.co"}}],as="https://www.kimi.com/code",lc="https://www.kimi.com/code/console",fc="https://www.kimi.com/user/agreement",cc="https://api.kimi.com/coding/v1",dc="https://api.kimi.com/coding/",hc="https://platform.moonshot.cn/console/api-keys",ss="https://platform.moonshot.cn/console/account",pc="https://platform.moonshot.cn/docs/intro",_c="https://api.moonshot.ai/v1",Wn="https://bailian.console.aliyun.com/",zn="https://help.aliyun.com/zh/model-studio/",us="https://open.bigmodel.cn/usercenter/apikeys",ls="https://open.bigmodel.cn/",yc="https://open.bigmodel.cn/api/paas/v4",bc="https://open.bigmodel.cn/api/coding/paas/v4",Al={openai:[{id:"official-subscription",label:"OpenAI Subscription",kind:"oauth-subscription",lifecycle:"unavailable",authModes:["oauth","local"],productLabel:"OpenAI",runtimeProviderIds:["openai"],credentialPrefixHints:[],consoleUrl:"https://chatgpt.com/codex",subscriptionUrl:"https://chatgpt.com/codex",endpoints:[{protocol:"responses",baseUrl:"https://chatgpt.com/backend-api/codex"}],modelDiscovery:{strategy:"unsupported",path:"/models",endpointProtocol:"responses"},quota:{strategy:"subscription",url:"https://chatgpt.com/codex"},usagePolicyUrl:"https://openai.com/policies/usage-policies/",region:"global"},{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:yr,productLabel:"OpenAI",runtimeProviderIds:["openai"],credentialPrefixHints:["sk-"],consoleUrl:"https://platform.openai.com/api-keys",subscriptionUrl:"https://platform.openai.com/settings/organization/billing/overview",endpoints:[{protocol:"responses",baseUrl:"https://api.openai.com/v1"},{protocol:"chatCompletions",baseUrl:"https://api.openai.com/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"responses"},quota:{strategy:"providerApi",url:"https://platform.openai.com/usage"},usagePolicyUrl:"https://openai.com/policies/usage-policies/",region:"global"}],anthropic:[{id:"official-subscription",label:"Claude Pro / Max",kind:"oauth-subscription",lifecycle:"unavailable",authModes:["oauth"],authorizationMethods:[],productLabel:"Claude Code",runtimeProviderIds:["anthropic"],credentialPrefixHints:[],consoleUrl:"https://claude.ai/",subscriptionUrl:"https://claude.com/pricing",endpoints:[],modelDiscovery:{strategy:"unsupported",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"subscription",url:"https://claude.ai/settings/usage"},usagePolicyUrl:"https://www.anthropic.com/legal/aup",region:"global"},{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:yr,productLabel:"Anthropic",runtimeProviderIds:["anthropic"],credentialPrefixHints:["sk-ant-"],consoleUrl:"https://console.anthropic.com/settings/keys",subscriptionUrl:"https://console.anthropic.com/settings/plans",endpoints:[{protocol:"anthropic",baseUrl:"https://api.anthropic.com/v1"}],modelDiscovery:{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"console",url:"https://console.anthropic.com/settings/limits"},usagePolicyUrl:"https://www.anthropic.com/legal/aup",region:"global"}],kimi:[fs({id:"subscription-key",label:"Token Plan",kind:"token-plan",authModes:["apiKey"],productLabel:"Kimi Coding",runtimeProviderIds:["kimi"],credentialPrefixHints:["sk-kimi-"],baseUrl:cc,anthropicBaseUrl:dc,quotaStrategy:"subscription",quotaUrl:as,consoleUrl:lc,subscriptionUrl:as,usagePolicyUrl:fc,supportsDeveloperMessages:!1}),fs({id:"api-platform",label:"API Platform",kind:"api-platform",authModes:["apiKey"],productLabel:"Moonshot AI",runtimeProviderIds:["kimi"],credentialPrefixHints:["sk-"],baseUrl:_c,quotaStrategy:"console",quotaUrl:ss,consoleUrl:hc,subscriptionUrl:ss,usagePolicyUrl:pc})],bailian:[Bn({id:"pay-as-you-go",label:"Pay as You Go",kind:"api-platform",runtimeProviderIds:["bailian"],credentialPrefixHints:["sk-"],region:"cn",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://dashscope.aliyuncs.com/apps/anthropic",quotaStrategy:"console",consoleUrl:Wn,usagePolicyUrl:zn}),Bn({id:"token-plan",label:"Token Plan Personal",kind:"token-plan",runtimeProviderIds:["bailian-token-plan"],credentialPrefixHints:["sk-"],region:"cn-beijing",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:Wn,usagePolicyUrl:zn}),Bn({id:"token-plan-team",label:"Token Plan Team",kind:"token-plan",runtimeProviderIds:["bailian-token-plan"],credentialPrefixHints:["sk-"],region:"cn-beijing",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:Wn,usagePolicyUrl:zn}),Bn({id:"coding-plan",label:"Coding Plan Pro",kind:"token-plan",runtimeProviderIds:["bailian-coding-plan"],credentialPrefixHints:["sk-sp-"],region:"cn",baseUrl:"https://coding.dashscope.aliyuncs.com/v1",anthropicBaseUrl:"https://coding.dashscope.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:Wn,usagePolicyUrl:zn})],deepseek:[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],productLabel:"DeepSeek",runtimeProviderIds:["deepseek"],credentialPrefixHints:["sk-"],consoleUrl:"https://platform.deepseek.com/api_keys",subscriptionUrl:"https://platform.deepseek.com/usage",endpoints:[{protocol:"chatCompletions",baseUrl:"https://api.deepseek.com/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"console",url:"https://platform.deepseek.com/usage"},usagePolicyUrl:"https://cdn.deepseek.com/policies/en-US/deepseek-open-platform-terms-of-use.html",region:"global"}],ollama:[{id:"local",label:"Local Ollama",kind:"local",lifecycle:"active",authModes:["local"],productLabel:"Ollama",runtimeProviderIds:["ollama"],credentialPrefixHints:[],consoleUrl:"https://ollama.com",subscriptionUrl:"https://ollama.com",endpoints:[{protocol:"chatCompletions",baseUrl:"http://localhost:11434/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"unsupported",url:"https://ollama.com"},usagePolicyUrl:"https://ollama.com",region:"local"}],zhipu:[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:yr,productLabel:"智谱 AI",runtimeProviderIds:["zhipu"],credentialPrefixHints:["id."],consoleUrl:us,subscriptionUrl:"https://open.bigmodel.cn/finance-center/expense-manage",endpoints:[{protocol:"chatCompletions",baseUrl:yc,region:"cn"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"console",url:"https://open.bigmodel.cn/finance-center/expense-manage"},usagePolicyUrl:ls,region:"cn"},{id:"coding-plan",label:"GLM Coding Plan",kind:"token-plan",lifecycle:"active",authModes:["apiKey"],authorizationMethods:yr,productLabel:"智谱 AI",runtimeProviderIds:["zhipu"],credentialPrefixHints:["id."],consoleUrl:us,subscriptionUrl:"https://bigmodel.cn/glm-coding",endpoints:[{protocol:"chatCompletions",baseUrl:bc,region:"cn"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"subscription",url:"https://bigmodel.cn/glm-coding"},usagePolicyUrl:ls,region:"cn"}]};function fs(e){return{id:e.id,label:e.label,kind:e.kind,lifecycle:"active",authModes:e.authModes,authorizationMethods:yr,productLabel:e.productLabel,runtimeProviderIds:e.runtimeProviderIds,credentialPrefixHints:e.credentialPrefixHints,consoleUrl:e.consoleUrl,subscriptionUrl:e.subscriptionUrl,endpoints:El(e.baseUrl,e.anthropicBaseUrl,"cn",e.supportsDeveloperMessages),modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:e.quotaStrategy,url:e.quotaUrl},usagePolicyUrl:e.usagePolicyUrl,region:"cn"}}function Bn(e){return{id:e.id,label:e.label,lifecycle:"active",productLabel:"Alibaba Bailian",kind:e.kind,authModes:["apiKey"],authorizationMethods:yr,runtimeProviderIds:e.runtimeProviderIds,credentialPrefixHints:e.credentialPrefixHints,consoleUrl:e.consoleUrl,subscriptionUrl:e.consoleUrl,endpoints:El(e.baseUrl,e.anthropicBaseUrl,e.region),modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:e.quotaStrategy,url:e.consoleUrl},usagePolicyUrl:e.usagePolicyUrl,region:e.region}}function El(e,t,r,n){return[{protocol:"chatCompletions",baseUrl:e,region:r,...n===void 0?{}:{supportsDeveloperMessages:n}},...t?[{protocol:"anthropic",baseUrl:t,region:r}]:[]]}function vl(e,t=!1){return(Al[e]??Sl).map(r=>e==="openai"&&r.id==="official-subscription"&&t?{...r,lifecycle:"active",authModes:Array.from(new Set([...r.authModes??[],"local"])),authorizationMethods:[{id:"device-code",authMode:"deviceCode",connectMode:"deviceCodeOAuth",lifecycle:"active"},{id:"local-session-import",authMode:"local",lifecycle:"active"}]}:{...r})}const Cp=Tn.flatMap(e=>[e,...gc(e).map(t=>`${e}-${t.id}`)]);function gc(e){return e==="custom"?ln:Al[e]??Sl}function wc(e,t){return e==="anthropic"||t==="anthropic-compatible"?"anthropic":"openai"}function bn(e,t){return e==="openai"&&(t==="local"||t==="oauth"||t==="deviceCode")?"official-subscription":e==="kimi"&&(t==="oauth"||t==="deviceCode")?"subscription-key":e==="bailian"?"pay-as-you-go":e==="ollama"?"local":e==="custom"?"openai-compatible":"api-platform"}function cs(e,t){const r=vl(e).find(i=>i.id===(t??bn(e,"apiKey")));if(!r)return;const n=r.modelDiscovery?.endpointProtocol;return r.endpoints?.find(i=>i.protocol===n)?.baseUrl??r.endpoints?.[0]?.baseUrl}function Kn(e,t){const r=t.trim().toLowerCase();if(e==="bailian"){if(r==="token-plan-personal")return"token-plan";if(r==="coding-plan-pro")return"coding-plan"}return r}function Hn(e){return{offeringId:e.offeringId,priority:e.priority??100,enabled:e.enabled??!0,health:e.health??"unknown",...e.baseUrl?{baseUrl:e.baseUrl}:{}}}function Lp(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{throw new Error("invalid_proxy_url")}if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.hash)throw new Error("invalid_proxy_url");if(!t.hostname)throw new Error("invalid_proxy_url");return t.href.replace(/\/$/u,"")}class ai extends Error{constructor(t,r,n={}){const i=Rl(t);super(i?`AI Connection request failed: ${i}`:`AI Connection request failed (HTTP ${r})`),this.name="AiConnectionsRequestError",this.code=i,this.status=r,this.providerStatus=Ie(t)&&typeof t.providerStatus=="number"?t.providerStatus:void 0,this.payload=t,this.provider=n.provider,this.authMode=n.authMode}}function Rl(e){if(Ie(e)){if(typeof e.code=="string")return e.code;if(typeof e.errorCode=="string")return e.errorCode;if(typeof e.error=="string"&&/^[a-z][a-z0-9_:-]{0,80}$/i.test(e.error))return e.error}}async function ds(e){const t=await e.text();if(t)try{return JSON.parse(t)}catch{throw new Error(`AI Connection returned invalid JSON (${e.status})`)}}function mc(e){if(!Tn.includes(e))throw new Error(`Unsupported AI provider: ${e}`)}function Ui(e){if(!(!Ie(e)||typeof e.id!="string"||typeof e.owner!="string"||!Array.isArray(e.scopes)||!e.scopes.every(t=>typeof t=="string")||typeof e.createdAt!="string"))return Me({id:e.id,kind:e.kind==="client-credentials"?e.kind:void 0,credentialResource:fe(e.credentialResource),fingerprint:fe(e.fingerprint),owner:e.owner,scopes:e.scopes,createdAt:e.createdAt,expiresAt:fe(e.expiresAt),lastUsedAt:fe(e.lastUsedAt),disabledAt:fe(e.disabledAt),revokedAt:fe(e.revokedAt),name:fe(e.name),maskedHint:fe(e.maskedHint),plaintextAvailable:typeof e.plaintextAvailable=="boolean"?e.plaintextAvailable:void 0,clientCredentialId:fe(e.clientCredentialId),appliedTo:fe(e.appliedTo),appliedOn:fe(e.appliedOn),appliedAt:fe(e.appliedAt),appliedClients:br(e.appliedClients)})}function hs(e){if(!Array.isArray(e))throw new Error("AI Connection returned an invalid custom models response");const t=[];for(const r of e)!Ie(r)||typeof r.id!="string"||!r.id||t.push(Me({id:r.id,displayName:fe(r.displayName),inputModalities:br(r.inputModalities),outputModalities:br(r.outputModalities),capabilities:br(r.capabilities)}));return t}function br(e){if(!Array.isArray(e))return;const t=e.filter(r=>typeof r=="string");return t.length>0?t:void 0}function Il(e){if(!Ie(e)||typeof e.id!="string"||Ac(e.id))return;const t=At(e.provider)??At(e.providerId)??At(e.owned_by)??Ec(e.id);if(!t)return;const r=Ie(e.capabilities)?e.capabilities.imageInput:void 0;return Me({id:e.id,provider:t,offeringId:fe(e.offeringId),resourceId:fe(e.resourceId),displayName:fe(e.displayName)??fe(e.display_name)??fe(e.name),modelType:typeof e.modelType=="string"&&Object.prototype.hasOwnProperty.call(ic,e.modelType)?e.modelType:void 0,contextWindow:Yo(e.contextWindow)??Yo(e.context_window),dimension:typeof e.dimension=="number"&&Number.isInteger(e.dimension)&&e.dimension>0?e.dimension:void 0,protocols:Array.isArray(e.protocols)?e.protocols.filter(n=>typeof n=="string"):void 0,custom:e.custom===!0?!0:void 0,inputModalities:ps(e.modalities,"input")??(r===!0?["text","image"]:r===!1?["text"]:void 0),outputModalities:ps(e.modalities,"output"),capabilities:Sc(e)})}function ps(e,t){if(!Ie(e))return;const r=e[t];if(!Array.isArray(r))return;const n=r.filter(i=>typeof i=="string");return n.length>0?n:void 0}function Sc(e){if(Array.isArray(e.custom_capabilities)){const r=e.custom_capabilities.filter(n=>typeof n=="string");if(r.length>0)return r}if(!Ie(e.capabilities))return;const t=[];return e.capabilities.imageInput===!0&&t.push("image"),e.capabilities.toolCalls===!0&&t.push("tool_call"),e.capabilities.reasoningEffort===!0&&t.push("reasoning"),e.capabilities.fast===!0&&t.push("fast"),e.capabilities.embedding===!0&&t.push("embedding"),t.length>0?t:void 0}function Ac(e){const t=e.toLowerCase();return t==="linx"||t==="linx-lite"||t==="undefineds/linx"||t==="undefineds/linx-lite"}function At(e){if(typeof e!="string")return;const t=e.toLowerCase().trim();return t==="alibaba"||t==="dashscope"||t==="alibaba-bailian"||t==="bailian-coding-plan"||t==="bailian-token-plan"?"bailian":Tn.includes(t)?t:void 0}function Ec(e){const t=e.split("/",1)[0];return e.includes("/")?At(t):void 0}function Yo(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function vc(e){const t=new Map;for(const r of e){const n=Rc(r);if(!n)continue;const i=t.get(n.id);t.set(n.id,i?xc(i,n):n)}return[...t.values()]}function Rc(e){return Tc(e)??Ic(e)}function Ic(e){if(!Ie(e)||typeof e.provider!="string"||!Jc(e.status)||!Ie(e.connect)||!Array.isArray(e.connect.modes)||!e.connect.modes.every(fa)||typeof e.connect.configured!="boolean")return;const t=At(e.provider);if(!t)return;const r=Uc(e,t);return{id:t,name:Dl(t),offerings:[],credentials:r?[r]:[],selectedModels:[],status:$c(e.status)}}function Tc(e){if(!Ie(e))return;const t=At(e.id)??At(e.provider);if(!t||!zc(e.status))return;const r=kt(e.offerings,Oc),n=kt(e.credentials,fn),i=kt(e.selectedModels,Il);return{id:t,name:fe(e.name)??Dl(t),offerings:r,credentials:n,selectedModels:i,status:e.status}}function Oc(e){if(!Ie(e)||typeof e.id!="string"||!e.id)return;const t=kt(e.authModes,Cl);return Me({id:e.id,label:fe(e.label),kind:fe(e.kind),lifecycle:Cc(e.lifecycle),authModes:t,authorizationMethods:kt(e.authorizationMethods,Tl),runtimeProviderIds:br(e.runtimeProviderIds),productLabel:fe(e.productLabel),credentialPrefixHints:br(e.credentialPrefixHints),consoleUrl:fe(e.consoleUrl),subscriptionUrl:fe(e.subscriptionUrl),endpoints:kt(e.endpoints,Ol),modelDiscovery:Lc(e.modelDiscovery),quota:Dc(e.quota),usagePolicyUrl:fe(e.usagePolicyUrl),region:fe(e.region)})}function Mc(e){if(!Ie(e)||typeof e.offeringId!="string"||!e.offeringId)return;const t=At(e.provider);if(!t)return;const r=kt(e.authorizationMethods,Tl);return{provider:t,offeringId:e.offeringId,...Array.isArray(e.endpoints)?{endpoints:kt(e.endpoints,Ol)}:{},authorizationMethods:r}}function Tl(e){if(!Ie(e)||typeof e.id!="string"||!e.id)return;const t=Cl(e.authMode),r=Pc(e.lifecycle);if(!t||!r)return;const n=fa(e.connectMode)?e.connectMode:void 0;return Me({id:e.id,authMode:t,connectMode:n,label:fe(e.label),lifecycle:r,reason:fe(e.reason)})}function Pc(e){return e==="active"||e==="unavailable"?e:void 0}function Cc(e){return e==="active"||e==="legacy"||e==="unavailable"?e:void 0}function Ol(e){if(!Ie(e))return;const t=fe(e.protocol),r=fe(e.baseUrl);if(!(!t||!r))return Me({protocol:t,baseUrl:r,region:fe(e.region)})}function Lc(e){if(!Ie(e))return;const t=fe(e.strategy),r=fe(e.path),n=fe(e.endpointProtocol);return t&&r&&n?{strategy:t,path:r,endpointProtocol:n}:void 0}function Dc(e){if(!Ie(e))return;const t=fe(e.strategy),r=fe(e.url);return t&&r?{strategy:t,url:r}:void 0}function fn(e){if(!(!Ie(e)||typeof e.id!="string"||!e.id||typeof e.offeringId!="string"||!e.offeringId||!Ll(e.authMode)||typeof e.enabled!="boolean"||typeof e.priority!="number"||!Number.isFinite(e.priority)||!Wc(e.health)||typeof e.version!="number"||!Number.isFinite(e.version)))return Me({id:e.id,provider:At(e.provider),offeringId:e.offeringId,authMode:e.authMode,label:fe(e.label),enabled:e.enabled,priority:e.priority,health:e.health,maskedHint:fe(e.maskedHint),baseUrl:fe(e.baseUrl),proxyUrl:fe(e.proxyUrl),expiresAt:fe(e.expiresAt),lastFailureCode:fe(e.lastFailureCode),lastFailureAt:fe(e.lastFailureAt),rateLimitResetAt:fe(e.rateLimitResetAt),failCount:Yo(e.failCount),version:e.version})}function Ml(e){return Ie(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!kc(t)).map(([t,r])=>[t,Pl(r)])):{}}function Pl(e){return Array.isArray(e)?e.map(Pl):Ie(e)?Ml(e):e}function kc(e){const t=e.toLocaleLowerCase();return t.includes("secret")||t.includes("token")||t.includes("apikey")||t==="api_key"||t==="key"||t==="authorization"}function xc(e,t){const r=ji([...e.credentials,...t.credentials],o=>o.id),n=ji([...e.offerings,...t.offerings],o=>o.id),i=ji([...e.selectedModels,...t.selectedModels],Nc);return{id:e.id,name:e.name??t.name,offerings:n,credentials:r,selectedModels:i,status:qc(e.status,t.status)}}function Nc(e){return e.resourceId??`${e.provider}:${e.offeringId??""}:${e.id}`}function $c(e){return e==="connected"?"available":e==="reauthRequired"?"attention":"unconfigured"}function qc(e,t){return e==="available"||t==="available"?"available":e==="attention"||t==="attention"?"attention":e==="configured"||t==="configured"?"configured":e==="unconfigured"||t==="unconfigured"?"unconfigured":"unavailable"}function Uc(e,t){if(e.status==="disconnected")return;const r=jc(e.authMode);return Me({id:fe(e.credentialIri)??`${t}:current`,offeringId:Fc(t,r),authMode:r,label:fe(e.accountLabel),enabled:e.status==="connected",priority:0,health:e.status==="reauthRequired"||e.reauthRequired===!0?"expired":"healthy",maskedHint:fe(e.maskedHint),baseUrl:fe(e.baseUrl),proxyUrl:fe(e.proxyUrl),expiresAt:fe(e.expiresAt),version:typeof e.version=="number"?e.version:0})}function jc(e){return e==="deviceCodeOAuth"?"deviceCode":"apiKey"}function Fc(e,t){return e==="kimi"&&(t==="deviceCode"||t==="oauth")?"subscription-key":t==="deviceCode"||t==="oauth"?"official-subscription":"api-platform"}function Cl(e){return Ll(e)?e:void 0}function Ll(e){return e==="oauth"||e==="deviceCode"||e==="apiKey"||e==="local"}function Wc(e){return e==="healthy"||e==="expired"||e==="invalid"||e==="unknown"}function zc(e){return e==="unconfigured"||e==="configured"||e==="available"||e==="attention"||e==="unavailable"}function kt(e,t){return Array.isArray(e)?e.map(t).filter(gn):[]}function ji(e,t){const r=new Set,n=[];for(const i of e){const o=t(i);r.has(o)||(r.add(o),n.push(i))}return n}function Dl(e){return ml[e]}function Bc(e){if(!Ie(e)||typeof e.id!="string"||typeof e.credentialIri!="string"||typeof e.webId!="string"||typeof e.provider!="string"||typeof e.authMode!="string"||typeof e.status!="string")return;const t=At(e.provider);if(t)return Me({id:e.id,credentialIri:e.credentialIri,webId:e.webId,provider:t,authMode:e.authMode,status:e.status,accountLabel:fe(e.accountLabel),expiresAt:fe(e.expiresAt),version:typeof e.version=="number"?e.version:void 0,reauthRequired:typeof e.reauthRequired=="boolean"?e.reauthRequired:void 0})}function Kc(e,t){if(!Ie(e)||!fa(e.mode)||!Yc(e.status)||e.provider!==t)throw new Error("AI Connection returned an invalid Connect response");return Me({mode:e.mode,status:e.status,provider:t,attemptId:fe(e.attemptId),state:fe(e.state),signature:fe(e.signature),expiresAt:fe(e.expiresAt),authorizationUrl:Fi(e.authorizationUrl),userCode:fe(e.userCode),verificationUri:Fi(e.verificationUri),verificationUriComplete:Fi(e.verificationUriComplete),intervalSeconds:typeof e.intervalSeconds=="number"?e.intervalSeconds:void 0,apiKeyManagementSupported:typeof e.apiKeyManagementSupported=="boolean"?e.apiKeyManagementSupported:void 0,credentialId:fe(e.credentialId),offeringId:fe(e.offeringId),authorizationMethodId:fe(e.authorizationMethodId),oauthCredential:Hc(e.oauthCredential),message:fe(e.message)})}function Hc(e){if(e!==void 0){if(!Ie(e)||typeof e.accessToken!="string"||!e.accessToken||typeof e.refreshToken!="string"||!e.refreshToken)throw new Error("AI Connection returned an invalid OAuth credential payload");return Me({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:fe(e.expiresAt),scope:fe(e.scope),idToken:fe(e.idToken),accountSubject:fe(e.accountSubject),accountId:fe(e.accountId),accountLabel:fe(e.accountLabel),offeringId:fe(e.offeringId),authorizationMethodId:fe(e.authorizationMethodId),expectedVersion:typeof e.expectedVersion=="number"?e.expectedVersion:void 0})}}function Gc(e,t){if(!Ie(e)||!Array.isArray(e.models))throw new Error("AI Connection returned an invalid model discovery response");const r=e.models.map(n=>{if(!Ie(n)||typeof n.id!="string"||!n.id)return;const i=Array.isArray(n.capabilities)?n.capabilities.filter(a=>typeof a=="string"):void 0,o=Vc(n.modelType);return Me({id:n.id,displayName:fe(n.displayName),capabilities:i??(o==="embedding"?["embedding"]:void 0),modelType:o})}).filter(gn);return{provider:t,credential:typeof e.credential=="string"?e.credential:"",models:r,observedAt:typeof e.observedAt=="string"?e.observedAt:new Date(0).toISOString(),source:typeof e.source=="string"?e.source:""}}function Me(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Vc(e){return e==="chat"||e==="embedding"?e:void 0}function fe(e){return typeof e=="string"?e:void 0}function Fi(e){if(typeof e=="string")try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:void 0}catch{return}}function fa(e){return e==="browserAssistedApiKey"||e==="deviceCodeOAuth"||e==="authorizationCodeOAuth"||e==="connectUnsupported"}function Yc(e){return e==="pending"||e==="authorization_pending"||e==="slow_down"||e==="completed"||e==="expired"||e==="cancelled"||e==="unsupported"}function Jc(e){return e==="connected"||e==="disconnected"||e==="reauthRequired"}function Ie(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function gn(e){return e!==void 0}function ca(e){const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error("Current Pod URL must use HTTP or HTTPS");return t.origin}function Qc({webId:e,podBaseUrl:t,authenticatedFetch:r}){const n=ca(t),i=async(l,c,p,g={})=>{const S=await r(`${n}${l}`,{method:c,credentials:"omit",mode:"cors",headers:{accept:"application/json",...p?{"content-type":"application/json"}:{}},...p?{body:JSON.stringify(p)}:{}}),O=await ds(S);if(!S.ok)throw new ai(O,S.status,g);return O},o=l=>(mc(l),`/api/ai/gateway/providers/${l}`),a=async(l,c,p,g)=>{const S=await i(`${o(l)}${c}`,p,g,{provider:l});return Kc(S,l)},s=async()=>{const l=await i("/v1/models","GET");return Array.isArray(l.data)?l.data.map(Il).filter(gn):[]};return{webId:e,apiBase:n,getServiceAccess(){return i("/api/applets/service-access/ai-connections","GET")},async listProviders(){const l=await i("/api/ai/providers","GET");return Array.isArray(l.data)?vc(l.data):[]},async listAuthorizationMethods(){const l=await r(`${n}/api/ai/connections/authorization-methods`,{method:"GET",credentials:"omit",mode:"cors",headers:{accept:"application/json"}});if(l.status===404)return[];const c=await ds(l);if(!l.ok)throw new ai(c,l.status);return Ie(c)&&Array.isArray(c.data)?c.data.map(Mc).filter(gn):[]},listModels:s,listGatewayModels:s,async listGatewayKeys(){const l=await i("/api/ai/gateway/keys","GET");return Array.isArray(l.data)?l.data.map(Ui).filter(gn):[]},async createGatewayKey(l){const c=await i("/api/ai/gateway/keys","POST",Me(l));if(typeof c.key!="string"||!c.key)throw new Error("Xpod did not return the new API Key");const p=Ui(c.record);if(!p)throw new Error("Xpod returned an invalid API Key record");return{plaintext:c.key,record:p}},async updateGatewayKey(l,c){const p=await i(`/api/ai/gateway/keys/${encodeURIComponent(l)}`,"PATCH",c),g=Ui(p.record);if(!g)throw new Error("Xpod returned an invalid API Key record");return g},async deleteGatewayKey(l){await i(`/api/ai/gateway/keys/${encodeURIComponent(l)}`,"DELETE")},async beginConnect(l,c,p){return await a(l,"/connect/begin","POST",Me({mode:c,offeringId:p?.offeringId,authorizationMethodId:p?.authorizationMethodId}))},connectStatus(l,c){if(!c.attemptId)throw new Error("Connect attempt id is required");const p=new URLSearchParams({state:c.state??"",signature:c.signature??""});return c.mode&&p.set("mode",c.mode),a(l,`/connect/status/${encodeURIComponent(c.attemptId)}?${p}`,"GET")},completeApiKey(l,c,p,g,S){return a(l,"/connect/complete-api-key","POST",Me({attemptId:c.attemptId,state:c.state,signature:c.signature,offeringId:c.offeringId,apiKey:p,accountLabel:g,baseUrl:S}))},pollDevice(l,c){return a(l,"/connect/poll","POST",Me({mode:c.mode,attemptId:c.attemptId,state:c.state,signature:c.signature,offeringId:c.offeringId}))},cancelConnect(l,c){return a(l,"/connect/cancel","POST",Me({mode:c.mode,attemptId:c.attemptId,state:c.state,signature:c.signature,offeringId:c.offeringId}))},refreshOAuthCredential(l,c,p,g,S,O){return a(l,"/connect/refresh","POST",{credentialId:c,refreshToken:p,expectedVersion:g,...S?{offeringId:S}:{},...O?{mode:O}:{}})},async disconnect(l,c){const p=c?`?${new URLSearchParams({credentialId:c})}`:"",g=await i(`${o(l)}/connect${p}`,"DELETE");return Bc(g.record)},async createApiKeyCredential(l,c){const p=await i(`/api/ai/providers/${l}/credentials/api-key`,"POST",Me({...c}),{provider:l}),g=fn(p.credential);if(!g)throw new Error("AI Connection returned an invalid Provider credential");return g},async createLocalCredential(l,c){const p=await i(`/api/ai/providers/${l}/credentials/local`,"POST",Me(c),{provider:l}),g=fn(p.credential);if(!g)throw new Error("AI Connection returned an invalid Provider credential");return g},async updateProviderCredential(l,c,p){const g=await i(`/api/ai/providers/${l}/credentials/${encodeURIComponent(c)}`,"PATCH",Me({...p}),{provider:l}),S=fn(g.credential);if(!S)throw new Error("AI Connection returned an invalid Provider credential");return S},async deleteProviderCredential(l,c){const p=await i(`/api/ai/providers/${l}/credentials/${encodeURIComponent(c)}`,"DELETE",void 0,{provider:l});return fn(p.credential)},async testProviderCredential(l,c){const p=await i(`/api/ai/providers/${l}/credentials/test`,"POST",Me({...c}),{provider:l});return Ml(p.result)},quota(l,c=!1,p){const g=!c&&p?.credentialIri?`?credentialIri=${encodeURIComponent(p.credentialIri)}${p.offeringId?`&offeringId=${encodeURIComponent(p.offeringId)}`:""}`:"";return i(`${o(l)}/quota/${c?"refresh":"status"}${g}`,c?"POST":"GET",c?Me({offeringId:p?.offeringId,credentialId:p?.credentialId,credentialIri:p?.credentialIri}):void 0,{provider:l})},quotaFromSecret(l,c){return i(`${o(l)}/quota/refresh`,"POST",Me(c),{provider:l})},async discoverModels(l,c){const p=await i(`${o(l)}/models/refresh`,"POST",Me({...c}),{provider:l,authMode:c?.authMode});return Gc(p,l)},async saveProviderModel(l,c){const p=await i(o(l)+"/models","POST",Me({id:c.id,displayName:c.displayName,inputModalities:c.inputModalities,outputModalities:c.outputModalities,capabilities:c.capabilities}),{provider:l});return hs(p.data)},async deleteProviderModel(l,c){const p=await i(`${o(l)}/models/${encodeURIComponent(c)}`,"DELETE",void 0,{provider:l});return hs(p.data)}}}function Xc(e){const t=new TextEncoder().encode(JSON.stringify(e));let r="";for(const n of t)r+=String.fromCharCode(n);return btoa(r)}function Zc(e){const t=atob(e),r=Uint8Array.from(t,n=>n.charCodeAt(0));return JSON.parse(new TextDecoder().decode(r))}function ed(e){return JSON.stringify({algorithm:"PLAINTEXT",encoding:"base64",ciphertext:Xc(e.secret),webId:e.webId,credentialIri:e.credentialIri,provider:e.provider})}function td(e){if(!(typeof e.envelope!="string"||!e.envelope.trim()))try{const t=JSON.parse(e.envelope);if(t.algorithm!=="PLAINTEXT"||t.webId!==e.webId||t.provider!==e.provider||t.credentialIri!==e.credentialIri)return;const r=t.encoding==="base64"?Zc(String(t.ciphertext)):JSON.parse(String(t.ciphertext));return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}catch{return}}function rd(e){return $e.buildId({id:e})}function nd(e){return $e.buildId({id:`custom-instance-${encodeURIComponent(e)}.ttl#this`})}function _s(e,t){const r=crypto.randomUUID();return t==="local"?`${e}-local-${r}`:`${e}-${r}`}function Dp(e){const t=(e.split("#",1)[0]??e).split("/").filter(Boolean).at(-1)??"",r=t.endsWith(".ttl")?t.slice(0,-4):t;if(r)return r.startsWith("custom-")||r==="custom"?"custom":Tn.find(n=>r===n||r.startsWith(`${n}-`))}function ur(e){if(!e)return;const t=e.split("#",1)[0]??e,r=t.split("/").filter(Boolean).at(-1)??t;if(!r)return;const n=r.endsWith(".ttl")?r:`${r}.ttl`,i=e.indexOf("#");return i<0?n:`${n}${e.slice(i)}`}function xt(e){const t=ur(e);if(t)return(t.split("#",1)[0]??t).replace(/\.ttl$/u,"")}const kl="AI Connection request failed. Please try again.";function Gn(e){return typeof e=="object"&&e!==null}const xl="订阅登录态自动刷新失败,请稍后重试。",Nl="订阅登录态已失效,请在原客户端重新登录后重读,或使用设备码登录。",$l="模型服务请求超时。请检查网络或代理设置,稍后重试同步模型。",ql="订阅登录态不可用,请重读登录态或重新登录后再同步模型。",Ul=new Set([$l,ql,xl,Nl,"密钥不可用。请检查密钥是否填写正确,或换一个密钥后重试。","模型服务地址不正确。请检查服务地址后重试。","请求太频繁。请稍等一会儿再试。","模型服务暂时没有响应。请稍后重试。","模型列表获取失败。请检查密钥、服务地址或网络后重试。"]);function ys(e){if(e.startsWith("provider_models_response_error:"))return da(e.slice(31))??"模型列表获取失败。请检查密钥、服务地址或网络后重试。";const t=si(e);if(t)return t;const r=e.split(":",1)[0]?.trim(),n=r?si(r):void 0;return n||(e==="AI Connection service identity is unavailable"||Ul.has(e)||ud(e)?e:e.startsWith("invalid_")?"AI Connection returned an invalid response.":kl)}function id(e){return e instanceof ai?od(e.payload,e.status,{provider:e.provider,authMode:e.authMode}):e instanceof Error?ys(e.message):ys(String(e))}function od(e,t,r={}){const n=Rl(e);if(n==="provider_models_response_error"){const a=Gn(e)&&typeof e.message=="string"?da(e.message):void 0;return a||"模型列表获取失败。请检查密钥、服务地址或网络后重试。"}if(n==="provider_models_fetch_failed"){const a=Gn(e)&&typeof e.providerStatus=="number"?e.providerStatus:void 0,s=Gn(e)&&typeof e.providerMessage=="string"?e.providerMessage.trim():void 0;return sd(ad(a,r.authMode),s)}const i=n?si(n,r.provider):void 0;if(i)return i;const o=Gn(e)&&typeof e.error=="string"?e.error:void 0;if(o){const a=si(o,r.provider);if(a)return a;if(o==="AI Connection service identity is unavailable")return o;if(o==="Provider credential not found for current identity")return"当前身份没有可用的额度凭证。";if(o==="Provider quota adapter not found"||o==="Provider quota lookup failed")return"该接入方式不支持查询官方额度。"}return t===401?"Please sign in again to continue.":t===403?"AI Connection permission was denied.":t===404&&r.provider?`${Jo(r.provider)} connection is not configured.`:t===429?"AI Connection is rate limited. Please try again later.":t===503?"AI Connection service is unavailable.":kl}function si(e,t){switch(e.trim().toLowerCase().replace(/-/g,"_")){case"not_configured":case"notconfigured":return t?`${Jo(t)} connection is not configured.`:"AI provider connection is not configured.";case"unsupported":return t?`${Jo(t)} does not support this operation.`:"This AI Connection operation is not supported.";case"service_access_missing":case"pod_interface_key_missing":case"pod_interface_key_rejected":case"caller_dpop_replay_unsupported":return"Xpod 尚未获准访问这个 Pod,请到 Pod 的授权应用中允许 Xpod 访问。";case"unauthorized":return"Please sign in again to continue.";case"forbidden":case"permission_denied":return"AI Connection permission was denied.";case"rate_limited":return"AI Connection is rate limited. Please try again later.";case"service_unavailable":return"AI Connection service is unavailable.";case"unsafe_provider_base_url":return"该服务地址指向 Xpod 不允许访问的网络,请改用公网 HTTPS 地址。";case"provider_request_timeout":return $l;case"invalid_proxy_url":return"代理地址必须是无账号密码的 HTTP 或 HTTPS 地址。";case"oauth_refresh_failed":case"oauth_refresh_unavailable":case"local_session_refresh_failed":return xl;case"oauth_session_reauth_required":case"oauth_refresh_token_required":case"local_session_reauth_required":case"local_session_missing_refresh_token":return Nl;case"models_persistence_failed":return"模型已获取,但保存到 Pod 失败。请重试同步模型。";case"quota_credential_not_found":return"当前身份没有可用的额度凭证。";case"credential_secret_unavailable":return"当前凭证密钥不可用,请重新保存后再查询额度。";case"gateway_api_key_plaintext_unavailable":return"Pod 中未找到此 API Key 的原文,无法复制配置。请创建新的 Key,更新客户端后再删除旧 Key。";case"quota_adapter_not_found":return"该接入方式不支持查询官方额度。";default:return}}function ad(e,t){return e===401||e===403?t==="deviceCodeOAuth"?ql:"密钥不可用。请检查密钥是否填写正确,或换一个密钥后重试。":e===404?"模型服务地址不正确。请检查服务地址后重试。":e===429?"请求太频繁。请稍等一会儿再试。":e!==void 0&&e>=500?"模型服务暂时没有响应。请稍后重试。":"模型列表获取失败。请检查密钥、服务地址或网络后重试。"}function sd(e,t){const r=t?da(t):void 0;return r?`${e} 上游返回:${r}`:e}function ud(e){const r=e.indexOf(" 上游返回:");return r<=0?!1:Ul.has(e.slice(0,r))}function da(e){return e.replace(/[\u0000-\u001f\u007f]/gu," ").replace(/\bBearer\s+[^\s,;]+/giu,"Bearer [REDACTED]").replace(/(?:sk|id)[._-][A-Za-z0-9._-]{8,}/gu,"[REDACTED]").replace(/https?:\/\/[^\s]+/giu,"[URL]").trim().slice(0,240)||void 0}function Jo(e){switch(e){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"kimi":return"Kimi";case"bailian":return"Bailian";case"deepseek":return"DeepSeek";case"zhipu":return"Zhipu";case"ollama":return"Ollama";case"custom":return"Custom"}}function ld(e){const t={...e};for(const[r,n]of Object.entries(e))typeof n=="function"&&(t[r]=async(...i)=>{try{return await n.apply(e,i)}catch(o){throw o instanceof ai&&(o.message=id(o)),o}});return t}const fd={"api-key":"添加 API Key","browser-login":"打开控制台","browser-oauth":"浏览器登录","device-code":"设备码登录","local-session-import":"已有登录态","local-service":"本地服务"};function cd(e){return e.label??fd[e.id]}function kp(e){return e.map(t=>{const r=cd(t);return r===t.label?t:{...t,label:r}})}function ui(e){return ml[e]}const dd=3e4;function xp({webId:e,podUrl:t,authenticatedFetch:r}){return ld(Qc({webId:e,podBaseUrl:t,authenticatedFetch:hd(r)}))}function hd(e){return(async(t,r)=>Qo(await e(t,r)))}function pd({podUrl:e,authenticatedFetch:t,invocationFetch:r=t,now:n=()=>new Date,invocationSelector:i=gd}){const o=ca(e);let a,s;const l=async(S,O)=>{const x=await t(S,O);return a=await bd(x.clone(),i),x},c=async()=>{if(md(a,n()))return a;if(s)return s;s=p();try{return await s}finally{s=void 0}},p=async()=>{if(!(await l(`${o}/api/applets/service-access/ai-connections`,{method:"GET",credentials:"include",headers:{accept:"application/json"}})).ok)throw new Error("AI Connection request failed. Please try again.");const O=a;if(!O?.token)throw new Error("AI Connection request failed. Please try again.");return O},g=async(S,O)=>{const x=await c(),v=Sd(x);if(!v)throw new Error("AI Connection request failed. Please try again.");const w=new Headers(O?.headers);return w.set("Authorization",`Bearer ${v}`),r(S,{...O,credentials:"omit",headers:w})};return(async(S,O)=>{if(_d(S,o))return l(S,O);if(!yd(S,o))return t(S,O);const x=await g(S,O);if(x.status!==401)return Qo(x);await x.arrayBuffer(),a=void 0;const v=await g(S,O);return Qo(v)})}function Np({podUrl:e,controlPlaneOrigin:t,authenticatedFetch:r,invocationFetch:n,now:i}){const o=ca(e),a=n??r,l=pd({podUrl:e,authenticatedFetch:r,invocationFetch:(c,p)=>{const g=new URL(c instanceof Request?c.url:String(c),o);if(t&&g.origin===o&&g.pathname.startsWith("/api/ai/client-configuration/")){const S=new URL(`${g.pathname}${g.search}`,t);return a(c instanceof Request?new Request(S,c):S.href,p)}return a(c,p)},now:i,invocationSelector:wd});return{inspect:async c=>{const p=await l(pr(o,c),{method:"GET",credentials:"omit",headers:{accept:"application/json"}});return p.status===403||p.status===404||p.status===503?(await p.arrayBuffer(),bs()):_r(p)},plan:async c=>_r(await l(`${pr(o,c.client)}/plan`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({endpoint:t?new URL(t).origin:c.endpoint,...c.activeModels!==void 0?{activeModels:c.activeModels}:{}})})),apply:async c=>_r(await l(`${pr(o,c.client)}/apply`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:c.planId,apiKey:c.apiKey,confirmation:c.confirmation})})),verify:async c=>_r(await l(`${pr(o,c.client)}/verify`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:c.planId})})),launch:async c=>_r(await l(`${pr(o,c)}/launch`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({})})),restore:async c=>{const p=await l(`${pr(o,c)}/restore`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({})});return p.status===403||p.status===404||p.status===503?(await p.arrayBuffer(),bs()):_r(p)}}}function _d(e,t){try{const r=new URL(String(e),t),n=new URL(t);return r.origin===n.origin&&r.pathname==="/api/applets/service-access/ai-connections"}catch{return!1}}function yd(e,t){try{const r=new URL(String(e),t),n=new URL(t);return r.origin===n.origin&&(r.pathname.startsWith("/api/ai/")||r.pathname.startsWith("/v1/"))}catch{return!1}}async function bd(e,t){if(!(!e.ok||!e.headers.get("content-type")?.includes("application/json")))try{const r=await e.json();return Ad(t(r))}catch{return}}function gd(e){return e.invocation}function wd(e){const t=e.aiClientConfiguration;return pi(t)?t.invocation:void 0}function md(e,t){if(!e?.token)return!1;if(!e.expiresAt)return!0;const r=Date.parse(e.expiresAt);return Number.isFinite(r)&&r-t.getTime()>dd}function Sd(e){return e?.token}function Ad(e){if(!pi(e))return;const t=["gateway","Key"].join("");return{token:typeof e.token=="string"?e.token:typeof e.apiKey=="string"?e.apiKey:typeof e[t]=="string"?e[t]:void 0,baseUrl:typeof e.baseUrl=="string"?e.baseUrl:void 0,expiresAt:typeof e.expiresAt=="string"?e.expiresAt:void 0}}async function Qo(e){return e.ok?e:e.headers.get("content-type")?.includes("application/json")?vd(e):(await e.arrayBuffer(),new Response(JSON.stringify({error:"internal_error"}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}))}function pr(e,t){return`${e}/api/ai/client-configuration/${encodeURIComponent(t)}`}async function _r(e){if(!e.ok)throw await Ed(e);if(!e.headers.get("content-type")?.includes("application/json"))throw await e.arrayBuffer(),new Error("AI client configuration request failed. Please try again.");return await e.json()}async function Ed(e){let t;try{t=e.headers.get("content-type")?.includes("application/json")?await e.json():void 0}catch{t=void 0}if(pi(t)){const r=typeof t.code=="string"?t.code:typeof t.error=="string"?t.error:void 0,n=typeof t.message=="string"?t.message:"AI client configuration request failed. Please try again.",i=new Error(n);return i.code=r,i.status=e.status,i.details=t.details,i}return await e.arrayBuffer().catch(()=>{}),new Error("AI client configuration request failed. Please try again.")}function bs(){return{status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."}}async function vd(e){let t;try{t=await e.clone().json()}catch{return e}const r=Id(t);return r?new Response(JSON.stringify({code:r}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}):Rd(t)?new Response(JSON.stringify({code:t.error.code,error:t.error.message}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}):e}function Rd(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e.error;return!!(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.code=="string"&&typeof t.message=="string"&&typeof t.status=="number")}function Id(e){if(!(!pi(e)||typeof e.error!="string")&&e.error==="Gateway API Key plaintext is not available")return"gateway_api_key_plaintext_unavailable"}function pi(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}var Qt={},Kr={},Xt={},Zt={};var li="@@__IMMUTABLE_INDEXED__@@";function it(e){return!!(e&&e[li])}var fi="@@__IMMUTABLE_KEYED__@@";function Re(e){return!!(e&&e[fi])}function _i(e){return Re(e)||it(e)}var jl="@@__IMMUTABLE_ITERABLE__@@";function ot(e){return!!(e&&e[jl])}var je=function(t){return ot(t)?t:Ke(t)},_t=(function(e){function t(r){return Re(r)?r:Wt(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t})(je),lr=(function(e){function t(r){return it(r)?r:bt(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t})(je),Or=(function(e){function t(r){return ot(r)&&!_i(r)?r:Lr(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t})(je);je.Keyed=_t;je.Indexed=lr;je.Set=Or;var Mr=0,dt=1,ht=2,Xo=typeof Symbol=="function"&&Symbol.iterator,Fl="@@iterator",yi=Xo||Fl,ye=function(t){this.next=t};ye.prototype.toString=function(){return"[Iterator]"};ye.KEYS=Mr;ye.VALUES=dt;ye.ENTRIES=ht;ye.prototype.inspect=ye.prototype.toSource=function(){return this.toString()};ye.prototype[yi]=function(){return this};function Pe(e,t,r,n){var i=e===Mr?t:e===dt?r:[t,r];return n?n.value=i:n={value:i,done:!1},n}function Be(){return{value:void 0,done:!0}}function ha(e){return Array.isArray(e)?!0:!!bi(e)}function gs(e){return!!(e&&typeof e.next=="function")}function Zo(e){var t=bi(e);return t&&t.call(e)}function bi(e){var t=e&&(Xo&&e[Xo]||e[Fl]);if(typeof t=="function")return t}function Td(e){var t=bi(e);return t&&t===e.entries}function Od(e){var t=bi(e);return t&&t===e.keys}var On="delete",ve=5,ct=1<<ve,Qe=ct-1,pe={};function ea(){return{value:!1}}function pt(e){e&&(e.value=!0)}function pa(){}function mr(e){return e.size===void 0&&(e.size=e.__iterate(Wl)),e.size}function $t(e,t){if(typeof t!="number"){var r=t>>>0;if(""+r!==t||r===4294967295)return NaN;t=r}return t<0?mr(e)+t:t}function Wl(){return!0}function Mn(e,t,r){return(e===0&&!Bl(e)||r!==void 0&&e<=-r)&&(t===void 0||r!==void 0&&t>=r)}function Pr(e,t){return zl(e,t,0)}function Pn(e,t){return zl(e,t,t)}function zl(e,t,r){return e===void 0?r:Bl(e)?t===1/0?t:Math.max(0,t+e)|0:t===void 0||t===e?e:Math.min(t,e)|0}function Bl(e){return e<0||e===0&&1/e===-1/0}var Kl="@@__IMMUTABLE_RECORD__@@";function Ft(e){return!!(e&&e[Kl])}function yt(e){return ot(e)||Ft(e)}var qt="@@__IMMUTABLE_ORDERED__@@";function wt(e){return!!(e&&e[qt])}var Hl="@@__IMMUTABLE_SEQ__@@";function gi(e){return!!(e&&e[Hl])}var Cr=Object.prototype.hasOwnProperty;function _a(e){return Array.isArray(e)||typeof e=="string"?!0:e&&typeof e=="object"&&Number.isInteger(e.length)&&e.length>=0&&(e.length===0?Object.keys(e).length===1:e.hasOwnProperty(e.length-1))}var Ke=(function(e){function t(r){return r==null?ba():yt(r)?r.toSeq():Pd(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq {","}")},t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},t.prototype.__iterate=function(n,i){var o=this._cache;if(o){for(var a=o.length,s=0;s!==a;){var l=o[i?a-++s:s++];if(n(l[1],l[0],this)===!1)break}return s}return this.__iterateUncached(n,i)},t.prototype.__iterator=function(n,i){var o=this._cache;if(o){var a=o.length,s=0;return new ye(function(){if(s===a)return Be();var l=o[i?a-++s:s++];return Pe(n,l[0],l[1])})}return this.__iteratorUncached(n,i)},t})(je),Wt=(function(e){function t(r){return r==null?ba().toKeyedSeq():ot(r)?Re(r)?r.toSeq():r.fromEntrySeq():Ft(r)?r.toSeq():ga(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toKeyedSeq=function(){return this},t})(Ke),bt=(function(e){function t(r){return r==null?ba():ot(r)?Re(r)?r.entrySeq():r.toIndexedSeq():Ft(r)?r.toSeq().entrySeq():Gl(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t})(Ke),Lr=(function(e){function t(r){return(ot(r)&&!_i(r)?r:bt(r)).toSetSeq()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t})(Ke);Ke.isSeq=gi;Ke.Keyed=Wt;Ke.Set=Lr;Ke.Indexed=bt;Ke.prototype[Hl]=!0;var Sr=(function(e){function t(r){this._array=r,this.size=r.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,i){return this.has(n)?this._array[$t(this,n)]:i},t.prototype.__iterate=function(n,i){for(var o=this._array,a=o.length,s=0;s!==a;){var l=i?a-++s:s++;if(n(o[l],l,this)===!1)break}return s},t.prototype.__iterator=function(n,i){var o=this._array,a=o.length,s=0;return new ye(function(){if(s===a)return Be();var l=i?a-++s:s++;return Pe(n,l,o[l])})},t})(bt),ya=(function(e){function t(r){var n=Object.keys(r).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r):[]);this._object=r,this._keys=n,this.size=n.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,i){return i!==void 0&&!this.has(n)?i:this._object[n]},t.prototype.has=function(n){return Cr.call(this._object,n)},t.prototype.__iterate=function(n,i){for(var o=this._object,a=this._keys,s=a.length,l=0;l!==s;){var c=a[i?s-++l:l++];if(n(o[c],c,this)===!1)break}return l},t.prototype.__iterator=function(n,i){var o=this._object,a=this._keys,s=a.length,l=0;return new ye(function(){if(l===s)return Be();var c=a[i?s-++l:l++];return Pe(n,c,o[c])})},t})(Wt);ya.prototype[qt]=!0;var Md=(function(e){function t(r){this._collection=r,this.size=r.length||r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(n,i){if(i)return this.cacheResult().__iterate(n,i);var o=this._collection,a=Zo(o),s=0;if(gs(a))for(var l;!(l=a.next()).done&&n(l.value,s++,this)!==!1;);return s},t.prototype.__iteratorUncached=function(n,i){if(i)return this.cacheResult().__iterator(n,i);var o=this._collection,a=Zo(o);if(!gs(a))return new ye(Be);var s=0;return new ye(function(){var l=a.next();return l.done?l:Pe(n,s++,l.value)})},t})(bt),ws;function ba(){return ws||(ws=new Sr([]))}function ga(e){var t=wa(e);if(t)return t.fromEntrySeq();if(typeof e=="object")return new ya(e);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+e)}function Gl(e){var t=wa(e);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+e)}function Pd(e){var t=wa(e);if(t)return Td(e)?t.fromEntrySeq():Od(e)?t.toSetSeq():t;if(typeof e=="object")return new ya(e);throw new TypeError("Expected Array or collection object of values, or keyed object: "+e)}function wa(e){return _a(e)?new Sr(e):ha(e)?new Md(e):void 0}function Cn(){return this.__ensureOwner()}function Ln(){return this.__ownerID?this:this.__ensureOwner(new pa)}var Hr=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var n=t&65535,i=r&65535;return n*i+((t>>>16)*i+n*(r>>>16)<<16>>>0)|0};function wi(e){return e>>>1&1073741824|e&3221225471}var Cd=Object.prototype.valueOf;function Je(e){if(e==null)return ms(e);if(typeof e.hashCode=="function")return wi(e.hashCode(e));var t=qd(e);if(t==null)return ms(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return Ld(t);case"string":return t.length>Ud?Dd(t):ta(t);case"object":case"function":return Nd(t);case"symbol":return xd(t);default:if(typeof t.toString=="function")return ta(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function ms(e){return e===null?1108378658:1108378659}function Ld(e){if(e!==e||e===1/0)return 0;var t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)e/=4294967295,t^=e;return wi(t)}function Dd(e){var t=Bi[e];return t===void 0&&(t=ta(e),zi===jd&&(zi=0,Bi={}),zi++,Bi[e]=t),t}function ta(e){for(var t=0,r=0;r<e.length;r++)t=31*t+e.charCodeAt(r)|0;return wi(t)}var kd=(Math.random()*1048576|1)%1048576||40503;function ma(e){if(typeof e!="string")return Je(e);for(var t=0,r=0;r<e.length;r++)t=kd*t+e.charCodeAt(r)|0;return t}function xd(e){var t=Es[e];return t!==void 0||(t=Vl(),Es[e]=t),t}function Nd(e){var t;if(ra&&(t=na.get(e),t!==void 0)||(t=e[or],t!==void 0)||!As&&(t=e.propertyIsEnumerable&&e.propertyIsEnumerable[or],t!==void 0||(t=$d(e),t!==void 0)))return t;if(t=Vl(),ra)na.set(e,t);else{if(Ss!==void 0&&Ss(e)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(As)Object.defineProperty(e,or,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(e.propertyIsEnumerable!==void 0&&e.propertyIsEnumerable===e.constructor.prototype.propertyIsEnumerable)e.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},e.propertyIsEnumerable[or]=t;else if(e.nodeType!==void 0)e[or]=t;else throw new Error("Unable to set a non-enumerable property on object.")}return t}var Ss=Object.isExtensible,As=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function $d(e){if(e&&e.nodeType>0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}function qd(e){return e.valueOf!==Cd&&typeof e.valueOf=="function"?e.valueOf(e):e}function Vl(){var e=++Wi;return Wi&1073741824&&(Wi=0),e}var ra=typeof WeakMap=="function",na;ra&&(na=new WeakMap);var Es=Object.create(null),Wi=0,or="__immutablehash__";typeof Symbol=="function"&&(or=Symbol(or));var Ud=16,jd=255,zi=0,Bi={},mi=(function(e){function t(r,n){this._iter=r,this._useKeys=n,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,i){return this._iter.get(n,i)},t.prototype.has=function(n){return this._iter.has(n)},t.prototype.valueSeq=function(){return this._iter.valueSeq()},t.prototype.reverse=function(){var n=this,i=Sa(this,!0);return this._useKeys||(i.valueSeq=function(){return n._iter.toSeq().reverse()}),i},t.prototype.map=function(n,i){var o=this,a=Zl(this,n,i);return this._useKeys||(a.valueSeq=function(){return o._iter.toSeq().map(n,i)}),a},t.prototype.__iterate=function(n,i){var o=this;return this._iter.__iterate(function(a,s){return n(a,s,o)},i)},t.prototype.__iterator=function(n,i){return this._iter.__iterator(n,i)},t})(Wt);mi.prototype[qt]=!0;var Yl=(function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.includes=function(n){return this._iter.includes(n)},t.prototype.__iterate=function(n,i){var o=this,a=0;return i&&mr(this),this._iter.__iterate(function(s){return n(s,i?o.size-++a:a++,o)},i)},t.prototype.__iterator=function(n,i){var o=this,a=this._iter.__iterator(dt,i),s=0;return i&&mr(this),new ye(function(){var l=a.next();return l.done?l:Pe(n,i?o.size-++s:s++,l.value,l)})},t})(bt),Jl=(function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.has=function(n){return this._iter.includes(n)},t.prototype.__iterate=function(n,i){var o=this;return this._iter.__iterate(function(a){return n(a,a,o)},i)},t.prototype.__iterator=function(n,i){var o=this._iter.__iterator(dt,i);return new ye(function(){var a=o.next();return a.done?a:Pe(n,a.value,a.value,a)})},t})(Lr),Ql=(function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.entrySeq=function(){return this._iter.toSeq()},t.prototype.__iterate=function(n,i){var o=this;return this._iter.__iterate(function(a){if(a){Rs(a);var s=ot(a);return n(s?a.get(1):a[1],s?a.get(0):a[0],o)}},i)},t.prototype.__iterator=function(n,i){var o=this._iter.__iterator(dt,i);return new ye(function(){for(;;){var a=o.next();if(a.done)return a;var s=a.value;if(s){Rs(s);var l=ot(s);return Pe(n,l?s.get(0):s[0],l?s.get(1):s[1],a)}}})},t})(Wt);Yl.prototype.cacheResult=mi.prototype.cacheResult=Jl.prototype.cacheResult=Ql.prototype.cacheResult=va;function Xl(e){var t=Rt(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var r=e.reverse.apply(this);return r.flip=function(){return e.reverse()},r},t.has=function(r){return e.includes(r)},t.includes=function(r){return e.has(r)},t.cacheResult=va,t.__iterateUncached=function(r,n){var i=this;return e.__iterate(function(o,a){return r(a,o,i)!==!1},n)},t.__iteratorUncached=function(r,n){if(r===ht){var i=e.__iterator(r,n);return new ye(function(){var o=i.next();if(!o.done){var a=o.value[0];o.value[0]=o.value[1],o.value[1]=a}return o})}return e.__iterator(r===dt?Mr:dt,n)},t}function Zl(e,t,r){var n=Rt(e);return n.size=e.size,n.has=function(i){return e.has(i)},n.get=function(i,o){var a=e.get(i,pe);return a===pe?o:t.call(r,a,i,e)},n.__iterateUncached=function(i,o){var a=this;return e.__iterate(function(s,l,c){return i(t.call(r,s,l,c),l,a)!==!1},o)},n.__iteratorUncached=function(i,o){var a=e.__iterator(ht,o);return new ye(function(){var s=a.next();if(s.done)return s;var l=s.value,c=l[0];return Pe(i,c,t.call(r,l[1],c,e),s)})},n}function Sa(e,t){var r=Rt(e);return r._iter=e,r.size=e.size,r.reverse=function(){return e},e.flip&&(r.flip=function(){var n=Xl(e);return n.reverse=function(){return e.flip()},n}),r.get=function(n,i){return e.get(t?n:-1-n,i)},r.has=function(n){return e.has(t?n:-1-n)},r.includes=function(n){return e.includes(n)},r.cacheResult=va,r.__iterate=function(n,i){var o=this,a=0;return i&&mr(e),e.__iterate(function(s,l){return n(s,t?l:i?o.size-++a:a++,o)},!i)},r.__iterator=function(n,i){var o=0;i&&mr(e);var a=e.__iterator(ht,!i);return new ye(function(){var s=a.next();if(s.done)return s;var l=s.value;return Pe(n,t?l[0]:i?r.size-++o:o++,l[1],s)})},r}function ef(e,t,r,n){var i=Rt(e);return n&&(i.has=function(o){var a=e.get(o,pe);return a!==pe&&!!t.call(r,a,o,e)},i.get=function(o,a){var s=e.get(o,pe);return s!==pe&&t.call(r,s,o,e)?s:a}),i.__iterateUncached=function(o,a){var s=this,l=0;return e.__iterate(function(c,p,g){if(t.call(r,c,p,g))return l++,o(c,n?p:l-1,s)},a),l},i.__iteratorUncached=function(o,a){var s=e.__iterator(ht,a),l=0;return new ye(function(){for(;;){var c=s.next();if(c.done)return c;var p=c.value,g=p[0],S=p[1];if(t.call(r,S,g,e))return Pe(o,n?g:l++,S,c)}})},i}function Fd(e,t,r){var n=fr().asMutable();return e.__iterate(function(i,o){n.update(t.call(r,i,o,e),0,function(a){return a+1})}),n.asImmutable()}function Wd(e,t,r){var n=Re(e),i=(wt(e)?vt():fr()).asMutable();e.__iterate(function(a,s){i.update(t.call(r,a,s,e),function(l){return l=l||[],l.push(n?[s,a]:a),l})});var o=Ea(e);return i.map(function(a){return Ee(e,o(a))}).asImmutable()}function zd(e,t,r){var n=Re(e),i=[[],[]];e.__iterate(function(a,s){i[t.call(r,a,s,e)?1:0].push(n?[s,a]:a)});var o=Ea(e);return i.map(function(a){return Ee(e,o(a))})}function Aa(e,t,r,n){var i=e.size;if(Mn(t,r,i))return e;if(typeof i>"u"&&(t<0||r<0))return Aa(e.toSeq().cacheResult(),t,r,n);var o=Pr(t,i),a=Pn(r,i),s=a-o,l;s===s&&(l=s<0?0:s);var c=Rt(e);return c.size=l===0?l:e.size&&l||void 0,!n&&gi(e)&&l>=0&&(c.get=function(p,g){return p=$t(this,p),p>=0&&p<l?e.get(p+o,g):g}),c.__iterateUncached=function(p,g){var S=this;if(l===0)return 0;if(g)return this.cacheResult().__iterate(p,g);var O=0,x=!0,v=0;return e.__iterate(function(w,P){if(!(x&&(x=O++<o)))return v++,p(w,n?P:v-1,S)!==!1&&v!==l}),v},c.__iteratorUncached=function(p,g){if(l!==0&&g)return this.cacheResult().__iterator(p,g);if(l===0)return new ye(Be);var S=e.__iterator(p,g),O=0,x=0;return new ye(function(){for(;O++<o;)S.next();if(++x>l)return Be();var v=S.next();return n||p===dt||v.done?v:p===Mr?Pe(p,x-1,void 0,v):Pe(p,x-1,v.value[1],v)})},c}function Bd(e,t,r){var n=Rt(e);return n.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=0;return e.__iterate(function(l,c,p){return t.call(r,l,c,p)&&++s&&i(l,c,a)}),s},n.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(ht,o),l=!0;return new ye(function(){if(!l)return Be();var c=s.next();if(c.done)return c;var p=c.value,g=p[0],S=p[1];return t.call(r,S,g,a)?i===ht?c:Pe(i,g,S,c):(l=!1,Be())})},n}function tf(e,t,r,n){var i=Rt(e);return i.__iterateUncached=function(o,a){var s=this;if(a)return this.cacheResult().__iterate(o,a);var l=!0,c=0;return e.__iterate(function(p,g,S){if(!(l&&(l=t.call(r,p,g,S))))return c++,o(p,n?g:c-1,s)}),c},i.__iteratorUncached=function(o,a){var s=this;if(a)return this.cacheResult().__iterator(o,a);var l=e.__iterator(ht,a),c=!0,p=0;return new ye(function(){var g,S,O;do{if(g=l.next(),g.done)return n||o===dt?g:o===Mr?Pe(o,p++,void 0,g):Pe(o,p++,g.value[1],g);var x=g.value;S=x[0],O=x[1],c&&(c=t.call(r,O,S,s))}while(c);return o===ht?g:Pe(o,S,O,g)})},i}var Kd=(function(e){function t(r){this._wrappedIterables=r.flatMap(function(n){return n._wrappedIterables?n._wrappedIterables:[n]}),this.size=this._wrappedIterables.reduce(function(n,i){if(n!==void 0){var o=i.size;if(o!==void 0)return n+o}},0),this[fi]=this._wrappedIterables[0][fi],this[li]=this._wrappedIterables[0][li],this[qt]=this._wrappedIterables[0][qt]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(n,i){if(this._wrappedIterables.length!==0){if(i)return this.cacheResult().__iterate(n,i);for(var o=0,a=Re(this),s=a?ht:dt,l=this._wrappedIterables[o].__iterator(s,i),c=!0,p=0;c;){for(var g=l.next();g.done;){if(o++,o===this._wrappedIterables.length)return p;l=this._wrappedIterables[o].__iterator(s,i),g=l.next()}var S=a?n(g.value[1],g.value[0],this):n(g.value,p,this);c=S!==!1,p++}return p}},t.prototype.__iteratorUncached=function(n,i){var o=this;if(this._wrappedIterables.length===0)return new ye(Be);if(i)return this.cacheResult().__iterator(n,i);var a=0,s=this._wrappedIterables[a].__iterator(n,i);return new ye(function(){for(var l=s.next();l.done;){if(a++,a===o._wrappedIterables.length)return l;s=o._wrappedIterables[a].__iterator(n,i),l=s.next()}return l})},t})(Ke);function Hd(e,t){var r=Re(e),n=[e].concat(t).map(function(o){return ot(o)?r&&(o=_t(o)):o=r?ga(o):Gl(Array.isArray(o)?o:[o]),o}).filter(function(o){return o.size!==0});if(n.length===0)return e;if(n.length===1){var i=n[0];if(i===e||r&&Re(i)||it(e)&&it(i))return i}return new Kd(n)}function rf(e,t,r){var n=Rt(e);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var a=0,s=!1;function l(c,p){c.__iterate(function(g,S){return(!t||p<t)&&ot(g)?l(g,p+1):(a++,i(g,r?S:a-1,n)===!1&&(s=!0)),!s},o)}return l(e,0),a},n.__iteratorUncached=function(i,o){if(o)return this.cacheResult().__iterator(i,o);var a=e.__iterator(i,o),s=[],l=0;return new ye(function(){for(;a;){var c=a.next();if(c.done!==!1){a=s.pop();continue}var p=c.value;if(i===ht&&(p=p[1]),(!t||s.length<t)&&ot(p))s.push(a),a=p.__iterator(i,o);else return r?c:Pe(i,l++,p,c)}return Be()})},n}function Gd(e,t,r){var n=Ea(e);return e.toSeq().map(function(i,o){return n(t.call(r,i,o,e))}).flatten(!0)}function Vd(e,t){var r=Rt(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(n,i){var o=this,a=0;return e.__iterate(function(s){return(!a||n(t,a++,o)!==!1)&&n(s,a++,o)!==!1},i),a},r.__iteratorUncached=function(n,i){var o=e.__iterator(dt,i),a=0,s;return new ye(function(){return(!s||a%2)&&(s=o.next(),s.done)?s:a%2?Pe(n,a++,t):Pe(n,a++,s.value,s)})},r}function Ar(e,t,r){t||(t=nf);var n=Re(e),i=0,o=e.toSeq().map(function(a,s){return[s,a,i++,r?r(a,s,e):a]}).valueSeq().toArray();return o.sort(function(a,s){return t(a[3],s[3])||a[2]-s[2]}).forEach(n?function(a,s){o[s].length=2}:function(a,s){o[s]=a[1]}),n?Wt(o):it(e)?bt(o):Lr(o)}function Vn(e,t,r){if(t||(t=nf),r){var n=e.toSeq().map(function(i,o){return[i,r(i,o,e)]}).reduce(function(i,o){return vs(t,i[1],o[1])?o:i});return n&&n[0]}return e.reduce(function(i,o){return vs(t,i,o)?o:i})}function vs(e,t,r){var n=e(r,t);return n===0&&r!==t&&(r==null||r!==r)||n>0}function Yn(e,t,r,n){var i=Rt(e),o=new Sr(r).map(function(a){return a.size});return i.size=n?o.max():o.min(),i.__iterate=function(a,s){for(var l=this.__iterator(dt,s),c,p=0;!(c=l.next()).done&&a(c.value,p++,this)!==!1;);return p},i.__iteratorUncached=function(a,s){var l=r.map(function(g){return g=je(g),Zo(s?g.reverse():g)}),c=0,p=!1;return new ye(function(){var g;return p||(g=l.map(function(S){return S.next()}),p=n?g.every(function(S){return S.done}):g.some(function(S){return S.done})),p?Be():Pe(a,c++,t.apply(null,g.map(function(S){return S.value})))})},i}function Ee(e,t){return e===t?e:gi(e)?t:e.constructor(t)}function Rs(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function Ea(e){return Re(e)?_t:it(e)?lr:Or}function Rt(e){return Object.create((Re(e)?Wt:it(e)?bt:Lr).prototype)}function va(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ke.prototype.cacheResult.call(this)}function nf(e,t){return e===void 0&&t===void 0?0:e===void 0?1:t===void 0?-1:e>t?1:e<t?-1:0}function ia(e){return!!(e&&typeof e.equals=="function"&&typeof e.hashCode=="function")}function Ue(e,t){if(e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1;if(typeof e.valueOf=="function"&&typeof t.valueOf=="function"){if(e=e.valueOf(),t=t.valueOf(),e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1}return!!(ia(e)&&ia(t)&&e.equals(t))}function Ra(e,t,r,n){return cr(e,[t],r,n)}function of(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return sf(this,e)}function af(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];if(typeof e!="function")throw new TypeError("Invalid merger function: "+e);return sf(this,t,e)}function sf(e,t,r){for(var n=[],i=0;i<t.length;i++){var o=_t(t[i]);o.size!==0&&n.push(o)}return n.length===0?e:e.toSeq().size===0&&!e.__ownerID&&n.length===1?Ft(e)?e:e.constructor(n[0]):e.withMutations(function(a){for(var s=r?function(c,p){Ra(a,p,pe,function(g){return g===pe?c:r(g,c,p)})}:function(c,p){a.set(p,c)},l=0;l<n.length;l++)n[l].forEach(s)})}var Yd=Object.prototype.toString;function Ia(e){if(!e||typeof e!="object"||Yd.call(e)!=="[object Object]")return!1;var t=Object.getPrototypeOf(e);if(t===null)return!0;for(var r=t,n=Object.getPrototypeOf(t);n!==null;)r=n,n=Object.getPrototypeOf(r);return r===t}function Ut(e){return typeof e=="object"&&(yt(e)||Array.isArray(e)||Ia(e))}function Dn(e){return typeof e=="string"&&(e==="__proto__"||e==="constructor")}function mt(e,t){t=t||0;for(var r=Math.max(0,e.length-t),n=new Array(r),i=0;i<r;i++)n[i]=e[i+t];return n}function ci(e){if(Array.isArray(e))return mt(e);var t={};for(var r in e)Dn(r)||Cr.call(e,r)&&(t[r]=e[r]);return t}function Jd(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return xn(e,t)}function Qd(e,t){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return xn(t,r,e)}function Xd(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return kn(e,t)}function Zd(e,t){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return kn(t,r,e)}function kn(e,t,r){return xn(e,t,eh(r))}function xn(e,t,r){if(!Ut(e))throw new TypeError("Cannot merge into non-data-structure value: "+e);if(yt(e))return typeof r=="function"&&e.mergeWith?e.mergeWith.apply(e,[r].concat(t)):e.merge?e.merge.apply(e,t):e.concat.apply(e,t);for(var n=Array.isArray(e),i=e,o=n?lr:_t,a=n?function(l){i===e&&(i=ci(i)),i.push(l)}:function(l,c){if(!Dn(c)){var p=Cr.call(i,c),g=p&&r?r(i[c],l,c):l;(!p||g!==i[c])&&(i===e&&(i=ci(i)),i[c]=g)}},s=0;s<t.length;s++)o(t[s]).forEach(a);return i}function eh(e){function t(r,n,i){return Ut(r)&&Ut(n)&&th(r,n)?xn(r,[n],t):e?e(r,n,i):n}return t}function th(e,t){var r=Ke(e),n=Ke(t);return it(r)===it(n)&&Re(r)===Re(n)}function uf(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return kn(this,e)}function lf(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return kn(this,t,e)}function Ta(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return cr(this,e,St(),function(n){return kn(n,t)})}function Oa(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return cr(this,e,St(),function(n){return xn(n,t)})}function ff(e,t,r){return cr(e,t,pe,function(){return r})}function Ma(e,t){return ff(this,e,t)}function Pa(e,t,r){return arguments.length===1?e(this):Ra(this,e,t,r)}function Ca(e,t,r){return cr(this,e,t,r)}function La(){return this.__altered}function Nn(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}var cf="@@__IMMUTABLE_MAP__@@";function Si(e){return!!(e&&e[cf])}function wn(e,t){if(!e)throw new Error(t)}function ft(e){wn(e!==1/0,"Cannot perform this action with an infinite size.")}var fr=(function(e){function t(r){return r==null?St():Si(r)&&!wt(r)?r:St().withMutations(function(n){var i=e(r);ft(i.size),i.forEach(function(o,a){return n.set(a,o)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(n,i){return this._root?this._root.get(0,void 0,n,i):i},t.prototype.set=function(n,i){return Os(this,n,i)},t.prototype.remove=function(n){return Os(this,n,pe)},t.prototype.deleteAll=function(n){var i=je(n);return i.size===0?this:this.withMutations(function(o){i.forEach(function(a){return o.remove(a)})})},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},t.prototype.sort=function(n){return vt(Ar(this,n))},t.prototype.sortBy=function(n,i){return vt(Ar(this,i,n))},t.prototype.map=function(n,i){var o=this;return this.withMutations(function(a){a.forEach(function(s,l){a.set(l,n.call(i,s,l,o))})})},t.prototype.__iterator=function(n,i){return new rh(this,n,i)},t.prototype.__iterate=function(n,i){var o=this,a=0;return this._root&&this._root.iterate(function(s){return a++,n(s[1],s[0],o)},i),a},t.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?Da(this.size,this._root,n,this.__hash):this.size===0?St():(this.__ownerID=n,this.__altered=!1,this)},t})(_t);fr.isMap=Si;var Ce=fr.prototype;Ce[cf]=!0;Ce[On]=Ce.remove;Ce.removeAll=Ce.deleteAll;Ce.setIn=Ma;Ce.removeIn=Ce.deleteIn=$a;Ce.update=Pa;Ce.updateIn=Ca;Ce.merge=Ce.concat=of;Ce.mergeWith=af;Ce.mergeDeep=uf;Ce.mergeDeepWith=lf;Ce.mergeIn=Oa;Ce.mergeDeepIn=Ta;Ce.withMutations=Nn;Ce.wasAltered=La;Ce.asImmutable=Cn;Ce["@@transducer/init"]=Ce.asMutable=Ln;Ce["@@transducer/step"]=function(e,t){return e.set(t[0],t[1])};Ce["@@transducer/result"]=function(e){return e.asImmutable()};var Sn=function(t,r){this.ownerID=t,this.entries=r};Sn.prototype.get=function(t,r,n,i){for(var o=this.entries,a=0,s=o.length;a<s;a++)if(Ue(n,o[a][0]))return o[a][1];return i};Sn.prototype.update=function(t,r,n,i,o,a,s){for(var l=o===pe,c=this.entries,p=0,g=c.length;p<g&&!Ue(i,c[p][0]);p++);var S=p<g;if(S?c[p][1]===o:l)return this;if(pt(s),(l||!S)&&pt(a),!(l&&c.length===1)){if(!S&&!l&&c.length>=uh)return nh(t,c,i,o);var O=t&&t===this.ownerID,x=O?c:mt(c);return S?l?p===g-1?x.pop():x[p]=x.pop():x[p]=[i,o]:x.push([i,o]),O?(this.entries=x,this):new Sn(t,x)}};var Er=function(t,r,n){this.ownerID=t,this.bitmap=r,this.nodes=n};Er.prototype.get=function(t,r,n,i){r===void 0&&(r=Je(n));var o=1<<((t===0?r:r>>>t)&Qe),a=this.bitmap;return(a&o)===0?i:this.nodes[df(a&o-1)].get(t+ve,r,n,i)};Er.prototype.update=function(t,r,n,i,o,a,s){n===void 0&&(n=Je(i));var l=(r===0?n:n>>>r)&Qe,c=1<<l,p=this.bitmap,g=(p&c)!==0;if(!g&&o===pe)return this;var S=df(p&c-1),O=this.nodes,x=g?O[S]:void 0,v=ka(x,t,r+ve,n,i,o,a,s);if(v===x)return this;if(!g&&v&&O.length>=lh)return oh(t,O,p,l,v);if(g&&!v&&O.length===2&&Ms(O[S^1]))return O[S^1];if(g&&v&&O.length===1&&Ms(v))return v;var w=t&&t===this.ownerID,P=g?v?p:p^c:p|c,E=g?v?hf(O,S,v,w):sh(O,S,w):ah(O,S,v,w);return w?(this.bitmap=P,this.nodes=E,this):new Er(t,P,E)};var An=function(t,r,n){this.ownerID=t,this.count=r,this.nodes=n};An.prototype.get=function(t,r,n,i){r===void 0&&(r=Je(n));var o=(t===0?r:r>>>t)&Qe,a=this.nodes[o];return a?a.get(t+ve,r,n,i):i};An.prototype.update=function(t,r,n,i,o,a,s){n===void 0&&(n=Je(i));var l=(r===0?n:n>>>r)&Qe,c=o===pe,p=this.nodes,g=p[l];if(c&&!g)return this;var S=ka(g,t,r+ve,n,i,o,a,s);if(S===g)return this;var O=this.count;if(!g)O++;else if(!S&&(O--,O<fh))return ih(t,p,O,l);var x=t&&t===this.ownerID,v=hf(p,l,S,x);return x?(this.count=O,this.nodes=v,this):new An(t,O,v)};var jt=function(t,r,n){this.ownerID=t,this.keyHash=r,this.entries=n,this._index=void 0};jt.prototype._positionOf=function(t,r){var n=this.entries,i=this._index;if(i===void 0&&r&&n.length>=ch&&(i=this._buildIndex()),i!==void 0){var o=i[ma(t)];if(o!==void 0)for(var a=0;a<o.length;a++){var s=o[a];if(Ue(t,n[s][0]))return s}return-1}for(var l=0,c=n.length;l<c;l++)if(Ue(t,n[l][0]))return l;return-1};jt.prototype._buildIndex=function(){for(var t=Object.create(null),r=this.entries,n=0,i=r.length;n<i;n++){var o=ma(r[n][0]),a=t[o];a!==void 0?a.push(n):t[o]=[n]}return this._index=t,t};jt.prototype.get=function(t,r,n,i){var o=this._positionOf(n,!0);return o===-1?i:this.entries[o][1]};jt.prototype.update=function(t,r,n,i,o,a,s){n===void 0&&(n=Je(i));var l=o===pe;if(n!==this.keyHash)return l?this:(pt(s),pt(a),xa(this,t,r,n,[i,o]));var c=this.entries,p=c.length,g=t&&t===this.ownerID,S=this._positionOf(i,g),O=S===-1?p:S,x=S!==-1;if(x?c[O][1]===o:l)return this;if(pt(s),(l||!x)&&pt(a),l&&p===2)return new Tt(t,this.keyHash,c[O^1]);var v=g?c:mt(c);if(x)l?(O===p-1?v.pop():v[O]=v.pop(),g&&(this._index=void 0)):v[O]=[i,o];else if(v.push([i,o]),g&&this._index!==void 0){var w=ma(i),P=this._index[w];P!==void 0?P.push(p):this._index[w]=[p]}return g?(this.entries=v,this):new jt(t,this.keyHash,v)};var Tt=function(t,r,n){this.ownerID=t,this.keyHash=r,this.entry=n};Tt.prototype.get=function(t,r,n,i){return Ue(n,this.entry[0])?this.entry[1]:i};Tt.prototype.update=function(t,r,n,i,o,a,s){var l=o===pe,c=Ue(i,this.entry[0]);if(c?o===this.entry[1]:l)return this;if(pt(s),l){pt(a);return}return c?t&&t===this.ownerID?(this.entry[1]=o,this):new Tt(t,this.keyHash,[i,o]):(pt(a),xa(this,t,r,Je(i),[i,o]))};Sn.prototype.iterate=jt.prototype.iterate=function(e,t){for(var r=this.entries,n=0,i=r.length-1;n<=i;n++)if(e(r[t?i-n:n])===!1)return!1};Er.prototype.iterate=An.prototype.iterate=function(e,t){for(var r=this.nodes,n=0,i=r.length-1;n<=i;n++){var o=r[t?i-n:n];if(o&&o.iterate(e,t)===!1)return!1}};Tt.prototype.iterate=function(e,t){return e(this.entry)};var rh=(function(e){function t(r,n,i){this._type=n,this._reverse=i,this._stack=r._root&&Is(r._root)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.next=function(){for(var n=this._type,i=this._stack;i;){var o=i.node,a=i.index++,s=void 0;if(o.entry){if(a===0)return Ki(n,o.entry)}else if(o.entries){if(s=o.entries.length-1,a<=s)return Ki(n,o.entries[this._reverse?s-a:a])}else if(s=o.nodes.length-1,a<=s){var l=o.nodes[this._reverse?s-a:a];if(l){if(l.entry)return Ki(n,l.entry);i=this._stack=Is(l,i)}continue}i=this._stack=this._stack.__prev}return Be()},t})(ye);function Ki(e,t){return Pe(e,t[0],t[1])}function Is(e,t){return{node:e,index:0,__prev:t}}function Da(e,t,r,n){var i=Object.create(Ce);return i.size=e,i._root=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}var Ts;function St(){return Ts||(Ts=Da(0))}function Os(e,t,r){var n,i;if(e._root){var o=ea(),a=ea();if(n=ka(e._root,e.__ownerID,0,void 0,t,r,o,a),!a.value)return e;i=e.size+(o.value?r===pe?-1:1:0)}else{if(r===pe)return e;i=1,n=new Sn(e.__ownerID,[[t,r]])}return e.__ownerID?(e.size=i,e._root=n,e.__hash=void 0,e.__altered=!0,e):n?Da(i,n):St()}function ka(e,t,r,n,i,o,a,s){return e?e.update(t,r,n,i,o,a,s):o===pe?e:(pt(s),pt(a),new Tt(t,n,[i,o]))}function Ms(e){return e.constructor===Tt||e.constructor===jt}function xa(e,t,r,n,i){if(e.keyHash===n)return new jt(t,n,[e.entry,i]);var o=(r===0?e.keyHash:e.keyHash>>>r)&Qe,a=(r===0?n:n>>>r)&Qe,s,l=o===a?[xa(e,t,r+ve,n,i)]:(s=new Tt(t,n,i),o<a?[e,s]:[s,e]);return new Er(t,1<<o|1<<a,l)}function nh(e,t,r,n){e||(e=new pa);for(var i=new Tt(e,Je(r),[r,n]),o=0;o<t.length;o++){var a=t[o];i=i.update(e,0,void 0,a[0],a[1])}return i}function ih(e,t,r,n){for(var i=0,o=0,a=new Array(r),s=0,l=1,c=t.length;s<c;s++,l<<=1){var p=t[s];p!==void 0&&s!==n&&(i|=l,a[o++]=p)}return new Er(e,i,a)}function oh(e,t,r,n,i){for(var o=0,a=new Array(ct),s=0;r!==0;s++,r>>>=1)a[s]=r&1?t[o++]:void 0;return a[n]=i,new An(e,o+1,a)}function df(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function hf(e,t,r,n){var i=n?e:mt(e);return i[t]=r,i}function ah(e,t,r,n){var i=e.length+1;if(n&&t+1===i)return e[t]=r,e;for(var o=new Array(i),a=0,s=0;s<i;s++)s===t?(o[s]=r,a=-1):o[s]=e[s+a];return o}function sh(e,t,r){var n=e.length-1;if(r&&t===n)return e.pop(),e;for(var i=new Array(n),o=0,a=0;a<n;a++)a===t&&(o=1),i[a]=e[a+o];return i}var uh=ct/4,lh=ct/2,fh=ct/4,ch=16;function pf(e){if(_a(e)&&typeof e!="string")return e;if(wt(e))return e.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+e)}function En(e){try{return typeof e=="string"?JSON.stringify(e):String(e)}catch{return JSON.stringify(e)}}function _f(e,t){return yt(e)?e.has(t):Ut(e)&&Cr.call(e,t)}function Na(e,t,r){return yt(e)?e.get(t,r):_f(e,t)?typeof e.get=="function"?e.get(t):e[t]:r}function yf(e,t){if(!Ut(e))throw new TypeError("Cannot update non-data-structure value: "+e);if(yt(e)){if(!e.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+e);return e.remove(t)}if(!Cr.call(e,t))return e;var r=ci(e);return Array.isArray(r)?r.splice(t,1):delete r[t],r}function bf(e,t,r){if(Dn(t))return e;if(!Ut(e))throw new TypeError("Cannot update non-data-structure value: "+e);if(yt(e)){if(!e.set)throw new TypeError("Cannot update immutable value without .set() method: "+e);return e.set(t,r)}if(Cr.call(e,t)&&r===e[t])return e;var n=ci(e);return n[t]=r,n}function cr(e,t,r,n){n||(n=r,r=void 0);var i=gf(yt(e),e,pf(t),0,r,n);return i===pe?r:i}function gf(e,t,r,n,i,o){var a=t===pe;if(n===r.length){var s=a?i:t,l=o(s);return l===s?t:l}if(!a&&!Ut(t))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(r).slice(0,n).map(En)+"]: "+t);var c=r[n],p=a?pe:Na(t,c,pe),g=gf(p===pe?e:yt(p),p,r,n+1,i,o);return g===p?t:g===pe?yf(t,c):bf(a?e?St():{}:t,c,g)}function wf(e,t){return cr(e,t,function(){return pe})}function $a(e){return wf(this,e)}var mf="@@__IMMUTABLE_LIST__@@";function qa(e){return!!(e&&e[mf])}var $n=(function(e){function t(r){var n=oi();if(r==null)return n;if(qa(r))return r;var i=e(r),o=i.size;return o===0?n:(ft(o),o>0&&o<ct?vn(0,o,ve,void 0,new Nt(i.toArray())):n.withMutations(function(a){a.setSize(o),i.forEach(function(s,l){return a.set(l,s)})}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("List [","]")},t.prototype.get=function(n,i){if(n=$t(this,n),n>=0&&n<this.size){n+=this._origin;var o=Sf(this,n);return o&&o.array[n&Qe]}return i},t.prototype.set=function(n,i){return dh(this,n,i)},t.prototype.remove=function(n){return this.has(n)?n===0?this.shift():n===this.size-1?this.pop():this.splice(n,1):this},t.prototype.insert=function(n,i){return this.splice(n,0,i)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=ve,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):oi()},t.prototype.push=function(){var n=arguments,i=this.size;return this.withMutations(function(o){Dt(o,0,i+n.length);for(var a=0;a<n.length;a++)o.set(i+a,n[a])})},t.prototype.pop=function(){return Dt(this,0,-1)},t.prototype.unshift=function(){var n=arguments;return this.withMutations(function(i){Dt(i,-n.length);for(var o=0;o<n.length;o++)i.set(o,n[o])})},t.prototype.shift=function(){return Dt(this,1)},t.prototype.shuffle=function(n){return n===void 0&&(n=Math.random),this.withMutations(function(i){for(var o=i.size,a,s;o;)a=Math.floor(n()*o--),s=i.get(a),i.set(a,i.get(o)),i.set(o,s)})},t.prototype.concat=function(){for(var n=arguments,i=[],o=0;o<arguments.length;o++){var a=n[o],s=e(typeof a!="string"&&ha(a)?a:[a]);s.size!==0&&i.push(s)}return i.length===0?this:this.size===0&&!this.__ownerID&&i.length===1?this.constructor(i[0]):this.withMutations(function(l){i.forEach(function(c){return c.forEach(function(p){return l.push(p)})})})},t.prototype.setSize=function(n){return Dt(this,0,n)},t.prototype.map=function(n,i){var o=this;return this.withMutations(function(a){for(var s=0;s<o.size;s++)a.set(s,n.call(i,a.get(s),s,o))})},t.prototype.slice=function(n,i){var o=this.size;return Mn(n,i,o)?this:Dt(this,Pr(n,o),Pn(i,o))},t.prototype.__iterator=function(n,i){var o=i?this.size:0,a=Ps(this,i);return new ye(function(){var s=a();return s===mn?Be():Pe(n,i?--o:o++,s)})},t.prototype.__iterate=function(n,i){for(var o=i?this.size:0,a=Ps(this,i),s;(s=a())!==mn&&n(s,i?--o:o++,this)!==!1;);return o},t.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?vn(this._origin,this._capacity,this._level,this._root,this._tail,n,this.__hash):this.size===0?oi():(this.__ownerID=n,this.__altered=!1,this)},t})(lr);$n.isList=qa;var xe=$n.prototype;xe[mf]=!0;xe[On]=xe.remove;xe.merge=xe.concat;xe.setIn=Ma;xe.deleteIn=xe.removeIn=$a;xe.update=Pa;xe.updateIn=Ca;xe.mergeIn=Oa;xe.mergeDeepIn=Ta;xe.withMutations=Nn;xe.wasAltered=La;xe.asImmutable=Cn;xe["@@transducer/init"]=xe.asMutable=Ln;xe["@@transducer/step"]=function(e,t){return e.push(t)};xe["@@transducer/result"]=function(e){return e.asImmutable()};var Nt=function(t,r){this.array=t,this.ownerID=r};Nt.prototype.removeBefore=function(t,r,n){if((n&(1<<r+ve)-1)===0||this.array.length===0)return this;var i=n>>>r&Qe;if(i>=this.array.length)return new Nt([],t);var o=i===0,a;if(r>0){var s=this.array[i];if(a=s&&s.removeBefore(t,r-ve,n),a===s&&o)return this}if(o&&!a)return this;var l=vr(this,t);if(!o)for(var c=0;c<i;c++)l.array[c]=void 0;return a&&(l.array[i]=a),l};Nt.prototype.removeAfter=function(t,r,n){if(n===(r?1<<r+ve:ct)||this.array.length===0)return this;var i=n-1>>>r&Qe;if(i>=this.array.length)return this;var o;if(r>0){var a=this.array[i];if(o=a&&a.removeAfter(t,r-ve,n),o===a&&i===this.array.length-1)return this}var s=vr(this,t);return s.array.splice(i+1),o&&(s.array[i]=o),s};var mn={};function Ps(e,t){var r=e._origin,n=e._capacity,i=Rn(n),o=e._tail;return a(e._root,e._level,0);function a(c,p,g){return p===0?s(c,g):l(c,p,g)}function s(c,p){var g=p===i?o&&o.array:c&&c.array,S=p>r?0:r-p,O=n-p;return O>ct&&(O=ct),function(){if(S===O)return mn;var x=t?--O:S++;return g&&g[x]}}function l(c,p,g){var S,O=c&&c.array,x=g>r?0:r-g>>p,v=(n-g>>p)+1;return v>ct&&(v=ct),function(){for(;;){if(S){var w=S();if(w!==mn)return w;S=null}if(x===v)return mn;var P=t?--v:x++;S=a(O&&O[P],p-ve,g+(P<<p))}}}}function vn(e,t,r,n,i,o,a){var s=Object.create(xe);return s.size=t-e,s._origin=e,s._capacity=t,s._level=r,s._root=n,s._tail=i,s.__ownerID=o,s.__hash=a,s.__altered=!1,s}function oi(){return vn(0,0,ve)}function dh(e,t,r){if(t=$t(e,t),t!==t)return e;if(t>=e.size||t<0)return e.withMutations(function(a){t<0?Dt(a,t).set(0,r):Dt(a,0,t+1).set(t,r)});t+=e._origin;var n=e._tail,i=e._root,o=ea();return t>=Rn(e._capacity)?n=oa(n,e.__ownerID,0,t,r,o):i=oa(i,e.__ownerID,e._level,t,r,o),o.value?e.__ownerID?(e._root=i,e._tail=n,e.__hash=void 0,e.__altered=!0,e):vn(e._origin,e._capacity,e._level,i,n):e}function oa(e,t,r,n,i,o){var a=n>>>r&Qe,s=e&&a<e.array.length;if(!s&&i===void 0)return e;var l;if(r>0){var c=e&&e.array[a],p=oa(c,t,r-ve,n,i,o);return p===c?e:(l=vr(e,t),l.array[a]=p,l)}return s&&e.array[a]===i?e:(o&&pt(o),l=vr(e,t),i===void 0&&a===l.array.length-1?l.array.pop():l.array[a]=i,l)}function vr(e,t){return t&&e&&t===e.ownerID?e:new Nt(e?e.array.slice():[],t)}function Sf(e,t){if(t>=Rn(e._capacity))return e._tail;if(t<1<<e._level+ve){for(var r=e._root,n=e._level;r&&n>0;)r=r.array[t>>>n&Qe],n-=ve;return r}}function hh(e,t,r){var n=e._origin+(t===void 0?0:t),i=r===void 0?e._capacity:r<0?e._capacity+r:e._origin+r;if(Number.isFinite(i)&&i>Jn||Number.isFinite(n)&&n<-Jn||Number.isFinite(i)&&Number.isFinite(n)&&i-n>Jn)throw new RangeError("Invalid List size: a List cannot hold more than "+Jn+" (2 ** 30) values.")}function Dt(e,t,r){hh(e,t,r),t!==void 0&&(t|=0),r!==void 0&&(r|=0);var n=e.__ownerID||new pa,i=e._origin,o=e._capacity,a=i+t,s=r===void 0?o:r<0?o+r:i+r;if(a===i&&s===o)return e;if(a>=s)return e.clear();for(var l=e._level,c=e._root,p=0;a+p<0;)c=new Nt(c&&c.array.length?[void 0,c]:[],n),l+=ve,p+=Cs(l);p&&(a+=p,i+=p,s+=p,o+=p);for(var g=Rn(o),S=Rn(s);S>=Cs(l+ve);)c=new Nt(c&&c.array.length?[c]:[],n),l+=ve;var O=e._tail,x=S<g?Sf(e,s-1):S>g?new Nt([],n):O;if(O&&S>g&&a<o&&O.array.length){c=vr(c,n);for(var v=c,w=l;w>ve;w-=ve){var P=g>>>w&Qe;v=v.array[P]=vr(v.array[P],n)}v.array[g>>>ve&Qe]=O}if(s<o&&(x=x&&x.removeAfter(n,0,s)),a>=S)a-=S,s-=S,l=ve,c=void 0,x=x&&x.removeBefore(n,0,a);else if(a>i||S<g){for(p=0;c;){var E=a>>>l&Qe;if(E!==S>>>l&Qe)break;E&&(p+=(1<<l)*E),l-=ve,c=c.array[E]}c&&a>i&&(c=c.removeBefore(n,l,a-p)),c&&S<g&&(c=c.removeAfter(n,l,S-p)),p&&(a-=p,s-=p)}return e.__ownerID?(e.size=s-a,e._origin=a,e._capacity=s,e._level=l,e._root=c,e._tail=x,e.__hash=void 0,e.__altered=!0,e):vn(a,s,l,c,x)}function Rn(e){return e<ct?0:e-1>>>ve<<ve}var Jn=Math.pow(2,30);function Cs(e){return e<31?1<<e:Math.pow(2,e)}function Ua(e){return Si(e)&&wt(e)}var vt=(function(e){function t(r){return r==null?cn():Ua(r)?r:cn().withMutations(function(n){var i=_t(r);ft(i.size),i.forEach(function(o,a){return n.set(a,o)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("OrderedMap {","}")},t.prototype.get=function(n,i){var o=this._map.get(n);return o!==void 0?this._list.get(o)[1]:i},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):cn()},t.prototype.set=function(n,i){return Ds(this,n,i)},t.prototype.remove=function(n){return Ds(this,n,pe)},t.prototype.__iterate=function(n,i){var o=this;return this._list.__iterate(function(a){return a&&n(a[1],a[0],o)},i)},t.prototype.__iterator=function(n,i){return this._list.fromEntrySeq().__iterator(n,i)},t.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var i=this._map.__ensureOwner(n),o=this._list.__ensureOwner(n);return n?ja(i,o,n,this.__hash):this.size===0?cn():(this.__ownerID=n,this.__altered=!1,this._map=i,this._list=o,this)},t})(fr);vt.isOrderedMap=Ua;vt.prototype[qt]=!0;vt.prototype[On]=vt.prototype.remove;function ja(e,t,r,n){var i=Object.create(vt.prototype);return i.size=e?e.size:0,i._map=e,i._list=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}var Ls;function cn(){return Ls||(Ls=ja(St(),oi()))}function Ds(e,t,r){var n=e._map,i=e._list,o=n.get(t),a=o!==void 0,s,l;if(r===pe){if(!a)return e;i.size>=ct&&i.size>=n.size*2?(l=i.filter(function(c,p){return c!==void 0&&o!==p}),s=l.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),e.__ownerID&&(s.__ownerID=l.__ownerID=e.__ownerID)):(s=n.remove(t),l=o===i.size-1?i.pop():i.set(o,void 0))}else if(a){if(r===i.get(o)[1])return e;s=n,l=i.set(o,[t,r])}else s=n.set(t,i.size),l=i.set(i.size,[t,r]);return e.__ownerID?(e.size=s.size,e._map=s,e._list=l,e.__hash=void 0,e.__altered=!0,e):ja(s,l)}var Af="@@__IMMUTABLE_STACK__@@";function di(e){return!!(e&&e[Af])}var Ai=(function(e){function t(r){return r==null?Qn():di(r)?r:Qn().pushAll(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(n,i){var o=this._head;for(n=$t(this,n);o&&n--;)o=o.next;return o?o.value:i},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var n=arguments;if(arguments.length===0)return this;for(var i=this.size+arguments.length,o=this._head,a=arguments.length-1;a>=0;a--)o={value:n[a],next:o};return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):dn(i,o)},t.prototype.pushAll=function(n){if(n=e(n),n.size===0)return this;if(this.size===0&&di(n))return n;ft(n.size);var i=this.size,o=this._head;return n.__iterate(function(a){i++,o={value:a,next:o}},!0),this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):dn(i,o)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Qn()},t.prototype.slice=function(n,i){if(Mn(n,i,this.size))return this;var o=Pr(n,this.size),a=Pn(i,this.size);if(a!==this.size)return e.prototype.slice.call(this,n,i);for(var s=this.size-o,l=this._head;o--;)l=l.next;return this.__ownerID?(this.size=s,this._head=l,this.__hash=void 0,this.__altered=!0,this):dn(s,l)},t.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?dn(this.size,this._head,n,this.__hash):this.size===0?Qn():(this.__ownerID=n,this.__altered=!1,this)},t.prototype.__iterate=function(n,i){var o=this;if(i)return new Sr(this.toArray()).__iterate(function(l,c){return n(l,c,o)},i);for(var a=0,s=this._head;s&&n(s.value,a++,this)!==!1;)s=s.next;return a},t.prototype.__iterator=function(n,i){if(i)return new Sr(this.toArray()).__iterator(n,i);var o=0,a=this._head;return new ye(function(){if(a){var s=a.value;return a=a.next,Pe(n,o++,s)}return Be()})},t})(lr);Ai.isStack=di;var Xe=Ai.prototype;Xe[Af]=!0;Xe.shift=Xe.pop;Xe.unshift=Xe.push;Xe.unshiftAll=Xe.pushAll;Xe.withMutations=Nn;Xe.wasAltered=La;Xe.asImmutable=Cn;Xe["@@transducer/init"]=Xe.asMutable=Ln;Xe["@@transducer/step"]=function(e,t){return e.unshift(t)};Xe["@@transducer/result"]=function(e){return e.asImmutable()};function dn(e,t,r,n){var i=Object.create(Xe);return i.size=e,i._head=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}var ks;function Qn(){return ks||(ks=dn(0))}function xs(e,t,r,n,i,o){return ft(e.size),e.__iterate(function(a,s,l){i?(i=!1,r=a):r=t.call(n,r,a,s,l)},o),r}function ph(e,t){return t}function _h(e,t){return[t,e]}function Hi(e){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return!e.apply(this,t)}}function Ns(e){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return-e.apply(this,t)}}function $s(e,t){return e<t?1:e>t?-1:0}function Fa(e,t){if(e===t)return!0;if(!ot(t)||e.size!==void 0&&t.size!==void 0&&e.size!==t.size||e.__hash!==void 0&&t.__hash!==void 0&&e.__hash!==t.__hash||Re(e)!==Re(t)||it(e)!==it(t)||wt(e)!==wt(t))return!1;if(e.size===0&&t.size===0)return!0;var r=!_i(e);if(wt(e)){var n=e.entries();return t.every(function(l,c){var p=n.next().value;return p&&Ue(p[1],l)&&(r||Ue(p[0],c))})&&n.next().done}var i=!1;if(e.size===void 0)if(t.size===void 0)typeof e.cacheResult=="function"&&e.cacheResult();else{i=!0;var o=e;e=t,t=o}var a=!0,s=t.__iterate(function(l,c){if(r?!e.has(l):i?!Ue(l,e.get(c,pe)):!Ue(e.get(c,pe),l))return a=!1,!1});return a&&e.size===s}var Ef=(function(e){function t(r,n,i){if(i===void 0&&(i=1),!(this instanceof t))return new t(r,n,i);if(wn(i!==0,"Cannot step a Range by 0"),wn(r!==void 0,"You must define a start value when using Range"),wn(n!==void 0,"You must define an end value when using Range"),i=Math.abs(i),n<r&&(i=-i),this._start=r,this._end=n,this._step=i,this.size=Math.max(0,Math.ceil((n-r)/i-1)+1),this.size===0){if(Gi)return Gi;Gi=this}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},t.prototype.get=function(n,i){return this.has(n)?this._start+$t(this,n)*this._step:i},t.prototype.includes=function(n){var i=(n-this._start)/this._step;return i>=0&&i<this.size&&i===Math.floor(i)},t.prototype.slice=function(n,i){return Mn(n,i,this.size)?this:(n=Pr(n,this.size),i=Pn(i,this.size),i<=n?new t(0,0):new t(this.get(n,this._end),this.get(i,this._end),this._step))},t.prototype.indexOf=function(n){var i=n-this._start;if(i%this._step===0){var o=i/this._step;if(o>=0&&o<this.size)return o}return-1},t.prototype.lastIndexOf=function(n){return this.indexOf(n)},t.prototype.__iterate=function(n,i){for(var o=this.size,a=this._step,s=i?this._start+(o-1)*a:this._start,l=0;l!==o&&n(s,i?o-++l:l++,this)!==!1;)s+=i?-a:a;return l},t.prototype.__iterator=function(n,i){var o=this.size,a=this._step,s=i?this._start+(o-1)*a:this._start,l=0;return new ye(function(){if(l===o)return Be();var c=s;return s+=i?-a:a,Pe(n,i?o-++l:l++,c)})},t.prototype.equals=function(n){return n instanceof t?this._start===n._start&&this._end===n._end&&this._step===n._step:Fa(this,n)},t})(bt),Gi,vf="@@__IMMUTABLE_SET__@@";function Ei(e){return!!(e&&e[vf])}var qn=(function(e){function t(r){return r==null?hn():Ei(r)&&!wt(r)?r:hn().withMutations(function(n){var i=e(r);ft(i.size),i.forEach(function(o){return n.add(o)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(n){return this(_t(n).keySeq())},t.intersect=function(n){return n=je(n).toArray(),n.length?ze.intersect.apply(t(n.pop()),n):hn()},t.union=function(n){return n=je(n).toArray(),n.length?ze.union.apply(t(n.pop()),n):hn()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(n){return this._map.has(n)},t.prototype.add=function(n){return Xn(this,this._map.set(n,n))},t.prototype.remove=function(n){return Xn(this,this._map.remove(n))},t.prototype.clear=function(){return Xn(this,this._map.clear())},t.prototype.map=function(n,i){var o=this,a=!1,s=Xn(this,this._map.mapEntries(function(l){var c=l[1],p=n.call(i,c,c,o);return p!==c&&(a=!0),[p,p]},i));return a?s:this},t.prototype.union=function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];return n=n.filter(function(o){return o.size!==0}),n.length===0?this:this.size===0&&!this.__ownerID&&n.length===1?this.constructor(n[0]):this.withMutations(function(o){for(var a=0;a<n.length;a++)typeof n[a]=="string"?o.add(n[a]):e(n[a]).forEach(function(s){return o.add(s)})})},t.prototype.intersect=function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];if(n.length===0)return this;n=n.map(function(a){return e(a)});var o=[];return this.forEach(function(a){n.every(function(s){return s.includes(a)})||o.push(a)}),this.withMutations(function(a){o.forEach(function(s){a.remove(s)})})},t.prototype.subtract=function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];if(n.length===0)return this;n=n.map(function(a){return e(a)});var o=[];return this.forEach(function(a){n.some(function(s){return s.includes(a)})&&o.push(a)}),this.withMutations(function(a){o.forEach(function(s){a.remove(s)})})},t.prototype.sort=function(n){return Ir(Ar(this,n))},t.prototype.sortBy=function(n,i){return Ir(Ar(this,i,n))},t.prototype.wasAltered=function(){return this._map.wasAltered()},t.prototype.__iterate=function(n,i){var o=this;return this._map.__iterate(function(a){return n(a,a,o)},i)},t.prototype.__iterator=function(n,i){return this._map.__iterator(n,i)},t.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var i=this._map.__ensureOwner(n);return n?this.__make(i,n):this.size===0?this.__empty():(this.__ownerID=n,this._map=i,this)},t})(Or);qn.isSet=Ei;var ze=qn.prototype;ze[vf]=!0;ze[On]=ze.remove;ze.merge=ze.concat=ze.union;ze.withMutations=Nn;ze.asImmutable=Cn;ze["@@transducer/init"]=ze.asMutable=Ln;ze["@@transducer/step"]=function(e,t){return e.add(t)};ze["@@transducer/result"]=function(e){return e.asImmutable()};ze.__empty=hn;ze.__make=Rf;function Xn(e,t){return e.__ownerID?(e.size=t.size,e._map=t,e):t===e._map?e:t.size===0?e.__empty():e.__make(t)}function Rf(e,t){var r=Object.create(ze);return r.size=e?e.size:0,r._map=e,r.__ownerID=t,r}var qs;function hn(){return qs||(qs=Rf(St()))}function Wa(e,t,r){for(var n=pf(t),i=0;i!==n.length;)if(e=Na(e,n[i++],pe),e===pe)return r;return e}function If(e,t){return Wa(this,e,t)}function Tf(e,t){return Wa(e,t,pe)!==pe}function yh(e){return Tf(this,e)}function Of(){ft(this.size);var e={};return this.__iterate(function(t,r){Dn(r)||(e[r]=t)}),e}function hi(e){if(!e||typeof e!="object")return e;if(!ot(e)){if(!Ut(e))return e;e=Ke(e)}if(Re(e)){var t={};return e.__iterate(function(n,i){Dn(i)||(t[i]=hi(n))}),t}var r=[];return e.__iterate(function(n){r.push(hi(n))}),r}function bh(e){if(e.size===1/0)return 0;var t=wt(e),r=Re(e),n=t?1:0;return e.__iterate(r?t?function(i,o){n=31*n+Us(Je(i),Je(o))|0}:function(i,o){n=n+Us(Je(i),Je(o))|0}:t?function(i){n=31*n+Je(i)|0}:function(i){n=n+Je(i)|0}),gh(e.size,n)}function gh(e,t){return t=Hr(t,3432918353),t=Hr(t<<15|t>>>-15,461845907),t=Hr(t<<13|t>>>-13,5),t=(t+3864292196|0)^e,t=Hr(t^t>>>16,2246822507),t=Hr(t^t>>>13,3266489909),t=wi(t^t>>>16),t}function Us(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}function dr(e,t){var r=function(n){e.prototype[n]=t[n]};return Object.keys(t).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(r),e}je.Iterator=ye;dr(je,{toArray:function(){ft(this.size);var t=new Array(this.size||0),r=Re(this),n=0;return this.__iterate(function(i,o){t[n++]=r?[o,i]:i}),t},toIndexedSeq:function(){return new Yl(this)},toJS:function(){return hi(this)},toKeyedSeq:function(){return new mi(this,!0)},toMap:function(){return fr(this.toKeyedSeq())},toObject:Of,toOrderedMap:function(){return vt(this.toKeyedSeq())},toOrderedSet:function(){return Ir(Re(this)?this.valueSeq():this)},toSet:function(){return qn(Re(this)?this.valueSeq():this)},toSetSeq:function(){return new Jl(this)},toSeq:function(){return it(this)?this.toIndexedSeq():Re(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Ai(Re(this)?this.valueSeq():this)},toList:function(){return $n(Re(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(t,r){return this.size===0?t+r:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+r},concat:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Ee(this,Hd(this,t))},includes:function(t){return this.some(function(r){return Ue(r,t)})},entries:function(){return this.__iterator(ht)},every:function(t,r){ft(this.size);var n=!0;return this.__iterate(function(i,o,a){if(!t.call(r,i,o,a))return n=!1,!1}),n},filter:function(t,r){return Ee(this,ef(this,t,r,!0))},partition:function(t,r){return zd(this,t,r)},find:function(t,r,n){var i=this.findEntry(t,r);return i?i[1]:n},forEach:function(t,r){return ft(this.size),this.__iterate(r?t.bind(r):t)},join:function(t){ft(this.size),t=t!==void 0?""+t:",";var r="",n=!0;return this.__iterate(function(i){n?n=!1:r+=t,r+=i!=null?i.toString():""}),r},keys:function(){return this.__iterator(Mr)},map:function(t,r){return Ee(this,Zl(this,t,r))},reduce:function(t,r,n){return xs(this,t,r,n,arguments.length<2,!1)},reduceRight:function(t,r,n){return xs(this,t,r,n,arguments.length<2,!0)},reverse:function(){return Ee(this,Sa(this,!0))},slice:function(t,r){return Ee(this,Aa(this,t,r,!0))},some:function(t,r){ft(this.size);var n=!1;return this.__iterate(function(i,o,a){if(t.call(r,i,o,a))return n=!0,!1}),n},sort:function(t){return Ee(this,Ar(this,t))},values:function(){return this.__iterator(dt)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(t,r){return mr(t?this.toSeq().filter(t,r):this)},countBy:function(t,r){return Fd(this,t,r)},equals:function(t){return Fa(this,t)},entrySeq:function(){var t=this;if(t._cache)return new Sr(t._cache);var r=t.toSeq().map(_h).toIndexedSeq();return r.fromEntrySeq=function(){return t.toSeq()},r},filterNot:function(t,r){return this.filter(Hi(t),r)},findEntry:function(t,r,n){var i=n;return this.__iterate(function(o,a,s){if(t.call(r,o,a,s))return i=[a,o],!1}),i},findKey:function(t,r){var n=this.findEntry(t,r);return n&&n[0]},findLast:function(t,r,n){return this.toKeyedSeq().reverse().find(t,r,n)},findLastEntry:function(t,r,n){return this.toKeyedSeq().reverse().findEntry(t,r,n)},findLastKey:function(t,r){return this.toKeyedSeq().reverse().findKey(t,r)},first:function(t){return this.find(Wl,null,t)},flatMap:function(t,r){return Ee(this,Gd(this,t,r))},flatten:function(t){return Ee(this,rf(this,t,!0))},fromEntrySeq:function(){return new Ql(this)},get:function(t,r){return this.find(function(n,i){return Ue(i,t)},void 0,r)},getIn:If,groupBy:function(t,r){return Wd(this,t,r)},has:function(t){return this.get(t,pe)!==pe},hasIn:yh,isSubset:function(t){return t=typeof t.includes=="function"?t:je(t),this.every(function(r){return t.includes(r)})},isSuperset:function(t){return t=typeof t.isSubset=="function"?t:je(t),t.isSubset(this)},keyOf:function(t){return this.findKey(function(r){return Ue(r,t)})},keySeq:function(){return this.toSeq().map(ph).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return Vn(this,t)},maxBy:function(t,r){return Vn(this,r,t)},min:function(t){return Vn(this,t?Ns(t):$s)},minBy:function(t,r){return Vn(this,r?Ns(r):$s,t)},rest:function(){return this.slice(1)},skip:function(t){return t===0?this:this.slice(Math.max(0,t))},skipLast:function(t){return t===0?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,r){return Ee(this,tf(this,t,r,!0))},skipUntil:function(t,r){return this.skipWhile(Hi(t),r)},sortBy:function(t,r){return Ee(this,Ar(this,r,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,r){return Ee(this,Bd(this,t,r))},takeUntil:function(t,r){return this.takeWhile(Hi(t),r)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=bh(this))}});var He=je.prototype;He[jl]=!0;He[yi]=He.values;He.toJSON=He.toArray;He.__toStringMapper=En;He.inspect=He.toSource=function(){return this.toString()};He.chain=He.flatMap;He.contains=He.includes;dr(_t,{flip:function(){return Ee(this,Xl(this))},mapEntries:function(t,r){var n=this,i=0;return Ee(this,this.toSeq().map(function(o,a){return t.call(r,[a,o],i++,n)}).fromEntrySeq())},mapKeys:function(t,r){var n=this;return Ee(this,this.toSeq().flip().map(function(i,o){return t.call(r,i,o,n)}).flip())}});var Un=_t.prototype;Un[fi]=!0;Un[yi]=He.entries;Un.toJSON=Of;Un.__toStringMapper=function(e,t){return En(t)+": "+En(e)};dr(lr,{toKeyedSeq:function(){return new mi(this,!1)},filter:function(t,r){return Ee(this,ef(this,t,r,!1))},findIndex:function(t,r){var n=this.findEntry(t,r);return n?n[0]:-1},indexOf:function(t){var r=this.keyOf(t);return r===void 0?-1:r},lastIndexOf:function(t){var r=this.lastKeyOf(t);return r===void 0?-1:r},reverse:function(){return Ee(this,Sa(this,!1))},slice:function(t,r){return Ee(this,Aa(this,t,r,!1))},splice:function(t,r){var n=arguments.length;if(r=Math.max(r||0,0),n===0||n===2&&!r)return this;t=Pr(t,t<0?this.count():this.size);var i=this.slice(0,t);return Ee(this,n===1?i:i.concat(mt(arguments,2),this.slice(t+r)))},findLastIndex:function(t,r){var n=this.findLastEntry(t,r);return n?n[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Ee(this,rf(this,t,!1))},get:function(t,r){return t=$t(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?r:this.find(function(n,i){return i===t},void 0,r)},has:function(t){return t=$t(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.find(function(r,n){return n===t},void 0,pe)!==pe)},interpose:function(t){return Ee(this,Vd(this,t))},interleave:function(){var t=[this].concat(mt(arguments)),r=Yn(this.toSeq(),bt.of,t),n=r.flatten(!0);return r.size&&(n.size=r.size*t.length),Ee(this,n)},keySeq:function(){return Ef(0,this.size)},last:function(t){return this.get(-1,t)},skipWhile:function(t,r){return Ee(this,tf(this,t,r,!1))},zip:function(){var t=[this].concat(mt(arguments));return Ee(this,Yn(this,js,t))},zipAll:function(){var t=[this].concat(mt(arguments));return Ee(this,Yn(this,js,t,!0))},zipWith:function(t){var r=mt(arguments);return r[0]=this,Ee(this,Yn(this,t,r))}});var Dr=lr.prototype;Dr[li]=!0;Dr[qt]=!0;dr(Or,{get:function(t,r){return this.has(t)?t:r},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}});var Rr=Or.prototype;Rr.has=He.includes;Rr.contains=Rr.includes;Rr.keys=Rr.values;dr(Wt,Un);dr(bt,Dr);dr(Lr,Rr);function js(){return mt(arguments)}function za(e){return Ei(e)&&wt(e)}var Ir=(function(e){function t(r){return r==null?aa():za(r)?r:aa().withMutations(function(n){var i=Or(r);ft(i.size),i.forEach(function(o){return n.add(o)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(n){return this(_t(n).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t})(qn);Ir.isOrderedSet=za;var hr=Ir.prototype;hr[qt]=!0;hr.zip=Dr.zip;hr.zipWith=Dr.zipWith;hr.zipAll=Dr.zipAll;hr.__empty=aa;hr.__make=Mf;function Mf(e,t){var r=Object.create(hr);return r.size=e?e.size:0,r._map=e,r.__ownerID=t,r}var Fs;function aa(){return Fs||(Fs=Mf(cn()))}var wh={LeftThenRight:-1,RightThenLeft:1};function mh(e){if(Ft(e))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(yt(e))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(e===null||typeof e!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var qe=function(t,r){var n;mh(t);var i=function(s){var l=this;if(s instanceof i)return s;if(!(this instanceof i))return new i(s);if(!n){n=!0;var c=Object.keys(t),p=o._indices={};o._name=r,o._keys=c,o._defaultValues=t;for(var g=0;g<c.length;g++){var S=c[g];p[S]=g,o[S]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+Ka(this)+' with property "'+S+'" since that property name is part of the Record API.'):Sh(o,S)}}return this.__ownerID=void 0,this._values=$n().withMutations(function(O){O.setSize(l._keys.length),_t(s).forEach(function(x,v){O.set(l._indices[v],x===l._defaultValues[v]?void 0:x)})}),this},o=i.prototype=Object.create(Te);return o.constructor=i,r&&(i.displayName=r),i};qe.prototype.toString=function(){for(var t=Ka(this)+" { ",r=this._keys,n,i=0,o=r.length;i!==o;i++)n=r[i],t+=(i?", ":"")+n+": "+En(this.get(n));return t+" }"};qe.prototype.equals=function(t){return this===t||Ft(t)&&Tr(this).equals(Tr(t))};qe.prototype.hashCode=function(){return Tr(this).hashCode()};qe.prototype.has=function(t){return this._indices.hasOwnProperty(t)};qe.prototype.get=function(t,r){if(!this.has(t))return r;var n=this._indices[t],i=this._values.get(n);return i===void 0?this._defaultValues[t]:i};qe.prototype.set=function(t,r){if(this.has(t)){var n=this._values.set(this._indices[t],r===this._defaultValues[t]?void 0:r);if(n!==this._values&&!this.__ownerID)return Ba(this,n)}return this};qe.prototype.remove=function(t){return this.set(t)};qe.prototype.clear=function(){var t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Ba(this,t)};qe.prototype.wasAltered=function(){return this._values.wasAltered()};qe.prototype.toSeq=function(){return Tr(this)};qe.prototype.toJS=function(){return hi(this)};qe.prototype.entries=function(){return this.__iterator(ht)};qe.prototype.__iterator=function(t,r){return Tr(this).__iterator(t,r)};qe.prototype.__iterate=function(t,r){return Tr(this).__iterate(t,r)};qe.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._values.__ensureOwner(t);return t?Ba(this,r,t):(this.__ownerID=t,this._values=r,this)};qe.isRecord=Ft;qe.getDescriptiveName=Ka;var Te=qe.prototype;Te[Kl]=!0;Te[On]=Te.remove;Te.deleteIn=Te.removeIn=$a;Te.getIn=If;Te.hasIn=He.hasIn;Te.merge=of;Te.mergeWith=af;Te.mergeIn=Oa;Te.mergeDeep=uf;Te.mergeDeepWith=lf;Te.mergeDeepIn=Ta;Te.setIn=Ma;Te.update=Pa;Te.updateIn=Ca;Te.withMutations=Nn;Te.asMutable=Ln;Te.asImmutable=Cn;Te[yi]=Te.entries;Te.toJSON=Te.toObject=He.toObject;Te.inspect=Te.toSource=function(){return this.toString()};function Ba(e,t,r){var n=Object.create(Object.getPrototypeOf(e));return n._values=t,n.__ownerID=r,n}function Ka(e){return e.constructor.displayName||e.constructor.name||"Record"}function Tr(e){return ga(e._keys.map(function(t){return[t,e.get(t)]}))}function Sh(e,t){try{Object.defineProperty(e,t,{get:function(){return this.get(t)},set:function(r){wn(this.__ownerID,"Cannot set on an immutable record."),this.set(t,r)}})}catch{}}var Ah=(function(e){function t(r,n){if(!(this instanceof t))return new t(r,n);if(this._value=r,this.size=n===void 0?1/0:Math.max(0,n),this.size===0){if(Vi)return Vi;Vi=this}}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},t.prototype.get=function(n,i){return this.has(n)?this._value:i},t.prototype.includes=function(n){return Ue(this._value,n)},t.prototype.slice=function(n,i){var o=this.size;return Mn(n,i,o)?this:new t(this._value,Pn(i,o)-Pr(n,o))},t.prototype.reverse=function(){return this},t.prototype.indexOf=function(n){return this.size!==0&&Ue(this._value,n)?0:-1},t.prototype.lastIndexOf=function(n){return this.size!==0&&Ue(this._value,n)?this.size-1:-1},t.prototype.__iterate=function(n,i){for(var o=this.size,a=0;a!==o&&n(this._value,i?o-++a:a++,this)!==!1;);return a},t.prototype.__iterator=function(n,i){var o=this,a=this.size,s=0;return new ye(function(){return s===a?Be():Pe(n,i?a-++s:s++,o._value)})},t.prototype.equals=function(n){return n instanceof t?Ue(this._value,n._value):Fa(this,n)},t})(bt),Vi;function Eh(e,t){return Pf([],t||vh,e,"",t&&t.length>2?[]:void 0,{"":e})}function Pf(e,t,r,n,i,o){if(typeof r!="string"&&!yt(r)&&(_a(r)||ha(r)||Ia(r))){if(~e.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");e.push(r),i&&n!==""&&i.push(n);var a=t.call(o,n,Ke(r).map(function(s,l){return Pf(e,t,s,l,i,r)}),i&&i.slice());return e.pop(),i&&i.pop(),a}return r}function vh(e,t){return it(t)?t.toList():Re(t)?t.toMap():t.toSet()}var Rh="5.1.9",Ih=je;const Th=Object.freeze(Object.defineProperty({__proto__:null,Collection:je,Iterable:Ih,List:$n,Map:fr,OrderedMap:vt,OrderedSet:Ir,PairSorting:wh,Range:Ef,Record:qe,Repeat:Ah,Seq:Ke,Set:qn,Stack:Ai,fromJS:Eh,get:Na,getIn:Wa,has:_f,hasIn:Tf,hash:Je,is:Ue,isAssociative:_i,isCollection:ot,isImmutable:yt,isIndexed:it,isKeyed:Re,isList:qa,isMap:Si,isOrdered:wt,isOrderedMap:Ua,isOrderedSet:za,isPlainObject:Ia,isRecord:Ft,isSeq:gi,isSet:Ei,isStack:di,isValueObject:ia,merge:Jd,mergeDeep:Xd,mergeDeepWith:Zd,mergeWith:Qd,remove:yf,removeIn:wf,set:bf,setIn:ff,update:Ra,updateIn:cr,version:Rh},Symbol.toStringTag,{value:"Module"})),Oh=wl(Th);var Ws;function Cf(){if(Ws)return Zt;Ws=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.ActionContextKey=Zt.ActionContext=void 0;const e=Oh;let t=class pn{constructor(i={}){this.map=(0,e.Map)(i)}setDefault(i,o){return this.has(i)?this:this.set(i,o)}set(i,o){return this.setRaw(i.name,o)}setRaw(i,o){return new pn(this.map.set(i,o))}delete(i){return new pn(this.map.delete(i.name))}get(i){return this.getRaw(i.name)}getRaw(i){return this.map.get(i)}getSafe(i){if(!this.has(i))throw new Error(`Context entry ${i.name} is required but not available`);return this.get(i)}has(i){return this.hasRaw(i.name)}hasRaw(i){return this.map.has(i)}merge(...i){let o=this;for(const a of i)for(const s of a.keys())o=o.set(s,a.get(s));return o}keys(){return[...this.map.keys()].map(i=>new r(i))}toJS(){return this.map.toJS()}toString(){return`ActionContext(${JSON.stringify(this.map.toJS())})`}[Symbol.for("nodejs.util.inspect.custom")](){return`ActionContext(${JSON.stringify(this.map.toJS(),null," ")})`}static ensureActionContext(i){return i instanceof pn?i:new pn((0,e.Map)(i??{}))}};Zt.ActionContext=t;class r{constructor(i){this.name=i}}return Zt.ActionContextKey=r,Zt}var Gr={},zs;function Lf(){if(zs)return Gr;zs=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.Bus=void 0;let e=class{constructor(r){this.actors=[],this.observers=[],this.dependencyLinks=new Map,Object.assign(this,r),this.failMessage=`All actors over bus ${this.name} failed to handle an action`}subscribe(r){this.actors.push(r),this.reorderForDependencies()}subscribeObserver(r){this.observers.push(r)}unsubscribe(r){const n=this.actors.indexOf(r);return n>=0?(this.actors.splice(n,1),!0):!1}unsubscribeObserver(r){const n=this.observers.indexOf(r);return n>=0?(this.observers.splice(n,1),!0):!1}publish(r){return this.actors.map(n=>({actor:n,reply:n.test(r)}))}onRun(r,n,i){for(const o of this.observers)o.onRun(r,n,i)}addDependencies(r,n){for(const i of n){let o=this.dependencyLinks.get(i);o||(o=[],this.dependencyLinks.set(i,o)),o.push(r)}this.reorderForDependencies()}reorderForDependencies(){if(this.dependencyLinks.size>0){const r=[];for(const n of this.dependencyLinks.keys()){const i=this.actors.indexOf(n);i>=0&&(this.actors.splice(i,1),r.push(n))}for(;r.length>0;){let n=-1;for(let o=0;o<r.length;o++){let a=!0;for(const s of this.dependencyLinks.get(r[o]))if(!this.actors.includes(s)&&r.includes(s)){a=!1;break}if(a){n=o;break}}if(n<0)throw new Error(`Cyclic dependency links detected in bus ${this.name}`);const i=r.splice(n,1)[0];this.actors.push(i)}}}};return Gr.Bus=e,Gr}var Vr={},Bs;function Mh(){if(Bs)return Vr;Bs=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.BusIndexed=void 0;const e=Lf();let t=class extends e.Bus{constructor(n){super(n),this.actorsIndex={}}subscribe(n){const i=this.getActorIdentifiers(n)??["_undefined_"];for(const o of i){let a=this.actorsIndex[o];a||(a=this.actorsIndex[o]=[]),a.push(n),super.subscribe(n)}}unsubscribe(n){const i=this.getActorIdentifiers(n)??["_undefined_"];let o=!1;for(const a of i){const s=this.actorsIndex[a];if(s){const l=s.indexOf(n);l>=0&&s.splice(l,1),s.length===0&&delete this.actorsIndex[a]}o=o||super.unsubscribe(n)}return o}publish(n){const i=this.getActionIdentifier(n);return i?[...this.actorsIndex[i]||[],...this.actorsIndex._undefined_||[]].map(a=>({actor:a,reply:a.test(n)})):super.publish(n)}getActorIdentifiers(n){const i=this.actorIdentifierFields.reduce((o,a)=>o[a],n);if(i)return Array.isArray(i)?i:[i]}getActionIdentifier(n){return this.actionIdentifierFields.reduce((i,o)=>i[o],n)}};return Vr.BusIndexed=t,Vr}var Yr={},Ks;function Df(){if(Ks)return Yr;Ks=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.CONTEXT_KEY_LOGGER=void 0;const e=Cf();return Yr.CONTEXT_KEY_LOGGER=new e.ActionContextKey("@comunica/core:log"),Yr}var Jr={},Hs;function Ph(){if(Hs)return Jr;Hs=1,Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.ActionObserver=void 0;let e=class{constructor(r){Object.assign(this,r)}};return Jr.ActionObserver=e,Jr}var Qr={},Gs;function Ch(){if(Gs)return Qr;Gs=1,Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.Actor=void 0;const e=Df();let t=class ir{constructor(n){this.beforeActors=[],Object.assign(this,n),this.bus.subscribe(this),this.beforeActors.length>0&&this.bus.addDependencies(this,this.beforeActors),n.busFailMessage&&(this.bus.failMessage=n.busFailMessage)}static getContextLogger(n){return n.get(e.CONTEXT_KEY_LOGGER)}runObservable(n,i){const o=this.run(n,i);return this.bus.onRun(this,n,o),o}getDefaultLogData(n,i){const o=i?i():{};return o.actor=this.name,o}logTrace(n,i,o){const a=ir.getContextLogger(n);a&&a.trace(i,this.getDefaultLogData(n,o))}logDebug(n,i,o){const a=ir.getContextLogger(n);a&&a.debug(i,this.getDefaultLogData(n,o))}logInfo(n,i,o){const a=ir.getContextLogger(n);a&&a.info(i,this.getDefaultLogData(n,o))}logWarn(n,i,o){const a=ir.getContextLogger(n);a&&a.warn(i,this.getDefaultLogData(n,o))}logError(n,i,o){const a=ir.getContextLogger(n);a&&a.error(i,this.getDefaultLogData(n,o))}logFatal(n,i,o){const a=ir.getContextLogger(n);a&&a.fatal(i,this.getDefaultLogData(n,o))}};return Qr.Actor=t,Qr}var Xr={},Vs;function Lh(){if(Vs)return Xr;Vs=1,Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.Mediator=void 0;let e=class sa{constructor(r){Object.assign(this,r)}publish(r){const n=this.bus.publish(r);if(n.length===0)throw new Error(`No actors are able to reply to a message in the bus ${this.bus.name}`);return n}async mediateActor(r){return await this.mediateWith(r,this.publish(r))}async mediateTestable(r){return(await this.mediateActor(r)).mapAsync((i,o)=>i.runObservable(r,o))}async mediate(r){return(await this.mediateTestable(r)).getOrThrow()}constructFailureMessage(r,n){const i=`
2
- `;return`${this.bus.failMessage.replaceAll(/\$\{(.*?)\}/gu,(a,s)=>sa.getObjectValue({action:r},s.split("."))||a)}
3
- Error messages of failing actors:${i}${n.join(i)}`}static getObjectValue(r,n){if(n.length===0)return r;if(r)return sa.getObjectValue(r[n[0]],n.slice(1))}};return Xr.Mediator=e,Xr}var We={},Ys;function Dh(){if(Ys)return We;Ys=1,Object.defineProperty(We,"__esModule",{value:!0}),We.TestResultFailed=We.TestResultPassed=We.failTest=We.passTestVoidWithSideData=We.passTestWithSideData=We.passTestVoid=We.passTest=void 0;function e(s){return new o(s,void 0)}We.passTest=e;function t(){return new o(!0,void 0)}We.passTestVoid=t;function r(s,l){return new o(s,l)}We.passTestWithSideData=r;function n(s){return new o(!0,s)}We.passTestVoidWithSideData=n;function i(s){return new a(s)}We.failTest=i;class o{constructor(l,c){this.value=l,this.sideData=c}isPassed(){return!0}isFailed(){return!1}get(){return this.value}getOrThrow(){return this.value}getSideData(){return this.sideData}getFailMessage(){}map(l){return new o(l(this.value,this.sideData),this.sideData)}async mapAsync(l){return new o(await l(this.value,this.sideData),this.sideData)}}We.TestResultPassed=o;class a{constructor(l){this.failMessage=l}isPassed(){return!1}isFailed(){return!0}get(){}getOrThrow(){throw new Error(this.getFailMessage())}getSideData(){throw new Error(this.getFailMessage())}getFailMessage(){return this.failMessage}map(){return this}async mapAsync(){return this}}return We.TestResultFailed=a,We}var Js;function zt(){return Js||(Js=1,(function(e){var t=Xt&&Xt.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=Xt&&Xt.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Cf(),e),r(Lf(),e),r(Mh(),e),r(Df(),e),r(Ph(),e),r(Ch(),e),r(Lh(),e),r(Dh(),e)})(Xt)),Xt}var Qs;function kh(){if(Qs)return Kr;Qs=1,Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.ActionObserverHttp=void 0;const e=zt();class t extends e.ActionObserver{constructor(n){super(n),this.requests=0,this.bus.subscribeObserver(this),this.httpInvalidator.addInvalidateListener(()=>{this.requests=0})}onRun(n,i,o){this.observedActors.includes(n.name)&&this.requests++}}return Kr.ActionObserverHttp=t,Kr}var Zr={},er={},en={},tr={},tn={},Xs;function kf(){if(Xs)return tn;Xs=1,Object.defineProperty(tn,"__esModule",{value:!0}),tn.ActorAbstractMediaTyped=void 0;const e=zt();let t=class extends e.Actor{constructor(n){super(n)}async run(n){if("handle"in n){const i=n;return{handle:await this.runHandle(i.handle,i.handleMediaType,n.context)}}if("mediaTypes"in n)return{mediaTypes:await this.getMediaTypes(n.context)};if("mediaTypeFormats"in n)return{mediaTypeFormats:await this.getMediaTypeFormats(n.context)};throw new Error("Either a handle, mediaTypes or mediaTypeFormats action needs to be provided")}async test(n){if("handle"in n){const i=n;return(await this.testHandle(i.handle,i.handleMediaType,n.context)).map(o=>({handle:o}))}return"mediaTypes"in n?(await this.testMediaType(n.context)).map(i=>({mediaTypes:i})):"mediaTypeFormats"in n?(await this.testMediaTypeFormats(n.context)).map(i=>({mediaTypeFormats:i})):(0,e.failTest)("Either a handle, mediaTypes or mediaTypeFormats action needs to be provided")}};return tn.ActorAbstractMediaTyped=t,tn}var rn={},Zs;function xh(){if(Zs)return rn;Zs=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.ActorAbstractMediaTypedFixed=void 0;const e=zt(),t=kf();let r=class extends t.ActorAbstractMediaTyped{constructor(i){super(i);const o=this.priorityScale||this.priorityScale===0?this.priorityScale:1;if(this.mediaTypePriorities)for(const[a,[s,l]]of Object.entries(this.mediaTypePriorities).entries())this.mediaTypePriorities[s]=o*l;this.mediaTypePriorities=Object.freeze(this.mediaTypePriorities),this.mediaTypeFormats=Object.freeze(this.mediaTypeFormats)}async testHandle(i,o,a){return!o||!(o in this.mediaTypePriorities)?(0,e.failTest)(`Unrecognized media type: ${o}`):await this.testHandleChecked(i,a)}async testMediaType(i){return(0,e.passTestVoid)()}async getMediaTypes(i){return this.mediaTypePriorities}async testMediaTypeFormats(i){return(0,e.passTestVoid)()}async getMediaTypeFormats(i){return this.mediaTypeFormats}};return rn.ActorAbstractMediaTypedFixed=r,rn}var eu;function xf(){return eu||(eu=1,(function(e){var t=tr&&tr.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=tr&&tr.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(kf(),e),r(xh(),e)})(tr)),tr}var tu;function Nh(){if(tu)return en;tu=1,Object.defineProperty(en,"__esModule",{value:!0}),en.ActorQueryResultSerialize=void 0;const e=xf();let t=class extends e.ActorAbstractMediaTyped{constructor(n){super(n)}};return en.ActorQueryResultSerialize=t,en}var nn={},ru;function $h(){if(ru)return nn;ru=1,Object.defineProperty(nn,"__esModule",{value:!0}),nn.ActorQueryResultSerializeFixedMediaTypes=void 0;const e=xf(),t=zt();let r=class extends e.ActorAbstractMediaTypedFixed{constructor(i){super(i)}async testHandleChecked(i,o){return(0,t.passTestVoid)()}};return nn.ActorQueryResultSerializeFixedMediaTypes=r,nn}var nu;function Nf(){return nu||(nu=1,(function(e){var t=er&&er.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=er&&er.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Nh(),e),r($h(),e)})(er)),er}var rr={},we={},iu;function qh(){if(iu)return we;iu=1,Object.defineProperty(we,"__esModule",{value:!0}),we.KeysStatistics=we.KeysRdfJoin=we.KeysMergeBindingsContext=we.KeysRdfUpdateQuads=we.KeysQuerySourceIdentify=we.KeysRdfParseHtmlScript=we.KeysRdfParseJsonLd=we.KeysQueryOperation=we.KeysExpressionEvaluator=we.KeysInitQuery=we.KeysHttpProxy=we.KeysHttpMemento=we.KeysHttpWayback=we.KeysHttp=we.KeysCore=void 0;const e=zt();return we.KeysCore={log:e.CONTEXT_KEY_LOGGER},we.KeysHttp={includeCredentials:new e.ActionContextKey("@comunica/bus-http:include-credentials"),auth:new e.ActionContextKey("@comunica/bus-http:auth"),fetch:new e.ActionContextKey("@comunica/bus-http:fetch"),httpTimeout:new e.ActionContextKey("@comunica/bus-http:http-timeout"),httpBodyTimeout:new e.ActionContextKey("@comunica/bus-http:http-body-timeout"),httpRetryCount:new e.ActionContextKey("@comunica/bus-http:http-retry-count"),httpRetryDelayFallback:new e.ActionContextKey("@comunica/bus-http:http-retry-delay-fallback"),httpRetryDelayLimit:new e.ActionContextKey("@comunica/bus-http:http-retry-delay-limit"),httpRetryStatusCodes:new e.ActionContextKey("@comunica/bus-http:http-retry-status-codes")},we.KeysHttpWayback={recoverBrokenLinks:new e.ActionContextKey("@comunica/bus-http:recover-broken-links")},we.KeysHttpMemento={datetime:new e.ActionContextKey("@comunica/actor-http-memento:datetime")},we.KeysHttpProxy={httpProxyHandler:new e.ActionContextKey("@comunica/actor-http-proxy:httpProxyHandler")},we.KeysInitQuery={querySourcesUnidentified:new e.ActionContextKey("@comunica/actor-init-query:querySourcesUnidentified"),initialBindings:new e.ActionContextKey("@comunica/actor-init-query:initialBindings"),queryFormat:new e.ActionContextKey("@comunica/actor-init-query:queryFormat"),graphqlSingularizeVariables:new e.ActionContextKey("@comunica/actor-init-query:singularizeVariables"),lenient:new e.ActionContextKey("@comunica/actor-init-query:lenient"),queryString:new e.ActionContextKey("@comunica/actor-init-query:queryString"),query:new e.ActionContextKey("@comunica/actor-init-query:query"),baseIRI:new e.ActionContextKey("@comunica/actor-init-query:baseIRI"),fileBaseIRI:new e.ActionContextKey("@comunica/actor-init-query:fileBaseIRI"),functionArgumentsCache:new e.ActionContextKey("@comunica/actor-init-query:functionArgumentsCache"),queryTimestamp:new e.ActionContextKey("@comunica/actor-init-query:queryTimestamp"),queryTimestampHighResolution:new e.ActionContextKey("@comunica/actor-init-query:queryTimestampHighResolution"),extensionFunctionCreator:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctionCreator"),extensionFunctions:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctions"),extensionFunctionsAlwaysPushdown:new e.ActionContextKey("@comunica/actor-init-query:extensionFunctionsAlwaysPushdown"),cliArgsHandlers:new e.ActionContextKey("@comunica/actor-init-query:cliArgsHandlers"),explain:new e.ActionContextKey("@comunica/actor-init-query:explain"),physicalQueryPlanLogger:new e.ActionContextKey("@comunica/actor-init-query:physicalQueryPlanLogger"),physicalQueryPlanNode:new e.ActionContextKey("@comunica/actor-init-query:physicalQueryPlanNode"),jsonLdContext:new e.ActionContextKey("@context"),invalidateCache:new e.ActionContextKey("@comunica/actor-init-query:invalidateCache"),dataFactory:new e.ActionContextKey("@comunica/actor-init-query:dataFactory"),distinctConstruct:new e.ActionContextKey("@comunica/actor-init-query:distinctConstruct")},we.KeysExpressionEvaluator={extensionFunctionCreator:new e.ActionContextKey("@comunica/utils-expression-evaluator:extensionFunctionCreator"),superTypeProvider:new e.ActionContextKey("@comunica/utils-expression-evaluator:superTypeProvider"),defaultTimeZone:new e.ActionContextKey("@comunica/utils-expression-evaluator:defaultTimeZone"),actionContext:new e.ActionContextKey("@comunica/utils-expression-evaluator:actionContext")},we.KeysQueryOperation={operation:new e.ActionContextKey("@comunica/bus-query-operation:operation"),joinLeftMetadata:new e.ActionContextKey("@comunica/bus-query-operation:joinLeftMetadata"),joinRightMetadatas:new e.ActionContextKey("@comunica/bus-query-operation:joinRightMetadatas"),joinBindings:new e.ActionContextKey("@comunica/bus-query-operation:joinBindings"),readOnly:new e.ActionContextKey("@comunica/bus-query-operation:readOnly"),isPathArbitraryLengthDistinctKey:new e.ActionContextKey("@comunica/bus-query-operation:isPathArbitraryLengthDistinct"),limitIndicator:new e.ActionContextKey("@comunica/bus-query-operation:limitIndicator"),unionDefaultGraph:new e.ActionContextKey("@comunica/bus-query-operation:unionDefaultGraph"),querySources:new e.ActionContextKey("@comunica/bus-query-operation:querySources")},we.KeysRdfParseJsonLd={documentLoader:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:documentLoader"),strictValues:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:strictValues"),parserOptions:new e.ActionContextKey("@comunica/actor-rdf-parse-jsonld:parserOptions")},we.KeysRdfParseHtmlScript={processingHtmlScript:new e.ActionContextKey("@comunica/actor-rdf-parse-html-script:processingHtmlScript"),extractAllScripts:new e.ActionContextKey("extractAllScripts")},we.KeysQuerySourceIdentify={sourceIds:new e.ActionContextKey("@comunica/bus-query-source-identify:sourceIds"),hypermediaSourcesAggregatedStores:new e.ActionContextKey("@comunica/bus-query-source-identify:hypermediaSourcesAggregatedStores"),traverse:new e.ActionContextKey("@comunica/bus-query-source-identify:traverse")},we.KeysRdfUpdateQuads={destination:new e.ActionContextKey("@comunica/bus-rdf-update-quads:destination")},we.KeysMergeBindingsContext={sourcesBinding:new e.ActionContextKey("@comunica/bus-merge-bindings-context:sourcesBinding")},we.KeysRdfJoin={lastPhysicalJoin:new e.ActionContextKey("@comunica/bus-rdf-join:lastPhysicalJoin")},we.KeysStatistics={discoveredLinks:new e.ActionContextKey("@comunica/statistic:discoveredLinks"),dereferencedLinks:new e.ActionContextKey("@comunica/statistic:dereferencedLinks"),intermediateResults:new e.ActionContextKey("@comunica/statistic:intermediateResults")},we}var ou;function Uh(){return ou||(ou=1,(function(e){var t=rr&&rr.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=rr&&rr.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(qh(),e)})(rr)),rr}var Yi={},on={},au;function jh(){if(au)return on;au=1,Object.defineProperty(on,"__esModule",{value:!0}),on.LinkedList=void 0;class e{constructor(){this._length=0,this._head=null,this._tail=null}get length(){return this._length}get first(){var r;return(r=this._head)===null||r===void 0?void 0:r.value}get last(){var r;return(r=this._tail)===null||r===void 0?void 0:r.value}get empty(){return this._head===null}push(r){const n={value:r,next:null};this._tail===null?this._head=this._tail=n:this._tail.next=this._tail=n,this._length++}shift(){if(this._head===null)return;const{value:r,next:n}=this._head;return this._head=n,n===null&&(this._tail=null),this._length--,r}clear(){this._length=0,this._head=this._tail=null}}return on.LinkedList=e,on}var an={};let Ji=1;const Ha=new Map;let Qi=!1,Ga,$f=(e,...t)=>(Ha.set(Ji,[e,t]),Ga(Ji),Ji++),Va=e=>{Ha.delete(e)};function Ya(e){if(Qi)setTimeout(Ya,0,e);else{const t=Ha.get(e);if(t){Qi=!0;try{t[0](...t[1])}finally{Va(e),Qi=!1}}}}function Fh(){const e=new MessageChannel;e.port1.onmessage=t=>{Ya(t.data)},Ga=t=>{e.port2.postMessage(t)}}function Wh(){const e=`setImmediate$${Math.random()}$`;window.addEventListener("message",t=>{typeof t.data=="string"&&t.data.startsWith(e)&&Ya(+t.data.slice(e.length))}),Ga=t=>{window.postMessage(e+t,"*")}}const Zn=typeof self>"u"?typeof global>"u"?void 0:global:self;Zn.setImmediate?($f=Zn.setImmediate,Va=Zn.clearImmediate):Zn.importScripts?Fh():Wh();const zh=Object.freeze(Object.defineProperty({__proto__:null,get clearImmediate(){return Va},get setImmediate(){return $f}},Symbol.toStringTag,{value:"Module"})),Bh=wl(zh);var su;function Kh(){if(su)return an;su=1,Object.defineProperty(an,"__esModule",{value:!0}),an.createTaskScheduler=void 0;const e=Bh,t=Promise.resolve(void 0);function r(n=e.setImmediate){const i=typeof queueMicrotask=="function"?queueMicrotask:s=>t.then(s);let o=0,a=null;return s=>{a!==null?a.push(s):++o<100?i(s):(a=[s],n(()=>{for(const l of a)i(l);a=null,o=0}))}}return an.createTaskScheduler=r,an}var uu;function qf(){return uu||(uu=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isIterator=e.isIterable=e.isSourceExpression=e.isPromise=e.isEventEmitter=e.isFunction=e.range=e.union=e.fromIterable=e.fromIterator=e.fromArray=e.single=e.empty=e.wrap=e.WrappingIterator=e.ClonedIterator=e.UnionIterator=e.MultiTransformIterator=e.SimpleTransformIterator=e.TransformIterator=e.BufferedIterator=e.MappingIterator=e.DESTINATION=e.identity=e.IntegerIterator=e.ArrayIterator=e.SingletonIterator=e.EmptyIterator=e.AsyncIterator=e.DESTROYED=e.ENDED=e.CLOSED=e.CLOSING=e.OPEN=e.INIT=e.setTaskScheduler=e.getTaskScheduler=e.scheduleTask=e.LinkedList=void 0;const t=Pt(),r=jh();Object.defineProperty(e,"LinkedList",{enumerable:!0,get:function(){return r.LinkedList}});let i=Kh().createTaskScheduler();function o(j){i(j)}e.scheduleTask=o;function a(){return i}e.getTaskScheduler=a;function s(j){i=j}e.setTaskScheduler=s,e.INIT=1,e.OPEN=2,e.CLOSING=4,e.CLOSED=8,e.ENDED=16,e.DESTROYED=32;class l extends t.EventEmitter{constructor(u=e.OPEN){super(),this._readable=!1,this._state=u,this.on("newListener",c)}_changeState(u,d=!1){const b=u>this._state&&this._state<e.ENDED;return b&&(this._state=u,u===e.ENDED&&(d?i(()=>this.emit("end")):this.emit("end"))),b}read(){return null}forEach(u,d){this.on("data",re(u,d))}close(){this._changeState(e.CLOSED)&&this._endAsync()}destroy(u){this.done||this._destroy(u,d=>{u=u||d,u&&this.emit("error",u),this._end(!0)})}_destroy(u,d){d()}_end(u=!1){this._changeState(u?e.DESTROYED:e.ENDED)&&(this._readable=!1,this.removeAllListeners("readable"),this.removeAllListeners("data"),this.removeAllListeners("end"))}_endAsync(){i(()=>this._end())}get readable(){return this._readable}set readable(u){u=!!u&&!this.done,this._readable!==u&&(this._readable=u,u&&i(()=>this.emit("readable")))}get closed(){return this._state>=e.CLOSING}get ended(){return this._state===e.ENDED}get destroyed(){return this._state===e.DESTROYED}get done(){return this._state>=e.ENDED}toString(){const u=this._toStringDetails();return`[${this.constructor.name}${u?` ${u}`:""}]`}_toStringDetails(){return""}toArray(u){const d=[],b=typeof u?.limit=="number"?u.limit:1/0;return this.ended||b<=0?Promise.resolve(d):new Promise((T,q)=>{const U=()=>T(d),y=M=>{d.push(M),d.length>=b&&(this.removeListener("error",q),this.removeListener("data",y),this.removeListener("end",U),T(d))};this.on("error",q),this.on("data",y),this.on("end",U)})}getProperty(u,d){const b=this._properties;if(!d)return b&&b[u];if(b&&u in b)i(()=>d(b[u]));else{let T;(T=this._propertyCallbacks)||(this._propertyCallbacks=T=Object.create(null)),u in T?T[u].push(d):T[u]=[d]}}setProperty(u,d){const b=this._properties||(this._properties=Object.create(null));b[u]=d;const T=this._propertyCallbacks||{},q=T[u];if(q){delete T[u],i(()=>{for(const U of q)U(d)});for(u in T)return;delete this._propertyCallbacks}}getProperties(){const u=this._properties,d={};for(const b in u)d[b]=u[b];return d}setProperties(u){for(const d in u)this.setProperty(d,u[d])}copyProperties(u,d){for(const b of d)u.getProperty(b,T=>this.setProperty(b,T))}transform(u){return new L(this,u)}map(u,d){return new P(this,re(u,d))}filter(u,d){return this.map(function(b){return u.call(d||this,b)?b:null})}uniq(u=w){const d=new Set;return this.filter(function(b){const T=u.call(this,b);return d.has(T)?!1:(d.add(T),!0)})}prepend(u){return this.transform({prepend:u})}append(u){return this.transform({append:u})}surround(u,d){return this.transform({prepend:u,append:d})}skip(u){return this.map(d=>u-- >0?null:d)}take(u){return this.transform({limit:u})}range(u,d){return this.transform({offset:u,limit:Math.max(d-u+1,0)})}clone(){return new K(this)}[Symbol.asyncIterator](){const u=this;let d=null,b=null,T=null;u.addListener("readable",q),u.addListener("end",q),u.addListener("error",U);function q(){if(d!==null)if(T!==null)U(T);else if(u.done)d({done:!0,value:void 0}),d=b=null,y();else{const M=u.read();M!==null&&(d({done:!1,value:M}),d=b=null)}}function U(M){b!==null?(b(M),d=b=T=null,y()):T===null&&(T=M)}function y(){u.removeListener("readable",q),u.removeListener("end",q),u.removeListener("error",U)}return{next(){return new Promise((M,W)=>{d=M,b=W,q()})}}}}e.AsyncIterator=l;function c(j){j==="data"&&(this.removeListener("newListener",c),g(this,"readable",p),this.readable&&i(()=>p.call(this)))}function p(){let j;for(;this.listenerCount("data")!==0&&(j=this.read())!==null;)this.emit("data",j);this.listenerCount("data")===0&&!this.done&&(this.removeListener("readable",p),g(this,"newListener",c))}function g(j,u,d){j.listeners(u).includes(d)||j.on(u,d)}class S extends l{constructor(){super(),this._changeState(e.ENDED,!0)}}e.EmptyIterator=S;class O extends l{constructor(u){super(),this._item=u,u===null?this.close():this.readable=!0}read(){const u=this._item;return this._item=null,this.close(),u}_toStringDetails(){return this._item===null?"":`(${this._item})`}}e.SingletonIterator=O;class x extends l{constructor(u=[],{autoStart:d=!0,preserve:b=!0}={}){super();const T=b||!Array.isArray(u)?[...u]:u;this._index=0,this._sourceStarted=d!==!1,this._truncateThreshold=b?-1:64,this._sourceStarted&&T.length===0?this.close():this._buffer=T,this.readable=!0}read(){this._sourceStarted||(this._sourceStarted=!0);let u=null;return this._buffer&&(this._index<this._buffer.length&&(u=this._buffer[this._index++]),this._index===this._buffer.length?(delete this._buffer,this.close()):this._index===this._truncateThreshold&&(this._buffer.splice(0,this._truncateThreshold),this._index=0)),u}_toStringDetails(){return`(${this._buffer?this._buffer.length-this._index:0})`}_destroy(u,d){delete this._buffer,d()}toArray(u={}){if(!this._buffer)return Promise.resolve([]);const{length:d}=this._buffer,b=this._index,T=typeof u.limit!="number"?d:b+u.limit,q=this._buffer.slice(b,T);return this._index=T,T>=d&&this.close(),Promise.resolve(q)}}e.ArrayIterator=x;class v extends l{constructor({start:u=0,step:d=1,end:b}={}){super(),Number.isFinite(u)&&(u=Math.trunc(u)),this._next=u,Number.isFinite(d)&&(d=Math.trunc(d)),this._step=d;const T=d>=0,q=T?1/0:-1/0;Number.isFinite(b)?b=Math.trunc(b):b!==-q&&(b=q),this._last=b,!Number.isFinite(u)||(T?u>b:u<b)?this.close():this.readable=!0}read(){if(this.closed)return null;const u=this._next,d=this._step,b=this._last,T=this._next+=d;return(d>=0?T>b:T<b)&&this.close(),u}_toStringDetails(){return`(${this._next}...${this._last})`}}e.IntegerIterator=v;function w(j){return j}e.identity=w,e.DESTINATION=Symbol("destination");class P extends l{constructor(u,d=w,b={}){super(),this._map=d,this._source=E(u),this._destroySource=b.destroySource!==!1,u.done?this.close():(this._source[e.DESTINATION]=this,this._source.on("end",ae),this._source.on("error",se),this._source.on("readable",V),this.readable=this._source.readable)}read(){if(!this.done){if(this._source.readable){let u,d;for(;(u=this._source.read())!==null;)if((d=this._map(u))!==null)return d}this.readable=!1,this._source.done&&this.close()}return null}_end(u){this._source.removeListener("end",ae),this._source.removeListener("error",se),this._source.removeListener("readable",V),delete this._source[e.DESTINATION],this._destroySource&&this._source.destroy(),super._end(u)}}e.MappingIterator=P;function E(j,u=!1){if(!j||!oe(j.read)||!oe(j.on))throw new TypeError(`Invalid source: ${j}`);if(!u&&j[e.DESTINATION])throw new Error("The source already has a destination");return j}class m extends l{constructor({maxBufferSize:u=4,autoStart:d=!0}={}){super(e.INIT),this._buffer=new r.LinkedList,this._maxBufferSize=4,this._reading=!0,this._pushedCount=0,this.maxBufferSize=u,i(()=>this._init(d)),this._sourceStarted=d!==!1}get maxBufferSize(){return this._maxBufferSize}set maxBufferSize(u){u!==1/0&&(u=Number.isFinite(u)?Math.max(Math.trunc(u),1):4),this._maxBufferSize!==u&&(this._maxBufferSize=u,this._state===e.OPEN&&this._fillBuffer())}_init(u){let d=!1;this._reading=!0,this._begin(()=>{if(d)throw new Error("done callback called multiple times");d=!0,this._reading=!1,this._changeState(e.OPEN),u?this._fillBufferAsync():this.readable=!0})}_begin(u){u()}read(){if(this.done)return null;this._sourceStarted||(this._sourceStarted=!0);const u=this._buffer;let d;return u.empty?(d=null,this.readable=!1):d=u.shift(),!this._reading&&u.length<this._maxBufferSize&&(this.closed?u.empty&&this._endAsync():this._fillBufferAsync()),d}_read(u,d){d()}_push(u){this.done||(this._pushedCount++,this._buffer.push(u),this.readable=!0)}_fillBuffer(){let u;this._reading||(this.closed?this._completeClose():(u=Math.min(this._maxBufferSize-this._buffer.length,128))>0&&(this._pushedCount=0,this._reading=!0,this._read(u,()=>{if(!u)throw new Error("done callback called multiple times");u=0,this._reading=!1,this.closed?this._completeClose():this._pushedCount&&(this.readable=!0,this._buffer.length<this._maxBufferSize/2&&this._fillBufferAsync())})))}_fillBufferAsync(){this._reading||(this._reading=!0,i(()=>{this._reading=!1,this._fillBuffer()}))}close(){this._reading?this._changeState(e.CLOSING):this._completeClose()}_completeClose(){this._changeState(e.CLOSED)&&(this._reading=!0,this._flush(()=>{if(!this._reading)throw new Error("done callback called multiple times");this._reading=!1,this._buffer.empty&&this._endAsync()}))}_destroy(u,d){this._buffer.clear(),d()}_flush(u){u()}_toStringDetails(){const u=this._buffer;return`{${u.empty?"":`next: ${u.first}, `}buffer: ${u.length}}`}}e.BufferedIterator=m;class Q extends m{constructor(u,d=u||{}){super(d),this._boundPush=b=>this._push(b),N(u)||(u=d.source),ie(u)?this.source=u:u&&(this._createSource=I(u)?()=>u:u,this._sourceStarted&&this._loadSourceAsync()),this._optional=!!d.optional,this._destroySource=d.destroySource!==!1}get source(){return oe(this._createSource)&&this._loadSourceAsync(),this._source}set source(u){const d=this._source=this._validateSource(u);d[e.DESTINATION]=this,this.done?this._destroySource&&d.destroy():d.done?this.close():(d.on("end",Y),d.on("readable",ce),d.on("error",se))}_loadSourceAsync(){oe(this._createSource)&&(Promise.resolve(this._createSource()).then(u=>{delete this._createSource,this.source=u,this._fillBuffer()},u=>this.emit("error",u)),this._createSource=null)}_validateSource(u,d=!1){if(this._source||typeof this._createSource<"u")throw new Error("The source cannot be changed after it has been set");return E(u,d)}_read(u,d){const b=()=>{this._pushedCount<u&&!this.closed?i(()=>this._readAndTransform(b,d)):d()};this._readAndTransform(b,d)}_readAndTransform(u,d){let b;const T=this.source;!T||T.done||(b=T.read())===null?d():this._optional?this._optionalTransform(b,u):this._transform(b,u,this._boundPush)}_optionalTransform(u,d){const b=this._pushedCount;this._transform(u,()=>{b===this._pushedCount&&this._push(u),d()},this._boundPush)}_transform(u,d,b){b(u),d()}_closeWhenDone(){this.close()}_end(u){const d=this._source;d&&(d.removeListener("end",Y),d.removeListener("error",se),d.removeListener("readable",ce),delete d[e.DESTINATION],this._destroySource&&d.destroy()),super._end(u)}}e.TransformIterator=Q;function V(){this[e.DESTINATION].readable=!0}function se(j){this[e.DESTINATION].emit("error",j)}function ae(){this[e.DESTINATION].close()}function Y(){this[e.DESTINATION]._closeWhenDone()}function ce(){this[e.DESTINATION]._sourceStarted!==!1&&this[e.DESTINATION]._fillBuffer()}class L extends Q{constructor(u,d){if(super(u,d),this._offset=0,this._limit=1/0,this._filter=b=>!0,d=d||(N(u)?null:u),d){const b=oe(d)?d:d.transform,{limit:T,offset:q,filter:U,map:y,prepend:M,append:W}=d;q===1/0||T===-1/0?this._limit=0:(Number.isFinite(q)&&(this._offset=Math.max(Math.trunc(q),0)),Number.isFinite(T)&&(this._limit=Math.max(Math.trunc(T),0)),oe(U)&&(this._filter=U),oe(y)&&(this._map=y),this._transform=oe(b)?b:null),M&&(this._prepender=ie(M)?M:_(M)),W&&(this._appender=ie(W)?W:_(W))}}_read(u,d){const b=()=>this._readAndTransformSimple(u,T,d);this._readAndTransformSimple(u,T,d);function T(){i(b)}}_readAndTransformSimple(u,d,b){let T;const{source:q}=this;if(!q||q.done){b();return}for(this._limit===0&&this.close();!this.closed&&this._pushedCount<u&&(T=q.read())!==null;){if(!this._filter(T)||this._offset!==0&&this._offset--)continue;const U=typeof this._map>"u"?T:this._map(T);if(U===null)this._optional&&this._push(T);else if(!oe(this._transform))this._push(U);else{this._optional?this._optionalTransform(U,d):this._transform(U,d,this._boundPush);return}--this._limit===0&&this.close()}b()}_begin(u){this._insert(this._prepender,u),delete this._prepender}_flush(u){this._insert(this._appender,u),delete this._appender}_insert(u,d){const b=q=>this._push(q);!u||u.done?d():(u.on("data",b),u.on("end",T));function T(){u.removeListener("data",b),u.removeListener("end",T),d()}}}e.SimpleTransformIterator=L;class R extends Q{constructor(u,d){if(super(u,d),this._transformerQueue=[],d){const b=oe(d)?d:d.multiTransform;b&&(this._createTransformer=b)}}_read(u,d){const b=this._transformerQueue,T=this._optional;let q,U;for(;(q=b[0])&&q.transformer.done;){T&&q.item!==null&&(u--,this._push(q.item)),b.shift();const{transformer:M}=q;M.removeListener("end",ce),M.removeListener("readable",ce),M.removeListener("error",se)}const{source:y}=this;for(;y&&!y.done&&b.length<this.maxBufferSize&&(U=y.read(),U!==null);){const M=this._createTransformer(U)||new S;M[e.DESTINATION]=this,M.on("end",ce),M.on("readable",ce),M.on("error",se),b.push({transformer:M,item:U})}if(q=b[0],q){const{transformer:M}=q;for(;u-- >0&&(U=M.read())!==null;)this._push(U),T&&(q.item=null)}else y&&y.done&&this.close();d()}_createTransformer(u){return new O(u)}_closeWhenDone(){this._transformerQueue.length||this.close()}_end(u){if(super._end(u),this._destroySource)for(const d of this._transformerQueue)d.transformer.destroy()}}e.MultiTransformIterator=R;class F extends m{constructor(u,d={}){super(d),this._sources=[],this._currentSource=-1;const b=d.autoStart!==!1;if(ie(u))u.on("error",T=>this.emit("error",T)),this._pending={loading:!1,sources:u},b&&this._loadSources();else if(Array.isArray(u)&&u.length>0)for(const T of u)this._addSource(T);else b&&this.close();this._destroySources=d.destroySources!==!1}_loadSources(){const u=this._pending.sources;this._pending.loading=!0,u.done?(delete this._pending,this.close()):(u.on("data",d=>{this._addSource(d),this._fillBufferAsync()}),u.on("end",()=>{delete this._pending,this._fillBuffer()}))}_addSource(u){I(u)&&(u=ue(u)),u.done||(this._sources.push(u),u[e.DESTINATION]=this,u.on("error",se),u.on("readable",ce),u.on("end",A))}_removeEmptySources(){this._sources=this._sources.filter((u,d)=>(u.done&&d<=this._currentSource&&this._currentSource--,!u.done)),this._fillBuffer()}_read(u,d){var b;((b=this._pending)===null||b===void 0?void 0:b.loading)===!1&&this._loadSources();let T=0,q;for(;T!==(T=u);)for(let U=0;U<this._sources.length&&u>0;U++)this._currentSource=(this._currentSource+1)%this._sources.length,(q=this._sources[this._currentSource].read())!==null&&(u--,this._push(q));!this._pending&&this._sources.length===0&&this.close(),d()}_end(u=!1){if(super._end(u),this._destroySources){for(const d of this._sources)d.destroy();this._pending&&(this._pending.sources.destroy(),delete this._pending)}}}e.UnionIterator=F;function A(){this[e.DESTINATION]._removeEmptySources()}class K extends Q{constructor(u){super(u,{autoStart:!1}),this._readPosition=0,this._reading=!1,u&&(this.readable=!0)}_init(){}close(){l.prototype.close.call(this)}get source(){return super.source}set source(u){const d=this._source=this._validateSource(u),b=d&&d[e.DESTINATION]||(d[e.DESTINATION]=new J(d));this.done?this._destroySource&&d.destroy():b.endsAt(0)?this.close():(b.register(this),(d._sourceStarted===!1||b.readAt(0)!==null)&&(this.readable=!0));const T=this._propertyCallbacks;for(const q in T){const U=T[q];for(const y of U)this._getSourceProperty(q,y)}}_validateSource(u,d=!1){const b=u&&u[e.DESTINATION];return super._validateSource(u,!b||b instanceof J)}getProperty(u,d){const{source:b}=this,T=this._properties,q=T&&u in T;if(!d)return q?T&&T[u]:b&&b.getProperty(u);super.getProperty(u,d),b&&!q&&this._getSourceProperty(u,d)}_getSourceProperty(u,d){this.source.getProperty(u,b=>{(!this._properties||!(u in this._properties))&&d(b)})}getProperties(){const u=this.source?this.source.getProperties():{},d=this._properties;for(const b in d)u[b]=d[b];return u}_toStringDetails(){return`{source: ${this.source?this.source.toString():"none"}}`}read(){this._sourceStarted||(this._sourceStarted=!0);const u=this.source;let d=null;if(!this.done&&u){const b=u[e.DESTINATION];(d=b.readAt(this._readPosition))!==null?this._readPosition++:this.readable=!1,b.endsAt(this._readPosition)&&this.close()}return d}_end(u){const d=this.source,b=d?.[e.DESTINATION];b&&b.unregister(this),m.prototype._end.call(this,u)}}e.ClonedIterator=K;class J{constructor(u){if(this._history=[],this._trackers=new Set,this._source=u,!u.done){const d=()=>{for(const q of this._trackers)q.readable=!0},b=q=>{for(const U of this._trackers)U.emit("error",q)},T=()=>{for(const q of this._trackers)q._sourceStarted!==!1&&q._readPosition===this._history.length&&q.close();this._trackers.clear(),u.removeListener("end",T),u.removeListener("error",b),u.removeListener("readable",d)};u.on("end",T),u.on("error",b),u.on("readable",d)}}register(u){this._source.done||this._trackers.add(u)}unregister(u){this._trackers.delete(u)}readAt(u){let d=null;return u<this._history.length?d=this._history[u]:!this._source.done&&(d=this._source.read())!==null&&(this._history[u]=d),d}endsAt(u){return this._source.done&&this._history.length===u}}class ee extends l{constructor(u,d){super(),this._source=null,this._destroySource=d?.destroySource!==!1,I(u)?(this._source=new l,u.then(b=>{this._source=null,this.source=b}).catch(b=>this.emit("error",b))):u&&(this.source=u)}set source(u){let d=u;if(this._source!==null)throw new Error("The source cannot be changed after it has been set");if(G(d)&&(d=d[Symbol.iterator]()),ne(d)){let b=d;d=new t.EventEmitter,d.read=()=>{if(b!==null){let T;for(;!(T=b.next()).done;)if(T.value!==null)return T.value;b=null,this.close()}return null}}else d=E(d);if(this.done){this._destroySource&&oe(d.destroy)&&d.destroy();return}d[e.DESTINATION]=this,d.on("end",ae),d.on("error",se),d.on("readable",V),this._source=d,this.readable=d.readable!==!1}read(){if(this._source!==null&&this._source.readable!==!1){const u=this._source.read();if(u!==null)return u;this.readable=!1}return null}_end(u=!1){this._source!==null&&(this._source.removeListener("end",ae),this._source.removeListener("error",se),this._source.removeListener("readable",V),delete this._source[e.DESTINATION],this._destroySource&&oe(this._source.destroy)&&this._source.destroy(),this._source=null),super._end(u)}}e.WrappingIterator=ee;function ue(j,u){if(u&&("autoStart"in u||"optional"in u||"source"in u||"maxBufferSize"in u))return j&&!ie(j)&&(j=new ee(j)),new Q(j,u);if(!j)return D();if(I(j))return new ee(j,u);if(j instanceof l)return j;if(Array.isArray(j))return _(j);if(G(j)||ne(j)||ie(j))return new ee(j,u);throw new TypeError(`Invalid source: ${j}`)}e.wrap=ue;function D(){return new S}e.empty=D;function Z(j){return new O(j)}e.single=Z;function _(j){return new x(j)}e.fromArray=_;function $(j){return new ee(j)}e.fromIterator=$;function H(j){return new ee(j)}e.fromIterable=H;function C(j){return new F(j)}e.union=C;function X(j,u,d){return new v({start:j,end:u,step:d})}e.range=X;function re(j,u){return u?j.bind(u):j}function oe(j){return typeof j=="function"}e.isFunction=oe;function ie(j){return oe(j?.on)}e.isEventEmitter=ie;function I(j){return oe(j?.then)}e.isPromise=I;function N(j){return j&&(ie(j)||I(j)||oe(j))}e.isSourceExpression=N;function G(j){return j&&Symbol.iterator in j}e.isIterable=G;function ne(j){return oe(j?.next)}e.isIterator=ne})(Yi)),Yi}var Xi={exports:{}},Zi={exports:{}},eo,lu;function De(){if(lu)return eo;lu=1;class e extends Error{constructor(r){if(!Array.isArray(r))throw new TypeError(`Expected input to be an Array, got ${typeof r}`);let n="";for(let i=0;i<r.length;i++)n+=` ${r[i].stack}
4
- `;super(n),this.name="AggregateError",this.errors=r}}return eo={AggregateError:e,ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,r){return t.includes(r)},ArrayPrototypeIndexOf(t,r){return t.indexOf(r)},ArrayPrototypeJoin(t,r){return t.join(r)},ArrayPrototypeMap(t,r){return t.map(r)},ArrayPrototypePop(t,r){return t.pop(r)},ArrayPrototypePush(t,r){return t.push(r)},ArrayPrototypeSlice(t,r,n){return t.slice(r,n)},Error,FunctionPrototypeCall(t,r,...n){return t.call(r,...n)},FunctionPrototypeSymbolHasInstance(t,r){return Function.prototype[Symbol.hasInstance].call(t,r)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,r){return Object.defineProperties(t,r)},ObjectDefineProperty(t,r,n){return Object.defineProperty(t,r,n)},ObjectGetOwnPropertyDescriptor(t,r){return Object.getOwnPropertyDescriptor(t,r)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,r){return Object.setPrototypeOf(t,r)},Promise,PromisePrototypeCatch(t,r){return t.catch(r)},PromisePrototypeThen(t,r,n){return t.then(r,n)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,r){return t.test(r)},SafeSet:Set,String,StringPrototypeSlice(t,r,n){return t.slice(r,n)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,r,n){return t.set(r,n)},Boolean,Uint8Array},eo}var to={exports:{}},ro,fu;function Uf(){return fu||(fu=1,ro={format(e,...t){return e.replace(/%([sdifj])/g,function(...[r,n]){const i=t.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(e){switch(typeof e){case"string":if(e.includes("'"))if(e.includes('"')){if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}else return`"${e}"`;return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}}}),ro}var no,cu;function Ze(){if(cu)return no;cu=1;const{format:e,inspect:t}=Uf(),{AggregateError:r}=De(),n=globalThis.AggregateError||r,i=Symbol("kIsNodeError"),o=["string","function","number","object","Function","Object","boolean","bigint","symbol"],a=/^([A-Z][a-z0-9]*)+$/,s="__node_internal_",l={};function c(w,P){if(!w)throw new l.ERR_INTERNAL_ASSERTION(P)}function p(w){let P="",E=w.length;const m=w[0]==="-"?1:0;for(;E>=m+4;E-=3)P=`_${w.slice(E-3,E)}${P}`;return`${w.slice(0,E)}${P}`}function g(w,P,E){if(typeof P=="function")return c(P.length<=E.length,`Code: ${w}; The provided arguments length (${E.length}) does not match the required ones (${P.length}).`),P(...E);const m=(P.match(/%[dfijoOs]/g)||[]).length;return c(m===E.length,`Code: ${w}; The provided arguments length (${E.length}) does not match the required ones (${m}).`),E.length===0?P:e(P,...E)}function S(w,P,E){E||(E=Error);class m extends E{constructor(...V){super(g(w,P,V))}toString(){return`${this.name} [${w}]: ${this.message}`}}Object.defineProperties(m.prototype,{name:{value:E.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${w}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),m.prototype.code=w,m.prototype[i]=!0,l[w]=m}function O(w){const P=s+w.name;return Object.defineProperty(w,"name",{value:P}),w}function x(w,P){if(w&&P&&w!==P){if(Array.isArray(P.errors))return P.errors.push(w),P;const E=new n([P,w],P.message);return E.code=P.code,E}return w||P}class v extends Error{constructor(P="The operation was aborted",E=void 0){if(E!==void 0&&typeof E!="object")throw new l.ERR_INVALID_ARG_TYPE("options","Object",E);super(P,E),this.code="ABORT_ERR",this.name="AbortError"}}return S("ERR_ASSERTION","%s",Error),S("ERR_INVALID_ARG_TYPE",(w,P,E)=>{c(typeof w=="string","'name' must be a string"),Array.isArray(P)||(P=[P]);let m="The ";w.endsWith(" argument")?m+=`${w} `:m+=`"${w}" ${w.includes(".")?"property":"argument"} `,m+="must be ";const Q=[],V=[],se=[];for(const Y of P)c(typeof Y=="string","All expected entries have to be of type string"),o.includes(Y)?Q.push(Y.toLowerCase()):a.test(Y)?V.push(Y):(c(Y!=="object",'The value "object" should be written as "Object"'),se.push(Y));if(V.length>0){const Y=Q.indexOf("object");Y!==-1&&(Q.splice(Q,Y,1),V.push("Object"))}if(Q.length>0){switch(Q.length){case 1:m+=`of type ${Q[0]}`;break;case 2:m+=`one of type ${Q[0]} or ${Q[1]}`;break;default:{const Y=Q.pop();m+=`one of type ${Q.join(", ")}, or ${Y}`}}(V.length>0||se.length>0)&&(m+=" or ")}if(V.length>0){switch(V.length){case 1:m+=`an instance of ${V[0]}`;break;case 2:m+=`an instance of ${V[0]} or ${V[1]}`;break;default:{const Y=V.pop();m+=`an instance of ${V.join(", ")}, or ${Y}`}}se.length>0&&(m+=" or ")}switch(se.length){case 0:break;case 1:se[0].toLowerCase()!==se[0]&&(m+="an "),m+=`${se[0]}`;break;case 2:m+=`one of ${se[0]} or ${se[1]}`;break;default:{const Y=se.pop();m+=`one of ${se.join(", ")}, or ${Y}`}}if(E==null)m+=`. Received ${E}`;else if(typeof E=="function"&&E.name)m+=`. Received function ${E.name}`;else if(typeof E=="object"){var ae;if((ae=E.constructor)!==null&&ae!==void 0&&ae.name)m+=`. Received an instance of ${E.constructor.name}`;else{const Y=t(E,{depth:-1});m+=`. Received ${Y}`}}else{let Y=t(E,{colors:!1});Y.length>25&&(Y=`${Y.slice(0,25)}...`),m+=`. Received type ${typeof E} (${Y})`}return m},TypeError),S("ERR_INVALID_ARG_VALUE",(w,P,E="is invalid")=>{let m=t(P);return m.length>128&&(m=m.slice(0,128)+"..."),`The ${w.includes(".")?"property":"argument"} '${w}' ${E}. Received ${m}`},TypeError),S("ERR_INVALID_RETURN_VALUE",(w,P,E)=>{var m;const Q=E!=null&&(m=E.constructor)!==null&&m!==void 0&&m.name?`instance of ${E.constructor.name}`:`type ${typeof E}`;return`Expected ${w} to be returned from the "${P}" function but got ${Q}.`},TypeError),S("ERR_MISSING_ARGS",(...w)=>{c(w.length>0,"At least one arg needs to be specified");let P;const E=w.length;switch(w=(Array.isArray(w)?w:[w]).map(m=>`"${m}"`).join(" or "),E){case 1:P+=`The ${w[0]} argument`;break;case 2:P+=`The ${w[0]} and ${w[1]} arguments`;break;default:{const m=w.pop();P+=`The ${w.join(", ")}, and ${m} arguments`}break}return`${P} must be specified`},TypeError),S("ERR_OUT_OF_RANGE",(w,P,E)=>{c(P,'Missing "range" argument');let m;if(Number.isInteger(E)&&Math.abs(E)>2**32)m=p(String(E));else if(typeof E=="bigint"){m=String(E);const Q=BigInt(2)**BigInt(32);(E>Q||E<-Q)&&(m=p(m)),m+="n"}else m=t(E);return`The value of "${w}" is out of range. It must be ${P}. Received ${m}`},RangeError),S("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),S("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),S("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),S("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),S("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),S("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),S("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),S("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),S("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),S("ERR_STREAM_WRITE_AFTER_END","write after end",Error),S("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),no={AbortError:v,aggregateTwoErrors:O(x),hideStackFrames:O,codes:l},no}var du;function rt(){return du||(du=1,(function(e){const t=at(),{format:r,inspect:n}=Uf(),{codes:{ERR_INVALID_ARG_TYPE:i}}=Ze(),{kResistStopPropagation:o,AggregateError:a,SymbolDispose:s}=De(),l=globalThis.AbortSignal||Et().AbortSignal,c=globalThis.AbortController||Et().AbortController,p=Object.getPrototypeOf(async function(){}).constructor,g=globalThis.Blob||t.Blob,S=typeof g<"u"?function(w){return w instanceof g}:function(w){return!1},O=(v,w)=>{if(v!==void 0&&(v===null||typeof v!="object"||!("aborted"in v)))throw new i(w,"AbortSignal",v)},x=(v,w)=>{if(typeof v!="function")throw new i(w,"Function",v)};e.exports={AggregateError:a,kEmptyObject:Object.freeze({}),once(v){let w=!1;return function(...P){w||(w=!0,v.apply(this,P))}},createDeferredPromise:function(){let v,w;return{promise:new Promise((E,m)=>{v=E,w=m}),resolve:v,reject:w}},promisify(v){return new Promise((w,P)=>{v((E,...m)=>E?P(E):w(...m))})},debuglog(){return function(){}},format:r,inspect:n,types:{isAsyncFunction(v){return v instanceof p},isArrayBufferView(v){return ArrayBuffer.isView(v)}},isBlob:S,deprecate(v,w){return v},addAbortListener:Pt().addAbortListener||function(w,P){if(w===void 0)throw new i("signal","AbortSignal",w);O(w,"signal"),x(P,"listener");let E;return w.aborted?queueMicrotask(()=>P()):(w.addEventListener("abort",P,{__proto__:null,once:!0,[o]:!0}),E=()=>{w.removeEventListener("abort",P)}),{__proto__:null,[s](){var m;(m=E)===null||m===void 0||m()}}},AbortSignalAny:l.any||function(w){if(w.length===1)return w[0];const P=new c,E=()=>P.abort();return w.forEach(m=>{O(m,"signals"),m.addEventListener("abort",E,{once:!0})}),P.signal.addEventListener("abort",()=>{w.forEach(m=>m.removeEventListener("abort",E))},{once:!0}),P.signal}},e.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(to)),to.exports}var ei={},io,hu;function jn(){if(hu)return io;hu=1;const{ArrayIsArray:e,ArrayPrototypeIncludes:t,ArrayPrototypeJoin:r,ArrayPrototypeMap:n,NumberIsInteger:i,NumberIsNaN:o,NumberMAX_SAFE_INTEGER:a,NumberMIN_SAFE_INTEGER:s,NumberParseInt:l,ObjectPrototypeHasOwnProperty:c,RegExpPrototypeExec:p,String:g,StringPrototypeToUpperCase:S,StringPrototypeTrim:O}=De(),{hideStackFrames:x,codes:{ERR_SOCKET_BAD_PORT:v,ERR_INVALID_ARG_TYPE:w,ERR_INVALID_ARG_VALUE:P,ERR_OUT_OF_RANGE:E,ERR_UNKNOWN_SIGNAL:m}}=Ze(),{normalizeEncoding:Q}=rt(),{isAsyncFunction:V,isArrayBufferView:se}=rt().types,ae={};function Y(y){return y===(y|0)}function ce(y){return y===y>>>0}const L=/^[0-7]+$/,R="must be a 32-bit unsigned integer or an octal string";function F(y,M,W){if(typeof y>"u"&&(y=W),typeof y=="string"){if(p(L,y)===null)throw new P(M,y,R);y=l(y,8)}return J(y,M),y}const A=x((y,M,W=s,k=a)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);if(y<W||y>k)throw new E(M,`>= ${W} && <= ${k}`,y)}),K=x((y,M,W=-2147483648,k=2147483647)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);if(y<W||y>k)throw new E(M,`>= ${W} && <= ${k}`,y)}),J=x((y,M,W=!1)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);const k=W?1:0,de=4294967295;if(y<k||y>de)throw new E(M,`>= ${k} && <= ${de}`,y)});function ee(y,M){if(typeof y!="string")throw new w(M,"string",y)}function ue(y,M,W=void 0,k){if(typeof y!="number")throw new w(M,"number",y);if(W!=null&&y<W||k!=null&&y>k||(W!=null||k!=null)&&o(y))throw new E(M,`${W!=null?`>= ${W}`:""}${W!=null&&k!=null?" && ":""}${k!=null?`<= ${k}`:""}`,y)}const D=x((y,M,W)=>{if(!t(W,y)){const de="must be one of: "+r(n(W,me=>typeof me=="string"?`'${me}'`:g(me)),", ");throw new P(M,y,de)}});function Z(y,M){if(typeof y!="boolean")throw new w(M,"boolean",y)}function _(y,M,W){return y==null||!c(y,M)?W:y[M]}const $=x((y,M,W=null)=>{const k=_(W,"allowArray",!1),de=_(W,"allowFunction",!1);if(!_(W,"nullable",!1)&&y===null||!k&&e(y)||typeof y!="object"&&(!de||typeof y!="function"))throw new w(M,"Object",y)}),H=x((y,M)=>{if(y!=null&&typeof y!="object"&&typeof y!="function")throw new w(M,"a dictionary",y)}),C=x((y,M,W=0)=>{if(!e(y))throw new w(M,"Array",y);if(y.length<W){const k=`must be longer than ${W}`;throw new P(M,y,k)}});function X(y,M){C(y,M);for(let W=0;W<y.length;W++)ee(y[W],`${M}[${W}]`)}function re(y,M){C(y,M);for(let W=0;W<y.length;W++)Z(y[W],`${M}[${W}]`)}function oe(y,M){C(y,M);for(let W=0;W<y.length;W++){const k=y[W],de=`${M}[${W}]`;if(k==null)throw new w(de,"AbortSignal",k);ne(k,de)}}function ie(y,M="signal"){if(ee(y,M),ae[y]===void 0)throw ae[S(y)]!==void 0?new m(y+" (signals must use all capital letters)"):new m(y)}const I=x((y,M="buffer")=>{if(!se(y))throw new w(M,["Buffer","TypedArray","DataView"],y)});function N(y,M){const W=Q(M),k=y.length;if(W==="hex"&&k%2!==0)throw new P("encoding",M,`is invalid for data of length ${k}`)}function G(y,M="Port",W=!0){if(typeof y!="number"&&typeof y!="string"||typeof y=="string"&&O(y).length===0||+y!==+y>>>0||y>65535||y===0&&!W)throw new v(M,y,W);return y|0}const ne=x((y,M)=>{if(y!==void 0&&(y===null||typeof y!="object"||!("aborted"in y)))throw new w(M,"AbortSignal",y)}),j=x((y,M)=>{if(typeof y!="function")throw new w(M,"Function",y)}),u=x((y,M)=>{if(typeof y!="function"||V(y))throw new w(M,"Function",y)}),d=x((y,M)=>{if(y!==void 0)throw new w(M,"undefined",y)});function b(y,M,W){if(!t(W,y))throw new w(M,`('${r(W,"|")}')`,y)}const T=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function q(y,M){if(typeof y>"u"||!p(T,y))throw new P(M,y,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function U(y){if(typeof y=="string")return q(y,"hints"),y;if(e(y)){const M=y.length;let W="";if(M===0)return W;for(let k=0;k<M;k++){const de=y[k];q(de,"hints"),W+=de,k!==M-1&&(W+=", ")}return W}throw new P("hints",y,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}return io={isInt32:Y,isUint32:ce,parseFileMode:F,validateArray:C,validateStringArray:X,validateBooleanArray:re,validateAbortSignalArray:oe,validateBoolean:Z,validateBuffer:I,validateDictionary:H,validateEncoding:N,validateFunction:j,validateInt32:K,validateInteger:A,validateNumber:ue,validateObject:$,validateOneOf:D,validatePlainFunction:u,validatePort:G,validateSignalName:ie,validateString:ee,validateUint32:J,validateUndefined:d,validateUnion:b,validateAbortSignal:ne,validateLinkHeaderValue:U},io}var ti={exports:{}},oo,pu;function Ct(){if(pu)return oo;pu=1;const{SymbolAsyncIterator:e,SymbolIterator:t,SymbolFor:r}=De(),n=r("nodejs.stream.destroyed"),i=r("nodejs.stream.errored"),o=r("nodejs.stream.readable"),a=r("nodejs.stream.writable"),s=r("nodejs.stream.disturbed"),l=r("nodejs.webstream.isClosedPromise"),c=r("nodejs.webstream.controllerErrorFunction");function p(_,$=!1){var H;return!!(_&&typeof _.pipe=="function"&&typeof _.on=="function"&&(!$||typeof _.pause=="function"&&typeof _.resume=="function")&&(!_._writableState||((H=_._readableState)===null||H===void 0?void 0:H.readable)!==!1)&&(!_._writableState||_._readableState))}function g(_){var $;return!!(_&&typeof _.write=="function"&&typeof _.on=="function"&&(!_._readableState||(($=_._writableState)===null||$===void 0?void 0:$.writable)!==!1))}function S(_){return!!(_&&typeof _.pipe=="function"&&_._readableState&&typeof _.on=="function"&&typeof _.write=="function")}function O(_){return _&&(_._readableState||_._writableState||typeof _.write=="function"&&typeof _.on=="function"||typeof _.pipe=="function"&&typeof _.on=="function")}function x(_){return!!(_&&!O(_)&&typeof _.pipeThrough=="function"&&typeof _.getReader=="function"&&typeof _.cancel=="function")}function v(_){return!!(_&&!O(_)&&typeof _.getWriter=="function"&&typeof _.abort=="function")}function w(_){return!!(_&&!O(_)&&typeof _.readable=="object"&&typeof _.writable=="object")}function P(_){return x(_)||v(_)||w(_)}function E(_,$){return _==null?!1:$===!0?typeof _[e]=="function":$===!1?typeof _[t]=="function":typeof _[e]=="function"||typeof _[t]=="function"}function m(_){if(!O(_))return null;const $=_._writableState,H=_._readableState,C=$||H;return!!(_.destroyed||_[n]||C!=null&&C.destroyed)}function Q(_){if(!g(_))return null;if(_.writableEnded===!0)return!0;const $=_._writableState;return $!=null&&$.errored?!1:typeof $?.ended!="boolean"?null:$.ended}function V(_,$){if(!g(_))return null;if(_.writableFinished===!0)return!0;const H=_._writableState;return H!=null&&H.errored?!1:typeof H?.finished!="boolean"?null:!!(H.finished||$===!1&&H.ended===!0&&H.length===0)}function se(_){if(!p(_))return null;if(_.readableEnded===!0)return!0;const $=_._readableState;return!$||$.errored?!1:typeof $?.ended!="boolean"?null:$.ended}function ae(_,$){if(!p(_))return null;const H=_._readableState;return H!=null&&H.errored?!1:typeof H?.endEmitted!="boolean"?null:!!(H.endEmitted||$===!1&&H.ended===!0&&H.length===0)}function Y(_){return _&&_[o]!=null?_[o]:typeof _?.readable!="boolean"?null:m(_)?!1:p(_)&&_.readable&&!ae(_)}function ce(_){return _&&_[a]!=null?_[a]:typeof _?.writable!="boolean"?null:m(_)?!1:g(_)&&_.writable&&!Q(_)}function L(_,$){return O(_)?m(_)?!0:!($?.readable!==!1&&Y(_)||$?.writable!==!1&&ce(_)):null}function R(_){var $,H;return O(_)?_.writableErrored?_.writableErrored:($=(H=_._writableState)===null||H===void 0?void 0:H.errored)!==null&&$!==void 0?$:null:null}function F(_){var $,H;return O(_)?_.readableErrored?_.readableErrored:($=(H=_._readableState)===null||H===void 0?void 0:H.errored)!==null&&$!==void 0?$:null:null}function A(_){if(!O(_))return null;if(typeof _.closed=="boolean")return _.closed;const $=_._writableState,H=_._readableState;return typeof $?.closed=="boolean"||typeof H?.closed=="boolean"?$?.closed||H?.closed:typeof _._closed=="boolean"&&K(_)?_._closed:null}function K(_){return typeof _._closed=="boolean"&&typeof _._defaultKeepAlive=="boolean"&&typeof _._removedConnection=="boolean"&&typeof _._removedContLen=="boolean"}function J(_){return typeof _._sent100=="boolean"&&K(_)}function ee(_){var $;return typeof _._consuming=="boolean"&&typeof _._dumped=="boolean"&&(($=_.req)===null||$===void 0?void 0:$.upgradeOrConnect)===void 0}function ue(_){if(!O(_))return null;const $=_._writableState,H=_._readableState,C=$||H;return!C&&J(_)||!!(C&&C.autoDestroy&&C.emitClose&&C.closed===!1)}function D(_){var $;return!!(_&&(($=_[s])!==null&&$!==void 0?$:_.readableDidRead||_.readableAborted))}function Z(_){var $,H,C,X,re,oe,ie,I,N,G;return!!(_&&(($=(H=(C=(X=(re=(oe=_[i])!==null&&oe!==void 0?oe:_.readableErrored)!==null&&re!==void 0?re:_.writableErrored)!==null&&X!==void 0?X:(ie=_._readableState)===null||ie===void 0?void 0:ie.errorEmitted)!==null&&C!==void 0?C:(I=_._writableState)===null||I===void 0?void 0:I.errorEmitted)!==null&&H!==void 0?H:(N=_._readableState)===null||N===void 0?void 0:N.errored)!==null&&$!==void 0?$:!((G=_._writableState)===null||G===void 0)&&G.errored))}return oo={isDestroyed:m,kIsDestroyed:n,isDisturbed:D,kIsDisturbed:s,isErrored:Z,kIsErrored:i,isReadable:Y,kIsReadable:o,kIsClosedPromise:l,kControllerErrorFunction:c,kIsWritable:a,isClosed:A,isDuplexNodeStream:S,isFinished:L,isIterable:E,isReadableNodeStream:p,isReadableStream:x,isReadableEnded:se,isReadableFinished:ae,isReadableErrored:F,isNodeStream:O,isWebStream:P,isWritable:ce,isWritableNodeStream:g,isWritableStream:v,isWritableEnded:Q,isWritableFinished:V,isWritableErrored:R,isServerRequest:ee,isServerResponse:J,willEmitClose:ue,isTransformStream:w},oo}var _u;function Bt(){if(_u)return ti.exports;_u=1;const e=st(),{AbortError:t,codes:r}=Ze(),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_PREMATURE_CLOSE:i}=r,{kEmptyObject:o,once:a}=rt(),{validateAbortSignal:s,validateFunction:l,validateObject:c,validateBoolean:p}=jn(),{Promise:g,PromisePrototypeThen:S,SymbolDispose:O}=De(),{isClosed:x,isReadable:v,isReadableNodeStream:w,isReadableStream:P,isReadableFinished:E,isReadableErrored:m,isWritable:Q,isWritableNodeStream:V,isWritableStream:se,isWritableFinished:ae,isWritableErrored:Y,isNodeStream:ce,willEmitClose:L,kIsClosedPromise:R}=Ct();let F;function A(D){return D.setHeader&&typeof D.abort=="function"}const K=()=>{};function J(D,Z,_){var $,H;if(arguments.length===2?(_=Z,Z=o):Z==null?Z=o:c(Z,"options"),l(_,"callback"),s(Z.signal,"options.signal"),_=a(_),P(D)||se(D))return ee(D,Z,_);if(!ce(D))throw new n("stream",["ReadableStream","WritableStream","Stream"],D);const C=($=Z.readable)!==null&&$!==void 0?$:w(D),X=(H=Z.writable)!==null&&H!==void 0?H:V(D),re=D._writableState,oe=D._readableState,ie=()=>{D.writable||G()};let I=L(D)&&w(D)===C&&V(D)===X,N=ae(D,!1);const G=()=>{N=!0,D.destroyed&&(I=!1),!(I&&(!D.readable||C))&&(!C||ne)&&_.call(D)};let ne=E(D,!1);const j=()=>{ne=!0,D.destroyed&&(I=!1),!(I&&(!D.writable||X))&&(!X||N)&&_.call(D)},u=y=>{_.call(D,y)};let d=x(D);const b=()=>{d=!0;const y=Y(D)||m(D);if(y&&typeof y!="boolean")return _.call(D,y);if(C&&!ne&&w(D,!0)&&!E(D,!1))return _.call(D,new i);if(X&&!N&&!ae(D,!1))return _.call(D,new i);_.call(D)},T=()=>{d=!0;const y=Y(D)||m(D);if(y&&typeof y!="boolean")return _.call(D,y);_.call(D)},q=()=>{D.req.on("finish",G)};A(D)?(D.on("complete",G),I||D.on("abort",b),D.req?q():D.on("request",q)):X&&!re&&(D.on("end",ie),D.on("close",ie)),!I&&typeof D.aborted=="boolean"&&D.on("aborted",b),D.on("end",j),D.on("finish",G),Z.error!==!1&&D.on("error",u),D.on("close",b),d?e.nextTick(b):re!=null&&re.errorEmitted||oe!=null&&oe.errorEmitted?I||e.nextTick(T):(!C&&(!I||v(D))&&(N||Q(D)===!1)||!X&&(!I||Q(D))&&(ne||v(D)===!1)||oe&&D.req&&D.aborted)&&e.nextTick(T);const U=()=>{_=K,D.removeListener("aborted",b),D.removeListener("complete",G),D.removeListener("abort",b),D.removeListener("request",q),D.req&&D.req.removeListener("finish",G),D.removeListener("end",ie),D.removeListener("close",ie),D.removeListener("finish",G),D.removeListener("end",j),D.removeListener("error",u),D.removeListener("close",b)};if(Z.signal&&!d){const y=()=>{const M=_;U(),M.call(D,new t(void 0,{cause:Z.signal.reason}))};if(Z.signal.aborted)e.nextTick(y);else{F=F||rt().addAbortListener;const M=F(Z.signal,y),W=_;_=a((...k)=>{M[O](),W.apply(D,k)})}}return U}function ee(D,Z,_){let $=!1,H=K;if(Z.signal)if(H=()=>{$=!0,_.call(D,new t(void 0,{cause:Z.signal.reason}))},Z.signal.aborted)e.nextTick(H);else{F=F||rt().addAbortListener;const X=F(Z.signal,H),re=_;_=a((...oe)=>{X[O](),re.apply(D,oe)})}const C=(...X)=>{$||e.nextTick(()=>_.apply(D,X))};return S(D[R].promise,C,C),K}function ue(D,Z){var _;let $=!1;return Z===null&&(Z=o),(_=Z)!==null&&_!==void 0&&_.cleanup&&(p(Z.cleanup,"cleanup"),$=Z.cleanup),new g((H,C)=>{const X=J(D,Z,re=>{$&&X(),re?C(re):H()})})}return ti.exports=J,ti.exports.finished=ue,ti.exports}var ao,yu;function kr(){if(yu)return ao;yu=1;const e=st(),{aggregateTwoErrors:t,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:n}=Ze(),{Symbol:i}=De(),{kIsDestroyed:o,isDestroyed:a,isFinished:s,isServerRequest:l}=Ct(),c=i("kDestroy"),p=i("kConstruct");function g(L,R,F){L&&(L.stack,R&&!R.errored&&(R.errored=L),F&&!F.errored&&(F.errored=L))}function S(L,R){const F=this._readableState,A=this._writableState,K=A||F;return A!=null&&A.destroyed||F!=null&&F.destroyed?(typeof R=="function"&&R(),this):(g(L,A,F),A&&(A.destroyed=!0),F&&(F.destroyed=!0),K.constructed?O(this,L,R):this.once(c,function(J){O(this,t(J,L),R)}),this)}function O(L,R,F){let A=!1;function K(J){if(A)return;A=!0;const ee=L._readableState,ue=L._writableState;g(J,ue,ee),ue&&(ue.closed=!0),ee&&(ee.closed=!0),typeof F=="function"&&F(J),J?e.nextTick(x,L,J):e.nextTick(v,L)}try{L._destroy(R||null,K)}catch(J){K(J)}}function x(L,R){w(L,R),v(L)}function v(L){const R=L._readableState,F=L._writableState;F&&(F.closeEmitted=!0),R&&(R.closeEmitted=!0),(F!=null&&F.emitClose||R!=null&&R.emitClose)&&L.emit("close")}function w(L,R){const F=L._readableState,A=L._writableState;A!=null&&A.errorEmitted||F!=null&&F.errorEmitted||(A&&(A.errorEmitted=!0),F&&(F.errorEmitted=!0),L.emit("error",R))}function P(){const L=this._readableState,R=this._writableState;L&&(L.constructed=!0,L.closed=!1,L.closeEmitted=!1,L.destroyed=!1,L.errored=null,L.errorEmitted=!1,L.reading=!1,L.ended=L.readable===!1,L.endEmitted=L.readable===!1),R&&(R.constructed=!0,R.destroyed=!1,R.closed=!1,R.closeEmitted=!1,R.errored=null,R.errorEmitted=!1,R.finalCalled=!1,R.prefinished=!1,R.ended=R.writable===!1,R.ending=R.writable===!1,R.finished=R.writable===!1)}function E(L,R,F){const A=L._readableState,K=L._writableState;if(K!=null&&K.destroyed||A!=null&&A.destroyed)return this;A!=null&&A.autoDestroy||K!=null&&K.autoDestroy?L.destroy(R):R&&(R.stack,K&&!K.errored&&(K.errored=R),A&&!A.errored&&(A.errored=R),F?e.nextTick(w,L,R):w(L,R))}function m(L,R){if(typeof L._construct!="function")return;const F=L._readableState,A=L._writableState;F&&(F.constructed=!1),A&&(A.constructed=!1),L.once(p,R),!(L.listenerCount(p)>1)&&e.nextTick(Q,L)}function Q(L){let R=!1;function F(A){if(R){E(L,A??new r);return}R=!0;const K=L._readableState,J=L._writableState,ee=J||K;K&&(K.constructed=!0),J&&(J.constructed=!0),ee.destroyed?L.emit(c,A):A?E(L,A,!0):e.nextTick(V,L)}try{L._construct(A=>{e.nextTick(F,A)})}catch(A){e.nextTick(F,A)}}function V(L){L.emit(p)}function se(L){return L?.setHeader&&typeof L.abort=="function"}function ae(L){L.emit("close")}function Y(L,R){L.emit("error",R),e.nextTick(ae,L)}function ce(L,R){!L||a(L)||(!R&&!s(L)&&(R=new n),l(L)?(L.socket=null,L.destroy(R)):se(L)?L.abort():se(L.req)?L.req.abort():typeof L.destroy=="function"?L.destroy(R):typeof L.close=="function"?L.close():R?e.nextTick(Y,L,R):e.nextTick(ae,L),L.destroyed||(L[o]=!0))}return ao={construct:m,destroyer:ce,destroy:S,undestroy:P,errorOrDestroy:E},ao}var so,bu;function Ja(){if(bu)return so;bu=1;const{ArrayIsArray:e,ObjectSetPrototypeOf:t}=De(),{EventEmitter:r}=Pt();function n(o){r.call(this,o)}t(n.prototype,r.prototype),t(n,r),n.prototype.pipe=function(o,a){const s=this;function l(v){o.writable&&o.write(v)===!1&&s.pause&&s.pause()}s.on("data",l);function c(){s.readable&&s.resume&&s.resume()}o.on("drain",c),!o._isStdio&&(!a||a.end!==!1)&&(s.on("end",g),s.on("close",S));let p=!1;function g(){p||(p=!0,o.end())}function S(){p||(p=!0,typeof o.destroy=="function"&&o.destroy())}function O(v){x(),r.listenerCount(this,"error")===0&&this.emit("error",v)}i(s,"error",O),i(o,"error",O);function x(){s.removeListener("data",l),o.removeListener("drain",c),s.removeListener("end",g),s.removeListener("close",S),s.removeListener("error",O),o.removeListener("error",O),s.removeListener("end",x),s.removeListener("close",x),o.removeListener("close",x)}return s.on("end",x),s.on("close",x),o.on("close",x),o.emit("pipe",s),o};function i(o,a,s){if(typeof o.prependListener=="function")return o.prependListener(a,s);!o._events||!o._events[a]?o.on(a,s):e(o._events[a])?o._events[a].unshift(s):o._events[a]=[s,o._events[a]]}return so={Stream:n,prependListener:i},so}var uo={exports:{}},gu;function vi(){return gu||(gu=1,(function(e){const{SymbolDispose:t}=De(),{AbortError:r,codes:n}=Ze(),{isNodeStream:i,isWebStream:o,kControllerErrorFunction:a}=Ct(),s=Bt(),{ERR_INVALID_ARG_TYPE:l}=n;let c;const p=(g,S)=>{if(typeof g!="object"||!("aborted"in g))throw new l(S,"AbortSignal",g)};e.exports.addAbortSignal=function(S,O){if(p(S,"signal"),!i(O)&&!o(O))throw new l("stream",["ReadableStream","WritableStream","Stream"],O);return e.exports.addAbortSignalNoValidate(S,O)},e.exports.addAbortSignalNoValidate=function(g,S){if(typeof g!="object"||!("aborted"in g))return S;const O=i(S)?()=>{S.destroy(new r(void 0,{cause:g.reason}))}:()=>{S[a](new r(void 0,{cause:g.reason}))};if(g.aborted)O();else{c=c||rt().addAbortListener;const x=c(g,O);s(S,x[t])}return S}})(uo)),uo.exports}var lo,wu;function Hh(){if(wu)return lo;wu=1;const{StringPrototypeSlice:e,SymbolIterator:t,TypedArrayPrototypeSet:r,Uint8Array:n}=De(),{Buffer:i}=at(),{inspect:o}=rt();return lo=class{constructor(){this.head=null,this.tail=null,this.length=0}push(s){const l={data:s,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length}unshift(s){const l={data:s,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length}shift(){if(this.length===0)return;const s=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,s}clear(){this.head=this.tail=null,this.length=0}join(s){if(this.length===0)return"";let l=this.head,c=""+l.data;for(;(l=l.next)!==null;)c+=s+l.data;return c}concat(s){if(this.length===0)return i.alloc(0);const l=i.allocUnsafe(s>>>0);let c=this.head,p=0;for(;c;)r(l,c.data,p),p+=c.data.length,c=c.next;return l}consume(s,l){const c=this.head.data;if(s<c.length){const p=c.slice(0,s);return this.head.data=c.slice(s),p}return s===c.length?this.shift():l?this._getString(s):this._getBuffer(s)}first(){return this.head.data}*[t](){for(let s=this.head;s;s=s.next)yield s.data}_getString(s){let l="",c=this.head,p=0;do{const g=c.data;if(s>g.length)l+=g,s-=g.length;else{s===g.length?(l+=g,++p,c.next?this.head=c.next:this.head=this.tail=null):(l+=e(g,0,s),this.head=c,c.data=e(g,s));break}++p}while((c=c.next)!==null);return this.length-=p,l}_getBuffer(s){const l=i.allocUnsafe(s),c=s;let p=this.head,g=0;do{const S=p.data;if(s>S.length)r(l,S,c-s),s-=S.length;else{s===S.length?(r(l,S,c-s),++g,p.next?this.head=p.next:this.head=this.tail=null):(r(l,new n(S.buffer,S.byteOffset,s),c-s),this.head=p,p.data=S.slice(s));break}++g}while((p=p.next)!==null);return this.length-=g,l}[Symbol.for("nodejs.util.inspect.custom")](s,l){return o(this,{...l,depth:0,customInspect:!1})}},lo}var fo,mu;function Ri(){if(mu)return fo;mu=1;const{MathFloor:e,NumberIsInteger:t}=De(),{validateInteger:r}=jn(),{ERR_INVALID_ARG_VALUE:n}=Ze().codes;let i=16*1024,o=16;function a(p,g,S){return p.highWaterMark!=null?p.highWaterMark:g?p[S]:null}function s(p){return p?o:i}function l(p,g){r(g,"value",0),p?o=g:i=g}function c(p,g,S,O){const x=a(g,O,S);if(x!=null){if(!t(x)||x<0){const v=O?`options.${S}`:"options.highWaterMark";throw new n(v,x)}return e(x)}return s(p.objectMode)}return fo={getHighWaterMark:c,getDefaultHighWaterMark:s,setDefaultHighWaterMark:l},fo}var co,Su;function jf(){if(Su)return co;Su=1;const e=st(),{PromisePrototypeThen:t,SymbolAsyncIterator:r,SymbolIterator:n}=De(),{Buffer:i}=at(),{ERR_INVALID_ARG_TYPE:o,ERR_STREAM_NULL_VALUES:a}=Ze().codes;function s(l,c,p){let g;if(typeof c=="string"||c instanceof i)return new l({objectMode:!0,...p,read(){this.push(c),this.push(null)}});let S;if(c&&c[r])S=!0,g=c[r]();else if(c&&c[n])S=!1,g=c[n]();else throw new o("iterable",["Iterable"],c);const O=new l({objectMode:!0,highWaterMark:1,...p});let x=!1;O._read=function(){x||(x=!0,w())},O._destroy=function(P,E){t(v(P),()=>e.nextTick(E,P),m=>e.nextTick(E,m||P))};async function v(P){const E=P!=null,m=typeof g.throw=="function";if(E&&m){const{value:Q,done:V}=await g.throw(P);if(await Q,V)return}if(typeof g.return=="function"){const{value:Q}=await g.return();await Q}}async function w(){for(;;){try{const{value:P,done:E}=S?await g.next():g.next();if(E)O.push(null);else{const m=P&&typeof P.then=="function"?await P:P;if(m===null)throw x=!1,new a;if(O.push(m))continue;x=!1}}catch(P){O.destroy(P)}break}}return O}return co=s,co}var ho,Au;function Ii(){if(Au)return ho;Au=1;const e=st(),{ArrayPrototypeIndexOf:t,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:o,ObjectKeys:a,ObjectSetPrototypeOf:s,Promise:l,SafeSet:c,SymbolAsyncDispose:p,SymbolAsyncIterator:g,Symbol:S}=De();ho=k,k.ReadableState=W;const{EventEmitter:O}=Pt(),{Stream:x,prependListener:v}=Ja(),{Buffer:w}=at(),{addAbortSignal:P}=vi(),E=Bt();let m=rt().debuglog("stream",f=>{m=f});const Q=Hh(),V=kr(),{getHighWaterMark:se,getDefaultHighWaterMark:ae}=Ri(),{aggregateTwoErrors:Y,codes:{ERR_INVALID_ARG_TYPE:ce,ERR_METHOD_NOT_IMPLEMENTED:L,ERR_OUT_OF_RANGE:R,ERR_STREAM_PUSH_AFTER_EOF:F,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:A},AbortError:K}=Ze(),{validateObject:J}=jn(),ee=S("kPaused"),{StringDecoder:ue}=gl(),D=jf();s(k.prototype,x.prototype),s(k,x);const Z=()=>{},{errorOrDestroy:_}=V,$=1,H=2,C=4,X=8,re=16,oe=32,ie=64,I=128,N=256,G=512,ne=1024,j=2048,u=4096,d=8192,b=16384,T=32768,q=65536,U=1<<17,y=1<<18;function M(f){return{enumerable:!1,get(){return(this.state&f)!==0},set(h){h?this.state|=f:this.state&=~f}}}o(W.prototype,{objectMode:M($),ended:M(H),endEmitted:M(C),reading:M(X),constructed:M(re),sync:M(oe),needReadable:M(ie),emittedReadable:M(I),readableListening:M(N),resumeScheduled:M(G),errorEmitted:M(ne),emitClose:M(j),autoDestroy:M(u),destroyed:M(d),closed:M(b),closeEmitted:M(T),multiAwaitDrain:M(q),readingMore:M(U),dataEmitted:M(y)});function W(f,h,z){typeof z!="boolean"&&(z=h instanceof Ot()),this.state=j|u|re|oe,f&&f.objectMode&&(this.state|=$),z&&f&&f.readableObjectMode&&(this.state|=$),this.highWaterMark=f?se(this,f,"readableHighWaterMark",z):ae(!1),this.buffer=new Q,this.length=0,this.pipes=[],this.flowing=null,this[ee]=null,f&&f.emitClose===!1&&(this.state&=~j),f&&f.autoDestroy===!1&&(this.state&=~u),this.errored=null,this.defaultEncoding=f&&f.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,f&&f.encoding&&(this.decoder=new ue(f.encoding),this.encoding=f.encoding)}function k(f){if(!(this instanceof k))return new k(f);const h=this instanceof Ot();this._readableState=new W(f,this,h),f&&(typeof f.read=="function"&&(this._read=f.read),typeof f.destroy=="function"&&(this._destroy=f.destroy),typeof f.construct=="function"&&(this._construct=f.construct),f.signal&&!h&&P(f.signal,this)),x.call(this,f),V.construct(this,()=>{this._readableState.needReadable&&Ae(this,this._readableState)})}k.prototype.destroy=V.destroy,k.prototype._undestroy=V.undestroy,k.prototype._destroy=function(f,h){h(f)},k.prototype[O.captureRejectionSymbol]=function(f){this.destroy(f)},k.prototype[p]=function(){let f;return this.destroyed||(f=this.readableEnded?null:new K,this.destroy(f)),new l((h,z)=>E(this,B=>B&&B!==f?z(B):h(null)))},k.prototype.push=function(f,h){return de(this,f,h,!1)},k.prototype.unshift=function(f,h){return de(this,f,h,!0)};function de(f,h,z,B){m("readableAddChunk",h);const te=f._readableState;let ge;if((te.state&$)===0&&(typeof h=="string"?(z=z||te.defaultEncoding,te.encoding!==z&&(B&&te.encoding?h=w.from(h,z).toString(te.encoding):(h=w.from(h,z),z=""))):h instanceof w?z="":x._isUint8Array(h)?(h=x._uint8ArrayToBuffer(h),z=""):h!=null&&(ge=new ce("chunk",["string","Buffer","Uint8Array"],h))),ge)_(f,ge);else if(h===null)te.state&=~X,Le(f,te);else if((te.state&$)!==0||h&&h.length>0)if(B)if((te.state&C)!==0)_(f,new A);else{if(te.destroyed||te.errored)return!1;me(f,te,h,!0)}else if(te.ended)_(f,new F);else{if(te.destroyed||te.errored)return!1;te.state&=~X,te.decoder&&!z?(h=te.decoder.write(h),te.objectMode||h.length!==0?me(f,te,h,!1):Ae(f,te)):me(f,te,h,!1)}else B||(te.state&=~X,Ae(f,te));return!te.ended&&(te.length<te.highWaterMark||te.length===0)}function me(f,h,z,B){h.flowing&&h.length===0&&!h.sync&&f.listenerCount("data")>0?((h.state&q)!==0?h.awaitDrainWriters.clear():h.awaitDrainWriters=null,h.dataEmitted=!0,f.emit("data",z)):(h.length+=h.objectMode?1:z.length,B?h.buffer.unshift(z):h.buffer.push(z),(h.state&ie)!==0&&Fe(f)),Ae(f,h)}k.prototype.isPaused=function(){const f=this._readableState;return f[ee]===!0||f.flowing===!1},k.prototype.setEncoding=function(f){const h=new ue(f);this._readableState.decoder=h,this._readableState.encoding=this._readableState.decoder.encoding;const z=this._readableState.buffer;let B="";for(const te of z)B+=h.write(te);return z.clear(),B!==""&&z.push(B),this._readableState.length=B.length,this};const he=1073741824;function Se(f){if(f>he)throw new R("size","<= 1GiB",f);return f--,f|=f>>>1,f|=f>>>2,f|=f>>>4,f|=f>>>8,f|=f>>>16,f++,f}function be(f,h){return f<=0||h.length===0&&h.ended?0:(h.state&$)!==0?1:n(f)?h.flowing&&h.length?h.buffer.first().length:h.length:f<=h.length?f:h.ended?h.length:0}k.prototype.read=function(f){m("read",f),f===void 0?f=NaN:r(f)||(f=i(f,10));const h=this._readableState,z=f;if(f>h.highWaterMark&&(h.highWaterMark=Se(f)),f!==0&&(h.state&=~I),f===0&&h.needReadable&&((h.highWaterMark!==0?h.length>=h.highWaterMark:h.length>0)||h.ended))return m("read: emitReadable",h.length,h.ended),h.length===0&&h.ended?Ht(this):Fe(this),null;if(f=be(f,h),f===0&&h.ended)return h.length===0&&Ht(this),null;let B=(h.state&ie)!==0;if(m("need readable",B),(h.length===0||h.length-f<h.highWaterMark)&&(B=!0,m("length less than watermark",B)),h.ended||h.reading||h.destroyed||h.errored||!h.constructed)B=!1,m("reading, ended or constructing",B);else if(B){m("do read"),h.state|=X|oe,h.length===0&&(h.state|=ie);try{this._read(h.highWaterMark)}catch(ge){_(this,ge)}h.state&=~oe,h.reading||(f=be(z,h))}let te;return f>0?te=Ur(f,h):te=null,te===null?(h.needReadable=h.length<=h.highWaterMark,f=0):(h.length-=f,h.multiAwaitDrain?h.awaitDrainWriters.clear():h.awaitDrainWriters=null),h.length===0&&(h.ended||(h.needReadable=!0),z!==f&&h.ended&&Ht(this)),te!==null&&!h.errorEmitted&&!h.closeEmitted&&(h.dataEmitted=!0,this.emit("data",te)),te};function Le(f,h){if(m("onEofChunk"),!h.ended){if(h.decoder){const z=h.decoder.end();z&&z.length&&(h.buffer.push(z),h.length+=h.objectMode?1:z.length)}h.ended=!0,h.sync?Fe(f):(h.needReadable=!1,h.emittedReadable=!0,It(f))}}function Fe(f){const h=f._readableState;m("emitReadable",h.needReadable,h.emittedReadable),h.needReadable=!1,h.emittedReadable||(m("emitReadable",h.flowing),h.emittedReadable=!0,e.nextTick(It,f))}function It(f){const h=f._readableState;m("emitReadable_",h.destroyed,h.length,h.ended),!h.destroyed&&!h.errored&&(h.length||h.ended)&&(f.emit("readable"),h.emittedReadable=!1),h.needReadable=!h.flowing&&!h.ended&&h.length<=h.highWaterMark,$r(f)}function Ae(f,h){!h.readingMore&&h.constructed&&(h.readingMore=!0,e.nextTick(Pi,f,h))}function Pi(f,h){for(;!h.reading&&!h.ended&&(h.length<h.highWaterMark||h.flowing&&h.length===0);){const z=h.length;if(m("maybeReadMore read 0"),f.read(0),z===h.length)break}h.readingMore=!1}k.prototype._read=function(f){throw new L("_read()")},k.prototype.pipe=function(f,h){const z=this,B=this._readableState;B.pipes.length===1&&(B.multiAwaitDrain||(B.multiAwaitDrain=!0,B.awaitDrainWriters=new c(B.awaitDrainWriters?[B.awaitDrainWriters]:[]))),B.pipes.push(f),m("pipe count=%d opts=%j",B.pipes.length,h);const ge=(!h||h.end!==!1)&&f!==e.stdout&&f!==e.stderr?Fr:gt;B.endEmitted?e.nextTick(ge):z.once("end",ge),f.on("unpipe",Oe);function Oe(Ve,Ne){m("onunpipe"),Ve===z&&Ne&&Ne.hasUnpiped===!1&&(Ne.hasUnpiped=!0,qi())}function Fr(){m("onend"),f.end()}let Ge,Wr=!1;function qi(){m("cleanup"),f.removeListener("close",Yt),f.removeListener("finish",Jt),Ge&&f.removeListener("drain",Ge),f.removeListener("error",Vt),f.removeListener("unpipe",Oe),z.removeListener("end",Fr),z.removeListener("end",gt),z.removeListener("data",Br),Wr=!0,Ge&&B.awaitDrainWriters&&(!f._writableState||f._writableState.needDrain)&&Ge()}function zr(){Wr||(B.pipes.length===1&&B.pipes[0]===f?(m("false write response, pause",0),B.awaitDrainWriters=f,B.multiAwaitDrain=!1):B.pipes.length>1&&B.pipes.includes(f)&&(m("false write response, pause",B.awaitDrainWriters.size),B.awaitDrainWriters.add(f)),z.pause()),Ge||(Ge=Ci(z,f),f.on("drain",Ge))}z.on("data",Br);function Br(Ve){m("ondata");const Ne=f.write(Ve);m("dest.write",Ne),Ne===!1&&zr()}function Vt(Ve){if(m("onerror",Ve),gt(),f.removeListener("error",Vt),f.listenerCount("error")===0){const Ne=f._writableState||f._readableState;Ne&&!Ne.errorEmitted?_(f,Ve):f.emit("error",Ve)}}v(f,"error",Vt);function Yt(){f.removeListener("finish",Jt),gt()}f.once("close",Yt);function Jt(){m("onfinish"),f.removeListener("close",Yt),gt()}f.once("finish",Jt);function gt(){m("unpipe"),z.unpipe(f)}return f.emit("pipe",z),f.writableNeedDrain===!0?zr():B.flowing||(m("pipe resume"),z.resume()),f};function Ci(f,h){return function(){const B=f._readableState;B.awaitDrainWriters===h?(m("pipeOnDrain",1),B.awaitDrainWriters=null):B.multiAwaitDrain&&(m("pipeOnDrain",B.awaitDrainWriters.size),B.awaitDrainWriters.delete(h)),(!B.awaitDrainWriters||B.awaitDrainWriters.size===0)&&f.listenerCount("data")&&f.resume()}}k.prototype.unpipe=function(f){const h=this._readableState,z={hasUnpiped:!1};if(h.pipes.length===0)return this;if(!f){const te=h.pipes;h.pipes=[],this.pause();for(let ge=0;ge<te.length;ge++)te[ge].emit("unpipe",this,{hasUnpiped:!1});return this}const B=t(h.pipes,f);return B===-1?this:(h.pipes.splice(B,1),h.pipes.length===0&&this.pause(),f.emit("unpipe",this,z),this)},k.prototype.on=function(f,h){const z=x.prototype.on.call(this,f,h),B=this._readableState;return f==="data"?(B.readableListening=this.listenerCount("readable")>0,B.flowing!==!1&&this.resume()):f==="readable"&&!B.endEmitted&&!B.readableListening&&(B.readableListening=B.needReadable=!0,B.flowing=!1,B.emittedReadable=!1,m("on readable",B.length,B.reading),B.length?Fe(this):B.reading||e.nextTick(Li,this)),z},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(f,h){const z=x.prototype.removeListener.call(this,f,h);return f==="readable"&&e.nextTick(Nr,this),z},k.prototype.off=k.prototype.removeListener,k.prototype.removeAllListeners=function(f){const h=x.prototype.removeAllListeners.apply(this,arguments);return(f==="readable"||f===void 0)&&e.nextTick(Nr,this),h};function Nr(f){const h=f._readableState;h.readableListening=f.listenerCount("readable")>0,h.resumeScheduled&&h[ee]===!1?h.flowing=!0:f.listenerCount("data")>0?f.resume():h.readableListening||(h.flowing=null)}function Li(f){m("readable nexttick read 0"),f.read(0)}k.prototype.resume=function(){const f=this._readableState;return f.flowing||(m("resume"),f.flowing=!f.readableListening,Di(this,f)),f[ee]=!1,this};function Di(f,h){h.resumeScheduled||(h.resumeScheduled=!0,e.nextTick(ki,f,h))}function ki(f,h){m("resume",h.reading),h.reading||f.read(0),h.resumeScheduled=!1,f.emit("resume"),$r(f),h.flowing&&!h.reading&&f.read(0)}k.prototype.pause=function(){return m("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(m("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[ee]=!0,this};function $r(f){const h=f._readableState;for(m("flow",h.flowing);h.flowing&&f.read()!==null;);}k.prototype.wrap=function(f){let h=!1;f.on("data",B=>{!this.push(B)&&f.pause&&(h=!0,f.pause())}),f.on("end",()=>{this.push(null)}),f.on("error",B=>{_(this,B)}),f.on("close",()=>{this.destroy()}),f.on("destroy",()=>{this.destroy()}),this._read=()=>{h&&f.resume&&(h=!1,f.resume())};const z=a(f);for(let B=1;B<z.length;B++){const te=z[B];this[te]===void 0&&typeof f[te]=="function"&&(this[te]=f[te].bind(f))}return this},k.prototype[g]=function(){return qr(this)},k.prototype.iterator=function(f){return f!==void 0&&J(f,"options"),qr(this,f)};function qr(f,h){typeof f.read!="function"&&(f=k.wrap(f,{objectMode:!0}));const z=xi(f,h);return z.stream=f,z}async function*xi(f,h){let z=Z;function B(Oe){this===f?(z(),z=Z):z=Oe}f.on("readable",B);let te;const ge=E(f,{writable:!1},Oe=>{te=Oe?Y(te,Oe):null,z(),z=Z});try{for(;;){const Oe=f.destroyed?null:f.read();if(Oe!==null)yield Oe;else{if(te)throw te;if(te===null)return;await new l(B)}}}catch(Oe){throw te=Y(te,Oe),te}finally{(te||h?.destroyOnReturn!==!1)&&(te===void 0||f._readableState.autoDestroy)?V.destroyer(f,null):(f.off("readable",B),ge())}}o(k.prototype,{readable:{__proto__:null,get(){const f=this._readableState;return!!f&&f.readable!==!1&&!f.destroyed&&!f.errorEmitted&&!f.endEmitted},set(f){this._readableState&&(this._readableState.readable=!!f)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(f){this._readableState&&(this._readableState.flowing=f)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(f){this._readableState&&(this._readableState.destroyed=f)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),o(W.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[ee]!==!1},set(f){this[ee]=!!f}}}),k._fromList=Ur;function Ur(f,h){if(h.length===0)return null;let z;return h.objectMode?z=h.buffer.shift():!f||f>=h.length?(h.decoder?z=h.buffer.join(""):h.buffer.length===1?z=h.buffer.first():z=h.buffer.concat(h.length),h.buffer.clear()):z=h.buffer.consume(f,h.decoder),z}function Ht(f){const h=f._readableState;m("endReadable",h.endEmitted),h.endEmitted||(h.ended=!0,e.nextTick(Ni,h,f))}function Ni(f,h){if(m("endReadableNT",f.endEmitted,f.length),!f.errored&&!f.closeEmitted&&!f.endEmitted&&f.length===0){if(f.endEmitted=!0,h.emit("end"),h.writable&&h.allowHalfOpen===!1)e.nextTick($i,h);else if(f.autoDestroy){const z=h._writableState;(!z||z.autoDestroy&&(z.finished||z.writable===!1))&&h.destroy()}}}function $i(f){f.writable&&!f.writableEnded&&!f.destroyed&&f.end()}k.from=function(f,h){return D(k,f,h)};let Gt;function jr(){return Gt===void 0&&(Gt={}),Gt}return k.fromWeb=function(f,h){return jr().newStreamReadableFromReadableStream(f,h)},k.toWeb=function(f,h){return jr().newReadableStreamFromStreamReadable(f,h)},k.wrap=function(f,h){var z,B;return new k({objectMode:(z=(B=f.readableObjectMode)!==null&&B!==void 0?B:f.objectMode)!==null&&z!==void 0?z:!0,...h,destroy(te,ge){V.destroyer(f,te),ge(te)}}).wrap(f)},ho}var po,Eu;function Qa(){if(Eu)return po;Eu=1;const e=st(),{ArrayPrototypeSlice:t,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:o,ObjectSetPrototypeOf:a,StringPrototypeToLowerCase:s,Symbol:l,SymbolHasInstance:c}=De();po=J,J.WritableState=A;const{EventEmitter:p}=Pt(),g=Ja().Stream,{Buffer:S}=at(),O=kr(),{addAbortSignal:x}=vi(),{getHighWaterMark:v,getDefaultHighWaterMark:w}=Ri(),{ERR_INVALID_ARG_TYPE:P,ERR_METHOD_NOT_IMPLEMENTED:E,ERR_MULTIPLE_CALLBACK:m,ERR_STREAM_CANNOT_PIPE:Q,ERR_STREAM_DESTROYED:V,ERR_STREAM_ALREADY_FINISHED:se,ERR_STREAM_NULL_VALUES:ae,ERR_STREAM_WRITE_AFTER_END:Y,ERR_UNKNOWN_ENCODING:ce}=Ze().codes,{errorOrDestroy:L}=O;a(J.prototype,g.prototype),a(J,g);function R(){}const F=l("kOnFinished");function A(u,d,b){typeof b!="boolean"&&(b=d instanceof Ot()),this.objectMode=!!(u&&u.objectMode),b&&(this.objectMode=this.objectMode||!!(u&&u.writableObjectMode)),this.highWaterMark=u?v(this,u,"writableHighWaterMark",b):w(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const T=!!(u&&u.decodeStrings===!1);this.decodeStrings=!T,this.defaultEncoding=u&&u.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=_.bind(void 0,d),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,K(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!u||u.emitClose!==!1,this.autoDestroy=!u||u.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[F]=[]}function K(u){u.buffered=[],u.bufferedIndex=0,u.allBuffers=!0,u.allNoop=!0}A.prototype.getBuffer=function(){return t(this.buffered,this.bufferedIndex)},i(A.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function J(u){const d=this instanceof Ot();if(!d&&!n(J,this))return new J(u);this._writableState=new A(u,this,d),u&&(typeof u.write=="function"&&(this._write=u.write),typeof u.writev=="function"&&(this._writev=u.writev),typeof u.destroy=="function"&&(this._destroy=u.destroy),typeof u.final=="function"&&(this._final=u.final),typeof u.construct=="function"&&(this._construct=u.construct),u.signal&&x(u.signal,this)),g.call(this,u),O.construct(this,()=>{const b=this._writableState;b.writing||X(this,b),I(this,b)})}i(J,c,{__proto__:null,value:function(u){return n(this,u)?!0:this!==J?!1:u&&u._writableState instanceof A}}),J.prototype.pipe=function(){L(this,new Q)};function ee(u,d,b,T){const q=u._writableState;if(typeof b=="function")T=b,b=q.defaultEncoding;else{if(!b)b=q.defaultEncoding;else if(b!=="buffer"&&!S.isEncoding(b))throw new ce(b);typeof T!="function"&&(T=R)}if(d===null)throw new ae;if(!q.objectMode)if(typeof d=="string")q.decodeStrings!==!1&&(d=S.from(d,b),b="buffer");else if(d instanceof S)b="buffer";else if(g._isUint8Array(d))d=g._uint8ArrayToBuffer(d),b="buffer";else throw new P("chunk",["string","Buffer","Uint8Array"],d);let U;return q.ending?U=new Y:q.destroyed&&(U=new V("write")),U?(e.nextTick(T,U),L(u,U,!0),U):(q.pendingcb++,ue(u,q,d,b,T))}J.prototype.write=function(u,d,b){return ee(this,u,d,b)===!0},J.prototype.cork=function(){this._writableState.corked++},J.prototype.uncork=function(){const u=this._writableState;u.corked&&(u.corked--,u.writing||X(this,u))},J.prototype.setDefaultEncoding=function(d){if(typeof d=="string"&&(d=s(d)),!S.isEncoding(d))throw new ce(d);return this._writableState.defaultEncoding=d,this};function ue(u,d,b,T,q){const U=d.objectMode?1:b.length;d.length+=U;const y=d.length<d.highWaterMark;return y||(d.needDrain=!0),d.writing||d.corked||d.errored||!d.constructed?(d.buffered.push({chunk:b,encoding:T,callback:q}),d.allBuffers&&T!=="buffer"&&(d.allBuffers=!1),d.allNoop&&q!==R&&(d.allNoop=!1)):(d.writelen=U,d.writecb=q,d.writing=!0,d.sync=!0,u._write(b,T,d.onwrite),d.sync=!1),y&&!d.errored&&!d.destroyed}function D(u,d,b,T,q,U,y){d.writelen=T,d.writecb=y,d.writing=!0,d.sync=!0,d.destroyed?d.onwrite(new V("write")):b?u._writev(q,d.onwrite):u._write(q,U,d.onwrite),d.sync=!1}function Z(u,d,b,T){--d.pendingcb,T(b),C(d),L(u,b)}function _(u,d){const b=u._writableState,T=b.sync,q=b.writecb;if(typeof q!="function"){L(u,new m);return}b.writing=!1,b.writecb=null,b.length-=b.writelen,b.writelen=0,d?(d.stack,b.errored||(b.errored=d),u._readableState&&!u._readableState.errored&&(u._readableState.errored=d),T?e.nextTick(Z,u,b,d,q):Z(u,b,d,q)):(b.buffered.length>b.bufferedIndex&&X(u,b),T?b.afterWriteTickInfo!==null&&b.afterWriteTickInfo.cb===q?b.afterWriteTickInfo.count++:(b.afterWriteTickInfo={count:1,cb:q,stream:u,state:b},e.nextTick($,b.afterWriteTickInfo)):H(u,b,1,q))}function $({stream:u,state:d,count:b,cb:T}){return d.afterWriteTickInfo=null,H(u,d,b,T)}function H(u,d,b,T){for(!d.ending&&!u.destroyed&&d.length===0&&d.needDrain&&(d.needDrain=!1,u.emit("drain"));b-- >0;)d.pendingcb--,T();d.destroyed&&C(d),I(u,d)}function C(u){if(u.writing)return;for(let q=u.bufferedIndex;q<u.buffered.length;++q){var d;const{chunk:U,callback:y}=u.buffered[q],M=u.objectMode?1:U.length;u.length-=M,y((d=u.errored)!==null&&d!==void 0?d:new V("write"))}const b=u[F].splice(0);for(let q=0;q<b.length;q++){var T;b[q]((T=u.errored)!==null&&T!==void 0?T:new V("end"))}K(u)}function X(u,d){if(d.corked||d.bufferProcessing||d.destroyed||!d.constructed)return;const{buffered:b,bufferedIndex:T,objectMode:q}=d,U=b.length-T;if(!U)return;let y=T;if(d.bufferProcessing=!0,U>1&&u._writev){d.pendingcb-=U-1;const M=d.allNoop?R:k=>{for(let de=y;de<b.length;++de)b[de].callback(k)},W=d.allNoop&&y===0?b:t(b,y);W.allBuffers=d.allBuffers,D(u,d,!0,d.length,W,"",M),K(d)}else{do{const{chunk:M,encoding:W,callback:k}=b[y];b[y++]=null;const de=q?1:M.length;D(u,d,!1,de,M,W,k)}while(y<b.length&&!d.writing);y===b.length?K(d):y>256?(b.splice(0,y),d.bufferedIndex=0):d.bufferedIndex=y}d.bufferProcessing=!1}J.prototype._write=function(u,d,b){if(this._writev)this._writev([{chunk:u,encoding:d}],b);else throw new E("_write()")},J.prototype._writev=null,J.prototype.end=function(u,d,b){const T=this._writableState;typeof u=="function"?(b=u,u=null,d=null):typeof d=="function"&&(b=d,d=null);let q;if(u!=null){const U=ee(this,u,d);U instanceof r&&(q=U)}return T.corked&&(T.corked=1,this.uncork()),q||(!T.errored&&!T.ending?(T.ending=!0,I(this,T,!0),T.ended=!0):T.finished?q=new se("end"):T.destroyed&&(q=new V("end"))),typeof b=="function"&&(q||T.finished?e.nextTick(b,q):T[F].push(b)),this};function re(u){return u.ending&&!u.destroyed&&u.constructed&&u.length===0&&!u.errored&&u.buffered.length===0&&!u.finished&&!u.writing&&!u.errorEmitted&&!u.closeEmitted}function oe(u,d){let b=!1;function T(q){if(b){L(u,q??m());return}if(b=!0,d.pendingcb--,q){const U=d[F].splice(0);for(let y=0;y<U.length;y++)U[y](q);L(u,q,d.sync)}else re(d)&&(d.prefinished=!0,u.emit("prefinish"),d.pendingcb++,e.nextTick(N,u,d))}d.sync=!0,d.pendingcb++;try{u._final(T)}catch(q){T(q)}d.sync=!1}function ie(u,d){!d.prefinished&&!d.finalCalled&&(typeof u._final=="function"&&!d.destroyed?(d.finalCalled=!0,oe(u,d)):(d.prefinished=!0,u.emit("prefinish")))}function I(u,d,b){re(d)&&(ie(u,d),d.pendingcb===0&&(b?(d.pendingcb++,e.nextTick((T,q)=>{re(q)?N(T,q):q.pendingcb--},u,d)):re(d)&&(d.pendingcb++,N(u,d))))}function N(u,d){d.pendingcb--,d.finished=!0;const b=d[F].splice(0);for(let T=0;T<b.length;T++)b[T]();if(u.emit("finish"),d.autoDestroy){const T=u._readableState;(!T||T.autoDestroy&&(T.endEmitted||T.readable===!1))&&u.destroy()}}o(J.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(u){this._writableState&&(this._writableState.destroyed=u)}},writable:{__proto__:null,get(){const u=this._writableState;return!!u&&u.writable!==!1&&!u.destroyed&&!u.errored&&!u.ending&&!u.ended},set(u){this._writableState&&(this._writableState.writable=!!u)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){const u=this._writableState;return u?!u.destroyed&&!u.ending&&u.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});const G=O.destroy;J.prototype.destroy=function(u,d){const b=this._writableState;return!b.destroyed&&(b.bufferedIndex<b.buffered.length||b[F].length)&&e.nextTick(C,b),G.call(this,u,d),this},J.prototype._undestroy=O.undestroy,J.prototype._destroy=function(u,d){d(u)},J.prototype[p.captureRejectionSymbol]=function(u){this.destroy(u)};let ne;function j(){return ne===void 0&&(ne={}),ne}return J.fromWeb=function(u,d){return j().newStreamWritableFromWritableStream(u,d)},J.toWeb=function(u){return j().newWritableStreamFromStreamWritable(u)},po}var _o,vu;function Gh(){if(vu)return _o;vu=1;const e=st(),t=at(),{isReadable:r,isWritable:n,isIterable:i,isNodeStream:o,isReadableNodeStream:a,isWritableNodeStream:s,isDuplexNodeStream:l,isReadableStream:c,isWritableStream:p}=Ct(),g=Bt(),{AbortError:S,codes:{ERR_INVALID_ARG_TYPE:O,ERR_INVALID_RETURN_VALUE:x}}=Ze(),{destroyer:v}=kr(),w=Ot(),P=Ii(),E=Qa(),{createDeferredPromise:m}=rt(),Q=jf(),V=globalThis.Blob||t.Blob,se=typeof V<"u"?function(A){return A instanceof V}:function(A){return!1},ae=globalThis.AbortController||Et().AbortController,{FunctionPrototypeCall:Y}=De();class ce extends w{constructor(A){super(A),A?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),A?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}_o=function F(A,K){if(l(A))return A;if(a(A))return R({readable:A});if(s(A))return R({writable:A});if(o(A))return R({writable:!1,readable:!1});if(c(A))return R({readable:P.fromWeb(A)});if(p(A))return R({writable:E.fromWeb(A)});if(typeof A=="function"){const{value:ee,write:ue,final:D,destroy:Z}=L(A);if(i(ee))return Q(ce,ee,{objectMode:!0,write:ue,final:D,destroy:Z});const _=ee?.then;if(typeof _=="function"){let $;const H=Y(_,ee,C=>{if(C!=null)throw new x("nully","body",C)},C=>{v($,C)});return $=new ce({objectMode:!0,readable:!1,write:ue,final(C){D(async()=>{try{await H,e.nextTick(C,null)}catch(X){e.nextTick(C,X)}})},destroy:Z})}throw new x("Iterable, AsyncIterable or AsyncFunction",K,ee)}if(se(A))return F(A.arrayBuffer());if(i(A))return Q(ce,A,{objectMode:!0,writable:!1});if(c(A?.readable)&&p(A?.writable))return ce.fromWeb(A);if(typeof A?.writable=="object"||typeof A?.readable=="object"){const ee=A!=null&&A.readable?a(A?.readable)?A?.readable:F(A.readable):void 0,ue=A!=null&&A.writable?s(A?.writable)?A?.writable:F(A.writable):void 0;return R({readable:ee,writable:ue})}const J=A?.then;if(typeof J=="function"){let ee;return Y(J,A,ue=>{ue!=null&&ee.push(ue),ee.push(null)},ue=>{v(ee,ue)}),ee=new ce({objectMode:!0,writable:!1,read(){}})}throw new O(K,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],A)};function L(F){let{promise:A,resolve:K}=m();const J=new ae,ee=J.signal;return{value:F((async function*(){for(;;){const D=A;A=null;const{chunk:Z,done:_,cb:$}=await D;if(e.nextTick($),_)return;if(ee.aborted)throw new S(void 0,{cause:ee.reason});({promise:A,resolve:K}=m()),yield Z}})(),{signal:ee}),write(D,Z,_){const $=K;K=null,$({chunk:D,done:!1,cb:_})},final(D){const Z=K;K=null,Z({done:!0,cb:D})},destroy(D,Z){J.abort(),Z(D)}}}function R(F){const A=F.readable&&typeof F.readable.read!="function"?P.wrap(F.readable):F.readable,K=F.writable;let J=!!r(A),ee=!!n(K),ue,D,Z,_,$;function H(C){const X=_;_=null,X?X(C):C&&$.destroy(C)}return $=new ce({readableObjectMode:!!(A!=null&&A.readableObjectMode),writableObjectMode:!!(K!=null&&K.writableObjectMode),readable:J,writable:ee}),ee&&(g(K,C=>{ee=!1,C&&v(A,C),H(C)}),$._write=function(C,X,re){K.write(C,X)?re():ue=re},$._final=function(C){K.end(),D=C},K.on("drain",function(){if(ue){const C=ue;ue=null,C()}}),K.on("finish",function(){if(D){const C=D;D=null,C()}})),J&&(g(A,C=>{J=!1,C&&v(A,C),H(C)}),A.on("readable",function(){if(Z){const C=Z;Z=null,C()}}),A.on("end",function(){$.push(null)}),$._read=function(){for(;;){const C=A.read();if(C===null){Z=$._read;return}if(!$.push(C))return}}),$._destroy=function(C,X){!C&&_!==null&&(C=new S),Z=null,ue=null,D=null,_===null?X(C):(_=X,v(K,C),v(A,C))},$}return _o}var yo,Ru;function Ot(){if(Ru)return yo;Ru=1;const{ObjectDefineProperties:e,ObjectGetOwnPropertyDescriptor:t,ObjectKeys:r,ObjectSetPrototypeOf:n}=De();yo=a;const i=Ii(),o=Qa();n(a.prototype,i.prototype),n(a,i);{const p=r(o.prototype);for(let g=0;g<p.length;g++){const S=p[g];a.prototype[S]||(a.prototype[S]=o.prototype[S])}}function a(p){if(!(this instanceof a))return new a(p);i.call(this,p),o.call(this,p),p?(this.allowHalfOpen=p.allowHalfOpen!==!1,p.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),p.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}e(a.prototype,{writable:{__proto__:null,...t(o.prototype,"writable")},writableHighWaterMark:{__proto__:null,...t(o.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...t(o.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...t(o.prototype,"writableBuffer")},writableLength:{__proto__:null,...t(o.prototype,"writableLength")},writableFinished:{__proto__:null,...t(o.prototype,"writableFinished")},writableCorked:{__proto__:null,...t(o.prototype,"writableCorked")},writableEnded:{__proto__:null,...t(o.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...t(o.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(p){this._readableState&&this._writableState&&(this._readableState.destroyed=p,this._writableState.destroyed=p)}}});let s;function l(){return s===void 0&&(s={}),s}a.fromWeb=function(p,g){return l().newStreamDuplexFromReadableWritablePair(p,g)},a.toWeb=function(p){return l().newReadableWritablePairFromDuplex(p)};let c;return a.from=function(p){return c||(c=Gh()),c(p,"body")},yo}var bo,Iu;function Ff(){if(Iu)return bo;Iu=1;const{ObjectSetPrototypeOf:e,Symbol:t}=De();bo=a;const{ERR_METHOD_NOT_IMPLEMENTED:r}=Ze().codes,n=Ot(),{getHighWaterMark:i}=Ri();e(a.prototype,n.prototype),e(a,n);const o=t("kCallback");function a(c){if(!(this instanceof a))return new a(c);const p=c?i(this,c,"readableHighWaterMark",!0):null;p===0&&(c={...c,highWaterMark:null,readableHighWaterMark:p,writableHighWaterMark:c.writableHighWaterMark||0}),n.call(this,c),this._readableState.sync=!1,this[o]=null,c&&(typeof c.transform=="function"&&(this._transform=c.transform),typeof c.flush=="function"&&(this._flush=c.flush)),this.on("prefinish",l)}function s(c){typeof this._flush=="function"&&!this.destroyed?this._flush((p,g)=>{if(p){c?c(p):this.destroy(p);return}g!=null&&this.push(g),this.push(null),c&&c()}):(this.push(null),c&&c())}function l(){this._final!==s&&s.call(this)}return a.prototype._final=s,a.prototype._transform=function(c,p,g){throw new r("_transform()")},a.prototype._write=function(c,p,g){const S=this._readableState,O=this._writableState,x=S.length;this._transform(c,p,(v,w)=>{if(v){g(v);return}w!=null&&this.push(w),O.ended||x===S.length||S.length<S.highWaterMark?g():this[o]=g})},a.prototype._read=function(){if(this[o]){const c=this[o];this[o]=null,c()}},bo}var go,Tu;function Wf(){if(Tu)return go;Tu=1;const{ObjectSetPrototypeOf:e}=De();go=r;const t=Ff();e(r.prototype,t.prototype),e(r,t);function r(n){if(!(this instanceof r))return new r(n);t.call(this,n)}return r.prototype._transform=function(n,i,o){o(null,n)},go}var wo,Ou;function Xa(){if(Ou)return wo;Ou=1;const e=st(),{ArrayIsArray:t,Promise:r,SymbolAsyncIterator:n,SymbolDispose:i}=De(),o=Bt(),{once:a}=rt(),s=kr(),l=Ot(),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:g,ERR_MISSING_ARGS:S,ERR_STREAM_DESTROYED:O,ERR_STREAM_PREMATURE_CLOSE:x},AbortError:v}=Ze(),{validateFunction:w,validateAbortSignal:P}=jn(),{isIterable:E,isReadable:m,isReadableNodeStream:Q,isNodeStream:V,isTransformStream:se,isWebStream:ae,isReadableStream:Y,isReadableFinished:ce}=Ct(),L=globalThis.AbortController||Et().AbortController;let R,F,A;function K(C,X,re){let oe=!1;C.on("close",()=>{oe=!0});const ie=o(C,{readable:X,writable:re},I=>{oe=!I});return{destroy:I=>{oe||(oe=!0,s.destroyer(C,I||new O("pipe")))},cleanup:ie}}function J(C){return w(C[C.length-1],"streams[stream.length - 1]"),C.pop()}function ee(C){if(E(C))return C;if(Q(C))return ue(C);throw new p("val",["Readable","Iterable","AsyncIterable"],C)}async function*ue(C){F||(F=Ii()),yield*F.prototype[n].call(C)}async function D(C,X,re,{end:oe}){let ie,I=null;const N=j=>{if(j&&(ie=j),I){const u=I;I=null,u()}},G=()=>new r((j,u)=>{ie?u(ie):I=()=>{ie?u(ie):j()}});X.on("drain",N);const ne=o(X,{readable:!1},N);try{X.writableNeedDrain&&await G();for await(const j of C)X.write(j)||await G();oe&&(X.end(),await G()),re()}catch(j){re(ie!==j?c(ie,j):j)}finally{ne(),X.off("drain",N)}}async function Z(C,X,re,{end:oe}){se(X)&&(X=X.writable);const ie=X.getWriter();try{for await(const I of C)await ie.ready,ie.write(I).catch(()=>{});await ie.ready,oe&&await ie.close(),re()}catch(I){try{await ie.abort(I),re(I)}catch(N){re(N)}}}function _(...C){return $(C,a(J(C)))}function $(C,X,re){if(C.length===1&&t(C[0])&&(C=C[0]),C.length<2)throw new S("streams");const oe=new L,ie=oe.signal,I=re?.signal,N=[];P(I,"options.signal");function G(){q(new v)}A=A||rt().addAbortListener;let ne;I&&(ne=A(I,G));let j,u;const d=[];let b=0;function T(W){q(W,--b===0)}function q(W,k){var de;if(W&&(!j||j.code==="ERR_STREAM_PREMATURE_CLOSE")&&(j=W),!(!j&&!k)){for(;d.length;)d.shift()(j);(de=ne)===null||de===void 0||de[i](),oe.abort(),k&&(j||N.forEach(me=>me()),e.nextTick(X,j,u))}}let U;for(let W=0;W<C.length;W++){const k=C[W],de=W<C.length-1,me=W>0,he=de||re?.end!==!1,Se=W===C.length-1;if(V(k)){let be=function(Le){Le&&Le.name!=="AbortError"&&Le.code!=="ERR_STREAM_PREMATURE_CLOSE"&&T(Le)};if(he){const{destroy:Le,cleanup:Fe}=K(k,de,me);d.push(Le),m(k)&&Se&&N.push(Fe)}k.on("error",be),m(k)&&Se&&N.push(()=>{k.removeListener("error",be)})}if(W===0)if(typeof k=="function"){if(U=k({signal:ie}),!E(U))throw new g("Iterable, AsyncIterable or Stream","source",U)}else E(k)||Q(k)||se(k)?U=k:U=l.from(k);else if(typeof k=="function"){if(se(U)){var y;U=ee((y=U)===null||y===void 0?void 0:y.readable)}else U=ee(U);if(U=k(U,{signal:ie}),de){if(!E(U,!0))throw new g("AsyncIterable",`transform[${W-1}]`,U)}else{var M;R||(R=Wf());const be=new R({objectMode:!0}),Le=(M=U)===null||M===void 0?void 0:M.then;if(typeof Le=="function")b++,Le.call(U,Ae=>{u=Ae,Ae!=null&&be.write(Ae),he&&be.end(),e.nextTick(T)},Ae=>{be.destroy(Ae),e.nextTick(T,Ae)});else if(E(U,!0))b++,D(U,be,T,{end:he});else if(Y(U)||se(U)){const Ae=U.readable||U;b++,D(Ae,be,T,{end:he})}else throw new g("AsyncIterable or Promise","destination",U);U=be;const{destroy:Fe,cleanup:It}=K(U,!1,!0);d.push(Fe),Se&&N.push(It)}}else if(V(k)){if(Q(U)){b+=2;const be=H(U,k,T,{end:he});m(k)&&Se&&N.push(be)}else if(se(U)||Y(U)){const be=U.readable||U;b++,D(be,k,T,{end:he})}else if(E(U))b++,D(U,k,T,{end:he});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],U);U=k}else if(ae(k)){if(Q(U))b++,Z(ee(U),k,T,{end:he});else if(Y(U)||E(U))b++,Z(U,k,T,{end:he});else if(se(U))b++,Z(U.readable,k,T,{end:he});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],U);U=k}else U=l.from(k)}return(ie!=null&&ie.aborted||I!=null&&I.aborted)&&e.nextTick(G),U}function H(C,X,re,{end:oe}){let ie=!1;if(X.on("close",()=>{ie||re(new x)}),C.pipe(X,{end:!1}),oe){let I=function(){ie=!0,X.end()};ce(C)?e.nextTick(I):C.once("end",I)}else re();return o(C,{readable:!0,writable:!1},I=>{const N=C._readableState;I&&I.code==="ERR_STREAM_PREMATURE_CLOSE"&&N&&N.ended&&!N.errored&&!N.errorEmitted?C.once("end",re).once("error",re):re(I)}),o(X,{readable:!1,writable:!0},re)}return wo={pipelineImpl:$,pipeline:_},wo}var mo,Mu;function zf(){if(Mu)return mo;Mu=1;const{pipeline:e}=Xa(),t=Ot(),{destroyer:r}=kr(),{isNodeStream:n,isReadable:i,isWritable:o,isWebStream:a,isTransformStream:s,isWritableStream:l,isReadableStream:c}=Ct(),{AbortError:p,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:S}}=Ze(),O=Bt();return mo=function(...v){if(v.length===0)throw new S("streams");if(v.length===1)return t.from(v[0]);const w=[...v];if(typeof v[0]=="function"&&(v[0]=t.from(v[0])),typeof v[v.length-1]=="function"){const R=v.length-1;v[R]=t.from(v[R])}for(let R=0;R<v.length;++R)if(!(!n(v[R])&&!a(v[R]))){if(R<v.length-1&&!(i(v[R])||c(v[R])||s(v[R])))throw new g(`streams[${R}]`,w[R],"must be readable");if(R>0&&!(o(v[R])||l(v[R])||s(v[R])))throw new g(`streams[${R}]`,w[R],"must be writable")}let P,E,m,Q,V;function se(R){const F=Q;Q=null,F?F(R):R?V.destroy(R):!L&&!ce&&V.destroy()}const ae=v[0],Y=e(v,se),ce=!!(o(ae)||l(ae)||s(ae)),L=!!(i(Y)||c(Y)||s(Y));if(V=new t({writableObjectMode:!!(ae!=null&&ae.writableObjectMode),readableObjectMode:!!(Y!=null&&Y.readableObjectMode),writable:ce,readable:L}),ce){if(n(ae))V._write=function(F,A,K){ae.write(F,A)?K():P=K},V._final=function(F){ae.end(),E=F},ae.on("drain",function(){if(P){const F=P;P=null,F()}});else if(a(ae)){const A=(s(ae)?ae.writable:ae).getWriter();V._write=async function(K,J,ee){try{await A.ready,A.write(K).catch(()=>{}),ee()}catch(ue){ee(ue)}},V._final=async function(K){try{await A.ready,A.close().catch(()=>{}),E=K}catch(J){K(J)}}}const R=s(Y)?Y.readable:Y;O(R,()=>{if(E){const F=E;E=null,F()}})}if(L){if(n(Y))Y.on("readable",function(){if(m){const R=m;m=null,R()}}),Y.on("end",function(){V.push(null)}),V._read=function(){for(;;){const R=Y.read();if(R===null){m=V._read;return}if(!V.push(R))return}};else if(a(Y)){const F=(s(Y)?Y.readable:Y).getReader();V._read=async function(){for(;;)try{const{value:A,done:K}=await F.read();if(!V.push(A))return;if(K){V.push(null);return}}catch{return}}}}return V._destroy=function(R,F){!R&&Q!==null&&(R=new p),m=null,P=null,E=null,Q===null?F(R):(Q=F,n(Y)&&r(Y,R))},V},mo}var Pu;function Vh(){if(Pu)return ei;Pu=1;const e=globalThis.AbortController||Et().AbortController,{codes:{ERR_INVALID_ARG_VALUE:t,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:i},AbortError:o}=Ze(),{validateAbortSignal:a,validateInteger:s,validateObject:l}=jn(),c=De().Symbol("kWeak"),p=De().Symbol("kResistStopPropagation"),{finished:g}=Bt(),S=zf(),{addAbortSignalNoValidate:O}=vi(),{isWritable:x,isNodeStream:v}=Ct(),{deprecate:w}=rt(),{ArrayPrototypePush:P,Boolean:E,MathFloor:m,Number:Q,NumberIsNaN:V,Promise:se,PromiseReject:ae,PromiseResolve:Y,PromisePrototypeThen:ce,Symbol:L}=De(),R=L("kEmpty"),F=L("kEof");function A(I,N){if(N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),v(I)&&!x(I))throw new t("stream",I,"must be writable");const G=S(this,I);return N!=null&&N.signal&&O(N.signal,G),G}function K(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal");let G=1;N?.concurrency!=null&&(G=m(N.concurrency));let ne=G-1;return N?.highWaterMark!=null&&(ne=m(N.highWaterMark)),s(G,"options.concurrency",1),s(ne,"options.highWaterMark",0),ne+=G,(async function*(){const u=rt().AbortSignalAny([N?.signal].filter(E)),d=this,b=[],T={signal:u};let q,U,y=!1,M=0;function W(){y=!0,k()}function k(){M-=1,de()}function de(){U&&!y&&M<G&&b.length<ne&&(U(),U=null)}async function me(){try{for await(let he of d){if(y)return;if(u.aborted)throw new o;try{if(he=I(he,T),he===R)continue;he=Y(he)}catch(Se){he=ae(Se)}M+=1,ce(he,k,W),b.push(he),q&&(q(),q=null),!y&&(b.length>=ne||M>=G)&&await new se(Se=>{U=Se})}b.push(F)}catch(he){const Se=ae(he);ce(Se,k,W),b.push(Se)}finally{y=!0,q&&(q(),q=null)}}me();try{for(;;){for(;b.length>0;){const he=await b[0];if(he===F)return;if(u.aborted)throw new o;he!==R&&(yield he),b.shift(),de()}await new se(he=>{q=he})}}finally{y=!0,U&&(U(),U=null)}}).call(this)}function J(I=void 0){return I!=null&&l(I,"options"),I?.signal!=null&&a(I.signal,"options.signal"),(async function*(){let G=0;for await(const j of this){var ne;if(I!=null&&(ne=I.signal)!==null&&ne!==void 0&&ne.aborted)throw new o({cause:I.signal.reason});yield[G++,j]}}).call(this)}async function ee(I,N=void 0){for await(const G of _.call(this,I,N))return!0;return!1}async function ue(I,N=void 0){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);return!await ee.call(this,async(...G)=>!await I(...G),N)}async function D(I,N){for await(const G of _.call(this,I,N))return G}async function Z(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);async function G(ne,j){return await I(ne,j),R}for await(const ne of K.call(this,G,N));}function _(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);async function G(ne,j){return await I(ne,j)?ne:R}return K.call(this,G,N)}class $ extends n{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function H(I,N,G){var ne;if(typeof I!="function")throw new r("reducer",["Function","AsyncFunction"],I);G!=null&&l(G,"options"),G?.signal!=null&&a(G.signal,"options.signal");let j=arguments.length>1;if(G!=null&&(ne=G.signal)!==null&&ne!==void 0&&ne.aborted){const q=new o(void 0,{cause:G.signal.reason});throw this.once("error",()=>{}),await g(this.destroy(q)),q}const u=new e,d=u.signal;if(G!=null&&G.signal){const q={once:!0,[c]:this,[p]:!0};G.signal.addEventListener("abort",()=>u.abort(),q)}let b=!1;try{for await(const q of this){var T;if(b=!0,G!=null&&(T=G.signal)!==null&&T!==void 0&&T.aborted)throw new o;j?N=await I(N,q,{signal:d}):(N=q,j=!0)}if(!b&&!j)throw new $}finally{u.abort()}return N}async function C(I){I!=null&&l(I,"options"),I?.signal!=null&&a(I.signal,"options.signal");const N=[];for await(const ne of this){var G;if(I!=null&&(G=I.signal)!==null&&G!==void 0&&G.aborted)throw new o(void 0,{cause:I.signal.reason});P(N,ne)}return N}function X(I,N){const G=K.call(this,I,N);return(async function*(){for await(const j of G)yield*j}).call(this)}function re(I){if(I=Q(I),V(I))return 0;if(I<0)throw new i("number",">= 0",I);return I}function oe(I,N=void 0){return N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),I=re(I),(async function*(){var ne;if(N!=null&&(ne=N.signal)!==null&&ne!==void 0&&ne.aborted)throw new o;for await(const u of this){var j;if(N!=null&&(j=N.signal)!==null&&j!==void 0&&j.aborted)throw new o;I--<=0&&(yield u)}}).call(this)}function ie(I,N=void 0){return N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),I=re(I),(async function*(){var ne;if(N!=null&&(ne=N.signal)!==null&&ne!==void 0&&ne.aborted)throw new o;for await(const u of this){var j;if(N!=null&&(j=N.signal)!==null&&j!==void 0&&j.aborted)throw new o;if(I-- >0&&(yield u),I<=0)return}}).call(this)}return ei.streamReturningOperators={asIndexedPairs:w(J,"readable.asIndexedPairs will be removed in a future version."),drop:oe,filter:_,flatMap:X,map:K,take:ie,compose:A},ei.promiseReturningOperators={every:ue,forEach:Z,reduce:H,toArray:C,some:ee,find:D},ei}var So,Cu;function Bf(){if(Cu)return So;Cu=1;const{ArrayPrototypePop:e,Promise:t}=De(),{isIterable:r,isNodeStream:n,isWebStream:i}=Ct(),{pipelineImpl:o}=Xa(),{finished:a}=Bt();Kf();function s(...l){return new t((c,p)=>{let g,S;const O=l[l.length-1];if(O&&typeof O=="object"&&!n(O)&&!r(O)&&!i(O)){const x=e(l);g=x.signal,S=x.end}o(l,(x,v)=>{x?p(x):c(v)},{signal:g,end:S})})}return So={finished:a,pipeline:s},So}var Lu;function Kf(){if(Lu)return Zi.exports;Lu=1;const{Buffer:e}=at(),{ObjectDefineProperty:t,ObjectKeys:r,ReflectApply:n}=De(),{promisify:{custom:i}}=rt(),{streamReturningOperators:o,promiseReturningOperators:a}=Vh(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:s}}=Ze(),l=zf(),{setDefaultHighWaterMark:c,getDefaultHighWaterMark:p}=Ri(),{pipeline:g}=Xa(),{destroyer:S}=kr(),O=Bt(),x=Bf(),v=Ct(),w=Zi.exports=Ja().Stream;w.isDestroyed=v.isDestroyed,w.isDisturbed=v.isDisturbed,w.isErrored=v.isErrored,w.isReadable=v.isReadable,w.isWritable=v.isWritable,w.Readable=Ii();for(const E of r(o)){let Q=function(...V){if(new.target)throw s();return w.Readable.from(n(m,this,V))};const m=o[E];t(Q,"name",{__proto__:null,value:m.name}),t(Q,"length",{__proto__:null,value:m.length}),t(w.Readable.prototype,E,{__proto__:null,value:Q,enumerable:!1,configurable:!0,writable:!0})}for(const E of r(a)){let Q=function(...V){if(new.target)throw s();return n(m,this,V)};const m=a[E];t(Q,"name",{__proto__:null,value:m.name}),t(Q,"length",{__proto__:null,value:m.length}),t(w.Readable.prototype,E,{__proto__:null,value:Q,enumerable:!1,configurable:!0,writable:!0})}w.Writable=Qa(),w.Duplex=Ot(),w.Transform=Ff(),w.PassThrough=Wf(),w.pipeline=g;const{addAbortSignal:P}=vi();return w.addAbortSignal=P,w.finished=O,w.destroy=S,w.compose=l,w.setDefaultHighWaterMark=c,w.getDefaultHighWaterMark=p,t(w,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return x}}),t(g,i,{__proto__:null,enumerable:!0,get(){return x.pipeline}}),t(O,i,{__proto__:null,enumerable:!0,get(){return x.finished}}),w.Stream=w,w._isUint8Array=function(m){return m instanceof Uint8Array},w._uint8ArrayToBuffer=function(m){return e.from(m.buffer,m.byteOffset,m.byteLength)},Zi.exports}var Du;function Yh(){return Du||(Du=1,(function(e){const t=Kf(),r=Bf(),n=t.Readable.destroy;e.exports=t.Readable,e.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,e.exports._isUint8Array=t._isUint8Array,e.exports.isDisturbed=t.isDisturbed,e.exports.isErrored=t.isErrored,e.exports.isReadable=t.isReadable,e.exports.Readable=t.Readable,e.exports.Writable=t.Writable,e.exports.Duplex=t.Duplex,e.exports.Transform=t.Transform,e.exports.PassThrough=t.PassThrough,e.exports.addAbortSignal=t.addAbortSignal,e.exports.finished=t.finished,e.exports.destroy=t.destroy,e.exports.destroy=n,e.exports.pipeline=t.pipeline,e.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get(){return r}}),e.exports.Stream=t.Stream,e.exports.default=e.exports})(Xi)),Xi.exports}var ku;function Jh(){if(ku)return Zr;ku=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.ActorQueryResultSerializeStats=void 0;const e=Nf(),t=Uh(),r=zt(),n=qf(),i=Yh();let o=class extends e.ActorQueryResultSerializeFixedMediaTypes{constructor(s){super(s)}async testHandleChecked(s,l){return["bindings","quads"].includes(s.type)?(0,r.passTestVoid)():(0,r.failTest)("This actor can only handle bindings streams or quad streams.")}pushHeader(s){const l=["Result","Delay (ms)","HTTP requests"].join(",");s.push(`${l}
5
- `)}createStat(s,l){return`${[l,this.delay(s),this.httpObserver.requests].join(",")}
6
- `}createSpecialLine(s,l){return`${[s,this.delay(l),this.httpObserver.requests].join(",")}
7
- `}async runHandle(s,l,c){const p=new i.Readable,g=s.type==="bindings"?s.bindingsStream:s.quadStream,S=s.context.getSafe(t.KeysInitQuery.queryTimestampHighResolution);let O=1;function*x(w){yield w()}const v=(0,n.wrap)(g).map(()=>this.createStat(S,O++)).prepend([this.createSpecialLine("PLANNING",S)]).append((0,n.wrap)(x(()=>this.createSpecialLine("TOTAL",S))));return this.pushHeader(p),p.wrap(v),{data:p}}now(){return performance.now()}delay(s){return this.now()-s}};return Zr.ActorQueryResultSerializeStats=o,Zr}var xu;function Qh(){return xu||(xu=1,(function(e){var t=Qt&&Qt.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=Qt&&Qt.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(kh(),e),r(Jh(),e)})(Qt)),Qt}var Xh=Qh(),nr={},sn={},Nu;function Zh(){if(Nu)return sn;Nu=1,Object.defineProperty(sn,"__esModule",{value:!0}),sn.ActionObserverHttp=void 0;const e=zt();let t=class extends e.ActionObserver{constructor(n){super(n),this.requests=0,this.bus.subscribeObserver(this),this.httpInvalidator.addInvalidateListener(()=>{this.requests=0})}onRun(n,i,o){this.observedActors.includes(n.name)&&this.requests++}};return sn.ActionObserverHttp=t,sn}var un={},Ao={exports:{}},Eo={exports:{}},vo,$u;function ke(){if($u)return vo;$u=1;class e extends Error{constructor(r){if(!Array.isArray(r))throw new TypeError(`Expected input to be an Array, got ${typeof r}`);let n="";for(let i=0;i<r.length;i++)n+=` ${r[i].stack}
8
- `;super(n),this.name="AggregateError",this.errors=r}}return vo={AggregateError:e,ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,r){return t.includes(r)},ArrayPrototypeIndexOf(t,r){return t.indexOf(r)},ArrayPrototypeJoin(t,r){return t.join(r)},ArrayPrototypeMap(t,r){return t.map(r)},ArrayPrototypePop(t,r){return t.pop(r)},ArrayPrototypePush(t,r){return t.push(r)},ArrayPrototypeSlice(t,r,n){return t.slice(r,n)},Error,FunctionPrototypeCall(t,r,...n){return t.call(r,...n)},FunctionPrototypeSymbolHasInstance(t,r){return Function.prototype[Symbol.hasInstance].call(t,r)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,r){return Object.defineProperties(t,r)},ObjectDefineProperty(t,r,n){return Object.defineProperty(t,r,n)},ObjectGetOwnPropertyDescriptor(t,r){return Object.getOwnPropertyDescriptor(t,r)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,r){return Object.setPrototypeOf(t,r)},Promise,PromisePrototypeCatch(t,r){return t.catch(r)},PromisePrototypeThen(t,r,n){return t.then(r,n)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,r){return t.test(r)},SafeSet:Set,String,StringPrototypeSlice(t,r,n){return t.slice(r,n)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,r,n){return t.set(r,n)},Boolean,Uint8Array},vo}var Ro={exports:{}},Io,qu;function Hf(){return qu||(qu=1,Io={format(e,...t){return e.replace(/%([sdifj])/g,function(...[r,n]){const i=t.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(e){switch(typeof e){case"string":if(e.includes("'"))if(e.includes('"')){if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}else return`"${e}"`;return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}}}),Io}var To,Uu;function et(){if(Uu)return To;Uu=1;const{format:e,inspect:t}=Hf(),{AggregateError:r}=ke(),n=globalThis.AggregateError||r,i=Symbol("kIsNodeError"),o=["string","function","number","object","Function","Object","boolean","bigint","symbol"],a=/^([A-Z][a-z0-9]*)+$/,s="__node_internal_",l={};function c(w,P){if(!w)throw new l.ERR_INTERNAL_ASSERTION(P)}function p(w){let P="",E=w.length;const m=w[0]==="-"?1:0;for(;E>=m+4;E-=3)P=`_${w.slice(E-3,E)}${P}`;return`${w.slice(0,E)}${P}`}function g(w,P,E){if(typeof P=="function")return c(P.length<=E.length,`Code: ${w}; The provided arguments length (${E.length}) does not match the required ones (${P.length}).`),P(...E);const m=(P.match(/%[dfijoOs]/g)||[]).length;return c(m===E.length,`Code: ${w}; The provided arguments length (${E.length}) does not match the required ones (${m}).`),E.length===0?P:e(P,...E)}function S(w,P,E){E||(E=Error);class m extends E{constructor(...V){super(g(w,P,V))}toString(){return`${this.name} [${w}]: ${this.message}`}}Object.defineProperties(m.prototype,{name:{value:E.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${w}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),m.prototype.code=w,m.prototype[i]=!0,l[w]=m}function O(w){const P=s+w.name;return Object.defineProperty(w,"name",{value:P}),w}function x(w,P){if(w&&P&&w!==P){if(Array.isArray(P.errors))return P.errors.push(w),P;const E=new n([P,w],P.message);return E.code=P.code,E}return w||P}class v extends Error{constructor(P="The operation was aborted",E=void 0){if(E!==void 0&&typeof E!="object")throw new l.ERR_INVALID_ARG_TYPE("options","Object",E);super(P,E),this.code="ABORT_ERR",this.name="AbortError"}}return S("ERR_ASSERTION","%s",Error),S("ERR_INVALID_ARG_TYPE",(w,P,E)=>{c(typeof w=="string","'name' must be a string"),Array.isArray(P)||(P=[P]);let m="The ";w.endsWith(" argument")?m+=`${w} `:m+=`"${w}" ${w.includes(".")?"property":"argument"} `,m+="must be ";const Q=[],V=[],se=[];for(const Y of P)c(typeof Y=="string","All expected entries have to be of type string"),o.includes(Y)?Q.push(Y.toLowerCase()):a.test(Y)?V.push(Y):(c(Y!=="object",'The value "object" should be written as "Object"'),se.push(Y));if(V.length>0){const Y=Q.indexOf("object");Y!==-1&&(Q.splice(Q,Y,1),V.push("Object"))}if(Q.length>0){switch(Q.length){case 1:m+=`of type ${Q[0]}`;break;case 2:m+=`one of type ${Q[0]} or ${Q[1]}`;break;default:{const Y=Q.pop();m+=`one of type ${Q.join(", ")}, or ${Y}`}}(V.length>0||se.length>0)&&(m+=" or ")}if(V.length>0){switch(V.length){case 1:m+=`an instance of ${V[0]}`;break;case 2:m+=`an instance of ${V[0]} or ${V[1]}`;break;default:{const Y=V.pop();m+=`an instance of ${V.join(", ")}, or ${Y}`}}se.length>0&&(m+=" or ")}switch(se.length){case 0:break;case 1:se[0].toLowerCase()!==se[0]&&(m+="an "),m+=`${se[0]}`;break;case 2:m+=`one of ${se[0]} or ${se[1]}`;break;default:{const Y=se.pop();m+=`one of ${se.join(", ")}, or ${Y}`}}if(E==null)m+=`. Received ${E}`;else if(typeof E=="function"&&E.name)m+=`. Received function ${E.name}`;else if(typeof E=="object"){var ae;if((ae=E.constructor)!==null&&ae!==void 0&&ae.name)m+=`. Received an instance of ${E.constructor.name}`;else{const Y=t(E,{depth:-1});m+=`. Received ${Y}`}}else{let Y=t(E,{colors:!1});Y.length>25&&(Y=`${Y.slice(0,25)}...`),m+=`. Received type ${typeof E} (${Y})`}return m},TypeError),S("ERR_INVALID_ARG_VALUE",(w,P,E="is invalid")=>{let m=t(P);return m.length>128&&(m=m.slice(0,128)+"..."),`The ${w.includes(".")?"property":"argument"} '${w}' ${E}. Received ${m}`},TypeError),S("ERR_INVALID_RETURN_VALUE",(w,P,E)=>{var m;const Q=E!=null&&(m=E.constructor)!==null&&m!==void 0&&m.name?`instance of ${E.constructor.name}`:`type ${typeof E}`;return`Expected ${w} to be returned from the "${P}" function but got ${Q}.`},TypeError),S("ERR_MISSING_ARGS",(...w)=>{c(w.length>0,"At least one arg needs to be specified");let P;const E=w.length;switch(w=(Array.isArray(w)?w:[w]).map(m=>`"${m}"`).join(" or "),E){case 1:P+=`The ${w[0]} argument`;break;case 2:P+=`The ${w[0]} and ${w[1]} arguments`;break;default:{const m=w.pop();P+=`The ${w.join(", ")}, and ${m} arguments`}break}return`${P} must be specified`},TypeError),S("ERR_OUT_OF_RANGE",(w,P,E)=>{c(P,'Missing "range" argument');let m;if(Number.isInteger(E)&&Math.abs(E)>2**32)m=p(String(E));else if(typeof E=="bigint"){m=String(E);const Q=BigInt(2)**BigInt(32);(E>Q||E<-Q)&&(m=p(m)),m+="n"}else m=t(E);return`The value of "${w}" is out of range. It must be ${P}. Received ${m}`},RangeError),S("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),S("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),S("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),S("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),S("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),S("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),S("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),S("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),S("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),S("ERR_STREAM_WRITE_AFTER_END","write after end",Error),S("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),To={AbortError:v,aggregateTwoErrors:O(x),hideStackFrames:O,codes:l},To}var ju;function nt(){return ju||(ju=1,(function(e){const t=at(),{format:r,inspect:n}=Hf(),{codes:{ERR_INVALID_ARG_TYPE:i}}=et(),{kResistStopPropagation:o,AggregateError:a,SymbolDispose:s}=ke(),l=globalThis.AbortSignal||Et().AbortSignal,c=globalThis.AbortController||Et().AbortController,p=Object.getPrototypeOf(async function(){}).constructor,g=globalThis.Blob||t.Blob,S=typeof g<"u"?function(w){return w instanceof g}:function(w){return!1},O=(v,w)=>{if(v!==void 0&&(v===null||typeof v!="object"||!("aborted"in v)))throw new i(w,"AbortSignal",v)},x=(v,w)=>{if(typeof v!="function")throw new i(w,"Function",v)};e.exports={AggregateError:a,kEmptyObject:Object.freeze({}),once(v){let w=!1;return function(...P){w||(w=!0,v.apply(this,P))}},createDeferredPromise:function(){let v,w;return{promise:new Promise((E,m)=>{v=E,w=m}),resolve:v,reject:w}},promisify(v){return new Promise((w,P)=>{v((E,...m)=>E?P(E):w(...m))})},debuglog(){return function(){}},format:r,inspect:n,types:{isAsyncFunction(v){return v instanceof p},isArrayBufferView(v){return ArrayBuffer.isView(v)}},isBlob:S,deprecate(v,w){return v},addAbortListener:Pt().addAbortListener||function(w,P){if(w===void 0)throw new i("signal","AbortSignal",w);O(w,"signal"),x(P,"listener");let E;return w.aborted?queueMicrotask(()=>P()):(w.addEventListener("abort",P,{__proto__:null,once:!0,[o]:!0}),E=()=>{w.removeEventListener("abort",P)}),{__proto__:null,[s](){var m;(m=E)===null||m===void 0||m()}}},AbortSignalAny:l.any||function(w){if(w.length===1)return w[0];const P=new c,E=()=>P.abort();return w.forEach(m=>{O(m,"signals"),m.addEventListener("abort",E,{once:!0})}),P.signal.addEventListener("abort",()=>{w.forEach(m=>m.removeEventListener("abort",E))},{once:!0}),P.signal}},e.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(Ro)),Ro.exports}var ri={},Oo,Fu;function Fn(){if(Fu)return Oo;Fu=1;const{ArrayIsArray:e,ArrayPrototypeIncludes:t,ArrayPrototypeJoin:r,ArrayPrototypeMap:n,NumberIsInteger:i,NumberIsNaN:o,NumberMAX_SAFE_INTEGER:a,NumberMIN_SAFE_INTEGER:s,NumberParseInt:l,ObjectPrototypeHasOwnProperty:c,RegExpPrototypeExec:p,String:g,StringPrototypeToUpperCase:S,StringPrototypeTrim:O}=ke(),{hideStackFrames:x,codes:{ERR_SOCKET_BAD_PORT:v,ERR_INVALID_ARG_TYPE:w,ERR_INVALID_ARG_VALUE:P,ERR_OUT_OF_RANGE:E,ERR_UNKNOWN_SIGNAL:m}}=et(),{normalizeEncoding:Q}=nt(),{isAsyncFunction:V,isArrayBufferView:se}=nt().types,ae={};function Y(y){return y===(y|0)}function ce(y){return y===y>>>0}const L=/^[0-7]+$/,R="must be a 32-bit unsigned integer or an octal string";function F(y,M,W){if(typeof y>"u"&&(y=W),typeof y=="string"){if(p(L,y)===null)throw new P(M,y,R);y=l(y,8)}return J(y,M),y}const A=x((y,M,W=s,k=a)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);if(y<W||y>k)throw new E(M,`>= ${W} && <= ${k}`,y)}),K=x((y,M,W=-2147483648,k=2147483647)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);if(y<W||y>k)throw new E(M,`>= ${W} && <= ${k}`,y)}),J=x((y,M,W=!1)=>{if(typeof y!="number")throw new w(M,"number",y);if(!i(y))throw new E(M,"an integer",y);const k=W?1:0,de=4294967295;if(y<k||y>de)throw new E(M,`>= ${k} && <= ${de}`,y)});function ee(y,M){if(typeof y!="string")throw new w(M,"string",y)}function ue(y,M,W=void 0,k){if(typeof y!="number")throw new w(M,"number",y);if(W!=null&&y<W||k!=null&&y>k||(W!=null||k!=null)&&o(y))throw new E(M,`${W!=null?`>= ${W}`:""}${W!=null&&k!=null?" && ":""}${k!=null?`<= ${k}`:""}`,y)}const D=x((y,M,W)=>{if(!t(W,y)){const de="must be one of: "+r(n(W,me=>typeof me=="string"?`'${me}'`:g(me)),", ");throw new P(M,y,de)}});function Z(y,M){if(typeof y!="boolean")throw new w(M,"boolean",y)}function _(y,M,W){return y==null||!c(y,M)?W:y[M]}const $=x((y,M,W=null)=>{const k=_(W,"allowArray",!1),de=_(W,"allowFunction",!1);if(!_(W,"nullable",!1)&&y===null||!k&&e(y)||typeof y!="object"&&(!de||typeof y!="function"))throw new w(M,"Object",y)}),H=x((y,M)=>{if(y!=null&&typeof y!="object"&&typeof y!="function")throw new w(M,"a dictionary",y)}),C=x((y,M,W=0)=>{if(!e(y))throw new w(M,"Array",y);if(y.length<W){const k=`must be longer than ${W}`;throw new P(M,y,k)}});function X(y,M){C(y,M);for(let W=0;W<y.length;W++)ee(y[W],`${M}[${W}]`)}function re(y,M){C(y,M);for(let W=0;W<y.length;W++)Z(y[W],`${M}[${W}]`)}function oe(y,M){C(y,M);for(let W=0;W<y.length;W++){const k=y[W],de=`${M}[${W}]`;if(k==null)throw new w(de,"AbortSignal",k);ne(k,de)}}function ie(y,M="signal"){if(ee(y,M),ae[y]===void 0)throw ae[S(y)]!==void 0?new m(y+" (signals must use all capital letters)"):new m(y)}const I=x((y,M="buffer")=>{if(!se(y))throw new w(M,["Buffer","TypedArray","DataView"],y)});function N(y,M){const W=Q(M),k=y.length;if(W==="hex"&&k%2!==0)throw new P("encoding",M,`is invalid for data of length ${k}`)}function G(y,M="Port",W=!0){if(typeof y!="number"&&typeof y!="string"||typeof y=="string"&&O(y).length===0||+y!==+y>>>0||y>65535||y===0&&!W)throw new v(M,y,W);return y|0}const ne=x((y,M)=>{if(y!==void 0&&(y===null||typeof y!="object"||!("aborted"in y)))throw new w(M,"AbortSignal",y)}),j=x((y,M)=>{if(typeof y!="function")throw new w(M,"Function",y)}),u=x((y,M)=>{if(typeof y!="function"||V(y))throw new w(M,"Function",y)}),d=x((y,M)=>{if(y!==void 0)throw new w(M,"undefined",y)});function b(y,M,W){if(!t(W,y))throw new w(M,`('${r(W,"|")}')`,y)}const T=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function q(y,M){if(typeof y>"u"||!p(T,y))throw new P(M,y,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function U(y){if(typeof y=="string")return q(y,"hints"),y;if(e(y)){const M=y.length;let W="";if(M===0)return W;for(let k=0;k<M;k++){const de=y[k];q(de,"hints"),W+=de,k!==M-1&&(W+=", ")}return W}throw new P("hints",y,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}return Oo={isInt32:Y,isUint32:ce,parseFileMode:F,validateArray:C,validateStringArray:X,validateBooleanArray:re,validateAbortSignalArray:oe,validateBoolean:Z,validateBuffer:I,validateDictionary:H,validateEncoding:N,validateFunction:j,validateInt32:K,validateInteger:A,validateNumber:ue,validateObject:$,validateOneOf:D,validatePlainFunction:u,validatePort:G,validateSignalName:ie,validateString:ee,validateUint32:J,validateUndefined:d,validateUnion:b,validateAbortSignal:ne,validateLinkHeaderValue:U},Oo}var ni={exports:{}},Mo,Wu;function Lt(){if(Wu)return Mo;Wu=1;const{SymbolAsyncIterator:e,SymbolIterator:t,SymbolFor:r}=ke(),n=r("nodejs.stream.destroyed"),i=r("nodejs.stream.errored"),o=r("nodejs.stream.readable"),a=r("nodejs.stream.writable"),s=r("nodejs.stream.disturbed"),l=r("nodejs.webstream.isClosedPromise"),c=r("nodejs.webstream.controllerErrorFunction");function p(_,$=!1){var H;return!!(_&&typeof _.pipe=="function"&&typeof _.on=="function"&&(!$||typeof _.pause=="function"&&typeof _.resume=="function")&&(!_._writableState||((H=_._readableState)===null||H===void 0?void 0:H.readable)!==!1)&&(!_._writableState||_._readableState))}function g(_){var $;return!!(_&&typeof _.write=="function"&&typeof _.on=="function"&&(!_._readableState||(($=_._writableState)===null||$===void 0?void 0:$.writable)!==!1))}function S(_){return!!(_&&typeof _.pipe=="function"&&_._readableState&&typeof _.on=="function"&&typeof _.write=="function")}function O(_){return _&&(_._readableState||_._writableState||typeof _.write=="function"&&typeof _.on=="function"||typeof _.pipe=="function"&&typeof _.on=="function")}function x(_){return!!(_&&!O(_)&&typeof _.pipeThrough=="function"&&typeof _.getReader=="function"&&typeof _.cancel=="function")}function v(_){return!!(_&&!O(_)&&typeof _.getWriter=="function"&&typeof _.abort=="function")}function w(_){return!!(_&&!O(_)&&typeof _.readable=="object"&&typeof _.writable=="object")}function P(_){return x(_)||v(_)||w(_)}function E(_,$){return _==null?!1:$===!0?typeof _[e]=="function":$===!1?typeof _[t]=="function":typeof _[e]=="function"||typeof _[t]=="function"}function m(_){if(!O(_))return null;const $=_._writableState,H=_._readableState,C=$||H;return!!(_.destroyed||_[n]||C!=null&&C.destroyed)}function Q(_){if(!g(_))return null;if(_.writableEnded===!0)return!0;const $=_._writableState;return $!=null&&$.errored?!1:typeof $?.ended!="boolean"?null:$.ended}function V(_,$){if(!g(_))return null;if(_.writableFinished===!0)return!0;const H=_._writableState;return H!=null&&H.errored?!1:typeof H?.finished!="boolean"?null:!!(H.finished||$===!1&&H.ended===!0&&H.length===0)}function se(_){if(!p(_))return null;if(_.readableEnded===!0)return!0;const $=_._readableState;return!$||$.errored?!1:typeof $?.ended!="boolean"?null:$.ended}function ae(_,$){if(!p(_))return null;const H=_._readableState;return H!=null&&H.errored?!1:typeof H?.endEmitted!="boolean"?null:!!(H.endEmitted||$===!1&&H.ended===!0&&H.length===0)}function Y(_){return _&&_[o]!=null?_[o]:typeof _?.readable!="boolean"?null:m(_)?!1:p(_)&&_.readable&&!ae(_)}function ce(_){return _&&_[a]!=null?_[a]:typeof _?.writable!="boolean"?null:m(_)?!1:g(_)&&_.writable&&!Q(_)}function L(_,$){return O(_)?m(_)?!0:!($?.readable!==!1&&Y(_)||$?.writable!==!1&&ce(_)):null}function R(_){var $,H;return O(_)?_.writableErrored?_.writableErrored:($=(H=_._writableState)===null||H===void 0?void 0:H.errored)!==null&&$!==void 0?$:null:null}function F(_){var $,H;return O(_)?_.readableErrored?_.readableErrored:($=(H=_._readableState)===null||H===void 0?void 0:H.errored)!==null&&$!==void 0?$:null:null}function A(_){if(!O(_))return null;if(typeof _.closed=="boolean")return _.closed;const $=_._writableState,H=_._readableState;return typeof $?.closed=="boolean"||typeof H?.closed=="boolean"?$?.closed||H?.closed:typeof _._closed=="boolean"&&K(_)?_._closed:null}function K(_){return typeof _._closed=="boolean"&&typeof _._defaultKeepAlive=="boolean"&&typeof _._removedConnection=="boolean"&&typeof _._removedContLen=="boolean"}function J(_){return typeof _._sent100=="boolean"&&K(_)}function ee(_){var $;return typeof _._consuming=="boolean"&&typeof _._dumped=="boolean"&&(($=_.req)===null||$===void 0?void 0:$.upgradeOrConnect)===void 0}function ue(_){if(!O(_))return null;const $=_._writableState,H=_._readableState,C=$||H;return!C&&J(_)||!!(C&&C.autoDestroy&&C.emitClose&&C.closed===!1)}function D(_){var $;return!!(_&&(($=_[s])!==null&&$!==void 0?$:_.readableDidRead||_.readableAborted))}function Z(_){var $,H,C,X,re,oe,ie,I,N,G;return!!(_&&(($=(H=(C=(X=(re=(oe=_[i])!==null&&oe!==void 0?oe:_.readableErrored)!==null&&re!==void 0?re:_.writableErrored)!==null&&X!==void 0?X:(ie=_._readableState)===null||ie===void 0?void 0:ie.errorEmitted)!==null&&C!==void 0?C:(I=_._writableState)===null||I===void 0?void 0:I.errorEmitted)!==null&&H!==void 0?H:(N=_._readableState)===null||N===void 0?void 0:N.errored)!==null&&$!==void 0?$:!((G=_._writableState)===null||G===void 0)&&G.errored))}return Mo={isDestroyed:m,kIsDestroyed:n,isDisturbed:D,kIsDisturbed:s,isErrored:Z,kIsErrored:i,isReadable:Y,kIsReadable:o,kIsClosedPromise:l,kControllerErrorFunction:c,kIsWritable:a,isClosed:A,isDuplexNodeStream:S,isFinished:L,isIterable:E,isReadableNodeStream:p,isReadableStream:x,isReadableEnded:se,isReadableFinished:ae,isReadableErrored:F,isNodeStream:O,isWebStream:P,isWritable:ce,isWritableNodeStream:g,isWritableStream:v,isWritableEnded:Q,isWritableFinished:V,isWritableErrored:R,isServerRequest:ee,isServerResponse:J,willEmitClose:ue,isTransformStream:w},Mo}var zu;function Kt(){if(zu)return ni.exports;zu=1;const e=st(),{AbortError:t,codes:r}=et(),{ERR_INVALID_ARG_TYPE:n,ERR_STREAM_PREMATURE_CLOSE:i}=r,{kEmptyObject:o,once:a}=nt(),{validateAbortSignal:s,validateFunction:l,validateObject:c,validateBoolean:p}=Fn(),{Promise:g,PromisePrototypeThen:S,SymbolDispose:O}=ke(),{isClosed:x,isReadable:v,isReadableNodeStream:w,isReadableStream:P,isReadableFinished:E,isReadableErrored:m,isWritable:Q,isWritableNodeStream:V,isWritableStream:se,isWritableFinished:ae,isWritableErrored:Y,isNodeStream:ce,willEmitClose:L,kIsClosedPromise:R}=Lt();let F;function A(D){return D.setHeader&&typeof D.abort=="function"}const K=()=>{};function J(D,Z,_){var $,H;if(arguments.length===2?(_=Z,Z=o):Z==null?Z=o:c(Z,"options"),l(_,"callback"),s(Z.signal,"options.signal"),_=a(_),P(D)||se(D))return ee(D,Z,_);if(!ce(D))throw new n("stream",["ReadableStream","WritableStream","Stream"],D);const C=($=Z.readable)!==null&&$!==void 0?$:w(D),X=(H=Z.writable)!==null&&H!==void 0?H:V(D),re=D._writableState,oe=D._readableState,ie=()=>{D.writable||G()};let I=L(D)&&w(D)===C&&V(D)===X,N=ae(D,!1);const G=()=>{N=!0,D.destroyed&&(I=!1),!(I&&(!D.readable||C))&&(!C||ne)&&_.call(D)};let ne=E(D,!1);const j=()=>{ne=!0,D.destroyed&&(I=!1),!(I&&(!D.writable||X))&&(!X||N)&&_.call(D)},u=y=>{_.call(D,y)};let d=x(D);const b=()=>{d=!0;const y=Y(D)||m(D);if(y&&typeof y!="boolean")return _.call(D,y);if(C&&!ne&&w(D,!0)&&!E(D,!1))return _.call(D,new i);if(X&&!N&&!ae(D,!1))return _.call(D,new i);_.call(D)},T=()=>{d=!0;const y=Y(D)||m(D);if(y&&typeof y!="boolean")return _.call(D,y);_.call(D)},q=()=>{D.req.on("finish",G)};A(D)?(D.on("complete",G),I||D.on("abort",b),D.req?q():D.on("request",q)):X&&!re&&(D.on("end",ie),D.on("close",ie)),!I&&typeof D.aborted=="boolean"&&D.on("aborted",b),D.on("end",j),D.on("finish",G),Z.error!==!1&&D.on("error",u),D.on("close",b),d?e.nextTick(b):re!=null&&re.errorEmitted||oe!=null&&oe.errorEmitted?I||e.nextTick(T):(!C&&(!I||v(D))&&(N||Q(D)===!1)||!X&&(!I||Q(D))&&(ne||v(D)===!1)||oe&&D.req&&D.aborted)&&e.nextTick(T);const U=()=>{_=K,D.removeListener("aborted",b),D.removeListener("complete",G),D.removeListener("abort",b),D.removeListener("request",q),D.req&&D.req.removeListener("finish",G),D.removeListener("end",ie),D.removeListener("close",ie),D.removeListener("finish",G),D.removeListener("end",j),D.removeListener("error",u),D.removeListener("close",b)};if(Z.signal&&!d){const y=()=>{const M=_;U(),M.call(D,new t(void 0,{cause:Z.signal.reason}))};if(Z.signal.aborted)e.nextTick(y);else{F=F||nt().addAbortListener;const M=F(Z.signal,y),W=_;_=a((...k)=>{M[O](),W.apply(D,k)})}}return U}function ee(D,Z,_){let $=!1,H=K;if(Z.signal)if(H=()=>{$=!0,_.call(D,new t(void 0,{cause:Z.signal.reason}))},Z.signal.aborted)e.nextTick(H);else{F=F||nt().addAbortListener;const X=F(Z.signal,H),re=_;_=a((...oe)=>{X[O](),re.apply(D,oe)})}const C=(...X)=>{$||e.nextTick(()=>_.apply(D,X))};return S(D[R].promise,C,C),K}function ue(D,Z){var _;let $=!1;return Z===null&&(Z=o),(_=Z)!==null&&_!==void 0&&_.cleanup&&(p(Z.cleanup,"cleanup"),$=Z.cleanup),new g((H,C)=>{const X=J(D,Z,re=>{$&&X(),re?C(re):H()})})}return ni.exports=J,ni.exports.finished=ue,ni.exports}var Po,Bu;function xr(){if(Bu)return Po;Bu=1;const e=st(),{aggregateTwoErrors:t,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:n}=et(),{Symbol:i}=ke(),{kIsDestroyed:o,isDestroyed:a,isFinished:s,isServerRequest:l}=Lt(),c=i("kDestroy"),p=i("kConstruct");function g(L,R,F){L&&(L.stack,R&&!R.errored&&(R.errored=L),F&&!F.errored&&(F.errored=L))}function S(L,R){const F=this._readableState,A=this._writableState,K=A||F;return A!=null&&A.destroyed||F!=null&&F.destroyed?(typeof R=="function"&&R(),this):(g(L,A,F),A&&(A.destroyed=!0),F&&(F.destroyed=!0),K.constructed?O(this,L,R):this.once(c,function(J){O(this,t(J,L),R)}),this)}function O(L,R,F){let A=!1;function K(J){if(A)return;A=!0;const ee=L._readableState,ue=L._writableState;g(J,ue,ee),ue&&(ue.closed=!0),ee&&(ee.closed=!0),typeof F=="function"&&F(J),J?e.nextTick(x,L,J):e.nextTick(v,L)}try{L._destroy(R||null,K)}catch(J){K(J)}}function x(L,R){w(L,R),v(L)}function v(L){const R=L._readableState,F=L._writableState;F&&(F.closeEmitted=!0),R&&(R.closeEmitted=!0),(F!=null&&F.emitClose||R!=null&&R.emitClose)&&L.emit("close")}function w(L,R){const F=L._readableState,A=L._writableState;A!=null&&A.errorEmitted||F!=null&&F.errorEmitted||(A&&(A.errorEmitted=!0),F&&(F.errorEmitted=!0),L.emit("error",R))}function P(){const L=this._readableState,R=this._writableState;L&&(L.constructed=!0,L.closed=!1,L.closeEmitted=!1,L.destroyed=!1,L.errored=null,L.errorEmitted=!1,L.reading=!1,L.ended=L.readable===!1,L.endEmitted=L.readable===!1),R&&(R.constructed=!0,R.destroyed=!1,R.closed=!1,R.closeEmitted=!1,R.errored=null,R.errorEmitted=!1,R.finalCalled=!1,R.prefinished=!1,R.ended=R.writable===!1,R.ending=R.writable===!1,R.finished=R.writable===!1)}function E(L,R,F){const A=L._readableState,K=L._writableState;if(K!=null&&K.destroyed||A!=null&&A.destroyed)return this;A!=null&&A.autoDestroy||K!=null&&K.autoDestroy?L.destroy(R):R&&(R.stack,K&&!K.errored&&(K.errored=R),A&&!A.errored&&(A.errored=R),F?e.nextTick(w,L,R):w(L,R))}function m(L,R){if(typeof L._construct!="function")return;const F=L._readableState,A=L._writableState;F&&(F.constructed=!1),A&&(A.constructed=!1),L.once(p,R),!(L.listenerCount(p)>1)&&e.nextTick(Q,L)}function Q(L){let R=!1;function F(A){if(R){E(L,A??new r);return}R=!0;const K=L._readableState,J=L._writableState,ee=J||K;K&&(K.constructed=!0),J&&(J.constructed=!0),ee.destroyed?L.emit(c,A):A?E(L,A,!0):e.nextTick(V,L)}try{L._construct(A=>{e.nextTick(F,A)})}catch(A){e.nextTick(F,A)}}function V(L){L.emit(p)}function se(L){return L?.setHeader&&typeof L.abort=="function"}function ae(L){L.emit("close")}function Y(L,R){L.emit("error",R),e.nextTick(ae,L)}function ce(L,R){!L||a(L)||(!R&&!s(L)&&(R=new n),l(L)?(L.socket=null,L.destroy(R)):se(L)?L.abort():se(L.req)?L.req.abort():typeof L.destroy=="function"?L.destroy(R):typeof L.close=="function"?L.close():R?e.nextTick(Y,L,R):e.nextTick(ae,L),L.destroyed||(L[o]=!0))}return Po={construct:m,destroyer:ce,destroy:S,undestroy:P,errorOrDestroy:E},Po}var Co,Ku;function Za(){if(Ku)return Co;Ku=1;const{ArrayIsArray:e,ObjectSetPrototypeOf:t}=ke(),{EventEmitter:r}=Pt();function n(o){r.call(this,o)}t(n.prototype,r.prototype),t(n,r),n.prototype.pipe=function(o,a){const s=this;function l(v){o.writable&&o.write(v)===!1&&s.pause&&s.pause()}s.on("data",l);function c(){s.readable&&s.resume&&s.resume()}o.on("drain",c),!o._isStdio&&(!a||a.end!==!1)&&(s.on("end",g),s.on("close",S));let p=!1;function g(){p||(p=!0,o.end())}function S(){p||(p=!0,typeof o.destroy=="function"&&o.destroy())}function O(v){x(),r.listenerCount(this,"error")===0&&this.emit("error",v)}i(s,"error",O),i(o,"error",O);function x(){s.removeListener("data",l),o.removeListener("drain",c),s.removeListener("end",g),s.removeListener("close",S),s.removeListener("error",O),o.removeListener("error",O),s.removeListener("end",x),s.removeListener("close",x),o.removeListener("close",x)}return s.on("end",x),s.on("close",x),o.on("close",x),o.emit("pipe",s),o};function i(o,a,s){if(typeof o.prependListener=="function")return o.prependListener(a,s);!o._events||!o._events[a]?o.on(a,s):e(o._events[a])?o._events[a].unshift(s):o._events[a]=[s,o._events[a]]}return Co={Stream:n,prependListener:i},Co}var Lo={exports:{}},Hu;function Ti(){return Hu||(Hu=1,(function(e){const{SymbolDispose:t}=ke(),{AbortError:r,codes:n}=et(),{isNodeStream:i,isWebStream:o,kControllerErrorFunction:a}=Lt(),s=Kt(),{ERR_INVALID_ARG_TYPE:l}=n;let c;const p=(g,S)=>{if(typeof g!="object"||!("aborted"in g))throw new l(S,"AbortSignal",g)};e.exports.addAbortSignal=function(S,O){if(p(S,"signal"),!i(O)&&!o(O))throw new l("stream",["ReadableStream","WritableStream","Stream"],O);return e.exports.addAbortSignalNoValidate(S,O)},e.exports.addAbortSignalNoValidate=function(g,S){if(typeof g!="object"||!("aborted"in g))return S;const O=i(S)?()=>{S.destroy(new r(void 0,{cause:g.reason}))}:()=>{S[a](new r(void 0,{cause:g.reason}))};if(g.aborted)O();else{c=c||nt().addAbortListener;const x=c(g,O);s(S,x[t])}return S}})(Lo)),Lo.exports}var Do,Gu;function ep(){if(Gu)return Do;Gu=1;const{StringPrototypeSlice:e,SymbolIterator:t,TypedArrayPrototypeSet:r,Uint8Array:n}=ke(),{Buffer:i}=at(),{inspect:o}=nt();return Do=class{constructor(){this.head=null,this.tail=null,this.length=0}push(s){const l={data:s,next:null};this.length>0?this.tail.next=l:this.head=l,this.tail=l,++this.length}unshift(s){const l={data:s,next:this.head};this.length===0&&(this.tail=l),this.head=l,++this.length}shift(){if(this.length===0)return;const s=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,s}clear(){this.head=this.tail=null,this.length=0}join(s){if(this.length===0)return"";let l=this.head,c=""+l.data;for(;(l=l.next)!==null;)c+=s+l.data;return c}concat(s){if(this.length===0)return i.alloc(0);const l=i.allocUnsafe(s>>>0);let c=this.head,p=0;for(;c;)r(l,c.data,p),p+=c.data.length,c=c.next;return l}consume(s,l){const c=this.head.data;if(s<c.length){const p=c.slice(0,s);return this.head.data=c.slice(s),p}return s===c.length?this.shift():l?this._getString(s):this._getBuffer(s)}first(){return this.head.data}*[t](){for(let s=this.head;s;s=s.next)yield s.data}_getString(s){let l="",c=this.head,p=0;do{const g=c.data;if(s>g.length)l+=g,s-=g.length;else{s===g.length?(l+=g,++p,c.next?this.head=c.next:this.head=this.tail=null):(l+=e(g,0,s),this.head=c,c.data=e(g,s));break}++p}while((c=c.next)!==null);return this.length-=p,l}_getBuffer(s){const l=i.allocUnsafe(s),c=s;let p=this.head,g=0;do{const S=p.data;if(s>S.length)r(l,S,c-s),s-=S.length;else{s===S.length?(r(l,S,c-s),++g,p.next?this.head=p.next:this.head=this.tail=null):(r(l,new n(S.buffer,S.byteOffset,s),c-s),this.head=p,p.data=S.slice(s));break}++g}while((p=p.next)!==null);return this.length-=g,l}[Symbol.for("nodejs.util.inspect.custom")](s,l){return o(this,{...l,depth:0,customInspect:!1})}},Do}var ko,Vu;function Oi(){if(Vu)return ko;Vu=1;const{MathFloor:e,NumberIsInteger:t}=ke(),{validateInteger:r}=Fn(),{ERR_INVALID_ARG_VALUE:n}=et().codes;let i=16*1024,o=16;function a(p,g,S){return p.highWaterMark!=null?p.highWaterMark:g?p[S]:null}function s(p){return p?o:i}function l(p,g){r(g,"value",0),p?o=g:i=g}function c(p,g,S,O){const x=a(g,O,S);if(x!=null){if(!t(x)||x<0){const v=O?`options.${S}`:"options.highWaterMark";throw new n(v,x)}return e(x)}return s(p.objectMode)}return ko={getHighWaterMark:c,getDefaultHighWaterMark:s,setDefaultHighWaterMark:l},ko}var xo,Yu;function Gf(){if(Yu)return xo;Yu=1;const e=st(),{PromisePrototypeThen:t,SymbolAsyncIterator:r,SymbolIterator:n}=ke(),{Buffer:i}=at(),{ERR_INVALID_ARG_TYPE:o,ERR_STREAM_NULL_VALUES:a}=et().codes;function s(l,c,p){let g;if(typeof c=="string"||c instanceof i)return new l({objectMode:!0,...p,read(){this.push(c),this.push(null)}});let S;if(c&&c[r])S=!0,g=c[r]();else if(c&&c[n])S=!1,g=c[n]();else throw new o("iterable",["Iterable"],c);const O=new l({objectMode:!0,highWaterMark:1,...p});let x=!1;O._read=function(){x||(x=!0,w())},O._destroy=function(P,E){t(v(P),()=>e.nextTick(E,P),m=>e.nextTick(E,m||P))};async function v(P){const E=P!=null,m=typeof g.throw=="function";if(E&&m){const{value:Q,done:V}=await g.throw(P);if(await Q,V)return}if(typeof g.return=="function"){const{value:Q}=await g.return();await Q}}async function w(){for(;;){try{const{value:P,done:E}=S?await g.next():g.next();if(E)O.push(null);else{const m=P&&typeof P.then=="function"?await P:P;if(m===null)throw x=!1,new a;if(O.push(m))continue;x=!1}}catch(P){O.destroy(P)}break}}return O}return xo=s,xo}var No,Ju;function Mi(){if(Ju)return No;Ju=1;const e=st(),{ArrayPrototypeIndexOf:t,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:o,ObjectKeys:a,ObjectSetPrototypeOf:s,Promise:l,SafeSet:c,SymbolAsyncDispose:p,SymbolAsyncIterator:g,Symbol:S}=ke();No=k,k.ReadableState=W;const{EventEmitter:O}=Pt(),{Stream:x,prependListener:v}=Za(),{Buffer:w}=at(),{addAbortSignal:P}=Ti(),E=Kt();let m=nt().debuglog("stream",f=>{m=f});const Q=ep(),V=xr(),{getHighWaterMark:se,getDefaultHighWaterMark:ae}=Oi(),{aggregateTwoErrors:Y,codes:{ERR_INVALID_ARG_TYPE:ce,ERR_METHOD_NOT_IMPLEMENTED:L,ERR_OUT_OF_RANGE:R,ERR_STREAM_PUSH_AFTER_EOF:F,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:A},AbortError:K}=et(),{validateObject:J}=Fn(),ee=S("kPaused"),{StringDecoder:ue}=gl(),D=Gf();s(k.prototype,x.prototype),s(k,x);const Z=()=>{},{errorOrDestroy:_}=V,$=1,H=2,C=4,X=8,re=16,oe=32,ie=64,I=128,N=256,G=512,ne=1024,j=2048,u=4096,d=8192,b=16384,T=32768,q=65536,U=1<<17,y=1<<18;function M(f){return{enumerable:!1,get(){return(this.state&f)!==0},set(h){h?this.state|=f:this.state&=~f}}}o(W.prototype,{objectMode:M($),ended:M(H),endEmitted:M(C),reading:M(X),constructed:M(re),sync:M(oe),needReadable:M(ie),emittedReadable:M(I),readableListening:M(N),resumeScheduled:M(G),errorEmitted:M(ne),emitClose:M(j),autoDestroy:M(u),destroyed:M(d),closed:M(b),closeEmitted:M(T),multiAwaitDrain:M(q),readingMore:M(U),dataEmitted:M(y)});function W(f,h,z){typeof z!="boolean"&&(z=h instanceof Mt()),this.state=j|u|re|oe,f&&f.objectMode&&(this.state|=$),z&&f&&f.readableObjectMode&&(this.state|=$),this.highWaterMark=f?se(this,f,"readableHighWaterMark",z):ae(!1),this.buffer=new Q,this.length=0,this.pipes=[],this.flowing=null,this[ee]=null,f&&f.emitClose===!1&&(this.state&=~j),f&&f.autoDestroy===!1&&(this.state&=~u),this.errored=null,this.defaultEncoding=f&&f.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,f&&f.encoding&&(this.decoder=new ue(f.encoding),this.encoding=f.encoding)}function k(f){if(!(this instanceof k))return new k(f);const h=this instanceof Mt();this._readableState=new W(f,this,h),f&&(typeof f.read=="function"&&(this._read=f.read),typeof f.destroy=="function"&&(this._destroy=f.destroy),typeof f.construct=="function"&&(this._construct=f.construct),f.signal&&!h&&P(f.signal,this)),x.call(this,f),V.construct(this,()=>{this._readableState.needReadable&&Ae(this,this._readableState)})}k.prototype.destroy=V.destroy,k.prototype._undestroy=V.undestroy,k.prototype._destroy=function(f,h){h(f)},k.prototype[O.captureRejectionSymbol]=function(f){this.destroy(f)},k.prototype[p]=function(){let f;return this.destroyed||(f=this.readableEnded?null:new K,this.destroy(f)),new l((h,z)=>E(this,B=>B&&B!==f?z(B):h(null)))},k.prototype.push=function(f,h){return de(this,f,h,!1)},k.prototype.unshift=function(f,h){return de(this,f,h,!0)};function de(f,h,z,B){m("readableAddChunk",h);const te=f._readableState;let ge;if((te.state&$)===0&&(typeof h=="string"?(z=z||te.defaultEncoding,te.encoding!==z&&(B&&te.encoding?h=w.from(h,z).toString(te.encoding):(h=w.from(h,z),z=""))):h instanceof w?z="":x._isUint8Array(h)?(h=x._uint8ArrayToBuffer(h),z=""):h!=null&&(ge=new ce("chunk",["string","Buffer","Uint8Array"],h))),ge)_(f,ge);else if(h===null)te.state&=~X,Le(f,te);else if((te.state&$)!==0||h&&h.length>0)if(B)if((te.state&C)!==0)_(f,new A);else{if(te.destroyed||te.errored)return!1;me(f,te,h,!0)}else if(te.ended)_(f,new F);else{if(te.destroyed||te.errored)return!1;te.state&=~X,te.decoder&&!z?(h=te.decoder.write(h),te.objectMode||h.length!==0?me(f,te,h,!1):Ae(f,te)):me(f,te,h,!1)}else B||(te.state&=~X,Ae(f,te));return!te.ended&&(te.length<te.highWaterMark||te.length===0)}function me(f,h,z,B){h.flowing&&h.length===0&&!h.sync&&f.listenerCount("data")>0?((h.state&q)!==0?h.awaitDrainWriters.clear():h.awaitDrainWriters=null,h.dataEmitted=!0,f.emit("data",z)):(h.length+=h.objectMode?1:z.length,B?h.buffer.unshift(z):h.buffer.push(z),(h.state&ie)!==0&&Fe(f)),Ae(f,h)}k.prototype.isPaused=function(){const f=this._readableState;return f[ee]===!0||f.flowing===!1},k.prototype.setEncoding=function(f){const h=new ue(f);this._readableState.decoder=h,this._readableState.encoding=this._readableState.decoder.encoding;const z=this._readableState.buffer;let B="";for(const te of z)B+=h.write(te);return z.clear(),B!==""&&z.push(B),this._readableState.length=B.length,this};const he=1073741824;function Se(f){if(f>he)throw new R("size","<= 1GiB",f);return f--,f|=f>>>1,f|=f>>>2,f|=f>>>4,f|=f>>>8,f|=f>>>16,f++,f}function be(f,h){return f<=0||h.length===0&&h.ended?0:(h.state&$)!==0?1:n(f)?h.flowing&&h.length?h.buffer.first().length:h.length:f<=h.length?f:h.ended?h.length:0}k.prototype.read=function(f){m("read",f),f===void 0?f=NaN:r(f)||(f=i(f,10));const h=this._readableState,z=f;if(f>h.highWaterMark&&(h.highWaterMark=Se(f)),f!==0&&(h.state&=~I),f===0&&h.needReadable&&((h.highWaterMark!==0?h.length>=h.highWaterMark:h.length>0)||h.ended))return m("read: emitReadable",h.length,h.ended),h.length===0&&h.ended?Ht(this):Fe(this),null;if(f=be(f,h),f===0&&h.ended)return h.length===0&&Ht(this),null;let B=(h.state&ie)!==0;if(m("need readable",B),(h.length===0||h.length-f<h.highWaterMark)&&(B=!0,m("length less than watermark",B)),h.ended||h.reading||h.destroyed||h.errored||!h.constructed)B=!1,m("reading, ended or constructing",B);else if(B){m("do read"),h.state|=X|oe,h.length===0&&(h.state|=ie);try{this._read(h.highWaterMark)}catch(ge){_(this,ge)}h.state&=~oe,h.reading||(f=be(z,h))}let te;return f>0?te=Ur(f,h):te=null,te===null?(h.needReadable=h.length<=h.highWaterMark,f=0):(h.length-=f,h.multiAwaitDrain?h.awaitDrainWriters.clear():h.awaitDrainWriters=null),h.length===0&&(h.ended||(h.needReadable=!0),z!==f&&h.ended&&Ht(this)),te!==null&&!h.errorEmitted&&!h.closeEmitted&&(h.dataEmitted=!0,this.emit("data",te)),te};function Le(f,h){if(m("onEofChunk"),!h.ended){if(h.decoder){const z=h.decoder.end();z&&z.length&&(h.buffer.push(z),h.length+=h.objectMode?1:z.length)}h.ended=!0,h.sync?Fe(f):(h.needReadable=!1,h.emittedReadable=!0,It(f))}}function Fe(f){const h=f._readableState;m("emitReadable",h.needReadable,h.emittedReadable),h.needReadable=!1,h.emittedReadable||(m("emitReadable",h.flowing),h.emittedReadable=!0,e.nextTick(It,f))}function It(f){const h=f._readableState;m("emitReadable_",h.destroyed,h.length,h.ended),!h.destroyed&&!h.errored&&(h.length||h.ended)&&(f.emit("readable"),h.emittedReadable=!1),h.needReadable=!h.flowing&&!h.ended&&h.length<=h.highWaterMark,$r(f)}function Ae(f,h){!h.readingMore&&h.constructed&&(h.readingMore=!0,e.nextTick(Pi,f,h))}function Pi(f,h){for(;!h.reading&&!h.ended&&(h.length<h.highWaterMark||h.flowing&&h.length===0);){const z=h.length;if(m("maybeReadMore read 0"),f.read(0),z===h.length)break}h.readingMore=!1}k.prototype._read=function(f){throw new L("_read()")},k.prototype.pipe=function(f,h){const z=this,B=this._readableState;B.pipes.length===1&&(B.multiAwaitDrain||(B.multiAwaitDrain=!0,B.awaitDrainWriters=new c(B.awaitDrainWriters?[B.awaitDrainWriters]:[]))),B.pipes.push(f),m("pipe count=%d opts=%j",B.pipes.length,h);const ge=(!h||h.end!==!1)&&f!==e.stdout&&f!==e.stderr?Fr:gt;B.endEmitted?e.nextTick(ge):z.once("end",ge),f.on("unpipe",Oe);function Oe(Ve,Ne){m("onunpipe"),Ve===z&&Ne&&Ne.hasUnpiped===!1&&(Ne.hasUnpiped=!0,qi())}function Fr(){m("onend"),f.end()}let Ge,Wr=!1;function qi(){m("cleanup"),f.removeListener("close",Yt),f.removeListener("finish",Jt),Ge&&f.removeListener("drain",Ge),f.removeListener("error",Vt),f.removeListener("unpipe",Oe),z.removeListener("end",Fr),z.removeListener("end",gt),z.removeListener("data",Br),Wr=!0,Ge&&B.awaitDrainWriters&&(!f._writableState||f._writableState.needDrain)&&Ge()}function zr(){Wr||(B.pipes.length===1&&B.pipes[0]===f?(m("false write response, pause",0),B.awaitDrainWriters=f,B.multiAwaitDrain=!1):B.pipes.length>1&&B.pipes.includes(f)&&(m("false write response, pause",B.awaitDrainWriters.size),B.awaitDrainWriters.add(f)),z.pause()),Ge||(Ge=Ci(z,f),f.on("drain",Ge))}z.on("data",Br);function Br(Ve){m("ondata");const Ne=f.write(Ve);m("dest.write",Ne),Ne===!1&&zr()}function Vt(Ve){if(m("onerror",Ve),gt(),f.removeListener("error",Vt),f.listenerCount("error")===0){const Ne=f._writableState||f._readableState;Ne&&!Ne.errorEmitted?_(f,Ve):f.emit("error",Ve)}}v(f,"error",Vt);function Yt(){f.removeListener("finish",Jt),gt()}f.once("close",Yt);function Jt(){m("onfinish"),f.removeListener("close",Yt),gt()}f.once("finish",Jt);function gt(){m("unpipe"),z.unpipe(f)}return f.emit("pipe",z),f.writableNeedDrain===!0?zr():B.flowing||(m("pipe resume"),z.resume()),f};function Ci(f,h){return function(){const B=f._readableState;B.awaitDrainWriters===h?(m("pipeOnDrain",1),B.awaitDrainWriters=null):B.multiAwaitDrain&&(m("pipeOnDrain",B.awaitDrainWriters.size),B.awaitDrainWriters.delete(h)),(!B.awaitDrainWriters||B.awaitDrainWriters.size===0)&&f.listenerCount("data")&&f.resume()}}k.prototype.unpipe=function(f){const h=this._readableState,z={hasUnpiped:!1};if(h.pipes.length===0)return this;if(!f){const te=h.pipes;h.pipes=[],this.pause();for(let ge=0;ge<te.length;ge++)te[ge].emit("unpipe",this,{hasUnpiped:!1});return this}const B=t(h.pipes,f);return B===-1?this:(h.pipes.splice(B,1),h.pipes.length===0&&this.pause(),f.emit("unpipe",this,z),this)},k.prototype.on=function(f,h){const z=x.prototype.on.call(this,f,h),B=this._readableState;return f==="data"?(B.readableListening=this.listenerCount("readable")>0,B.flowing!==!1&&this.resume()):f==="readable"&&!B.endEmitted&&!B.readableListening&&(B.readableListening=B.needReadable=!0,B.flowing=!1,B.emittedReadable=!1,m("on readable",B.length,B.reading),B.length?Fe(this):B.reading||e.nextTick(Li,this)),z},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(f,h){const z=x.prototype.removeListener.call(this,f,h);return f==="readable"&&e.nextTick(Nr,this),z},k.prototype.off=k.prototype.removeListener,k.prototype.removeAllListeners=function(f){const h=x.prototype.removeAllListeners.apply(this,arguments);return(f==="readable"||f===void 0)&&e.nextTick(Nr,this),h};function Nr(f){const h=f._readableState;h.readableListening=f.listenerCount("readable")>0,h.resumeScheduled&&h[ee]===!1?h.flowing=!0:f.listenerCount("data")>0?f.resume():h.readableListening||(h.flowing=null)}function Li(f){m("readable nexttick read 0"),f.read(0)}k.prototype.resume=function(){const f=this._readableState;return f.flowing||(m("resume"),f.flowing=!f.readableListening,Di(this,f)),f[ee]=!1,this};function Di(f,h){h.resumeScheduled||(h.resumeScheduled=!0,e.nextTick(ki,f,h))}function ki(f,h){m("resume",h.reading),h.reading||f.read(0),h.resumeScheduled=!1,f.emit("resume"),$r(f),h.flowing&&!h.reading&&f.read(0)}k.prototype.pause=function(){return m("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(m("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[ee]=!0,this};function $r(f){const h=f._readableState;for(m("flow",h.flowing);h.flowing&&f.read()!==null;);}k.prototype.wrap=function(f){let h=!1;f.on("data",B=>{!this.push(B)&&f.pause&&(h=!0,f.pause())}),f.on("end",()=>{this.push(null)}),f.on("error",B=>{_(this,B)}),f.on("close",()=>{this.destroy()}),f.on("destroy",()=>{this.destroy()}),this._read=()=>{h&&f.resume&&(h=!1,f.resume())};const z=a(f);for(let B=1;B<z.length;B++){const te=z[B];this[te]===void 0&&typeof f[te]=="function"&&(this[te]=f[te].bind(f))}return this},k.prototype[g]=function(){return qr(this)},k.prototype.iterator=function(f){return f!==void 0&&J(f,"options"),qr(this,f)};function qr(f,h){typeof f.read!="function"&&(f=k.wrap(f,{objectMode:!0}));const z=xi(f,h);return z.stream=f,z}async function*xi(f,h){let z=Z;function B(Oe){this===f?(z(),z=Z):z=Oe}f.on("readable",B);let te;const ge=E(f,{writable:!1},Oe=>{te=Oe?Y(te,Oe):null,z(),z=Z});try{for(;;){const Oe=f.destroyed?null:f.read();if(Oe!==null)yield Oe;else{if(te)throw te;if(te===null)return;await new l(B)}}}catch(Oe){throw te=Y(te,Oe),te}finally{(te||h?.destroyOnReturn!==!1)&&(te===void 0||f._readableState.autoDestroy)?V.destroyer(f,null):(f.off("readable",B),ge())}}o(k.prototype,{readable:{__proto__:null,get(){const f=this._readableState;return!!f&&f.readable!==!1&&!f.destroyed&&!f.errorEmitted&&!f.endEmitted},set(f){this._readableState&&(this._readableState.readable=!!f)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(f){this._readableState&&(this._readableState.flowing=f)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(f){this._readableState&&(this._readableState.destroyed=f)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),o(W.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[ee]!==!1},set(f){this[ee]=!!f}}}),k._fromList=Ur;function Ur(f,h){if(h.length===0)return null;let z;return h.objectMode?z=h.buffer.shift():!f||f>=h.length?(h.decoder?z=h.buffer.join(""):h.buffer.length===1?z=h.buffer.first():z=h.buffer.concat(h.length),h.buffer.clear()):z=h.buffer.consume(f,h.decoder),z}function Ht(f){const h=f._readableState;m("endReadable",h.endEmitted),h.endEmitted||(h.ended=!0,e.nextTick(Ni,h,f))}function Ni(f,h){if(m("endReadableNT",f.endEmitted,f.length),!f.errored&&!f.closeEmitted&&!f.endEmitted&&f.length===0){if(f.endEmitted=!0,h.emit("end"),h.writable&&h.allowHalfOpen===!1)e.nextTick($i,h);else if(f.autoDestroy){const z=h._writableState;(!z||z.autoDestroy&&(z.finished||z.writable===!1))&&h.destroy()}}}function $i(f){f.writable&&!f.writableEnded&&!f.destroyed&&f.end()}k.from=function(f,h){return D(k,f,h)};let Gt;function jr(){return Gt===void 0&&(Gt={}),Gt}return k.fromWeb=function(f,h){return jr().newStreamReadableFromReadableStream(f,h)},k.toWeb=function(f,h){return jr().newReadableStreamFromStreamReadable(f,h)},k.wrap=function(f,h){var z,B;return new k({objectMode:(z=(B=f.readableObjectMode)!==null&&B!==void 0?B:f.objectMode)!==null&&z!==void 0?z:!0,...h,destroy(te,ge){V.destroyer(f,te),ge(te)}}).wrap(f)},No}var $o,Qu;function es(){if(Qu)return $o;Qu=1;const e=st(),{ArrayPrototypeSlice:t,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:o,ObjectSetPrototypeOf:a,StringPrototypeToLowerCase:s,Symbol:l,SymbolHasInstance:c}=ke();$o=J,J.WritableState=A;const{EventEmitter:p}=Pt(),g=Za().Stream,{Buffer:S}=at(),O=xr(),{addAbortSignal:x}=Ti(),{getHighWaterMark:v,getDefaultHighWaterMark:w}=Oi(),{ERR_INVALID_ARG_TYPE:P,ERR_METHOD_NOT_IMPLEMENTED:E,ERR_MULTIPLE_CALLBACK:m,ERR_STREAM_CANNOT_PIPE:Q,ERR_STREAM_DESTROYED:V,ERR_STREAM_ALREADY_FINISHED:se,ERR_STREAM_NULL_VALUES:ae,ERR_STREAM_WRITE_AFTER_END:Y,ERR_UNKNOWN_ENCODING:ce}=et().codes,{errorOrDestroy:L}=O;a(J.prototype,g.prototype),a(J,g);function R(){}const F=l("kOnFinished");function A(u,d,b){typeof b!="boolean"&&(b=d instanceof Mt()),this.objectMode=!!(u&&u.objectMode),b&&(this.objectMode=this.objectMode||!!(u&&u.writableObjectMode)),this.highWaterMark=u?v(this,u,"writableHighWaterMark",b):w(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const T=!!(u&&u.decodeStrings===!1);this.decodeStrings=!T,this.defaultEncoding=u&&u.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=_.bind(void 0,d),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,K(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!u||u.emitClose!==!1,this.autoDestroy=!u||u.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[F]=[]}function K(u){u.buffered=[],u.bufferedIndex=0,u.allBuffers=!0,u.allNoop=!0}A.prototype.getBuffer=function(){return t(this.buffered,this.bufferedIndex)},i(A.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function J(u){const d=this instanceof Mt();if(!d&&!n(J,this))return new J(u);this._writableState=new A(u,this,d),u&&(typeof u.write=="function"&&(this._write=u.write),typeof u.writev=="function"&&(this._writev=u.writev),typeof u.destroy=="function"&&(this._destroy=u.destroy),typeof u.final=="function"&&(this._final=u.final),typeof u.construct=="function"&&(this._construct=u.construct),u.signal&&x(u.signal,this)),g.call(this,u),O.construct(this,()=>{const b=this._writableState;b.writing||X(this,b),I(this,b)})}i(J,c,{__proto__:null,value:function(u){return n(this,u)?!0:this!==J?!1:u&&u._writableState instanceof A}}),J.prototype.pipe=function(){L(this,new Q)};function ee(u,d,b,T){const q=u._writableState;if(typeof b=="function")T=b,b=q.defaultEncoding;else{if(!b)b=q.defaultEncoding;else if(b!=="buffer"&&!S.isEncoding(b))throw new ce(b);typeof T!="function"&&(T=R)}if(d===null)throw new ae;if(!q.objectMode)if(typeof d=="string")q.decodeStrings!==!1&&(d=S.from(d,b),b="buffer");else if(d instanceof S)b="buffer";else if(g._isUint8Array(d))d=g._uint8ArrayToBuffer(d),b="buffer";else throw new P("chunk",["string","Buffer","Uint8Array"],d);let U;return q.ending?U=new Y:q.destroyed&&(U=new V("write")),U?(e.nextTick(T,U),L(u,U,!0),U):(q.pendingcb++,ue(u,q,d,b,T))}J.prototype.write=function(u,d,b){return ee(this,u,d,b)===!0},J.prototype.cork=function(){this._writableState.corked++},J.prototype.uncork=function(){const u=this._writableState;u.corked&&(u.corked--,u.writing||X(this,u))},J.prototype.setDefaultEncoding=function(d){if(typeof d=="string"&&(d=s(d)),!S.isEncoding(d))throw new ce(d);return this._writableState.defaultEncoding=d,this};function ue(u,d,b,T,q){const U=d.objectMode?1:b.length;d.length+=U;const y=d.length<d.highWaterMark;return y||(d.needDrain=!0),d.writing||d.corked||d.errored||!d.constructed?(d.buffered.push({chunk:b,encoding:T,callback:q}),d.allBuffers&&T!=="buffer"&&(d.allBuffers=!1),d.allNoop&&q!==R&&(d.allNoop=!1)):(d.writelen=U,d.writecb=q,d.writing=!0,d.sync=!0,u._write(b,T,d.onwrite),d.sync=!1),y&&!d.errored&&!d.destroyed}function D(u,d,b,T,q,U,y){d.writelen=T,d.writecb=y,d.writing=!0,d.sync=!0,d.destroyed?d.onwrite(new V("write")):b?u._writev(q,d.onwrite):u._write(q,U,d.onwrite),d.sync=!1}function Z(u,d,b,T){--d.pendingcb,T(b),C(d),L(u,b)}function _(u,d){const b=u._writableState,T=b.sync,q=b.writecb;if(typeof q!="function"){L(u,new m);return}b.writing=!1,b.writecb=null,b.length-=b.writelen,b.writelen=0,d?(d.stack,b.errored||(b.errored=d),u._readableState&&!u._readableState.errored&&(u._readableState.errored=d),T?e.nextTick(Z,u,b,d,q):Z(u,b,d,q)):(b.buffered.length>b.bufferedIndex&&X(u,b),T?b.afterWriteTickInfo!==null&&b.afterWriteTickInfo.cb===q?b.afterWriteTickInfo.count++:(b.afterWriteTickInfo={count:1,cb:q,stream:u,state:b},e.nextTick($,b.afterWriteTickInfo)):H(u,b,1,q))}function $({stream:u,state:d,count:b,cb:T}){return d.afterWriteTickInfo=null,H(u,d,b,T)}function H(u,d,b,T){for(!d.ending&&!u.destroyed&&d.length===0&&d.needDrain&&(d.needDrain=!1,u.emit("drain"));b-- >0;)d.pendingcb--,T();d.destroyed&&C(d),I(u,d)}function C(u){if(u.writing)return;for(let q=u.bufferedIndex;q<u.buffered.length;++q){var d;const{chunk:U,callback:y}=u.buffered[q],M=u.objectMode?1:U.length;u.length-=M,y((d=u.errored)!==null&&d!==void 0?d:new V("write"))}const b=u[F].splice(0);for(let q=0;q<b.length;q++){var T;b[q]((T=u.errored)!==null&&T!==void 0?T:new V("end"))}K(u)}function X(u,d){if(d.corked||d.bufferProcessing||d.destroyed||!d.constructed)return;const{buffered:b,bufferedIndex:T,objectMode:q}=d,U=b.length-T;if(!U)return;let y=T;if(d.bufferProcessing=!0,U>1&&u._writev){d.pendingcb-=U-1;const M=d.allNoop?R:k=>{for(let de=y;de<b.length;++de)b[de].callback(k)},W=d.allNoop&&y===0?b:t(b,y);W.allBuffers=d.allBuffers,D(u,d,!0,d.length,W,"",M),K(d)}else{do{const{chunk:M,encoding:W,callback:k}=b[y];b[y++]=null;const de=q?1:M.length;D(u,d,!1,de,M,W,k)}while(y<b.length&&!d.writing);y===b.length?K(d):y>256?(b.splice(0,y),d.bufferedIndex=0):d.bufferedIndex=y}d.bufferProcessing=!1}J.prototype._write=function(u,d,b){if(this._writev)this._writev([{chunk:u,encoding:d}],b);else throw new E("_write()")},J.prototype._writev=null,J.prototype.end=function(u,d,b){const T=this._writableState;typeof u=="function"?(b=u,u=null,d=null):typeof d=="function"&&(b=d,d=null);let q;if(u!=null){const U=ee(this,u,d);U instanceof r&&(q=U)}return T.corked&&(T.corked=1,this.uncork()),q||(!T.errored&&!T.ending?(T.ending=!0,I(this,T,!0),T.ended=!0):T.finished?q=new se("end"):T.destroyed&&(q=new V("end"))),typeof b=="function"&&(q||T.finished?e.nextTick(b,q):T[F].push(b)),this};function re(u){return u.ending&&!u.destroyed&&u.constructed&&u.length===0&&!u.errored&&u.buffered.length===0&&!u.finished&&!u.writing&&!u.errorEmitted&&!u.closeEmitted}function oe(u,d){let b=!1;function T(q){if(b){L(u,q??m());return}if(b=!0,d.pendingcb--,q){const U=d[F].splice(0);for(let y=0;y<U.length;y++)U[y](q);L(u,q,d.sync)}else re(d)&&(d.prefinished=!0,u.emit("prefinish"),d.pendingcb++,e.nextTick(N,u,d))}d.sync=!0,d.pendingcb++;try{u._final(T)}catch(q){T(q)}d.sync=!1}function ie(u,d){!d.prefinished&&!d.finalCalled&&(typeof u._final=="function"&&!d.destroyed?(d.finalCalled=!0,oe(u,d)):(d.prefinished=!0,u.emit("prefinish")))}function I(u,d,b){re(d)&&(ie(u,d),d.pendingcb===0&&(b?(d.pendingcb++,e.nextTick((T,q)=>{re(q)?N(T,q):q.pendingcb--},u,d)):re(d)&&(d.pendingcb++,N(u,d))))}function N(u,d){d.pendingcb--,d.finished=!0;const b=d[F].splice(0);for(let T=0;T<b.length;T++)b[T]();if(u.emit("finish"),d.autoDestroy){const T=u._readableState;(!T||T.autoDestroy&&(T.endEmitted||T.readable===!1))&&u.destroy()}}o(J.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(u){this._writableState&&(this._writableState.destroyed=u)}},writable:{__proto__:null,get(){const u=this._writableState;return!!u&&u.writable!==!1&&!u.destroyed&&!u.errored&&!u.ending&&!u.ended},set(u){this._writableState&&(this._writableState.writable=!!u)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){const u=this._writableState;return u?!u.destroyed&&!u.ending&&u.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});const G=O.destroy;J.prototype.destroy=function(u,d){const b=this._writableState;return!b.destroyed&&(b.bufferedIndex<b.buffered.length||b[F].length)&&e.nextTick(C,b),G.call(this,u,d),this},J.prototype._undestroy=O.undestroy,J.prototype._destroy=function(u,d){d(u)},J.prototype[p.captureRejectionSymbol]=function(u){this.destroy(u)};let ne;function j(){return ne===void 0&&(ne={}),ne}return J.fromWeb=function(u,d){return j().newStreamWritableFromWritableStream(u,d)},J.toWeb=function(u){return j().newWritableStreamFromStreamWritable(u)},$o}var qo,Xu;function tp(){if(Xu)return qo;Xu=1;const e=st(),t=at(),{isReadable:r,isWritable:n,isIterable:i,isNodeStream:o,isReadableNodeStream:a,isWritableNodeStream:s,isDuplexNodeStream:l,isReadableStream:c,isWritableStream:p}=Lt(),g=Kt(),{AbortError:S,codes:{ERR_INVALID_ARG_TYPE:O,ERR_INVALID_RETURN_VALUE:x}}=et(),{destroyer:v}=xr(),w=Mt(),P=Mi(),E=es(),{createDeferredPromise:m}=nt(),Q=Gf(),V=globalThis.Blob||t.Blob,se=typeof V<"u"?function(A){return A instanceof V}:function(A){return!1},ae=globalThis.AbortController||Et().AbortController,{FunctionPrototypeCall:Y}=ke();class ce extends w{constructor(A){super(A),A?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),A?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}qo=function F(A,K){if(l(A))return A;if(a(A))return R({readable:A});if(s(A))return R({writable:A});if(o(A))return R({writable:!1,readable:!1});if(c(A))return R({readable:P.fromWeb(A)});if(p(A))return R({writable:E.fromWeb(A)});if(typeof A=="function"){const{value:ee,write:ue,final:D,destroy:Z}=L(A);if(i(ee))return Q(ce,ee,{objectMode:!0,write:ue,final:D,destroy:Z});const _=ee?.then;if(typeof _=="function"){let $;const H=Y(_,ee,C=>{if(C!=null)throw new x("nully","body",C)},C=>{v($,C)});return $=new ce({objectMode:!0,readable:!1,write:ue,final(C){D(async()=>{try{await H,e.nextTick(C,null)}catch(X){e.nextTick(C,X)}})},destroy:Z})}throw new x("Iterable, AsyncIterable or AsyncFunction",K,ee)}if(se(A))return F(A.arrayBuffer());if(i(A))return Q(ce,A,{objectMode:!0,writable:!1});if(c(A?.readable)&&p(A?.writable))return ce.fromWeb(A);if(typeof A?.writable=="object"||typeof A?.readable=="object"){const ee=A!=null&&A.readable?a(A?.readable)?A?.readable:F(A.readable):void 0,ue=A!=null&&A.writable?s(A?.writable)?A?.writable:F(A.writable):void 0;return R({readable:ee,writable:ue})}const J=A?.then;if(typeof J=="function"){let ee;return Y(J,A,ue=>{ue!=null&&ee.push(ue),ee.push(null)},ue=>{v(ee,ue)}),ee=new ce({objectMode:!0,writable:!1,read(){}})}throw new O(K,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],A)};function L(F){let{promise:A,resolve:K}=m();const J=new ae,ee=J.signal;return{value:F((async function*(){for(;;){const D=A;A=null;const{chunk:Z,done:_,cb:$}=await D;if(e.nextTick($),_)return;if(ee.aborted)throw new S(void 0,{cause:ee.reason});({promise:A,resolve:K}=m()),yield Z}})(),{signal:ee}),write(D,Z,_){const $=K;K=null,$({chunk:D,done:!1,cb:_})},final(D){const Z=K;K=null,Z({done:!0,cb:D})},destroy(D,Z){J.abort(),Z(D)}}}function R(F){const A=F.readable&&typeof F.readable.read!="function"?P.wrap(F.readable):F.readable,K=F.writable;let J=!!r(A),ee=!!n(K),ue,D,Z,_,$;function H(C){const X=_;_=null,X?X(C):C&&$.destroy(C)}return $=new ce({readableObjectMode:!!(A!=null&&A.readableObjectMode),writableObjectMode:!!(K!=null&&K.writableObjectMode),readable:J,writable:ee}),ee&&(g(K,C=>{ee=!1,C&&v(A,C),H(C)}),$._write=function(C,X,re){K.write(C,X)?re():ue=re},$._final=function(C){K.end(),D=C},K.on("drain",function(){if(ue){const C=ue;ue=null,C()}}),K.on("finish",function(){if(D){const C=D;D=null,C()}})),J&&(g(A,C=>{J=!1,C&&v(A,C),H(C)}),A.on("readable",function(){if(Z){const C=Z;Z=null,C()}}),A.on("end",function(){$.push(null)}),$._read=function(){for(;;){const C=A.read();if(C===null){Z=$._read;return}if(!$.push(C))return}}),$._destroy=function(C,X){!C&&_!==null&&(C=new S),Z=null,ue=null,D=null,_===null?X(C):(_=X,v(K,C),v(A,C))},$}return qo}var Uo,Zu;function Mt(){if(Zu)return Uo;Zu=1;const{ObjectDefineProperties:e,ObjectGetOwnPropertyDescriptor:t,ObjectKeys:r,ObjectSetPrototypeOf:n}=ke();Uo=a;const i=Mi(),o=es();n(a.prototype,i.prototype),n(a,i);{const p=r(o.prototype);for(let g=0;g<p.length;g++){const S=p[g];a.prototype[S]||(a.prototype[S]=o.prototype[S])}}function a(p){if(!(this instanceof a))return new a(p);i.call(this,p),o.call(this,p),p?(this.allowHalfOpen=p.allowHalfOpen!==!1,p.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),p.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}e(a.prototype,{writable:{__proto__:null,...t(o.prototype,"writable")},writableHighWaterMark:{__proto__:null,...t(o.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...t(o.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...t(o.prototype,"writableBuffer")},writableLength:{__proto__:null,...t(o.prototype,"writableLength")},writableFinished:{__proto__:null,...t(o.prototype,"writableFinished")},writableCorked:{__proto__:null,...t(o.prototype,"writableCorked")},writableEnded:{__proto__:null,...t(o.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...t(o.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(p){this._readableState&&this._writableState&&(this._readableState.destroyed=p,this._writableState.destroyed=p)}}});let s;function l(){return s===void 0&&(s={}),s}a.fromWeb=function(p,g){return l().newStreamDuplexFromReadableWritablePair(p,g)},a.toWeb=function(p){return l().newReadableWritablePairFromDuplex(p)};let c;return a.from=function(p){return c||(c=tp()),c(p,"body")},Uo}var jo,el;function Vf(){if(el)return jo;el=1;const{ObjectSetPrototypeOf:e,Symbol:t}=ke();jo=a;const{ERR_METHOD_NOT_IMPLEMENTED:r}=et().codes,n=Mt(),{getHighWaterMark:i}=Oi();e(a.prototype,n.prototype),e(a,n);const o=t("kCallback");function a(c){if(!(this instanceof a))return new a(c);const p=c?i(this,c,"readableHighWaterMark",!0):null;p===0&&(c={...c,highWaterMark:null,readableHighWaterMark:p,writableHighWaterMark:c.writableHighWaterMark||0}),n.call(this,c),this._readableState.sync=!1,this[o]=null,c&&(typeof c.transform=="function"&&(this._transform=c.transform),typeof c.flush=="function"&&(this._flush=c.flush)),this.on("prefinish",l)}function s(c){typeof this._flush=="function"&&!this.destroyed?this._flush((p,g)=>{if(p){c?c(p):this.destroy(p);return}g!=null&&this.push(g),this.push(null),c&&c()}):(this.push(null),c&&c())}function l(){this._final!==s&&s.call(this)}return a.prototype._final=s,a.prototype._transform=function(c,p,g){throw new r("_transform()")},a.prototype._write=function(c,p,g){const S=this._readableState,O=this._writableState,x=S.length;this._transform(c,p,(v,w)=>{if(v){g(v);return}w!=null&&this.push(w),O.ended||x===S.length||S.length<S.highWaterMark?g():this[o]=g})},a.prototype._read=function(){if(this[o]){const c=this[o];this[o]=null,c()}},jo}var Fo,tl;function Yf(){if(tl)return Fo;tl=1;const{ObjectSetPrototypeOf:e}=ke();Fo=r;const t=Vf();e(r.prototype,t.prototype),e(r,t);function r(n){if(!(this instanceof r))return new r(n);t.call(this,n)}return r.prototype._transform=function(n,i,o){o(null,n)},Fo}var Wo,rl;function ts(){if(rl)return Wo;rl=1;const e=st(),{ArrayIsArray:t,Promise:r,SymbolAsyncIterator:n,SymbolDispose:i}=ke(),o=Kt(),{once:a}=nt(),s=xr(),l=Mt(),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:g,ERR_MISSING_ARGS:S,ERR_STREAM_DESTROYED:O,ERR_STREAM_PREMATURE_CLOSE:x},AbortError:v}=et(),{validateFunction:w,validateAbortSignal:P}=Fn(),{isIterable:E,isReadable:m,isReadableNodeStream:Q,isNodeStream:V,isTransformStream:se,isWebStream:ae,isReadableStream:Y,isReadableFinished:ce}=Lt(),L=globalThis.AbortController||Et().AbortController;let R,F,A;function K(C,X,re){let oe=!1;C.on("close",()=>{oe=!0});const ie=o(C,{readable:X,writable:re},I=>{oe=!I});return{destroy:I=>{oe||(oe=!0,s.destroyer(C,I||new O("pipe")))},cleanup:ie}}function J(C){return w(C[C.length-1],"streams[stream.length - 1]"),C.pop()}function ee(C){if(E(C))return C;if(Q(C))return ue(C);throw new p("val",["Readable","Iterable","AsyncIterable"],C)}async function*ue(C){F||(F=Mi()),yield*F.prototype[n].call(C)}async function D(C,X,re,{end:oe}){let ie,I=null;const N=j=>{if(j&&(ie=j),I){const u=I;I=null,u()}},G=()=>new r((j,u)=>{ie?u(ie):I=()=>{ie?u(ie):j()}});X.on("drain",N);const ne=o(X,{readable:!1},N);try{X.writableNeedDrain&&await G();for await(const j of C)X.write(j)||await G();oe&&(X.end(),await G()),re()}catch(j){re(ie!==j?c(ie,j):j)}finally{ne(),X.off("drain",N)}}async function Z(C,X,re,{end:oe}){se(X)&&(X=X.writable);const ie=X.getWriter();try{for await(const I of C)await ie.ready,ie.write(I).catch(()=>{});await ie.ready,oe&&await ie.close(),re()}catch(I){try{await ie.abort(I),re(I)}catch(N){re(N)}}}function _(...C){return $(C,a(J(C)))}function $(C,X,re){if(C.length===1&&t(C[0])&&(C=C[0]),C.length<2)throw new S("streams");const oe=new L,ie=oe.signal,I=re?.signal,N=[];P(I,"options.signal");function G(){q(new v)}A=A||nt().addAbortListener;let ne;I&&(ne=A(I,G));let j,u;const d=[];let b=0;function T(W){q(W,--b===0)}function q(W,k){var de;if(W&&(!j||j.code==="ERR_STREAM_PREMATURE_CLOSE")&&(j=W),!(!j&&!k)){for(;d.length;)d.shift()(j);(de=ne)===null||de===void 0||de[i](),oe.abort(),k&&(j||N.forEach(me=>me()),e.nextTick(X,j,u))}}let U;for(let W=0;W<C.length;W++){const k=C[W],de=W<C.length-1,me=W>0,he=de||re?.end!==!1,Se=W===C.length-1;if(V(k)){let be=function(Le){Le&&Le.name!=="AbortError"&&Le.code!=="ERR_STREAM_PREMATURE_CLOSE"&&T(Le)};if(he){const{destroy:Le,cleanup:Fe}=K(k,de,me);d.push(Le),m(k)&&Se&&N.push(Fe)}k.on("error",be),m(k)&&Se&&N.push(()=>{k.removeListener("error",be)})}if(W===0)if(typeof k=="function"){if(U=k({signal:ie}),!E(U))throw new g("Iterable, AsyncIterable or Stream","source",U)}else E(k)||Q(k)||se(k)?U=k:U=l.from(k);else if(typeof k=="function"){if(se(U)){var y;U=ee((y=U)===null||y===void 0?void 0:y.readable)}else U=ee(U);if(U=k(U,{signal:ie}),de){if(!E(U,!0))throw new g("AsyncIterable",`transform[${W-1}]`,U)}else{var M;R||(R=Yf());const be=new R({objectMode:!0}),Le=(M=U)===null||M===void 0?void 0:M.then;if(typeof Le=="function")b++,Le.call(U,Ae=>{u=Ae,Ae!=null&&be.write(Ae),he&&be.end(),e.nextTick(T)},Ae=>{be.destroy(Ae),e.nextTick(T,Ae)});else if(E(U,!0))b++,D(U,be,T,{end:he});else if(Y(U)||se(U)){const Ae=U.readable||U;b++,D(Ae,be,T,{end:he})}else throw new g("AsyncIterable or Promise","destination",U);U=be;const{destroy:Fe,cleanup:It}=K(U,!1,!0);d.push(Fe),Se&&N.push(It)}}else if(V(k)){if(Q(U)){b+=2;const be=H(U,k,T,{end:he});m(k)&&Se&&N.push(be)}else if(se(U)||Y(U)){const be=U.readable||U;b++,D(be,k,T,{end:he})}else if(E(U))b++,D(U,k,T,{end:he});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],U);U=k}else if(ae(k)){if(Q(U))b++,Z(ee(U),k,T,{end:he});else if(Y(U)||E(U))b++,Z(U,k,T,{end:he});else if(se(U))b++,Z(U.readable,k,T,{end:he});else throw new p("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],U);U=k}else U=l.from(k)}return(ie!=null&&ie.aborted||I!=null&&I.aborted)&&e.nextTick(G),U}function H(C,X,re,{end:oe}){let ie=!1;if(X.on("close",()=>{ie||re(new x)}),C.pipe(X,{end:!1}),oe){let I=function(){ie=!0,X.end()};ce(C)?e.nextTick(I):C.once("end",I)}else re();return o(C,{readable:!0,writable:!1},I=>{const N=C._readableState;I&&I.code==="ERR_STREAM_PREMATURE_CLOSE"&&N&&N.ended&&!N.errored&&!N.errorEmitted?C.once("end",re).once("error",re):re(I)}),o(X,{readable:!1,writable:!0},re)}return Wo={pipelineImpl:$,pipeline:_},Wo}var zo,nl;function Jf(){if(nl)return zo;nl=1;const{pipeline:e}=ts(),t=Mt(),{destroyer:r}=xr(),{isNodeStream:n,isReadable:i,isWritable:o,isWebStream:a,isTransformStream:s,isWritableStream:l,isReadableStream:c}=Lt(),{AbortError:p,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:S}}=et(),O=Kt();return zo=function(...v){if(v.length===0)throw new S("streams");if(v.length===1)return t.from(v[0]);const w=[...v];if(typeof v[0]=="function"&&(v[0]=t.from(v[0])),typeof v[v.length-1]=="function"){const R=v.length-1;v[R]=t.from(v[R])}for(let R=0;R<v.length;++R)if(!(!n(v[R])&&!a(v[R]))){if(R<v.length-1&&!(i(v[R])||c(v[R])||s(v[R])))throw new g(`streams[${R}]`,w[R],"must be readable");if(R>0&&!(o(v[R])||l(v[R])||s(v[R])))throw new g(`streams[${R}]`,w[R],"must be writable")}let P,E,m,Q,V;function se(R){const F=Q;Q=null,F?F(R):R?V.destroy(R):!L&&!ce&&V.destroy()}const ae=v[0],Y=e(v,se),ce=!!(o(ae)||l(ae)||s(ae)),L=!!(i(Y)||c(Y)||s(Y));if(V=new t({writableObjectMode:!!(ae!=null&&ae.writableObjectMode),readableObjectMode:!!(Y!=null&&Y.readableObjectMode),writable:ce,readable:L}),ce){if(n(ae))V._write=function(F,A,K){ae.write(F,A)?K():P=K},V._final=function(F){ae.end(),E=F},ae.on("drain",function(){if(P){const F=P;P=null,F()}});else if(a(ae)){const A=(s(ae)?ae.writable:ae).getWriter();V._write=async function(K,J,ee){try{await A.ready,A.write(K).catch(()=>{}),ee()}catch(ue){ee(ue)}},V._final=async function(K){try{await A.ready,A.close().catch(()=>{}),E=K}catch(J){K(J)}}}const R=s(Y)?Y.readable:Y;O(R,()=>{if(E){const F=E;E=null,F()}})}if(L){if(n(Y))Y.on("readable",function(){if(m){const R=m;m=null,R()}}),Y.on("end",function(){V.push(null)}),V._read=function(){for(;;){const R=Y.read();if(R===null){m=V._read;return}if(!V.push(R))return}};else if(a(Y)){const F=(s(Y)?Y.readable:Y).getReader();V._read=async function(){for(;;)try{const{value:A,done:K}=await F.read();if(!V.push(A))return;if(K){V.push(null);return}}catch{return}}}}return V._destroy=function(R,F){!R&&Q!==null&&(R=new p),m=null,P=null,E=null,Q===null?F(R):(Q=F,n(Y)&&r(Y,R))},V},zo}var il;function rp(){if(il)return ri;il=1;const e=globalThis.AbortController||Et().AbortController,{codes:{ERR_INVALID_ARG_VALUE:t,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:i},AbortError:o}=et(),{validateAbortSignal:a,validateInteger:s,validateObject:l}=Fn(),c=ke().Symbol("kWeak"),p=ke().Symbol("kResistStopPropagation"),{finished:g}=Kt(),S=Jf(),{addAbortSignalNoValidate:O}=Ti(),{isWritable:x,isNodeStream:v}=Lt(),{deprecate:w}=nt(),{ArrayPrototypePush:P,Boolean:E,MathFloor:m,Number:Q,NumberIsNaN:V,Promise:se,PromiseReject:ae,PromiseResolve:Y,PromisePrototypeThen:ce,Symbol:L}=ke(),R=L("kEmpty"),F=L("kEof");function A(I,N){if(N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),v(I)&&!x(I))throw new t("stream",I,"must be writable");const G=S(this,I);return N!=null&&N.signal&&O(N.signal,G),G}function K(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal");let G=1;N?.concurrency!=null&&(G=m(N.concurrency));let ne=G-1;return N?.highWaterMark!=null&&(ne=m(N.highWaterMark)),s(G,"options.concurrency",1),s(ne,"options.highWaterMark",0),ne+=G,(async function*(){const u=nt().AbortSignalAny([N?.signal].filter(E)),d=this,b=[],T={signal:u};let q,U,y=!1,M=0;function W(){y=!0,k()}function k(){M-=1,de()}function de(){U&&!y&&M<G&&b.length<ne&&(U(),U=null)}async function me(){try{for await(let he of d){if(y)return;if(u.aborted)throw new o;try{if(he=I(he,T),he===R)continue;he=Y(he)}catch(Se){he=ae(Se)}M+=1,ce(he,k,W),b.push(he),q&&(q(),q=null),!y&&(b.length>=ne||M>=G)&&await new se(Se=>{U=Se})}b.push(F)}catch(he){const Se=ae(he);ce(Se,k,W),b.push(Se)}finally{y=!0,q&&(q(),q=null)}}me();try{for(;;){for(;b.length>0;){const he=await b[0];if(he===F)return;if(u.aborted)throw new o;he!==R&&(yield he),b.shift(),de()}await new se(he=>{q=he})}}finally{y=!0,U&&(U(),U=null)}}).call(this)}function J(I=void 0){return I!=null&&l(I,"options"),I?.signal!=null&&a(I.signal,"options.signal"),(async function*(){let G=0;for await(const j of this){var ne;if(I!=null&&(ne=I.signal)!==null&&ne!==void 0&&ne.aborted)throw new o({cause:I.signal.reason});yield[G++,j]}}).call(this)}async function ee(I,N=void 0){for await(const G of _.call(this,I,N))return!0;return!1}async function ue(I,N=void 0){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);return!await ee.call(this,async(...G)=>!await I(...G),N)}async function D(I,N){for await(const G of _.call(this,I,N))return G}async function Z(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);async function G(ne,j){return await I(ne,j),R}for await(const ne of K.call(this,G,N));}function _(I,N){if(typeof I!="function")throw new r("fn",["Function","AsyncFunction"],I);async function G(ne,j){return await I(ne,j)?ne:R}return K.call(this,G,N)}class $ extends n{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function H(I,N,G){var ne;if(typeof I!="function")throw new r("reducer",["Function","AsyncFunction"],I);G!=null&&l(G,"options"),G?.signal!=null&&a(G.signal,"options.signal");let j=arguments.length>1;if(G!=null&&(ne=G.signal)!==null&&ne!==void 0&&ne.aborted){const q=new o(void 0,{cause:G.signal.reason});throw this.once("error",()=>{}),await g(this.destroy(q)),q}const u=new e,d=u.signal;if(G!=null&&G.signal){const q={once:!0,[c]:this,[p]:!0};G.signal.addEventListener("abort",()=>u.abort(),q)}let b=!1;try{for await(const q of this){var T;if(b=!0,G!=null&&(T=G.signal)!==null&&T!==void 0&&T.aborted)throw new o;j?N=await I(N,q,{signal:d}):(N=q,j=!0)}if(!b&&!j)throw new $}finally{u.abort()}return N}async function C(I){I!=null&&l(I,"options"),I?.signal!=null&&a(I.signal,"options.signal");const N=[];for await(const ne of this){var G;if(I!=null&&(G=I.signal)!==null&&G!==void 0&&G.aborted)throw new o(void 0,{cause:I.signal.reason});P(N,ne)}return N}function X(I,N){const G=K.call(this,I,N);return(async function*(){for await(const j of G)yield*j}).call(this)}function re(I){if(I=Q(I),V(I))return 0;if(I<0)throw new i("number",">= 0",I);return I}function oe(I,N=void 0){return N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),I=re(I),(async function*(){var ne;if(N!=null&&(ne=N.signal)!==null&&ne!==void 0&&ne.aborted)throw new o;for await(const u of this){var j;if(N!=null&&(j=N.signal)!==null&&j!==void 0&&j.aborted)throw new o;I--<=0&&(yield u)}}).call(this)}function ie(I,N=void 0){return N!=null&&l(N,"options"),N?.signal!=null&&a(N.signal,"options.signal"),I=re(I),(async function*(){var ne;if(N!=null&&(ne=N.signal)!==null&&ne!==void 0&&ne.aborted)throw new o;for await(const u of this){var j;if(N!=null&&(j=N.signal)!==null&&j!==void 0&&j.aborted)throw new o;if(I-- >0&&(yield u),I<=0)return}}).call(this)}return ri.streamReturningOperators={asIndexedPairs:w(J,"readable.asIndexedPairs will be removed in a future version."),drop:oe,filter:_,flatMap:X,map:K,take:ie,compose:A},ri.promiseReturningOperators={every:ue,forEach:Z,reduce:H,toArray:C,some:ee,find:D},ri}var Bo,ol;function Qf(){if(ol)return Bo;ol=1;const{ArrayPrototypePop:e,Promise:t}=ke(),{isIterable:r,isNodeStream:n,isWebStream:i}=Lt(),{pipelineImpl:o}=ts(),{finished:a}=Kt();Xf();function s(...l){return new t((c,p)=>{let g,S;const O=l[l.length-1];if(O&&typeof O=="object"&&!n(O)&&!r(O)&&!i(O)){const x=e(l);g=x.signal,S=x.end}o(l,(x,v)=>{x?p(x):c(v)},{signal:g,end:S})})}return Bo={finished:a,pipeline:s},Bo}var al;function Xf(){if(al)return Eo.exports;al=1;const{Buffer:e}=at(),{ObjectDefineProperty:t,ObjectKeys:r,ReflectApply:n}=ke(),{promisify:{custom:i}}=nt(),{streamReturningOperators:o,promiseReturningOperators:a}=rp(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:s}}=et(),l=Jf(),{setDefaultHighWaterMark:c,getDefaultHighWaterMark:p}=Oi(),{pipeline:g}=ts(),{destroyer:S}=xr(),O=Kt(),x=Qf(),v=Lt(),w=Eo.exports=Za().Stream;w.isDestroyed=v.isDestroyed,w.isDisturbed=v.isDisturbed,w.isErrored=v.isErrored,w.isReadable=v.isReadable,w.isWritable=v.isWritable,w.Readable=Mi();for(const E of r(o)){let Q=function(...V){if(new.target)throw s();return w.Readable.from(n(m,this,V))};const m=o[E];t(Q,"name",{__proto__:null,value:m.name}),t(Q,"length",{__proto__:null,value:m.length}),t(w.Readable.prototype,E,{__proto__:null,value:Q,enumerable:!1,configurable:!0,writable:!0})}for(const E of r(a)){let Q=function(...V){if(new.target)throw s();return n(m,this,V)};const m=a[E];t(Q,"name",{__proto__:null,value:m.name}),t(Q,"length",{__proto__:null,value:m.length}),t(w.Readable.prototype,E,{__proto__:null,value:Q,enumerable:!1,configurable:!0,writable:!0})}w.Writable=es(),w.Duplex=Mt(),w.Transform=Vf(),w.PassThrough=Yf(),w.pipeline=g;const{addAbortSignal:P}=Ti();return w.addAbortSignal=P,w.finished=O,w.destroy=S,w.compose=l,w.setDefaultHighWaterMark=c,w.getDefaultHighWaterMark=p,t(w,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return x}}),t(g,i,{__proto__:null,enumerable:!0,get(){return x.pipeline}}),t(O,i,{__proto__:null,enumerable:!0,get(){return x.finished}}),w.Stream=w,w._isUint8Array=function(m){return m instanceof Uint8Array},w._uint8ArrayToBuffer=function(m){return e.from(m.buffer,m.byteOffset,m.byteLength)},Eo.exports}var sl;function np(){return sl||(sl=1,(function(e){const t=Xf(),r=Qf(),n=t.Readable.destroy;e.exports=t.Readable,e.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,e.exports._isUint8Array=t._isUint8Array,e.exports.isDisturbed=t.isDisturbed,e.exports.isErrored=t.isErrored,e.exports.isReadable=t.isReadable,e.exports.Readable=t.Readable,e.exports.Writable=t.Writable,e.exports.Duplex=t.Duplex,e.exports.Transform=t.Transform,e.exports.PassThrough=t.PassThrough,e.exports.addAbortSignal=t.addAbortSignal,e.exports.finished=t.finished,e.exports.destroy=t.destroy,e.exports.destroy=n,e.exports.pipeline=t.pipeline,e.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get(){return r}}),e.exports.Stream=t.Stream,e.exports.default=e.exports})(Ao)),Ao.exports}var ul;function ip(){if(ul)return un;ul=1,Object.defineProperty(un,"__esModule",{value:!0}),un.ActorQueryResultSerializeSparqlJson=void 0;const e=Nf(),t=zt(),r=qf(),n=np();let i=class _n extends e.ActorQueryResultSerializeFixedMediaTypes{constructor(a){super(a)}static bindingToJsonBindings(a){if(a.termType==="Literal"){const s=a,l={value:s.value,type:"literal"},{language:c,datatype:p}=s;return c?l["xml:lang"]=c:p&&p.value!=="http://www.w3.org/2001/XMLSchema#string"&&(l.datatype=p.value),l}return a.termType==="BlankNode"?{value:a.value,type:"bnode"}:a.termType==="Quad"?{value:{subject:_n.bindingToJsonBindings(a.subject),predicate:_n.bindingToJsonBindings(a.predicate),object:_n.bindingToJsonBindings(a.object)},type:"triple"}:{value:a.value,type:"uri"}}async testHandleChecked(a,s){return["bindings","boolean"].includes(a.type)?(0,t.passTestVoid)():(0,t.failTest)("This actor can only handle bindings streams or booleans.")}async runHandle(a,s,l){const c=new n.Readable,p={};if(a.type==="bindings"){const g=await a.metadata();g.variables.length>0&&(p.vars=g.variables.map(S=>S.variable.value))}if(c.push(`{"head": ${JSON.stringify(p)},
9
- `),a.type==="bindings"){const g=a.bindingsStream;c.push(`"results": { "bindings": [
10
- `);let S=!0;function*O(x){yield x()}c.wrap((0,r.wrap)(g).map(x=>{const v=`${S?"":`,
11
- `}${JSON.stringify(Object.fromEntries([...x].map(([w,P])=>[w.value,_n.bindingToJsonBindings(P)])))}`;return S=!1,v}).append((0,r.wrap)(O(()=>`
12
- ]}${this.emitMetadata?`,
13
- "metadata": { "httpRequests": ${this.httpObserver.requests} }`:""}}
14
- `))))}else c.wrap((0,r.wrap)(a.execute().then(g=>[`"boolean":${g}
15
- }
16
- `])));return{data:c}}};return un.ActorQueryResultSerializeSparqlJson=i,un}var ll;function op(){return ll||(ll=1,(function(e){var t=nr&&nr.__createBinding||(Object.create?(function(n,i,o,a){a===void 0&&(a=o);var s=Object.getOwnPropertyDescriptor(i,o);(!s||("get"in s?!i.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,a,s)}):(function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]})),r=nr&&nr.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Zh(),e),r(ip(),e)})(nr)),nr}var ap=op();const In=Array.from(new Set([...Tn,"zhipu","ollama","custom"])),fl=new WeakMap,sp=os.storage.base.slice(os.storage.base.lastIndexOf("/")+1);function up(e){const t=e.indexOf("#");return t<0?e:e.slice(0,t)}function Vp(e){cp(),oc({createQueryEngine:async()=>new ac});const t=new URL("settings/-/sparql",e.podUrl).toString();return _e.setSparqlEndpoint(t),$e.setSparqlEndpoint(t),tt.setSparqlEndpoint(t),{credentialsTableDocument(){return _e.buildIri(e.podUrl,{id:sp})},providerTableDocument(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");const o=i==="custom"&&n?ua(n):ar(i);return $e.buildIri(e.podUrl,{id:up(o)})},async listModels(){return await e.database.init?.(tt),(await e.database.select().from(tt).execute()).map(yp).filter(wr)},async listProviders(){await e.database.init?.(_e,$e,tt);const r=await e.database.select().from(_e).execute(),n=await e.database.select().from($e).execute(),i=await e.database.select().from(tt).execute();return dp(e,r,n,i)},async createApiKeyCredential(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(_e,$e);const o=le(n.id),a=o??_e.buildId({id:_s(i,"apiKey")}),s=1,l=Kn(i,n.offeringId??bn(i,"apiKey")),c=n.baseUrl??cs(i,l),p=Ho(n.proxyUrl),g={id:a,provider:i==="custom"?ua(a):ar(i),service:"ai",authMode:"apiKey",offeringId:l,status:"active",accountLabel:n.label,label:n.label,baseUrl:c,proxyUrl:p,keyVersion:String(s),reauthRequired:!1,encryptedSecret:ii(e,i,a,{type:"apiKey",apiKey:n.apiKey}),encryptionAlgorithm:"PLAINTEXT",metadata:{...Hn({offeringId:l,baseUrl:c,priority:n.priority}),...n.compatibility?{compatibility:n.compatibility}:{}}};return await hl(e,a,g,o!==void 0),Ye(e,i,g)},async createLocalCredential(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(_e,$e);const o=le(n.id),a=o??_e.buildId({id:_s(i,"local")}),s=Kn(i,n.offeringId??bn(i,"local")),l=n.baseUrl??cs(i,s),c={id:a,provider:ar(i),service:"ai",authMode:"local",offeringId:s,status:"active",accountLabel:n.label??"Local",label:n.label??"Local",baseUrl:l,keyVersion:"1",reauthRequired:!1,encryptedSecret:ii(e,i,a,{type:"local"}),encryptionAlgorithm:"PLAINTEXT",metadata:Hn({offeringId:s,baseUrl:l,priority:n.priority})};return await hl(e,a,c,o!==void 0),Ye(e,i,c)},async saveOAuthCredential(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");const a=(fl.get(e.database)??Promise.resolve()).then(async()=>{await e.database.init?.(_e,$e);const s=Kn(i,n.offeringId??bn(i,"deviceCode")),c=(await e.database.select().from(_e).execute()).find(E=>{const m=Ye(e,i,E);if(!m||m.authMode!=="deviceCode"&&m.authMode!=="oauth"||_l(i,m.offeringId)!==_l(i,s)||E.status!=="active"&&E.status!=="disabled")return!1;const Q=yn(e,i,m.id,E.encryptedSecret);return hp(n,lt(E.metadata),Q)}),p=c&&Ye(e,i,c),g=lt(c?.metadata),S=p&&yn(e,i,p.id,c?.encryptedSecret),O=p?.id??_e.buildId({id:`${i}-oauth-${crypto.randomUUID()}`}),x=n.accountLabel??"OAuth",v=n.accountId??le(g?.accountId)??le(S?.accountId),w=n.accountSubject??le(g?.authoritativeSubject)??le(S?.accountSubject)??le(S?.authoritativeSubject),P={...c,id:O,provider:ar(i),service:"ai",authMode:"deviceCodeOAuth",offeringId:s,status:p?.enabled===!1?"disabled":"active",accountLabel:c?.accountLabel??x,label:c?.label??x,expiresAt:n.expiresAt,scopes:n.scope?n.scope.split(/\s+/u).filter(Boolean):void 0,keyVersion:String((p?.version??0)+1),reauthRequired:!1,failCount:0,lastFailureCode:null,lastFailureAt:null,rateLimitResetAt:null,encryptedSecret:ii(e,i,O,{type:"deviceCodeOAuth",accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt,scope:n.scope,idToken:n.idToken,accountId:v,accountSubject:w,accountLabel:n.accountLabel,offeringId:s,authorizationMethodId:n.authorizationMethodId}),encryptionAlgorithm:"PLAINTEXT",metadata:{...g,...Hn({offeringId:s,priority:p?.priority,enabled:p?.enabled,health:"healthy"}),authoritativeSubject:w,accountId:v,authorizationMethodId:n.authorizationMethodId}};if(c){const E={...P};if(delete E.id,!await e.database.updateById(_e,O,E))throw new Error("credential_version_conflict")}else await e.database.insert(_e).values(P).execute();return Ye(e,i,P)});return fl.set(e.database,a.then(()=>{},()=>{})),a},async updateOAuthCredential(r,n,i,o){const a=ut(r);if(!a)throw new Error("unsupported_provider");await e.database.init?.(_e,$e);const s=await e.database.findById(_e,n),l=s&&Ye(e,a,s);if(!s||!l||l.authMode!=="deviceCode")throw new Error("oauth_credential_not_found");if(l.version!==i)throw new Error("credential_version_conflict");const c=yn(e,a,n,s.encryptedSecret),p=o.accountId??le(lt(s.metadata)?.accountId)??le(c?.accountId),g=o.accountSubject??le(lt(s.metadata)?.authoritativeSubject)??le(c?.accountSubject)??le(c?.authoritativeSubject),S=Kn(a,o.offeringId??l.offeringId),O={expiresAt:o.expiresAt,scopes:o.scope?o.scope.split(/\s+/u).filter(Boolean):void 0,keyVersion:String(i+1),reauthRequired:!1,failCount:0,lastFailureCode:null,lastFailureAt:null,rateLimitResetAt:null,status:"active",encryptedSecret:ii(e,a,n,{type:"deviceCodeOAuth",accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt,scope:o.scope,idToken:o.idToken,accountId:p,accountSubject:g,accountLabel:o.accountLabel??le(s.accountLabel),offeringId:S,authorizationMethodId:o.authorizationMethodId??le(lt(s.metadata)?.authorizationMethodId)}),accountLabel:o.accountLabel??le(s.accountLabel),label:o.accountLabel??le(s.label),offeringId:S,metadata:{...lt(s.metadata),...Hn({offeringId:S,health:"healthy"}),authoritativeSubject:g,accountId:p,authorizationMethodId:o.authorizationMethodId??le(lt(s.metadata)?.authorizationMethodId)}},x=await e.database.updateById(_e,n,O);if(!x)throw new Error("credential_version_conflict");return Ye(e,a,x)},async updateProviderCredential(r,n,i){const o=ut(r);if(!o)throw new Error("unsupported_provider");await e.database.init?.(_e,$e);const a=await e.database.findById(_e,n),s=a&&Ye(e,o,a);if(!a||!s)throw new Error("credential_not_found");if(s.version!==i.expectedVersion)throw new Error("credential_version_conflict");const l={...lt(a.metadata),...i.priority===void 0?{}:{priority:i.priority},...i.enabled===void 0?{}:{enabled:i.enabled},...i.baseUrl===void 0?{}:{baseUrl:i.baseUrl},...i.proxyUrl===void 0?{}:{proxyUrl:Ho(i.proxyUrl)}},c={...i.label===void 0?{}:{accountLabel:i.label,label:i.label},...i.baseUrl===void 0?{}:{baseUrl:i.baseUrl},...i.proxyUrl===void 0?{}:{proxyUrl:Ho(i.proxyUrl)},...i.enabled===void 0?{}:{status:i.enabled?"active":"disabled"},keyVersion:String(s.version+1),metadata:l},p=await e.database.updateById(_e,n,c);if(!p)throw new Error("credential_update_failed");const g=Ye(e,o,p);if(!g)throw new Error("credential_update_failed");return g},async markCredentialHealth(r,n,i,o){const a=ut(r);if(!a)throw new Error("unsupported_provider");await e.database.init?.(_e);const s=await e.database.findById(_e,n),l=s&&Ye(e,a,s);if(!s||!l)throw new Error("credential_not_found");if(l.version!==o)throw new Error("credential_version_conflict");const c=await e.database.updateById(_e,n,{keyVersion:String(l.version+1),metadata:{...lt(s.metadata),health:i},...i==="healthy"?{failCount:0,lastFailureCode:null,lastFailureAt:null,rateLimitResetAt:null,reauthRequired:!1}:{}});if(!c)throw new Error("credential_update_failed");const p=Ye(e,a,c);if(!p)throw new Error("credential_update_failed");return p},async deleteProviderCredential(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(_e,$e);const o=await e.database.findById(_e,n),a=o&&Ye(e,i,o);if(a)return await e.database.deleteById(_e,n),a},async readCredentialSecret(r,n){const i=ut(r);if(!i)throw new Error("unsupported_provider");const o=await e.database.findById(_e,n);if(!o||!Ye(e,i,o))throw new Error("credential_not_found");const a=yn(e,i,n,o.encryptedSecret);if(!a)throw new Error("credential_secret_unavailable");return a},async saveDiscoveredModels(r,n,i){const o=ut(r);if(!o)throw new Error("unsupported_provider");await e.database.init?.(_e,$e,tt);const a=await cl(e,n),s=pl(o,a);await yl(e.database,s,ui(o));const l=await e.database.select().from(tt).execute(),c=new Set(l.map(S=>le(S.id)).filter(wr)),p=i.map(bp).filter(wr),g=new Set(p.map(S=>S.id));for(const S of l.filter(O=>gp(O,s,o))){const O=sr(le(S.id),s)??ec(le(S.id));O&&!g.has(O)&&le(S.status)!=="unavailable"&&await e.database.updateById(tt,String(S.id),{status:"unavailable"})}for(const S of p)await wp(e.database,s,S,c)},async saveModelSelection(r,n,i){const o=ut(r);if(!o)throw new Error("unsupported_provider");await e.database.init?.($e,tt);const a=o==="custom"&&i?await cl(e,i):null;if(o==="custom"&&i&&!a)throw new Error("credential_not_found");const s=a?pl(o,a):ar(o);await yl(e.database,s,ui(o));const c=(await e.database.select().from($e).execute()).find(v=>gr(le(v.id),s)),p=le(c?.id)??s,g=rc(c?.hasModel),S=await e.database.select().from(tt).execute(),O=[...new Set(n.map(v=>Sp(o,v,S,a?s:void 0)))];if(!await e.database.updateById($e,p,{hasModel:O}))throw new Error("provider_model_selection_update_failed");e.authenticatedFetch&&await fp(e,p,g,O)}}}const lp="https://undefineds.co/ns#hasModel";async function fp(e,t,r,n){const i=Ko($e,e.podUrl,t),o=r.map(p=>Ko(tt,e.podUrl,p)),a=n.map(p=>Ko(tt,e.podUrl,p)),s=p=>p.map(g=>`<${i}> <${lp}> <${g}> .`).join(`
17
- `),l=[o.length>0?`DELETE DATA { ${s(o)} }`:void 0,a.length>0?`INSERT DATA { ${s(a)} }`:void 0].filter(p=>!!p);if(l.length===0)return;const c=await e.authenticatedFetch(i.split("#",1)[0],{method:"PATCH",headers:{"content-type":"application/sparql-update"},body:l.join(`;
18
- `)});if(!c.ok)throw new Error(`provider_model_selection_persist_failed:${c.status}`)}function Ko(e,t,r){return/^https?:\/\//u.test(r)?r:e.buildIri(t,{id:r})}async function cl(e,t){const r=await e.database.findById(_e,t);return r||((await e.database.select().from(_e).execute()).find(i=>{const o=le(i.id);return o===t||(o?_e.buildIri(e.podUrl,{id:o})===t:!1)})??null)}function cp(){dl(Xh.ActionObserverHttp.prototype),dl(ap.ActionObserverHttp.prototype)}function dl(e){const t=e;if(t.__xpodObservedActorsPatch)return;const r=t.onRun;t.onRun=function(n,i,o){return Array.isArray(this.observedActors)||(this.observedActors=[]),r.call(this,n,i,o)},t.__xpodObservedActorsPatch=!0}function dp(e,t,r,n){const i=t.filter(o=>le(o.service)==="ai").filter(o=>le(o.status)!=="revoked");return In.map(o=>{const a=i.map(p=>Ye(e,o,p)).filter(wr).sort((p,g)=>p.priority-g.priority||p.id.localeCompare(g.id)),s=r.find(p=>xt(le(p.id))===o),c=rc(s?.hasModel).map(p=>_p(o,p,n));return{id:o,name:o==="custom"?a.find(p=>p.label)?.label??ui(o):ui(o),offerings:o==="custom"?Ap(i.filter(p=>Ye(e,o,p))):vl(o,e.openAiSubscriptionImportAvailable===!0),credentials:a,selectedModels:c,status:Ep(a)}})}async function hl(e,t,r,n){if(!(n?await e.database.findById(_e,t):null)){await e.database.insert(_e).values(r).execute();return}const o={...r};if(delete o.id,!await e.database.updateById(_e,t,o))throw new Error("credential_create_failed")}function ii(e,t,r,n){return ed({webId:e.webId,provider:t,credentialIri:_e.buildIri(e.podUrl,{id:r}),secret:n})}function hp(e,t,r){let n=!1;for(const[i,o]of[[e.accountId,[t?.accountId,r?.accountId]],[e.accountSubject,[t?.authoritativeSubject,r?.accountSubject,r?.authoritativeSubject]]]){const a=[...new Set(o.map(le).filter(wr).filter(s=>s.trim()))];if(a.length>1)return!1;if(!(!i?.trim()||!a.length)){if(a[0]!==i)return!1;n=!0}}return n}function Ye(e,t,r){const n=le(r.id);if(!n)return;const i=ns(le(r.provider))??Rp(n);if(i!==t)return;const o=lt(r.metadata),a=nc(r.authMode);if(a)return{id:n,provider:i,offeringId:Zf(r,i,a),authMode:a,label:le(r.accountLabel)??le(r.label),enabled:bl(o?.enabled)??le(r.status)==="active",priority:Go(o?.priority)??100,health:Tp(o?.health)??(bl(r.reauthRequired)?"expired":"healthy"),lastFailureCode:le(r.lastFailureCode),lastFailureAt:Vo(r.lastFailureAt),rateLimitResetAt:Vo(r.rateLimitResetAt),failCount:Go(r.failCount),maskedHint:vp(e,i,n,r.encryptedSecret),baseUrl:le(r.baseUrl),proxyUrl:Ip(le(r.proxyUrl)??le(o?.proxyUrl)),compatibility:pp(o?.compatibility),expiresAt:Vo(r.expiresAt),version:Go(r.keyVersion)??0}}function pp(e){return e==="auto"||e==="openai"||e==="anthropic"?e:void 0}function Zf(e,t,r){return le(e.offeringId)??le(lt(e.metadata)?.offeringId)??is(le(e.provider))??bn(t,r)}function _p(e,t,r){const n=r.find(s=>ur(le(s.id))===ur(t)),i=le(n?.isProvidedBy),o=n?sr(t,i??e)??t:sr(t,e)??t,a=n??r.find(s=>{const l=le(s.id),c=le(s.isProvidedBy);return l===t||sr(l,e)===o||ns(c)===e&&sr(l,c??e)===o});return{id:o,provider:e,offeringId:is(le(a?.isProvidedBy)),credentialId:rs(i),resourceId:le(a?.id)??t,displayName:le(a?.displayName),availability:le(a?.status)==="unavailable"||!a?"unavailable":"available"}}function yp(e){const t=le(e.isProvidedBy),r=ns(t),n=r&&sr(le(e.id),t??r);if(!(!r||!n))return{id:n,provider:r,offeringId:is(t),credentialId:rs(t),resourceId:le(e.id),displayName:le(e.displayName),availability:le(e.status)==="unavailable"?"unavailable":"available",...mp(e)}}function bp(e){const t=lt(e),r=le(t?.id);if(r)return{id:r,displayName:le(t?.displayName),modelType:tc(t?.modelType)}}function pl(e,t){const r=rs(le(t?.provider));return r?ua(r):ar(e)}function ar(e){return rd(e)}function ua(e){return nd(e)}function rs(e){const t=xt(e),r=t?.startsWith("custom-instance-")?t.slice(16):void 0;if(r)try{return decodeURIComponent(r)}catch{return}}function _l(e,t){if(!t)return;const r=t.trim().toLowerCase();if(e==="bailian"){if(r==="token-plan")return"token-plan-personal";if(r==="coding-plan")return"coding-plan-pro";if(r==="payg")return"pay-as-you-go"}return r}function gr(e,t){const r=ur(e),n=ur(t);return r!==void 0&&r===n}function gp(e,t,r){const n=le(e.isProvidedBy);return gr(n,t)?!0:r==="custom"?!1:xt(n)?.startsWith(`${r}-`)===!0}function ec(e){if(!e)return;const t=e.lastIndexOf("#");if(t<0||t===e.length-1)return;const r=e.slice(t+1);try{return decodeURIComponent(r)}catch{return r}}async function yl(e,t,r){(await e.select().from($e).execute()).some(i=>gr(le(i.id),t))||await e.insert($e).values({id:t,displayName:r}).execute()}async function wp(e,t,r,n){const i=la(t,r.id),o={displayName:r.displayName??r.id,isProvidedBy:t,status:"active",...r.modelType?{modelType:r.modelType}:{}};if(n.has(i)){await e.updateById(tt,i,o);return}await e.insert(tt).values({id:i,...o}).execute(),n.add(i)}function mp(e){const t=tc(e.modelType);return t?{modelType:t,...t==="embedding"?{capabilities:["embedding"]}:{}}:{}}function tc(e){const t=le(e)?.trim().toLowerCase();return t==="chat"||t==="embedding"?t:void 0}function la(e,t){const r=ur(e)??`${e}.ttl`;return`${r.split("#",1)[0]??r}#${encodeURIComponent(t)}`}function Sp(e,t,r,n){const i=le(t.resourceId),o=n??ar(e),a=le(t.id),s=a?r.filter(c=>{const p=le(c.isProvidedBy),g=xt(p);return(n?gr(p,n):g===e||g?.startsWith(`${e}-`)===!0)&&sr(le(c.id),p??o)===a}):[],l=n||s.length===1?s[0]:void 0;if(i){const c=r.find(O=>le(O.id)===i);if(!c&&l)return String(l.id);const p=le(c?.isProvidedBy),g=xt(p),S=n?gr(p,n):g===e||g?.startsWith(`${e}-`)===!0;if(c&&!S)throw new Error("invalid_model_selection_resource");if(!c){const O=a??ec(i),x=xt(i),v=n?gr(x,n):x===e||x?.startsWith(`${e}-`)===!0;if(!O||!v)throw new Error("invalid_model_selection_resource");return la(o,O)}return i}if(!a)throw new Error("invalid_model_selection_resource");return le(l?.id)??la(o,a)}function sr(e,t){if(!e)return;const n=ur(t)?.split("#",1)[0]??t,i=n.endsWith(".ttl")?`${n}#`:`${n}.ttl#`,o=e.lastIndexOf(i);if(!(o<0))try{return decodeURIComponent(e.slice(o+i.length))}catch{return e.slice(o+i.length)}}function rc(e){if(Array.isArray(e))return e.map(le).filter(wr);const t=le(e);return t?[t]:[]}function Ap(e){const t=new Map;for(const r of e){const n=lt(r.metadata),i=Zf(r,"custom",nc(r.authMode)??"apiKey"),o=wc(n?.compatibility,i),a=le(r.baseUrl)??le(n?.baseUrl),s=ln.find(l=>l.id===i)??ln.find(l=>l.id===`${o}-compatible`)??ln[0];t.set(i,{...s,id:i,endpoints:a?[{protocol:o==="anthropic"?"anthropic":"chatCompletions",baseUrl:a}]:s.endpoints,modelDiscovery:o==="anthropic"?{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"}:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"}})}return t.size>0?[...t.values()]:ln}function Ep(e){return e.some(t=>t.health==="expired"||t.health==="invalid")?"attention":e.some(t=>t.enabled)?"available":e.length>0?"configured":"unconfigured"}function vp(e,t,r,n){const i=yn(e,t,r,n),o=le(i?.apiKey);if(o)return o.length<=8?`${o.slice(0,2)}…`:`${o.slice(0,3)}...${o.slice(-4)}`}function yn(e,t,r,n){return td({webId:e.webId,provider:t,credentialIri:_e.buildIri(e.podUrl,{id:r}),envelope:n})}function ns(e){const t=xt(e),r=ut(t);return r||In.find(n=>t?.startsWith(`${n}-`))}function is(e){const t=xt(e);if(t&&!t.startsWith("custom-instance-")){if(t==="bailian-token-plan-personal")return"token-plan";if(t==="bailian-token-plan-team")return"token-plan-team";if(t==="bailian-coding-plan-pro")return"coding-plan";if(t==="bailian-pay-as-you-go")return"pay-as-you-go";for(const r of In)if(t.startsWith(`${r}-`))return t.slice(r.length+1)}}function Rp(e){const t=/\/([^/#]+)\.ttl#/u.exec(e);return ut(t?.[1])}function ut(e){if(typeof e!="string"||!e.trim())return;const t=e.trim().toLowerCase();if(t==="zhipu"||t.startsWith("zhipu-"))return"zhipu";if(In.includes(t))return t;for(const r of In)if(t.startsWith(`${r}-`)||r==="bailian"&&(t==="bailian-token-plan"||t==="bailian-coding-plan"))return r}function Ho(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{throw new Error("invalid_proxy_url")}if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.hash||!t.hostname)throw new Error("invalid_proxy_url");return t.toString().replace(/\/$/u,"")}function Ip(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{return}if(!(!["http:","https:"].includes(t.protocol)||!t.hostname))return t.username="",t.password="",t.search="",t.hash="",t.toString().replace(/\/$/u,"")}function nc(e){if(e==="oauth"||e==="deviceCode"||e==="apiKey"||e==="local")return e;if(e==="deviceCodeOAuth")return"deviceCode"}function Tp(e){if(e==="healthy"||e==="expired"||e==="invalid"||e==="unknown")return e;if(e==="reauthRequired")return"expired";if(e==="disabled")return"unknown"}function lt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function le(e){return typeof e=="string"&&e.trim()?e:void 0}function Go(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function bl(e){if(typeof e=="boolean")return e;if(e==="true")return!0;if(e==="false")return!1}function Vo(e){return e instanceof Date?e.toISOString():le(e)}function wr(e){return e!==void 0}export{Cp as A,ml as P,Hn as a,nd as b,_s as c,bn as d,rd as e,xp as f,Vp as g,Tn as h,Dp as i,Qc as j,ai as k,id as l,Np as m,Lp as n,cs as o,xt as p,Kn as s,kp as w};