@doubao-dev/cli 0.0.19 → 0.0.20

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 (99) hide show
  1. package/dist/2514.js +8 -8
  2. package/dist/2932.js +1 -1
  3. package/dist/318.js +1 -1
  4. package/dist/3494.js +284 -0
  5. package/dist/{1122.js.LICENSE.txt → 3494.js.LICENSE.txt} +6 -0
  6. package/dist/4931.js +1 -1
  7. package/dist/7410.js +1 -1
  8. package/dist/{1664.js → 8713.js} +3 -3
  9. package/dist/@byted-doubao-apps/create.js +1 -1
  10. package/dist/@byted-doubao-apps/login.js +1 -1
  11. package/dist/@byted-doubao-apps/login~1.js +1 -1
  12. package/dist/@byted-doubao-apps/template-empty/README.md +0 -2
  13. package/dist/@byted-doubao-apps/template-empty/package.json +3 -3
  14. package/dist/@byted-doubao-apps/template-starter/README.md +1 -1
  15. package/dist/@byted-doubao-apps/template-starter/package.json +3 -3
  16. package/dist/@byted-hdt/cli.js +1 -1
  17. package/dist/@inquirer/select.js +1 -1
  18. package/dist/@lynx-js/web-core-canary.js +2 -13
  19. package/dist/@lynx-js/web-core-canary~1.js +2 -0
  20. package/dist/app.js +1 -1
  21. package/dist/assets/web-sdk-debugger/chrome-devtools/entrypoints/devtools_app/devtools_app.js +9 -7
  22. package/dist/assets/web-sdk-debugger/chrome-devtools/panels/wsd-debug/WsdDebug.js +9 -7
  23. package/dist/assets/web-sdk-debugger/chrome-devtools/panels/wsd-debug/WsdDebugMeta.js +79 -77
  24. package/dist/assets/web-sdk-debugger/index.html +1 -1
  25. package/dist/assets/web-sdk-debugger/static/css/index.9952f4197c.css +1 -0
  26. package/dist/assets/web-sdk-debugger/static/js/{741.ece428827e.js → 48.8c158322ee.js} +60 -67
  27. package/dist/assets/web-sdk-debugger/static/js/48.8c158322ee.js.LICENSE.txt +5 -0
  28. package/dist/assets/web-sdk-debugger/static/js/async/257.4d55bd5ce8.js +1 -0
  29. package/dist/assets/web-sdk-debugger/static/js/async/{web-core-template-loader-thread.f9f3ef68b1.js → web-core-template-loader-thread.20d5b2a451.js} +2 -2
  30. package/dist/assets/web-sdk-debugger/static/js/async/{web-core-worker-chunk.002a4f7b9d.js → web-core-worker-chunk.71b9323071.js} +1 -1
  31. package/dist/assets/web-sdk-debugger/static/js/index.e5bc5f1bbd.js +26 -0
  32. package/dist/assets/web-sdk-debugger/static/js/{lib-polyfill.8cf763c414.js → lib-polyfill.4f00df8f2a.js} +1 -1
  33. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-api.template.js +0 -0
  34. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-framework.template.js +0 -0
  35. package/dist/auth.js +1 -1
  36. package/dist/browser.js +1 -1
  37. package/dist/csstree.esm.js +12 -0
  38. package/dist/dbx-demo.js +1 -1
  39. package/dist/dbx.js +1 -1
  40. package/dist/demo-server.js +1 -1
  41. package/dist/dev-config.js +1 -1
  42. package/dist/dev-service-client.js +6 -6
  43. package/dist/dev-shell.js +1 -1
  44. package/dist/dev.js +7 -7
  45. package/dist/eval.js +1 -1
  46. package/dist/gen-explore.js +1 -1
  47. package/dist/gen-trajectory.js +1 -1
  48. package/dist/get.js +1 -1
  49. package/dist/init.js +2 -2
  50. package/dist/ink.js +1 -1
  51. package/dist/json-file.js +1 -1
  52. package/dist/login.js +1 -1
  53. package/dist/main.js +1 -1
  54. package/dist/manifest-mcp-config.js +1 -1
  55. package/dist/ora.js +1 -1
  56. package/dist/portal.js +1 -1
  57. package/dist/project-layout.js +1 -1
  58. package/dist/prompt.js +1 -1
  59. package/dist/prompts.js +1 -1
  60. package/dist/report.js +1 -1
  61. package/dist/run-registry.js +1 -1
  62. package/dist/run.js +1 -1
  63. package/dist/sandbox.js +1 -1
  64. package/dist/sdk.js +67 -133
  65. package/dist/sdk~1.js +67 -133
  66. package/dist/server.js +1 -1
  67. package/dist/shared.js +1 -1
  68. package/dist/simulator-client.js +1 -1
  69. package/dist/skill.js +1 -1
  70. package/dist/skills~1.js +1 -1
  71. package/dist/static/assets/web-view-proxy-page-client.js +1 -0
  72. package/dist/static/assets/web-view-proxy-service-worker.js +1 -0
  73. package/dist/status.js +1 -1
  74. package/dist/status~1.js +1 -1
  75. package/dist/stop.js +1 -1
  76. package/dist/update.js +1 -1
  77. package/dist/upgrade.js +1 -1
  78. package/dist/upload.js +1 -1
  79. package/dist/validate.js +1 -1
  80. package/dist/workspace.js +1 -1
  81. package/dist/yaml.js +1 -1
  82. package/package.json +2 -2
  83. package/skills/doubao-agentic-service-development/references/dev-debug.md +6 -6
  84. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +105 -25
  85. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +118 -6
  86. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/06-/344/272/244/344/272/222.md +18 -8
  87. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/quick-reference.md +3 -3
  88. package/skills/doubao-agentic-service-development/references/frontend/examples/page-widget-basics.md +2 -3
  89. package/skills/doubao-agentic-service-development/references/frontend/guides/component-development.md +2 -1
  90. package/skills/doubao-agentic-service-development/references/frontend/guides/debugger-mcp.md +7 -1
  91. package/skills/doubao-agentic-service-development/references/frontend/rules/dos-and-donts.md +4 -7
  92. package/skills/doubao-agentic-service-development/references/frontend-dev.md +0 -1
  93. package/skills/doubao-agentic-service-development/references/manifest-guide.md +5 -4
  94. package/skills/doubao-agentic-service-development/references/mcp-protocol.md +4 -3
  95. package/dist/1122.js +0 -277
  96. package/dist/assets/web-sdk-debugger/static/css/index.fe34ed7927.css +0 -1
  97. package/dist/assets/web-sdk-debugger/static/js/index.da81c37197.js +0 -26
  98. package/dist/push-page.js +0 -1
  99. package/dist/push-widget.js +0 -1
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{external_node_stream_promises_namespaceObject as t,getApiBaseUrl as n,getAuthOptions as r,version_version as o,isRecord as i,command_Command as s,option_Option as a,runCommand as d,chalk_source as l}from"./1664.js";import{DEV_ACTIONS as c,ensureDevActionSucceeded as u,summarizeData as p,parseJsonData as h,DEV_EVENTS as f,connectDevService as m,ServiceManager as g,startForegroundDevService as y}from"./dev-service-client.js";import{listMiniAppVersions as _}from"./app.js";import{openUrlInBrowser as b}from"./browser.js";import{resolveDevSimulatorPaths as w,prepareDevBusinessTemplates as v,normalizeLoopbackUrl as E,prepareDevManifest as I,resolveDevMcpEndpoint as T,formatFinalDevWarnings as A}from"./dev-config.js";import{resolveProjectLayout as C}from"./project-layout.js";import{extractMCPHeadersFromManifest as j}from"./manifest-mcp-config.js";import{createKitDevOptions as k}from"./kit-dev-options.js";import"./180.js";import"./3551.js";e.add({"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"(e,t,n){t.Ph=void 0;var r=n("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js");Object.defineProperty(t,"Ph",{enumerable:!0,get:function(){return r.createRealDeviceDebugQRCodeValue}})},"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js"(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.createRealDeviceDebugQRCodeValue=t.REAL_DEVICE_DEBUG_QR_ACTION=t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL=void 0;let r=n("../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"),o=r.__importStar(n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"));t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL="https://hello.doubao-dev.com",t.REAL_DEVICE_DEBUG_QR_ACTION="start_real_device_debug";class i extends Error{constructor(e,t){super(t),this.name="RealDeviceDebugAuthError",this.code=e}}let s=null;function a(e,t){let n=e.trim();if(!n)throw Error(t);return n}t.createRealDeviceDebugQRCodeValue=function(e){var n,d,l;return r.__awaiter(this,void 0,void 0,function*(){var c;let u=Object.assign(Object.assign({hostUrl:a(e.hostUrl,"hostUrl is required to request real-device debug ticket"),appKey:a(e.appKey,"appKey is required to request real-device debug ticket"),isSigned:e.isSigned,isEncrypted:!!e.isEncrypted,signPublicKeyVersion:null==(n=e.signPublicKeyVersion)?void 0:n.trim(),versionTag:(c=e.versionTag,void 0===c?void 0:a(c,"versionTag must not be empty")),appletType:e.appletType,baseApiUrl:e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL},!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}),p=yield function(e,n){return r.__awaiter(this,void 0,void 0,function*(){var r;let o,i=(r=e.appKey,o=a(e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL,"baseApiUrl is required to request real-device debug ticket"),new URL(`/developer/check_api/apps/${encodeURIComponent(r)}/debug/ticket`,o).toString()),s=yield n({method:"POST",url:i,data:{debug_context:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({appletName:e.appKey,appletHost:e.hostUrl,appletType:e.appletType,isSigned:e.isSigned,isEncrypted:e.isEncrypted},e.versionTag?{versionTag:e.versionTag}:{}),e.isSigned&&e.signPublicKeyVersion?{signPublicKeyVersion:e.signPublicKeyVersion}:{}),!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}))}});return null==s?void 0:s.data})}(u,function(e){return({method:t,url:n,data:a,headers:d})=>r.__awaiter(this,void 0,void 0,function*(){try{let r,i=Object.entries(Object.assign(Object.assign({},void 0===a?{}:{"Content-Type":"application/json"}),d)).reduce((e,[t,n])=>("string"==typeof n&&(e[t]=n),e),{}),l=yield(e?o.withAuth(fetch,e):(!s&&(s=o.withAuth()),s))(n,{method:t,headers:i,body:void 0===a?void 0:JSON.stringify(a)}),c=yield l.text();if(c)try{r=JSON.parse(c)}catch(e){r=c}if(!l.ok)throw Error(`Authed request failed with HTTP ${l.status}${c?`: ${c}`:""}`);return{data:r,status:l.status,headers:l.headers}}catch(e){throw e instanceof o.NotLoggedInError?new i("NOT_LOGGED_IN","No open-platform login session is available. Please run dbx auth:login first, then retry."):e instanceof o.TokenExpiredError?new i("TOKEN_EXPIRED","The open-platform login session has expired. Please run dbx auth:login again, then retry."):e instanceof o.AuthError?new i("AUTH_FAILED",`Open-platform authentication failed: ${e.message}`):e instanceof Error?e:Error(String(e))}})}(e.authOptions));if(!p||0!==p.code){let e=(null==p?void 0:p.code)===void 0?"unknown":String(p.code);if((null==p?void 0:p.code)===0x2fb1793)throw new i("APP_ROLE_PERMISSION_REQUIRED",`真机调试授权失败:当前账号没有工程所配置智能服务的角色权限。
1
+ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{external_node_stream_promises_namespaceObject as t,getApiBaseUrl as n,getAuthOptions as r,version_version as o,isRecord as i,command_Command as s,option_Option as a,runCommand as d,chalk_source as l}from"./8713.js";import{DEV_ACTIONS as c,ensureDevActionSucceeded as u,summarizeData as p,parseJsonData as h,DEV_EVENTS as f,connectDevService as m,ServiceManager as g,startForegroundDevService as y}from"./dev-service-client.js";import{listMiniAppVersions as _}from"./app.js";import{openUrlInBrowser as b}from"./browser.js";import{resolveDevSimulatorPaths as w,prepareDevBusinessTemplates as v,normalizeLoopbackUrl as E,prepareDevManifest as I,resolveDevMcpEndpoint as T,formatFinalDevWarnings as A}from"./dev-config.js";import{resolveProjectLayout as C}from"./project-layout.js";import{extractMCPHeadersFromManifest as j}from"./manifest-mcp-config.js";import{createKitDevOptions as k}from"./kit-dev-options.js";import"./180.js";import"./3551.js";e.add({"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"(e,t,n){t.Ph=void 0;var r=n("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js");Object.defineProperty(t,"Ph",{enumerable:!0,get:function(){return r.createRealDeviceDebugQRCodeValue}})},"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js"(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.createRealDeviceDebugQRCodeValue=t.REAL_DEVICE_DEBUG_QR_ACTION=t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL=void 0;let r=n("../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"),o=r.__importStar(n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"));t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL="https://hello.doubao-dev.com",t.REAL_DEVICE_DEBUG_QR_ACTION="start_real_device_debug";class i extends Error{constructor(e,t){super(t),this.name="RealDeviceDebugAuthError",this.code=e}}let s=null;function a(e,t){let n=e.trim();if(!n)throw Error(t);return n}t.createRealDeviceDebugQRCodeValue=function(e){var n,d,l;return r.__awaiter(this,void 0,void 0,function*(){var c;let u=Object.assign(Object.assign({hostUrl:a(e.hostUrl,"hostUrl is required to request real-device debug ticket"),appKey:a(e.appKey,"appKey is required to request real-device debug ticket"),isSigned:e.isSigned,isEncrypted:!!e.isEncrypted,signPublicKeyVersion:null==(n=e.signPublicKeyVersion)?void 0:n.trim(),versionTag:(c=e.versionTag,void 0===c?void 0:a(c,"versionTag must not be empty")),appletType:e.appletType,baseApiUrl:e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL},!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}),p=yield function(e,n){return r.__awaiter(this,void 0,void 0,function*(){var r;let o,i=(r=e.appKey,o=a(e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL,"baseApiUrl is required to request real-device debug ticket"),new URL(`/developer/check_api/apps/${encodeURIComponent(r)}/debug/ticket`,o).toString()),s=yield n({method:"POST",url:i,data:{debug_context:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({appletName:e.appKey,appletHost:e.hostUrl,appletType:e.appletType,isSigned:e.isSigned,isEncrypted:e.isEncrypted},e.versionTag?{versionTag:e.versionTag}:{}),e.isSigned&&e.signPublicKeyVersion?{signPublicKeyVersion:e.signPublicKeyVersion}:{}),!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}))}});return null==s?void 0:s.data})}(u,function(e){return({method:t,url:n,data:a,headers:d})=>r.__awaiter(this,void 0,void 0,function*(){try{let r,i=Object.entries(Object.assign(Object.assign({},void 0===a?{}:{"Content-Type":"application/json"}),d)).reduce((e,[t,n])=>("string"==typeof n&&(e[t]=n),e),{}),l=yield(e?o.withAuth(fetch,e):(!s&&(s=o.withAuth()),s))(n,{method:t,headers:i,body:void 0===a?void 0:JSON.stringify(a)}),c=yield l.text();if(c)try{r=JSON.parse(c)}catch(e){r=c}if(!l.ok)throw Error(`Authed request failed with HTTP ${l.status}${c?`: ${c}`:""}`);return{data:r,status:l.status,headers:l.headers}}catch(e){throw e instanceof o.NotLoggedInError?new i("NOT_LOGGED_IN","No open-platform login session is available. Please run dbx auth:login first, then retry."):e instanceof o.TokenExpiredError?new i("TOKEN_EXPIRED","The open-platform login session has expired. Please run dbx auth:login again, then retry."):e instanceof o.AuthError?new i("AUTH_FAILED",`Open-platform authentication failed: ${e.message}`):e instanceof Error?e:Error(String(e))}})}(e.authOptions));if(!p||0!==p.code){let e=(null==p?void 0:p.code)===void 0?"unknown":String(p.code);if((null==p?void 0:p.code)===0x2fb1793)throw new i("APP_ROLE_PERMISSION_REQUIRED",`真机调试授权失败:当前账号没有工程所配置智能服务的角色权限。
2
2
  工程 AppKey:${u.appKey}
3
3
  请先检查本地工程的 app_key 是否正确,且不是 mock 或占位值;该 AppKey 应属于你有权限的智能服务。
4
4
  权限开通:进入豆包开发者平台 → 对应智能服务 → 成员管理,请应用管理员邀请你的账号并授予开发或调试权限。
@@ -6,12 +6,12 @@ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";imp
6
6
  工程 AppKey:${u.appKey}
7
7
  请先检查本地工程的 app_key 是否正确,且不是 mock 或占位值;该 AppKey 应属于你要调试的智能服务。
8
8
  权限配置:进入豆包开发者平台 → 对应智能服务 → 白名单配置,添加真机调试所需权限后重试。
9
- 错误码:${e}`);let t=(null==p?void 0:p.message)||"Failed to get debug ticket";throw Error(`${t} (code=${e}, appKey=${u.appKey}, baseApiUrl=${u.baseApiUrl})`)}let h=String((null==(d=p.data)?void 0:d.debug_token)||"").trim(),f=String((null==(l=p.data)?void 0:l.encrypted_debug_payload)||"").trim();if(!h||!f)throw Error("Debug ticket response is missing required fields");return{qrCodeValue:JSON.stringify({action:t.REAL_DEVICE_DEBUG_QR_ACTION,debug_token:h,encrypted_debug_payload:f}),debugToken:h,encryptedDebugPayload:f}})}},"../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(e){var t={single_source_shortest_paths:function(e,n,r){var o,i,s,a,d,l,c,u={},p={};p[n]=0;var h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(s in i=(o=h.pop()).value,a=o.cost,d=e[i]||{})d.hasOwnProperty(s)&&(l=a+d[s],c=p[s],(void 0===p[s]||c>l)&&(p[s]=l,h.push(s,l),u[s]=i));if(void 0!==r&&void 0===p[r])throw Error(["Could not find a path from ",n," to ",r,"."].join(""));return u},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var o=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,o={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=e.sorter||r.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){this.queue.push({value:e,cost:t}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=[function(){},function(e,t,n,r){if(r===t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],i=[function(){},function(e,t,n,r){let o=t[0];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];t.dataToBitMap=function(e,t){let n,s,a,d,l,c,u=t.width,p=t.height,h=t.depth,f=t.bpp,m=t.interlace;8!==h&&(n=[],s=0,a={get:function(t){for(;n.length<t;)!function(){let t,r,o,i;if(s===e.length)throw Error("Ran out of data");let a=e[s];switch(s++,h){default:throw Error("unrecognised depth");case 16:o=e[s],s++,n.push((a<<8)+o);break;case 4:o=15&a,i=a>>4,n.push(i,o);break;case 2:t=3&a,r=a>>2&3,o=a>>4&3,i=a>>6&3,n.push(i,o,r,t);break;case 1:t=a>>4&1,r=a>>5&1,o=a>>6&1,i=a>>7&1,n.push(i,o,r,t,a>>3&1,a>>2&1,a>>1&1,1&a)}}();let r=n.slice(0,t);return n=n.slice(t),r},resetAfterLine:function(){n.length=0},end:function(){if(s!==e.length)throw Error("extra data found")}}),d=h<=8?Buffer.alloc(u*p*4):new Uint16Array(u*p*4);let g=Math.pow(2,h)-1,y=0;if(m)l=r.getImagePasses(u,p),c=r.getInterlaceIterator(u,p);else{let e=0;c=function(){let t=e;return e+=4,t},l=[{width:u,height:p}]}for(let t=0;t<l.length;t++)8===h?y=function(e,t,n,r,i,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++)for(let d=0;d<a;d++){let a=n(d,e,l);o[r](t,i,a,s),s+=r}return s}(l[t],d,c,f,e,y):function(e,t,n,r,o,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++){for(let d=0;d<a;d++){let a=o.get(r),c=n(d,e,l);i[r](t,a,c,s)}o.resetAfterLine()}}(l[t],d,c,f,a,g);if(8===h){if(y!==e.length)throw Error("extra data found")}else a.end();return d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js");e.exports=function(e,t,n,o){let i=-1!==[r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(o.colorType);if(o.colorType===o.inputColorType){let t,n=(new DataView(t=new ArrayBuffer(2)).setInt16(0,256,!0),256!==new Int16Array(t)[0]);if(8===o.bitDepth||16===o.bitDepth&&n)return e}let s=16!==o.bitDepth?e:new Uint16Array(e.buffer),a=255,d=r.COLORTYPE_TO_BPP_MAP[o.inputColorType];4!==d||o.inputHasAlpha||(d=3);let l=r.COLORTYPE_TO_BPP_MAP[o.colorType];16===o.bitDepth&&(a=65535,l*=2);let c=Buffer.alloc(t*n*l),u=0,p=0,h=o.bgColor||{};void 0===h.red&&(h.red=a),void 0===h.green&&(h.green=a),void 0===h.blue&&(h.blue=a);for(let e=0;e<n;e++)for(let e=0;e<t;e++){let e=function(){let e,t,n,d=a;switch(o.inputColorType){case r.COLORTYPE_COLOR_ALPHA:d=s[u+3],e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_COLOR:e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_ALPHA:d=s[u+1],t=e=s[u],n=e;break;case r.COLORTYPE_GRAYSCALE:t=e=s[u],n=e;break;default:throw Error("input color type:"+o.inputColorType+" is not supported at present")}return o.inputHasAlpha&&!i&&(d/=a,e=Math.min(Math.max(Math.round((1-d)*h.red+d*e),0),a),t=Math.min(Math.max(Math.round((1-d)*h.green+d*t),0),a),n=Math.min(Math.max(Math.round((1-d)*h.blue+d*n),0),a)),{red:e,green:t,blue:n,alpha:d}}();switch(o.colorType){case r.COLORTYPE_COLOR_ALPHA:case r.COLORTYPE_COLOR:8===o.bitDepth?(c[p]=e.red,c[p+1]=e.green,c[p+2]=e.blue,i&&(c[p+3]=e.alpha)):(c.writeUInt16BE(e.red,p),c.writeUInt16BE(e.green,p+2),c.writeUInt16BE(e.blue,p+4),i&&c.writeUInt16BE(e.alpha,p+6));break;case r.COLORTYPE_ALPHA:case r.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;8===o.bitDepth?(c[p]=t,i&&(c[p+1]=e.alpha)):(c.writeUInt16BE(t,p),i&&c.writeUInt16BE(e.alpha,p+2));break}default:throw Error("unrecognised color Type "+o.colorType)}u+=d,p+=l}return c}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"(e,t,n){let r=n("util"),o=n("stream"),i=e.exports=function(){o.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};r.inherits(i,o),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},i.prototype.write=function(e,t){let n;return this.writable?(n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let o=this._buffers[n++],i=Math.min(o.length,e.length-t);o.copy(r,t,0,i),t+=i,i!==o.length&&(this._buffers[--n]=o.slice(i))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"(e){e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"(e){let t=[];for(let e=0;e<256;e++){let n=e;for(let e=0;e<8;e++)1&n?n=0xedb88320^n>>>1:n>>>=1;t[e]=n}let n=e.exports=function(){this._crc=-1};n.prototype.write=function(e){for(let n=0;n<e.length;n++)this._crc=t[(this._crc^e[n])&255]^this._crc>>>8;return!0},n.prototype.crc32=function(){return -1^this._crc},n.crc32=function(e){let n=-1;for(let r=0;r<e.length;r++)n=t[(n^e[r])&255]^n>>>8;return -1^n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"),o={0:function(e,t,n,r,o){for(let i=0;i<n;i++)r[o+i]=e[t+i]},1:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let n=s>=i?e[t+s-i]:0,a=e[t+s]-n;r[o+s]=a}},2:function(e,t,n,r,o){for(let i=0;i<n;i++){let s=t>0?e[t+i-n]:0,a=e[t+i]-s;r[o+i]=a}},3:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let a=s>=i?e[t+s-i]:0,d=t>0?e[t+s-n]:0,l=e[t+s]-(a+d>>1);r[o+s]=l}},4:function(e,t,n,o,i,s){for(let a=0;a<n;a++){let d=a>=s?e[t+a-s]:0,l=t>0?e[t+a-n]:0,c=t>0&&a>=s?e[t+a-(n+s)]:0,u=e[t+a]-r(d,l,c);o[i+a]=u}}},i={0:function(e,t,n){let r=0,o=t+n;for(let n=t;n<o;n++)r+=Math.abs(e[n]);return r},1:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let n=i>=r?e[t+i-r]:0;o+=Math.abs(e[t+i]-n)}return o},2:function(e,t,n){let r=0,o=t+n;for(let i=t;i<o;i++){let o=t>0?e[i-n]:0;r+=Math.abs(e[i]-o)}return r},3:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let s=i>=r?e[t+i-r]:0,a=t>0?e[t+i-n]:0;o+=Math.abs(e[t+i]-(s+a>>1))}return o},4:function(e,t,n,o){let i=0;for(let s=0;s<n;s++){let a=s>=o?e[t+s-o]:0,d=t>0?e[t+s-n]:0,l=t>0&&s>=o?e[t+s-(n+o)]:0;i+=Math.abs(e[t+s]-r(a,d,l))}return i}};e.exports=function(e,t,n,r,s){let a;if("filterType"in r&&-1!==r.filterType)if("number"==typeof r.filterType)a=[r.filterType];else throw Error("unrecognised filter types");else a=[0,1,2,3,4];16===r.bitDepth&&(s*=2);let d=t*s,l=0,c=0,u=Buffer.alloc((d+1)*n),p=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=i[a[n]](e,c,d,s);r<t&&(p=a[n],t=r)}}u[l]=p,l++,o[p](e,c,d,u,l,s),l+=d,c+=d}return u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"(e,t,n){let r=n("util"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"),s=e.exports=function(e){o.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit("complete",Buffer.concat(t))}}),this._filter.start()};r.inherits(s,o)},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js");t.process=function(e,t){let n=[],i=new r(e);return new o(t,{read:i.read.bind(i),write:function(e){n.push(e)},complete:function(){}}).start(),i.process(),Buffer.concat(n)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js");function i(e,t,n){let r=e*t;return 8!==n&&(r=Math.ceil(r/(8/n))),r}let s=e.exports=function(e,t){let n=e.width,o=e.height,s=e.interlace,a=e.bpp,d=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],s){let e=r.getImagePasses(n,o);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,a,d),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(n,a,d),height:o,lineIndex:0});8===d?this._xComparison=a:16===d?this._xComparison=2*a:this._xComparison=1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,o=r-1;for(let i=0;i<n;i++){let n=e[1+i],s=i>o?t[i-r]:0;t[i]=n+s}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],i=r?r[o]:0;t[o]=n+i}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,o=r-1,i=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],a=i?i[s]:0,d=Math.floor(((s>o?t[s-r]:0)+a)/2);t[s]=n+d}},s.prototype._unFilterType4=function(e,t,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let a=0;a<n;a++){let n=e[1+a],d=s?s[a]:0,l=o(a>i?t[a-r]:0,d,a>i&&s?s[a-r]:0);t[a]=n+l}},s.prototype._reverseFilterLine=function(e){let t,n=e[0],r=this._images[this._imageIndex],o=r.byteWidth;if(0===n)t=e.slice(1,o+1);else switch(t=Buffer.alloc(o),n){case 1:this._unFilterType1(e,t,o);break;case 2:this._unFilterType2(e,t,o);break;case 3:this._unFilterType3(e,t,o);break;case 4:this._unFilterType4(e,t,o);break;default:throw Error("Unrecognised filter type - "+n)}this.write(t),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=t,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"(e){e.exports=function(e,t){let n=t.depth,r=t.width,o=t.height,i=t.colorType,s=t.transColor,a=t.palette,d=e;return 3===i?!function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=o[e[i]];if(!n)throw Error("index "+e[i]+" not in palette");for(let e=0;e<4;e++)t[i+e]=n[e];i+=4}}(e,d,r,o,a):(s&&function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=!1;if(1===o.length?o[0]===e[i]&&(n=!0):o[0]===e[i]&&o[1]===e[i+1]&&o[2]===e[i+2]&&(n=!0),n)for(let e=0;e<4;e++)t[i+e]=0;i+=4}}(e,d,r,o,s),8!==n&&(16===n&&(d=Buffer.alloc(r*o*4)),!function(e,t,n,r,o){let i=Math.pow(2,o)-1,s=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[s+n]=Math.floor(255*e[s+n]/i+.5);s+=4}}(e,d,r,o,n))),d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"(e,t){let n=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];t.getImagePasses=function(e,t){let r=[],o=e%8,i=t%8,s=(e-o)/8,a=(t-i)/8;for(let e=0;e<n.length;e++){let t=n[e],d=s*t.x.length,l=a*t.y.length;for(let e=0;e<t.x.length;e++)if(t.x[e]<o)d++;else break;for(let e=0;e<t.y.length;e++)if(t.y[e]<i)l++;else break;d>0&&l>0&&r.push({width:d,height:l,index:e})}return r},t.getInterlaceIterator=function(e){return function(t,r,o){let i=t%n[o].x.length,s=(t-i)/n[o].x.length*8+n[o].x[i],a=r%n[o].y.length;return 4*s+((r-a)/n[o].y.length*8+n[o].y[a])*e*4}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"),a=e.exports=function(e){o.call(this),this._packer=new s(e||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(a,o),a.prototype.pack=function(e,t,n,r){this.emit("data",Buffer.from(i.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,n)),r&&this.emit("data",this._packer.packGAMA(r));let o=this._packer.filterData(e,t,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(e){this.emit("data",this._packer.packIDAT(e))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(o)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js"(e,t,n){let r=!0,o=n("zlib");o.deflateSync||(r=!1);let i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js");e.exports=function(e,t){if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new s(t||{}),a=[];a.push(Buffer.from(i.PNG_SIGNATURE)),a.push(n.packIHDR(e.width,e.height)),e.gamma&&a.push(n.packGAMA(e.gamma));let d=n.filterData(e.data,e.width,e.height),l=o.deflateSync(d,n.getDeflateOptions());if(d=null,!l||!l.length)throw Error("bad png - invalid compressed data response");return a.push(n.packIDAT(l)),a.push(n.packIEND()),Buffer.concat(a)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"),a=n("zlib"),d=e.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=null!=e.deflateLevel?e.deflateLevel:9,e.deflateStrategy=null!=e.deflateStrategy?e.deflateStrategy:3,e.inputHasAlpha=null==e.inputHasAlpha||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||a.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType="number"==typeof e.colorType?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType="number"==typeof e.inputColorType?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType))throw Error("option color type:"+e.colorType+" is not supported at present");if(-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType))throw Error("option input color type:"+e.inputColorType+" is not supported at present");if(8!==e.bitDepth&&16!==e.bitDepth)throw Error("option bit depth:"+e.bitDepth+" is not supported at present")};d.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},d.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},d.prototype.filterData=function(e,t,n){let o=i(e,t,n,this._options),a=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return s(o,t,n,this._options,a)},d.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(o.crc32(r.slice(4,r.length-4)),r.length-4),r},d.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},d.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},d.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},d.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"(e){e.exports=function(e,t,n){let r=e+t-n,o=Math.abs(r-e),i=Math.abs(r-t),s=Math.abs(r-n);return o<=i&&o<=s?e:i<=s?t:n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"(e,t,n){let r=n("util"),o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"),c=e.exports=function(e){i.call(this),this._parser=new a(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};r.inherits(c,i),c.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},c.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=o.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,o.Z_MIN_CHUNK);this._inflate=o.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,"error");this._inflate.on("error",function(e){n&&r(e)}),this._filter.on("complete",this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on("data",function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)},c.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new s(this._bitmapInfo)},c.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},c.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},c.prototype._simpleTransparency=function(){this._metaData.alpha=!0},c.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},c.prototype._complete=function(e){let t;if(!this.errord){try{let n=d.dataToBitMap(e,this._bitmapInfo);t=l(n,this._bitmapInfo),n=null}catch(e){this._handleError(e);return}this.emit("parsed",t)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"(e,t,n){let r=!0,o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js");o.deflateSync||(r=!1);let s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),c=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js");e.exports=function(e,t){let n,u,p,h;if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let f=[],m=new s(e);if(new d(t,{read:m.read.bind(m),error:function(e){n=e},metadata:function(e){u=e},gamma:function(e){p=e},palette:function(e){u.palette=e},transColor:function(e){u.transColor=e},inflateData:function(e){f.push(e)},simpleTransparency:function(){u.alpha=!0}}).start(),m.process(),n)throw n;let g=Buffer.concat(f);if(f.length=0,u.interlace)h=o.inflateSync(g);else{let e=((u.width*u.bpp*u.depth+7>>3)+1)*u.height;h=i(g,{chunkSize:e,maxLength:e})}if(g=null,!h||!h.length)throw Error("bad png - invalid inflate data response");let y=a.process(h,u);g=null;let _=l.dataToBitMap(y,u);y=null;let b=c(_,u);return u.data=b,u.gamma=p||0,u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=e.exports=function(e,t){this._options=e,e.checkCRC=!1!==e.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=r.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return void this.error(Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),n=e.readUInt32BE(4),i="";for(let t=4;t<8;t++)i+=String.fromCharCode(e[t]);let s=!!(32&e[4]);return this._hasIHDR||n===r.TYPE_IHDR?(this._crc=new o,this._crc.write(Buffer.from(i)),this._chunks[n])?this._chunks[n](t):s?void this.read(t+4,this._skipChunk.bind(this)):void this.error(Error("Unsupported critical chunk type "+i)):void this.error(Error("Expected IHDR on beggining"))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==t?this.error(Error("Crc error - "+t+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),o=e[8],i=e[9],s=e[10],a=e[11],d=e[12];if(8!==o&&4!==o&&2!==o&&1!==o&&16!==o)return void this.error(Error("Unsupported bit depth "+o));if(!(i in r.COLORTYPE_TO_BPP_MAP))return void this.error(Error("Unsupported color type"));if(0!==s)return void this.error(Error("Unsupported compression method"));if(0!==a)return void this.error(Error("Unsupported filter method"));if(0!==d&&1!==d)return void this.error(Error("Unsupported interlace method"));this._colorType=i;let l=r.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:n,depth:o,interlace:!!d,palette:!!(i&r.COLORTYPE_PALETTE),color:!!(i&r.COLORTYPE_COLOR),alpha:!!(i&r.COLORTYPE_ALPHA),bpp:l,colorType:i}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[3*n],e[3*n+1],e[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===r.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(Error("Transparency chunk must be after palette"));if(e.length>this._palette.length)return void this.error(Error("More transparent colors than palette size"));for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===r.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===r.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/r.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===r.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw Error("Expected palette not found");this.inflateData(t);let n=e-t.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js");t.read=function(e,t){return r(e,t||{})},t.write=function(e,t){return o(e,t)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"),d=t.O=function(e){o.call(this),e=e||{},this.width=0|e.width,this.height=0|e.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(e){this.data=e,this.emit("parsed",e)}).bind(this)),this._packer=new s(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};r.inherits(d,o),d.sync=a,d.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},d.prototype.parse=function(e,t){if(t){let e,n;e=(function(e){this.removeListener("error",n),this.data=e,t(null,this)}).bind(this),n=(function(n){this.removeListener("parsed",e),t(n,null)}).bind(this),this.once("parsed",e),this.once("error",n)}return this.end(e),this},d.prototype.write=function(e){return this._parser.write(e),!0},d.prototype.end=function(e){this._parser.end(e)},d.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)},d.prototype._gamma=function(e){this.gamma=e},d.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},d.bitblt=function(e,t,n,r,o,i,s,a){if(r|=0,o|=0,i|=0,s|=0,a|=0,(n|=0)>e.width||r>e.height||n+o>e.width||r+i>e.height)throw Error("bitblt reading outside image");if(s>t.width||a>t.height||s+o>t.width||a+i>t.height)throw Error("bitblt writing outside image");for(let d=0;d<i;d++)e.data.copy(t.data,(a+d)*t.width+s<<2,(r+d)*e.width+n<<2,(r+d)*e.width+n+o<<2)},d.prototype.bitblt=function(e,t,n,r,o,i,s){return d.bitblt(this,e,t,n,r,o,i,s),this},d.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[r+t]=Math.round(255*n)}}e.gamma=0}},d.prototype.adjustGamma=function(){d.adjustGamma(this)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js"(e,t,n){let r=n("assert").ok,o=n("zlib"),i=n("util"),s=n("buffer").kMaxLength;function a(e){if(!(this instanceof a))return new a(e);e&&e.chunkSize<o.Z_MIN_CHUNK&&(e.chunkSize=o.Z_MIN_CHUNK),o.Inflate.call(this,e),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&null!=e.maxLength&&(this._maxLength=e.maxLength)}function d(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}function l(e,t){var n=new a(t),r=e;if("string"==typeof r&&(r=Buffer.from(r)),!(r instanceof Buffer))throw TypeError("Not a string or buffer");let i=n._finishFlushFlag;return null==i&&(i=o.Z_FINISH),n._processChunk(r,i)}a.prototype._processChunk=function(e,t,n){let i,a;if("function"==typeof n)return o.Inflate._processChunk.call(this,e,t,n);let l=this,c=e&&e.length,u=this._chunkSize-this._offset,p=this._maxLength,h=0,f=[],m=0;this.on("error",function(e){i=e}),r(this._handle,"zlib binding closed");do a=(a=this._handle.writeSync(t,e,h,c,this._buffer,this._offset,u))||this._writeState;while(!this._hadError&&function(e,t){if(l._hadError)return;let n=u-t;if(r(n>=0,"have should not go down"),n>0){let e=l._buffer.slice(l._offset,l._offset+n);if(l._offset+=n,e.length>p&&(e=e.slice(0,p)),f.push(e),m+=e.length,0==(p-=e.length))return!1}return(0===t||l._offset>=l._chunkSize)&&(u=l._chunkSize,l._offset=0,l._buffer=Buffer.allocUnsafe(l._chunkSize)),0===t&&(h+=c-e,c=e,!0)}(a[0],a[1]));if(this._hadError)throw i;if(m>=s)throw d(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+s.toString(16)+" bytes");let g=Buffer.concat(f,m);return d(this),g},i.inherits(a,o.Inflate),e.exports=t=l,t.Inflate=a,t.createInflate=function(e){return new a(e)},t.inflateSync=l},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"(e){let t=e.exports=function(e){this._buffer=e,this._reads=[]};t.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},t.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js");function a(e,t,n,i,s){let a=[].slice.call(arguments,1),d=a.length,l="function"==typeof a[d-1];if(!l&&!r())throw Error("Callback required as last argument");if(l){if(d<2)throw Error("Too few arguments provided");2===d?(s=n,n=t,t=i=void 0):3===d&&(t.getContext&&void 0===s?(s=i,i=void 0):(s=i,i=n,n=t,t=void 0))}else{if(d<1)throw Error("Too few arguments provided");return 1===d?(n=t,t=i=void 0):2!==d||t.getContext||(i=n,n=t,t=void 0),new Promise(function(r,s){try{let s=o.create(n,i);r(e(s,t,i))}catch(e){s(e)}})}try{let r=o.create(n,i);s(null,e(r,t,i))}catch(e){s(e)}}o.create,a.bind(null,i.render),a.bind(null,i.renderToDataURL),a.bind(null,function(e,t,n){return s.render(e,n)})},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(e){e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getRowColCoords=function(e){if(1===e)return[];let t=Math.floor(e/7)+2,n=r(e),o=145===n?26:2*Math.ceil((n-13)/(2*t-2)),i=[n-7];for(let e=1;e<t-1;e++)i[e]=i[e-1]-o;return i.push(6),i.reverse()},t.getPositions=function(e){let n=[],r=t.getRowColCoords(e),o=r.length;for(let e=0;e<o;e++)for(let t=0;t<o;t++)(0!==e||0!==t)&&(0!==e||t!==o-1)&&(e!==o-1||0!==t)&&n.push([r[e],r[t]]);return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(e){this.mode=r.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*o.indexOf(this.data[t]);n+=o.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(o.indexOf(this.data[t]),6)},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(e){function t(){this.buffer=[],this.length=0}t.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(e){function t(e){if(!e||e<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}t.prototype.set=function(e,t,n,r){let o=e*this.size+t;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(e,t){return this.data[e*this.size+t]},t.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},t.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.BYTE,"string"==typeof e?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}o.getBitsLength=function(e){return 8*e},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(e,t){switch(t){case r.L:return o[(e-1)*4+0];case r.M:return o[(e-1)*4+1];case r.Q:return o[(e-1)*4+2];case r.H:return o[(e-1)*4+3];default:return}},t.getTotalCodewordsCount=function(e,t){switch(t){case r.L:return i[(e-1)*4+0];case r.M:return i[(e-1)*4+1];case r.Q:return i[(e-1)*4+2];case r.H:return i[(e-1)*4+3];default:return}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(e,t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw Error("Unknown EC Level: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getPositions=function(e){let t=r(e);return[[0,0],[t-7,0],[0,t-7]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=r.getBCHDigit(1335);t.getEncodedBits=function(e,t){let n=e.bit<<3|t,i=n<<10;for(;r.getBCHDigit(i)-o>=0;)i^=1335<<r.getBCHDigit(i)-o;return(n<<10|i)^21522}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(e,t){let n=new Uint8Array(512),r=new Uint8Array(256),o=1;for(let e=0;e<255;e++)n[e]=o,r[o]=e,256&(o<<=1)&&(o^=285);for(let e=255;e<512;e++)n[e]=n[e-255];t.exp=function(e){return n[e]},t.mul=function(e,t){return 0===e||0===t?0:n[r[e]+r[t]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js");function i(e){this.mode=r.KANJI,this.data=e}i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=o.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n=(n>>>8&255)*192+(255&n),e.put(n,13)}},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(e,t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};t.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){let t=e.size,n=0,r=0,o=0,i=null,s=null;for(let a=0;a<t;a++){r=o=0,i=s=null;for(let d=0;d<t;d++){let t=e.get(a,d);t===i?r++:(r>=5&&(n+=3+(r-5)),i=t,r=1),(t=e.get(d,a))===s?o++:(o>=5&&(n+=3+(o-5)),s=t,o=1)}r>=5&&(n+=3+(r-5)),o>=5&&(n+=3+(o-5))}return n},t.getPenaltyN2=function(e){let t=e.size,n=0;for(let r=0;r<t-1;r++)for(let o=0;o<t-1;o++){let t=e.get(r,o)+e.get(r,o+1)+e.get(r+1,o)+e.get(r+1,o+1);(4===t||0===t)&&n++}return 3*n},t.getPenaltyN3=function(e){let t=e.size,n=0,r=0,o=0;for(let i=0;i<t;i++){r=o=0;for(let s=0;s<t;s++)r=r<<1&2047|e.get(i,s),s>=10&&(1488===r||93===r)&&n++,o=o<<1&2047|e.get(s,i),s>=10&&(1488===o||93===o)&&n++}return 40*n},t.getPenaltyN4=function(e){let t=0,n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return 10*Math.abs(Math.ceil(100*t/n/5)-10)},t.applyMask=function(e,n){let r=n.size;for(let o=0;o<r;o++)for(let i=0;i<r;i++)n.isReserved(i,o)||n.xor(i,o,function(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error("bad maskPattern:"+e)}}(e,i,o))},t.getBestMask=function(e,n){let r=Object.keys(t.Patterns).length,o=0,i=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);let r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<i&&(i=r,o=s)}return o}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js");t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(e,t){if(!e.ccBits)throw Error("Invalid mode: "+e);if(!r.isValid(t))throw Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]},t.getBestModeForData=function(e){return o.testNumeric(e)?t.NUMERIC:o.testAlphanumeric(e)?t.ALPHANUMERIC:o.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(e){if(e&&e.id)return e.id;throw Error("Invalid mode")},t.isValid=function(e){return e&&e.bit&&e.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw Error("Unknown mode: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.NUMERIC,this.data=e.toString()}o.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let t,n;for(t=0;t+3<=this.data.length;t+=3)n=parseInt(this.data.substr(t,3),10),e.put(n,10);let r=this.data.length-t;r>0&&(n=parseInt(this.data.substr(t),10),e.put(n,3*r+1))},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js");t.mul=function(e,t){let n=new Uint8Array(e.length+t.length-1);for(let o=0;o<e.length;o++)for(let i=0;i<t.length;i++)n[o+i]^=r.mul(e[o],t[i]);return n},t.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){let e=n[0];for(let o=0;o<t.length;o++)n[o]^=r.mul(t[o],e);let o=0;for(;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},t.generateECPolynomial=function(e){let n=new Uint8Array([1]);for(let o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"),c=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),u=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"),p=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"),h=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"),f=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),m=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js");function g(e,t,n){let r,o,i=e.size,s=h.getEncodedBits(t,n);for(r=0;r<15;r++)o=(s>>r&1)==1,r<6?e.set(r,8,o,!0):r<8?e.set(r+1,8,o,!0):e.set(i-15+r,8,o,!0),r<8?e.set(8,i-r-1,o,!0):r<9?e.set(8,15-r-1+1,o,!0):e.set(8,15-r-1,o,!0);e.set(i-8,8,1,!0)}t.create=function(e,t){let n,h;if(void 0===e||""===e)throw Error("No input text");let y=o.M;return void 0!==t&&(y=o.from(t.errorCorrectionLevel,o.M),n=p.from(t.version),h=l.from(t.maskPattern),t.toSJISFunc&&r.setToSJISFunction(t.toSJISFunc)),function(e,t,n,o){let h;if(Array.isArray(e))h=m.fromArray(e);else if("string"==typeof e){let r=t;if(!r){let t=m.rawSplit(e);r=p.getBestVersionForData(t,n)}h=m.fromString(e,r||40)}else throw Error("Invalid data");let y=p.getBestVersionForData(h,n);if(!y)throw Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<y)throw Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+y+".\n")}else t=y;let _=function(e,t,n){let o=new i;n.forEach(function(t){o.put(t.mode.bit,4),o.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(o)});let s=(r.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,t))*8;for(o.getLengthInBits()+4<=s&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);let a=(s-o.getLengthInBits())/8;for(let e=0;e<a;e++)o.put(e%2?17:236,8);return function(e,t,n){let o,i,s=r.getSymbolTotalCodewords(t),a=s-c.getTotalCodewordsCount(t,n),d=c.getBlocksCount(t,n),l=s%d,p=d-l,h=Math.floor(s/d),f=Math.floor(a/d),m=f+1,g=h-f,y=new u(g),_=0,b=Array(d),w=Array(d),v=0,E=new Uint8Array(e.buffer);for(let e=0;e<d;e++){let t=e<p?f:m;b[e]=E.slice(_,_+t),w[e]=y.encode(b[e]),_+=t,v=Math.max(v,t)}let I=new Uint8Array(s),T=0;for(o=0;o<v;o++)for(i=0;i<d;i++)o<b[i].length&&(I[T++]=b[i][o]);for(o=0;o<g;o++)for(i=0;i<d;i++)I[T++]=w[i][o];return I}(o,e,t)}(t,n,h),b=new s(r.getSymbolSize(t));!function(e,t){let n=e.size,r=d.getPositions(t);for(let t=0;t<r.length;t++){let o=r[t][0],i=r[t][1];for(let t=-1;t<=7;t++)if(!(o+t<=-1)&&!(n<=o+t))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(o+t,i+r,!0,!0):e.set(o+t,i+r,!1,!0))}}(b,t);let w=b.size;for(let e=8;e<w-8;e++){let t=e%2==0;b.set(e,6,t,!0),b.set(6,e,t,!0)}return!function(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],o=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,o+n,!0,!0):e.set(r+t,o+n,!1,!0)}}(b,t),g(b,n,0),t>=7&&function(e,t){let n,r,o,i=e.size,s=p.getEncodedBits(t);for(let t=0;t<18;t++)n=Math.floor(t/3),r=t%3+i-8-3,o=(s>>t&1)==1,e.set(n,r,o,!0),e.set(r,n,o,!0)}(b,t),!function(e,t){let n=e.size,r=-1,o=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(o,a-n)){let r=!1;s<t.length&&(r=(t[s]>>>i&1)==1),e.set(o,a-n,r),-1==--i&&(s++,i=7)}if((o+=r)<0||n<=o){o-=r,r=-r;break}}}(b,_),isNaN(o)&&(o=l.getBestMask(b,g.bind(null,b,n))),l.applyMask(o,b),g(b,n,o),{modules:b,version:t,errorCorrectionLevel:n,maskPattern:o,segments:h}}(e,n,y,h)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js");function o(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let n=r.mod(t,this.genPoly),o=this.degree-n.length;if(o>0){let e=new Uint8Array(this.degree);return e.set(n,o),e}return n},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(e,t){let n="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",o="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=RegExp(r,"g"),t.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=RegExp(o,"g"),t.NUMERIC=RegExp(n,"g"),t.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let i=RegExp("^"+r+"$"),s=RegExp("^"+n+"$"),a=RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(e){return i.test(e)},t.testNumeric=function(e){return s.test(e)},t.testAlphanumeric=function(e){return a.test(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),c=n("../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js");function u(e){return unescape(encodeURIComponent(e)).length}function p(e,t,n){let r,o=[];for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function h(e){let t,n,o=p(d.NUMERIC,r.NUMERIC,e),i=p(d.ALPHANUMERIC,r.ALPHANUMERIC,e);return l.isKanjiModeEnabled()?(t=p(d.BYTE,r.BYTE,e),n=p(d.KANJI,r.KANJI,e)):(t=p(d.BYTE_KANJI,r.BYTE,e),n=[]),o.concat(i,t,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,t){switch(t){case r.NUMERIC:return o.getBitsLength(e);case r.ALPHANUMERIC:return i.getBitsLength(e);case r.KANJI:return a.getBitsLength(e);case r.BYTE:return s.getBitsLength(e)}}function m(e,t){let n,d=r.getBestModeForData(e);if((n=r.from(t,d))!==r.BYTE&&n.bit<d.bit)throw Error('"'+e+'" cannot be encoded with mode '+r.toString(n)+".\n Suggested mode is: "+r.toString(d));switch(n===r.KANJI&&!l.isKanjiModeEnabled()&&(n=r.BYTE),n){case r.NUMERIC:return new o(e);case r.ALPHANUMERIC:return new i(e);case r.KANJI:return new a(e);case r.BYTE:return new s(e)}}t.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},t.fromString=function(e,n){let o=function(e,t){let n={},o={start:{}},i=["start"];for(let s=0;s<e.length;s++){let a=e[s],d=[];for(let e=0;e<a.length;e++){let l=a[e],c=""+s+e;d.push(c),n[c]={node:l,lastCount:0},o[c]={};for(let e=0;e<i.length;e++){let s=i[e];n[s]&&n[s].node.mode===l.mode?(o[s][c]=f(n[s].lastCount+l.length,l.mode)-f(n[s].lastCount,l.mode),n[s].lastCount+=l.length):(n[s]&&(n[s].lastCount=l.length),o[s][c]=f(l.length,l.mode)+4+r.getCharCountIndicator(l.mode,t))}}i=d}for(let e=0;e<i.length;e++)o[i[e]].end=0;return{map:o,table:n}}(function(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];switch(o.mode){case r.NUMERIC:t.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:t.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:t.push([o,{data:o.data,mode:r.BYTE,length:u(o.data)}]);break;case r.BYTE:t.push([{data:o.data,mode:r.BYTE,length:u(o.data)}])}}return t}(h(e,l.isKanjiModeEnabled())),n),i=c.find_path(o.map,"start","end"),s=[];for(let e=1;e<i.length-1;e++)s.push(o.table[i[e]].node);return t.fromArray(s.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?e[e.length-1].data+=t.data:e.push(t),e},[]))},t.rawSplit=function(e){return t.fromArray(h(e,l.isKanjiModeEnabled()))}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(e,t){let n,r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(e){if(!e)throw Error('"version" cannot be null or undefined');if(e<1||e>40)throw Error('"version" should be in range from 1 to 40');return 4*e+17},t.getSymbolTotalCodewords=function(e){return r[e]},t.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},t.setToSJISFunction=function(e){if("function"!=typeof e)throw Error('"toSJISFunc" is not a valid function.');n=e},t.isKanjiModeEnabled=function(){return void 0!==n},t.toSJIS=function(e){return n(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(e,t){t.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),d=r.getBCHDigit(7973);function l(e,t){return s.getCharCountIndicator(e,t)+4}t.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},t.getCapacity=function(e,t,n){if(!a.isValid(e))throw Error("Invalid QR Code version");void 0===n&&(n=s.BYTE);let i=(r.getSymbolTotalCodewords(e)-o.getTotalCodewordsCount(e,t))*8;if(n===s.MIXED)return i;let d=i-l(n,e);switch(n){case s.NUMERIC:return Math.floor(d/10*3);case s.ALPHANUMERIC:return Math.floor(d/11*2);case s.KANJI:return Math.floor(d/13);case s.BYTE:default:return Math.floor(d/8)}},t.getBestVersionForData=function(e,n){let r,o=i.from(n,i.M);if(Array.isArray(e)){if(e.length>1){for(let n=1;n<=40;n++)if(function(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}(e,n)<=t.getCapacity(n,o,s.MIXED))return n;return}if(0===e.length)return 1;r=e[0]}else r=e;return function(e,n,r){for(let o=1;o<=40;o++)if(n<=t.getCapacity(o,r,e))return o}(r.mode,r.getLength(),o)},t.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error("Invalid QR Code version");let t=e<<12;for(;r.getBCHDigit(t)-d>=0;)t^=7973<<r.getBCHDigit(t)-d;return e<<12|t}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"(e,t,n){e.exports=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js")},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t,n){var o;let i=n,s=t;void 0!==i||t&&t.getContext||(i=t,t=void 0),t||(s=function(){try{return document.createElement("canvas")}catch(e){throw Error("You need to specify a canvas element")}}()),i=r.getOptions(i);let a=r.getImageWidth(e.modules.size,i),d=s.getContext("2d"),l=d.createImageData(a,a);return r.qrToImageData(l.data,e,i),o=s,d.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px",d.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let o=r;void 0!==o||n&&n.getContext||(o=n,n=void 0),o||(o={});let i=t.render(e,n,o),s=o.type||"image/png",a=o.rendererOpts||{};return i.toDataURL(s,a.quality)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(e,t,n){let r=n("fs"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js").O,i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t){let n=i.getOptions(t),r=n.rendererOpts,s=i.getImageWidth(e.modules.size,n);r.width=s,r.height=s;let a=new o(r);return i.qrToImageData(a.data,e,n),a},t.renderToDataURL=function(e,n,r){void 0===r&&(r=n,n=void 0),t.renderToBuffer(e,n,function(e,t){e&&r(e);let n="data:image/png;base64,";n+=t.toString("base64"),r(null,n)})},t.renderToBuffer=function(e,n,r){void 0===r&&(r=n,n=void 0);let o=t.render(e,n),i=[];o.on("error",r),o.on("data",function(e){i.push(e)}),o.on("end",function(){r(null,Buffer.concat(i))}),o.pack()},t.renderToFile=function(e,n,o,i){void 0===i&&(i=o,o=void 0);let s=!1,a=(...e)=>{s||(s=!0,i.apply(null,e))},d=r.createWriteStream(e);d.on("error",a),d.on("close",a),t.renderToFileStream(d,n,o)},t.renderToFileStream=function(e,n,r){t.render(n,r).pack().pipe(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");function o(e,t){let n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function i(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}t.render=function(e,t,n){let s=r.getOptions(t),a=e.modules.size,d=e.modules.data,l=a+2*s.margin,c=s.color.light.a?"<path "+o(s.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+o(s.color.dark,"stroke")+' d="'+function(e,t,n){let r="",o=0,s=!1,a=0;for(let d=0;d<e.length;d++){let l=Math.floor(d%t),c=Math.floor(d/t);l||s||(s=!0),e[d]?(a++,d>0&&l>0&&e[d-1]||(r+=s?i("M",l+n,.5+c+n):i("m",o,0),o=0,s=!1),l+1<t&&e[d+1]||(r+=i("h",a),a=0)):o++}return r}(d,a,s.margin)+'"/>',p='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+('viewBox="0 0 '+l+" ")+l+'" shape-rendering="crispEdges">'+c+u+"</svg>\n";return"function"==typeof n&&n(null,p),p}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(e,t,n){t.render=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js").render,t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,'<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js");t.render=function(e,t,n){return t&&t.small?o.render(e,t,n):r.render(e,t,n)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js"(e,t){let n="\x1b[37m",r="\x1b[30m",o="\x1b[0m",i="\x1b[47m"+r,s="\x1b[40m"+n,a=function(e,t,n,r){let o=t+1;return n>=o||r>=o||r<-1||n<-1?"0":n>=t||r>=t||r<0||n<0?"1":e[r*t+n]?"2":"1"},d=function(e,t,n,r){return a(e,t,n,r)+a(e,t,n,r+1)};t.render=function(e,t,a){var l,c;let u=e.modules.size,p=e.modules.data,h=!!(t&&t.inverse),f=t&&t.inverse?s:i,m={"00":o+" "+f,"01":o+(l=h?r:n)+"▄"+f,"02":o+(c=h?n:r)+"▄"+f,10:o+l+"▀"+f,11:" ",12:"▄",20:o+c+"▀"+f,21:"▀",22:"█"},g=o+"\n"+f,y=f;for(let e=-1;e<u+1;e+=2){for(let t=-1;t<u;t++)y+=m[d(p,u,t,e)];y+=m[d(p,u,u,e)]+g}return y+=o,"function"==typeof a&&a(null,y),y}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"(e,t){t.render=function(e,t,n){let r=e.modules.size,o=e.modules.data,i="\x1b[47m \x1b[0m",s="",a=Array(r+3).join(i),d=[,,].join(i);s+=a+"\n";for(let e=0;e<r;++e){s+=i;for(let t=0;t<r;t++)s+=o[e*r+t]?"\x1b[40m \x1b[0m":i;s+=d+"\n"}return s+=a+"\n","function"==typeof n&&n(null,s),s}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"),o={WW:" ",WB:"▄",BB:"█",BW:"▀"},i={BB:" ",BW:"▄",WW:"█",WB:"▀"};t.render=function(e,t,n){let s=r.getOptions(t),a=o;("#ffffff"===s.color.dark.hex||"#000000"===s.color.light.hex)&&(a=i);let d=e.modules.size,l=e.modules.data,c="",u=Array(d+2*s.margin+1).join(a.WW);u=Array(s.margin/2+1).join(u+"\n");let p=Array(s.margin+1).join(a.WW);c+=u;for(let e=0;e<d;e+=2){c+=p;for(let t=0;t<d;t++){var h;let n=l[e*d+t],r=l[(e+1)*d+t];c+=(h=a,n&&r?h.BB:n&&!r?h.BW:!n&&r?h.WB:h.WW)}c+=p+"\n"}return c+=u.slice(0,-1),"function"==typeof n&&n(null,c),c},t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(e,t){function n(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw Error("Invalid hex color: "+e);(3===t.length||4===t.length)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");let n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}t.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,o=e.scale||4;return{width:r,scale:r?4:o,margin:t,color:{dark:n(e.color.dark||"#000000ff"),light:n(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},t.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},t.getImageWidth=function(e,n){let r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){let o=n.modules.size,i=n.modules.data,s=t.getScale(o,r),a=Math.floor((o+2*r.margin)*s),d=r.margin*s,l=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let c=(t*a+n)*4,u=r.color.light;t>=d&&n>=d&&t<a-d&&n<a-d&&(u=l[+!!i[Math.floor((t-d)/s)*o+Math.floor((n-d)/s)]]),e[c++]=u.r,e[c++]=u.g,e[c++]=u.b,e[c]=u.a}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"),a=(n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"),n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"));function d(e,t,n){if(void 0===e)throw Error("String required as first argument");if(void 0===n&&(n=t,t={}),"function"!=typeof n)if(r())t=n||{},n=null;else throw Error("Callback required as last argument");return{opts:t,cb:n}}function l(e){switch(e){case"svg":return a;case"txt":case"utf8":return s;default:return i}}function c(e,t,n){if(!n.cb)return new Promise(function(r,i){try{let s=o.create(t,n.opts);return e(s,n.opts,function(e,t){return e?i(e):r(t)})}catch(e){i(e)}});try{let r=o.create(t,n.opts);return e(r,n.opts,n.cb)}catch(e){n.cb(e)}}o.create,n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"),t.toBuffer=function(e,t,n){let r=d(e,t,n);return c(l(r.opts.type).renderToBuffer,e,r)},t.toFile=function(e,t,n,o){if("string"!=typeof e||"string"!=typeof t&&"object"!=typeof t)throw Error("Invalid argument");if(arguments.length<3&&!r())throw Error("Too few arguments provided");let i=d(t,n,o);return c(l(i.opts.type||e.slice((e.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,e),t,i)}},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"(e,t,n){var r=n("node:os"),o=n("node:path");let i=o.join(r.homedir(),".dbx","token"),s=o.join(r.homedir(),".doubao","token"),a={};function d(e){Object.assign(a,e)}function l(e={}){let t={...a,...e},n=function(e,t){let n;try{n=new URL(c(e))}catch{throw Error(`${t} must be an absolute HTTPS URL`)}if("https:"!==n.protocol)throw Error(`${t} must use https`);return c(n.toString())}(t.baseUrl??"https://developer.doubao.com","baseUrl"),r=t.tokenPath??i;return{...t,baseUrl:n,allowedOrigins:function(e,t){let n=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins entries must be absolute HTTPS origins: ${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins entries must use https: ${t}`);n.add(e.origin)}return[...n]}(t.allowedOrigins,n),tokenPath:r,legacyTokenPath:t.tokenPath?void 0:s,requestHeaders:new Headers(t.requestHeaders)}}function c(e){return e.replace(/\/+$/,"")}n.d(t,{$i:()=>l,ZI:()=>d},{E:"dbx-cli"})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"(e,t,n){var r=n("node:child_process"),o=n("node:crypto"),i=n("node:fs"),s=n("node:os"),a=n("node:path");let d=(0,n("node:util").promisify)(r.execFile),l="byted-doubao-open-dbx-cli",c="dbx-cli",u="aes-256-gcm";class p extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}function h(){let e=new m;return"darwin"===process.platform?new f(new g,e):"linux"===process.platform?new f(new y,e):e}class f{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new p(`Failed to read token from system credential store (${T(t)}); encrypted-file fallback also failed: ${T(e)}`);throw e}if(t)throw t instanceof Error?t:new p(`Failed to read token from system credential store: ${String(t)}`)}async set(e,t){let n;try{await this.primary.set(e,t)}catch(e){n=e}try{await this.fallback.set(e,t)}catch(e){if(n)throw new p(`Failed to write token to system credential store (${T(n)}) and encrypted-file fallback (${T(e)})`);throw e}}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new p(`Failed to delete token from system credential store (${T(t)}) and encrypted-file fallback (${T(e)})`);throw e}}}class m{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?a.join(s.homedir(),"Library","Application Support",c):"win32"===process.platform?a.join(process.env.APPDATA||a.join(s.homedir(),"AppData","Roaming"),c):a.join(process.env.XDG_DATA_HOME||a.join(s.homedir(),".local","share"),c))}async get(e){var t,n;let r,s,a=this.credentialFilePath(e);try{r=await i.promises.readFile(a,"utf8")}catch(e){if(I(e)&&"ENOENT"===e.code)return;throw new p(`Failed to read encrypted token file: ${T(e)}`)}try{s=JSON.parse(r)}catch(e){throw new p(`Encrypted token file is not valid JSON: ${T(e)}`)}if(!((t=s)&&"object"==typeof t&&1===t.version&&t.algorithm===u&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new p("Encrypted token file has an unsupported format");let d=await this.readMasterKey();try{let t=o.createDecipheriv(u,d,Buffer.from(s.iv,"base64url"));return t.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8")),t.setAuthTag(Buffer.from(s.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(s.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new p(`Failed to decrypt encrypted token file: ${T(e)}`)}}async set(e,t){var n;let r=await this.readOrCreateMasterKey(),i=o.randomBytes(12),s=o.createCipheriv(u,r,i);s.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8"));let a=Buffer.concat([s.update(t,"utf8"),s.final()]),d={version:1,algorithm:u,iv:i.toString("base64url"),authTag:s.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await _(this.credentialFilePath(e),`${JSON.stringify(d,null,2)}
9
+ 错误码:${e}`);let t=(null==p?void 0:p.message)||"Failed to get debug ticket";throw Error(`${t} (code=${e}, appKey=${u.appKey}, baseApiUrl=${u.baseApiUrl})`)}let h=String((null==(d=p.data)?void 0:d.debug_token)||"").trim(),f=String((null==(l=p.data)?void 0:l.encrypted_debug_payload)||"").trim();if(!h||!f)throw Error("Debug ticket response is missing required fields");return{qrCodeValue:JSON.stringify({action:t.REAL_DEVICE_DEBUG_QR_ACTION,debug_token:h,encrypted_debug_payload:f}),debugToken:h,encryptedDebugPayload:f}})}},"../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(e){var t={single_source_shortest_paths:function(e,n,r){var o,i,s,a,d,l,c,u={},p={};p[n]=0;var h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(s in i=(o=h.pop()).value,a=o.cost,d=e[i]||{})d.hasOwnProperty(s)&&(l=a+d[s],c=p[s],(void 0===p[s]||c>l)&&(p[s]=l,h.push(s,l),u[s]=i));if(void 0!==r&&void 0===p[r])throw Error(["Could not find a path from ",n," to ",r,"."].join(""));return u},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var o=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,o={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=e.sorter||r.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){this.queue.push({value:e,cost:t}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=[function(){},function(e,t,n,r){if(r===t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],i=[function(){},function(e,t,n,r){let o=t[0];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];t.dataToBitMap=function(e,t){let n,s,a,d,l,c,u=t.width,p=t.height,h=t.depth,f=t.bpp,m=t.interlace;8!==h&&(n=[],s=0,a={get:function(t){for(;n.length<t;)!function(){let t,r,o,i;if(s===e.length)throw Error("Ran out of data");let a=e[s];switch(s++,h){default:throw Error("unrecognised depth");case 16:o=e[s],s++,n.push((a<<8)+o);break;case 4:o=15&a,i=a>>4,n.push(i,o);break;case 2:t=3&a,r=a>>2&3,o=a>>4&3,i=a>>6&3,n.push(i,o,r,t);break;case 1:t=a>>4&1,r=a>>5&1,o=a>>6&1,i=a>>7&1,n.push(i,o,r,t,a>>3&1,a>>2&1,a>>1&1,1&a)}}();let r=n.slice(0,t);return n=n.slice(t),r},resetAfterLine:function(){n.length=0},end:function(){if(s!==e.length)throw Error("extra data found")}}),d=h<=8?Buffer.alloc(u*p*4):new Uint16Array(u*p*4);let g=Math.pow(2,h)-1,y=0;if(m)l=r.getImagePasses(u,p),c=r.getInterlaceIterator(u,p);else{let e=0;c=function(){let t=e;return e+=4,t},l=[{width:u,height:p}]}for(let t=0;t<l.length;t++)8===h?y=function(e,t,n,r,i,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++)for(let d=0;d<a;d++){let a=n(d,e,l);o[r](t,i,a,s),s+=r}return s}(l[t],d,c,f,e,y):function(e,t,n,r,o,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++){for(let d=0;d<a;d++){let a=o.get(r),c=n(d,e,l);i[r](t,a,c,s)}o.resetAfterLine()}}(l[t],d,c,f,a,g);if(8===h){if(y!==e.length)throw Error("extra data found")}else a.end();return d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js");e.exports=function(e,t,n,o){let i=-1!==[r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(o.colorType);if(o.colorType===o.inputColorType){let t,n=(new DataView(t=new ArrayBuffer(2)).setInt16(0,256,!0),256!==new Int16Array(t)[0]);if(8===o.bitDepth||16===o.bitDepth&&n)return e}let s=16!==o.bitDepth?e:new Uint16Array(e.buffer),a=255,d=r.COLORTYPE_TO_BPP_MAP[o.inputColorType];4!==d||o.inputHasAlpha||(d=3);let l=r.COLORTYPE_TO_BPP_MAP[o.colorType];16===o.bitDepth&&(a=65535,l*=2);let c=Buffer.alloc(t*n*l),u=0,p=0,h=o.bgColor||{};void 0===h.red&&(h.red=a),void 0===h.green&&(h.green=a),void 0===h.blue&&(h.blue=a);for(let e=0;e<n;e++)for(let e=0;e<t;e++){let e=function(){let e,t,n,d=a;switch(o.inputColorType){case r.COLORTYPE_COLOR_ALPHA:d=s[u+3],e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_COLOR:e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_ALPHA:d=s[u+1],t=e=s[u],n=e;break;case r.COLORTYPE_GRAYSCALE:t=e=s[u],n=e;break;default:throw Error("input color type:"+o.inputColorType+" is not supported at present")}return o.inputHasAlpha&&!i&&(d/=a,e=Math.min(Math.max(Math.round((1-d)*h.red+d*e),0),a),t=Math.min(Math.max(Math.round((1-d)*h.green+d*t),0),a),n=Math.min(Math.max(Math.round((1-d)*h.blue+d*n),0),a)),{red:e,green:t,blue:n,alpha:d}}();switch(o.colorType){case r.COLORTYPE_COLOR_ALPHA:case r.COLORTYPE_COLOR:8===o.bitDepth?(c[p]=e.red,c[p+1]=e.green,c[p+2]=e.blue,i&&(c[p+3]=e.alpha)):(c.writeUInt16BE(e.red,p),c.writeUInt16BE(e.green,p+2),c.writeUInt16BE(e.blue,p+4),i&&c.writeUInt16BE(e.alpha,p+6));break;case r.COLORTYPE_ALPHA:case r.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;8===o.bitDepth?(c[p]=t,i&&(c[p+1]=e.alpha)):(c.writeUInt16BE(t,p),i&&c.writeUInt16BE(e.alpha,p+2));break}default:throw Error("unrecognised color Type "+o.colorType)}u+=d,p+=l}return c}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"(e,t,n){let r=n("util"),o=n("stream"),i=e.exports=function(){o.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};r.inherits(i,o),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},i.prototype.write=function(e,t){let n;return this.writable?(n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let o=this._buffers[n++],i=Math.min(o.length,e.length-t);o.copy(r,t,0,i),t+=i,i!==o.length&&(this._buffers[--n]=o.slice(i))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"(e){e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"(e){let t=[];for(let e=0;e<256;e++){let n=e;for(let e=0;e<8;e++)1&n?n=0xedb88320^n>>>1:n>>>=1;t[e]=n}let n=e.exports=function(){this._crc=-1};n.prototype.write=function(e){for(let n=0;n<e.length;n++)this._crc=t[(this._crc^e[n])&255]^this._crc>>>8;return!0},n.prototype.crc32=function(){return -1^this._crc},n.crc32=function(e){let n=-1;for(let r=0;r<e.length;r++)n=t[(n^e[r])&255]^n>>>8;return -1^n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"),o={0:function(e,t,n,r,o){for(let i=0;i<n;i++)r[o+i]=e[t+i]},1:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let n=s>=i?e[t+s-i]:0,a=e[t+s]-n;r[o+s]=a}},2:function(e,t,n,r,o){for(let i=0;i<n;i++){let s=t>0?e[t+i-n]:0,a=e[t+i]-s;r[o+i]=a}},3:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let a=s>=i?e[t+s-i]:0,d=t>0?e[t+s-n]:0,l=e[t+s]-(a+d>>1);r[o+s]=l}},4:function(e,t,n,o,i,s){for(let a=0;a<n;a++){let d=a>=s?e[t+a-s]:0,l=t>0?e[t+a-n]:0,c=t>0&&a>=s?e[t+a-(n+s)]:0,u=e[t+a]-r(d,l,c);o[i+a]=u}}},i={0:function(e,t,n){let r=0,o=t+n;for(let n=t;n<o;n++)r+=Math.abs(e[n]);return r},1:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let n=i>=r?e[t+i-r]:0;o+=Math.abs(e[t+i]-n)}return o},2:function(e,t,n){let r=0,o=t+n;for(let i=t;i<o;i++){let o=t>0?e[i-n]:0;r+=Math.abs(e[i]-o)}return r},3:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let s=i>=r?e[t+i-r]:0,a=t>0?e[t+i-n]:0;o+=Math.abs(e[t+i]-(s+a>>1))}return o},4:function(e,t,n,o){let i=0;for(let s=0;s<n;s++){let a=s>=o?e[t+s-o]:0,d=t>0?e[t+s-n]:0,l=t>0&&s>=o?e[t+s-(n+o)]:0;i+=Math.abs(e[t+s]-r(a,d,l))}return i}};e.exports=function(e,t,n,r,s){let a;if("filterType"in r&&-1!==r.filterType)if("number"==typeof r.filterType)a=[r.filterType];else throw Error("unrecognised filter types");else a=[0,1,2,3,4];16===r.bitDepth&&(s*=2);let d=t*s,l=0,c=0,u=Buffer.alloc((d+1)*n),p=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=i[a[n]](e,c,d,s);r<t&&(p=a[n],t=r)}}u[l]=p,l++,o[p](e,c,d,u,l,s),l+=d,c+=d}return u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"(e,t,n){let r=n("util"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"),s=e.exports=function(e){o.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit("complete",Buffer.concat(t))}}),this._filter.start()};r.inherits(s,o)},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js");t.process=function(e,t){let n=[],i=new r(e);return new o(t,{read:i.read.bind(i),write:function(e){n.push(e)},complete:function(){}}).start(),i.process(),Buffer.concat(n)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js");function i(e,t,n){let r=e*t;return 8!==n&&(r=Math.ceil(r/(8/n))),r}let s=e.exports=function(e,t){let n=e.width,o=e.height,s=e.interlace,a=e.bpp,d=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],s){let e=r.getImagePasses(n,o);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,a,d),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(n,a,d),height:o,lineIndex:0});8===d?this._xComparison=a:16===d?this._xComparison=2*a:this._xComparison=1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,o=r-1;for(let i=0;i<n;i++){let n=e[1+i],s=i>o?t[i-r]:0;t[i]=n+s}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],i=r?r[o]:0;t[o]=n+i}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,o=r-1,i=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],a=i?i[s]:0,d=Math.floor(((s>o?t[s-r]:0)+a)/2);t[s]=n+d}},s.prototype._unFilterType4=function(e,t,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let a=0;a<n;a++){let n=e[1+a],d=s?s[a]:0,l=o(a>i?t[a-r]:0,d,a>i&&s?s[a-r]:0);t[a]=n+l}},s.prototype._reverseFilterLine=function(e){let t,n=e[0],r=this._images[this._imageIndex],o=r.byteWidth;if(0===n)t=e.slice(1,o+1);else switch(t=Buffer.alloc(o),n){case 1:this._unFilterType1(e,t,o);break;case 2:this._unFilterType2(e,t,o);break;case 3:this._unFilterType3(e,t,o);break;case 4:this._unFilterType4(e,t,o);break;default:throw Error("Unrecognised filter type - "+n)}this.write(t),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=t,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"(e){e.exports=function(e,t){let n=t.depth,r=t.width,o=t.height,i=t.colorType,s=t.transColor,a=t.palette,d=e;return 3===i?!function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=o[e[i]];if(!n)throw Error("index "+e[i]+" not in palette");for(let e=0;e<4;e++)t[i+e]=n[e];i+=4}}(e,d,r,o,a):(s&&function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=!1;if(1===o.length?o[0]===e[i]&&(n=!0):o[0]===e[i]&&o[1]===e[i+1]&&o[2]===e[i+2]&&(n=!0),n)for(let e=0;e<4;e++)t[i+e]=0;i+=4}}(e,d,r,o,s),8!==n&&(16===n&&(d=Buffer.alloc(r*o*4)),!function(e,t,n,r,o){let i=Math.pow(2,o)-1,s=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[s+n]=Math.floor(255*e[s+n]/i+.5);s+=4}}(e,d,r,o,n))),d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"(e,t){let n=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];t.getImagePasses=function(e,t){let r=[],o=e%8,i=t%8,s=(e-o)/8,a=(t-i)/8;for(let e=0;e<n.length;e++){let t=n[e],d=s*t.x.length,l=a*t.y.length;for(let e=0;e<t.x.length;e++)if(t.x[e]<o)d++;else break;for(let e=0;e<t.y.length;e++)if(t.y[e]<i)l++;else break;d>0&&l>0&&r.push({width:d,height:l,index:e})}return r},t.getInterlaceIterator=function(e){return function(t,r,o){let i=t%n[o].x.length,s=(t-i)/n[o].x.length*8+n[o].x[i],a=r%n[o].y.length;return 4*s+((r-a)/n[o].y.length*8+n[o].y[a])*e*4}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"),a=e.exports=function(e){o.call(this),this._packer=new s(e||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(a,o),a.prototype.pack=function(e,t,n,r){this.emit("data",Buffer.from(i.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,n)),r&&this.emit("data",this._packer.packGAMA(r));let o=this._packer.filterData(e,t,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(e){this.emit("data",this._packer.packIDAT(e))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(o)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js"(e,t,n){let r=!0,o=n("zlib");o.deflateSync||(r=!1);let i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js");e.exports=function(e,t){if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new s(t||{}),a=[];a.push(Buffer.from(i.PNG_SIGNATURE)),a.push(n.packIHDR(e.width,e.height)),e.gamma&&a.push(n.packGAMA(e.gamma));let d=n.filterData(e.data,e.width,e.height),l=o.deflateSync(d,n.getDeflateOptions());if(d=null,!l||!l.length)throw Error("bad png - invalid compressed data response");return a.push(n.packIDAT(l)),a.push(n.packIEND()),Buffer.concat(a)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"),a=n("zlib"),d=e.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=null!=e.deflateLevel?e.deflateLevel:9,e.deflateStrategy=null!=e.deflateStrategy?e.deflateStrategy:3,e.inputHasAlpha=null==e.inputHasAlpha||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||a.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType="number"==typeof e.colorType?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType="number"==typeof e.inputColorType?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType))throw Error("option color type:"+e.colorType+" is not supported at present");if(-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType))throw Error("option input color type:"+e.inputColorType+" is not supported at present");if(8!==e.bitDepth&&16!==e.bitDepth)throw Error("option bit depth:"+e.bitDepth+" is not supported at present")};d.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},d.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},d.prototype.filterData=function(e,t,n){let o=i(e,t,n,this._options),a=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return s(o,t,n,this._options,a)},d.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(o.crc32(r.slice(4,r.length-4)),r.length-4),r},d.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},d.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},d.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},d.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"(e){e.exports=function(e,t,n){let r=e+t-n,o=Math.abs(r-e),i=Math.abs(r-t),s=Math.abs(r-n);return o<=i&&o<=s?e:i<=s?t:n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"(e,t,n){let r=n("util"),o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"),c=e.exports=function(e){i.call(this),this._parser=new a(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};r.inherits(c,i),c.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},c.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=o.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,o.Z_MIN_CHUNK);this._inflate=o.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,"error");this._inflate.on("error",function(e){n&&r(e)}),this._filter.on("complete",this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on("data",function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)},c.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new s(this._bitmapInfo)},c.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},c.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},c.prototype._simpleTransparency=function(){this._metaData.alpha=!0},c.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},c.prototype._complete=function(e){let t;if(!this.errord){try{let n=d.dataToBitMap(e,this._bitmapInfo);t=l(n,this._bitmapInfo),n=null}catch(e){this._handleError(e);return}this.emit("parsed",t)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"(e,t,n){let r=!0,o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js");o.deflateSync||(r=!1);let s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),c=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js");e.exports=function(e,t){let n,u,p,h;if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let f=[],m=new s(e);if(new d(t,{read:m.read.bind(m),error:function(e){n=e},metadata:function(e){u=e},gamma:function(e){p=e},palette:function(e){u.palette=e},transColor:function(e){u.transColor=e},inflateData:function(e){f.push(e)},simpleTransparency:function(){u.alpha=!0}}).start(),m.process(),n)throw n;let g=Buffer.concat(f);if(f.length=0,u.interlace)h=o.inflateSync(g);else{let e=((u.width*u.bpp*u.depth+7>>3)+1)*u.height;h=i(g,{chunkSize:e,maxLength:e})}if(g=null,!h||!h.length)throw Error("bad png - invalid inflate data response");let y=a.process(h,u);g=null;let _=l.dataToBitMap(y,u);y=null;let b=c(_,u);return u.data=b,u.gamma=p||0,u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=e.exports=function(e,t){this._options=e,e.checkCRC=!1!==e.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=r.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return void this.error(Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),n=e.readUInt32BE(4),i="";for(let t=4;t<8;t++)i+=String.fromCharCode(e[t]);let s=!!(32&e[4]);return this._hasIHDR||n===r.TYPE_IHDR?(this._crc=new o,this._crc.write(Buffer.from(i)),this._chunks[n])?this._chunks[n](t):s?void this.read(t+4,this._skipChunk.bind(this)):void this.error(Error("Unsupported critical chunk type "+i)):void this.error(Error("Expected IHDR on beggining"))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==t?this.error(Error("Crc error - "+t+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),o=e[8],i=e[9],s=e[10],a=e[11],d=e[12];if(8!==o&&4!==o&&2!==o&&1!==o&&16!==o)return void this.error(Error("Unsupported bit depth "+o));if(!(i in r.COLORTYPE_TO_BPP_MAP))return void this.error(Error("Unsupported color type"));if(0!==s)return void this.error(Error("Unsupported compression method"));if(0!==a)return void this.error(Error("Unsupported filter method"));if(0!==d&&1!==d)return void this.error(Error("Unsupported interlace method"));this._colorType=i;let l=r.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:n,depth:o,interlace:!!d,palette:!!(i&r.COLORTYPE_PALETTE),color:!!(i&r.COLORTYPE_COLOR),alpha:!!(i&r.COLORTYPE_ALPHA),bpp:l,colorType:i}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[3*n],e[3*n+1],e[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===r.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(Error("Transparency chunk must be after palette"));if(e.length>this._palette.length)return void this.error(Error("More transparent colors than palette size"));for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===r.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===r.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/r.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===r.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw Error("Expected palette not found");this.inflateData(t);let n=e-t.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js");t.read=function(e,t){return r(e,t||{})},t.write=function(e,t){return o(e,t)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"),d=t.O=function(e){o.call(this),e=e||{},this.width=0|e.width,this.height=0|e.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(e){this.data=e,this.emit("parsed",e)}).bind(this)),this._packer=new s(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};r.inherits(d,o),d.sync=a,d.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},d.prototype.parse=function(e,t){if(t){let e,n;e=(function(e){this.removeListener("error",n),this.data=e,t(null,this)}).bind(this),n=(function(n){this.removeListener("parsed",e),t(n,null)}).bind(this),this.once("parsed",e),this.once("error",n)}return this.end(e),this},d.prototype.write=function(e){return this._parser.write(e),!0},d.prototype.end=function(e){this._parser.end(e)},d.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)},d.prototype._gamma=function(e){this.gamma=e},d.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},d.bitblt=function(e,t,n,r,o,i,s,a){if(r|=0,o|=0,i|=0,s|=0,a|=0,(n|=0)>e.width||r>e.height||n+o>e.width||r+i>e.height)throw Error("bitblt reading outside image");if(s>t.width||a>t.height||s+o>t.width||a+i>t.height)throw Error("bitblt writing outside image");for(let d=0;d<i;d++)e.data.copy(t.data,(a+d)*t.width+s<<2,(r+d)*e.width+n<<2,(r+d)*e.width+n+o<<2)},d.prototype.bitblt=function(e,t,n,r,o,i,s){return d.bitblt(this,e,t,n,r,o,i,s),this},d.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[r+t]=Math.round(255*n)}}e.gamma=0}},d.prototype.adjustGamma=function(){d.adjustGamma(this)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js"(e,t,n){let r=n("assert").ok,o=n("zlib"),i=n("util"),s=n("buffer").kMaxLength;function a(e){if(!(this instanceof a))return new a(e);e&&e.chunkSize<o.Z_MIN_CHUNK&&(e.chunkSize=o.Z_MIN_CHUNK),o.Inflate.call(this,e),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&null!=e.maxLength&&(this._maxLength=e.maxLength)}function d(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}function l(e,t){var n=new a(t),r=e;if("string"==typeof r&&(r=Buffer.from(r)),!(r instanceof Buffer))throw TypeError("Not a string or buffer");let i=n._finishFlushFlag;return null==i&&(i=o.Z_FINISH),n._processChunk(r,i)}a.prototype._processChunk=function(e,t,n){let i,a;if("function"==typeof n)return o.Inflate._processChunk.call(this,e,t,n);let l=this,c=e&&e.length,u=this._chunkSize-this._offset,p=this._maxLength,h=0,f=[],m=0;this.on("error",function(e){i=e}),r(this._handle,"zlib binding closed");do a=(a=this._handle.writeSync(t,e,h,c,this._buffer,this._offset,u))||this._writeState;while(!this._hadError&&function(e,t){if(l._hadError)return;let n=u-t;if(r(n>=0,"have should not go down"),n>0){let e=l._buffer.slice(l._offset,l._offset+n);if(l._offset+=n,e.length>p&&(e=e.slice(0,p)),f.push(e),m+=e.length,0==(p-=e.length))return!1}return(0===t||l._offset>=l._chunkSize)&&(u=l._chunkSize,l._offset=0,l._buffer=Buffer.allocUnsafe(l._chunkSize)),0===t&&(h+=c-e,c=e,!0)}(a[0],a[1]));if(this._hadError)throw i;if(m>=s)throw d(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+s.toString(16)+" bytes");let g=Buffer.concat(f,m);return d(this),g},i.inherits(a,o.Inflate),e.exports=t=l,t.Inflate=a,t.createInflate=function(e){return new a(e)},t.inflateSync=l},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"(e){let t=e.exports=function(e){this._buffer=e,this._reads=[]};t.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},t.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js");function a(e,t,n,i,s){let a=[].slice.call(arguments,1),d=a.length,l="function"==typeof a[d-1];if(!l&&!r())throw Error("Callback required as last argument");if(l){if(d<2)throw Error("Too few arguments provided");2===d?(s=n,n=t,t=i=void 0):3===d&&(t.getContext&&void 0===s?(s=i,i=void 0):(s=i,i=n,n=t,t=void 0))}else{if(d<1)throw Error("Too few arguments provided");return 1===d?(n=t,t=i=void 0):2!==d||t.getContext||(i=n,n=t,t=void 0),new Promise(function(r,s){try{let s=o.create(n,i);r(e(s,t,i))}catch(e){s(e)}})}try{let r=o.create(n,i);s(null,e(r,t,i))}catch(e){s(e)}}o.create,a.bind(null,i.render),a.bind(null,i.renderToDataURL),a.bind(null,function(e,t,n){return s.render(e,n)})},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(e){e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getRowColCoords=function(e){if(1===e)return[];let t=Math.floor(e/7)+2,n=r(e),o=145===n?26:2*Math.ceil((n-13)/(2*t-2)),i=[n-7];for(let e=1;e<t-1;e++)i[e]=i[e-1]-o;return i.push(6),i.reverse()},t.getPositions=function(e){let n=[],r=t.getRowColCoords(e),o=r.length;for(let e=0;e<o;e++)for(let t=0;t<o;t++)(0!==e||0!==t)&&(0!==e||t!==o-1)&&(e!==o-1||0!==t)&&n.push([r[e],r[t]]);return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(e){this.mode=r.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*o.indexOf(this.data[t]);n+=o.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(o.indexOf(this.data[t]),6)},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(e){function t(){this.buffer=[],this.length=0}t.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(e){function t(e){if(!e||e<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}t.prototype.set=function(e,t,n,r){let o=e*this.size+t;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(e,t){return this.data[e*this.size+t]},t.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},t.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.BYTE,"string"==typeof e?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}o.getBitsLength=function(e){return 8*e},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(e,t){switch(t){case r.L:return o[(e-1)*4+0];case r.M:return o[(e-1)*4+1];case r.Q:return o[(e-1)*4+2];case r.H:return o[(e-1)*4+3];default:return}},t.getTotalCodewordsCount=function(e,t){switch(t){case r.L:return i[(e-1)*4+0];case r.M:return i[(e-1)*4+1];case r.Q:return i[(e-1)*4+2];case r.H:return i[(e-1)*4+3];default:return}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(e,t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw Error("Unknown EC Level: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getPositions=function(e){let t=r(e);return[[0,0],[t-7,0],[0,t-7]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=r.getBCHDigit(1335);t.getEncodedBits=function(e,t){let n=e.bit<<3|t,i=n<<10;for(;r.getBCHDigit(i)-o>=0;)i^=1335<<r.getBCHDigit(i)-o;return(n<<10|i)^21522}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(e,t){let n=new Uint8Array(512),r=new Uint8Array(256),o=1;for(let e=0;e<255;e++)n[e]=o,r[o]=e,256&(o<<=1)&&(o^=285);for(let e=255;e<512;e++)n[e]=n[e-255];t.exp=function(e){return n[e]},t.mul=function(e,t){return 0===e||0===t?0:n[r[e]+r[t]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js");function i(e){this.mode=r.KANJI,this.data=e}i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=o.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n=(n>>>8&255)*192+(255&n),e.put(n,13)}},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(e,t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};t.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){let t=e.size,n=0,r=0,o=0,i=null,s=null;for(let a=0;a<t;a++){r=o=0,i=s=null;for(let d=0;d<t;d++){let t=e.get(a,d);t===i?r++:(r>=5&&(n+=3+(r-5)),i=t,r=1),(t=e.get(d,a))===s?o++:(o>=5&&(n+=3+(o-5)),s=t,o=1)}r>=5&&(n+=3+(r-5)),o>=5&&(n+=3+(o-5))}return n},t.getPenaltyN2=function(e){let t=e.size,n=0;for(let r=0;r<t-1;r++)for(let o=0;o<t-1;o++){let t=e.get(r,o)+e.get(r,o+1)+e.get(r+1,o)+e.get(r+1,o+1);(4===t||0===t)&&n++}return 3*n},t.getPenaltyN3=function(e){let t=e.size,n=0,r=0,o=0;for(let i=0;i<t;i++){r=o=0;for(let s=0;s<t;s++)r=r<<1&2047|e.get(i,s),s>=10&&(1488===r||93===r)&&n++,o=o<<1&2047|e.get(s,i),s>=10&&(1488===o||93===o)&&n++}return 40*n},t.getPenaltyN4=function(e){let t=0,n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return 10*Math.abs(Math.ceil(100*t/n/5)-10)},t.applyMask=function(e,n){let r=n.size;for(let o=0;o<r;o++)for(let i=0;i<r;i++)n.isReserved(i,o)||n.xor(i,o,function(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error("bad maskPattern:"+e)}}(e,i,o))},t.getBestMask=function(e,n){let r=Object.keys(t.Patterns).length,o=0,i=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);let r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<i&&(i=r,o=s)}return o}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js");t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(e,t){if(!e.ccBits)throw Error("Invalid mode: "+e);if(!r.isValid(t))throw Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]},t.getBestModeForData=function(e){return o.testNumeric(e)?t.NUMERIC:o.testAlphanumeric(e)?t.ALPHANUMERIC:o.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(e){if(e&&e.id)return e.id;throw Error("Invalid mode")},t.isValid=function(e){return e&&e.bit&&e.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw Error("Unknown mode: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.NUMERIC,this.data=e.toString()}o.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let t,n;for(t=0;t+3<=this.data.length;t+=3)n=parseInt(this.data.substr(t,3),10),e.put(n,10);let r=this.data.length-t;r>0&&(n=parseInt(this.data.substr(t),10),e.put(n,3*r+1))},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js");t.mul=function(e,t){let n=new Uint8Array(e.length+t.length-1);for(let o=0;o<e.length;o++)for(let i=0;i<t.length;i++)n[o+i]^=r.mul(e[o],t[i]);return n},t.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){let e=n[0];for(let o=0;o<t.length;o++)n[o]^=r.mul(t[o],e);let o=0;for(;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},t.generateECPolynomial=function(e){let n=new Uint8Array([1]);for(let o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"),c=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),u=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"),p=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"),h=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"),f=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),m=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js");function g(e,t,n){let r,o,i=e.size,s=h.getEncodedBits(t,n);for(r=0;r<15;r++)o=(s>>r&1)==1,r<6?e.set(r,8,o,!0):r<8?e.set(r+1,8,o,!0):e.set(i-15+r,8,o,!0),r<8?e.set(8,i-r-1,o,!0):r<9?e.set(8,15-r-1+1,o,!0):e.set(8,15-r-1,o,!0);e.set(i-8,8,1,!0)}t.create=function(e,t){let n,h;if(void 0===e||""===e)throw Error("No input text");let y=o.M;return void 0!==t&&(y=o.from(t.errorCorrectionLevel,o.M),n=p.from(t.version),h=l.from(t.maskPattern),t.toSJISFunc&&r.setToSJISFunction(t.toSJISFunc)),function(e,t,n,o){let h;if(Array.isArray(e))h=m.fromArray(e);else if("string"==typeof e){let r=t;if(!r){let t=m.rawSplit(e);r=p.getBestVersionForData(t,n)}h=m.fromString(e,r||40)}else throw Error("Invalid data");let y=p.getBestVersionForData(h,n);if(!y)throw Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<y)throw Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+y+".\n")}else t=y;let _=function(e,t,n){let o=new i;n.forEach(function(t){o.put(t.mode.bit,4),o.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(o)});let s=(r.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,t))*8;for(o.getLengthInBits()+4<=s&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);let a=(s-o.getLengthInBits())/8;for(let e=0;e<a;e++)o.put(e%2?17:236,8);return function(e,t,n){let o,i,s=r.getSymbolTotalCodewords(t),a=s-c.getTotalCodewordsCount(t,n),d=c.getBlocksCount(t,n),l=s%d,p=d-l,h=Math.floor(s/d),f=Math.floor(a/d),m=f+1,g=h-f,y=new u(g),_=0,b=Array(d),w=Array(d),v=0,E=new Uint8Array(e.buffer);for(let e=0;e<d;e++){let t=e<p?f:m;b[e]=E.slice(_,_+t),w[e]=y.encode(b[e]),_+=t,v=Math.max(v,t)}let I=new Uint8Array(s),T=0;for(o=0;o<v;o++)for(i=0;i<d;i++)o<b[i].length&&(I[T++]=b[i][o]);for(o=0;o<g;o++)for(i=0;i<d;i++)I[T++]=w[i][o];return I}(o,e,t)}(t,n,h),b=new s(r.getSymbolSize(t));!function(e,t){let n=e.size,r=d.getPositions(t);for(let t=0;t<r.length;t++){let o=r[t][0],i=r[t][1];for(let t=-1;t<=7;t++)if(!(o+t<=-1)&&!(n<=o+t))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(o+t,i+r,!0,!0):e.set(o+t,i+r,!1,!0))}}(b,t);let w=b.size;for(let e=8;e<w-8;e++){let t=e%2==0;b.set(e,6,t,!0),b.set(6,e,t,!0)}return!function(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],o=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,o+n,!0,!0):e.set(r+t,o+n,!1,!0)}}(b,t),g(b,n,0),t>=7&&function(e,t){let n,r,o,i=e.size,s=p.getEncodedBits(t);for(let t=0;t<18;t++)n=Math.floor(t/3),r=t%3+i-8-3,o=(s>>t&1)==1,e.set(n,r,o,!0),e.set(r,n,o,!0)}(b,t),!function(e,t){let n=e.size,r=-1,o=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(o,a-n)){let r=!1;s<t.length&&(r=(t[s]>>>i&1)==1),e.set(o,a-n,r),-1==--i&&(s++,i=7)}if((o+=r)<0||n<=o){o-=r,r=-r;break}}}(b,_),isNaN(o)&&(o=l.getBestMask(b,g.bind(null,b,n))),l.applyMask(o,b),g(b,n,o),{modules:b,version:t,errorCorrectionLevel:n,maskPattern:o,segments:h}}(e,n,y,h)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js");function o(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let n=r.mod(t,this.genPoly),o=this.degree-n.length;if(o>0){let e=new Uint8Array(this.degree);return e.set(n,o),e}return n},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(e,t){let n="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",o="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=RegExp(r,"g"),t.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=RegExp(o,"g"),t.NUMERIC=RegExp(n,"g"),t.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let i=RegExp("^"+r+"$"),s=RegExp("^"+n+"$"),a=RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(e){return i.test(e)},t.testNumeric=function(e){return s.test(e)},t.testAlphanumeric=function(e){return a.test(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),c=n("../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js");function u(e){return unescape(encodeURIComponent(e)).length}function p(e,t,n){let r,o=[];for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function h(e){let t,n,o=p(d.NUMERIC,r.NUMERIC,e),i=p(d.ALPHANUMERIC,r.ALPHANUMERIC,e);return l.isKanjiModeEnabled()?(t=p(d.BYTE,r.BYTE,e),n=p(d.KANJI,r.KANJI,e)):(t=p(d.BYTE_KANJI,r.BYTE,e),n=[]),o.concat(i,t,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,t){switch(t){case r.NUMERIC:return o.getBitsLength(e);case r.ALPHANUMERIC:return i.getBitsLength(e);case r.KANJI:return a.getBitsLength(e);case r.BYTE:return s.getBitsLength(e)}}function m(e,t){let n,d=r.getBestModeForData(e);if((n=r.from(t,d))!==r.BYTE&&n.bit<d.bit)throw Error('"'+e+'" cannot be encoded with mode '+r.toString(n)+".\n Suggested mode is: "+r.toString(d));switch(n===r.KANJI&&!l.isKanjiModeEnabled()&&(n=r.BYTE),n){case r.NUMERIC:return new o(e);case r.ALPHANUMERIC:return new i(e);case r.KANJI:return new a(e);case r.BYTE:return new s(e)}}t.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},t.fromString=function(e,n){let o=function(e,t){let n={},o={start:{}},i=["start"];for(let s=0;s<e.length;s++){let a=e[s],d=[];for(let e=0;e<a.length;e++){let l=a[e],c=""+s+e;d.push(c),n[c]={node:l,lastCount:0},o[c]={};for(let e=0;e<i.length;e++){let s=i[e];n[s]&&n[s].node.mode===l.mode?(o[s][c]=f(n[s].lastCount+l.length,l.mode)-f(n[s].lastCount,l.mode),n[s].lastCount+=l.length):(n[s]&&(n[s].lastCount=l.length),o[s][c]=f(l.length,l.mode)+4+r.getCharCountIndicator(l.mode,t))}}i=d}for(let e=0;e<i.length;e++)o[i[e]].end=0;return{map:o,table:n}}(function(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];switch(o.mode){case r.NUMERIC:t.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:t.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:t.push([o,{data:o.data,mode:r.BYTE,length:u(o.data)}]);break;case r.BYTE:t.push([{data:o.data,mode:r.BYTE,length:u(o.data)}])}}return t}(h(e,l.isKanjiModeEnabled())),n),i=c.find_path(o.map,"start","end"),s=[];for(let e=1;e<i.length-1;e++)s.push(o.table[i[e]].node);return t.fromArray(s.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?e[e.length-1].data+=t.data:e.push(t),e},[]))},t.rawSplit=function(e){return t.fromArray(h(e,l.isKanjiModeEnabled()))}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(e,t){let n,r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(e){if(!e)throw Error('"version" cannot be null or undefined');if(e<1||e>40)throw Error('"version" should be in range from 1 to 40');return 4*e+17},t.getSymbolTotalCodewords=function(e){return r[e]},t.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},t.setToSJISFunction=function(e){if("function"!=typeof e)throw Error('"toSJISFunc" is not a valid function.');n=e},t.isKanjiModeEnabled=function(){return void 0!==n},t.toSJIS=function(e){return n(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(e,t){t.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),d=r.getBCHDigit(7973);function l(e,t){return s.getCharCountIndicator(e,t)+4}t.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},t.getCapacity=function(e,t,n){if(!a.isValid(e))throw Error("Invalid QR Code version");void 0===n&&(n=s.BYTE);let i=(r.getSymbolTotalCodewords(e)-o.getTotalCodewordsCount(e,t))*8;if(n===s.MIXED)return i;let d=i-l(n,e);switch(n){case s.NUMERIC:return Math.floor(d/10*3);case s.ALPHANUMERIC:return Math.floor(d/11*2);case s.KANJI:return Math.floor(d/13);case s.BYTE:default:return Math.floor(d/8)}},t.getBestVersionForData=function(e,n){let r,o=i.from(n,i.M);if(Array.isArray(e)){if(e.length>1){for(let n=1;n<=40;n++)if(function(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}(e,n)<=t.getCapacity(n,o,s.MIXED))return n;return}if(0===e.length)return 1;r=e[0]}else r=e;return function(e,n,r){for(let o=1;o<=40;o++)if(n<=t.getCapacity(o,r,e))return o}(r.mode,r.getLength(),o)},t.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error("Invalid QR Code version");let t=e<<12;for(;r.getBCHDigit(t)-d>=0;)t^=7973<<r.getBCHDigit(t)-d;return e<<12|t}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"(e,t,n){e.exports=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js")},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t,n){var o;let i=n,s=t;void 0!==i||t&&t.getContext||(i=t,t=void 0),t||(s=function(){try{return document.createElement("canvas")}catch(e){throw Error("You need to specify a canvas element")}}()),i=r.getOptions(i);let a=r.getImageWidth(e.modules.size,i),d=s.getContext("2d"),l=d.createImageData(a,a);return r.qrToImageData(l.data,e,i),o=s,d.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px",d.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let o=r;void 0!==o||n&&n.getContext||(o=n,n=void 0),o||(o={});let i=t.render(e,n,o),s=o.type||"image/png",a=o.rendererOpts||{};return i.toDataURL(s,a.quality)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(e,t,n){let r=n("fs"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js").O,i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t){let n=i.getOptions(t),r=n.rendererOpts,s=i.getImageWidth(e.modules.size,n);r.width=s,r.height=s;let a=new o(r);return i.qrToImageData(a.data,e,n),a},t.renderToDataURL=function(e,n,r){void 0===r&&(r=n,n=void 0),t.renderToBuffer(e,n,function(e,t){e&&r(e);let n="data:image/png;base64,";n+=t.toString("base64"),r(null,n)})},t.renderToBuffer=function(e,n,r){void 0===r&&(r=n,n=void 0);let o=t.render(e,n),i=[];o.on("error",r),o.on("data",function(e){i.push(e)}),o.on("end",function(){r(null,Buffer.concat(i))}),o.pack()},t.renderToFile=function(e,n,o,i){void 0===i&&(i=o,o=void 0);let s=!1,a=(...e)=>{s||(s=!0,i.apply(null,e))},d=r.createWriteStream(e);d.on("error",a),d.on("close",a),t.renderToFileStream(d,n,o)},t.renderToFileStream=function(e,n,r){t.render(n,r).pack().pipe(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");function o(e,t){let n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function i(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}t.render=function(e,t,n){let s=r.getOptions(t),a=e.modules.size,d=e.modules.data,l=a+2*s.margin,c=s.color.light.a?"<path "+o(s.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+o(s.color.dark,"stroke")+' d="'+function(e,t,n){let r="",o=0,s=!1,a=0;for(let d=0;d<e.length;d++){let l=Math.floor(d%t),c=Math.floor(d/t);l||s||(s=!0),e[d]?(a++,d>0&&l>0&&e[d-1]||(r+=s?i("M",l+n,.5+c+n):i("m",o,0),o=0,s=!1),l+1<t&&e[d+1]||(r+=i("h",a),a=0)):o++}return r}(d,a,s.margin)+'"/>',p='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+('viewBox="0 0 '+l+" ")+l+'" shape-rendering="crispEdges">'+c+u+"</svg>\n";return"function"==typeof n&&n(null,p),p}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(e,t,n){t.render=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js").render,t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,'<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js");t.render=function(e,t,n){return t&&t.small?o.render(e,t,n):r.render(e,t,n)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js"(e,t){let n="\x1b[37m",r="\x1b[30m",o="\x1b[0m",i="\x1b[47m"+r,s="\x1b[40m"+n,a=function(e,t,n,r){let o=t+1;return n>=o||r>=o||r<-1||n<-1?"0":n>=t||r>=t||r<0||n<0?"1":e[r*t+n]?"2":"1"},d=function(e,t,n,r){return a(e,t,n,r)+a(e,t,n,r+1)};t.render=function(e,t,a){var l,c;let u=e.modules.size,p=e.modules.data,h=!!(t&&t.inverse),f=t&&t.inverse?s:i,m={"00":o+" "+f,"01":o+(l=h?r:n)+"▄"+f,"02":o+(c=h?n:r)+"▄"+f,10:o+l+"▀"+f,11:" ",12:"▄",20:o+c+"▀"+f,21:"▀",22:"█"},g=o+"\n"+f,y=f;for(let e=-1;e<u+1;e+=2){for(let t=-1;t<u;t++)y+=m[d(p,u,t,e)];y+=m[d(p,u,u,e)]+g}return y+=o,"function"==typeof a&&a(null,y),y}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"(e,t){t.render=function(e,t,n){let r=e.modules.size,o=e.modules.data,i="\x1b[47m \x1b[0m",s="",a=Array(r+3).join(i),d=[,,].join(i);s+=a+"\n";for(let e=0;e<r;++e){s+=i;for(let t=0;t<r;t++)s+=o[e*r+t]?"\x1b[40m \x1b[0m":i;s+=d+"\n"}return s+=a+"\n","function"==typeof n&&n(null,s),s}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"),o={WW:" ",WB:"▄",BB:"█",BW:"▀"},i={BB:" ",BW:"▄",WW:"█",WB:"▀"};t.render=function(e,t,n){let s=r.getOptions(t),a=o;("#ffffff"===s.color.dark.hex||"#000000"===s.color.light.hex)&&(a=i);let d=e.modules.size,l=e.modules.data,c="",u=Array(d+2*s.margin+1).join(a.WW);u=Array(s.margin/2+1).join(u+"\n");let p=Array(s.margin+1).join(a.WW);c+=u;for(let e=0;e<d;e+=2){c+=p;for(let t=0;t<d;t++){var h;let n=l[e*d+t],r=l[(e+1)*d+t];c+=(h=a,n&&r?h.BB:n&&!r?h.BW:!n&&r?h.WB:h.WW)}c+=p+"\n"}return c+=u.slice(0,-1),"function"==typeof n&&n(null,c),c},t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(e,t){function n(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw Error("Invalid hex color: "+e);(3===t.length||4===t.length)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");let n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}t.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,o=e.scale||4;return{width:r,scale:r?4:o,margin:t,color:{dark:n(e.color.dark||"#000000ff"),light:n(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},t.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},t.getImageWidth=function(e,n){let r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){let o=n.modules.size,i=n.modules.data,s=t.getScale(o,r),a=Math.floor((o+2*r.margin)*s),d=r.margin*s,l=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let c=(t*a+n)*4,u=r.color.light;t>=d&&n>=d&&t<a-d&&n<a-d&&(u=l[+!!i[Math.floor((t-d)/s)*o+Math.floor((n-d)/s)]]),e[c++]=u.r,e[c++]=u.g,e[c++]=u.b,e[c]=u.a}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"),a=(n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"),n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"));function d(e,t,n){if(void 0===e)throw Error("String required as first argument");if(void 0===n&&(n=t,t={}),"function"!=typeof n)if(r())t=n||{},n=null;else throw Error("Callback required as last argument");return{opts:t,cb:n}}function l(e){switch(e){case"svg":return a;case"txt":case"utf8":return s;default:return i}}function c(e,t,n){if(!n.cb)return new Promise(function(r,i){try{let s=o.create(t,n.opts);return e(s,n.opts,function(e,t){return e?i(e):r(t)})}catch(e){i(e)}});try{let r=o.create(t,n.opts);return e(r,n.opts,n.cb)}catch(e){n.cb(e)}}o.create,n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"),t.toBuffer=function(e,t,n){let r=d(e,t,n);return c(l(r.opts.type).renderToBuffer,e,r)},t.toFile=function(e,t,n,o){if("string"!=typeof e||"string"!=typeof t&&"object"!=typeof t)throw Error("Invalid argument");if(arguments.length<3&&!r())throw Error("Too few arguments provided");let i=d(t,n,o);return c(l(i.opts.type||e.slice((e.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,e),t,i)}},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"(e,t,n){var r=n("node:os"),o=n("node:path");let i=o.join(r.homedir(),".dbx","token"),s=o.join(r.homedir(),".doubao","token"),a={};function d(e){Object.assign(a,e)}function l(e={}){let t={...a,...e},n=function(e,t){let n;try{n=new URL(c(e))}catch{throw Error(`${t} must be an absolute HTTPS URL`)}if("https:"!==n.protocol)throw Error(`${t} must use https`);return c(n.toString())}(t.baseUrl??"https://developer.doubao.com","baseUrl"),r=t.tokenPath??i;return{...t,baseUrl:n,allowedOrigins:function(e,t){let n=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins entries must be absolute HTTPS origins: ${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins entries must use https: ${t}`);n.add(e.origin)}return[...n]}(t.allowedOrigins,n),tokenPath:r,legacyTokenPath:t.tokenPath?void 0:s,requestHeaders:new Headers(t.requestHeaders)}}function c(e){return e.replace(/\/+$/,"")}n.d(t,{$i:()=>l,ZI:()=>d},{E:"dbx-cli"})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"(e,t,n){var r=n("node:child_process"),o=n("node:crypto"),i=n("node:fs"),s=n("node:os"),a=n("node:path");let d=(0,n("node:util").promisify)(r.execFile),l="byted-doubao-open-dbx-cli",c="dbx-cli",u="aes-256-gcm";class p extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}function h(){let e=new m;return"darwin"===process.platform?new f(new g,e):"linux"===process.platform?new f(new y,e):e}class f{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new p(`Failed to read token from system credential store (${T(t)}); encrypted-file fallback also failed: ${T(e)}`);throw e}if(t)throw t instanceof Error?t:new p(`Failed to read token from system credential store: ${String(t)}`)}async set(e,t){let n;try{await this.primary.set(e,t)}catch(e){n=e}try{await this.fallback.set(e,t)}catch(e){if(n)throw new p(`Failed to write token to system credential store (${T(n)}) and encrypted-file fallback (${T(e)})`);throw e}}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new p(`Failed to delete token from system credential store (${T(t)}) and encrypted-file fallback (${T(e)})`);throw e}}}class m{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?a.join(s.homedir(),"Library","Application Support",c):"win32"===process.platform?a.join(process.env.APPDATA||a.join(s.homedir(),"AppData","Roaming"),c):a.join(process.env.XDG_DATA_HOME||a.join(s.homedir(),".local","share"),c))}async get(e){var t,n;let r,s,a=this.credentialFilePath(e);try{r=await i.promises.readFile(a,"utf8")}catch(e){if(I(e)&&"ENOENT"===e.code)return;throw new p(`Failed to read encrypted token file: ${T(e)}`)}try{s=JSON.parse(r)}catch(e){throw new p(`Encrypted token file is not valid JSON: ${T(e)}`)}if(!((t=s)&&"object"==typeof t&&1===t.version&&t.algorithm===u&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new p("Encrypted token file has an unsupported format");let d=await this.readMasterKey();try{let t=o.createDecipheriv(u,d,Buffer.from(s.iv,"base64url"));return t.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8")),t.setAuthTag(Buffer.from(s.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(s.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new p(`Failed to decrypt encrypted token file: ${T(e)}`)}}async set(e,t){var n;let r=await this.readOrCreateMasterKey(),i=o.randomBytes(12),s=o.createCipheriv(u,r,i);s.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8"));let a=Buffer.concat([s.update(t,"utf8"),s.final()]),d={version:1,algorithm:u,iv:i.toString("base64url"),authTag:s.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await _(this.credentialFilePath(e),`${JSON.stringify(d,null,2)}
10
10
  `)}async delete(e){try{await i.promises.unlink(this.credentialFilePath(e))}catch(e){if(!I(e)||"ENOENT"!==e.code)throw new p(`Failed to delete encrypted token file: ${T(e)}`)}}masterKeyPath(){return a.join(this.baseDir,"master.key")}credentialFilePath(e){let t=o.createHash("sha256").update(e).digest("hex");return a.join(this.baseDir,"credentials",`${t}.json`)}async readMasterKey(){try{var e=await i.promises.readFile(this.masterKeyPath(),"utf8");let t=Buffer.from(e.trim(),"base64url");if(32!==t.length)throw new p("Encrypted token master key has an unsupported format");return t}catch(e){if(I(e)&&"ENOENT"===e.code)throw new p("Encrypted token master key is missing");if(e instanceof p)throw e;throw new p(`Failed to read encrypted token master key: ${T(e)}`)}}async readOrCreateMasterKey(){try{return await this.readMasterKey()}catch(e){if(!(e instanceof p)||!e.message.includes("master key is missing"))throw e}let e=o.randomBytes(32);try{return await _(this.masterKeyPath(),`${e.toString("base64url")}
11
- `),e}catch(e){if(I(e)&&"EEXIST"===e.code)return this.readMasterKey();throw new p(`Failed to write encrypted token master key: ${T(e)}`)}}}class g{async get(e){try{let{stdout:t}=await d("security",["find-generic-password","-a",e,"-s",l,"-w"]);return String(t).replace(/\n$/,"")}catch(e){if(b(e))return;throw new p(`Failed to read token from macOS Keychain: ${T(e)}`)}}async set(e,t){try{await d("security",["add-generic-password","-a",e,"-s",l,"-w",t,"-U"])}catch(e){throw new p(`Failed to write token to macOS Keychain: ${T(e)}`)}}async delete(e){try{await d("security",["delete-generic-password","-a",e,"-s",l])}catch(e){if(b(e))return;throw new p(`Failed to delete token from macOS Keychain: ${T(e)}`)}}}class y{async get(e){try{let{stdout:t}=await d("secret-tool",["lookup","service",l,"account",e]);return String(t).replace(/\n$/,"")}catch(e){if(w(e))return;throw new p(`Failed to read token from Secret Service: ${T(e)}`)}}async set(e,t){try{var n,o,i;await (n="secret-tool",o=["store","--label","Doubao Open CLI token","service",l,"account",e],i=t,new Promise((e,t)=>{let s=(0,r.spawn)(n,o,{stdio:["pipe","ignore","pipe"]}),a="";s.stderr.setEncoding("utf8"),s.stderr.on("data",e=>{a+=String(e)}),s.on("error",t),s.on("close",r=>{0===r?e():t(Error(a.trim()||`${n} exited with code ${r}`))}),s.stdin.end(i)}))}catch(e){throw new p(`Failed to write token to Secret Service: ${T(e)}`)}}async delete(e){try{await d("secret-tool",["clear","service",l,"account",e])}catch(e){if(w(e))return;throw new p(`Failed to delete token from Secret Service: ${T(e)}`)}}}async function _(e,t){let n=a.dirname(e);await i.promises.mkdir(n,{recursive:!0,mode:448}),"win32"!==process.platform&&await i.promises.chmod(n,448);let r=a.join(n,`.${a.basename(e)}.${process.pid}.${Date.now()}.tmp`);try{await i.promises.writeFile(r,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await i.promises.chmod(r,384),await i.promises.rename(r,e),"win32"!==process.platform&&await i.promises.chmod(e,384)}finally{try{await i.promises.unlink(r)}catch{}}}function b(e){let t=v(e),n=E(e);return(1===t||44===t)&&(n.includes("could not be found")||n.includes("The specified item could not be found"))}function w(e){let t=v(e),n=E(e);return 1===t&&(n.includes("could not be found")||n.includes("No matching items")||""===n.trim())}function v(e){return"object"==typeof e&&null!==e&&"code"in e?e.code:void 0}function E(e){return"object"==typeof e&&null!==e&&"stderr"in e?String(e.stderr??""):""}function I(e){return e instanceof Error&&"code"in e}function T(e){if("object"==typeof e&&null!==e&&"stderr"in e){let t=String(e.stderr??"").trim();if(t)return t}return e instanceof Error&&e.message?e.message:String(e)}n.d(t,{Mj:()=>h,RI:()=>p})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function d(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,l=t.sleep??_,c=await u(n,t.baseUrl,t.requestHeaders),h=b(t.baseUrl,c.user_code);t.onVerification?.({userCode:c.user_code,verificationUrl:h,expiresIn:c.expires_in,interval:c.interval});let f=Math.max(1,c.interval),m=Date.now()+1e3*c.expires_in;for(;Date.now()<m;){await l(1e3*f);let e=await p(n,t.baseUrl,c.device_code,t.requestHeaders);if(t.onPoll?.({status:e.status,interval:f}),e.status!==a.A.Pending){if(e.status===a.A.SlowDown){f+=Math.max(1,c.interval);continue}if(e.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(e.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(e.status===a.A.Authorized){if(!e.access_token)throw new o.JC("Authorization response did not include an access token");let n=y(e,t.baseUrl);return await (0,s.tK)(t.tokenPath,n,{credentialStore:t.credentialStore}),{accessToken:n.accessToken,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl,uid:(0,i.m)(n.accessToken),tokenPath:t.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(e.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function l(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,o=await u(n,t.baseUrl,t.requestHeaders),i=b(t.baseUrl,o.user_code);return t.onVerification?.({userCode:o.user_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}),{userCode:o.user_code,deviceCode:o.device_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}}async function c(e,t={}){let n=(0,r.$i)(t),d=n.fetch??fetch,l=n.sleep??_,u=n.baseUrl,h=n.requestHeaders,f=5,m=Date.now()+6e5;for(;Date.now()<m;){await l(1e3*f);let t=await p(d,u,e,h);if(n.onPoll?.({status:t.status,interval:f}),t.status!==a.A.Pending){if(t.status===a.A.SlowDown){f+=5;continue}if(t.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(t.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(t.status===a.A.Authorized){if(!t.access_token)throw new o.JC("Authorization response did not include an access token");let e=y(t,u);return await (0,s.tK)(n.tokenPath,e,{credentialStore:n.credentialStore}),{accessToken:e.accessToken,tokenType:e.tokenType,expiresAt:e.expiresAt,baseUrl:e.baseUrl,uid:(0,i.m)(e.accessToken),tokenPath:n.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(t.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function u(e,t,n){let i=await e(`${t}/app_developer/oauth/device/code`,{method:"POST",headers:g(n),body:JSON.stringify({client_name:r.E})}),s=await h(i),a=m(s);if(!a||!a.device_code||!a.user_code||"number"!=typeof a.expires_in||"number"!=typeof a.interval)throw new o.JC(`Device code response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return a}async function p(e,t,n,r){let i=await e(`${t}/app_developer/oauth/token`,{method:"POST",headers:g(r),body:JSON.stringify({device_code:n})}),s=await h(i),d=m(s);if(d?.access_token)return{status:a.A.Authorized,access_token:d.access_token,token_type:d.token_type,expires_in:d.expires_in,expires_at:d.expires_at};if(!d||"number"!=typeof d.status)throw new o.JC(`Token response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return d}async function h(e){var t;let n,r=e.headers.get("x-tt-logid")??void 0;try{n=await e.json()}catch{throw new o.JC(`Auth server returned non-JSON response with status ${e.status}${f(r)}`,"DEVICE_AUTH_FAILED",{logId:r})}let i=function(e){if(e&&"object"==typeof e)return"string"==typeof e.log_id&&e.log_id?e.log_id:void 0}(n)??r;if(!e.ok)throw new o.JC(`Auth server returned HTTP ${e.status}: ${JSON.stringify(n)}${f(i)}`,"DEVICE_AUTH_FAILED",{logId:i});let s=(t=n)&&"object"==typeof t&&"number"==typeof t.code&&0!==t.code?{code:t.code,message:"string"==typeof t.message?t.message:"Unknown error",logId:"string"==typeof t.log_id?t.log_id:void 0}:null;if(s)throw new o.JC(`Auth server error (code ${s.code}): ${s.message}${f(s.logId??i)}`,"DEVICE_AUTH_FAILED",{logId:s.logId??i});return n}function f(e){return e?` [log_id: ${e}]`:""}function m(e){return e&&"object"==typeof e&&"data"in e?e.data:e}function g(e){let t=new Headers(e);return t.set("Content-Type","application/json"),t}function y(e,t){let n=Math.floor(Date.now()/1e3);return{accessToken:e.access_token??"",tokenType:e.token_type??"Bearer",expiresAt:"number"==typeof e.expires_at?e.expires_at:n+(e.expires_in??0),baseUrl:t}}function _(e){return new Promise(t=>{setTimeout(t,e)})}function b(e,t){let n=new URL(e).host,r=new URL(`https://${n}/oauth/device`);return r.searchParams.set("user_code",t),r.toString()}n.d(t,{R$:()=>c,c$:()=>l,iD:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"(e,t,n){class r extends Error{constructor(e,t){super(e),this.code=t,this.name="AuthError"}}class o extends r{constructor(e="Not logged in"){super(e,"NOT_LOGGED_IN"),this.name="NotLoggedInError"}}class i extends r{constructor(e="Login token has expired"){super(e,"TOKEN_EXPIRED"),this.name="TokenExpiredError"}}class s extends r{constructor(e,t="DEVICE_AUTH_FAILED",n={}){super(e,t),this.name="DeviceAuthError",this.logId=n.logId}}n.d(t,{BX:()=>i,JC:()=>s,bG:()=>o,lR:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/store.js");function s(e=fetch,t={}){return async(n,s={})=>{let a=(0,o.$i)(t);var d=n,l=a.allowedOrigins;let c=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return e;return new URL(e.url)}catch{throw Error("Authenticated requests must use an absolute HTTPS URL")}}(d);if("https:"!==c.protocol)throw Error(`Authenticated requests must use https: ${c.toString()}`);if(!l.includes(c.origin))throw Error(`Refusing to attach Authorization header to untrusted origin: ${c.origin}`);let u=await (0,i.AI)(a.tokenPath,{allowExpired:!0,envTokenBaseUrl:a.baseUrl,credentialStore:a.credentialStore,legacyTokenPath:a.legacyTokenPath});if(!u)throw new r.bG;if((0,i._d)(u))throw new r.BX;let p=new Headers(s.headers);return a.requestHeaders.forEach((e,t)=>{p.set(t,e)}),p.set("Authorization",`${u.tokenType||"Bearer"} ${u.accessToken}`),e(n,{...s,headers:p})}}n.d(t,{r:()=>s})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"(e,t,n){n.r(t);var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"),d=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),l=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function c(e={}){let t=(0,r.$i)(e);await (0,s.ni)(t.tokenPath,{credentialStore:t.credentialStore}),t.legacyTokenPath&&await (0,s.ni)(t.legacyTokenPath,{credentialStore:t.credentialStore})}async function u(e={}){let t,n=(0,r.$i)(e);try{t=await (0,s.AI)(n.tokenPath,{envTokenBaseUrl:n.baseUrl,credentialStore:n.credentialStore,legacyTokenPath:n.legacyTokenPath})}catch(e){if(e instanceof o.RI)return{loggedIn:!1,tokenPath:n.tokenPath,baseUrl:n.baseUrl,credentialError:{code:"CREDENTIAL_STORE_UNAVAILABLE",message:e.message}};throw e}if(!t)return{loggedIn:!1,tokenPath:n.tokenPath};let i=await p(e.fetch??fetch,n.baseUrl,t,n.requestHeaders);return i?{loggedIn:!0,uid:i.userId,name:i.name,avatar:i.avatar,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}:{loggedIn:!1,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}}async function p(e,t,n,r){let o=new Headers(r);o.set("Authorization",`${n.tokenType||"Bearer"} ${n.accessToken}`);let i=await e(`${t.replace(/\/+$/,"")}/app_developer/api/user/basic`,{method:"GET",headers:o});if(!i.ok)return;let s=await i.json();if(0===s.code){var a;return{userId:"string"==typeof(a=s.data?.user_id)&&a.length>0?a:"number"==typeof a&&Number.isFinite(a)?String(a):void 0,name:s.data?.name,avatar:s.data?.avatar}}}n.d(t,{AuthError:()=>d.lR,CredentialStoreError:()=>o.RI,DeviceAuthError:()=>d.JC,NotLoggedInError:()=>d.bG,TokenExpiredError:()=>d.BX,TokenStatus:()=>l.A,completeLogin:()=>i.R$,configureAuth:()=>r.ZI,login:()=>i.iD,logout:()=>c,startLogin:()=>i.c$,whoami:()=>u,withAuth:()=>a.r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"(e,t,n){function r(e){let t=function(e){let t=e.split(".")[1];if(t)try{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(e.length+(4-e.length%4)%4,"="),r=Buffer.from(n,"base64").toString("utf8"),o=JSON.parse(r);return o&&"object"==typeof o?o:void 0}catch{return}}(e),n=t?.uid??t?.sub;return"string"==typeof n&&n.length>0?n:"number"==typeof n&&Number.isFinite(n)?String(n):void 0}n.d(t,{m:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"(e,t,n){var r=n("node:fs"),o=n("node:crypto"),i=n("node:path"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js");async function a(e,t={}){let n,r=process.env.DBX_ACCESS_TOKEN?.trim()||void 0;if(r)return{accessToken:r,tokenType:"Bearer",expiresAt:0xf4865700,baseUrl:t.envTokenBaseUrl??""};let o=await h(e);if(void 0===o)return f(e,t);try{n=JSON.parse(o)}catch(e){return}if(p(n)){if(!t.allowExpired&&c(n))return void await l(e,t);let r=await m(t).get(n.credentialAccount);if(!r)throw new s.RI("Stored login metadata exists, but the token credential is missing or inaccessible. Run dbx auth login again from a terminal that can access the credential store.");return{accessToken:r,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl}}if(u(n))return!t.allowExpired&&c(n)?void await l(e,t):(await d(e,n,t),n)}async function d(e,t,n={}){let o={version:2,storage:"keychain",credentialAccount:g(e),tokenType:t.tokenType,expiresAt:t.expiresAt,baseUrl:t.baseUrl};await m(n).set(o.credentialAccount,t.accessToken),await r.promises.mkdir(i.dirname(e),{recursive:!0,mode:448}),"win32"!==process.platform&&await r.promises.chmod(i.dirname(e),448);let s=`${e}.${process.pid}.${Date.now()}.tmp`;await r.promises.writeFile(s,`${JSON.stringify(o,null,2)}
12
- `,{mode:384}),"win32"!==process.platform&&await r.promises.chmod(s,384),await r.promises.rename(s,e),"win32"!==process.platform&&await r.promises.chmod(e,384)}async function l(e,t={}){let n=await h(e);if(void 0!==n)try{let r=JSON.parse(n);p(r)?await m(t).delete(r.credentialAccount):await m(t).delete(g(e))}catch{}try{await r.promises.unlink(e)}catch(e){if(!y(e)||"ENOENT"!==e.code)throw e}}function c(e,t=Math.floor(Date.now()/1e3)){return e.expiresAt<=t}function u(e){return!!e&&"object"==typeof e&&"string"==typeof e.accessToken&&e.accessToken.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}function p(e){return!!e&&"object"==typeof e&&2===e.version&&"keychain"===e.storage&&"string"==typeof e.credentialAccount&&e.credentialAccount.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}async function h(e){try{return await r.promises.readFile(e,"utf8")}catch(e){y(e)&&e.code;return}}async function f(e,t){let n;if(!t.legacyTokenPath||i.resolve(t.legacyTokenPath)===i.resolve(e))return;let r=await h(t.legacyTokenPath);if(void 0!==r){try{n=JSON.parse(r)}catch{return}if(u(n))return!t.allowExpired&&c(n)?void await l(t.legacyTokenPath,t):(await d(e,n,t),await l(t.legacyTokenPath,t),n)}}function m(e){return e.credentialStore??(0,s.Mj)()}function g(e){let t=o.createHash("sha256").update(i.resolve(e)).digest("hex").slice(0,32);return`token:${t}`}function y(e){return e instanceof Error&&"code"in e}n.d(t,{AI:()=>a,_d:()=>c,ni:()=>l,tK:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.17/node_modules/@byted-doubao-apps/auth-cli/dist/types.js"(e,t,n){var r,o;(o=r||(r={}))[o.Pending=1]="Pending",o[o.Authorized=2]="Authorized",o[o.Expired=3]="Expired",o[o.Invalid=4]="Invalid",o[o.SlowDown=5]="SlowDown",n.d(t,{A:()=>r})}});var S={};e.r(S),e.d(S,{createDeferredDevShellSession:()=>t6,default:()=>t5,isInteractiveTerminal:()=>t7,withWebDebuggerFallback:()=>t9});let P=e("node:zlib"),D=e("../../../node_modules/.pnpm/@byted-doubao-tools+devtool-connection-core@0.1.0-beta.11_debug@4.4.3_react@19.2.7/node_modules/@byted-doubao-tools/devtool-connection-core/dist/lib/ipc/index.js"),x=4*Math.ceil(5614250.666666667),$=new Map;class L extends Error{code;cause;constructor(e,t,n){super(t),this.code=e,this.name="RuntimeInspectionError",n&&"cause"in n&&(this.cause=n.cause)}}async function R(e){let t,n=new g(e.namespace,{nodeId:`${e.nodeIdPrefix}-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:12e3}),r=new Set,o=new Set,s=0,a=!0;n.createService({name:`runtimeInspection${process.pid}${Math.random().toString(36).slice(2,8)}`,events:{[D.DEVTOOL_CONNECTION_IPC_EVENTS.messageReceived](e){let n=e.params,o=function(e){if("Page.screencastFrame"===e.method&&i(e.params)&&"string"==typeof e.params.data&&e.params.data)return{data:e.params.data}}(n);for(let e of(o&&Number.isSafeInteger(n.clientId)&&Number.isSafeInteger(n.sessionId)&&(t={clientId:n.clientId,sessionId:n.sessionId,data:o.data}),r))e(n)},[f.runtimeInspectionTargetChanged](e){let t=function(e){if(i(e)&&"number"==typeof e.clientId&&"number"==typeof e.sessionId&&"string"==typeof e.url)return{clientId:e.clientId,sessionId:e.sessionId,url:e.url}}(e.params);if(t)for(let e of o)e(t)}}});try{await n.start()}catch(e){throw await n.stop().catch(()=>void 0),e}let d=(e,t)=>ed(()=>n.call(`${D.DEFAULT_DEVTOOL_CONNECTION_IPC_SERVICE_NAME}.${e}`,t),5e3);return{eventSubscriptionWarmupMs:e.eventSubscriptionWarmupMs??5e3,getConnectedClients:()=>d(D.DEVTOOL_CONNECTION_IPC_ACTIONS.getConnectedClients),getLatestScreencastFrame(e){if(t?.clientId===e.clientId&&t.sessionId===e.sessionId)return{data:t.data}},async getRuntimeInspectionTarget(){if(!a)return null;try{return await n.call(c.getRuntimeInspectionTarget)}catch(e){if(ea(e))return a=!1,null;throw e}},subscribeRuntimeInspectionTarget:e=>(o.add(e),()=>{o.delete(e)}),async sendCdp(e,t,n={},r={}){let o={id:1e9+process.pid%1e5*1e3+s++,clientId:e.clientId,sessionId:e.sessionId,method:t,params:n,messageType:"CDP",timeoutMs:!1===r.expectResponse?100:1e4};try{let e=await d(D.DEVTOOL_CONNECTION_IPC_ACTIONS.sendMessageToApp,o);var a,l,c=t,u=e;if(!u.success)throw Error([u.reason,u.apps?.length?`apps=${u.apps.join(",")}`:"",u.clients?.length?`clients=${u.clients.map(e=>`${e.clientId}:${e.info.App}`).join(",")}`:""].filter(Boolean).join("; "));if(i(u.data)&&i(u.data.error)){let e=void 0===u.data.error.code?"unknown":String(u.data.error.code),t=void 0===u.data.error.message?"unknown error":String(u.data.error.message);throw Error(`${c} failed: ${t} (code=${e})`)}return Y(u.data)}catch(e){if(!1===r.expectResponse&&(a=e,l=t,(a instanceof Error?a.message:String(a)).includes(`send CDP message timeout, method: ${l}`)))return;throw Error(`${t} failed: ${e instanceof Error?e.message:String(e)}`)}},subscribeMessage:e=>(r.add(e),()=>{r.delete(e)}),async stop(){r.clear(),o.clear(),t=void 0,await n.stop()}}}async function N(e,t={}){let n=Date.now()+(t.timeoutMs??3e3);for(;;){ec(t.signal);let r=await e.getConnectedClients(),o=function(e,t={}){let n,r=t.explicitTarget??(t.policy?.kind==="fixed"?t.policy.target:void 0);if(r){let n=e.find(e=>e.device.clientId===r.clientId);if(!n){if(t.activeClientId===r.clientId)throw new L("TARGET_CLIENT_DISCONNECTED",`debug client ${r.clientId} is disconnected`);throw new L("TARGET_STALE",`${O(r)} no longer points to a connected debug client`)}let o=n.sessions.find(e=>e.sessionId===r.sessionId&&V(e));if(!o)throw new L("TARGET_STALE",`${O(r)} no longer points to a live Lynx session`);return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}if(void 0!==t.activeClientId){if(!(n=e.find(e=>e.device.clientId===t.activeClientId)))throw new L("TARGET_CLIENT_DISCONNECTED",`authenticated debug client ${t.activeClientId} is disconnected`)}else if(e.length>1)throw new L("TARGET_AMBIGUOUS",`more than one debug device is connected: ${e.map(e=>`${e.device.clientId}:${e.device.info.App||"unknown"}`).join(", ")}`);else n=e[0];if(!n)return;let o=n.sessions.filter(V).sort((e,t)=>t.sessionId-e.sessionId)[0];if(o)return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}(r,t);if(o)return o;if(Date.now()>=n)throw 0===r.length?new L("DEVICE_NOT_CONNECTED","no debug device is connected"):new L("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");await eu(100,t.signal)}}function O(e){return`@${e.clientId}:${e.sessionId}`}function q(e){let t=/^@([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new L("INVALID_TARGET_REF",`invalid target ref "${e}"; expected @<clientId>:<sessionId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId))throw new L("INVALID_TARGET_REF",`invalid target ref "${e}"; every id must be a safe integer`);return n}function M(e){return`@${e.clientId}:${e.sessionId}:${e.nodeId}`}async function B(e,t){let n=(await e.getConnectedClients()).find(e=>e.device.clientId===t.clientId),r=n?.sessions.find(e=>e.sessionId===t.sessionId&&V(e));if(!n||!r)throw new L("STALE_NODE_REF",`${M(t)} no longer points to a live Lynx session; run get-page-tree again`);return{clientId:t.clientId,sessionId:t.sessionId,url:r.url}}async function U(e,t,n={}){var r,o,s;let a,d,l,c,u,p=n.depth??-1,h=n.maxNodes??5e3;if(!Number.isInteger(p)||p<-1)throw Error("page tree depth must be -1 or a non-negative integer");if(!Number.isSafeInteger(h)||h<1)throw Error("page tree maxNodes must be a positive integer");await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{u=await e.sendCdp(t,"DOM.getDocument",{depth:p})}catch{u=await e.sendCdp(t,"DOM.getDocument")}let f=function(e){let t=Y(e);if(!i(t))throw ee("DOM.getDocument","response is not an object");let n=t.root;if(!0===t.compress&&"string"==typeof n)try{if(n.length>x)throw Error("compressed root exceeds the input limit");n=JSON.parse((0,P.inflateSync)(Buffer.from(n,"base64"),{maxOutputLength:0x1000000}).toString("utf8"))}catch(e){throw ee("DOM.getDocument","failed to decode compressed root",e)}else if("string"==typeof n)try{n=JSON.parse(n)}catch(e){throw ee("DOM.getDocument","root is not valid JSON",e)}if(!i(n))throw ee("DOM.getDocument","missing root node");return n}(u),m=await K(e,t,f,p,h),g=(r=f,o=t,s=h,a=0,d=!1,l=[],{root:(c=e=>{var t;let n=G(e.nodeId),r="string"==typeof e.nodeName&&e.nodeName?e.nodeName:"unknown";if(void 0===n)throw ee("DOM.getDocument",`node ${r} has no valid nodeId`);a++;let i=[],u={ref:M({clientId:o.clientId,sessionId:o.sessionId,nodeId:n}),nodeId:n,...void 0===G(e.backendNodeId)?{}:{backendNodeId:G(e.backendNodeId)},nodeType:"number"==typeof e.nodeType&&Number.isSafeInteger(e.nodeType)?e.nodeType:0,nodeName:r,..."string"==typeof e.localName?{localName:e.localName}:{},nodeValue:"string"==typeof e.nodeValue?e.nodeValue:"",attributes:function(e){if(!Array.isArray(e))return{};let t={};for(let n=0;n<e.length;n+=2){let r=e[n];if("string"!=typeof r||!r)continue;let o=e[n+1];t[r]="string"==typeof o?o:String(o??"")}return t}(e.attributes),childNodeCount:"number"==typeof e.childNodeCount&&Number.isSafeInteger(e.childNodeCount)?Math.max(0,e.childNodeCount):J(e).length,children:i};for(let t of(W(u)&&u.nodeValue&&(u.text=u.nodeValue),J(e))){if(a>=s){d=!0;break}i.push(c(t))}if("text"===((t=u).localName||t.nodeName).toLowerCase()){let e=function e(t){return t.children.flatMap(t=>W(t)?[t.nodeValue]:[e(t)]).join("")}(u);e?u.text=e:l.push(u)}return u})(r),nodeCount:a,truncated:d,textCandidates:l});return await Q(e,t,g.textCandidates),{target:t,depth:p,nodeCount:g.nodeCount,truncated:m.truncated||g.truncated,root:g.root}}async function F(e,t,n,r=[]){let o;await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{o=await e.sendCdp(t,"CSS.getComputedStyleForNode",{nodeId:n.nodeId})}catch(e){var s;if(s=e,/(could not find|cannot find|no such|unknown|invalid|stale).{0,40}node|node.{0,40}(not found|does not exist|invalid|stale)/i.test(s instanceof Error?s.message:String(s)))throw new L("STALE_NODE_REF",`${M(n)} is stale; run get-page-tree again`,{cause:e});throw e}let a=Y(o);if(!i(a)||!Array.isArray(a.computedStyle))throw ee("CSS.getComputedStyleForNode","missing computedStyle array");let d=a.computedStyle.filter(i).flatMap(e=>"string"==typeof e.name&&"string"==typeof e.value?[{name:e.name,value:e.value}]:[]),l=0===r.length?d:r.flatMap(e=>{let t=d.find(t=>t.name===e);return t?[t]:[]});return{target:t,nodeRef:M(n),nodeId:n.nodeId,properties:l}}function V(e){return"lynx"===e.type&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!z(e.url)}function H(e){return`${e.clientId}:${e.sessionId}`}function z(e){return/(?:-main\.js|\.main\.lynx\.js)(?:[?#].*)?$/.test(e)}async function K(e,t,n,r,o){let s=0,a=!1,d=async(n,l)=>{if(s>=o){a=!0;return}if(s++,r>=0&&l>=r)return;let c=J(n);if(("number"==typeof n.childNodeCount&&Number.isSafeInteger(n.childNodeCount)?Math.max(0,n.childNodeCount):c.length)>c.length&&"number"==typeof n.nodeId&&Number.isSafeInteger(n.nodeId)){let r=Y(await e.sendCdp(t,"DOM.requestChildNodes",{nodeId:n.nodeId}));if(!i(r)||!Array.isArray(r.nodes))throw ee("DOM.requestChildNodes",`missing nodes array for node ${n.nodeId}`);n.children=c=r.nodes.filter(i)}for(let e of c)if(await d(e,l+1),s>=o){c.indexOf(e)<c.length-1&&(a=!0);break}};return await d(n,0),{truncated:a}}function Y(e){return i(e)&&"id"in e&&"result"in e?e.result:e}function J(e){return Array.isArray(e.children)?e.children.filter(i):[]}function G(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0?e:void 0}function W(e){return 3===e.nodeType||"#text"===e.nodeName.toLowerCase()}async function Q(e,t,n){let r=n[0];if(!r)return;let o=await X(e,t,r);if(o.supported){o.text&&(r.text=o.text);for(let r=1;r<n.length;r+=8){let o=n.slice(r,r+8);await Promise.all(o.map(async n=>{let r=await X(e,t,n);r.text&&(n.text=r.text)}))}}}async function X(e,t,n){try{let r=Y(await e.sendCdp(t,"DOM.innerText",{nodeId:n.nodeId}));if(!i(r)||!Array.isArray(r.rawTextValues))return{supported:!1};let o=r.rawTextValues.filter(i).flatMap(e=>"string"==typeof e.text?[e.text]:[]).join("");return{supported:!0,...o?{text:o}:{}}}catch{return{supported:!1}}}function Z(e,t=120){let n=e.replace(/\s+/g," ").trim();return JSON.stringify(n.length>t?`${n.slice(0,Math.max(0,t-1))}…`:n)}function ee(e,t,n){return new L("INVALID_CDP_RESPONSE",`${e} returned an invalid response: ${t}`,void 0===n?void 0:{cause:n})}async function et(e,t,n){let r,o,s,a=0,d=!1,l=H(t),c=new Promise((e,t)=>{o=e,s=t}),u=e=>{d||(d=!0,o({count:a,reason:e}))},p=()=>u("aborted"),h=e.getRuntimeInspectionTarget?.bind(e),f=e=>{if(d||!(Number.isSafeInteger(e.clientId)&&e.clientId>0&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!z(e.url)))return;let r=H(e);if(r!==l&&(l=r,r!==H(t)))try{n.onTargetChange?.(e)}catch{}},m=e.subscribeMessage(e=>{if(d||!er(e,t))return;let r=function(e){var t;if("Runtime.consoleAPICalled"!==e.method||!i(e.params))return;let n={...t=e.params,...Array.isArray(t.args)?{args:t.args.map(e=>i(e)?{...e}:e)}:{},...i(t.stackTrace)?{stackTrace:{...t.stackTrace,...Array.isArray(t.stackTrace.callFrames)?{callFrames:t.stackTrace.callFrames.map(e=>i(e)?{...e}:e)}:{}}}:{}},r="string"==typeof n.consoleTag?n.consoleTag:void 0;return{type:"string"==typeof n.type?n.type:"log",thread:"Lepus"===r?"main":"background",args:Array.isArray(n.args)?n.args:[],...r?{consoleTag:r}:{},..."number"==typeof n.timestamp?{timestamp:n.timestamp}:{},..."stackTrace"in n?{stackTrace:n.stackTrace}:{},params:n}}(e);if(r){try{n.onMessage(r)}catch(e){d||(d=!0,s(e));return}a++,void 0!==n.limit&&a>=n.limit&&u("limit")}}),g=n.onTargetChange?e.subscribeRuntimeInspectionTarget?.(f):void 0;n.signal?.addEventListener("abort",p,{once:!0}),n.onTargetChange&&h&&h().then(e=>{e&&f(e)}).catch(()=>void 0);try{if(n.signal?.aborted)return u("aborted"),await c;if(await eo(e,t,n.subscriptionWarmupMs??e.eventSubscriptionWarmupMs??5e3,n.signal),d)return await c;for(let o of(void 0!==n.timeoutMs&&(r=setTimeout(()=>u("timeout"),n.timeoutMs)),[{method:"Page.getResourceTree",params:{}},{method:"Debugger.enable",params:{}},{method:"Runtime.enable",params:{}}])){if(d)break;await e.sendCdp(t,o.method,o.params,{expectResponse:!1})}return await c}catch(e){if(n.signal?.aborted)return u("aborted"),await c;throw e}finally{r&&clearTimeout(r),n.signal?.removeEventListener("abort",p),g?.(),m()}}async function en(e,t,n={}){return el(t,async()=>{let r,o=new Promise(e=>{r=e}),s=e.subscribeMessage(e=>{er(e,t)&&"Page.screencastFrame"===e.method&&i(e.params)&&"string"==typeof e.params.data&&e.params.data&&r({data:e.params.data})}),a=!1;try{var d,l,c;await eo(e,t,e.eventSubscriptionWarmupMs??5e3);let r=n.activeCapture?void 0:e.getLatestScreencastFrame?.(t);!r&&n.activeCapture&&(await e.sendCdp(t,"Page.enable"),a=!0,await e.sendCdp(t,"Page.startScreencast",{format:"jpeg",quality:80},{expectResponse:!1})),r??=await (d=o,l=t,c=n.timeoutMs??1e4,new Promise((e,t)=>{let n=setTimeout(()=>t(new L("SCREENSHOT_TIMEOUT",`no Page.screencastFrame received for ${O(l)} within ${c}ms; make sure the target session is active and can produce screenshot frames`)),c);d.then(t=>{clearTimeout(n),e(t)},e=>{clearTimeout(n),t(e)})})),a&&await e.sendCdp(t,"Page.screencastFrameAck",{},{expectResponse:!1}).catch(()=>void 0);let i=function(e){let t=e.replace(/\s+/g,"");if(!t||t.length%4!=0||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame returned invalid base64 data");let n=Buffer.from(t,"base64");if(n.length<4||255!==n[0]||216!==n[1]||255!==n[n.length-2]||217!==n[n.length-1])throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame did not return a complete JPEG image");let r=function(e){let t=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]),n=2;for(;n+3<e.length;){if(255!==e[n]){n++;continue}for(;n<e.length&&255===e[n];)n++;let r=e[n++];if(void 0===r||217===r||218===r)break;if(1===r||r>=208&&r<=215)continue;if(n+1>=e.length)break;let o=e.readUInt16BE(n);if(o<2||n+o>e.length)break;if(t.has(r)){if(o<7)break;let t=e.readUInt16BE(n+3),r=e.readUInt16BE(n+5);if(r>0&&t>0)return{width:r,height:t};break}n+=o}}(n);if(!r)throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame JPEG has no readable dimensions");return{buffer:n,data:t,...r}}(r.data);return{data:i.data,format:"jpeg",source:"Page.screencastFrame",width:i.width,height:i.height,byteLength:i.buffer.length}}finally{a&&await e.sendCdp(t,"Page.stopScreencast",{},{expectResponse:!1}).catch(()=>void 0),s()}})}function er(e,t){return"CDP"===e.messageType&&e.clientId===t.clientId&&e.sessionId===t.sessionId}async function eo(e,t,n,r){let o;if(n<=0)return;let i=Date.now()+n,s=new Promise(e=>{o=e}),a=e.subscribeMessage(e=>{er(e,t)&&o()});try{for(;Date.now()<i;){if(ec(r),await e.sendCdp(t,"Page.getResourceTree",{},{expectResponse:!1}).catch(()=>void 0),await function(e,t,n){return new Promise((r,o)=>{let i=new AbortController,s=setTimeout(()=>{i.abort(),r(!1)},t);n?.addEventListener("abort",()=>{clearTimeout(s),i.abort(),o(n?.reason instanceof Error?n.reason:Error("operation aborted"))},{once:!0,signal:i.signal}),e.then(()=>{clearTimeout(s),i.abort(),r(!0)},e=>{clearTimeout(s),i.abort(),o(e)})})}(s,Math.min(250,Math.max(0,i-Date.now())),r))return;await eu(Math.min(50,Math.max(0,i-Date.now())),r)}}finally{a()}}function ei(e){return i(e)?e.objectId?`<${String(e.description||e.className||"Object")} (objectId:${String(e.objectId)})>`:"value"in e?es(e.value):"string"==typeof e.description?e.description:es(e):es(e)}function es(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";try{let t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}function ea(e){return/is not (found|available)/i.test(e instanceof Error?e.message:String(e))}async function ed(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(!ea(e)||Date.now()>=n)throw e;await eu(50)}}async function el(e,t){let n,r=H(e),o=$.get(r)??Promise.resolve(),i=new Promise(e=>{n=e});$.set(r,i),await o.catch(()=>void 0);try{return await t()}finally{n(),$.get(r)===i&&$.delete(r)}}function ec(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:Error("operation aborted")}function eu(e,t){return new Promise((n,r)=>{if(t?.aborted)return void r(t.reason instanceof Error?t.reason:Error("operation aborted"));let o=new AbortController,i=setTimeout(()=>{o.abort(),n()},e);t?.addEventListener("abort",()=>{clearTimeout(i),o.abort(),r(t?.reason instanceof Error?t.reason:Error("operation aborted"))},{once:!0,signal:o.signal})})}let ep={schemaVersion:1,cliVersion:o,deviceAppVersion:"1.0.7",packages:{"darwin-arm64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/440719597/1.0.7/darwin-arm64/DoubaoDeveloperTools-v1.0.7-darwin-arm64.zip",sha256:"050c45bf3eba444343a9e49d951c4c98851f1c81412d6ab3f08c05e201634c1f",entry:"豆包开发者工具.app",sizeBytes:0x77fdd18},"win32-x64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/440719597/1.0.7/win32-x64/DoubaoDeveloperTools-v1.0.7-win32-x64.zip",sha256:"455cc927477cd88a152ed2ec3ff1e92511996a8fb5ebfa59625b5b8884671848",entry:"豆包开发者工具.exe",sizeBytes:0x84c4955}}},eh=e("node:child_process"),ef=e("node:crypto");var em=e.n(ef);let eg=e("node:fs");var ey=e.n(eg);let e_=e("node:http"),eb=e("node:os");var ew=e.n(eb);let ev=e("node:path");var eE=e.n(ev);let eI=e("node:stream"),eT=e("node:url"),eA=e("node:util"),eC=e("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"),ej=e("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"),ek="DBX_DEVICE_APP_PATH",eS="dbx-device-app.json",eP="state.json",eD="versions",ex=eE().dirname((0,eT.fileURLToPath)(import.meta.url)),e$=[{command:"web",description:"打开 Web 模拟器"},{command:"device",description:"进入真机调试"},{command:"status",description:"查看本地调试服务状态"}],eL=[{command:"qr",description:"重新生成真机调试二维码"},{command:"page [id]",description:"在真机打开页面(省略 id 可选择)"},{command:"pages",description:"列出真机可打开页面"},{command:"widget [id]",description:"向真机推送卡片(省略 id 可选择)"},{command:"widgets",description:"列出真机可推送卡片"},{command:"sessions",description:"列出当前可检查的 Lynx sessions"},{command:"use-session <@client:session|latest>",description:"固定 CLI session 或恢复跟随最新"},{command:"get-console",description:"持续输出当前 Lynx 页面新产生的日志"},{command:"take-screenshot",description:"截取当前 Lynx 页面画面"},{command:"get-page-tree",description:"获取当前 Lynx 页面的 DOM 树"},{command:"get-computed-style [node-ref]",description:"获取 DOM 节点的 computed style"},{command:"back",description:"返回主命令"}];function eR(e){if("complete"===e.phase)return`豆包开发者工具已安装:${e.appPath}`;if("install"===e.phase){let t={verify:"验证",extract:"解压",install:"安装"}[e.stage];return`安装豆包开发者工具:${t}`}let t=[void 0===e.percentage?void 0:`${e.percentage}%`,void 0===e.totalBytes?e.downloadedBytes>0?e9(e.downloadedBytes):void 0:`${e9(e.downloadedBytes)} / ${e9(e.totalBytes)}`,`${Math.max(0,Math.round(e.elapsedMs/1e3))}s`].filter(e=>!!e);return`下载豆包开发者工具:${t.join(" \xb7 ")}`}function eN(e,t){let n,r=!1;return o=>{if(!o)return void t?.(void 0);if("download"===o.phase){n=o,t?.(o);return}if(n&&!r&&(r=!0,t1(e,`✓ ${eR(n)}`)),"complete"===o.phase){t?.(void 0),t1(e,`✓ ${eR(o)}`);return}t?.(o)}}function eO(e,t){if("true"===e)return!0;if("false"===e)return!1;throw Error(`${t} must be "true" or "false"`)}async function eq(e){var t,n;let r,o,i,s,a,d=e.output??process.stderr,l=e.client??await m({projectPath:e.projectPath,appDir:e.appDir,nodeIdPrefix:"dev-shell"}),c=e.closeDeviceApp??eX,u=new AbortController,p=e.openBrowser??b,h=new Set,f={runtime:e.runtime,client:l,output:d,manageDeviceApp:!0,runtimeInspectionTargetPolicy:{kind:"latest"},openBrowser:p,openQRCodeViewer:e.openQRCodeViewer??((e,t,n)=>tW(e,p,t,d,n)),signal:u.signal,launchDeviceApp:e.launchDeviceApp??(e=>eG(e,d)),closeDeviceApp:c,prepareDeviceApp:e.prepareDeviceApp??(e=>eW(d,e)),...e.onDeviceAppSetupProgress?{onDeviceAppSetupProgress:e.onDeviceAppSetupProgress}:{},openPreparedDeviceApp:e.openPreparedDeviceApp??eQ,runRealDeviceAuth:e.runRealDeviceAuth??tO,...e.createRuntimeInspectionSession?{createRuntimeInspectionSession:e.createRuntimeInspectionSession}:{},listAppVersions:e.listAppVersions??(async e=>{let t=await _(e);return t.data?.version_list??[]}),selectItem:e.selectItem},y=(e.createRuntimeInspectionSession??R)({namespace:e.runtime.getState().namespace,nodeIdPrefix:"dev-shell-runtime-inspection"});y.catch(()=>void 0),f.runtimeInspectionSession=y;let w=async()=>s||(s=(async()=>{f.activeDeviceId=void 0,tG(),f.manageDeviceApp&&await eU(f)})().finally(()=>{s=void 0})),v=(t=e.runtime.getState().namespace,n=async()=>{if(f.activeDeviceId&&!a){t1(d,"检测到真机连接断开,正在返回主命令并清理真机调试资源..."),await w();for(let e of h)try{e("client-disconnected")}catch{}}},(r=new g(t,{nodeId:`dev-disconnect-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3})).createService({name:`devDisconnectListener${process.pid}`,events:{"connection.clientDisconnected":()=>n()}}),{start:()=>r.start(),stop:()=>r.stop()});return await v.start(),{stopped:e.runtime.stopped,getState:()=>e.runtime.getState(),execute(e){let t=new AbortController,n=AbortSignal.any([u.signal,t.signal]);i=t,f.signal=n;let r=eM(e,f);return o=r,r.finally(()=>{o===r&&(o=void 0),i===t&&(i=void 0),f.signal===n&&(f.signal=u.signal)})},cancelActiveCommand(){if(!i||i.signal.aborted)return!1;let e=Error("command cancelled");return e.name="AbortError",i.abort(e),!0},returnToRoot:()=>w(),handleClientDisconnected:()=>w(),subscribe:e=>(h.add(e),()=>{h.delete(e)}),close:()=>a??=(async()=>{u.abort(new tH),await o?.catch(()=>void 0),await v.stop().catch(()=>void 0),await w(),await f.runtimeInspectionSession?.then(e=>e.stop()).catch(()=>void 0),await l.stop().catch(()=>void 0),await e.runtime.stop().catch(()=>void 0)})()}}async function eM(e,t){var n;let r;try{r=function(e){let t,n=[],r="",o=!1,i=()=>{r.length>0&&(n.push(r),r="")};for(let n of e.trim()){if(o){r+=n,o=!1;continue}if("\\"===n&&"'"!==t){o=!0;continue}if("'"===n||'"'===n){if(!t){t=n;continue}if(t===n){t=void 0;continue}}if(!t&&/\s/.test(n)){i();continue}r+=n}if(o&&(r+="\\"),t)throw Error(`unterminated ${t} quote`);return i(),n}(e)}catch(e){return t1(t.output,tF(t4(e))),"continue"}let o=r[0]?.toLowerCase(),i=r.slice(1);if(!o)return"continue";if((n=i).includes("--help")||n.includes("-h")){let e="device"===o&&i[0]&&!i[0].startsWith("-")?`device ${i[0].toLowerCase()}`:o;if(function(e,t){switch(t){case"device widget":return t1(e,"usage: widget [widget-id] [--data <json>] [--bot-id <id>] [--device-id <id>]"),t1(e,"推送卡片到已连接真机;省略 widget-id 时从 `widgets` 列表中选择。"),t1(e,"需要非交互式 CLI 参数说明时,可运行:dbx dev push-widget --help"),!0;case"device page":return t1(e,"usage: page [page-id] [--data <json>] [--settings <value>] [--mode <full|popup|floating>] [--device-id <id>]"),t1(e,"打开页面到已连接真机;省略 page-id 时从 `pages` 列表中选择。"),t1(e,"需要非交互式 CLI 参数说明时,可运行:dbx dev push-page --help"),!0;case"device":t1(e,"usage: device [--agent] [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),t1(e,"进入真机模式并连接调试设备,默认准备并打开豆包开发者工具。"),t1(e,"使用 `device --agent` 进入 Agent 模式,不准备、启动或关闭豆包开发者工具。"),t1(e,"使用 --mcp 进入 MCP 端到端调试,并从当前 AppID 的版本列表中选择 versionTag。");for(let t of(t1(e,"真机调试命令"),eL))t1(e,` ${t.command.padEnd(22)}${t.description}`);return t1(e,"进入真机模式后执行 `<命令> --help` 查看参数。"),t1(e,"get-page-tree、get-computed-style、take-screenshot 支持通用的 --json 输出。"),!0;case"device qr":return t1(e,"usage: qr [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),t1(e,"重新生成真机调试二维码;MCP 端到端调试会沿用已选择的 versionTag,也可用 --mcp 重新选择。"),!0;case"device get-console":return t1(e,"usage: get-console [--target <@client:session>] [--limit <count>] [--timeout-seconds <seconds>] [--include-stack-traces]"),t1(e,"持续输出当前 Lynx session 新产生的 console 日志;按 Ctrl+C 停止监听并返回真机命令。"),t1(e,"默认仅 error 日志显示调用栈;使用 --include-stack-traces 展开所有日志的调用栈。"),!0;case"device sessions":return t1(e,"usage: sessions"),t1(e,"列出当前可检查的 Lynx sessions,并标记 latest、CLI fixed 和 Electron current。"),!0;case"device use-session":return t1(e,"usage: use-session <@client:session|latest>"),t1(e,"固定 CLI 后续检查命令使用的 session,或用 latest 恢复到鉴权 client 内最新活跃 session;不会切换 Electron。"),!0;case"device take-screenshot":return t1(e,"usage: take-screenshot [--target <@client:session>] [-o, --output <file.jpeg>] [--json]"),t1(e,"保存 Electron 当前为目标 session 输出的最近一帧 JPEG;截图范围跟随 Electron 当前 mode。"),!0;case"device get-page-tree":return t1(e,"usage: get-page-tree [--target <@client:session>] [--depth <-1|n>] [--json]"),t1(e,"获取当前 Lynx session 的 DevTools Elements DOM 树;默认 depth=-1。"),t1(e,"终端输出紧凑树;--json 输出节点文本、完整 attributes 和可复用 node-ref。"),!0;case"device get-computed-style":return t1(e,"usage: get-computed-style <node-ref> [--properties <name,...>] [--json]"),t1(e,"获取元素节点的 computed style;node-ref 格式为 @<clientId>:<sessionId>:<nodeId>。"),t1(e,"省略 --properties 返回全部属性,例如 --properties color,font-size。"),!0;case"web":return t1(e,"usage: web"),t1(e,"在默认浏览器打开本地 Web 模拟器。"),!0;case"device pages":case"device widgets":{let n="device pages"===t?"打开的页面":"推送的卡片";return t1(e,`usage: ${t.slice(7)}`),t1(e,`列出真机可${n}。`),!0}case"status":return t1(e,"usage: status"),t1(e,"查看本地调试服务状态。"),!0;default:return!1}}(t.output,e))return"continue"}try{switch(o){case"status":return await eF(t),"continue";case"web":return await eV(t),"continue";case"device":return await eB(t,i)?"enter-device":"continue";default:return t1(t.output,`unknown command: ${o}`),["qr","pages","page","widgets","widget","sessions","use-session","get-console","take-screenshot","get-page-tree","get-computed-style"].includes(o)&&t1(t.output,`\`${o}\` is only available in device mode; run \`device\` first.`),"continue"}}catch(e){return t1(t.output,tF(t4(e))),"continue"}}async function eB(e,t){let n=t[0]?.toLowerCase();if(!n||n.startsWith("-"))return await eH(e,t,{reuseDeviceAppMode:!1,reuseVersionTag:!1}),!0;let r=function(e){let t=!1,n=[];for(let r of e)"--json"===r?t=!0:n.push(r);return{args:n,json:t}}(t.slice(1)),o=["get-page-tree","get-computed-style","take-screenshot"].includes(n);try{if(r.json&&!o)throw Error(`--json is not supported by device ${n}; use it with get-page-tree, get-computed-style, or take-screenshot`);switch(n){case"qr":return await eY(e,r.args),!0;case"pages":return await tv(e,"page",c.discoverPages),!0;case"page":return await tx(e,r.args),!0;case"widgets":return await tv(e,"widget",c.discoverWidgets),!0;case"widget":return await t$(e,r.args),!0;case"sessions":return await tE(e,r.args),!0;case"use-session":return await tI(e,r.args),!0;case"get-console":return await tT(e,r.args),!0;case"take-screenshot":return await tA(e,r.args,r.json),!0;case"get-page-tree":return await tC(e,r.args,r.json),!0;case"get-computed-style":return await tj(e,r.args,r.json),!0;default:return t1(e.output,`unknown device subcommand: ${n}`),!1}}catch(t){if(!r.json||!o)throw t;return t2(e.output,{ok:!1,error:{code:t instanceof L?t.code:"INSPECTION_FAILED",message:t4(t)}}),!0}}async function eU(e){try{var t,n;let r=await e.closeDeviceApp();t=e.output,n=r,"closed"===n.status?t1(t,`豆包开发者工具已关闭:${n.appPath}`):t1(t,`关闭豆包开发者工具失败${n.reason?`:${tF(n.reason)}`:""}`)}catch(t){t1(e.output,`关闭豆包开发者工具失败:${tF(t4(t))}`)}}async function eF(e){let t=await e.client.call(c.getInfo);t1(e.output,`status: ${t.status}`),t1(e.output,`app_id: ${t.appId??"-"}`),t1(e.output,`dev_server: ${t.host??"-"}`),t1(e.output,`web_debugger: ${t.webDebuggerUrl??"-"}`)}async function eV(e){let t=e.runtime.getState().webDebuggerUrl;if(!t)throw Error("web debugger URL is not ready");await e.openBrowser(t),t1(e.output,`Web 模拟器已打开:${t}`)}async function eH(e,t,n){var r,o,i;let s,a,d,l=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{agent:{type:"boolean"},timeout:{type:"string"},"qr-file":{type:"string"},mcp:{type:"boolean"},"wifi-connect":{type:"string"},defaultDebugTagState:{type:"string"}}});if(n.reuseDeviceAppMode&&l.values.agent)throw Error("--agent is only supported when entering device mode");n.reuseDeviceAppMode||(e.manageDeviceApp=!l.values.agent);let c=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout must be a positive number of seconds");return Math.round(1e3*t)}(l.values.timeout),u=function(e){if(!e)return;let t=eE().resolve(e);if(".png"!==eE().extname(t).toLowerCase())throw Error("--qr-file must point to a .png file");return t}(l.values["qr-file"]),p=tM((r={defaultDebugTagState:l.values.defaultDebugTagState,wifiConnect:l.values["wifi-connect"]},d={},void 0!==r.defaultDebugTagState&&(d.defaultDebugTagState=eO(r.defaultDebugTagState,"--defaultDebugTagState")),void 0!==r.wifiConnect&&(d.usb=!eO(r.wifiConnect,"--wifi-connect")),Object.keys(d).length>0?d:void 0)),h=await e.client.call("dev.setConnectionTransport",{type:p.usb?"usb":"wifi"}),f=e.runtime.getState(),m=l.values.mcp?await ez(e,f.appId):n.reuseVersionTag?e.activeVersionTag:void 0;if(l.values.mcp&&!m)return;e.activeVersionTag=m,m&&!l.values.mcp&&t1(e.output,`沿用 MCP 端到端调试 versionTag:${m}`),e.manageDeviceApp||t1(e.output,"已启用 --agent:不会准备、启动或关闭豆包开发者工具。");let g={namespace:f.namespace,projectPath:f.projectPath,appDir:f.appDir,appKey:f.appId,hostUrl:f.host},y=e.manageDeviceApp?await eK(e):void 0;if(y?.status==="skipped")return void t1(e.output,`启动真机调试失败:${tF(y.reason??"豆包开发者工具准备失败")}`);tG();let _=new AbortController,b=e.signal?AbortSignal.any([e.signal,_.signal]):_.signal;try{a=await e.runRealDeviceAuth({hostUrl:h.host||f.host,appKey:h.appId||f.appId,versionTag:m,namespace:f.namespace,timeoutMs:c,settings:p,wifiConnectUrl:h.wifiConnectUrl,output:e.output,signal:b,onQRCodeReady:async(t,n)=>{(s=await e.openQRCodeViewer(t,u,n)).closed.then(()=>{_.abort(new tH)})}})}finally{await s?.close().catch(()=>void 0),tG()}if(function(e,t){let n;if(t.ok){let n=t.client?.clientId===void 0?"":`:client ${t.client.clientId}`,r=t.qrCodeValue?"扫码鉴权完成":"复用已连接设备,已跳过二维码鉴权";t1(e,`真机调试已连接${n}(${r})。`);return}"cancelled"===t.status?t1(e,"install"===t.waitingFor?"二维码页面已关闭,已取消等待设备安装。":"二维码页面已关闭,已取消等待设备连接。"):(n="timeout"===t.status?"install"===t.waitingFor?`设备已连接,但等待安装完成超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:`等待设备连接超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:tF(t.error??"未知错误"),t1(e,`启动真机调试失败:${n}`))}(e.output,a),a.ok&&"connected"===a.status){a.client?.clientId!==void 0&&(void 0!==e.activeClientId&&e.activeClientId!==a.client.clientId&&(e.runtimeInspectionTargetPolicy={kind:"latest"}),e.activeClientId=a.client.clientId);let t=a.client?.deviceId??(a.client?.clientId===void 0?void 0:String(a.client.clientId));t&&(e.activeDeviceId=t)}if(e.manageDeviceApp&&a.ok&&"connected"===a.status){let t=y?await eJ(e,y,g):await e.launchDeviceApp(g);o=e.output,"opened"===(i=t).status?t1(o,`豆包开发者工具已启动:${i.appPath}`):t1(o,`启动豆包开发者工具失败${i.reason?`:${tF(i.reason)}`:""}`)}}async function ez(e,t){if(!t)throw Error("无法查询 versionTag,当前工程缺少 AppID。");let n=(await e.listAppVersions(t)).filter(e=>"string"==typeof e.version_tag&&!!e.version_tag.trim());if(!n.length)throw Error(`当前 AppID(${t})没有可选的 versionTag。`);let r=await e.selectItem("versionTag",n,e.output);return r?(t1(e.output,`MCP 端到端调试 versionTag:${r}`),r):void t1(e.output,"已取消 versionTag 选择,未生成二维码。")}async function eK(e){if(e.prepareDeviceApp){e.onDeviceAppSetupProgress?.(void 0);try{return await e.prepareDeviceApp({onProgress:eN(e.output,e.onDeviceAppSetupProgress)})}catch(t){return e.onDeviceAppSetupProgress?.(void 0),{status:"skipped",reason:t4(t)}}}}async function eY(e,t){await eH(e,t,{reuseDeviceAppMode:!0,reuseVersionTag:!0})}async function eJ(e,t,n){return"skipped"!==t.status&&t.appPath?e.openPreparedDeviceApp?e.openPreparedDeviceApp(t.appPath,n):e.launchDeviceApp(n):{status:"skipped",reason:t.reason}}async function eG(e,t=process.stderr){let n=await eW(t);return"skipped"!==n.status&&n.appPath?eQ(n.appPath,e):{status:"skipped",reason:n.reason}}async function eW(e=process.stderr,t={}){let n=function(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??e4(),i=e.manifest??ep,s=e3(t);if(t[ek]?.trim()||!s&&e1({...t,[ek]:""},n,o))return;ta(i);let a=e5(n,r);if(!a)return;let d=i.packages[a];if(!d)return;td(d);let l=tl(i,d),c=e2(t,n);if(!(!s&&e6(c,i,a,d,l)))return{platform:a,version:l,...void 0===d.sizeBytes?{}:{sizeBytes:d.sizeBytes}}}();return n&&!t.onProgress&&(t1(e,"真机调试准备:"),t1(e,`首次或版本更新需要下载豆包开发者工具${n.sizeBytes?`(${e9(n.sizeBytes)})`:""}。`),t1(e,"下载完成后才会生成二维码;下载耗时取决于网络,进度和实际耗时将持续显示。")),await eZ({runner:{onProgress:t.onProgress??eN(e)}})}async function eQ(e,t){return await function(e,t,n=process.platform){var r,o,i;let s,a=(r=e,o=n,s=(i=t)?[["namespace",i.namespace],["project",i.appDir??i.projectPath],["app-key",i.appKey],["host-url",i.hostUrl]].flatMap(([e,t])=>t?[`--${e}=${t}`]:[]):[],"darwin"===o?{command:"open",args:[r,...s.length?["--args",...s]:[]]}:"win32"===o?{command:"cmd",args:["/c","start","",r,...s],windowsVerbatimArguments:!0}:{command:r,args:s});return new Promise((e,t)=>{let n=(0,eh.spawn)(a.command,a.args,{stdio:"ignore",windowsVerbatimArguments:a.windowsVerbatimArguments});n.once("error",t),n.once("spawn",e)})}(e,t),{status:"opened",appPath:e}}async function eX(){let e=function(e=process.env,t=process.platform,n=process.arch,r=e4()){let o=e[ek]?.trim();if(o)return eE().resolve(o);let i=e1({...e,[ek]:""},t,r);if(i)return i;let s=e5(t,n);if(!s)return;let a=e2(e,t),d=tn(a);if(!d||d.platform!==s)return;let l=tp(ti(a,d.activeDeviceAppVersion),d.entry,"device app state entry");return ey().existsSync(l)?l:void 0}();return e?(await function(e,t=process.platform){return"darwin"===t?tg(e):ty(tb(e,t),{rejectOnNonZero:!0}).then(()=>void 0)}(e),{status:"closed",appPath:e}):{status:"skipped",reason:`${ek} is not set and no packaged or cached device app was found`}}async function eZ(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??e4(),i=e3(t),s=t[ek]?.trim();if(s)return{status:"found",appPath:eE().resolve(s),source:"env"};if(!i){let e=e1({...t,[ek]:""},n,o);if(e)return{status:"found",appPath:e,source:"packaged"}}return e0({env:t,platform:n,arch:r,appDir:o,manifest:e.manifest,runner:e.runner})}async function e0(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.manifest??ep;ta(o);let i=e5(n,r);if(!i)return{status:"skipped",reason:`device app download is not supported on ${n}/${r}`};let s=o.packages[i];if(!s)return{status:"skipped",reason:`device app package is not configured for ${i} in CLI ${o.cliVersion}`};let a=e2(t,n),d=tl(o,s);if(!e3(t)){let e=e6(a,o,i,s,d);if(e)return tr(a,d),{status:"found",appPath:e,source:"cache"}}let l=await e8(a,o,i,s,n,e.runner);return tr(a,d),{status:"found",appPath:l,source:"downloaded"}}function e1(e=process.env,t=process.platform,n=e4()){let r=e[ek]?.trim();if(r)return eE().resolve(r);if(!ey().existsSync(n))return;let o=ey().readdirSync(n,{withFileTypes:!0}).find(e=>{var n,r;return n=e,"darwin"===(r=t)?n.isDirectory()&&n.name.endsWith(".app"):"win32"===r?n.isFile()&&n.name.toLowerCase().endsWith(".exe"):n.isFile()&&/\.(appimage|AppImage)$/.test(n.name)});return o?eE().join(n,o.name):void 0}function e2(e=process.env,t=process.platform){let n=e.DBX_DEVICE_APP_CACHE_DIR?.trim();if(n)return eE().resolve(n);if("darwin"===t)return eE().join(ew().homedir(),"Library","Application Support","dbx","device-app");if("win32"===t){let t=e.LOCALAPPDATA?.trim()||eE().join(ew().homedir(),"AppData","Local");return eE().join(t,"dbx","device-app")}return eE().join(ew().homedir(),".local","share","dbx","device-app")}function e4(){return eE().resolve(ex,"../../..","device-app")}function e5(e,t){if(("darwin"===e||"win32"===e)&&("arm64"===t||"x64"===t))return`${e}-${t}`}function e3(e){let t=e.DBX_DEVICE_APP_FORCE_DOWNLOAD?.trim().toLowerCase();return!!(t&&"0"!==t&&"false"!==t)}function e6(e,t,n,r,o){var i,s,a,d,l;let c,u=tn(e);if(!u||u.activeDeviceAppVersion!==o||u.cliVersion!==t.cliVersion||u.platform!==n||!tu(u.sha256,r)||u.entry!==r.entry)return;let p=ti(e,o);if(i=p,s=t,a=n,d=r,l=o,!((c=tt(i))&&c.cliVersion===s.cliVersion&&c.deviceAppVersion===l&&c.entry===d.entry&&c.platform===a&&tu(c.sha256,d)))return;let h=tp(p,r.entry,"device app entry");return ey().existsSync(h)?h:void 0}async function e8(e,t,n,r,o,i={}){td(r);let s=tl(t,r),a=i.now?.()??Date.now(),d=eE().join(e,".tmp");ey().mkdirSync(d,{recursive:!0}),ey().mkdirSync(eE().join(e,eD),{recursive:!0});let l=ey().mkdtempSync(eE().join(d,`${s}-`)),c=eE().join(l,"device-app.zip"),u=eE().join(l,"extract"),p=ti(e,s);try{var h,f,m,g,y,_,b,w;let d,l;if(i.onProgress?.({phase:"download",downloadedBytes:0,...void 0===r.sizeBytes?{}:{totalBytes:r.sizeBytes,percentage:0},elapsedMs:0}),await e7(r.url,c,i.fetch,i.onProgress),r.sha256&&(i.onProgress?.({phase:"install",stage:"verify"}),(d=await to(c))!==tc(r.sha256)))throw Error(`device app sha256 mismatch: expected ${r.sha256}, got ${d}`);ey().mkdirSync(u,{recursive:!0}),i.onProgress?.({phase:"install",stage:"extract"}),await te(c,u,o,i);let v=tp(u,r.entry,"device app package entry");(function(e,t){if(!ey().existsSync(e))throw Error(`device app entry not found after extraction: ${e}`);let n=ey().statSync(e);if("darwin"===t){if(!n.isDirectory()||!e.endsWith(".app"))throw Error(`macOS device app entry must be a .app directory: ${e}`);return}if("win32"===t&&(!n.isFile()||!e.toLowerCase().endsWith(".exe")))throw Error(`Windows device app entry must be an .exe file: ${e}`)})(v,o),function(e,t,n,r,o){let i=tt(e);if(i&&(i.cliVersion!==t.cliVersion||i.deviceAppVersion!==o||i.entry!==r.entry||i.platform!==n||!tu(i.sha256,r)))throw Error(`device app metadata does not match CLI manifest in ${eE().join(e,eS)}`)}(u,t,n,r,s),i.onProgress?.({phase:"install",stage:"install"}),ey().rmSync(p,{recursive:!0,force:!0}),ey().renameSync(u,p),h=p,f=t,m=n,g=r,y=s,_=a,l={name:"Doubao App V2",cliVersion:f.cliVersion,deviceAppVersion:y,entry:g.entry,platform:m,...g.sha256?{sha256:tc(g.sha256)}:{},installedAt:_},tm(eE().join(h,eS),l),b=e,w={activeDeviceAppVersion:s,cliVersion:t.cliVersion,entry:r.entry,platform:n,...r.sha256?{sha256:tc(r.sha256)}:{},installedAt:a},tm(eE().join(b,eP),w);let E=tp(p,r.entry,"device app entry");return i.onProgress?.({phase:"complete",appPath:E}),E}finally{ey().rmSync(l,{recursive:!0,force:!0})}}async function e7(e,n,r=fetch,o){var i,s;let a,d,l,c,u,p,h=new URL(e);if("https:"!==h.protocol&&"http:"!==h.protocol)throw Error(`device app package URL must be http(s): ${e}`);let f=await r(e);if(!f.ok)throw Error(`device app package download failed: HTTP ${f.status} ${f.statusText}`);if(!f.body)throw Error("device app package download failed: empty response body");let m=f.body;await (0,t.pipeline)(eI.Readable.fromWeb(m),(i=f,s=o,a=function(e){if(!e)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}(i.headers.get("content-length")),d=0,l=-1,c=0,u=Date.now(),(p=e=>{if(!s)return;if(a){let t=Math.min(100,Math.floor(d/a*100));if(!e&&100!==t&&t<l+10||t===l)return;l=t;let n=Date.now()-u;s({phase:"download",downloadedBytes:d,totalBytes:a,percentage:t,elapsedMs:n});return}if(!e&&d-c<0x3200000||d===c)return;c=d;let t=Date.now()-u;s({phase:"download",downloadedBytes:d,elapsedMs:t})})(!1),new eI.Transform({transform(e,t,n){d+=e.length,p(!1),n(null,e)},flush(e){p(!0),e()}})),ey().createWriteStream(n))}function e9(e){let t=["B","KB","MB","GB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return 0===r?`${n} ${t[r]}`:`${n.toFixed(1)} ${t[r]}`}async function te(e,t,n,r){let o=r.runCommand??(e=>ty(e,{rejectOnNonZero:!0}).then(()=>void 0));if("darwin"===n)return void await o({command:"ditto",args:["-x","-k",e,t]});if("win32"===n)return void await o({command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",`Expand-Archive -LiteralPath ${th(e)} -DestinationPath ${th(t)} -Force`],windowsVerbatimArguments:!0});throw Error(`device app zip extraction is not supported on ${n}`)}function tt(e){let t=tf(eE().join(e,eS));if(!i(t))return;let n=t.cliVersion,r=t.deviceAppVersion,o=t.entry,s=t.platform,a=t.sha256,d=t.installedAt;if("string"==typeof n&&"string"==typeof r&&"string"==typeof o&&"string"==typeof s&&(void 0===a||"string"==typeof a)&&"number"==typeof d)return{name:"string"==typeof t.name?t.name:void 0,cliVersion:n,deviceAppVersion:r,entry:o,platform:s,..."string"==typeof a?{sha256:a}:{},installedAt:d}}function tn(e){let t=tf(eE().join(e,eP));if(i(t)&&"string"==typeof t.activeDeviceAppVersion&&"string"==typeof t.cliVersion&&"string"==typeof t.entry&&"string"==typeof t.platform&&(void 0===t.sha256||"string"==typeof t.sha256)&&"number"==typeof t.installedAt)return{activeDeviceAppVersion:t.activeDeviceAppVersion,cliVersion:t.cliVersion,entry:t.entry,platform:t.platform,..."string"==typeof t.sha256?{sha256:t.sha256}:{},installedAt:t.installedAt}}function tr(e,t){let n=eE().join(e,eD);if(ey().existsSync(n)){for(let e of ey().readdirSync(n,{withFileTypes:!0}))if(e.isDirectory()&&e.name!==t)try{ey().rmSync(eE().join(n,e.name),{recursive:!0,force:!0})}catch{}}}async function to(e){let n=em().createHash("sha256");return await (0,t.pipeline)(ey().createReadStream(e),n),n.digest("hex")}function ti(e,t){return ts(t),eE().join(e,eD,t)}function ts(e){if(!/^[0-9A-Za-z._+-]+$/.test(e))throw Error(`device app version contains unsupported path characters: ${e}`)}function ta(e){if(1!==e.schemaVersion)throw Error(`unsupported device app manifest schemaVersion: ${e.schemaVersion}`);if(!e.cliVersion.trim())throw Error("device app manifest cliVersion is required");if(!e.deviceAppVersion.trim())throw Error("device app manifest deviceAppVersion is required");ts(e.deviceAppVersion)}function td(e){if(!e.url||!e.entry)throw Error("device app package requires url and entry");if(void 0!==e.version){if(!e.version.trim())throw Error("device app package version must not be empty");ts(e.version)}if(e.sha256&&!/^[0-9a-fA-F]{64}$/.test(e.sha256))throw Error(`device app package sha256 must be 64 hex characters: ${e.sha256}`);if(void 0!==e.sizeBytes&&(!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0))throw Error(`device app package sizeBytes must be a positive integer: ${e.sizeBytes}`);if(eE().isAbsolute(e.entry)||e.entry.split(/[\\/]+/).includes(".."))throw Error(`device app package entry must be a relative path inside the zip: ${e.entry}`)}function tl(e,t){let n=t.version??e.deviceAppVersion;if(!n.trim())throw Error("device app package version must not be empty");return ts(n),n}function tc(e){return e.toLowerCase()}function tu(e,t){return!t.sha256||e===tc(t.sha256)}function tp(e,t,n){if(eE().isAbsolute(t))throw Error(`${n} must be relative: ${t}`);let r=eE().resolve(e),o=eE().resolve(e,t);if(o!==r&&!o.startsWith(`${r}${eE().sep}`))throw Error(`${n} escapes target directory: ${t}`);return o}function th(e){return`'${e.replace(/'/g,"''")}'`}function tf(e){try{return JSON.parse(ey().readFileSync(e,"utf8"))}catch{return}}function tm(e,t){ey().mkdirSync(eE().dirname(e),{recursive:!0}),ey().writeFileSync(e,`${JSON.stringify(t,null,2)}
13
- `,"utf8")}async function tg(e){let t=function(e){if(!e.endsWith(".app"))return;let t=function(e){let t=eE().join(e,"Contents","Info.plist");if(!ey().existsSync(t))return;let n=ey().readFileSync(t,"utf8").match(/<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/);return n?.[1]}(e)??eE().basename(e,".app");return eE().join(e,"Contents","MacOS",t)}(e);await ty(tb(e,"darwin"),{rejectOnNonZero:!1}),!t||await t_(t)&&await ty({command:"pkill",args:["-f",tw(t)]},{rejectOnNonZero:!1})}function ty(e,t){return new Promise((n,r)=>{let o=(0,eh.spawn)(e.command,e.args,{stdio:"ignore",windowsVerbatimArguments:e.windowsVerbatimArguments});o.once("error",r),o.once("exit",o=>{let i=o??0;0!==i&&t.rejectOnNonZero?r(Error(`${e.command} exited with code ${i}`)):n(i)})})}async function t_(e){return 0===await ty({command:"pgrep",args:["-f",tw(e)]},{rejectOnNonZero:!1})}function tb(e,t){return"darwin"===t?{command:"osascript",args:["-e",`tell application (POSIX file "${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}" as alias) to quit`]}:"win32"===t?{command:"cmd",args:["/c","taskkill","/IM",eE().basename(e),"/T"],windowsVerbatimArguments:!0}:{command:"pkill",args:["-f",e]}}function tw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function tv(e,t,n){let r=await e.client.call(n);if(!r.length)return void t1(e.output,`no ${t}s found`);for(let t of r)t1(e.output,`- ${tZ(t)}`)}async function tE(e,t){if(t.length>0)throw Error("sessions does not accept arguments");let n=await tD(e,"sessions"),{session:r}=n;try{let t=await r.getConnectedClients();if(0===t.length)throw new L("DEVICE_NOT_CONNECTED","no debug device is connected");let n=t.flatMap(e=>e.sessions.filter(V).map(t=>({clientId:e.device.clientId,sessionId:t.sessionId,url:t.url}))).sort((e,t)=>e.clientId-t.clientId||t.sessionId-e.sessionId);if(0===n.length)throw new L("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");let o=r.getRuntimeInspectionTarget?await r.getRuntimeInspectionTarget().catch(()=>null):null,i=tk(e),s=e.activeClientId??(1===t.length?t[0]?.device.clientId:void 0),a=void 0===s?void 0:n.find(e=>e.clientId===s);for(let t of n){let n=[tS(t,o)?"electron":void 0,"fixed"===i.kind&&tS(t,i.target)?"cli":void 0,tS(t,a)?"latest":void 0].filter(e=>void 0!==e);t1(e.output,`${O(t)}${n.length?` ${n.map(e=>`[${e}]`).join(" ")}`:""} ${t.url||"unknown"}`)}}finally{n.owned&&await r.stop().catch(()=>void 0)}}async function tI(e,t){if(1!==t.length)throw Error("use-session requires @<clientId>:<sessionId> or latest");if(t[0]?.toLowerCase()==="latest"){e.runtimeInspectionTargetPolicy={kind:"latest"},t1(e.output,l.bold.blueBright(`CLI 调试目标已恢复为 latest${void 0===e.activeClientId?"":`(client ${e.activeClientId} 内最新活跃 Lynx session)`};不会切换 Electron。`));return}let n=q(t[0]??""),r=await tD(e,"use-session"),{session:o}=r;try{let t=await N(o,{activeClientId:e.activeClientId,explicitTarget:n,signal:e.signal});e.runtimeInspectionTargetPolicy={kind:"fixed",target:{clientId:t.clientId,sessionId:t.sessionId}},t1(e.output,l.bold.blueBright(`CLI 调试目标已固定为 ${O(t)}(${t.url||"unknown"});不会切换 Electron。`))}finally{r.owned&&await o.stop().catch(()=>void 0)}}async function tT(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{limit:{type:"string"},"timeout-seconds":{type:"string"},"include-stack-traces":{type:"boolean"},target:{type:"string"}}}),r=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>100)throw Error("--limit must be an integer between 1 and 100");return t}(n.values.limit),o=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout-seconds must be a positive number");return Math.round(1e3*t)}(n.values["timeout-seconds"]),s=await tD(e,"get-console"),{session:a}=s;try{let t=await tP(e,a,n.values.target);t1(e.output,l.bold.blueBright(`正在监听 client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})的新日志;按 Ctrl+C 停止监听。`));let s=await et(a,t,{...void 0===r?{}:{limit:r},...void 0===o?{}:{timeoutMs:o},signal:e.signal,onTargetChange(n){t1(e.output,l.bold.blueBright(`提示:Electron 已切换到 client ${n.clientId}、session ${n.sessionId}(${n.url||"unknown"});当前 CLI 仍监听 client ${t.clientId}、session ${t.sessionId},不会自动跟随 Electron。`))},onMessage(t){t1(e.output,function(e,t={}){var n;let r=e.args.map(ei).join(" "),o=t.includeStackTraces||"error"===e.type?(n=e.stackTrace,i(n)&&Array.isArray(n.callFrames)?n.callFrames.filter(i).map(e=>{let t="string"==typeof e.url?e.url:"",n="number"==typeof e.lineNumber?e.lineNumber:"unknown",r="number"==typeof e.columnNumber?e.columnNumber:"unknown";return` at ${t}:${n}:${r}`}).join("\n"):""):"";return`[${e.type}/${e.thread}] ${r}${o?`
14
- ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});t1(e.output,`日志监听已停止,共 ${s.count} 条。`)}finally{s.owned&&await a.stop().catch(()=>void 0)}}async function tA(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{output:{type:"string",short:"o"},target:{type:"string"}}}),o=await tD(e,"take-screenshot"),{session:i}=o;try{let t=await tP(e,i,r.values.target),o=await en(i,t,{activeCapture:!e.manageDeviceApp}),s=eE().resolve(r.values.output??`screenshot-${Date.now()}.jpeg`);await ey().promises.writeFile(s,Buffer.from(o.data,"base64")),n?t2(e.output,{ok:!0,command:"take-screenshot",target:t,output:s,format:o.format,source:o.source,width:o.width,height:o.height,byteLength:o.byteLength}):t1(e.output,`截图已保存:${s}(${o.width}\xd7${o.height},client ${t.clientId}、session ${t.sessionId},${t.url||"unknown"};${e.manageDeviceApp?"范围跟随 Electron 当前 mode":"由设备按当前截图 mode 生成"})`)}finally{o.owned&&await i.stop().catch(()=>void 0)}}async function tC(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{depth:{type:"string"},target:{type:"string"}}}),o=function(e){if(void 0===e)return -1;let t=Number(e);if(!Number.isSafeInteger(t)||t<-1)throw Error("--depth must be -1 or a non-negative integer");return t}(r.values.depth),i=await tD(e,"get-page-tree"),{session:s}=i;try{let t=await tP(e,s,r.values.target),i=await U(s,t,{depth:o});if(n)t2(e.output,{ok:!0,command:"get-page-tree",...i});else{let n,r;t1(e.output,`DOM tree: client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})`),t1(e.output,(n=[],(r=(e,t,o)=>{n.push(`${t}${o}${function(e){if(W(e))return`${e.ref} #text ${Z(e.nodeValue)}`;let t=(e.localName||e.nodeName).toLowerCase();if(t.startsWith("#"))return`${e.ref} ${t}`;let n=Object.entries(e.attributes).map(([e,t])=>`${e}=${Z(t,80)}`).join(" "),r=e.text||e.children.filter(W).map(e=>e.nodeValue).join("");return[e.ref,`<${t}${n?` ${n}`:""}>`,r?Z(r,120):""].filter(Boolean).join(" ")}(e)}`);let i=e.children.filter(e=>!W(e));i.forEach((e,n)=>{r(e,`${t}${o?"└─ "===o?" ":"│ ":""}`,n===i.length-1?"└─ ":"├─ ")})})(i.root,"",""),i.truncated&&n.push(`… tree truncated after ${i.nodeCount} nodes`),n.join("\n"))),t1(e.output,`共 ${i.nodeCount} 个节点${i.truncated?"(已截断)":""}。`)}}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tj(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{properties:{type:"string"}}}),o=r.positionals[0];if(!o)throw new L("INVALID_NODE_REF","node-ref is required; run get-page-tree and pass @<clientId>:<sessionId>:<nodeId>");if(r.positionals.length>1)throw Error("get-computed-style accepts exactly one node-ref");let i=function(e){let t=/^@([1-9]\d*):([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new L("INVALID_NODE_REF",`invalid node ref "${e}"; expected @<clientId>:<sessionId>:<nodeId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2]),nodeId:Number(t[3])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId)||!Number.isSafeInteger(n.nodeId))throw new L("INVALID_NODE_REF",`invalid node ref "${e}"; every id must be a safe integer`);return n}(o),s=function(e){if(void 0===e)return[];let t=e.split(",").map(e=>e.trim());if(0===t.length||t.some(e=>!/^-{0,2}[a-z][a-z0-9-]*$/i.test(e)))throw Error("--properties must be a comma-separated list of CSS property names");return[...new Set(t.map(e=>e.toLowerCase()))]}(r.values.properties),a=await tD(e,"get-computed-style"),{session:d}=a;try{let t=await B(d,i),r=await F(d,t,i,s);if(n)t2(e.output,{ok:!0,command:"get-computed-style",...r});else if(t1(e.output,`${r.nodeRef} computed style(client ${t.clientId}、session ${t.sessionId})`),0===r.properties.length)t1(e.output,"没有匹配的 computed style 属性。");else{let t=Math.max(...r.properties.map(e=>e.name.length));for(let n of r.properties)t1(e.output,` ${n.name.padEnd(t)} ${n.value}`)}}finally{a.owned&&await d.stop().catch(()=>void 0)}}function tk(e){return e.runtimeInspectionTargetPolicy??{kind:"latest"}}function tS(e,t){return null!=e&&null!=t&&e.clientId===t.clientId&&e.sessionId===t.sessionId}function tP(e,t,n){return N(t,{activeClientId:e.activeClientId,policy:tk(e),...void 0===n?{}:{explicitTarget:q(n)},signal:e.signal})}async function tD(e,t){if(e.runtimeInspectionSession)return{owned:!1,session:await e.runtimeInspectionSession};let n=e.createRuntimeInspectionSession??R;return{owned:!0,session:await n({namespace:e.runtime.getState().namespace,nodeIdPrefix:`dev-shell-${t}`})}}async function tx(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{data:{type:"string"},settings:{type:"string"},mode:{type:"string"},"device-id":{type:"string"}}}),r=n.positionals[0]??await tR(e,"page",c.discoverPages);if(!r)throw Error("page id is required");let o=function(e){if(void 0===e)return"full";if("full"===e||"popup"===e||"floating"===e)return e;throw Error("--mode must be one of: full, popup, floating")}(n.values.mode),i=h(n.values.data,"--data"),s=n.values["device-id"]??e.activeDeviceId;t1(e.output,`debug: page push request ${t0({pageId:r,data:i,settings:n.values.settings,mode:o,deviceId:s})}`);let a=u("page",await e.client.call(c.openPage,{pageId:r,pageData:i,pageSettings:n.values.settings,mode:o,deviceId:s}));t1(e.output,`page pushed: ${r}`),t1(e.output,`status: ${tL(a)}`)}async function t$(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{data:{type:"string"},"bot-id":{type:"string"},"device-id":{type:"string"}}}),r=n.positionals[0]??await tR(e,"widget",c.discoverWidgets);if(!r)throw Error("widget id is required");let o=h(n.values.data,"--data"),i=n.values["device-id"]??e.activeDeviceId;t1(e.output,`debug: widget push request ${t0({widgetId:r,data:o,botId:n.values["bot-id"],deviceId:i})}`);let s=u("widget",await e.client.call(c.pushWidget,{widgetId:r,widgetData:o,botId:n.values["bot-id"],deviceId:i}));t1(e.output,`widget pushed: ${r}`),t1(e.output,`status: ${tL(s)}`)}function tL(e){if(!e.ok)return"failed";let t=function(e){if(!e||"object"!=typeof e)return;let t=e.data;if(!t||"object"!=typeof t)return;let n=t.msg;return"string"==typeof n?n:void 0}(e.result);return"string"==typeof t&&t.trim()?t:"ok"}async function tR(e,t,n){let r=await e.client.call(n);if(r.length)return e.selectItem(t,r,e.output)}function tN(e){return e.map(e=>{let t=tX(e);return t?{label:tZ(e),value:t}:void 0}).filter(e=>!!e)}async function tO(e){var t,o;let i,s,a,d,l=e.timeoutMs??6e4;if(!e.hostUrl||!e.appKey)return{ok:!1,status:"skipped",timeoutMs:l,error:"无法生成二维码,缺少 hostUrl 或 appKey。"};let u=e.hostUrl,p=e.appKey,h=(t=e.namespace,o=l,s=new g(t,{nodeId:`dev-auth-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3}),a=!1,d=new Promise(e=>{i=e}),s.createService({name:`devAuthListener${process.pid}`,events:{"connection.newclient"(e){var t;a||(a=!0,i((t=e.params)&&"object"==typeof t?{scope:"string"==typeof t.scope?t.scope:void 0,type:"string"==typeof t.type?t.type:void 0,clientId:"number"==typeof t.clientId?t.clientId:void 0,deviceId:tY(t),app:"string"==typeof t.app?t.app:void 0}:{}))}}}),{start:()=>s.start(),stop:()=>s.stop(),wait:(e,t=o)=>{var n,r,i;return n=d,r=t,i=e,new Promise((e,t)=>{let o=()=>{clearTimeout(s),t(i?.reason instanceof Error?i.reason:new tH)},s=setTimeout(()=>{i?.removeEventListener("abort",o),t(new tV(r))},r);i?.aborted?o():(i?.addEventListener("abort",o,{once:!0}),n.then(t=>{clearTimeout(s),i?.removeEventListener("abort",o),e(t)},e=>{clearTimeout(s),i?.removeEventListener("abort",o),t(e)}))})},async findExistingClient(){let e=await tK(()=>s.call("devtoolConnection.getConnectedClients"),2e3).catch(()=>[]);return function(e){if(!e||"object"!=typeof e)return;let t=e.device,n=t?.info,r="number"==typeof t?.clientId?t.clientId:void 0;return{scope:"all",type:String(n?.network??"").toLowerCase().includes("wifi")?"wifi":"usb",...void 0===r?{}:{clientId:r},deviceId:tY({client:e}),app:"string"==typeof n?.App?n.App:""}}(Array.isArray(e)?e[0]:void 0)},async awaitDirectDebugReady(e){let t=Math.min(o,2500);try{return await s.call(c.awaitDirectDebugReady,{clientId:e,timeoutMs:t},{timeout:t+1e3})}catch{return!1}},waitForInstallResult:(e,t,n,r)=>{var o,i;return o=s.call(c.awaitDeviceInstallResult,{clientId:e,packageName:t,timeoutMs:n},{timeout:n+1e3}),(i=r)?new Promise((e,t)=>{let n=()=>{t(i.reason instanceof Error?i.reason:new tH)};if(i.aborted){o.catch(()=>void 0),n();return}i.addEventListener("abort",n,{once:!0}),o.then(t=>{i.removeEventListener("abort",n),e(t)},e=>{i.removeEventListener("abort",n),t(e)})}):o}}),f={},m="connection";await h.start();try{let t;e.signal?.throwIfAborted();let o=await h.findExistingClient(),i=o?.clientId!==void 0&&await h.awaitDirectDebugReady(o.clientId);if(!i){let o,i,s;t=await tq(f,()=>(0,eC.Ph)(function(e,t,o={}){let i=tM(o.settings);return{hostUrl:e,appKey:t,...void 0===o.versionTag?{}:{versionTag:o.versionTag},isSigned:!1,appletType:0,baseApiUrl:n(),authOptions:r(),...!1===i.defaultDebugTagState?{defaultDebugTagState:!1}:{},...!i.usb&&o.wifiConnectUrl?{wifiConnectUrl:o.wifiConnectUrl}:{}}}(u,p,{versionTag:e.versionTag,settings:e.settings,wifiConnectUrl:e.wifiConnectUrl}))),t1(e.output,""),t1(e.output,"使用豆包 App 扫码连接调试设备."),t1(e.output,`二维码创建成功,请在 ${(o=Math.max(1,Math.round(l/1e3)),i=Math.floor(o/60),s=o%60,i>0?`${i}m ${s}s`:`${s}s`)} 前扫码; 超时可在真机模式执行 \`qr\` 创建新二维码.`),t1(e.output,""),await e.onQRCodeReady?.(t.qrCodeValue,t.debugToken),e.signal?.throwIfAborted()}let s=Date.now()+l;t1(e.output,`等待设备连接 (${l/1e3}s timeout)...`);let a=i?o:await h.wait(e.signal,tz(s));if(void 0===a.clientId)throw Error("连接的设备缺少 clientId");m="install";let d=await h.waitForInstallResult(a.clientId,p,tz(s),e.signal);if(!d)throw new tV(l);if(!d.success)return{ok:!1,status:"skipped",timeoutMs:l,waitingFor:m,client:a,error:d.message||"安装 AIPackage 失败,请检查网络环境并关注客户端提示"};return{ok:!0,status:"connected",timeoutMs:l,...t?{qrCodeValue:t.qrCodeValue,debugToken:t.debugToken,encryptedDebugPayload:t.encryptedDebugPayload}:{},client:a}}catch(o){let t=o instanceof tV,n=o instanceof tH||!!e.signal?.aborted,r=function(e){if(e&&"object"==typeof e)return tU(e,"logId")??tU(e,"log_id")}(o)??f.logId;return{ok:!1,status:n?"cancelled":t?"timeout":"skipped",timeoutMs:l,waitingFor:m,...r?{logId:r}:{},error:o instanceof Error?o.message:String(o)}}finally{await h.stop()}}async function tq(e,t){let n=globalThis.fetch;globalThis.fetch=async(t,r)=>{var o;let i,s=await n((i=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return new URL(e.toString());return new URL(e.url)}catch{return}}(o=t))&&i.pathname.startsWith("/developer/check_api/apps/")&&i.pathname.endsWith("/debug/ticket")?(i.pathname=i.pathname.replace(/^\/developer\/check_api\//,"/app_developer/check_api/"),"string"==typeof o)?i.toString():o instanceof URL?i:new Request(i,o):o,r);return await tB(e,s),s};try{return await t()}finally{globalThis.fetch=n}}function tM(e){return{defaultDebugTagState:e?.defaultDebugTagState??!0,usb:e?.usb??!0}}async function tB(e,t){let n=t.headers.get("x-tt-logid");if(n){e.logId=n;return}try{let n=await t.clone().text();if(!n)return;let r=JSON.parse(n),o=tU(r,"log_id")??tU(r,"logId");o&&(e.logId=o)}catch{}}function tU(e,t){if(!e||"object"!=typeof e)return;let n=e[t];return"string"==typeof n&&n?n:void 0}function tF(e){return e.replace(/\s*[\[((]log_id:\s*[^\]))]+[\]))]/gi,"").trim()}class tV extends Error{constructor(e){super(`real-device auth timed out after ${e}ms`),this.name="RealDeviceAuthTimeoutError"}}class tH extends Error{constructor(){super("real-device auth cancelled"),this.name="RealDeviceAuthCancelledError"}}function tz(e){return Math.max(0,e-Date.now())}async function tK(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(Date.now()>=n)throw e;await new Promise(e=>{setTimeout(e,100)})}}function tY(e){let t=e.client?.device,n=t?.info;return n?.usbDeviceId||t?.xdbId||n?.did||n?.debugRouterId}async function tJ(e,t){let n=eE().resolve(t);if(".png"!==eE().extname(n).toLowerCase())throw Error("QR file must use the .png extension");return ey().mkdirSync(eE().dirname(n),{recursive:!0}),await ej.toFile(n,e,{errorCorrectionLevel:"L",margin:4,type:"png"}),n}function tG(e=ew().tmpdir()){let t;try{t=ey().readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of t)if(/^dbx-real-device-qr-.*\.(?:png|svg)$/i.test(n.name)&&(n.isFile()||n.isSymbolicLink()))try{ey().unlinkSync(eE().join(e,n.name))}catch{}}async function tW(e,t,n,r=process.stderr,o){let i,s,a;if(n){let t=await tJ(e,n);t1(r,`二维码图片已导出至:${t}`)}let d=await ej.toBuffer(e,{errorCorrectionLevel:"L",margin:4,type:"png"}),l=o?`doubaoapp://local_debug?short_token=${o}`:void 0,c=l?await ej.toBuffer(l,{errorCorrectionLevel:"L",margin:4,type:"png"}):void 0,u=em().randomBytes(18).toString("hex"),p=`/${u}/`,h=new Set,f=!1,m=new Promise(e=>{s=e}),g=()=>{clearTimeout(i),i=void 0,f||s()},y=(0,e_.createServer)((e,t)=>{let n=e.url?.split("?",1)[0];if(t.setHeader("Cache-Control","no-store, no-cache, must-revalidate, max-age=0"),t.setHeader("Expires","0"),t.setHeader("Pragma","no-cache"),"GET"===e.method&&n===p){var r;t.writeHead(200,{"Content-Security-Policy":"default-src 'none'; img-src 'self'; connect-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'","Content-Type":"text/html; charset=utf-8"}),t.end((r=!!c,`<!doctype html>
11
+ `),e}catch(e){if(I(e)&&"EEXIST"===e.code)return this.readMasterKey();throw new p(`Failed to write encrypted token master key: ${T(e)}`)}}}class g{async get(e){try{let{stdout:t}=await d("security",["find-generic-password","-a",e,"-s",l,"-w"]);return String(t).replace(/\n$/,"")}catch(e){if(b(e))return;throw new p(`Failed to read token from macOS Keychain: ${T(e)}`)}}async set(e,t){try{await d("security",["add-generic-password","-a",e,"-s",l,"-w",t,"-U"])}catch(e){throw new p(`Failed to write token to macOS Keychain: ${T(e)}`)}}async delete(e){try{await d("security",["delete-generic-password","-a",e,"-s",l])}catch(e){if(b(e))return;throw new p(`Failed to delete token from macOS Keychain: ${T(e)}`)}}}class y{async get(e){try{let{stdout:t}=await d("secret-tool",["lookup","service",l,"account",e]);return String(t).replace(/\n$/,"")}catch(e){if(w(e))return;throw new p(`Failed to read token from Secret Service: ${T(e)}`)}}async set(e,t){try{var n,o,i;await (n="secret-tool",o=["store","--label","Doubao Open CLI token","service",l,"account",e],i=t,new Promise((e,t)=>{let s=(0,r.spawn)(n,o,{stdio:["pipe","ignore","pipe"]}),a="";s.stderr.setEncoding("utf8"),s.stderr.on("data",e=>{a+=String(e)}),s.on("error",t),s.on("close",r=>{0===r?e():t(Error(a.trim()||`${n} exited with code ${r}`))}),s.stdin.end(i)}))}catch(e){throw new p(`Failed to write token to Secret Service: ${T(e)}`)}}async delete(e){try{await d("secret-tool",["clear","service",l,"account",e])}catch(e){if(w(e))return;throw new p(`Failed to delete token from Secret Service: ${T(e)}`)}}}async function _(e,t){let n=a.dirname(e);await i.promises.mkdir(n,{recursive:!0,mode:448}),"win32"!==process.platform&&await i.promises.chmod(n,448);let r=a.join(n,`.${a.basename(e)}.${process.pid}.${Date.now()}.tmp`);try{await i.promises.writeFile(r,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await i.promises.chmod(r,384),await i.promises.rename(r,e),"win32"!==process.platform&&await i.promises.chmod(e,384)}finally{try{await i.promises.unlink(r)}catch{}}}function b(e){let t=v(e),n=E(e);return(1===t||44===t)&&(n.includes("could not be found")||n.includes("The specified item could not be found"))}function w(e){let t=v(e),n=E(e);return 1===t&&(n.includes("could not be found")||n.includes("No matching items")||""===n.trim())}function v(e){return"object"==typeof e&&null!==e&&"code"in e?e.code:void 0}function E(e){return"object"==typeof e&&null!==e&&"stderr"in e?String(e.stderr??""):""}function I(e){return e instanceof Error&&"code"in e}function T(e){if("object"==typeof e&&null!==e&&"stderr"in e){let t=String(e.stderr??"").trim();if(t)return t}return e instanceof Error&&e.message?e.message:String(e)}n.d(t,{Mj:()=>h,RI:()=>p})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function d(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,l=t.sleep??_,c=await u(n,t.baseUrl,t.requestHeaders),h=b(t.baseUrl,c.user_code);t.onVerification?.({userCode:c.user_code,verificationUrl:h,expiresIn:c.expires_in,interval:c.interval});let f=Math.max(1,c.interval),m=Date.now()+1e3*c.expires_in;for(;Date.now()<m;){await l(1e3*f);let e=await p(n,t.baseUrl,c.device_code,t.requestHeaders);if(t.onPoll?.({status:e.status,interval:f}),e.status!==a.A.Pending){if(e.status===a.A.SlowDown){f+=Math.max(1,c.interval);continue}if(e.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(e.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(e.status===a.A.Authorized){if(!e.access_token)throw new o.JC("Authorization response did not include an access token");let n=y(e,t.baseUrl);return await (0,s.tK)(t.tokenPath,n,{credentialStore:t.credentialStore}),{accessToken:n.accessToken,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl,uid:(0,i.m)(n.accessToken),tokenPath:t.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(e.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function l(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,o=await u(n,t.baseUrl,t.requestHeaders),i=b(t.baseUrl,o.user_code);return t.onVerification?.({userCode:o.user_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}),{userCode:o.user_code,deviceCode:o.device_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}}async function c(e,t={}){let n=(0,r.$i)(t),d=n.fetch??fetch,l=n.sleep??_,u=n.baseUrl,h=n.requestHeaders,f=5,m=Date.now()+6e5;for(;Date.now()<m;){await l(1e3*f);let t=await p(d,u,e,h);if(n.onPoll?.({status:t.status,interval:f}),t.status!==a.A.Pending){if(t.status===a.A.SlowDown){f+=5;continue}if(t.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(t.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(t.status===a.A.Authorized){if(!t.access_token)throw new o.JC("Authorization response did not include an access token");let e=y(t,u);return await (0,s.tK)(n.tokenPath,e,{credentialStore:n.credentialStore}),{accessToken:e.accessToken,tokenType:e.tokenType,expiresAt:e.expiresAt,baseUrl:e.baseUrl,uid:(0,i.m)(e.accessToken),tokenPath:n.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(t.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function u(e,t,n){let i=await e(`${t}/app_developer/oauth/device/code`,{method:"POST",headers:g(n),body:JSON.stringify({client_name:r.E})}),s=await h(i),a=m(s);if(!a||!a.device_code||!a.user_code||"number"!=typeof a.expires_in||"number"!=typeof a.interval)throw new o.JC(`Device code response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return a}async function p(e,t,n,r){let i=await e(`${t}/app_developer/oauth/token`,{method:"POST",headers:g(r),body:JSON.stringify({device_code:n})}),s=await h(i),d=m(s);if(d?.access_token)return{status:a.A.Authorized,access_token:d.access_token,token_type:d.token_type,expires_in:d.expires_in,expires_at:d.expires_at};if(!d||"number"!=typeof d.status)throw new o.JC(`Token response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return d}async function h(e){var t;let n,r=e.headers.get("x-tt-logid")??void 0;try{n=await e.json()}catch{throw new o.JC(`Auth server returned non-JSON response with status ${e.status}${f(r)}`,"DEVICE_AUTH_FAILED",{logId:r})}let i=function(e){if(e&&"object"==typeof e)return"string"==typeof e.log_id&&e.log_id?e.log_id:void 0}(n)??r;if(!e.ok)throw new o.JC(`Auth server returned HTTP ${e.status}: ${JSON.stringify(n)}${f(i)}`,"DEVICE_AUTH_FAILED",{logId:i});let s=(t=n)&&"object"==typeof t&&"number"==typeof t.code&&0!==t.code?{code:t.code,message:"string"==typeof t.message?t.message:"Unknown error",logId:"string"==typeof t.log_id?t.log_id:void 0}:null;if(s)throw new o.JC(`Auth server error (code ${s.code}): ${s.message}${f(s.logId??i)}`,"DEVICE_AUTH_FAILED",{logId:s.logId??i});return n}function f(e){return e?` [log_id: ${e}]`:""}function m(e){return e&&"object"==typeof e&&"data"in e?e.data:e}function g(e){let t=new Headers(e);return t.set("Content-Type","application/json"),t}function y(e,t){let n=Math.floor(Date.now()/1e3);return{accessToken:e.access_token??"",tokenType:e.token_type??"Bearer",expiresAt:"number"==typeof e.expires_at?e.expires_at:n+(e.expires_in??0),baseUrl:t}}function _(e){return new Promise(t=>{setTimeout(t,e)})}function b(e,t){let n=new URL(e).host,r=new URL(`https://${n}/oauth/device`);return r.searchParams.set("user_code",t),r.toString()}n.d(t,{R$:()=>c,c$:()=>l,iD:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"(e,t,n){class r extends Error{constructor(e,t){super(e),this.code=t,this.name="AuthError"}}class o extends r{constructor(e="Not logged in"){super(e,"NOT_LOGGED_IN"),this.name="NotLoggedInError"}}class i extends r{constructor(e="Login token has expired"){super(e,"TOKEN_EXPIRED"),this.name="TokenExpiredError"}}class s extends r{constructor(e,t="DEVICE_AUTH_FAILED",n={}){super(e,t),this.name="DeviceAuthError",this.logId=n.logId}}n.d(t,{BX:()=>i,JC:()=>s,bG:()=>o,lR:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/store.js");function s(e=fetch,t={}){return async(n,s={})=>{let a=(0,o.$i)(t);var d=n,l=a.allowedOrigins;let c=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return e;return new URL(e.url)}catch{throw Error("Authenticated requests must use an absolute HTTPS URL")}}(d);if("https:"!==c.protocol)throw Error(`Authenticated requests must use https: ${c.toString()}`);if(!l.includes(c.origin))throw Error(`Refusing to attach Authorization header to untrusted origin: ${c.origin}`);let u=await (0,i.AI)(a.tokenPath,{allowExpired:!0,envTokenBaseUrl:a.baseUrl,credentialStore:a.credentialStore,legacyTokenPath:a.legacyTokenPath});if(!u)throw new r.bG;if((0,i._d)(u))throw new r.BX;let p=new Headers(s.headers);return a.requestHeaders.forEach((e,t)=>{p.set(t,e)}),p.set("Authorization",`${u.tokenType||"Bearer"} ${u.accessToken}`),e(n,{...s,headers:p})}}n.d(t,{r:()=>s})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"(e,t,n){n.r(t);var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"),d=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),l=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function c(e={}){let t=(0,r.$i)(e);await (0,s.ni)(t.tokenPath,{credentialStore:t.credentialStore}),t.legacyTokenPath&&await (0,s.ni)(t.legacyTokenPath,{credentialStore:t.credentialStore})}async function u(e={}){let t,n=(0,r.$i)(e);try{t=await (0,s.AI)(n.tokenPath,{envTokenBaseUrl:n.baseUrl,credentialStore:n.credentialStore,legacyTokenPath:n.legacyTokenPath})}catch(e){if(e instanceof o.RI)return{loggedIn:!1,tokenPath:n.tokenPath,baseUrl:n.baseUrl,credentialError:{code:"CREDENTIAL_STORE_UNAVAILABLE",message:e.message}};throw e}if(!t)return{loggedIn:!1,tokenPath:n.tokenPath};let i=await p(e.fetch??fetch,n.baseUrl,t,n.requestHeaders);return i?{loggedIn:!0,uid:i.userId,name:i.name,avatar:i.avatar,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}:{loggedIn:!1,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}}async function p(e,t,n,r){let o=new Headers(r);o.set("Authorization",`${n.tokenType||"Bearer"} ${n.accessToken}`);let i=await e(`${t.replace(/\/+$/,"")}/app_developer/api/user/basic`,{method:"GET",headers:o});if(!i.ok)return;let s=await i.json();if(0===s.code){var a;return{userId:"string"==typeof(a=s.data?.user_id)&&a.length>0?a:"number"==typeof a&&Number.isFinite(a)?String(a):void 0,name:s.data?.name,avatar:s.data?.avatar}}}n.d(t,{AuthError:()=>d.lR,CredentialStoreError:()=>o.RI,DeviceAuthError:()=>d.JC,NotLoggedInError:()=>d.bG,TokenExpiredError:()=>d.BX,TokenStatus:()=>l.A,completeLogin:()=>i.R$,configureAuth:()=>r.ZI,login:()=>i.iD,logout:()=>c,startLogin:()=>i.c$,whoami:()=>u,withAuth:()=>a.r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"(e,t,n){function r(e){let t=function(e){let t=e.split(".")[1];if(t)try{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(e.length+(4-e.length%4)%4,"="),r=Buffer.from(n,"base64").toString("utf8"),o=JSON.parse(r);return o&&"object"==typeof o?o:void 0}catch{return}}(e),n=t?.uid??t?.sub;return"string"==typeof n&&n.length>0?n:"number"==typeof n&&Number.isFinite(n)?String(n):void 0}n.d(t,{m:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"(e,t,n){var r=n("node:fs"),o=n("node:crypto"),i=n("node:path"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js");async function a(e,t={}){let n,r=process.env.DBX_ACCESS_TOKEN?.trim()||void 0;if(r)return{accessToken:r,tokenType:"Bearer",expiresAt:0xf4865700,baseUrl:t.envTokenBaseUrl??""};let o=await h(e);if(void 0===o)return f(e,t);try{n=JSON.parse(o)}catch(e){return}if(p(n)){if(!t.allowExpired&&c(n))return void await l(e,t);let r=await m(t).get(n.credentialAccount);if(!r)throw new s.RI("Stored login metadata exists, but the token credential is missing or inaccessible. Run dbx auth login again from a terminal that can access the credential store.");return{accessToken:r,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl}}if(u(n))return!t.allowExpired&&c(n)?void await l(e,t):(await d(e,n,t),n)}async function d(e,t,n={}){let o={version:2,storage:"keychain",credentialAccount:g(e),tokenType:t.tokenType,expiresAt:t.expiresAt,baseUrl:t.baseUrl};await m(n).set(o.credentialAccount,t.accessToken),await r.promises.mkdir(i.dirname(e),{recursive:!0,mode:448}),"win32"!==process.platform&&await r.promises.chmod(i.dirname(e),448);let s=`${e}.${process.pid}.${Date.now()}.tmp`;await r.promises.writeFile(s,`${JSON.stringify(o,null,2)}
12
+ `,{mode:384}),"win32"!==process.platform&&await r.promises.chmod(s,384),await r.promises.rename(s,e),"win32"!==process.platform&&await r.promises.chmod(e,384)}async function l(e,t={}){let n=await h(e);if(void 0!==n)try{let r=JSON.parse(n);p(r)?await m(t).delete(r.credentialAccount):await m(t).delete(g(e))}catch{}try{await r.promises.unlink(e)}catch(e){if(!y(e)||"ENOENT"!==e.code)throw e}}function c(e,t=Math.floor(Date.now()/1e3)){return e.expiresAt<=t}function u(e){return!!e&&"object"==typeof e&&"string"==typeof e.accessToken&&e.accessToken.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}function p(e){return!!e&&"object"==typeof e&&2===e.version&&"keychain"===e.storage&&"string"==typeof e.credentialAccount&&e.credentialAccount.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}async function h(e){try{return await r.promises.readFile(e,"utf8")}catch(e){y(e)&&e.code;return}}async function f(e,t){let n;if(!t.legacyTokenPath||i.resolve(t.legacyTokenPath)===i.resolve(e))return;let r=await h(t.legacyTokenPath);if(void 0!==r){try{n=JSON.parse(r)}catch{return}if(u(n))return!t.allowExpired&&c(n)?void await l(t.legacyTokenPath,t):(await d(e,n,t),await l(t.legacyTokenPath,t),n)}}function m(e){return e.credentialStore??(0,s.Mj)()}function g(e){let t=o.createHash("sha256").update(i.resolve(e)).digest("hex").slice(0,32);return`token:${t}`}function y(e){return e instanceof Error&&"code"in e}n.d(t,{AI:()=>a,_d:()=>c,ni:()=>l,tK:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.19/node_modules/@byted-doubao-apps/auth-cli/dist/types.js"(e,t,n){var r,o;(o=r||(r={}))[o.Pending=1]="Pending",o[o.Authorized=2]="Authorized",o[o.Expired=3]="Expired",o[o.Invalid=4]="Invalid",o[o.SlowDown=5]="SlowDown",n.d(t,{A:()=>r})}});var S={};e.r(S),e.d(S,{createDeferredDevShellSession:()=>t6,default:()=>t5,isInteractiveTerminal:()=>t7,withWebDebuggerFallback:()=>t9});let P=e("node:zlib"),D=e("../../../node_modules/.pnpm/@byted-doubao-tools+devtool-connection-core@0.1.0-beta.11_debug@4.4.3_react@19.2.7/node_modules/@byted-doubao-tools/devtool-connection-core/dist/lib/ipc/index.js"),x=4*Math.ceil(5614250.666666667),$=new Map;class L extends Error{code;cause;constructor(e,t,n){super(t),this.code=e,this.name="RuntimeInspectionError",n&&"cause"in n&&(this.cause=n.cause)}}async function R(e){let t,n=new g(e.namespace,{nodeId:`${e.nodeIdPrefix}-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:12e3}),r=new Set,o=new Set,s=0,a=!0;n.createService({name:`runtimeInspection${process.pid}${Math.random().toString(36).slice(2,8)}`,events:{[D.DEVTOOL_CONNECTION_IPC_EVENTS.messageReceived](e){let n=e.params,o=function(e){if("Page.screencastFrame"===e.method&&i(e.params)&&"string"==typeof e.params.data&&e.params.data)return{data:e.params.data}}(n);for(let e of(o&&Number.isSafeInteger(n.clientId)&&Number.isSafeInteger(n.sessionId)&&(t={clientId:n.clientId,sessionId:n.sessionId,data:o.data}),r))e(n)},[f.runtimeInspectionTargetChanged](e){let t=function(e){if(i(e)&&"number"==typeof e.clientId&&"number"==typeof e.sessionId&&"string"==typeof e.url)return{clientId:e.clientId,sessionId:e.sessionId,url:e.url}}(e.params);if(t)for(let e of o)e(t)}}});try{await n.start()}catch(e){throw await n.stop().catch(()=>void 0),e}let d=(e,t)=>ed(()=>n.call(`${D.DEFAULT_DEVTOOL_CONNECTION_IPC_SERVICE_NAME}.${e}`,t),5e3);return{eventSubscriptionWarmupMs:e.eventSubscriptionWarmupMs??5e3,getConnectedClients:()=>d(D.DEVTOOL_CONNECTION_IPC_ACTIONS.getConnectedClients),getLatestScreencastFrame(e){if(t?.clientId===e.clientId&&t.sessionId===e.sessionId)return{data:t.data}},async getRuntimeInspectionTarget(){if(!a)return null;try{return await n.call(c.getRuntimeInspectionTarget)}catch(e){if(ea(e))return a=!1,null;throw e}},subscribeRuntimeInspectionTarget:e=>(o.add(e),()=>{o.delete(e)}),async sendCdp(e,t,n={},r={}){let o={id:1e9+process.pid%1e5*1e3+s++,clientId:e.clientId,sessionId:e.sessionId,method:t,params:n,messageType:"CDP",timeoutMs:!1===r.expectResponse?100:1e4};try{let e=await d(D.DEVTOOL_CONNECTION_IPC_ACTIONS.sendMessageToApp,o);var a,l,c=t,u=e;if(!u.success)throw Error([u.reason,u.apps?.length?`apps=${u.apps.join(",")}`:"",u.clients?.length?`clients=${u.clients.map(e=>`${e.clientId}:${e.info.App}`).join(",")}`:""].filter(Boolean).join("; "));if(i(u.data)&&i(u.data.error)){let e=void 0===u.data.error.code?"unknown":String(u.data.error.code),t=void 0===u.data.error.message?"unknown error":String(u.data.error.message);throw Error(`${c} failed: ${t} (code=${e})`)}return Y(u.data)}catch(e){if(!1===r.expectResponse&&(a=e,l=t,(a instanceof Error?a.message:String(a)).includes(`send CDP message timeout, method: ${l}`)))return;throw Error(`${t} failed: ${e instanceof Error?e.message:String(e)}`)}},subscribeMessage:e=>(r.add(e),()=>{r.delete(e)}),async stop(){r.clear(),o.clear(),t=void 0,await n.stop()}}}async function N(e,t={}){let n=Date.now()+(t.timeoutMs??3e3);for(;;){ec(t.signal);let r=await e.getConnectedClients(),o=function(e,t={}){let n,r=t.explicitTarget??(t.policy?.kind==="fixed"?t.policy.target:void 0);if(r){let n=e.find(e=>e.device.clientId===r.clientId);if(!n){if(t.activeClientId===r.clientId)throw new L("TARGET_CLIENT_DISCONNECTED",`debug client ${r.clientId} is disconnected`);throw new L("TARGET_STALE",`${O(r)} no longer points to a connected debug client`)}let o=n.sessions.find(e=>e.sessionId===r.sessionId&&V(e));if(!o)throw new L("TARGET_STALE",`${O(r)} no longer points to a live Lynx session`);return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}if(void 0!==t.activeClientId){if(!(n=e.find(e=>e.device.clientId===t.activeClientId)))throw new L("TARGET_CLIENT_DISCONNECTED",`authenticated debug client ${t.activeClientId} is disconnected`)}else if(e.length>1)throw new L("TARGET_AMBIGUOUS",`more than one debug device is connected: ${e.map(e=>`${e.device.clientId}:${e.device.info.App||"unknown"}`).join(", ")}`);else n=e[0];if(!n)return;let o=n.sessions.filter(V).sort((e,t)=>t.sessionId-e.sessionId)[0];if(o)return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}(r,t);if(o)return o;if(Date.now()>=n)throw 0===r.length?new L("DEVICE_NOT_CONNECTED","no debug device is connected"):new L("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");await eu(100,t.signal)}}function O(e){return`@${e.clientId}:${e.sessionId}`}function q(e){let t=/^@([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new L("INVALID_TARGET_REF",`invalid target ref "${e}"; expected @<clientId>:<sessionId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId))throw new L("INVALID_TARGET_REF",`invalid target ref "${e}"; every id must be a safe integer`);return n}function M(e){return`@${e.clientId}:${e.sessionId}:${e.nodeId}`}async function B(e,t){let n=(await e.getConnectedClients()).find(e=>e.device.clientId===t.clientId),r=n?.sessions.find(e=>e.sessionId===t.sessionId&&V(e));if(!n||!r)throw new L("STALE_NODE_REF",`${M(t)} no longer points to a live Lynx session; run get-page-tree again`);return{clientId:t.clientId,sessionId:t.sessionId,url:r.url}}async function U(e,t,n={}){var r,o,s;let a,d,l,c,u,p=n.depth??-1,h=n.maxNodes??5e3;if(!Number.isInteger(p)||p<-1)throw Error("page tree depth must be -1 or a non-negative integer");if(!Number.isSafeInteger(h)||h<1)throw Error("page tree maxNodes must be a positive integer");await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{u=await e.sendCdp(t,"DOM.getDocument",{depth:p})}catch{u=await e.sendCdp(t,"DOM.getDocument")}let f=function(e){let t=Y(e);if(!i(t))throw ee("DOM.getDocument","response is not an object");let n=t.root;if(!0===t.compress&&"string"==typeof n)try{if(n.length>x)throw Error("compressed root exceeds the input limit");n=JSON.parse((0,P.inflateSync)(Buffer.from(n,"base64"),{maxOutputLength:0x1000000}).toString("utf8"))}catch(e){throw ee("DOM.getDocument","failed to decode compressed root",e)}else if("string"==typeof n)try{n=JSON.parse(n)}catch(e){throw ee("DOM.getDocument","root is not valid JSON",e)}if(!i(n))throw ee("DOM.getDocument","missing root node");return n}(u),m=await K(e,t,f,p,h),g=(r=f,o=t,s=h,a=0,d=!1,l=[],{root:(c=e=>{var t;let n=G(e.nodeId),r="string"==typeof e.nodeName&&e.nodeName?e.nodeName:"unknown";if(void 0===n)throw ee("DOM.getDocument",`node ${r} has no valid nodeId`);a++;let i=[],u={ref:M({clientId:o.clientId,sessionId:o.sessionId,nodeId:n}),nodeId:n,...void 0===G(e.backendNodeId)?{}:{backendNodeId:G(e.backendNodeId)},nodeType:"number"==typeof e.nodeType&&Number.isSafeInteger(e.nodeType)?e.nodeType:0,nodeName:r,..."string"==typeof e.localName?{localName:e.localName}:{},nodeValue:"string"==typeof e.nodeValue?e.nodeValue:"",attributes:function(e){if(!Array.isArray(e))return{};let t={};for(let n=0;n<e.length;n+=2){let r=e[n];if("string"!=typeof r||!r)continue;let o=e[n+1];t[r]="string"==typeof o?o:String(o??"")}return t}(e.attributes),childNodeCount:"number"==typeof e.childNodeCount&&Number.isSafeInteger(e.childNodeCount)?Math.max(0,e.childNodeCount):J(e).length,children:i};for(let t of(W(u)&&u.nodeValue&&(u.text=u.nodeValue),J(e))){if(a>=s){d=!0;break}i.push(c(t))}if("text"===((t=u).localName||t.nodeName).toLowerCase()){let e=function e(t){return t.children.flatMap(t=>W(t)?[t.nodeValue]:[e(t)]).join("")}(u);e?u.text=e:l.push(u)}return u})(r),nodeCount:a,truncated:d,textCandidates:l});return await Q(e,t,g.textCandidates),{target:t,depth:p,nodeCount:g.nodeCount,truncated:m.truncated||g.truncated,root:g.root}}async function F(e,t,n,r=[]){let o;await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{o=await e.sendCdp(t,"CSS.getComputedStyleForNode",{nodeId:n.nodeId})}catch(e){var s;if(s=e,/(could not find|cannot find|no such|unknown|invalid|stale).{0,40}node|node.{0,40}(not found|does not exist|invalid|stale)/i.test(s instanceof Error?s.message:String(s)))throw new L("STALE_NODE_REF",`${M(n)} is stale; run get-page-tree again`,{cause:e});throw e}let a=Y(o);if(!i(a)||!Array.isArray(a.computedStyle))throw ee("CSS.getComputedStyleForNode","missing computedStyle array");let d=a.computedStyle.filter(i).flatMap(e=>"string"==typeof e.name&&"string"==typeof e.value?[{name:e.name,value:e.value}]:[]),l=0===r.length?d:r.flatMap(e=>{let t=d.find(t=>t.name===e);return t?[t]:[]});return{target:t,nodeRef:M(n),nodeId:n.nodeId,properties:l}}function V(e){return"lynx"===e.type&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!z(e.url)}function H(e){return`${e.clientId}:${e.sessionId}`}function z(e){return/(?:-main\.js|\.main\.lynx\.js)(?:[?#].*)?$/.test(e)}async function K(e,t,n,r,o){let s=0,a=!1,d=async(n,l)=>{if(s>=o){a=!0;return}if(s++,r>=0&&l>=r)return;let c=J(n);if(("number"==typeof n.childNodeCount&&Number.isSafeInteger(n.childNodeCount)?Math.max(0,n.childNodeCount):c.length)>c.length&&"number"==typeof n.nodeId&&Number.isSafeInteger(n.nodeId)){let r=Y(await e.sendCdp(t,"DOM.requestChildNodes",{nodeId:n.nodeId}));if(!i(r)||!Array.isArray(r.nodes))throw ee("DOM.requestChildNodes",`missing nodes array for node ${n.nodeId}`);n.children=c=r.nodes.filter(i)}for(let e of c)if(await d(e,l+1),s>=o){c.indexOf(e)<c.length-1&&(a=!0);break}};return await d(n,0),{truncated:a}}function Y(e){return i(e)&&"id"in e&&"result"in e?e.result:e}function J(e){return Array.isArray(e.children)?e.children.filter(i):[]}function G(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0?e:void 0}function W(e){return 3===e.nodeType||"#text"===e.nodeName.toLowerCase()}async function Q(e,t,n){let r=n[0];if(!r)return;let o=await X(e,t,r);if(o.supported){o.text&&(r.text=o.text);for(let r=1;r<n.length;r+=8){let o=n.slice(r,r+8);await Promise.all(o.map(async n=>{let r=await X(e,t,n);r.text&&(n.text=r.text)}))}}}async function X(e,t,n){try{let r=Y(await e.sendCdp(t,"DOM.innerText",{nodeId:n.nodeId}));if(!i(r)||!Array.isArray(r.rawTextValues))return{supported:!1};let o=r.rawTextValues.filter(i).flatMap(e=>"string"==typeof e.text?[e.text]:[]).join("");return{supported:!0,...o?{text:o}:{}}}catch{return{supported:!1}}}function Z(e,t=120){let n=e.replace(/\s+/g," ").trim();return JSON.stringify(n.length>t?`${n.slice(0,Math.max(0,t-1))}…`:n)}function ee(e,t,n){return new L("INVALID_CDP_RESPONSE",`${e} returned an invalid response: ${t}`,void 0===n?void 0:{cause:n})}async function et(e,t,n){let r,o,s,a=0,d=!1,l=H(t),c=new Promise((e,t)=>{o=e,s=t}),u=e=>{d||(d=!0,o({count:a,reason:e}))},p=()=>u("aborted"),h=e.getRuntimeInspectionTarget?.bind(e),f=e=>{if(d||!(Number.isSafeInteger(e.clientId)&&e.clientId>0&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!z(e.url)))return;let r=H(e);if(r!==l&&(l=r,r!==H(t)))try{n.onTargetChange?.(e)}catch{}},m=e.subscribeMessage(e=>{if(d||!er(e,t))return;let r=function(e){var t;if("Runtime.consoleAPICalled"!==e.method||!i(e.params))return;let n={...t=e.params,...Array.isArray(t.args)?{args:t.args.map(e=>i(e)?{...e}:e)}:{},...i(t.stackTrace)?{stackTrace:{...t.stackTrace,...Array.isArray(t.stackTrace.callFrames)?{callFrames:t.stackTrace.callFrames.map(e=>i(e)?{...e}:e)}:{}}}:{}},r="string"==typeof n.consoleTag?n.consoleTag:void 0;return{type:"string"==typeof n.type?n.type:"log",thread:"Lepus"===r?"main":"background",args:Array.isArray(n.args)?n.args:[],...r?{consoleTag:r}:{},..."number"==typeof n.timestamp?{timestamp:n.timestamp}:{},..."stackTrace"in n?{stackTrace:n.stackTrace}:{},params:n}}(e);if(r){try{n.onMessage(r)}catch(e){d||(d=!0,s(e));return}a++,void 0!==n.limit&&a>=n.limit&&u("limit")}}),g=n.onTargetChange?e.subscribeRuntimeInspectionTarget?.(f):void 0;n.signal?.addEventListener("abort",p,{once:!0}),n.onTargetChange&&h&&h().then(e=>{e&&f(e)}).catch(()=>void 0);try{if(n.signal?.aborted)return u("aborted"),await c;if(await eo(e,t,n.subscriptionWarmupMs??e.eventSubscriptionWarmupMs??5e3,n.signal),d)return await c;for(let o of(void 0!==n.timeoutMs&&(r=setTimeout(()=>u("timeout"),n.timeoutMs)),[{method:"Page.getResourceTree",params:{}},{method:"Debugger.enable",params:{}},{method:"Runtime.enable",params:{}}])){if(d)break;await e.sendCdp(t,o.method,o.params,{expectResponse:!1})}return await c}catch(e){if(n.signal?.aborted)return u("aborted"),await c;throw e}finally{r&&clearTimeout(r),n.signal?.removeEventListener("abort",p),g?.(),m()}}async function en(e,t,n={}){return el(t,async()=>{let r,o=new Promise(e=>{r=e}),s=e.subscribeMessage(e=>{er(e,t)&&"Page.screencastFrame"===e.method&&i(e.params)&&"string"==typeof e.params.data&&e.params.data&&r({data:e.params.data})}),a=!1;try{var d,l,c;await eo(e,t,e.eventSubscriptionWarmupMs??5e3);let r=n.activeCapture?void 0:e.getLatestScreencastFrame?.(t);!r&&n.activeCapture&&(await e.sendCdp(t,"Page.enable"),a=!0,await e.sendCdp(t,"Page.startScreencast",{format:"jpeg",quality:80},{expectResponse:!1})),r??=await (d=o,l=t,c=n.timeoutMs??1e4,new Promise((e,t)=>{let n=setTimeout(()=>t(new L("SCREENSHOT_TIMEOUT",`no Page.screencastFrame received for ${O(l)} within ${c}ms; make sure the target session is active and can produce screenshot frames`)),c);d.then(t=>{clearTimeout(n),e(t)},e=>{clearTimeout(n),t(e)})})),a&&await e.sendCdp(t,"Page.screencastFrameAck",{},{expectResponse:!1}).catch(()=>void 0);let i=function(e){let t=e.replace(/\s+/g,"");if(!t||t.length%4!=0||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame returned invalid base64 data");let n=Buffer.from(t,"base64");if(n.length<4||255!==n[0]||216!==n[1]||255!==n[n.length-2]||217!==n[n.length-1])throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame did not return a complete JPEG image");let r=function(e){let t=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]),n=2;for(;n+3<e.length;){if(255!==e[n]){n++;continue}for(;n<e.length&&255===e[n];)n++;let r=e[n++];if(void 0===r||217===r||218===r)break;if(1===r||r>=208&&r<=215)continue;if(n+1>=e.length)break;let o=e.readUInt16BE(n);if(o<2||n+o>e.length)break;if(t.has(r)){if(o<7)break;let t=e.readUInt16BE(n+3),r=e.readUInt16BE(n+5);if(r>0&&t>0)return{width:r,height:t};break}n+=o}}(n);if(!r)throw new L("INVALID_SCREENSHOT_DATA","Page.screencastFrame JPEG has no readable dimensions");return{buffer:n,data:t,...r}}(r.data);return{data:i.data,format:"jpeg",source:"Page.screencastFrame",width:i.width,height:i.height,byteLength:i.buffer.length}}finally{a&&await e.sendCdp(t,"Page.stopScreencast",{},{expectResponse:!1}).catch(()=>void 0),s()}})}function er(e,t){return"CDP"===e.messageType&&e.clientId===t.clientId&&e.sessionId===t.sessionId}async function eo(e,t,n,r){let o;if(n<=0)return;let i=Date.now()+n,s=new Promise(e=>{o=e}),a=e.subscribeMessage(e=>{er(e,t)&&o()});try{for(;Date.now()<i;){if(ec(r),await e.sendCdp(t,"Page.getResourceTree",{},{expectResponse:!1}).catch(()=>void 0),await function(e,t,n){return new Promise((r,o)=>{let i=new AbortController,s=setTimeout(()=>{i.abort(),r(!1)},t);n?.addEventListener("abort",()=>{clearTimeout(s),i.abort(),o(n?.reason instanceof Error?n.reason:Error("operation aborted"))},{once:!0,signal:i.signal}),e.then(()=>{clearTimeout(s),i.abort(),r(!0)},e=>{clearTimeout(s),i.abort(),o(e)})})}(s,Math.min(250,Math.max(0,i-Date.now())),r))return;await eu(Math.min(50,Math.max(0,i-Date.now())),r)}}finally{a()}}function ei(e){return i(e)?e.objectId?`<${String(e.description||e.className||"Object")} (objectId:${String(e.objectId)})>`:"value"in e?es(e.value):"string"==typeof e.description?e.description:es(e):es(e)}function es(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";try{let t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}function ea(e){return/is not (found|available)/i.test(e instanceof Error?e.message:String(e))}async function ed(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(!ea(e)||Date.now()>=n)throw e;await eu(50)}}async function el(e,t){let n,r=H(e),o=$.get(r)??Promise.resolve(),i=new Promise(e=>{n=e});$.set(r,i),await o.catch(()=>void 0);try{return await t()}finally{n(),$.get(r)===i&&$.delete(r)}}function ec(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:Error("operation aborted")}function eu(e,t){return new Promise((n,r)=>{if(t?.aborted)return void r(t.reason instanceof Error?t.reason:Error("operation aborted"));let o=new AbortController,i=setTimeout(()=>{o.abort(),n()},e);t?.addEventListener("abort",()=>{clearTimeout(i),o.abort(),r(t?.reason instanceof Error?t.reason:Error("operation aborted"))},{once:!0,signal:o.signal})})}let ep={schemaVersion:1,cliVersion:o,deviceAppVersion:"1.0.7",packages:{"darwin-arm64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/440719597/1.0.7/darwin-arm64/DoubaoDeveloperTools-v1.0.7-darwin-arm64.zip",sha256:"050c45bf3eba444343a9e49d951c4c98851f1c81412d6ab3f08c05e201634c1f",entry:"豆包开发者工具.app",sizeBytes:0x77fdd18},"win32-x64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/440719597/1.0.7/win32-x64/DoubaoDeveloperTools-v1.0.7-win32-x64.zip",sha256:"455cc927477cd88a152ed2ec3ff1e92511996a8fb5ebfa59625b5b8884671848",entry:"豆包开发者工具.exe",sizeBytes:0x84c4955}}},eh=e("node:child_process"),ef=e("node:crypto");var em=e.n(ef);let eg=e("node:fs");var ey=e.n(eg);let e_=e("node:http"),eb=e("node:os");var ew=e.n(eb);let ev=e("node:path");var eE=e.n(ev);let eI=e("node:stream"),eT=e("node:url"),eA=e("node:util"),eC=e("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"),ej=e("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"),ek="DBX_DEVICE_APP_PATH",eS="dbx-device-app.json",eP="state.json",eD="versions",ex=eE().dirname((0,eT.fileURLToPath)(import.meta.url)),e$=[{command:"web",description:"打开 Web 模拟器"},{command:"device",description:"进入真机调试"},{command:"status",description:"查看本地调试服务状态"}],eL=[{command:"qr",description:"重新生成真机调试二维码"},{command:"page [url]",description:"在真机打开页面(省略 url 可选择)"},{command:"pages",description:"列出真机可打开页面"},{command:"widget [id]",description:"向真机推送卡片(省略 id 可选择)"},{command:"widgets",description:"列出真机可推送卡片"},{command:"sessions",description:"列出当前可检查的 Lynx sessions"},{command:"use-session <@client:session|latest>",description:"固定 CLI session 或恢复跟随最新"},{command:"get-console",description:"持续输出当前 Lynx 页面新产生的日志"},{command:"take-screenshot",description:"截取当前 Lynx 页面画面"},{command:"get-page-tree",description:"获取当前 Lynx 页面的 DOM 树"},{command:"get-computed-style [node-ref]",description:"获取 DOM 节点的 computed style"},{command:"back",description:"返回主命令"}];function eR(e){if("complete"===e.phase)return`豆包开发者工具已安装:${e.appPath}`;if("install"===e.phase){let t={verify:"验证",extract:"解压",install:"安装"}[e.stage];return`安装豆包开发者工具:${t}`}let t=[void 0===e.percentage?void 0:`${e.percentage}%`,void 0===e.totalBytes?e.downloadedBytes>0?e9(e.downloadedBytes):void 0:`${e9(e.downloadedBytes)} / ${e9(e.totalBytes)}`,`${Math.max(0,Math.round(e.elapsedMs/1e3))}s`].filter(e=>!!e);return`下载豆包开发者工具:${t.join(" \xb7 ")}`}function eN(e,t){let n,r=!1;return o=>{if(!o)return void t?.(void 0);if("download"===o.phase){n=o,t?.(o);return}if(n&&!r&&(r=!0,t1(e,`✓ ${eR(n)}`)),"complete"===o.phase){t?.(void 0),t1(e,`✓ ${eR(o)}`);return}t?.(o)}}function eO(e,t){if("true"===e)return!0;if("false"===e)return!1;throw Error(`${t} must be "true" or "false"`)}async function eq(e){var t,n;let r,o,i,s,a,d=e.output??process.stderr,l=e.client??await m({projectPath:e.projectPath,appDir:e.appDir,nodeIdPrefix:"dev-shell"}),c=e.closeDeviceApp??eX,u=new AbortController,p=e.openBrowser??b,h=new Set,f={runtime:e.runtime,client:l,output:d,manageDeviceApp:!0,runtimeInspectionTargetPolicy:{kind:"latest"},openBrowser:p,openQRCodeViewer:e.openQRCodeViewer??((e,t,n)=>tW(e,p,t,d,n)),signal:u.signal,launchDeviceApp:e.launchDeviceApp??(e=>eG(e,d)),closeDeviceApp:c,prepareDeviceApp:e.prepareDeviceApp??(e=>eW(d,e)),...e.onDeviceAppSetupProgress?{onDeviceAppSetupProgress:e.onDeviceAppSetupProgress}:{},openPreparedDeviceApp:e.openPreparedDeviceApp??eQ,runRealDeviceAuth:e.runRealDeviceAuth??tO,...e.createRuntimeInspectionSession?{createRuntimeInspectionSession:e.createRuntimeInspectionSession}:{},listAppVersions:e.listAppVersions??(async e=>{let t=await _(e);return t.data?.version_list??[]}),selectItem:e.selectItem},y=(e.createRuntimeInspectionSession??R)({namespace:e.runtime.getState().namespace,nodeIdPrefix:"dev-shell-runtime-inspection"});y.catch(()=>void 0),f.runtimeInspectionSession=y;let w=async()=>s||(s=(async()=>{f.activeDeviceId=void 0,tG(),f.manageDeviceApp&&await eU(f)})().finally(()=>{s=void 0})),v=(t=e.runtime.getState().namespace,n=async()=>{if(f.activeDeviceId&&!a){t1(d,"检测到真机连接断开,正在返回主命令并清理真机调试资源..."),await w();for(let e of h)try{e("client-disconnected")}catch{}}},(r=new g(t,{nodeId:`dev-disconnect-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3})).createService({name:`devDisconnectListener${process.pid}`,events:{"connection.clientDisconnected":()=>n()}}),{start:()=>r.start(),stop:()=>r.stop()});return await v.start(),{stopped:e.runtime.stopped,getState:()=>e.runtime.getState(),execute(e){let t=new AbortController,n=AbortSignal.any([u.signal,t.signal]);i=t,f.signal=n;let r=eM(e,f);return o=r,r.finally(()=>{o===r&&(o=void 0),i===t&&(i=void 0),f.signal===n&&(f.signal=u.signal)})},cancelActiveCommand(){if(!i||i.signal.aborted)return!1;let e=Error("command cancelled");return e.name="AbortError",i.abort(e),!0},returnToRoot:()=>w(),handleClientDisconnected:()=>w(),subscribe:e=>(h.add(e),()=>{h.delete(e)}),close:()=>a??=(async()=>{u.abort(new tH),await o?.catch(()=>void 0),await v.stop().catch(()=>void 0),await w(),await f.runtimeInspectionSession?.then(e=>e.stop()).catch(()=>void 0),await l.stop().catch(()=>void 0),await e.runtime.stop().catch(()=>void 0)})()}}async function eM(e,t){var n;let r;try{r=function(e){let t,n=[],r="",o=!1,i=()=>{r.length>0&&(n.push(r),r="")};for(let n of e.trim()){if(o){r+=n,o=!1;continue}if("\\"===n&&"'"!==t){o=!0;continue}if("'"===n||'"'===n){if(!t){t=n;continue}if(t===n){t=void 0;continue}}if(!t&&/\s/.test(n)){i();continue}r+=n}if(o&&(r+="\\"),t)throw Error(`unterminated ${t} quote`);return i(),n}(e)}catch(e){return t1(t.output,tF(t4(e))),"continue"}let o=r[0]?.toLowerCase(),i=r.slice(1);if(!o)return"continue";if((n=i).includes("--help")||n.includes("-h")){let e="device"===o&&i[0]&&!i[0].startsWith("-")?`device ${i[0].toLowerCase()}`:o;if(function(e,t){switch(t){case"device widget":return t1(e,"usage: widget [widget-id] [--data <json>] [--bot-id <id>] [--device-id <id>]"),t1(e,"推送卡片到已连接真机;省略 widget-id 时从 `widgets` 列表中选择。"),!0;case"device page":return t1(e,"usage: page [url] [--device-id <id>]"),t1(e,"通过完整 URL 打开页面;省略 url 时从 `pages` 列表中选择。页面参数请写入 URL query。"),!0;case"device":t1(e,"usage: device [--agent] [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),t1(e,"进入真机模式并连接调试设备,默认准备并打开豆包开发者工具。"),t1(e,"使用 `device --agent` 进入 Agent 模式,不准备、启动或关闭豆包开发者工具。"),t1(e,"使用 --mcp 进入 MCP 端到端调试,并从当前 AppID 的版本列表中选择 versionTag。");for(let t of(t1(e,"真机调试命令"),eL))t1(e,` ${t.command.padEnd(22)}${t.description}`);return t1(e,"进入真机模式后执行 `<命令> --help` 查看参数。"),t1(e,"get-page-tree、get-computed-style、take-screenshot 支持通用的 --json 输出。"),!0;case"device qr":return t1(e,"usage: qr [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),t1(e,"重新生成真机调试二维码;MCP 端到端调试会沿用已选择的 versionTag,也可用 --mcp 重新选择。"),!0;case"device get-console":return t1(e,"usage: get-console [--target <@client:session>] [--limit <count>] [--timeout-seconds <seconds>] [--include-stack-traces]"),t1(e,"持续输出当前 Lynx session 新产生的 console 日志;按 Ctrl+C 停止监听并返回真机命令。"),t1(e,"默认仅 error 日志显示调用栈;使用 --include-stack-traces 展开所有日志的调用栈。"),!0;case"device sessions":return t1(e,"usage: sessions"),t1(e,"列出当前可检查的 Lynx sessions,并标记 latest、CLI fixed 和 Electron current。"),!0;case"device use-session":return t1(e,"usage: use-session <@client:session|latest>"),t1(e,"固定 CLI 后续检查命令使用的 session,或用 latest 恢复到鉴权 client 内最新活跃 session;不会切换 Electron。"),!0;case"device take-screenshot":return t1(e,"usage: take-screenshot [--target <@client:session>] [-o, --output <file.jpeg>] [--json]"),t1(e,"保存 Electron 当前为目标 session 输出的最近一帧 JPEG;截图范围跟随 Electron 当前 mode。"),!0;case"device get-page-tree":return t1(e,"usage: get-page-tree [--target <@client:session>] [--depth <-1|n>] [--json]"),t1(e,"获取当前 Lynx session 的 DevTools Elements DOM 树;默认 depth=-1。"),t1(e,"终端输出紧凑树;--json 输出节点文本、完整 attributes 和可复用 node-ref。"),!0;case"device get-computed-style":return t1(e,"usage: get-computed-style <node-ref> [--properties <name,...>] [--json]"),t1(e,"获取元素节点的 computed style;node-ref 格式为 @<clientId>:<sessionId>:<nodeId>。"),t1(e,"省略 --properties 返回全部属性,例如 --properties color,font-size。"),!0;case"web":return t1(e,"usage: web"),t1(e,"在默认浏览器打开本地 Web 模拟器。"),!0;case"device pages":case"device widgets":{let n="device pages"===t?"打开的页面":"推送的卡片";return t1(e,`usage: ${t.slice(7)}`),t1(e,`列出真机可${n}。`),!0}case"status":return t1(e,"usage: status"),t1(e,"查看本地调试服务状态。"),!0;default:return!1}}(t.output,e))return"continue"}try{switch(o){case"status":return await eF(t),"continue";case"web":return await eV(t),"continue";case"device":return await eB(t,i)?"enter-device":"continue";default:return t1(t.output,`unknown command: ${o}`),["qr","pages","page","widgets","widget","sessions","use-session","get-console","take-screenshot","get-page-tree","get-computed-style"].includes(o)&&t1(t.output,`\`${o}\` is only available in device mode; run \`device\` first.`),"continue"}}catch(e){return t1(t.output,tF(t4(e))),"continue"}}async function eB(e,t){let n=t[0]?.toLowerCase();if(!n||n.startsWith("-"))return await eH(e,t,{reuseDeviceAppMode:!1,reuseVersionTag:!1}),!0;let r=function(e){let t=!1,n=[];for(let r of e)"--json"===r?t=!0:n.push(r);return{args:n,json:t}}(t.slice(1)),o=["get-page-tree","get-computed-style","take-screenshot"].includes(n);try{if(r.json&&!o)throw Error(`--json is not supported by device ${n}; use it with get-page-tree, get-computed-style, or take-screenshot`);switch(n){case"qr":return await eY(e,r.args),!0;case"pages":return await tv(e,"page",c.discoverPages),!0;case"page":return await tx(e,r.args),!0;case"widgets":return await tv(e,"widget",c.discoverWidgets),!0;case"widget":return await t$(e,r.args),!0;case"sessions":return await tE(e,r.args),!0;case"use-session":return await tI(e,r.args),!0;case"get-console":return await tT(e,r.args),!0;case"take-screenshot":return await tA(e,r.args,r.json),!0;case"get-page-tree":return await tC(e,r.args,r.json),!0;case"get-computed-style":return await tj(e,r.args,r.json),!0;default:return t1(e.output,`unknown device subcommand: ${n}`),!1}}catch(t){if(!r.json||!o)throw t;return t2(e.output,{ok:!1,error:{code:t instanceof L?t.code:"INSPECTION_FAILED",message:t4(t)}}),!0}}async function eU(e){try{var t,n;let r=await e.closeDeviceApp();t=e.output,n=r,"closed"===n.status?t1(t,`豆包开发者工具已关闭:${n.appPath}`):t1(t,`关闭豆包开发者工具失败${n.reason?`:${tF(n.reason)}`:""}`)}catch(t){t1(e.output,`关闭豆包开发者工具失败:${tF(t4(t))}`)}}async function eF(e){let t=await e.client.call(c.getInfo);t1(e.output,`status: ${t.status}`),t1(e.output,`app_id: ${t.appId??"-"}`),t1(e.output,`dev_server: ${t.host??"-"}`),t1(e.output,`web_debugger: ${t.webDebuggerUrl??"-"}`)}async function eV(e){let t=e.runtime.getState().webDebuggerUrl;if(!t)throw Error("web debugger URL is not ready");await e.openBrowser(t),t1(e.output,`Web 模拟器已打开:${t}`)}async function eH(e,t,n){var r,o,i;let s,a,d,l=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{agent:{type:"boolean"},timeout:{type:"string"},"qr-file":{type:"string"},mcp:{type:"boolean"},"wifi-connect":{type:"string"},defaultDebugTagState:{type:"string"}}});if(n.reuseDeviceAppMode&&l.values.agent)throw Error("--agent is only supported when entering device mode");n.reuseDeviceAppMode||(e.manageDeviceApp=!l.values.agent);let c=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout must be a positive number of seconds");return Math.round(1e3*t)}(l.values.timeout),u=function(e){if(!e)return;let t=eE().resolve(e);if(".png"!==eE().extname(t).toLowerCase())throw Error("--qr-file must point to a .png file");return t}(l.values["qr-file"]),p=tM((r={defaultDebugTagState:l.values.defaultDebugTagState,wifiConnect:l.values["wifi-connect"]},d={},void 0!==r.defaultDebugTagState&&(d.defaultDebugTagState=eO(r.defaultDebugTagState,"--defaultDebugTagState")),void 0!==r.wifiConnect&&(d.usb=!eO(r.wifiConnect,"--wifi-connect")),Object.keys(d).length>0?d:void 0)),h=await e.client.call("dev.setConnectionTransport",{type:p.usb?"usb":"wifi"}),f=e.runtime.getState(),m=l.values.mcp?await ez(e,f.appId):n.reuseVersionTag?e.activeVersionTag:void 0;if(l.values.mcp&&!m)return;e.activeVersionTag=m,m&&!l.values.mcp&&t1(e.output,`沿用 MCP 端到端调试 versionTag:${m}`),e.manageDeviceApp||t1(e.output,"已启用 --agent:不会准备、启动或关闭豆包开发者工具。");let g={namespace:f.namespace,projectPath:f.projectPath,appDir:f.appDir,appKey:f.appId,hostUrl:f.host},y=e.manageDeviceApp?await eK(e):void 0;if(y?.status==="skipped")return void t1(e.output,`启动真机调试失败:${tF(y.reason??"豆包开发者工具准备失败")}`);tG();let _=new AbortController,b=e.signal?AbortSignal.any([e.signal,_.signal]):_.signal;try{a=await e.runRealDeviceAuth({hostUrl:h.host||f.host,appKey:h.appId||f.appId,versionTag:m,namespace:f.namespace,timeoutMs:c,settings:p,wifiConnectUrl:h.wifiConnectUrl,output:e.output,signal:b,onQRCodeReady:async(t,n)=>{(s=await e.openQRCodeViewer(t,u,n)).closed.then(()=>{_.abort(new tH)})}})}finally{await s?.close().catch(()=>void 0),tG()}if(function(e,t){let n;if(t.ok){let n=t.client?.clientId===void 0?"":`:client ${t.client.clientId}`,r=t.qrCodeValue?"扫码鉴权完成":"复用已连接设备,已跳过二维码鉴权";t1(e,`真机调试已连接${n}(${r})。`);return}"cancelled"===t.status?t1(e,"install"===t.waitingFor?"二维码页面已关闭,已取消等待设备安装。":"二维码页面已关闭,已取消等待设备连接。"):(n="timeout"===t.status?"install"===t.waitingFor?`设备已连接,但等待安装完成超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:`等待设备连接超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:tF(t.error??"未知错误"),t1(e,`启动真机调试失败:${n}`))}(e.output,a),a.ok&&"connected"===a.status){a.client?.clientId!==void 0&&(void 0!==e.activeClientId&&e.activeClientId!==a.client.clientId&&(e.runtimeInspectionTargetPolicy={kind:"latest"}),e.activeClientId=a.client.clientId);let t=a.client?.deviceId??(a.client?.clientId===void 0?void 0:String(a.client.clientId));t&&(e.activeDeviceId=t)}if(e.manageDeviceApp&&a.ok&&"connected"===a.status){let t=y?await eJ(e,y,g):await e.launchDeviceApp(g);o=e.output,"opened"===(i=t).status?t1(o,`豆包开发者工具已启动:${i.appPath}`):t1(o,`启动豆包开发者工具失败${i.reason?`:${tF(i.reason)}`:""}`)}}async function ez(e,t){if(!t)throw Error("无法查询 versionTag,当前工程缺少 AppID。");let n=(await e.listAppVersions(t)).filter(e=>"string"==typeof e.version_tag&&!!e.version_tag.trim());if(!n.length)throw Error(`当前 AppID(${t})没有可选的 versionTag。`);let r=await e.selectItem("versionTag",n,e.output);return r?(t1(e.output,`MCP 端到端调试 versionTag:${r}`),r):void t1(e.output,"已取消 versionTag 选择,未生成二维码。")}async function eK(e){if(e.prepareDeviceApp){e.onDeviceAppSetupProgress?.(void 0);try{return await e.prepareDeviceApp({onProgress:eN(e.output,e.onDeviceAppSetupProgress)})}catch(t){return e.onDeviceAppSetupProgress?.(void 0),{status:"skipped",reason:t4(t)}}}}async function eY(e,t){await eH(e,t,{reuseDeviceAppMode:!0,reuseVersionTag:!0})}async function eJ(e,t,n){return"skipped"!==t.status&&t.appPath?e.openPreparedDeviceApp?e.openPreparedDeviceApp(t.appPath,n):e.launchDeviceApp(n):{status:"skipped",reason:t.reason}}async function eG(e,t=process.stderr){let n=await eW(t);return"skipped"!==n.status&&n.appPath?eQ(n.appPath,e):{status:"skipped",reason:n.reason}}async function eW(e=process.stderr,t={}){let n=function(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??e4(),i=e.manifest??ep,s=e3(t);if(t[ek]?.trim()||!s&&e1({...t,[ek]:""},n,o))return;ta(i);let a=e5(n,r);if(!a)return;let d=i.packages[a];if(!d)return;td(d);let l=tl(i,d),c=e2(t,n);if(!(!s&&e6(c,i,a,d,l)))return{platform:a,version:l,...void 0===d.sizeBytes?{}:{sizeBytes:d.sizeBytes}}}();return n&&!t.onProgress&&(t1(e,"真机调试准备:"),t1(e,`首次或版本更新需要下载豆包开发者工具${n.sizeBytes?`(${e9(n.sizeBytes)})`:""}。`),t1(e,"下载完成后才会生成二维码;下载耗时取决于网络,进度和实际耗时将持续显示。")),await eZ({runner:{onProgress:t.onProgress??eN(e)}})}async function eQ(e,t){return await function(e,t,n=process.platform){var r,o,i;let s,a=(r=e,o=n,s=(i=t)?[["namespace",i.namespace],["project",i.appDir??i.projectPath],["app-key",i.appKey],["host-url",i.hostUrl]].flatMap(([e,t])=>t?[`--${e}=${t}`]:[]):[],"darwin"===o?{command:"open",args:[r,...s.length?["--args",...s]:[]]}:"win32"===o?{command:"cmd",args:["/c","start","",r,...s],windowsVerbatimArguments:!0}:{command:r,args:s});return new Promise((e,t)=>{let n=(0,eh.spawn)(a.command,a.args,{stdio:"ignore",windowsVerbatimArguments:a.windowsVerbatimArguments});n.once("error",t),n.once("spawn",e)})}(e,t),{status:"opened",appPath:e}}async function eX(){let e=function(e=process.env,t=process.platform,n=process.arch,r=e4()){let o=e[ek]?.trim();if(o)return eE().resolve(o);let i=e1({...e,[ek]:""},t,r);if(i)return i;let s=e5(t,n);if(!s)return;let a=e2(e,t),d=tn(a);if(!d||d.platform!==s)return;let l=tp(ti(a,d.activeDeviceAppVersion),d.entry,"device app state entry");return ey().existsSync(l)?l:void 0}();return e?(await function(e,t=process.platform){return"darwin"===t?tg(e):ty(tb(e,t),{rejectOnNonZero:!0}).then(()=>void 0)}(e),{status:"closed",appPath:e}):{status:"skipped",reason:`${ek} is not set and no packaged or cached device app was found`}}async function eZ(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??e4(),i=e3(t),s=t[ek]?.trim();if(s)return{status:"found",appPath:eE().resolve(s),source:"env"};if(!i){let e=e1({...t,[ek]:""},n,o);if(e)return{status:"found",appPath:e,source:"packaged"}}return e0({env:t,platform:n,arch:r,appDir:o,manifest:e.manifest,runner:e.runner})}async function e0(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.manifest??ep;ta(o);let i=e5(n,r);if(!i)return{status:"skipped",reason:`device app download is not supported on ${n}/${r}`};let s=o.packages[i];if(!s)return{status:"skipped",reason:`device app package is not configured for ${i} in CLI ${o.cliVersion}`};let a=e2(t,n),d=tl(o,s);if(!e3(t)){let e=e6(a,o,i,s,d);if(e)return tr(a,d),{status:"found",appPath:e,source:"cache"}}let l=await e8(a,o,i,s,n,e.runner);return tr(a,d),{status:"found",appPath:l,source:"downloaded"}}function e1(e=process.env,t=process.platform,n=e4()){let r=e[ek]?.trim();if(r)return eE().resolve(r);if(!ey().existsSync(n))return;let o=ey().readdirSync(n,{withFileTypes:!0}).find(e=>{var n,r;return n=e,"darwin"===(r=t)?n.isDirectory()&&n.name.endsWith(".app"):"win32"===r?n.isFile()&&n.name.toLowerCase().endsWith(".exe"):n.isFile()&&/\.(appimage|AppImage)$/.test(n.name)});return o?eE().join(n,o.name):void 0}function e2(e=process.env,t=process.platform){let n=e.DBX_DEVICE_APP_CACHE_DIR?.trim();if(n)return eE().resolve(n);if("darwin"===t)return eE().join(ew().homedir(),"Library","Application Support","dbx","device-app");if("win32"===t){let t=e.LOCALAPPDATA?.trim()||eE().join(ew().homedir(),"AppData","Local");return eE().join(t,"dbx","device-app")}return eE().join(ew().homedir(),".local","share","dbx","device-app")}function e4(){return eE().resolve(ex,"../../..","device-app")}function e5(e,t){if(("darwin"===e||"win32"===e)&&("arm64"===t||"x64"===t))return`${e}-${t}`}function e3(e){let t=e.DBX_DEVICE_APP_FORCE_DOWNLOAD?.trim().toLowerCase();return!!(t&&"0"!==t&&"false"!==t)}function e6(e,t,n,r,o){var i,s,a,d,l;let c,u=tn(e);if(!u||u.activeDeviceAppVersion!==o||u.cliVersion!==t.cliVersion||u.platform!==n||!tu(u.sha256,r)||u.entry!==r.entry)return;let p=ti(e,o);if(i=p,s=t,a=n,d=r,l=o,!((c=tt(i))&&c.cliVersion===s.cliVersion&&c.deviceAppVersion===l&&c.entry===d.entry&&c.platform===a&&tu(c.sha256,d)))return;let h=tp(p,r.entry,"device app entry");return ey().existsSync(h)?h:void 0}async function e8(e,t,n,r,o,i={}){td(r);let s=tl(t,r),a=i.now?.()??Date.now(),d=eE().join(e,".tmp");ey().mkdirSync(d,{recursive:!0}),ey().mkdirSync(eE().join(e,eD),{recursive:!0});let l=ey().mkdtempSync(eE().join(d,`${s}-`)),c=eE().join(l,"device-app.zip"),u=eE().join(l,"extract"),p=ti(e,s);try{var h,f,m,g,y,_,b,w;let d,l;if(i.onProgress?.({phase:"download",downloadedBytes:0,...void 0===r.sizeBytes?{}:{totalBytes:r.sizeBytes,percentage:0},elapsedMs:0}),await e7(r.url,c,i.fetch,i.onProgress),r.sha256&&(i.onProgress?.({phase:"install",stage:"verify"}),(d=await to(c))!==tc(r.sha256)))throw Error(`device app sha256 mismatch: expected ${r.sha256}, got ${d}`);ey().mkdirSync(u,{recursive:!0}),i.onProgress?.({phase:"install",stage:"extract"}),await te(c,u,o,i);let v=tp(u,r.entry,"device app package entry");(function(e,t){if(!ey().existsSync(e))throw Error(`device app entry not found after extraction: ${e}`);let n=ey().statSync(e);if("darwin"===t){if(!n.isDirectory()||!e.endsWith(".app"))throw Error(`macOS device app entry must be a .app directory: ${e}`);return}if("win32"===t&&(!n.isFile()||!e.toLowerCase().endsWith(".exe")))throw Error(`Windows device app entry must be an .exe file: ${e}`)})(v,o),function(e,t,n,r,o){let i=tt(e);if(i&&(i.cliVersion!==t.cliVersion||i.deviceAppVersion!==o||i.entry!==r.entry||i.platform!==n||!tu(i.sha256,r)))throw Error(`device app metadata does not match CLI manifest in ${eE().join(e,eS)}`)}(u,t,n,r,s),i.onProgress?.({phase:"install",stage:"install"}),ey().rmSync(p,{recursive:!0,force:!0}),ey().renameSync(u,p),h=p,f=t,m=n,g=r,y=s,_=a,l={name:"Doubao App V2",cliVersion:f.cliVersion,deviceAppVersion:y,entry:g.entry,platform:m,...g.sha256?{sha256:tc(g.sha256)}:{},installedAt:_},tm(eE().join(h,eS),l),b=e,w={activeDeviceAppVersion:s,cliVersion:t.cliVersion,entry:r.entry,platform:n,...r.sha256?{sha256:tc(r.sha256)}:{},installedAt:a},tm(eE().join(b,eP),w);let E=tp(p,r.entry,"device app entry");return i.onProgress?.({phase:"complete",appPath:E}),E}finally{ey().rmSync(l,{recursive:!0,force:!0})}}async function e7(e,n,r=fetch,o){var i,s;let a,d,l,c,u,p,h=new URL(e);if("https:"!==h.protocol&&"http:"!==h.protocol)throw Error(`device app package URL must be http(s): ${e}`);let f=await r(e);if(!f.ok)throw Error(`device app package download failed: HTTP ${f.status} ${f.statusText}`);if(!f.body)throw Error("device app package download failed: empty response body");let m=f.body;await (0,t.pipeline)(eI.Readable.fromWeb(m),(i=f,s=o,a=function(e){if(!e)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}(i.headers.get("content-length")),d=0,l=-1,c=0,u=Date.now(),(p=e=>{if(!s)return;if(a){let t=Math.min(100,Math.floor(d/a*100));if(!e&&100!==t&&t<l+10||t===l)return;l=t;let n=Date.now()-u;s({phase:"download",downloadedBytes:d,totalBytes:a,percentage:t,elapsedMs:n});return}if(!e&&d-c<0x3200000||d===c)return;c=d;let t=Date.now()-u;s({phase:"download",downloadedBytes:d,elapsedMs:t})})(!1),new eI.Transform({transform(e,t,n){d+=e.length,p(!1),n(null,e)},flush(e){p(!0),e()}})),ey().createWriteStream(n))}function e9(e){let t=["B","KB","MB","GB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return 0===r?`${n} ${t[r]}`:`${n.toFixed(1)} ${t[r]}`}async function te(e,t,n,r){let o=r.runCommand??(e=>ty(e,{rejectOnNonZero:!0}).then(()=>void 0));if("darwin"===n)return void await o({command:"ditto",args:["-x","-k",e,t]});if("win32"===n)return void await o({command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",`Expand-Archive -LiteralPath ${th(e)} -DestinationPath ${th(t)} -Force`],windowsVerbatimArguments:!0});throw Error(`device app zip extraction is not supported on ${n}`)}function tt(e){let t=tf(eE().join(e,eS));if(!i(t))return;let n=t.cliVersion,r=t.deviceAppVersion,o=t.entry,s=t.platform,a=t.sha256,d=t.installedAt;if("string"==typeof n&&"string"==typeof r&&"string"==typeof o&&"string"==typeof s&&(void 0===a||"string"==typeof a)&&"number"==typeof d)return{name:"string"==typeof t.name?t.name:void 0,cliVersion:n,deviceAppVersion:r,entry:o,platform:s,..."string"==typeof a?{sha256:a}:{},installedAt:d}}function tn(e){let t=tf(eE().join(e,eP));if(i(t)&&"string"==typeof t.activeDeviceAppVersion&&"string"==typeof t.cliVersion&&"string"==typeof t.entry&&"string"==typeof t.platform&&(void 0===t.sha256||"string"==typeof t.sha256)&&"number"==typeof t.installedAt)return{activeDeviceAppVersion:t.activeDeviceAppVersion,cliVersion:t.cliVersion,entry:t.entry,platform:t.platform,..."string"==typeof t.sha256?{sha256:t.sha256}:{},installedAt:t.installedAt}}function tr(e,t){let n=eE().join(e,eD);if(ey().existsSync(n)){for(let e of ey().readdirSync(n,{withFileTypes:!0}))if(e.isDirectory()&&e.name!==t)try{ey().rmSync(eE().join(n,e.name),{recursive:!0,force:!0})}catch{}}}async function to(e){let n=em().createHash("sha256");return await (0,t.pipeline)(ey().createReadStream(e),n),n.digest("hex")}function ti(e,t){return ts(t),eE().join(e,eD,t)}function ts(e){if(!/^[0-9A-Za-z._+-]+$/.test(e))throw Error(`device app version contains unsupported path characters: ${e}`)}function ta(e){if(1!==e.schemaVersion)throw Error(`unsupported device app manifest schemaVersion: ${e.schemaVersion}`);if(!e.cliVersion.trim())throw Error("device app manifest cliVersion is required");if(!e.deviceAppVersion.trim())throw Error("device app manifest deviceAppVersion is required");ts(e.deviceAppVersion)}function td(e){if(!e.url||!e.entry)throw Error("device app package requires url and entry");if(void 0!==e.version){if(!e.version.trim())throw Error("device app package version must not be empty");ts(e.version)}if(e.sha256&&!/^[0-9a-fA-F]{64}$/.test(e.sha256))throw Error(`device app package sha256 must be 64 hex characters: ${e.sha256}`);if(void 0!==e.sizeBytes&&(!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0))throw Error(`device app package sizeBytes must be a positive integer: ${e.sizeBytes}`);if(eE().isAbsolute(e.entry)||e.entry.split(/[\\/]+/).includes(".."))throw Error(`device app package entry must be a relative path inside the zip: ${e.entry}`)}function tl(e,t){let n=t.version??e.deviceAppVersion;if(!n.trim())throw Error("device app package version must not be empty");return ts(n),n}function tc(e){return e.toLowerCase()}function tu(e,t){return!t.sha256||e===tc(t.sha256)}function tp(e,t,n){if(eE().isAbsolute(t))throw Error(`${n} must be relative: ${t}`);let r=eE().resolve(e),o=eE().resolve(e,t);if(o!==r&&!o.startsWith(`${r}${eE().sep}`))throw Error(`${n} escapes target directory: ${t}`);return o}function th(e){return`'${e.replace(/'/g,"''")}'`}function tf(e){try{return JSON.parse(ey().readFileSync(e,"utf8"))}catch{return}}function tm(e,t){ey().mkdirSync(eE().dirname(e),{recursive:!0}),ey().writeFileSync(e,`${JSON.stringify(t,null,2)}
13
+ `,"utf8")}async function tg(e){let t=function(e){if(!e.endsWith(".app"))return;let t=function(e){let t=eE().join(e,"Contents","Info.plist");if(!ey().existsSync(t))return;let n=ey().readFileSync(t,"utf8").match(/<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/);return n?.[1]}(e)??eE().basename(e,".app");return eE().join(e,"Contents","MacOS",t)}(e);await ty(tb(e,"darwin"),{rejectOnNonZero:!1}),!t||await t_(t)&&await ty({command:"pkill",args:["-f",tw(t)]},{rejectOnNonZero:!1})}function ty(e,t){return new Promise((n,r)=>{let o=(0,eh.spawn)(e.command,e.args,{stdio:"ignore",windowsVerbatimArguments:e.windowsVerbatimArguments});o.once("error",r),o.once("exit",o=>{let i=o??0;0!==i&&t.rejectOnNonZero?r(Error(`${e.command} exited with code ${i}`)):n(i)})})}async function t_(e){return 0===await ty({command:"pgrep",args:["-f",tw(e)]},{rejectOnNonZero:!1})}function tb(e,t){return"darwin"===t?{command:"osascript",args:["-e",`tell application (POSIX file "${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}" as alias) to quit`]}:"win32"===t?{command:"cmd",args:["/c","taskkill","/IM",eE().basename(e),"/T"],windowsVerbatimArguments:!0}:{command:"pkill",args:["-f",e]}}function tw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function tv(e,t,n){let r=await e.client.call(n);if(!r.length)return void t1(e.output,`no ${t}s found`);for(let n of r)t1(e.output,`- ${tZ(t,n)}`)}async function tE(e,t){if(t.length>0)throw Error("sessions does not accept arguments");let n=await tD(e,"sessions"),{session:r}=n;try{let t=await r.getConnectedClients();if(0===t.length)throw new L("DEVICE_NOT_CONNECTED","no debug device is connected");let n=t.flatMap(e=>e.sessions.filter(V).map(t=>({clientId:e.device.clientId,sessionId:t.sessionId,url:t.url}))).sort((e,t)=>e.clientId-t.clientId||t.sessionId-e.sessionId);if(0===n.length)throw new L("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");let o=r.getRuntimeInspectionTarget?await r.getRuntimeInspectionTarget().catch(()=>null):null,i=tk(e),s=e.activeClientId??(1===t.length?t[0]?.device.clientId:void 0),a=void 0===s?void 0:n.find(e=>e.clientId===s);for(let t of n){let n=[tS(t,o)?"electron":void 0,"fixed"===i.kind&&tS(t,i.target)?"cli":void 0,tS(t,a)?"latest":void 0].filter(e=>void 0!==e);t1(e.output,`${O(t)}${n.length?` ${n.map(e=>`[${e}]`).join(" ")}`:""} ${t.url||"unknown"}`)}}finally{n.owned&&await r.stop().catch(()=>void 0)}}async function tI(e,t){if(1!==t.length)throw Error("use-session requires @<clientId>:<sessionId> or latest");if(t[0]?.toLowerCase()==="latest"){e.runtimeInspectionTargetPolicy={kind:"latest"},t1(e.output,l.bold.blueBright(`CLI 调试目标已恢复为 latest${void 0===e.activeClientId?"":`(client ${e.activeClientId} 内最新活跃 Lynx session)`};不会切换 Electron。`));return}let n=q(t[0]??""),r=await tD(e,"use-session"),{session:o}=r;try{let t=await N(o,{activeClientId:e.activeClientId,explicitTarget:n,signal:e.signal});e.runtimeInspectionTargetPolicy={kind:"fixed",target:{clientId:t.clientId,sessionId:t.sessionId}},t1(e.output,l.bold.blueBright(`CLI 调试目标已固定为 ${O(t)}(${t.url||"unknown"});不会切换 Electron。`))}finally{r.owned&&await o.stop().catch(()=>void 0)}}async function tT(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{limit:{type:"string"},"timeout-seconds":{type:"string"},"include-stack-traces":{type:"boolean"},target:{type:"string"}}}),r=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>100)throw Error("--limit must be an integer between 1 and 100");return t}(n.values.limit),o=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout-seconds must be a positive number");return Math.round(1e3*t)}(n.values["timeout-seconds"]),s=await tD(e,"get-console"),{session:a}=s;try{let t=await tP(e,a,n.values.target);t1(e.output,l.bold.blueBright(`正在监听 client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})的新日志;按 Ctrl+C 停止监听。`));let s=await et(a,t,{...void 0===r?{}:{limit:r},...void 0===o?{}:{timeoutMs:o},signal:e.signal,onTargetChange(n){t1(e.output,l.bold.blueBright(`提示:Electron 已切换到 client ${n.clientId}、session ${n.sessionId}(${n.url||"unknown"});当前 CLI 仍监听 client ${t.clientId}、session ${t.sessionId},不会自动跟随 Electron。`))},onMessage(t){t1(e.output,function(e,t={}){var n;let r=e.args.map(ei).join(" "),o=t.includeStackTraces||"error"===e.type?(n=e.stackTrace,i(n)&&Array.isArray(n.callFrames)?n.callFrames.filter(i).map(e=>{let t="string"==typeof e.url?e.url:"",n="number"==typeof e.lineNumber?e.lineNumber:"unknown",r="number"==typeof e.columnNumber?e.columnNumber:"unknown";return` at ${t}:${n}:${r}`}).join("\n"):""):"";return`[${e.type}/${e.thread}] ${r}${o?`
14
+ ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});t1(e.output,`日志监听已停止,共 ${s.count} 条。`)}finally{s.owned&&await a.stop().catch(()=>void 0)}}async function tA(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{output:{type:"string",short:"o"},target:{type:"string"}}}),o=await tD(e,"take-screenshot"),{session:i}=o;try{let t=await tP(e,i,r.values.target),o=await en(i,t,{activeCapture:!e.manageDeviceApp}),s=eE().resolve(r.values.output??`screenshot-${Date.now()}.jpeg`);await ey().promises.writeFile(s,Buffer.from(o.data,"base64")),n?t2(e.output,{ok:!0,command:"take-screenshot",target:t,output:s,format:o.format,source:o.source,width:o.width,height:o.height,byteLength:o.byteLength}):t1(e.output,`截图已保存:${s}(${o.width}\xd7${o.height},client ${t.clientId}、session ${t.sessionId},${t.url||"unknown"};${e.manageDeviceApp?"范围跟随 Electron 当前 mode":"由设备按当前截图 mode 生成"})`)}finally{o.owned&&await i.stop().catch(()=>void 0)}}async function tC(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!1,options:{depth:{type:"string"},target:{type:"string"}}}),o=function(e){if(void 0===e)return -1;let t=Number(e);if(!Number.isSafeInteger(t)||t<-1)throw Error("--depth must be -1 or a non-negative integer");return t}(r.values.depth),i=await tD(e,"get-page-tree"),{session:s}=i;try{let t=await tP(e,s,r.values.target),i=await U(s,t,{depth:o});if(n)t2(e.output,{ok:!0,command:"get-page-tree",...i});else{let n,r;t1(e.output,`DOM tree: client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})`),t1(e.output,(n=[],(r=(e,t,o)=>{n.push(`${t}${o}${function(e){if(W(e))return`${e.ref} #text ${Z(e.nodeValue)}`;let t=(e.localName||e.nodeName).toLowerCase();if(t.startsWith("#"))return`${e.ref} ${t}`;let n=Object.entries(e.attributes).map(([e,t])=>`${e}=${Z(t,80)}`).join(" "),r=e.text||e.children.filter(W).map(e=>e.nodeValue).join("");return[e.ref,`<${t}${n?` ${n}`:""}>`,r?Z(r,120):""].filter(Boolean).join(" ")}(e)}`);let i=e.children.filter(e=>!W(e));i.forEach((e,n)=>{r(e,`${t}${o?"└─ "===o?" ":"│ ":""}`,n===i.length-1?"└─ ":"├─ ")})})(i.root,"",""),i.truncated&&n.push(`… tree truncated after ${i.nodeCount} nodes`),n.join("\n"))),t1(e.output,`共 ${i.nodeCount} 个节点${i.truncated?"(已截断)":""}。`)}}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tj(e,t,n=!1){let r=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{properties:{type:"string"}}}),o=r.positionals[0];if(!o)throw new L("INVALID_NODE_REF","node-ref is required; run get-page-tree and pass @<clientId>:<sessionId>:<nodeId>");if(r.positionals.length>1)throw Error("get-computed-style accepts exactly one node-ref");let i=function(e){let t=/^@([1-9]\d*):([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new L("INVALID_NODE_REF",`invalid node ref "${e}"; expected @<clientId>:<sessionId>:<nodeId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2]),nodeId:Number(t[3])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId)||!Number.isSafeInteger(n.nodeId))throw new L("INVALID_NODE_REF",`invalid node ref "${e}"; every id must be a safe integer`);return n}(o),s=function(e){if(void 0===e)return[];let t=e.split(",").map(e=>e.trim());if(0===t.length||t.some(e=>!/^-{0,2}[a-z][a-z0-9-]*$/i.test(e)))throw Error("--properties must be a comma-separated list of CSS property names");return[...new Set(t.map(e=>e.toLowerCase()))]}(r.values.properties),a=await tD(e,"get-computed-style"),{session:d}=a;try{let t=await B(d,i),r=await F(d,t,i,s);if(n)t2(e.output,{ok:!0,command:"get-computed-style",...r});else if(t1(e.output,`${r.nodeRef} computed style(client ${t.clientId}、session ${t.sessionId})`),0===r.properties.length)t1(e.output,"没有匹配的 computed style 属性。");else{let t=Math.max(...r.properties.map(e=>e.name.length));for(let n of r.properties)t1(e.output,` ${n.name.padEnd(t)} ${n.value}`)}}finally{a.owned&&await d.stop().catch(()=>void 0)}}function tk(e){return e.runtimeInspectionTargetPolicy??{kind:"latest"}}function tS(e,t){return null!=e&&null!=t&&e.clientId===t.clientId&&e.sessionId===t.sessionId}function tP(e,t,n){return N(t,{activeClientId:e.activeClientId,policy:tk(e),...void 0===n?{}:{explicitTarget:q(n)},signal:e.signal})}async function tD(e,t){if(e.runtimeInspectionSession)return{owned:!1,session:await e.runtimeInspectionSession};let n=e.createRuntimeInspectionSession??R;return{owned:!0,session:await n({namespace:e.runtime.getState().namespace,nodeIdPrefix:`dev-shell-${t}`})}}async function tx(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{"device-id":{type:"string"}}}),r=n.positionals[0]??await tR(e,"page",c.discoverPages);if(!r)throw Error("page url is required");let o=n.values["device-id"]??e.activeDeviceId;t1(e.output,`debug: page open request ${t0({url:r,deviceId:o})}`);let i=u("page",await e.client.call(c.openPageUrl,{url:r,deviceId:o}));t1(e.output,`page opened: ${r}`),t1(e.output,`status: ${tL(i)}`)}async function t$(e,t){let n=(0,eA.parseArgs)({args:t,allowPositionals:!0,options:{data:{type:"string"},"bot-id":{type:"string"},"device-id":{type:"string"}}}),r=n.positionals[0]??await tR(e,"widget",c.discoverWidgets);if(!r)throw Error("widget id is required");let o=h(n.values.data,"--data"),i=n.values["device-id"]??e.activeDeviceId;t1(e.output,`debug: widget push request ${t0({widgetId:r,data:o,botId:n.values["bot-id"],deviceId:i})}`);let s=u("widget",await e.client.call(c.pushWidget,{widgetId:r,widgetData:o,botId:n.values["bot-id"],deviceId:i}));t1(e.output,`widget pushed: ${r}`),t1(e.output,`status: ${tL(s)}`)}function tL(e){if(!e.ok)return"failed";let t=function(e){if(!e||"object"!=typeof e)return;let t=e.data;if(!t||"object"!=typeof t)return;let n=t.msg;return"string"==typeof n?n:void 0}(e.result);return"string"==typeof t&&t.trim()?t:"ok"}async function tR(e,t,n){let r=await e.client.call(n);if(r.length)return e.selectItem(t,r,e.output)}function tN(e,t){return t.map(t=>{let n=tX(e,t);return n?{label:tZ(e,t),value:n}:void 0}).filter(e=>!!e)}async function tO(e){var t,o;let i,s,a,d,l=e.timeoutMs??6e4;if(!e.hostUrl||!e.appKey)return{ok:!1,status:"skipped",timeoutMs:l,error:"无法生成二维码,缺少 hostUrl 或 appKey。"};let u=e.hostUrl,p=e.appKey,h=(t=e.namespace,o=l,s=new g(t,{nodeId:`dev-auth-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3}),a=!1,d=new Promise(e=>{i=e}),s.createService({name:`devAuthListener${process.pid}`,events:{"connection.newclient"(e){var t;a||(a=!0,i((t=e.params)&&"object"==typeof t?{scope:"string"==typeof t.scope?t.scope:void 0,type:"string"==typeof t.type?t.type:void 0,clientId:"number"==typeof t.clientId?t.clientId:void 0,deviceId:tY(t),app:"string"==typeof t.app?t.app:void 0}:{}))}}}),{start:()=>s.start(),stop:()=>s.stop(),wait:(e,t=o)=>{var n,r,i;return n=d,r=t,i=e,new Promise((e,t)=>{let o=()=>{clearTimeout(s),t(i?.reason instanceof Error?i.reason:new tH)},s=setTimeout(()=>{i?.removeEventListener("abort",o),t(new tV(r))},r);i?.aborted?o():(i?.addEventListener("abort",o,{once:!0}),n.then(t=>{clearTimeout(s),i?.removeEventListener("abort",o),e(t)},e=>{clearTimeout(s),i?.removeEventListener("abort",o),t(e)}))})},async findExistingClient(){let e=await tK(()=>s.call("devtoolConnection.getConnectedClients"),2e3).catch(()=>[]);return function(e){if(!e||"object"!=typeof e)return;let t=e.device,n=t?.info,r="number"==typeof t?.clientId?t.clientId:void 0;return{scope:"all",type:String(n?.network??"").toLowerCase().includes("wifi")?"wifi":"usb",...void 0===r?{}:{clientId:r},deviceId:tY({client:e}),app:"string"==typeof n?.App?n.App:""}}(Array.isArray(e)?e[0]:void 0)},async awaitDirectDebugReady(e){let t=Math.min(o,2500);try{return await s.call(c.awaitDirectDebugReady,{clientId:e,timeoutMs:t},{timeout:t+1e3})}catch{return!1}},waitForInstallResult:(e,t,n,r)=>{var o,i;return o=s.call(c.awaitDeviceInstallResult,{clientId:e,packageName:t,timeoutMs:n},{timeout:n+1e3}),(i=r)?new Promise((e,t)=>{let n=()=>{t(i.reason instanceof Error?i.reason:new tH)};if(i.aborted){o.catch(()=>void 0),n();return}i.addEventListener("abort",n,{once:!0}),o.then(t=>{i.removeEventListener("abort",n),e(t)},e=>{i.removeEventListener("abort",n),t(e)})}):o}}),f={},m="connection";await h.start();try{let t;e.signal?.throwIfAborted();let o=await h.findExistingClient(),i=o?.clientId!==void 0&&await h.awaitDirectDebugReady(o.clientId);if(!i){let o,i,s;t=await tq(f,()=>(0,eC.Ph)(function(e,t,o={}){let i=tM(o.settings);return{hostUrl:e,appKey:t,...void 0===o.versionTag?{}:{versionTag:o.versionTag},isSigned:!1,appletType:0,baseApiUrl:n(),authOptions:r(),...!1===i.defaultDebugTagState?{defaultDebugTagState:!1}:{},...!i.usb&&o.wifiConnectUrl?{wifiConnectUrl:o.wifiConnectUrl}:{}}}(u,p,{versionTag:e.versionTag,settings:e.settings,wifiConnectUrl:e.wifiConnectUrl}))),t1(e.output,""),t1(e.output,"使用豆包 App 扫码连接调试设备."),t1(e.output,`二维码创建成功,请在 ${(o=Math.max(1,Math.round(l/1e3)),i=Math.floor(o/60),s=o%60,i>0?`${i}m ${s}s`:`${s}s`)} 前扫码; 超时可在真机模式执行 \`qr\` 创建新二维码.`),t1(e.output,""),await e.onQRCodeReady?.(t.qrCodeValue,t.debugToken),e.signal?.throwIfAborted()}let s=Date.now()+l;t1(e.output,`等待设备连接 (${l/1e3}s timeout)...`);let a=i?o:await h.wait(e.signal,tz(s));if(void 0===a.clientId)throw Error("连接的设备缺少 clientId");m="install";let d=await h.waitForInstallResult(a.clientId,p,tz(s),e.signal);if(!d)throw new tV(l);if(!d.success)return{ok:!1,status:"skipped",timeoutMs:l,waitingFor:m,client:a,error:d.message||"安装 AIPackage 失败,请检查网络环境并关注客户端提示"};return{ok:!0,status:"connected",timeoutMs:l,...t?{qrCodeValue:t.qrCodeValue,debugToken:t.debugToken,encryptedDebugPayload:t.encryptedDebugPayload}:{},client:a}}catch(o){let t=o instanceof tV,n=o instanceof tH||!!e.signal?.aborted,r=function(e){if(e&&"object"==typeof e)return tU(e,"logId")??tU(e,"log_id")}(o)??f.logId;return{ok:!1,status:n?"cancelled":t?"timeout":"skipped",timeoutMs:l,waitingFor:m,...r?{logId:r}:{},error:o instanceof Error?o.message:String(o)}}finally{await h.stop()}}async function tq(e,t){let n=globalThis.fetch;globalThis.fetch=async(t,r)=>{var o;let i,s=await n((i=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return new URL(e.toString());return new URL(e.url)}catch{return}}(o=t))&&i.pathname.startsWith("/developer/check_api/apps/")&&i.pathname.endsWith("/debug/ticket")?(i.pathname=i.pathname.replace(/^\/developer\/check_api\//,"/app_developer/check_api/"),"string"==typeof o)?i.toString():o instanceof URL?i:new Request(i,o):o,r);return await tB(e,s),s};try{return await t()}finally{globalThis.fetch=n}}function tM(e){return{defaultDebugTagState:e?.defaultDebugTagState??!0,usb:e?.usb??!0}}async function tB(e,t){let n=t.headers.get("x-tt-logid");if(n){e.logId=n;return}try{let n=await t.clone().text();if(!n)return;let r=JSON.parse(n),o=tU(r,"log_id")??tU(r,"logId");o&&(e.logId=o)}catch{}}function tU(e,t){if(!e||"object"!=typeof e)return;let n=e[t];return"string"==typeof n&&n?n:void 0}function tF(e){return e.replace(/\s*[\[((]log_id:\s*[^\]))]+[\]))]/gi,"").trim()}class tV extends Error{constructor(e){super(`real-device auth timed out after ${e}ms`),this.name="RealDeviceAuthTimeoutError"}}class tH extends Error{constructor(){super("real-device auth cancelled"),this.name="RealDeviceAuthCancelledError"}}function tz(e){return Math.max(0,e-Date.now())}async function tK(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(Date.now()>=n)throw e;await new Promise(e=>{setTimeout(e,100)})}}function tY(e){let t=e.client?.device,n=t?.info;return n?.usbDeviceId||t?.xdbId||n?.did||n?.debugRouterId}async function tJ(e,t){let n=eE().resolve(t);if(".png"!==eE().extname(n).toLowerCase())throw Error("QR file must use the .png extension");return ey().mkdirSync(eE().dirname(n),{recursive:!0}),await ej.toFile(n,e,{errorCorrectionLevel:"L",margin:4,type:"png"}),n}function tG(e=ew().tmpdir()){let t;try{t=ey().readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of t)if(/^dbx-real-device-qr-.*\.(?:png|svg)$/i.test(n.name)&&(n.isFile()||n.isSymbolicLink()))try{ey().unlinkSync(eE().join(e,n.name))}catch{}}async function tW(e,t,n,r=process.stderr,o){let i,s,a;if(n){let t=await tJ(e,n);t1(r,`二维码图片已导出至:${t}`)}let d=await ej.toBuffer(e,{errorCorrectionLevel:"L",margin:4,type:"png"}),l=o?`doubaoapp://local_debug?short_token=${o}`:void 0,c=l?await ej.toBuffer(l,{errorCorrectionLevel:"L",margin:4,type:"png"}):void 0,u=em().randomBytes(18).toString("hex"),p=`/${u}/`,h=new Set,f=!1,m=new Promise(e=>{s=e}),g=()=>{clearTimeout(i),i=void 0,f||s()},y=(0,e_.createServer)((e,t)=>{let n=e.url?.split("?",1)[0];if(t.setHeader("Cache-Control","no-store, no-cache, must-revalidate, max-age=0"),t.setHeader("Expires","0"),t.setHeader("Pragma","no-cache"),"GET"===e.method&&n===p){var r;t.writeHead(200,{"Content-Security-Policy":"default-src 'none'; img-src 'self'; connect-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'","Content-Type":"text/html; charset=utf-8"}),t.end((r=!!c,`<!doctype html>
15
15
  <html lang="zh-CN">
16
16
  <head>
17
17
  <meta charset="utf-8">
@@ -41,7 +41,7 @@ ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});t1(e.ou
41
41
  });
42
42
  </script>
43
43
  </body>
44
- </html>`));return}if("GET"===e.method&&n===`${p}qr.png`){t.writeHead(200,{"Content-Type":"image/png"}),t.end(d);return}if("GET"===e.method&&n===`${p}qr-modern.png`){if(!c){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found");return}t.writeHead(200,{"Content-Type":"image/png"}),t.end(c);return}if("GET"===e.method&&n===`${p}events`){clearTimeout(i),i=void 0,t.writeHead(200,{Connection:"keep-alive","Content-Type":"text/event-stream"}),t.write("retry: 250\nevent: ready\ndata: ready\n\n"),h.add(t),t.once("close",()=>{h.delete(t),f||0!==h.size||(i=setTimeout(g,750))});return}if("POST"===e.method&&n===`${p}closed`){e.resume(),t.writeHead(204).end(),g();return}t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found")});await new Promise((e,t)=>{y.once("error",t),y.listen(0,"127.0.0.1",()=>{y.removeListener("error",t),e()})});let _=y.address();if(!_||"string"==typeof _)throw await tQ(y),Error("failed to start QR code viewer");let b=`http://127.0.0.1:${_.port}${p}`,w=()=>a??=(async()=>{f=!0,clearTimeout(i);try{for(let e of h)try{e.destroyed||e.writableEnded||(e.once("error",()=>void 0),e.end("event: close\ndata: close\n\n"))}catch{}}finally{h.clear(),await tQ(y)}})();try{await t(b),t1(r,"已在默认浏览器打开二维码。")}catch(e){throw await w(),Error(`二维码页面未能自动打开:${t4(e)}`)}return{closed:m,close:w}}function tQ(e){return e.listening?new Promise(t=>{e.close(()=>t()),e.closeAllConnections()}):Promise.resolve()}function tX(e){if(e&&"object"==typeof e)for(let t of["id","pageId","page_id","widgetId","widget_id","versionTag","version_tag","name","path"]){let n=e[t];if("string"==typeof n&&n.trim())return n}}function tZ(e){let t=tX(e);if(!e||"object"!=typeof e)return t??String(e);let n="";return"string"==typeof e.title?n=e.title:"string"==typeof e.name&&(n=e.name),[t,n&&n!==t?n:""].filter(Boolean).join(" ")}function t0(e){return JSON.stringify(Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).map(([e,t])=>[e,"data"===e?p(t):t])))}function t1(e,t=""){e.write(`${t}
44
+ </html>`));return}if("GET"===e.method&&n===`${p}qr.png`){t.writeHead(200,{"Content-Type":"image/png"}),t.end(d);return}if("GET"===e.method&&n===`${p}qr-modern.png`){if(!c){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found");return}t.writeHead(200,{"Content-Type":"image/png"}),t.end(c);return}if("GET"===e.method&&n===`${p}events`){clearTimeout(i),i=void 0,t.writeHead(200,{Connection:"keep-alive","Content-Type":"text/event-stream"}),t.write("retry: 250\nevent: ready\ndata: ready\n\n"),h.add(t),t.once("close",()=>{h.delete(t),f||0!==h.size||(i=setTimeout(g,750))});return}if("POST"===e.method&&n===`${p}closed`){e.resume(),t.writeHead(204).end(),g();return}t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found")});await new Promise((e,t)=>{y.once("error",t),y.listen(0,"127.0.0.1",()=>{y.removeListener("error",t),e()})});let _=y.address();if(!_||"string"==typeof _)throw await tQ(y),Error("failed to start QR code viewer");let b=`http://127.0.0.1:${_.port}${p}`,w=()=>a??=(async()=>{f=!0,clearTimeout(i);try{for(let e of h)try{e.destroyed||e.writableEnded||(e.once("error",()=>void 0),e.end("event: close\ndata: close\n\n"))}catch{}}finally{h.clear(),await tQ(y)}})();try{await t(b),t1(r,"已在默认浏览器打开二维码。")}catch(e){throw await w(),Error(`二维码页面未能自动打开:${t4(e)}`)}return{closed:m,close:w}}function tQ(e){return e.listening?new Promise(t=>{e.close(()=>t()),e.closeAllConnections()}):Promise.resolve()}function tX(e,t){if("page"!==e){if(!t||"object"!=typeof t)return;for(let e of["id","pageId","page_id","widgetId","widget_id","versionTag","version_tag","name","path"]){let n=t[e];if("string"==typeof n&&n.trim())return n}return}if(!t||"object"!=typeof t)return;let n=t.path;return"string"==typeof n&&n.trim()?n:void 0}function tZ(e,t){let n=tX(e,t);if(!t||"object"!=typeof t)return n??String(t);let r="";return"string"==typeof t.title?r=t.title:"string"==typeof t.name&&(r=t.name),[n,r&&r!==n?r:""].filter(Boolean).join(" ")}function t0(e){return JSON.stringify(Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).map(([e,t])=>[e,"data"===e?p(t):t])))}function t1(e,t=""){e.write(`${t}
45
45
  `)}function t2(e,t){t1(e,JSON.stringify(t))}function t4(e){return e instanceof Error?e.message:String(e)}function t5(){return new s("dev").description("启动 dev 调试控制台(Web 模拟器、真机调试、页面和卡片推送)").option("--project-path <path>","dbx 项目路径,状态数据会写入该目录下的 .dbx",".").option("--mcp-endpoint <url>","临时覆盖 manifest.mcp_server.end_point;优先级高于环境变量和 manifest").option("--manifest <path>","manifest.yaml 路径;相对路径按 --project-path 解析,默认按项目布局自动解析").option("--skill <path>","运行态 Skill 目录或 SKILL.md 路径;相对路径按 --project-path 解析,默认按项目布局自动解析").option("--verbose","输出 dev service 生命周期日志",!1).addOption(new a("--manifest-path <path>","本地调试使用的 simulator manifest 文件路径").hideHelp()).addOption(new a("--skill-path <path>","本地调试使用的 simulator skill 文件路径").hideHelp()).action(async(e,t)=>d(t,t=>t3(t,e)))}async function t3(e,t){let n,r,o,i,s;e.json&&e.error("dbx dev starts an interactive console and does not support --json");let a=t7(),d=(0,ev.resolve)(t.projectPath),{businessTemplatesPath:l,simulatorManifestPath:c,simulatorSkillPath:u,warnings:p}=w({projectPath:d,manifest:t.manifest,skill:t.skill,manifestPath:t.manifestPath,skillPath:t.skillPath}),h=[...p];l&&await v(l);let f=c,m=!1;if(f){let e=await I(f);h.push(...e.warnings),m=e.validated,e.usable?(n=e.appId,r=e.manifest):f=void 0}let g=await T(process.env,t.mcpEndpoint,f,r),_=j(r),b=C(d).frontendDirectory,S=new eI.PassThrough,P=process.stdin,D=new AbortController,x=y({projectPath:d,appDir:b,installSignalHandlers:!0,signal:D.signal,verbose:t.verbose,devOptions:k({appId:n,mcpEndpoint:g,mcpHeaders:_,simulatorBusinessTemplatesPath:l,simulatorManifestPath:f,simulatorSkillPath:u,openBrowser:e=>{o=E(e)},printLogs:a?t.verbose:void 0,onLog:a&&!t.verbose?e=>{("warn"===e.level||"error"===e.level)&&S.write(`${"error"===e.level?"error:":"⚠"} ${e.message}
46
46
  `)}:void 0,onProgress:a?({percentage:e})=>s?.(e):void 0})}).then(e=>(i=e,s?.(1),e)),$=A({manifestReady:m,mcpEndpointSet:!!g,warnings:h});if(!a){let t=await x;$&&e.warn($,{style:"label"});let n=t.getState();e.log(`Web 模拟器: ${n.webDebuggerUrl??o??"-"}`),e.log(`pid: ${n.pid??process.pid}`),e.log("stop: Ctrl+C or kill the process"),await t.stopped,t8()}$&&S.write(`⚠ ${$}
47
47
  `);try{let{runInkDevShell:e}=await import("./dev-shell.js");await e({createSession:(e,t,r)=>{S.pipe(e);let s=x.then(n=>{if("running"===n.getState().status)return eq({projectPath:d,appDir:b,runtime:t9(n,d,()=>o),output:e,onDeviceAppSetupProgress:r,selectItem:t})});return Promise.resolve(t6({session:s,stopped:x.then(e=>e.stopped),subscribe:e=>{let t,n=!1;return s.then(r=>{n||(t=r?.subscribe(e))}).catch(()=>void 0),()=>{n=!0,t?.()}},close:async()=>{D.abort(),await x.then(e=>e.stop()).catch(()=>void 0),await s.then(e=>e?.close()).catch(()=>void 0)},returnToRoot:async()=>{let e=await s.catch(()=>void 0);await e?.returnToRoot()},handleClientDisconnected:async()=>{let e=await s.catch(()=>void 0);await e?.handleClientDisconnected()},getState:()=>i?.getState()??{projectPath:d,appDir:b??d,appId:n,namespace:"",session_dir:"",status:"starting",created_at:0,updated_at:0}}))},subscribeCompileProgress:e=>(s=e,()=>{s===e&&(s=void 0)}),stdin:P,toChoices:tN})}finally{D.abort(),await x.then(e=>e.stop()).catch(()=>void 0),S.destroy()}t8()}function t6(e){let t,n;return e.session.then(e=>{t=e},()=>void 0),{stopped:e.stopped,cancelActiveCommand:()=>n?.phase!=="waiting"||n.cancelled?t?.cancelActiveCommand()??!1:(n.cancelled=!0,n.resolveCancelled("continue"),!0),close:e.close,subscribe:e.subscribe,execute(r){let o,i=new Promise(e=>{o=e}),s={cancelled:!1,phase:"waiting",resolveCancelled:o};return n=s,Promise.race([e.session.then(e=>(t=e,s.cancelled)?"continue":(s.phase="running",e?.execute(r)??"continue")),i]).finally(()=>{n===s&&(n=void 0)})},returnToRoot:e.returnToRoot,handleClientDisconnected:e.handleClientDisconnected,getState:()=>t?.getState()??e.getState()}}function t8(){process.exit(process.exitCode??0)}function t7(e=process.stdin,t=process.stderr){return!!(e.isTTY&&t.isTTY)}function t9(e,t,n){return{stopped:e.stopped,stop:()=>e.stop(),getState(){let r=e.getState();return{...r,projectPath:t,webDebuggerUrl:r.webDebuggerUrl??n()}}}}export{eL as DEV_SHELL_DEVICE_HELP_ITEMS,e$ as DEV_SHELL_HELP_ITEMS,S as dev_namespaceObject,eR as formatDeviceAppSetupStatus};