@heycys/gallery 0.2.1 → 0.2.2

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 (169) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/editor/page/annotate/index.mjs +3 -2
  3. package/browser/editor/page/board/index.mjs +2 -1
  4. package/browser/editor/page/board/settings.mjs +2 -1
  5. package/browser/editor/page/core.mjs +3 -2
  6. package/browser/editor/page/custom-page.mjs +4 -3
  7. package/browser/editor/page/editor.mjs +9 -5
  8. package/browser/editor/page/emoji-picker/support.mjs +3 -2
  9. package/browser/editor/page/links/index.mjs +1 -12
  10. package/browser/editor/page/links/pages.mjs +3 -2
  11. package/browser/editor/page/outline/folds.mjs +3 -0
  12. package/browser/editor/page/post.mjs +2 -1
  13. package/browser/editor/page/present-links.mjs +4 -3
  14. package/browser/editor/page/present-shell.mjs +3 -58
  15. package/browser/editor/page/session.mjs +3 -37
  16. package/browser/editor/page/storage.mjs +5 -5
  17. package/browser/shared/component-catalog.mjs +2 -2
  18. package/browser/shared/drafts.mjs +26 -51
  19. package/browser/shared/emoji/icon-value.mjs +2 -1
  20. package/browser/shared/extension-manifest.mjs +90 -0
  21. package/browser/shared/extensions.mjs +26 -16
  22. package/browser/shared/http.mjs +1 -1
  23. package/browser/shared/i18n/en.mjs +46 -15
  24. package/browser/shared/media.mjs +2 -1
  25. package/browser/shared/outline.mjs +11 -51
  26. package/browser/shared/page-address.mjs +8 -15
  27. package/browser/shared/paths.mjs +2 -1
  28. package/browser/shared/preferences.mjs +3 -1
  29. package/browser/shared/preview-server.mjs +51 -63
  30. package/browser/shared/service-location.mjs +18 -0
  31. package/browser/shared/session.mjs +3 -6
  32. package/browser/shared/workspace-address.mjs +19 -0
  33. package/browser/shared/workspace-columns.mjs +1 -2
  34. package/browser/shared/workspace-registry.mjs +6 -40
  35. package/browser/shared/workspace.mjs +3 -6
  36. package/browser/shared/writing-preferences.mjs +6 -4
  37. package/dist/{chunk-BYSF5UMM.mjs → chunk-236JJXWY.mjs} +2 -2
  38. package/dist/{chunk-3A5I2GJK.mjs → chunk-2KAVXMKG.mjs} +1 -1
  39. package/dist/chunk-2T4PZQEP.mjs +2 -0
  40. package/dist/{chunk-SAHS56QM.mjs → chunk-3SKOU6OZ.mjs} +1 -1
  41. package/dist/{chunk-S2Y7VI4H.mjs → chunk-3XZOA7AH.mjs} +2 -2
  42. package/dist/{chunk-MKTX5PGV.mjs → chunk-43B75J5T.mjs} +1 -1
  43. package/dist/{chunk-VKSRM7EY.mjs → chunk-4B2TB5K2.mjs} +1 -1
  44. package/dist/{chunk-LV24RY2E.mjs → chunk-4K5KC6V2.mjs} +1 -1
  45. package/dist/{chunk-SOD23RGL.mjs → chunk-4KUO7R2M.mjs} +8 -8
  46. package/dist/chunk-4SNV4HA5.mjs +2 -0
  47. package/dist/chunk-53XDTHTG.mjs +4 -0
  48. package/dist/chunk-5XV3YYLG.mjs +2 -0
  49. package/dist/{chunk-VNUWREXU.mjs → chunk-65NTKF4N.mjs} +1 -1
  50. package/dist/chunk-6GV3CBB2.mjs +2 -0
  51. package/dist/{chunk-DH6GMDNN.mjs → chunk-6L6V7YR2.mjs} +1 -1
  52. package/dist/{chunk-TOE6DPLH.mjs → chunk-6NLXUKAY.mjs} +1 -1
  53. package/dist/chunk-6Q7ASAXJ.mjs +3 -0
  54. package/dist/{chunk-ZCP7BTOZ.mjs → chunk-6QBHU4DF.mjs} +1 -1
  55. package/dist/{chunk-QXVNUASA.mjs → chunk-6QWQXHAV.mjs} +1 -1
  56. package/dist/chunk-6XD6U3QA.mjs +5 -0
  57. package/dist/{chunk-36FIRJIF.mjs → chunk-742D2WWJ.mjs} +2 -2
  58. package/dist/{chunk-7M7UPWU6.mjs → chunk-7EFHNQ5B.mjs} +1 -1
  59. package/dist/{chunk-JI6T3A4Y.mjs → chunk-7ISBBDJR.mjs} +1 -1
  60. package/dist/{chunk-2GKGEVMR.mjs → chunk-7UZUQQ7Q.mjs} +25 -24
  61. package/dist/{chunk-VPVOAJ7X.mjs → chunk-AGDILNWB.mjs} +1 -1
  62. package/dist/{chunk-5IIH335D.mjs → chunk-ALZ6ZENZ.mjs} +1 -1
  63. package/dist/{chunk-G4YP7GVC.mjs → chunk-BFJGHSQN.mjs} +1 -1
  64. package/dist/chunk-BLNQUR5R.mjs +168 -0
  65. package/dist/chunk-BMX3VUHY.mjs +2 -0
  66. package/dist/chunk-BN7M3IN7.mjs +8 -0
  67. package/dist/{chunk-AMDGVDNV.mjs → chunk-BQNTTFPL.mjs} +1 -1
  68. package/dist/chunk-C257H6IA.mjs +2 -0
  69. package/dist/{chunk-74RPP2M2.mjs → chunk-C564NU2H.mjs} +1 -1
  70. package/dist/chunk-CHQU37CA.mjs +2 -0
  71. package/dist/{chunk-WCWYNFDF.mjs → chunk-E4IHAIJ7.mjs} +1 -1
  72. package/dist/{chunk-7XDYK3UC.mjs → chunk-E7656LR7.mjs} +1 -1
  73. package/dist/{chunk-KFZBYDIS.mjs → chunk-ECZBLQKK.mjs} +1 -1
  74. package/dist/{chunk-PAFSFVYB.mjs → chunk-ERE2BXYV.mjs} +1 -1
  75. package/dist/{chunk-ZEY2RLBT.mjs → chunk-ERLAIBOA.mjs} +2 -2
  76. package/dist/chunk-FFV733MA.mjs +2 -0
  77. package/dist/{chunk-CZ5KJSGK.mjs → chunk-GJJRBGMY.mjs} +1 -1
  78. package/dist/{chunk-VA3KAQZD.mjs → chunk-GKOBB6DH.mjs} +1 -1
  79. package/dist/chunk-GMJD7ID3.mjs +2 -0
  80. package/dist/{chunk-QZ35UAB4.mjs → chunk-GRAXKKG4.mjs} +1 -1
  81. package/dist/{chunk-2RKIHJI2.mjs → chunk-HYMEEXKN.mjs} +1 -1
  82. package/dist/{chunk-DKR7LFIY.mjs → chunk-IA2SIEJQ.mjs} +1 -1
  83. package/dist/{chunk-QK3VISCA.mjs → chunk-IA4PSIMD.mjs} +1 -1
  84. package/dist/chunk-JPG2LBQM.mjs +11 -0
  85. package/dist/{chunk-VGTMLQWZ.mjs → chunk-JXXHAXYH.mjs} +1 -1
  86. package/dist/{chunk-5MEXZ2UF.mjs → chunk-K3JKPFL5.mjs} +1 -1
  87. package/dist/{chunk-LE44MD3O.mjs → chunk-KLQP46Y3.mjs} +1 -1
  88. package/dist/{chunk-NAGMRVW4.mjs → chunk-LKX55H76.mjs} +1 -1
  89. package/dist/chunk-LMUZQK5O.mjs +2 -0
  90. package/dist/{chunk-CG3UHDKH.mjs → chunk-M4NRDYI5.mjs} +1 -1
  91. package/dist/{chunk-HM4E43VM.mjs → chunk-MAFIGVXY.mjs} +1 -1
  92. package/dist/{chunk-4DNHHJSL.mjs → chunk-MKIBJTJZ.mjs} +1 -1
  93. package/dist/{chunk-L7W624FD.mjs → chunk-MNWJ4EZY.mjs} +1 -1
  94. package/dist/{chunk-FXQBADMN.mjs → chunk-NHP66IWR.mjs} +1 -1
  95. package/dist/{chunk-YBB5LWZK.mjs → chunk-OEIJLMPI.mjs} +1 -1
  96. package/dist/{chunk-NWRZXELO.mjs → chunk-PAREWQGB.mjs} +1 -1
  97. package/dist/{chunk-7N2LPG33.mjs → chunk-PDZR3L3C.mjs} +1 -1
  98. package/dist/{chunk-YFJU3O7G.mjs → chunk-PLB7L22J.mjs} +1 -1
  99. package/dist/{chunk-4AMTKWDO.mjs → chunk-PUOQ65NC.mjs} +1 -1
  100. package/dist/chunk-Q4MS6OFC.mjs +2 -0
  101. package/dist/{chunk-3OFXMN6N.mjs → chunk-Q7P3Q5YX.mjs} +1 -1
  102. package/dist/{chunk-6MPKCH3P.mjs → chunk-QNECWMGR.mjs} +1 -1
  103. package/dist/{chunk-HBAUKKQH.mjs → chunk-QP7BOHE4.mjs} +1 -1
  104. package/dist/chunk-QVGOPHOF.mjs +2 -0
  105. package/dist/{chunk-NFABH3QW.mjs → chunk-RRKJMHNX.mjs} +2 -2
  106. package/dist/chunk-S3SX3COT.mjs +20 -0
  107. package/dist/{chunk-ZO7SFB2E.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  108. package/dist/{chunk-VG5JEIUQ.mjs → chunk-TKWEX4FD.mjs} +2 -2
  109. package/dist/{chunk-CCSGFCLZ.mjs → chunk-U3SSPL4K.mjs} +1 -1
  110. package/dist/{chunk-DHB7UZ7F.mjs → chunk-U5XL7D6A.mjs} +1 -1
  111. package/dist/{chunk-CPS4SRPF.mjs → chunk-ULXSPX5H.mjs} +2 -2
  112. package/dist/{chunk-JXLSHVJ2.mjs → chunk-UMHUSOPJ.mjs} +1 -1
  113. package/dist/chunk-USIHBCSW.mjs +15 -0
  114. package/dist/{chunk-GWOYMENX.mjs → chunk-V6XZ4VIR.mjs} +1 -1
  115. package/dist/{chunk-AFGUR7SY.mjs → chunk-VPMRP2TL.mjs} +1 -1
  116. package/dist/{chunk-WTEGUPFG.mjs → chunk-VRPVVMRB.mjs} +1 -1
  117. package/dist/chunk-VZ2RQ3AM.mjs +2 -0
  118. package/dist/{chunk-XKOHV4H6.mjs → chunk-W5NPH5UA.mjs} +1 -1
  119. package/dist/chunk-WFGPMCTZ.mjs +4 -0
  120. package/dist/chunk-XZCFPKGO.mjs +2 -0
  121. package/dist/{chunk-QJ3TFJLQ.mjs → chunk-Y34NR5JL.mjs} +1 -1
  122. package/dist/{chunk-V5JRSGZF.mjs → chunk-YN37ZDLW.mjs} +1 -1
  123. package/dist/chunk-ZFGMJVJC.mjs +2 -0
  124. package/dist/{chunk-KH24LWAT.mjs → chunk-ZTHICSSF.mjs} +1 -1
  125. package/dist/cli.mjs +1 -1
  126. package/dist/server.mjs +1 -1
  127. package/dist/worker.mjs +1 -1
  128. package/kit/math.js +1 -1
  129. package/kit/runtime.js +12 -2
  130. package/kit/state.js +2 -0
  131. package/kit/ui.js +5 -1
  132. package/package.json +1 -1
  133. package/release.json +7 -7
  134. package/skill/SKILL.md +13 -13
  135. package/skill/references/building-blocks.md +1 -1
  136. package/skill/references/extensions.md +45 -9
  137. package/web/assets/{index-xP0uw3a0.css → index-FLb9jCfl.css} +1 -1
  138. package/web/assets/index-czjrXVjf.js +15 -0
  139. package/web/index.html +2 -2
  140. package/dist/chunk-46ACXOU5.mjs +0 -2
  141. package/dist/chunk-5DPABPBI.mjs +0 -2
  142. package/dist/chunk-5L26JUYA.mjs +0 -2
  143. package/dist/chunk-AEMVZYZQ.mjs +0 -166
  144. package/dist/chunk-ASAXY2DJ.mjs +0 -2
  145. package/dist/chunk-DAMVDXR3.mjs +0 -2
  146. package/dist/chunk-DLFZJJEE.mjs +0 -2
  147. package/dist/chunk-EKNHM3P4.mjs +0 -2
  148. package/dist/chunk-FCK6NXON.mjs +0 -3
  149. package/dist/chunk-FX42XU6J.mjs +0 -2
  150. package/dist/chunk-HATA2W7X.mjs +0 -2
  151. package/dist/chunk-JJNRIFND.mjs +0 -8
  152. package/dist/chunk-JL6R4FG4.mjs +0 -4
  153. package/dist/chunk-KUILYI7H.mjs +0 -4
  154. package/dist/chunk-NIW7F7LU.mjs +0 -4
  155. package/dist/chunk-OU3S466R.mjs +0 -20
  156. package/dist/chunk-QCEATQC4.mjs +0 -2
  157. package/dist/chunk-TDWJKOLN.mjs +0 -2
  158. package/dist/chunk-UGO5N3EI.mjs +0 -15
  159. package/dist/chunk-XMKHCUI6.mjs +0 -15
  160. package/dist/chunk-XQRUG4G3.mjs +0 -2
  161. package/dist/chunk-YPPJVDQI.mjs +0 -2
  162. package/dist/chunk-ZANMKAWS.mjs +0 -2
  163. package/web/assets/index-BHC5ZOMh.js +0 -15
  164. /package/dist/{chunk-N3DSBH5S.mjs → chunk-A55HN5OK.mjs} +0 -0
  165. /package/dist/{chunk-KNZJT4ET.mjs → chunk-QAIHRH3I.mjs} +0 -0
  166. /package/dist/{chunk-ZW2A6GBW.mjs → chunk-QR6A54KJ.mjs} +0 -0
  167. /package/dist/{chunk-74UW7QSL.mjs → chunk-UH4SIXTR.mjs} +0 -0
  168. /package/dist/{chunk-EKGYYOSP.mjs → chunk-W7XHE4CT.mjs} +0 -0
  169. /package/dist/{chunk-5MMN3N5J.mjs → chunk-YEY3RSFQ.mjs} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{$ as cr,$a as Ai,A as P,Aa as lr,Ab as pr,B as q,Bb as Gi,C as Ct,Ca as Oi,Cb as Xi,D as hi,Dc as rn,F as pi,Fb as Ji,G as fi,Gb as Yi,H as ne,I as b,Ib as Zi,J as Ne,K as mi,La as E,Ma as j,N as _e,Na as Ni,Nb as Qi,Oa as _i,P as gi,Pa as fe,Q as Et,Qa as Bi,S as wi,Sb as en,T as yi,U as vi,V as xi,Z as Be,_a as Fi,a as or,aa as bi,b as re,ca as Ci,cb as oe,d as Re,db as Ui,e as Oe,ea as J,f as Ze,fa as Ei,fb as hr,g as ci,gb as Li,ha as dr,ia as Si,ib as Mi,j as di,ja as Fe,jb as qi,k as ui,kb as ji,la as Pi,mb as $i,n as li,na as ki,nb as ae,o as ar,oa as Ii,ob as Hi,p as ie,pa as Di,pb as zi,q as bt,qa as St,ra as Ti,sb as Wi,sc as tn,t as D,tc as sn,va as Pt,w as L,wa as Ri,wb as Ki,xb as Vi,ya as ur,yb as Qe,zb as et}from"./chunk-ZO7SFB2E.mjs";import"./chunk-QJ3TFJLQ.mjs";import"./chunk-5MMN3N5J.mjs";import{b as xt,c as T}from"./chunk-EKGYYOSP.mjs";import"./chunk-74UW7QSL.mjs";import{d as ai}from"./chunk-5L7RYZCL.mjs";var Ve={};ai(Ve,{BidiServer:()=>Fs,EventEmitter:()=>K,OutgoingMessage:()=>X});function nn(n){return{all:n=n||new Map,on:function(e,t){var s=n.get(e);s?s.push(t):n.set(e,[t])},off:function(e,t){var s=n.get(e);s&&(t?s.splice(s.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var s=n.get(e);s&&s.slice().map(function(r){r(t)}),(s=n.get("*"))&&s.slice().map(function(r){r(e,t)})}}}var K=class{#e=nn();on(e,t){return this.#e.on(e,t),this}once(e,t){let s=r=>{t(r),this.off(e,s)};return this.on(e,s)}off(e,t){return this.#e.off(e,t),this}emit(e,t){this.#e.emit(e,t)}removeAllListeners(e){return e?this.#e.all.delete(e):this.#e.all.clear(),this}};var S;(function(n){n.bidi="bidi",n.cdp="cdp",n.debug="debug",n.debugError="debug:error",n.debugInfo="debug:info",n.debugWarn="debug:warn"})(S||(S={}));var on,tt=class{static LOGGER_PREFIX=`${S.debug}:queue`;#e;#t;#s=[];#r=!1;constructor(e,t){this.#t=e,this.#e=t}add(e,t){this.#s.push([e,t]),this.#i()}async#i(){if(!this.#r){for(this.#r=!0;this.#s.length>0;){let e=this.#s.shift();if(!e)continue;let[t,s]=e;this.#e?.(on.LOGGER_PREFIX)?.("Processing event:",s),await t.then(r=>{if(r.kind==="error"){this.#e?.(S.debugError)?.("Event threw before sending:",r.error.message,r.error.stack);return}return this.#t(r.value)}).catch(r=>{this.#e?.(S.debugError)?.("Event was not processed:",r?.message)})}this.#r=!1}}};on=tt;var C={};ai(C,{BiDiModule:()=>kt,Bluetooth:()=>Ae,BrowsingContext:()=>Tt,EVENT_NAMES:()=>ro,Input:()=>Rt,Log:()=>Dt,Network:()=>Ot,Script:()=>It,Speculation:()=>Ue});var kt;(function(n){n.Bluetooth="bluetooth",n.Browser="browser",n.BrowsingContext="browsingContext",n.Cdp="goog:cdp",n.Input="input",n.Log="log",n.Network="network",n.Script="script",n.Session="session",n.Speculation="speculation"})(kt||(kt={}));var It;(function(n){let e;(function(t){t.Message="script.message",t.RealmCreated="script.realmCreated",t.RealmDestroyed="script.realmDestroyed"})(e=n.EventNames||(n.EventNames={}))})(It||(It={}));var Dt;(function(n){let e;(function(t){t.LogEntryAdded="log.entryAdded"})(e=n.EventNames||(n.EventNames={}))})(Dt||(Dt={}));var Tt;(function(n){let e;(function(t){t.ContextCreated="browsingContext.contextCreated",t.ContextDestroyed="browsingContext.contextDestroyed",t.DomContentLoaded="browsingContext.domContentLoaded",t.DownloadEnd="browsingContext.downloadEnd",t.DownloadWillBegin="browsingContext.downloadWillBegin",t.FragmentNavigated="browsingContext.fragmentNavigated",t.HistoryUpdated="browsingContext.historyUpdated",t.Load="browsingContext.load",t.NavigationAborted="browsingContext.navigationAborted",t.NavigationCommitted="browsingContext.navigationCommitted",t.NavigationFailed="browsingContext.navigationFailed",t.NavigationStarted="browsingContext.navigationStarted",t.UserPromptClosed="browsingContext.userPromptClosed",t.UserPromptOpened="browsingContext.userPromptOpened"})(e=n.EventNames||(n.EventNames={}))})(Tt||(Tt={}));var Rt;(function(n){let e;(function(t){t.FileDialogOpened="input.fileDialogOpened"})(e=n.EventNames||(n.EventNames={}))})(Rt||(Rt={}));var Ot;(function(n){let e;(function(t){t.AuthRequired="network.authRequired",t.BeforeRequestSent="network.beforeRequestSent",t.FetchError="network.fetchError",t.ResponseCompleted="network.responseCompleted",t.ResponseStarted="network.responseStarted"})(e=n.EventNames||(n.EventNames={}))})(Ot||(Ot={}));var Ae;(function(n){let e;(function(t){t.RequestDevicePromptUpdated="bluetooth.requestDevicePromptUpdated",t.GattConnectionAttempted="bluetooth.gattConnectionAttempted",t.CharacteristicEventGenerated="bluetooth.characteristicEventGenerated",t.DescriptorEventGenerated="bluetooth.descriptorEventGenerated"})(e=n.EventNames||(n.EventNames={}))})(Ae||(Ae={}));var Ue;(function(n){let e;(function(t){t.PrefetchStatusUpdated="speculation.prefetchStatusUpdated"})(e=n.EventNames||(n.EventNames={}))})(Ue||(Ue={}));var ro=new Set([...Object.values(kt),...Object.values(Ae.EventNames),...Object.values(Tt.EventNames),...Object.values(Rt.EventNames),...Object.values(Dt.EventNames),...Object.values(Ot.EventNames),...Object.values(It.EventNames),...Object.values(Ue.EventNames)]);var F=class extends Error{error;message;stacktrace;constructor(e,t,s){super(),this.error=e,this.message=t,this.stacktrace=s}toErrorResponse(e){return{type:"error",id:e,error:this.error,message:this.message,stacktrace:this.stacktrace}}},x=class extends F{constructor(e,t){super("invalid argument",e,t)}},xe=class extends F{constructor(e,t){super("invalid selector",e,t)}};var st=class extends F{constructor(e,t){super("move target out of bounds",e,t)}},Nt=class extends F{constructor(e,t){super("no such alert",e,t)}},ce=class extends F{constructor(e,t){super("no such element",e,t)}},V=class extends F{constructor(e,t){super("no such frame",e,t)}},rt=class extends F{constructor(e,t){super("no such handle",e,t)}},_t=class extends F{constructor(e,t){super("no such history entry",e,t)}},Bt=class extends F{constructor(e,t){super("no such intercept",e,t)}},Y=class extends F{constructor(e,t){super("no such node",e,t)}},Le=class extends F{constructor(e,t){super("no such request",e,t)}},it=class extends F{constructor(e,t){super("no such script",e,t)}},G=class extends F{constructor(e,t){super("no such user context",e,t)}};var Ft=class extends F{constructor(e,t){super("unknown command",e,t)}},O=class extends F{constructor(e,t=new Error().stack){super("unknown error",e,t)}},nt=class extends F{constructor(e,t){super("unable to capture screen",e,t)}};var R=class extends F{constructor(e,t){super("unsupported operation",e,t)}};var At=class extends F{constructor(e,t){super("unable to set cookie",e,t)}},be=class extends F{constructor(e,t){super("unable to set file input",e,t)}};var Ut=class extends F{constructor(e,t){super("invalid web extension",e,t)}},Lt=class extends F{constructor(e,t){super("no such web extension",e,t)}},Me=class extends F{constructor(e,t){super("no such network collector",e,t)}},me=class extends F{constructor(e,t){super("no such network data",e,t)}};var Mt=class{parseDisableSimulationParameters(e){return e}parseHandleRequestDevicePromptParams(e){return e}parseSimulateAdapterParameters(e){return e}parseSimulateAdvertisementParameters(e){return e}parseSimulateCharacteristicParameters(e){return e}parseSimulateCharacteristicResponseParameters(e){return e}parseSimulateDescriptorParameters(e){return e}parseSimulateDescriptorResponseParameters(e){return e}parseSimulateGattConnectionResponseParameters(e){return e}parseSimulateGattDisconnectionParameters(e){return e}parseSimulatePreconnectedPeripheralParameters(e){return e}parseSimulateServiceParameters(e){return e}parseCreateUserContextParameters(e){return e}parseRemoveUserContextParameters(e){return e}parseSetClientWindowStateParameters(e){return e}parseSetDownloadBehaviorParameters(e){return e}parseActivateParams(e){return e}parseCaptureScreenshotParams(e){return e}parseCloseParams(e){return e}parseCreateParams(e){return e}parseGetTreeParams(e){return e}parseHandleUserPromptParams(e){return e}parseLocateNodesParams(e){return e}parseNavigateParams(e){return e}parsePrintParams(e){return e}parseReloadParams(e){return e}parseSetBypassCspParams(e){return e}parseSetViewportParams(e){return e}parseStartScreencastParams(e){return e}parseStopScreencastParams(e){return e}parseTraverseHistoryParams(e){return e}parseGetSessionParams(e){return e}parseResolveRealmParams(e){return e}parseSendCommandParams(e){return e}parseSetClientHintsOverrideParams(e){return e}parseSetForcedColorsModeThemeOverrideParams(e){return e}parseSetGeolocationOverrideParams(e){return e}parseSetLocaleOverrideParams(e){return e}parseSetNetworkConditionsParams(e){return e}parseSetScreenOrientationOverrideParams(e){return e}parseSetScreenSettingsOverrideParams(e){return e}parseSetScriptingEnabledParams(e){return e}parseSetScrollbarTypeOverrideParams(e){return e}parseSetTimezoneOverrideParams(e){return e}parseSetTouchOverrideParams(e){return e}parseSetUserAgentOverrideParams(e){return e}parseAddPreloadScriptParams(e){return e}parseCallFunctionParams(e){return e}parseDisownParams(e){return e}parseEvaluateParams(e){return e}parseGetRealmsParams(e){return e}parseRemovePreloadScriptParams(e){return e}parsePerformActionsParams(e){return e}parseReleaseActionsParams(e){return e}parseSetFilesParams(e){return e}parseAddDataCollectorParams(e){return e}parseAddInterceptParams(e){return e}parseContinueRequestParams(e){return e}parseContinueResponseParams(e){return e}parseContinueWithAuthParams(e){return e}parseDisownDataParams(e){return e}parseFailRequestParams(e){return e}parseGetDataParams(e){return e}parseProvideResponseParams(e){return e}parseRemoveDataCollectorParams(e){return e}parseRemoveInterceptParams(e){return e}parseSetCacheBehaviorParams(e){return e}parseSetExtraHeadersParams(e){return e}parseSetPermissionsParams(e){return e}parseSubscribeParams(e){return e}parseUnsubscribeParams(e){return e}parseDeleteCookiesParams(e){return e}parseGetCookiesParams(e){return e}parseSetCookieParams(e){return e}parseInstallParams(e){return e}parseUninstallParams(e){return e}parseSetVirtualWalletBehaviorParams(e){return e}};var qt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}close(){return setTimeout(()=>this.#e.sendCommand("Browser.close").catch(()=>{}),0),{}}async createUserContext(e){let t=e,s=this.#s.getGlobalConfig();if(t.acceptInsecureCerts!==void 0&&t.acceptInsecureCerts===!1&&s.acceptInsecureCerts===!0)throw new O(`Cannot set user context's "acceptInsecureCerts" to false, when a capability "acceptInsecureCerts" is set to true`);let r={};if(t.proxy){let o=no(t.proxy);o&&(r.proxyServer=o),t.proxy.noProxy&&(r.proxyBypassList=t.proxy.noProxy.join(","))}else{e["goog:proxyServer"]!==void 0&&(r.proxyServer=e["goog:proxyServer"]);let o=e["goog:proxyBypassList"]??void 0;o&&(r.proxyBypassList=o.join(","))}let i=await this.#e.sendCommand("Target.createBrowserContext",r);return await this.#a(s.downloadBehavior??null,i.browserContextId),this.#s.updateUserContextConfig(i.browserContextId,{acceptInsecureCerts:e.acceptInsecureCerts,userPromptHandler:e.unhandledPromptBehavior}),{userContext:i.browserContextId}}async removeUserContext(e){let t=e.userContext;if(t==="default")throw new x("`default` user context cannot be removed");try{await this.#e.sendCommand("Target.disposeBrowserContext",{browserContextId:t})}catch(s){throw s.message.startsWith("Failed to find context with id")?new G(s.message):s}return{}}async getUserContexts(){return{userContexts:await this.#r.getUserContexts()}}async#i(e){let t=await this.#e.sendCommand("Browser.getWindowForTarget",{targetId:e});return{active:!1,clientWindow:`${t.windowId}`,state:t.bounds.windowState??"normal",height:t.bounds.height??0,width:t.bounds.width??0,x:t.bounds.left??0,y:t.bounds.top??0}}async setClientWindowState(e){let{clientWindow:t}=e,s={windowState:e.state};e.state==="normal"&&(e.width!==void 0&&(s.width=e.width),e.height!==void 0&&(s.height=e.height),e.x!==void 0&&(s.left=e.x),e.y!==void 0&&(s.top=e.y));let r=Number.parseInt(t);if(isNaN(r))throw new x("no such client window");await this.#e.sendCommand("Browser.setWindowBounds",{windowId:r,bounds:s});let i=await this.#e.sendCommand("Browser.getWindowBounds",{windowId:r});return{active:!1,clientWindow:`${r}`,state:i.bounds.windowState??"normal",height:i.bounds.height??0,width:i.bounds.width??0,x:i.bounds.left??0,y:i.bounds.top??0}}async getClientWindows(){let e=this.#t.getTopLevelContexts().map(i=>i.cdpTarget.id),t=await Promise.all(e.map(async i=>await this.#i(i))),s=new Set,r=new Array;for(let i of t)s.has(i.clientWindow)||(s.add(i.clientWindow),r.push(i));return{clientWindows:r}}#o(e){if(e===null)return{behavior:"default"};if(e?.type==="denied")return{behavior:"deny"};if(e?.type==="allowed")return{behavior:"allow",downloadPath:e.destinationFolder};throw new O("Unexpected download behavior")}async#a(e,t){await this.#e.sendCommand("Browser.setDownloadBehavior",{...this.#o(e),browserContextId:t==="default"?void 0:t,eventsEnabled:!0})}async setDownloadBehavior(e){let t;return e.userContexts===void 0?t=(await this.#r.getUserContexts()).map(s=>s.userContext):t=Array.from(await this.#r.verifyUserContextIdList(e.userContexts)),e.userContexts===void 0?this.#s.updateGlobalConfig({downloadBehavior:e.downloadBehavior}):e.userContexts.map(s=>this.#s.updateUserContextConfig(s,{downloadBehavior:e.downloadBehavior})),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(void 0,s).downloadBehavior??null;await this.#a(r,s)})),{}}};function no(n){if(!(n.proxyType==="direct"||n.proxyType==="system")){if(n.proxyType==="pac")throw new R("PAC proxy configuration is not supported per user context");if(n.proxyType==="autodetect")throw new R("Autodetect proxy is not supported per user context");if(n.proxyType==="manual"){let e=[];if(n.httpProxy!==void 0&&e.push(`http=${n.httpProxy}`),n.sslProxy!==void 0&&e.push(`https=${n.sslProxy}`),n.socksProxy!==void 0||n.socksVersion!==void 0){if(n.socksProxy===void 0)throw new x("'socksVersion' cannot be set without 'socksProxy'");if(n.socksVersion===void 0||typeof n.socksVersion!="number"||!Number.isInteger(n.socksVersion)||n.socksVersion<0||n.socksVersion>255)throw new x("'socksVersion' must be between 0 and 255");e.push(`socks=socks${n.socksVersion}://${n.socksProxy}`)}return e.length===0?void 0:e.join(";")}throw new O("Unknown proxy type")}}var jt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}getSession(e){let t=e.context,s=this.#e.getContext(t).cdpTarget.cdpSessionId;return s===void 0?{}:{session:s}}resolveRealm(e){let t=e.realm,s=this.#t.getRealm({realmId:t});if(s===void 0)throw new O(`Could not find realm ${e.realm}`);return{executionContextId:s.executionContextId}}async sendCommand(e){return{result:await(e.session?this.#s.getCdpClient(e.session):this.#r).sendCommand(e.method,e.params),session:e.session}}};var $t=class{#e;#t;#s;#r;#i;constructor(e,t,s,r,i){this.#s=r,this.#i=s,this.#e=e,this.#t=t,this.#r=i,this.#r.addSubscribeHook(C.BrowsingContext.EventNames.ContextCreated,this.#a.bind(this))}getTree(e){return{contexts:(e.root===void 0?this.#t.getTopLevelContexts():[this.#t.getContext(e.root)]).map(s=>s.serializeToBidiValue(e.maxDepth??Number.MAX_VALUE))}}async create(e){let t,s="default";if(e.referenceContext!==void 0){if(t=this.#t.getContext(e.referenceContext),!t.isTopLevelContext())throw new x("referenceContext should be a top-level context");s=t.userContext}e.userContext!==void 0&&(s=e.userContext);let r=this.#t.getAllContexts().filter(c=>c.userContext===s),i=!1;switch(e.type){case"tab":i=!1;break;case"window":i=!0;break}r.length||(i=!0);let o;try{o=await this.#e.sendCommand("Target.createTarget",{url:"about:blank",newWindow:i,browserContextId:s==="default"?void 0:s,background:e.background===!0})}catch(c){throw c.message.startsWith("Failed to find browser context with id")||c.message==="browserContextId"?new G(`The context ${s} was not found`):c}let a=await this.#t.waitForContext(o.targetId);return await a.lifecycleLoaded(),{context:a.id}}navigate(e){return this.#t.getContext(e.context).navigate(e.url,e.wait??"none")}reload(e){return this.#t.getContext(e.context).reload(e.ignoreCache??!1,e.wait??"none")}async activate(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x("Activation is only supported on the top-level context");return await t.activate(),{}}async captureScreenshot(e){return await this.#t.getContext(e.context).captureScreenshot(e)}async print(e){return await this.#t.getContext(e.context).print(e)}async setViewport(e){if((e.viewport?.height??0)>1e7||(e.viewport?.width??0)>1e7)throw new R("Viewport dimension over 10000000 are not supported");let s={};e.devicePixelRatio!==void 0&&(s.devicePixelRatio=e.devicePixelRatio),e.viewport!==void 0&&(s.viewport=e.viewport);let r=await this.#o(e.context,e.userContexts);for(let i of e.userContexts??[])this.#s.updateUserContextConfig(i,s);return e.context!==void 0&&this.#s.updateBrowsingContextConfig(e.context,s),await Promise.all(r.map(async i=>{let o=this.#s.getActiveConfig(i.id,i.userContext);await i.setViewport(o.viewport??null,o.devicePixelRatio??null,o.screenOrientation??null)})),{}}async#o(e,t){if(e===void 0&&t===void 0)throw new x("Either userContexts or context must be provided");if(e!==void 0&&t!==void 0)throw new x("userContexts and context are mutually exclusive");if(e!==void 0){let r=this.#t.getContext(e);if(!r.isTopLevelContext())throw new x("Emulating viewport is only supported on the top-level context");return[r]}await this.#i.verifyUserContextIdList(t);let s=[];for(let r of t){let i=this.#t.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}return[...new Set(s).values()]}async traverseHistory(e){let t=this.#t.getContext(e.context);if(!t)throw new x(`No browsing context with id ${e.context}`);if(!t.isTopLevelContext())throw new x("Traversing history is only supported on the top-level context");return await t.traverseHistory(e.delta),{}}async handleUserPrompt(e){let t=this.#t.getContext(e.context);try{await t.handleUserPrompt(e.accept,e.userText)}catch(s){throw s.message?.includes("No dialog is showing")?new Nt("No dialog is showing"):s}return{}}async close(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x(`Non top-level browsing context ${t.id} cannot be closed.`);let s=t.cdpTarget.parentCdpClient;try{let r=new Promise(i=>{let o=a=>{a.targetId===e.context&&(s.off("Target.detachedFromTarget",o),i())};s.on("Target.detachedFromTarget",o)});try{e.promptUnload?await t.close():await s.sendCommand("Target.closeTarget",{targetId:e.context})}catch(i){if(!s.isCloseError(i))throw i}await r}catch(r){if(!(r.code===-32e3&&r.message==="Not attached to an active page"))throw r}return{}}async locateNodes(e){return await this.#t.getContext(e.context).locateNodes(e)}#a(e){return[this.#t.getContext(e),...this.#t.getContext(e).allChildren].forEach(r=>{this.#r.registerEvent({type:"event",method:C.BrowsingContext.EventNames.ContextCreated,params:r.serializeToBidiValue()},r.id)}),Promise.resolve()}};var Ht=class{#e;#t;#s;constructor(e,t,s){this.#e=t,this.#t=e,this.#s=s}async setGeolocationOverride(e){if("coordinates"in e&&"error"in e)throw new x("Coordinates and error cannot be set at the same time");let t=null;if("coordinates"in e){if((e.coordinates?.altitude??null)===null&&(e.coordinates?.altitudeAccuracy??null)!==null)throw new x("Geolocation altitudeAccuracy can be set only with altitude");t=e.coordinates}else if("error"in e){if(e.error.type!=="positionUnavailable")throw new x(`Unknown geolocation error ${e.error.type}`);t=e.error}else throw new x("Coordinates or error should be set");let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{geolocation:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{geolocation:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setGeolocationOverride(i.geolocation??null)})),{}}async setLocaleOverride(e){let t=e.locale??null;if(t!==null&&!oo(t))throw new x(`Invalid locale "${t}"`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{locale:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{locale:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await Promise.all([r.setLocaleOverride(i.locale??null),r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)])})),{}}async setScriptingEnabled(e){let t=e.enabled,s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{scriptingEnabled:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{scriptingEnabled:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setScriptingEnabled(i.scriptingEnabled??null)})),{}}async setScrollbarTypeOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{scrollbarType:e.scrollbarType});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{scrollbarType:e.scrollbarType});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setScrollbarTypeOverride(r.scrollbarType??null)})),{}}async setScreenOrientationOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenOrientation:e.screenOrientation});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenOrientation:e.screenOrientation});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async setScreenSettingsOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenArea:e.screenArea});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenArea:e.screenArea});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async#r(e,t,s=!1){if(e===void 0&&t===void 0){if(s)return this.#t.getTopLevelContexts();throw new x("Either user contexts or browsing contexts must be provided")}if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let r=[];if(e===void 0){if(t.length===0)throw new x("user context should be provided");await this.#e.verifyUserContextIdList(t);for(let i of t){let o=this.#t.getTopLevelContexts().filter(a=>a.userContext===i);r.push(...o)}}else{if(e.length===0)throw new x("browsing context should be provided");for(let i of e){let o=this.#t.getContext(i);if(!o.isTopLevelContext())throw new x("The command is only supported on the top-level context");r.push(o)}}return[...new Set(r).values()]}async setTimezoneOverride(e){let t=e.timezone??null;if(t!==null&&!ao(t))throw new x(`Invalid timezone "${t}"`);t!==null&&co(t)&&(t=`GMT${t}`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{timezone:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{timezone:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTimezoneOverride(i.timezone??null)})),{}}async setTouchOverride(e){let t=e.maxTouchPoints,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{maxTouchPoints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{maxTouchPoints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({maxTouchPoints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTouchOverride(i.maxTouchPoints??null)})),{}}async setUserAgentOverrideParams(e){if(e.userAgent==="")throw new R("empty user agent string is not supported");let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{userAgent:e.userAgent});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{userAgent:e.userAgent});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({userAgent:e.userAgent}),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setUserAgentAndAcceptLanguage(r.userAgent,r.locale,r.clientHints)})),{}}async setClientHintsOverride(e){let t=e.clientHints??null,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{clientHints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{clientHints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({clientHints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)})),{}}async setNetworkConditions(e){let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{emulatedNetworkConditions:e.networkConditions});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{emulatedNetworkConditions:e.networkConditions});if(e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({emulatedNetworkConditions:e.networkConditions}),e.networkConditions!==null&&e.networkConditions.type!=="offline")throw new R(`Unsupported network conditions ${e.networkConditions.type}`);return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setEmulatedNetworkConditions(r.emulatedNetworkConditions??null)})),{}}};function oo(n){try{return new Intl.Locale(n),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function ao(n){try{return Intl.DateTimeFormat(void 0,{timeZone:n}),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function co(n){return/^[+-](?:2[0-3]|[01]\d)(?::[0-5]\d)?$/.test(n)}function _(n,e){if(!n)throw new Error(e??"Internal assertion failed.")}function fr(n){return zt(n)&&n.length>1}function zt(n){return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].length===1}var Wt=class{type="none"},ot=class{type="key";pressed=new Set;#e=0;get modifiers(){return this.#e}get alt(){return(this.#e&1)===1}set alt(e){this.#t(e,1)}get ctrl(){return(this.#e&2)===2}set ctrl(e){this.#t(e,2)}get meta(){return(this.#e&4)===4}set meta(e){this.#t(e,4)}get shift(){return(this.#e&8)===8}set shift(e){this.#t(e,8)}#t(e,t){e?this.#e|=t:this.#e&=~t}},Kt=class n{static#e=500;static#t=2;count=0;#s;#r;#i;constructor(e,t,s){this.#s=e,this.#r=t,this.#i=s}compare(e){return e.#i-this.#i>n.#e||Math.abs(e.#s-this.#s)>n.#t||Math.abs(e.#r-this.#r)>n.#t}},Vt=class{type="pointer";subtype;pointerId;pressed=new Set;x=0;y=0;radiusX;radiusY;force;constructor(e,t){this.pointerId=e,this.subtype=t}get buttons(){let e=0;for(let t of this.pressed)switch(t){case 0:e|=1;break;case 1:e|=4;break;case 2:e|=2;break;case 3:e|=8;break;case 4:e|=16;break}return e}#e=new Map;setClickCount(e,t){let s=this.#e.get(e);return(!s||s.compare(t))&&(s=t),++s.count,this.#e.set(e,s),s.count}getClickCount(e){return this.#e.get(e)?.count??0}resetClickCount(){this.#e=new Map}},Gt=class{type="wheel"};function mr(n){switch(n){case"\uE000":return"Unidentified";case"\uE001":return"Cancel";case"\uE002":return"Help";case"\uE003":return"Backspace";case"\uE004":return"Tab";case"\uE005":return"Clear";case"\uE006":case"\uE007":return"Enter";case"\uE008":return"Shift";case"\uE009":return"Control";case"\uE00A":return"Alt";case"\uE00B":return"Pause";case"\uE00C":return"Escape";case"\uE00D":return" ";case"\uE00E":return"PageUp";case"\uE00F":return"PageDown";case"\uE010":return"End";case"\uE011":return"Home";case"\uE012":return"ArrowLeft";case"\uE013":return"ArrowUp";case"\uE014":return"ArrowRight";case"\uE015":return"ArrowDown";case"\uE016":return"Insert";case"\uE017":return"Delete";case"\uE018":return";";case"\uE019":return"=";case"\uE01A":return"0";case"\uE01B":return"1";case"\uE01C":return"2";case"\uE01D":return"3";case"\uE01E":return"4";case"\uE01F":return"5";case"\uE020":return"6";case"\uE021":return"7";case"\uE022":return"8";case"\uE023":return"9";case"\uE024":return"*";case"\uE025":return"+";case"\uE026":return",";case"\uE027":return"-";case"\uE028":return".";case"\uE029":return"/";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE03D":return"Meta";case"\uE040":return"ZenkakuHankaku";case"\uE050":return"Shift";case"\uE051":return"Control";case"\uE052":return"Alt";case"\uE053":return"Meta";case"\uE054":return"PageUp";case"\uE055":return"PageDown";case"\uE056":return"End";case"\uE057":return"Home";case"\uE058":return"ArrowLeft";case"\uE059":return"ArrowUp";case"\uE05A":return"ArrowRight";case"\uE05B":return"ArrowDown";case"\uE05C":return"Insert";case"\uE05D":return"Delete";default:return n}}function gr(n){switch(n){case"`":case"~":return"Backquote";case"\\":case"|":return"Backslash";case"\uE003":return"Backspace";case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case",":case"<":return"Comma";case"0":case")":return"Digit0";case"1":case"!":return"Digit1";case"2":case"@":return"Digit2";case"3":case"#":return"Digit3";case"4":case"$":return"Digit4";case"5":case"%":return"Digit5";case"6":case"^":return"Digit6";case"7":case"&":return"Digit7";case"8":case"*":return"Digit8";case"9":case"(":return"Digit9";case"=":case"+":return"Equal";case">":return"IntlBackslash";case"a":case"A":return"KeyA";case"b":case"B":return"KeyB";case"c":case"C":return"KeyC";case"d":case"D":return"KeyD";case"e":case"E":return"KeyE";case"f":case"F":return"KeyF";case"g":case"G":return"KeyG";case"h":case"H":return"KeyH";case"i":case"I":return"KeyI";case"j":case"J":return"KeyJ";case"k":case"K":return"KeyK";case"l":case"L":return"KeyL";case"m":case"M":return"KeyM";case"n":case"N":return"KeyN";case"o":case"O":return"KeyO";case"p":case"P":return"KeyP";case"q":case"Q":return"KeyQ";case"r":case"R":return"KeyR";case"s":case"S":return"KeyS";case"t":case"T":return"KeyT";case"u":case"U":return"KeyU";case"v":case"V":return"KeyV";case"w":case"W":return"KeyW";case"x":case"X":return"KeyX";case"y":case"Y":return"KeyY";case"z":case"Z":return"KeyZ";case"-":case"_":return"Minus";case".":return"Period";case"'":case'"':return"Quote";case";":case":":return"Semicolon";case"/":case"?":return"Slash";case"\uE00A":return"AltLeft";case"\uE052":return"AltRight";case"\uE009":return"ControlLeft";case"\uE051":return"ControlRight";case"\uE006":return"Enter";case"\uE00B":return"Pause";case"\uE03D":return"MetaLeft";case"\uE053":return"MetaRight";case"\uE008":return"ShiftLeft";case"\uE050":return"ShiftRight";case" ":case"\uE00D":return"Space";case"\uE004":return"Tab";case"\uE017":return"Delete";case"\uE010":return"End";case"\uE002":return"Help";case"\uE011":return"Home";case"\uE016":return"Insert";case"\uE00F":return"PageDown";case"\uE00E":return"PageUp";case"\uE015":return"ArrowDown";case"\uE012":return"ArrowLeft";case"\uE014":return"ArrowRight";case"\uE013":return"ArrowUp";case"\uE00C":return"Escape";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE019":return"NumpadEqual";case"\uE01A":case"\uE05C":return"Numpad0";case"\uE01B":case"\uE056":return"Numpad1";case"\uE01C":case"\uE05B":return"Numpad2";case"\uE01D":case"\uE055":return"Numpad3";case"\uE01E":case"\uE058":return"Numpad4";case"\uE01F":return"Numpad5";case"\uE020":case"\uE05A":return"Numpad6";case"\uE021":case"\uE057":return"Numpad7";case"\uE022":case"\uE059":return"Numpad8";case"\uE023":case"\uE054":return"Numpad9";case"\uE025":return"NumpadAdd";case"\uE026":return"NumpadComma";case"\uE028":case"\uE05D":return"NumpadDecimal";case"\uE029":return"NumpadDivide";case"\uE007":return"NumpadEnter";case"\uE024":return"NumpadMultiply";case"\uE027":return"NumpadSubtract";default:return}}function wr(n){switch(n){case"\uE007":case"\uE008":case"\uE009":case"\uE00A":case"\uE03D":return 1;case"\uE019":case"\uE01A":case"\uE01B":case"\uE01C":case"\uE01D":case"\uE01E":case"\uE01F":case"\uE020":case"\uE021":case"\uE022":case"\uE023":case"\uE024":case"\uE025":case"\uE026":case"\uE027":case"\uE028":case"\uE029":case"\uE054":case"\uE055":case"\uE056":case"\uE057":case"\uE058":case"\uE059":case"\uE05A":case"\uE05B":case"\uE05C":case"\uE05D":return 3;case"\uE050":case"\uE051":case"\uE052":case"\uE053":return 2;default:return 0}}var yr={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,Abort:3,Help:6,Backspace:8,Tab:9,Numpad5:12,NumpadEnter:13,Enter:13,"\\r":13,"\\n":13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Convert:28,NonConvert:29,Space:32,Numpad9:33,PageUp:33,Numpad3:34,PageDown:34,End:35,Numpad1:35,Home:36,Numpad7:36,ArrowLeft:37,Numpad4:37,Numpad8:38,ArrowUp:38,ArrowRight:39,Numpad6:39,Numpad2:40,ArrowDown:40,Select:41,Open:43,PrintScreen:44,Insert:45,Numpad0:45,Delete:46,NumpadDecimal:46,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,KeyA:65,KeyB:66,KeyC:67,KeyD:68,KeyE:69,KeyF:70,KeyG:71,KeyH:72,KeyI:73,KeyJ:74,KeyK:75,KeyL:76,KeyM:77,KeyN:78,KeyO:79,KeyP:80,KeyQ:81,KeyR:82,KeyS:83,KeyT:84,KeyU:85,KeyV:86,KeyW:87,KeyX:88,KeyY:89,KeyZ:90,MetaLeft:91,MetaRight:92,ContextMenu:93,NumpadMultiply:106,NumpadAdd:107,NumpadSubtract:109,NumpadDivide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NumLock:144,ScrollLock:145,AudioVolumeMute:173,AudioVolumeDown:174,AudioVolumeUp:175,MediaTrackNext:176,MediaTrackPrevious:177,MediaStop:178,MediaPlayPause:179,Semicolon:186,Equal:187,NumpadEqual:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222,AltGraph:225,Props:247,Cancel:3,Clear:12,Shift:16,Control:17,Alt:18,Accept:30,ModeChange:31," ":32,Print:42,Execute:43,"\\u0000":46,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,Meta:91,"*":106,"+":107,"-":109,"/":111,";":186,"=":187,",":188,".":190,"`":192,"[":219,"\\\\":220,"]":221,"'":222,Attn:246,CrSel:247,ExSel:248,EraseEof:249,Play:250,ZoomOut:251,")":48,"!":49,"@":50,"#":51,$:52,"%":53,"^":54,"&":55,"(":57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,":":186,"<":188,_:189,">":190,"?":191,"~":192,"{":219,"|":220,"}":221,'"':222,Camera:44,EndCall:95,VolumeDown:182,VolumeUp:183};var uo=(n=>{let e=n.getClientRects()[0],t=Math.max(0,Math.min(e.x,e.x+e.width)),s=Math.min(window.innerWidth,Math.max(e.x,e.x+e.width)),r=Math.max(0,Math.min(e.y,e.y+e.height)),i=Math.min(window.innerHeight,Math.max(e.y,e.y+e.height));return[t+(s-t>>1),r+(i-r>>1)]}).toString(),lo=(()=>navigator.platform.toLowerCase().includes("mac")).toString();async function ho(n,e){let s=await(await n.getOrCreateHiddenSandbox()).callFunction(uo,!1,{type:"undefined"},[e]);if(s.type==="exception")throw new ce(`Origin element ${e.sharedId} was not found`);_(s.result.type==="array"),_(s.result.value?.[0]?.type==="number"),_(s.result.value?.[1]?.type==="number");let{result:{value:[{value:r},{value:i}]}}=s;return{x:r,y:i}}var Ce=class{static isMacOS=async e=>{let s=await(await e.getOrCreateHiddenSandbox()).callFunction(lo,!1);return _(s.type!=="exception"),_(s.result.type==="boolean"),s.result.value};#e;#t=0;#s=0;#r;#i;#o;constructor(e,t,s,r){this.#e=t,this.#r=e,this.#i=s,this.#o=r}get#a(){return this.#e.getContext(this.#i)}async dispatchActions(e){await this.#r.queue.run(async()=>{for(let t of e)await this.dispatchTickActions(t)})}async dispatchTickActions(e){this.#t=performance.now(),this.#s=0;for(let{action:s}of e)"duration"in s&&s.duration!==void 0&&(this.#s=Math.max(this.#s,s.duration));let t=[new Promise(s=>setTimeout(s,this.#s))];for(let s of e)t.push(this.#d(s));await Promise.all(t)}async#d({id:e,action:t}){let s=this.#r.get(e),r=this.#r.getGlobalKeyState();switch(t.type){case"keyDown":{await this.#u(s,t),this.#r.cancelList.push({id:e,action:{...t,type:"keyUp"}});break}case"keyUp":{await this.#m(s,t);break}case"pause":break;case"pointerDown":{await this.#n(s,r,t),this.#r.cancelList.push({id:e,action:{...t,type:"pointerUp"}});break}case"pointerMove":{await this.#h(s,r,t);break}case"pointerUp":{await this.#l(s,r,t);break}case"scroll":{await this.#p(s,r,t);break}}}async#n(e,t,s){let{button:r}=s;if(e.pressed.has(r))return;e.pressed.add(r);let{x:i,y:o,subtype:a}=e,{width:c,height:d,pressure:u,twist:l,tangentialPressure:y}=s,{tiltX:f,tiltY:h}=dn(s),{modifiers:p}=t,{radiusX:m,radiusY:v}=un(c??1,d??1);switch(a){case"mouse":case"pen":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:o,modifiers:p,button:Xt(r),buttons:e.buttons,clickCount:e.setClickCount(r,new Kt(i,o,performance.now())),pointerType:a,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u});break;case"touch":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchStart",touchPoints:[{x:i,y:o,radiusX:m,radiusY:v,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u,id:e.pointerId}],modifiers:p});break}e.radiusX=m,e.radiusY=v,e.force=u}#l(e,t,s){let{button:r}=s;if(!e.pressed.has(r))return;e.pressed.delete(r);let{x:i,y:o,force:a,radiusX:c,radiusY:d,subtype:u}=e,{modifiers:l}=t;switch(u){case"mouse":case"pen":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:o,modifiers:l,button:Xt(r),buttons:e.buttons,clickCount:e.getClickCount(r),pointerType:u});case"touch":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchEnd",touchPoints:[{x:i,y:o,id:e.pointerId,force:a,radiusX:c,radiusY:d}],modifiers:l})}}async#h(e,t,s){let{x:r,y:i,subtype:o}=e,{width:a,height:c,pressure:d,twist:u,tangentialPressure:l,x:y,y:f,origin:h="viewport",duration:p=this.#s}=s,{tiltX:m,tiltY:v}=dn(s),{radiusX:I,radiusY:B}=un(a??1,c??1),{targetX:U,targetY:he}=await this.#f(h,y,f,r,i);if(U<0||he<0)throw new st(`Cannot move beyond viewport (x: ${U}, y: ${he})`);let Ie;do{let De=p>0?(performance.now()-this.#t)/p:1;Ie=De>=1;let Q,ee;if(Ie?(Q=U,ee=he):(Q=Math.round(De*(U-r)+r),ee=Math.round(De*(he-i)+i)),e.x!==Q||e.y!==ee){let{modifiers:Te}=t;switch(o){case"mouse":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d});break;case"pen":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d??.5});break;case"touch":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchMove",touchPoints:[{x:Q,y:ee,radiusX:I,radiusY:B,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d,id:e.pointerId}],modifiers:Te});break}e.x=Q,e.y=ee,e.radiusX=I,e.radiusY=B,e.force=d}}while(!Ie)}async#c(){if(this.#a.id===this.#a.cdpTarget.id)return{x:0,y:0};let{backendNodeId:e}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getFrameOwner",{frameId:this.#a.id}),{model:t}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getBoxModel",{backendNodeId:e});return{x:t.content[0],y:t.content[1]}}async#f(e,t,s,r,i){let o,a,c=await this.#c();switch(e){case"viewport":o=t+c.x,a=s+c.y;break;case"pointer":o=r+t+c.x,a=i+s+c.y;break;default:{let{x:d,y:u}=await ho(this.#a,e.element);o=d+t+c.x,a=u+s+c.y;break}}return{targetX:o,targetY:a}}async#p(e,t,s){let{deltaX:r,deltaY:i,x:o,y:a,origin:c="viewport",duration:d=this.#s}=s;if(c==="pointer")throw new x('"pointer" origin is invalid for scrolling.');let{targetX:u,targetY:l}=await this.#f(c,o,a,0,0);if(u<0||l<0)throw new st(`Cannot move beyond viewport (x: ${u}, y: ${l})`);let y=0,f=0,h;do{let p=d>0?(performance.now()-this.#t)/d:1;h=p>=1;let m,v;if(h?(m=r-y,v=i-f):(m=Math.round(p*r-y),v=Math.round(p*i-f)),m!==0||v!==0){let{modifiers:I}=t;await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseWheel",deltaX:m,deltaY:v,x:u,y:l,modifiers:I}),y+=m,f+=v}}while(!h)}async#u(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s),o=e.pressed.has(i),a=gr(s),c=wr(s);switch(i){case"Alt":e.alt=!0;break;case"Shift":e.shift=!0;break;case"Control":e.ctrl=!0;break;case"Meta":e.meta=!0;break}e.pressed.add(i);let{modifiers:d}=e,u=an(i,e,r),l=cn(a??"",e)??u,y;if(this.#o&&e.meta)switch(a){case"KeyA":y="SelectAll";break;case"KeyC":y="Copy";break;case"KeyV":y=e.shift?"PasteAndMatchStyle":"Paste";break;case"KeyX":y="Cut";break;case"KeyZ":y=e.shift?"Redo":"Undo";break;default:}let f=[this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:l?"keyDown":"rawKeyDown",windowsVirtualKeyCode:yr[i],key:i,code:a,text:l,unmodifiedText:u,autoRepeat:o,isSystemKey:e.alt||void 0,location:c<3?c:void 0,isKeypad:c===3,modifiers:d,commands:y?[y]:void 0})];i==="Escape"&&!e.alt&&(this.#o&&!e.ctrl&&!e.meta||!this.#o)&&f.push(this.#a.cdpTarget.cdpClient.sendCommand("Input.cancelDragging")),await Promise.all(f)}#m(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s);if(!e.pressed.has(i))return;let o=gr(s),a=wr(s);switch(i){case"Alt":e.alt=!1;break;case"Shift":e.shift=!1;break;case"Control":e.ctrl=!1;break;case"Meta":e.meta=!1;break}e.pressed.delete(i);let{modifiers:c}=e,d=an(i,e,r),u=cn(o??"",e)??d;return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:"keyUp",windowsVirtualKeyCode:yr[i],key:i,code:o,text:u,unmodifiedText:d,location:a<3?a:void 0,isSystemKey:e.alt||void 0,isKeypad:a===3,modifiers:c})}},an=(n,e,t)=>t?n:n==="Enter"?"\r":[...n].length===1?e.shift?n.toLocaleUpperCase("en-US"):n:void 0,cn=(n,e)=>{if(e.ctrl){switch(n){case"Digit2":if(e.shift)return"\0";break;case"KeyA":return"";case"KeyB":return"";case"KeyC":return"";case"KeyD":return"";case"KeyE":return"";case"KeyF":return"";case"KeyG":return"\x07";case"KeyH":return"\b";case"KeyI":return" ";case"KeyJ":return`
2
+ import{$ as cr,$a as Ai,A as P,Aa as lr,Ab as pr,B as q,Bb as Gi,C as Ct,Ca as Oi,Cb as Xi,D as hi,Dc as rn,F as pi,Fb as Ji,G as fi,Gb as Yi,H as ne,I as b,Ib as Zi,J as Ne,K as mi,La as E,Ma as j,N as _e,Na as Ni,Nb as Qi,Oa as _i,P as gi,Pa as fe,Q as Et,Qa as Bi,S as wi,Sb as en,T as yi,U as vi,V as xi,Z as Be,_a as Fi,a as or,aa as bi,b as re,ca as Ci,cb as oe,d as Re,db as Ui,e as Oe,ea as J,f as Ze,fa as Ei,fb as hr,g as ci,gb as Li,ha as dr,ia as Si,ib as Mi,j as di,ja as Fe,jb as qi,k as ui,kb as ji,la as Pi,mb as $i,n as li,na as ki,nb as ae,o as ar,oa as Ii,ob as Hi,p as ie,pa as Di,pb as zi,q as bt,qa as St,ra as Ti,sb as Wi,sc as tn,t as D,tc as sn,va as Pt,w as L,wa as Ri,wb as Ki,xb as Vi,ya as ur,yb as Qe,zb as et}from"./chunk-SQ6Y2ZMA.mjs";import"./chunk-Y34NR5JL.mjs";import"./chunk-YEY3RSFQ.mjs";import{b as xt,c as T}from"./chunk-W7XHE4CT.mjs";import"./chunk-UH4SIXTR.mjs";import{d as ai}from"./chunk-5L7RYZCL.mjs";var Ve={};ai(Ve,{BidiServer:()=>Fs,EventEmitter:()=>K,OutgoingMessage:()=>X});function nn(n){return{all:n=n||new Map,on:function(e,t){var s=n.get(e);s?s.push(t):n.set(e,[t])},off:function(e,t){var s=n.get(e);s&&(t?s.splice(s.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var s=n.get(e);s&&s.slice().map(function(r){r(t)}),(s=n.get("*"))&&s.slice().map(function(r){r(e,t)})}}}var K=class{#e=nn();on(e,t){return this.#e.on(e,t),this}once(e,t){let s=r=>{t(r),this.off(e,s)};return this.on(e,s)}off(e,t){return this.#e.off(e,t),this}emit(e,t){this.#e.emit(e,t)}removeAllListeners(e){return e?this.#e.all.delete(e):this.#e.all.clear(),this}};var S;(function(n){n.bidi="bidi",n.cdp="cdp",n.debug="debug",n.debugError="debug:error",n.debugInfo="debug:info",n.debugWarn="debug:warn"})(S||(S={}));var on,tt=class{static LOGGER_PREFIX=`${S.debug}:queue`;#e;#t;#s=[];#r=!1;constructor(e,t){this.#t=e,this.#e=t}add(e,t){this.#s.push([e,t]),this.#i()}async#i(){if(!this.#r){for(this.#r=!0;this.#s.length>0;){let e=this.#s.shift();if(!e)continue;let[t,s]=e;this.#e?.(on.LOGGER_PREFIX)?.("Processing event:",s),await t.then(r=>{if(r.kind==="error"){this.#e?.(S.debugError)?.("Event threw before sending:",r.error.message,r.error.stack);return}return this.#t(r.value)}).catch(r=>{this.#e?.(S.debugError)?.("Event was not processed:",r?.message)})}this.#r=!1}}};on=tt;var C={};ai(C,{BiDiModule:()=>kt,Bluetooth:()=>Ae,BrowsingContext:()=>Tt,EVENT_NAMES:()=>ro,Input:()=>Rt,Log:()=>Dt,Network:()=>Ot,Script:()=>It,Speculation:()=>Ue});var kt;(function(n){n.Bluetooth="bluetooth",n.Browser="browser",n.BrowsingContext="browsingContext",n.Cdp="goog:cdp",n.Input="input",n.Log="log",n.Network="network",n.Script="script",n.Session="session",n.Speculation="speculation"})(kt||(kt={}));var It;(function(n){let e;(function(t){t.Message="script.message",t.RealmCreated="script.realmCreated",t.RealmDestroyed="script.realmDestroyed"})(e=n.EventNames||(n.EventNames={}))})(It||(It={}));var Dt;(function(n){let e;(function(t){t.LogEntryAdded="log.entryAdded"})(e=n.EventNames||(n.EventNames={}))})(Dt||(Dt={}));var Tt;(function(n){let e;(function(t){t.ContextCreated="browsingContext.contextCreated",t.ContextDestroyed="browsingContext.contextDestroyed",t.DomContentLoaded="browsingContext.domContentLoaded",t.DownloadEnd="browsingContext.downloadEnd",t.DownloadWillBegin="browsingContext.downloadWillBegin",t.FragmentNavigated="browsingContext.fragmentNavigated",t.HistoryUpdated="browsingContext.historyUpdated",t.Load="browsingContext.load",t.NavigationAborted="browsingContext.navigationAborted",t.NavigationCommitted="browsingContext.navigationCommitted",t.NavigationFailed="browsingContext.navigationFailed",t.NavigationStarted="browsingContext.navigationStarted",t.UserPromptClosed="browsingContext.userPromptClosed",t.UserPromptOpened="browsingContext.userPromptOpened"})(e=n.EventNames||(n.EventNames={}))})(Tt||(Tt={}));var Rt;(function(n){let e;(function(t){t.FileDialogOpened="input.fileDialogOpened"})(e=n.EventNames||(n.EventNames={}))})(Rt||(Rt={}));var Ot;(function(n){let e;(function(t){t.AuthRequired="network.authRequired",t.BeforeRequestSent="network.beforeRequestSent",t.FetchError="network.fetchError",t.ResponseCompleted="network.responseCompleted",t.ResponseStarted="network.responseStarted"})(e=n.EventNames||(n.EventNames={}))})(Ot||(Ot={}));var Ae;(function(n){let e;(function(t){t.RequestDevicePromptUpdated="bluetooth.requestDevicePromptUpdated",t.GattConnectionAttempted="bluetooth.gattConnectionAttempted",t.CharacteristicEventGenerated="bluetooth.characteristicEventGenerated",t.DescriptorEventGenerated="bluetooth.descriptorEventGenerated"})(e=n.EventNames||(n.EventNames={}))})(Ae||(Ae={}));var Ue;(function(n){let e;(function(t){t.PrefetchStatusUpdated="speculation.prefetchStatusUpdated"})(e=n.EventNames||(n.EventNames={}))})(Ue||(Ue={}));var ro=new Set([...Object.values(kt),...Object.values(Ae.EventNames),...Object.values(Tt.EventNames),...Object.values(Rt.EventNames),...Object.values(Dt.EventNames),...Object.values(Ot.EventNames),...Object.values(It.EventNames),...Object.values(Ue.EventNames)]);var F=class extends Error{error;message;stacktrace;constructor(e,t,s){super(),this.error=e,this.message=t,this.stacktrace=s}toErrorResponse(e){return{type:"error",id:e,error:this.error,message:this.message,stacktrace:this.stacktrace}}},x=class extends F{constructor(e,t){super("invalid argument",e,t)}},xe=class extends F{constructor(e,t){super("invalid selector",e,t)}};var st=class extends F{constructor(e,t){super("move target out of bounds",e,t)}},Nt=class extends F{constructor(e,t){super("no such alert",e,t)}},ce=class extends F{constructor(e,t){super("no such element",e,t)}},V=class extends F{constructor(e,t){super("no such frame",e,t)}},rt=class extends F{constructor(e,t){super("no such handle",e,t)}},_t=class extends F{constructor(e,t){super("no such history entry",e,t)}},Bt=class extends F{constructor(e,t){super("no such intercept",e,t)}},Y=class extends F{constructor(e,t){super("no such node",e,t)}},Le=class extends F{constructor(e,t){super("no such request",e,t)}},it=class extends F{constructor(e,t){super("no such script",e,t)}},G=class extends F{constructor(e,t){super("no such user context",e,t)}};var Ft=class extends F{constructor(e,t){super("unknown command",e,t)}},O=class extends F{constructor(e,t=new Error().stack){super("unknown error",e,t)}},nt=class extends F{constructor(e,t){super("unable to capture screen",e,t)}};var R=class extends F{constructor(e,t){super("unsupported operation",e,t)}};var At=class extends F{constructor(e,t){super("unable to set cookie",e,t)}},be=class extends F{constructor(e,t){super("unable to set file input",e,t)}};var Ut=class extends F{constructor(e,t){super("invalid web extension",e,t)}},Lt=class extends F{constructor(e,t){super("no such web extension",e,t)}},Me=class extends F{constructor(e,t){super("no such network collector",e,t)}},me=class extends F{constructor(e,t){super("no such network data",e,t)}};var Mt=class{parseDisableSimulationParameters(e){return e}parseHandleRequestDevicePromptParams(e){return e}parseSimulateAdapterParameters(e){return e}parseSimulateAdvertisementParameters(e){return e}parseSimulateCharacteristicParameters(e){return e}parseSimulateCharacteristicResponseParameters(e){return e}parseSimulateDescriptorParameters(e){return e}parseSimulateDescriptorResponseParameters(e){return e}parseSimulateGattConnectionResponseParameters(e){return e}parseSimulateGattDisconnectionParameters(e){return e}parseSimulatePreconnectedPeripheralParameters(e){return e}parseSimulateServiceParameters(e){return e}parseCreateUserContextParameters(e){return e}parseRemoveUserContextParameters(e){return e}parseSetClientWindowStateParameters(e){return e}parseSetDownloadBehaviorParameters(e){return e}parseActivateParams(e){return e}parseCaptureScreenshotParams(e){return e}parseCloseParams(e){return e}parseCreateParams(e){return e}parseGetTreeParams(e){return e}parseHandleUserPromptParams(e){return e}parseLocateNodesParams(e){return e}parseNavigateParams(e){return e}parsePrintParams(e){return e}parseReloadParams(e){return e}parseSetBypassCspParams(e){return e}parseSetViewportParams(e){return e}parseStartScreencastParams(e){return e}parseStopScreencastParams(e){return e}parseTraverseHistoryParams(e){return e}parseGetSessionParams(e){return e}parseResolveRealmParams(e){return e}parseSendCommandParams(e){return e}parseSetClientHintsOverrideParams(e){return e}parseSetForcedColorsModeThemeOverrideParams(e){return e}parseSetGeolocationOverrideParams(e){return e}parseSetLocaleOverrideParams(e){return e}parseSetNetworkConditionsParams(e){return e}parseSetScreenOrientationOverrideParams(e){return e}parseSetScreenSettingsOverrideParams(e){return e}parseSetScriptingEnabledParams(e){return e}parseSetScrollbarTypeOverrideParams(e){return e}parseSetTimezoneOverrideParams(e){return e}parseSetTouchOverrideParams(e){return e}parseSetUserAgentOverrideParams(e){return e}parseAddPreloadScriptParams(e){return e}parseCallFunctionParams(e){return e}parseDisownParams(e){return e}parseEvaluateParams(e){return e}parseGetRealmsParams(e){return e}parseRemovePreloadScriptParams(e){return e}parsePerformActionsParams(e){return e}parseReleaseActionsParams(e){return e}parseSetFilesParams(e){return e}parseAddDataCollectorParams(e){return e}parseAddInterceptParams(e){return e}parseContinueRequestParams(e){return e}parseContinueResponseParams(e){return e}parseContinueWithAuthParams(e){return e}parseDisownDataParams(e){return e}parseFailRequestParams(e){return e}parseGetDataParams(e){return e}parseProvideResponseParams(e){return e}parseRemoveDataCollectorParams(e){return e}parseRemoveInterceptParams(e){return e}parseSetCacheBehaviorParams(e){return e}parseSetExtraHeadersParams(e){return e}parseSetPermissionsParams(e){return e}parseSubscribeParams(e){return e}parseUnsubscribeParams(e){return e}parseDeleteCookiesParams(e){return e}parseGetCookiesParams(e){return e}parseSetCookieParams(e){return e}parseInstallParams(e){return e}parseUninstallParams(e){return e}parseSetVirtualWalletBehaviorParams(e){return e}};var qt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}close(){return setTimeout(()=>this.#e.sendCommand("Browser.close").catch(()=>{}),0),{}}async createUserContext(e){let t=e,s=this.#s.getGlobalConfig();if(t.acceptInsecureCerts!==void 0&&t.acceptInsecureCerts===!1&&s.acceptInsecureCerts===!0)throw new O(`Cannot set user context's "acceptInsecureCerts" to false, when a capability "acceptInsecureCerts" is set to true`);let r={};if(t.proxy){let o=no(t.proxy);o&&(r.proxyServer=o),t.proxy.noProxy&&(r.proxyBypassList=t.proxy.noProxy.join(","))}else{e["goog:proxyServer"]!==void 0&&(r.proxyServer=e["goog:proxyServer"]);let o=e["goog:proxyBypassList"]??void 0;o&&(r.proxyBypassList=o.join(","))}let i=await this.#e.sendCommand("Target.createBrowserContext",r);return await this.#a(s.downloadBehavior??null,i.browserContextId),this.#s.updateUserContextConfig(i.browserContextId,{acceptInsecureCerts:e.acceptInsecureCerts,userPromptHandler:e.unhandledPromptBehavior}),{userContext:i.browserContextId}}async removeUserContext(e){let t=e.userContext;if(t==="default")throw new x("`default` user context cannot be removed");try{await this.#e.sendCommand("Target.disposeBrowserContext",{browserContextId:t})}catch(s){throw s.message.startsWith("Failed to find context with id")?new G(s.message):s}return{}}async getUserContexts(){return{userContexts:await this.#r.getUserContexts()}}async#i(e){let t=await this.#e.sendCommand("Browser.getWindowForTarget",{targetId:e});return{active:!1,clientWindow:`${t.windowId}`,state:t.bounds.windowState??"normal",height:t.bounds.height??0,width:t.bounds.width??0,x:t.bounds.left??0,y:t.bounds.top??0}}async setClientWindowState(e){let{clientWindow:t}=e,s={windowState:e.state};e.state==="normal"&&(e.width!==void 0&&(s.width=e.width),e.height!==void 0&&(s.height=e.height),e.x!==void 0&&(s.left=e.x),e.y!==void 0&&(s.top=e.y));let r=Number.parseInt(t);if(isNaN(r))throw new x("no such client window");await this.#e.sendCommand("Browser.setWindowBounds",{windowId:r,bounds:s});let i=await this.#e.sendCommand("Browser.getWindowBounds",{windowId:r});return{active:!1,clientWindow:`${r}`,state:i.bounds.windowState??"normal",height:i.bounds.height??0,width:i.bounds.width??0,x:i.bounds.left??0,y:i.bounds.top??0}}async getClientWindows(){let e=this.#t.getTopLevelContexts().map(i=>i.cdpTarget.id),t=await Promise.all(e.map(async i=>await this.#i(i))),s=new Set,r=new Array;for(let i of t)s.has(i.clientWindow)||(s.add(i.clientWindow),r.push(i));return{clientWindows:r}}#o(e){if(e===null)return{behavior:"default"};if(e?.type==="denied")return{behavior:"deny"};if(e?.type==="allowed")return{behavior:"allow",downloadPath:e.destinationFolder};throw new O("Unexpected download behavior")}async#a(e,t){await this.#e.sendCommand("Browser.setDownloadBehavior",{...this.#o(e),browserContextId:t==="default"?void 0:t,eventsEnabled:!0})}async setDownloadBehavior(e){let t;return e.userContexts===void 0?t=(await this.#r.getUserContexts()).map(s=>s.userContext):t=Array.from(await this.#r.verifyUserContextIdList(e.userContexts)),e.userContexts===void 0?this.#s.updateGlobalConfig({downloadBehavior:e.downloadBehavior}):e.userContexts.map(s=>this.#s.updateUserContextConfig(s,{downloadBehavior:e.downloadBehavior})),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(void 0,s).downloadBehavior??null;await this.#a(r,s)})),{}}};function no(n){if(!(n.proxyType==="direct"||n.proxyType==="system")){if(n.proxyType==="pac")throw new R("PAC proxy configuration is not supported per user context");if(n.proxyType==="autodetect")throw new R("Autodetect proxy is not supported per user context");if(n.proxyType==="manual"){let e=[];if(n.httpProxy!==void 0&&e.push(`http=${n.httpProxy}`),n.sslProxy!==void 0&&e.push(`https=${n.sslProxy}`),n.socksProxy!==void 0||n.socksVersion!==void 0){if(n.socksProxy===void 0)throw new x("'socksVersion' cannot be set without 'socksProxy'");if(n.socksVersion===void 0||typeof n.socksVersion!="number"||!Number.isInteger(n.socksVersion)||n.socksVersion<0||n.socksVersion>255)throw new x("'socksVersion' must be between 0 and 255");e.push(`socks=socks${n.socksVersion}://${n.socksProxy}`)}return e.length===0?void 0:e.join(";")}throw new O("Unknown proxy type")}}var jt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}getSession(e){let t=e.context,s=this.#e.getContext(t).cdpTarget.cdpSessionId;return s===void 0?{}:{session:s}}resolveRealm(e){let t=e.realm,s=this.#t.getRealm({realmId:t});if(s===void 0)throw new O(`Could not find realm ${e.realm}`);return{executionContextId:s.executionContextId}}async sendCommand(e){return{result:await(e.session?this.#s.getCdpClient(e.session):this.#r).sendCommand(e.method,e.params),session:e.session}}};var $t=class{#e;#t;#s;#r;#i;constructor(e,t,s,r,i){this.#s=r,this.#i=s,this.#e=e,this.#t=t,this.#r=i,this.#r.addSubscribeHook(C.BrowsingContext.EventNames.ContextCreated,this.#a.bind(this))}getTree(e){return{contexts:(e.root===void 0?this.#t.getTopLevelContexts():[this.#t.getContext(e.root)]).map(s=>s.serializeToBidiValue(e.maxDepth??Number.MAX_VALUE))}}async create(e){let t,s="default";if(e.referenceContext!==void 0){if(t=this.#t.getContext(e.referenceContext),!t.isTopLevelContext())throw new x("referenceContext should be a top-level context");s=t.userContext}e.userContext!==void 0&&(s=e.userContext);let r=this.#t.getAllContexts().filter(c=>c.userContext===s),i=!1;switch(e.type){case"tab":i=!1;break;case"window":i=!0;break}r.length||(i=!0);let o;try{o=await this.#e.sendCommand("Target.createTarget",{url:"about:blank",newWindow:i,browserContextId:s==="default"?void 0:s,background:e.background===!0})}catch(c){throw c.message.startsWith("Failed to find browser context with id")||c.message==="browserContextId"?new G(`The context ${s} was not found`):c}let a=await this.#t.waitForContext(o.targetId);return await a.lifecycleLoaded(),{context:a.id}}navigate(e){return this.#t.getContext(e.context).navigate(e.url,e.wait??"none")}reload(e){return this.#t.getContext(e.context).reload(e.ignoreCache??!1,e.wait??"none")}async activate(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x("Activation is only supported on the top-level context");return await t.activate(),{}}async captureScreenshot(e){return await this.#t.getContext(e.context).captureScreenshot(e)}async print(e){return await this.#t.getContext(e.context).print(e)}async setViewport(e){if((e.viewport?.height??0)>1e7||(e.viewport?.width??0)>1e7)throw new R("Viewport dimension over 10000000 are not supported");let s={};e.devicePixelRatio!==void 0&&(s.devicePixelRatio=e.devicePixelRatio),e.viewport!==void 0&&(s.viewport=e.viewport);let r=await this.#o(e.context,e.userContexts);for(let i of e.userContexts??[])this.#s.updateUserContextConfig(i,s);return e.context!==void 0&&this.#s.updateBrowsingContextConfig(e.context,s),await Promise.all(r.map(async i=>{let o=this.#s.getActiveConfig(i.id,i.userContext);await i.setViewport(o.viewport??null,o.devicePixelRatio??null,o.screenOrientation??null)})),{}}async#o(e,t){if(e===void 0&&t===void 0)throw new x("Either userContexts or context must be provided");if(e!==void 0&&t!==void 0)throw new x("userContexts and context are mutually exclusive");if(e!==void 0){let r=this.#t.getContext(e);if(!r.isTopLevelContext())throw new x("Emulating viewport is only supported on the top-level context");return[r]}await this.#i.verifyUserContextIdList(t);let s=[];for(let r of t){let i=this.#t.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}return[...new Set(s).values()]}async traverseHistory(e){let t=this.#t.getContext(e.context);if(!t)throw new x(`No browsing context with id ${e.context}`);if(!t.isTopLevelContext())throw new x("Traversing history is only supported on the top-level context");return await t.traverseHistory(e.delta),{}}async handleUserPrompt(e){let t=this.#t.getContext(e.context);try{await t.handleUserPrompt(e.accept,e.userText)}catch(s){throw s.message?.includes("No dialog is showing")?new Nt("No dialog is showing"):s}return{}}async close(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x(`Non top-level browsing context ${t.id} cannot be closed.`);let s=t.cdpTarget.parentCdpClient;try{let r=new Promise(i=>{let o=a=>{a.targetId===e.context&&(s.off("Target.detachedFromTarget",o),i())};s.on("Target.detachedFromTarget",o)});try{e.promptUnload?await t.close():await s.sendCommand("Target.closeTarget",{targetId:e.context})}catch(i){if(!s.isCloseError(i))throw i}await r}catch(r){if(!(r.code===-32e3&&r.message==="Not attached to an active page"))throw r}return{}}async locateNodes(e){return await this.#t.getContext(e.context).locateNodes(e)}#a(e){return[this.#t.getContext(e),...this.#t.getContext(e).allChildren].forEach(r=>{this.#r.registerEvent({type:"event",method:C.BrowsingContext.EventNames.ContextCreated,params:r.serializeToBidiValue()},r.id)}),Promise.resolve()}};var Ht=class{#e;#t;#s;constructor(e,t,s){this.#e=t,this.#t=e,this.#s=s}async setGeolocationOverride(e){if("coordinates"in e&&"error"in e)throw new x("Coordinates and error cannot be set at the same time");let t=null;if("coordinates"in e){if((e.coordinates?.altitude??null)===null&&(e.coordinates?.altitudeAccuracy??null)!==null)throw new x("Geolocation altitudeAccuracy can be set only with altitude");t=e.coordinates}else if("error"in e){if(e.error.type!=="positionUnavailable")throw new x(`Unknown geolocation error ${e.error.type}`);t=e.error}else throw new x("Coordinates or error should be set");let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{geolocation:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{geolocation:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setGeolocationOverride(i.geolocation??null)})),{}}async setLocaleOverride(e){let t=e.locale??null;if(t!==null&&!oo(t))throw new x(`Invalid locale "${t}"`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{locale:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{locale:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await Promise.all([r.setLocaleOverride(i.locale??null),r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)])})),{}}async setScriptingEnabled(e){let t=e.enabled,s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{scriptingEnabled:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{scriptingEnabled:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setScriptingEnabled(i.scriptingEnabled??null)})),{}}async setScrollbarTypeOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{scrollbarType:e.scrollbarType});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{scrollbarType:e.scrollbarType});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setScrollbarTypeOverride(r.scrollbarType??null)})),{}}async setScreenOrientationOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenOrientation:e.screenOrientation});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenOrientation:e.screenOrientation});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async setScreenSettingsOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenArea:e.screenArea});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenArea:e.screenArea});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async#r(e,t,s=!1){if(e===void 0&&t===void 0){if(s)return this.#t.getTopLevelContexts();throw new x("Either user contexts or browsing contexts must be provided")}if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let r=[];if(e===void 0){if(t.length===0)throw new x("user context should be provided");await this.#e.verifyUserContextIdList(t);for(let i of t){let o=this.#t.getTopLevelContexts().filter(a=>a.userContext===i);r.push(...o)}}else{if(e.length===0)throw new x("browsing context should be provided");for(let i of e){let o=this.#t.getContext(i);if(!o.isTopLevelContext())throw new x("The command is only supported on the top-level context");r.push(o)}}return[...new Set(r).values()]}async setTimezoneOverride(e){let t=e.timezone??null;if(t!==null&&!ao(t))throw new x(`Invalid timezone "${t}"`);t!==null&&co(t)&&(t=`GMT${t}`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{timezone:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{timezone:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTimezoneOverride(i.timezone??null)})),{}}async setTouchOverride(e){let t=e.maxTouchPoints,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{maxTouchPoints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{maxTouchPoints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({maxTouchPoints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTouchOverride(i.maxTouchPoints??null)})),{}}async setUserAgentOverrideParams(e){if(e.userAgent==="")throw new R("empty user agent string is not supported");let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{userAgent:e.userAgent});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{userAgent:e.userAgent});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({userAgent:e.userAgent}),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setUserAgentAndAcceptLanguage(r.userAgent,r.locale,r.clientHints)})),{}}async setClientHintsOverride(e){let t=e.clientHints??null,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{clientHints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{clientHints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({clientHints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)})),{}}async setNetworkConditions(e){let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{emulatedNetworkConditions:e.networkConditions});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{emulatedNetworkConditions:e.networkConditions});if(e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({emulatedNetworkConditions:e.networkConditions}),e.networkConditions!==null&&e.networkConditions.type!=="offline")throw new R(`Unsupported network conditions ${e.networkConditions.type}`);return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setEmulatedNetworkConditions(r.emulatedNetworkConditions??null)})),{}}};function oo(n){try{return new Intl.Locale(n),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function ao(n){try{return Intl.DateTimeFormat(void 0,{timeZone:n}),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function co(n){return/^[+-](?:2[0-3]|[01]\d)(?::[0-5]\d)?$/.test(n)}function _(n,e){if(!n)throw new Error(e??"Internal assertion failed.")}function fr(n){return zt(n)&&n.length>1}function zt(n){return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].length===1}var Wt=class{type="none"},ot=class{type="key";pressed=new Set;#e=0;get modifiers(){return this.#e}get alt(){return(this.#e&1)===1}set alt(e){this.#t(e,1)}get ctrl(){return(this.#e&2)===2}set ctrl(e){this.#t(e,2)}get meta(){return(this.#e&4)===4}set meta(e){this.#t(e,4)}get shift(){return(this.#e&8)===8}set shift(e){this.#t(e,8)}#t(e,t){e?this.#e|=t:this.#e&=~t}},Kt=class n{static#e=500;static#t=2;count=0;#s;#r;#i;constructor(e,t,s){this.#s=e,this.#r=t,this.#i=s}compare(e){return e.#i-this.#i>n.#e||Math.abs(e.#s-this.#s)>n.#t||Math.abs(e.#r-this.#r)>n.#t}},Vt=class{type="pointer";subtype;pointerId;pressed=new Set;x=0;y=0;radiusX;radiusY;force;constructor(e,t){this.pointerId=e,this.subtype=t}get buttons(){let e=0;for(let t of this.pressed)switch(t){case 0:e|=1;break;case 1:e|=4;break;case 2:e|=2;break;case 3:e|=8;break;case 4:e|=16;break}return e}#e=new Map;setClickCount(e,t){let s=this.#e.get(e);return(!s||s.compare(t))&&(s=t),++s.count,this.#e.set(e,s),s.count}getClickCount(e){return this.#e.get(e)?.count??0}resetClickCount(){this.#e=new Map}},Gt=class{type="wheel"};function mr(n){switch(n){case"\uE000":return"Unidentified";case"\uE001":return"Cancel";case"\uE002":return"Help";case"\uE003":return"Backspace";case"\uE004":return"Tab";case"\uE005":return"Clear";case"\uE006":case"\uE007":return"Enter";case"\uE008":return"Shift";case"\uE009":return"Control";case"\uE00A":return"Alt";case"\uE00B":return"Pause";case"\uE00C":return"Escape";case"\uE00D":return" ";case"\uE00E":return"PageUp";case"\uE00F":return"PageDown";case"\uE010":return"End";case"\uE011":return"Home";case"\uE012":return"ArrowLeft";case"\uE013":return"ArrowUp";case"\uE014":return"ArrowRight";case"\uE015":return"ArrowDown";case"\uE016":return"Insert";case"\uE017":return"Delete";case"\uE018":return";";case"\uE019":return"=";case"\uE01A":return"0";case"\uE01B":return"1";case"\uE01C":return"2";case"\uE01D":return"3";case"\uE01E":return"4";case"\uE01F":return"5";case"\uE020":return"6";case"\uE021":return"7";case"\uE022":return"8";case"\uE023":return"9";case"\uE024":return"*";case"\uE025":return"+";case"\uE026":return",";case"\uE027":return"-";case"\uE028":return".";case"\uE029":return"/";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE03D":return"Meta";case"\uE040":return"ZenkakuHankaku";case"\uE050":return"Shift";case"\uE051":return"Control";case"\uE052":return"Alt";case"\uE053":return"Meta";case"\uE054":return"PageUp";case"\uE055":return"PageDown";case"\uE056":return"End";case"\uE057":return"Home";case"\uE058":return"ArrowLeft";case"\uE059":return"ArrowUp";case"\uE05A":return"ArrowRight";case"\uE05B":return"ArrowDown";case"\uE05C":return"Insert";case"\uE05D":return"Delete";default:return n}}function gr(n){switch(n){case"`":case"~":return"Backquote";case"\\":case"|":return"Backslash";case"\uE003":return"Backspace";case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case",":case"<":return"Comma";case"0":case")":return"Digit0";case"1":case"!":return"Digit1";case"2":case"@":return"Digit2";case"3":case"#":return"Digit3";case"4":case"$":return"Digit4";case"5":case"%":return"Digit5";case"6":case"^":return"Digit6";case"7":case"&":return"Digit7";case"8":case"*":return"Digit8";case"9":case"(":return"Digit9";case"=":case"+":return"Equal";case">":return"IntlBackslash";case"a":case"A":return"KeyA";case"b":case"B":return"KeyB";case"c":case"C":return"KeyC";case"d":case"D":return"KeyD";case"e":case"E":return"KeyE";case"f":case"F":return"KeyF";case"g":case"G":return"KeyG";case"h":case"H":return"KeyH";case"i":case"I":return"KeyI";case"j":case"J":return"KeyJ";case"k":case"K":return"KeyK";case"l":case"L":return"KeyL";case"m":case"M":return"KeyM";case"n":case"N":return"KeyN";case"o":case"O":return"KeyO";case"p":case"P":return"KeyP";case"q":case"Q":return"KeyQ";case"r":case"R":return"KeyR";case"s":case"S":return"KeyS";case"t":case"T":return"KeyT";case"u":case"U":return"KeyU";case"v":case"V":return"KeyV";case"w":case"W":return"KeyW";case"x":case"X":return"KeyX";case"y":case"Y":return"KeyY";case"z":case"Z":return"KeyZ";case"-":case"_":return"Minus";case".":return"Period";case"'":case'"':return"Quote";case";":case":":return"Semicolon";case"/":case"?":return"Slash";case"\uE00A":return"AltLeft";case"\uE052":return"AltRight";case"\uE009":return"ControlLeft";case"\uE051":return"ControlRight";case"\uE006":return"Enter";case"\uE00B":return"Pause";case"\uE03D":return"MetaLeft";case"\uE053":return"MetaRight";case"\uE008":return"ShiftLeft";case"\uE050":return"ShiftRight";case" ":case"\uE00D":return"Space";case"\uE004":return"Tab";case"\uE017":return"Delete";case"\uE010":return"End";case"\uE002":return"Help";case"\uE011":return"Home";case"\uE016":return"Insert";case"\uE00F":return"PageDown";case"\uE00E":return"PageUp";case"\uE015":return"ArrowDown";case"\uE012":return"ArrowLeft";case"\uE014":return"ArrowRight";case"\uE013":return"ArrowUp";case"\uE00C":return"Escape";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE019":return"NumpadEqual";case"\uE01A":case"\uE05C":return"Numpad0";case"\uE01B":case"\uE056":return"Numpad1";case"\uE01C":case"\uE05B":return"Numpad2";case"\uE01D":case"\uE055":return"Numpad3";case"\uE01E":case"\uE058":return"Numpad4";case"\uE01F":return"Numpad5";case"\uE020":case"\uE05A":return"Numpad6";case"\uE021":case"\uE057":return"Numpad7";case"\uE022":case"\uE059":return"Numpad8";case"\uE023":case"\uE054":return"Numpad9";case"\uE025":return"NumpadAdd";case"\uE026":return"NumpadComma";case"\uE028":case"\uE05D":return"NumpadDecimal";case"\uE029":return"NumpadDivide";case"\uE007":return"NumpadEnter";case"\uE024":return"NumpadMultiply";case"\uE027":return"NumpadSubtract";default:return}}function wr(n){switch(n){case"\uE007":case"\uE008":case"\uE009":case"\uE00A":case"\uE03D":return 1;case"\uE019":case"\uE01A":case"\uE01B":case"\uE01C":case"\uE01D":case"\uE01E":case"\uE01F":case"\uE020":case"\uE021":case"\uE022":case"\uE023":case"\uE024":case"\uE025":case"\uE026":case"\uE027":case"\uE028":case"\uE029":case"\uE054":case"\uE055":case"\uE056":case"\uE057":case"\uE058":case"\uE059":case"\uE05A":case"\uE05B":case"\uE05C":case"\uE05D":return 3;case"\uE050":case"\uE051":case"\uE052":case"\uE053":return 2;default:return 0}}var yr={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,Abort:3,Help:6,Backspace:8,Tab:9,Numpad5:12,NumpadEnter:13,Enter:13,"\\r":13,"\\n":13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Convert:28,NonConvert:29,Space:32,Numpad9:33,PageUp:33,Numpad3:34,PageDown:34,End:35,Numpad1:35,Home:36,Numpad7:36,ArrowLeft:37,Numpad4:37,Numpad8:38,ArrowUp:38,ArrowRight:39,Numpad6:39,Numpad2:40,ArrowDown:40,Select:41,Open:43,PrintScreen:44,Insert:45,Numpad0:45,Delete:46,NumpadDecimal:46,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,KeyA:65,KeyB:66,KeyC:67,KeyD:68,KeyE:69,KeyF:70,KeyG:71,KeyH:72,KeyI:73,KeyJ:74,KeyK:75,KeyL:76,KeyM:77,KeyN:78,KeyO:79,KeyP:80,KeyQ:81,KeyR:82,KeyS:83,KeyT:84,KeyU:85,KeyV:86,KeyW:87,KeyX:88,KeyY:89,KeyZ:90,MetaLeft:91,MetaRight:92,ContextMenu:93,NumpadMultiply:106,NumpadAdd:107,NumpadSubtract:109,NumpadDivide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NumLock:144,ScrollLock:145,AudioVolumeMute:173,AudioVolumeDown:174,AudioVolumeUp:175,MediaTrackNext:176,MediaTrackPrevious:177,MediaStop:178,MediaPlayPause:179,Semicolon:186,Equal:187,NumpadEqual:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222,AltGraph:225,Props:247,Cancel:3,Clear:12,Shift:16,Control:17,Alt:18,Accept:30,ModeChange:31," ":32,Print:42,Execute:43,"\\u0000":46,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,Meta:91,"*":106,"+":107,"-":109,"/":111,";":186,"=":187,",":188,".":190,"`":192,"[":219,"\\\\":220,"]":221,"'":222,Attn:246,CrSel:247,ExSel:248,EraseEof:249,Play:250,ZoomOut:251,")":48,"!":49,"@":50,"#":51,$:52,"%":53,"^":54,"&":55,"(":57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,":":186,"<":188,_:189,">":190,"?":191,"~":192,"{":219,"|":220,"}":221,'"':222,Camera:44,EndCall:95,VolumeDown:182,VolumeUp:183};var uo=(n=>{let e=n.getClientRects()[0],t=Math.max(0,Math.min(e.x,e.x+e.width)),s=Math.min(window.innerWidth,Math.max(e.x,e.x+e.width)),r=Math.max(0,Math.min(e.y,e.y+e.height)),i=Math.min(window.innerHeight,Math.max(e.y,e.y+e.height));return[t+(s-t>>1),r+(i-r>>1)]}).toString(),lo=(()=>navigator.platform.toLowerCase().includes("mac")).toString();async function ho(n,e){let s=await(await n.getOrCreateHiddenSandbox()).callFunction(uo,!1,{type:"undefined"},[e]);if(s.type==="exception")throw new ce(`Origin element ${e.sharedId} was not found`);_(s.result.type==="array"),_(s.result.value?.[0]?.type==="number"),_(s.result.value?.[1]?.type==="number");let{result:{value:[{value:r},{value:i}]}}=s;return{x:r,y:i}}var Ce=class{static isMacOS=async e=>{let s=await(await e.getOrCreateHiddenSandbox()).callFunction(lo,!1);return _(s.type!=="exception"),_(s.result.type==="boolean"),s.result.value};#e;#t=0;#s=0;#r;#i;#o;constructor(e,t,s,r){this.#e=t,this.#r=e,this.#i=s,this.#o=r}get#a(){return this.#e.getContext(this.#i)}async dispatchActions(e){await this.#r.queue.run(async()=>{for(let t of e)await this.dispatchTickActions(t)})}async dispatchTickActions(e){this.#t=performance.now(),this.#s=0;for(let{action:s}of e)"duration"in s&&s.duration!==void 0&&(this.#s=Math.max(this.#s,s.duration));let t=[new Promise(s=>setTimeout(s,this.#s))];for(let s of e)t.push(this.#d(s));await Promise.all(t)}async#d({id:e,action:t}){let s=this.#r.get(e),r=this.#r.getGlobalKeyState();switch(t.type){case"keyDown":{await this.#u(s,t),this.#r.cancelList.push({id:e,action:{...t,type:"keyUp"}});break}case"keyUp":{await this.#m(s,t);break}case"pause":break;case"pointerDown":{await this.#n(s,r,t),this.#r.cancelList.push({id:e,action:{...t,type:"pointerUp"}});break}case"pointerMove":{await this.#h(s,r,t);break}case"pointerUp":{await this.#l(s,r,t);break}case"scroll":{await this.#p(s,r,t);break}}}async#n(e,t,s){let{button:r}=s;if(e.pressed.has(r))return;e.pressed.add(r);let{x:i,y:o,subtype:a}=e,{width:c,height:d,pressure:u,twist:l,tangentialPressure:y}=s,{tiltX:f,tiltY:h}=dn(s),{modifiers:p}=t,{radiusX:m,radiusY:v}=un(c??1,d??1);switch(a){case"mouse":case"pen":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:o,modifiers:p,button:Xt(r),buttons:e.buttons,clickCount:e.setClickCount(r,new Kt(i,o,performance.now())),pointerType:a,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u});break;case"touch":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchStart",touchPoints:[{x:i,y:o,radiusX:m,radiusY:v,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u,id:e.pointerId}],modifiers:p});break}e.radiusX=m,e.radiusY=v,e.force=u}#l(e,t,s){let{button:r}=s;if(!e.pressed.has(r))return;e.pressed.delete(r);let{x:i,y:o,force:a,radiusX:c,radiusY:d,subtype:u}=e,{modifiers:l}=t;switch(u){case"mouse":case"pen":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:o,modifiers:l,button:Xt(r),buttons:e.buttons,clickCount:e.getClickCount(r),pointerType:u});case"touch":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchEnd",touchPoints:[{x:i,y:o,id:e.pointerId,force:a,radiusX:c,radiusY:d}],modifiers:l})}}async#h(e,t,s){let{x:r,y:i,subtype:o}=e,{width:a,height:c,pressure:d,twist:u,tangentialPressure:l,x:y,y:f,origin:h="viewport",duration:p=this.#s}=s,{tiltX:m,tiltY:v}=dn(s),{radiusX:I,radiusY:B}=un(a??1,c??1),{targetX:U,targetY:he}=await this.#f(h,y,f,r,i);if(U<0||he<0)throw new st(`Cannot move beyond viewport (x: ${U}, y: ${he})`);let Ie;do{let De=p>0?(performance.now()-this.#t)/p:1;Ie=De>=1;let Q,ee;if(Ie?(Q=U,ee=he):(Q=Math.round(De*(U-r)+r),ee=Math.round(De*(he-i)+i)),e.x!==Q||e.y!==ee){let{modifiers:Te}=t;switch(o){case"mouse":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d});break;case"pen":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d??.5});break;case"touch":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchMove",touchPoints:[{x:Q,y:ee,radiusX:I,radiusY:B,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d,id:e.pointerId}],modifiers:Te});break}e.x=Q,e.y=ee,e.radiusX=I,e.radiusY=B,e.force=d}}while(!Ie)}async#c(){if(this.#a.id===this.#a.cdpTarget.id)return{x:0,y:0};let{backendNodeId:e}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getFrameOwner",{frameId:this.#a.id}),{model:t}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getBoxModel",{backendNodeId:e});return{x:t.content[0],y:t.content[1]}}async#f(e,t,s,r,i){let o,a,c=await this.#c();switch(e){case"viewport":o=t+c.x,a=s+c.y;break;case"pointer":o=r+t+c.x,a=i+s+c.y;break;default:{let{x:d,y:u}=await ho(this.#a,e.element);o=d+t+c.x,a=u+s+c.y;break}}return{targetX:o,targetY:a}}async#p(e,t,s){let{deltaX:r,deltaY:i,x:o,y:a,origin:c="viewport",duration:d=this.#s}=s;if(c==="pointer")throw new x('"pointer" origin is invalid for scrolling.');let{targetX:u,targetY:l}=await this.#f(c,o,a,0,0);if(u<0||l<0)throw new st(`Cannot move beyond viewport (x: ${u}, y: ${l})`);let y=0,f=0,h;do{let p=d>0?(performance.now()-this.#t)/d:1;h=p>=1;let m,v;if(h?(m=r-y,v=i-f):(m=Math.round(p*r-y),v=Math.round(p*i-f)),m!==0||v!==0){let{modifiers:I}=t;await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseWheel",deltaX:m,deltaY:v,x:u,y:l,modifiers:I}),y+=m,f+=v}}while(!h)}async#u(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s),o=e.pressed.has(i),a=gr(s),c=wr(s);switch(i){case"Alt":e.alt=!0;break;case"Shift":e.shift=!0;break;case"Control":e.ctrl=!0;break;case"Meta":e.meta=!0;break}e.pressed.add(i);let{modifiers:d}=e,u=an(i,e,r),l=cn(a??"",e)??u,y;if(this.#o&&e.meta)switch(a){case"KeyA":y="SelectAll";break;case"KeyC":y="Copy";break;case"KeyV":y=e.shift?"PasteAndMatchStyle":"Paste";break;case"KeyX":y="Cut";break;case"KeyZ":y=e.shift?"Redo":"Undo";break;default:}let f=[this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:l?"keyDown":"rawKeyDown",windowsVirtualKeyCode:yr[i],key:i,code:a,text:l,unmodifiedText:u,autoRepeat:o,isSystemKey:e.alt||void 0,location:c<3?c:void 0,isKeypad:c===3,modifiers:d,commands:y?[y]:void 0})];i==="Escape"&&!e.alt&&(this.#o&&!e.ctrl&&!e.meta||!this.#o)&&f.push(this.#a.cdpTarget.cdpClient.sendCommand("Input.cancelDragging")),await Promise.all(f)}#m(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s);if(!e.pressed.has(i))return;let o=gr(s),a=wr(s);switch(i){case"Alt":e.alt=!1;break;case"Shift":e.shift=!1;break;case"Control":e.ctrl=!1;break;case"Meta":e.meta=!1;break}e.pressed.delete(i);let{modifiers:c}=e,d=an(i,e,r),u=cn(o??"",e)??d;return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:"keyUp",windowsVirtualKeyCode:yr[i],key:i,code:o,text:u,unmodifiedText:d,location:a<3?a:void 0,isSystemKey:e.alt||void 0,isKeypad:a===3,modifiers:c})}},an=(n,e,t)=>t?n:n==="Enter"?"\r":[...n].length===1?e.shift?n.toLocaleUpperCase("en-US"):n:void 0,cn=(n,e)=>{if(e.ctrl){switch(n){case"Digit2":if(e.shift)return"\0";break;case"KeyA":return"";case"KeyB":return"";case"KeyC":return"";case"KeyD":return"";case"KeyE":return"";case"KeyF":return"";case"KeyG":return"\x07";case"KeyH":return"\b";case"KeyI":return" ";case"KeyJ":return`
3
3
  `;case"KeyK":return"\v";case"KeyL":return"\f";case"KeyM":return"\r";case"KeyN":return"";case"KeyO":return"";case"KeyP":return"";case"KeyQ":return"";case"KeyR":return"";case"KeyS":return"";case"KeyT":return"";case"KeyU":return"";case"KeyV":return"";case"KeyW":return"";case"KeyX":return"";case"KeyY":return"";case"KeyZ":return"";case"BracketLeft":return"\x1B";case"Backslash":return"";case"BracketRight":return"";case"Digit6":if(e.shift)return"";break;case"Minus":return""}return""}if(e.alt)return""};function Xt(n){switch(n){case 0:return"left";case 1:return"middle";case 2:return"right";case 3:return"back";case 4:return"forward";default:return"none"}}function dn(n){let e=n.altitudeAngle??Math.PI/2,t=n.azimuthAngle??0,s=0,r=0;if(e===0&&((t===0||t===2*Math.PI)&&(s=Math.PI/2),t===Math.PI/2&&(r=Math.PI/2),t===Math.PI&&(s=-Math.PI/2),t===3*Math.PI/2&&(r=-Math.PI/2),t>0&&t<Math.PI/2&&(s=Math.PI/2,r=Math.PI/2),t>Math.PI/2&&t<Math.PI&&(s=-Math.PI/2,r=Math.PI/2),t>Math.PI&&t<3*Math.PI/2&&(s=-Math.PI/2,r=-Math.PI/2),t>3*Math.PI/2&&t<2*Math.PI&&(s=Math.PI/2,r=-Math.PI/2)),e!==0){let o=Math.tan(e);s=Math.atan(Math.cos(t)/o),r=Math.atan(Math.sin(t)/o)}let i=180/Math.PI;return{tiltX:Math.round(s*i),tiltY:Math.round(r*i)}}function un(n,e){return{radiusX:n?n/2:.5,radiusY:e?e/2:.5}}var Jt=class{#e=!1;#t=[];acquire(){let e={resolved:!1};return this.#e?new Promise(t=>{this.#t.push(()=>t(this.#s.bind(this,e)))}):(this.#e=!0,Promise.resolve(this.#s.bind(this,e)))}#s(e){if(e.resolved)throw new Error("Cannot release more than once.");e.resolved=!0;let t=this.#t.shift();if(!t){this.#e=!1;return}t()}async run(e){let t=await this.acquire();try{return await e()}finally{t()}}};var Yt=class{cancelList=[];#e=new Map;#t=new Jt;getOrCreate(e,t,s){let r=this.#e.get(e);if(!r){switch(t){case"none":r=new Wt;break;case"key":r=new ot;break;case"pointer":{let i=s==="mouse"?0:2,o=new Set;for(let[,a]of this.#e)a.type==="pointer"&&o.add(a.pointerId);for(;o.has(i);)++i;r=new Vt(i,s);break}case"wheel":r=new Gt;break;default:throw new x(`Expected "none", "key", "pointer", or "wheel". Found unknown source type ${t}.`)}return this.#e.set(e,r),r}if(r.type!==t)throw new x(`Input source type of ${e} is ${r.type}, but received ${t}.`);return r}get(e){let t=this.#e.get(e);if(!t)throw new O("Internal error.");return t}getGlobalKeyState(){let e=new ot;for(let[,t]of this.#e)if(t.type==="key"){for(let s of t.pressed)e.pressed.add(s);e.alt||=t.alt,e.ctrl||=t.ctrl,e.meta||=t.meta,e.shift||=t.shift}return e}get queue(){return this.#t}};var Zt=class extends WeakMap{get(e){return _(e.isTopLevelContext()),this.has(e)||this.set(e,new Yt),super.get(e)}};var Qt=class{#e;#t=new Zt;constructor(e){this.#e=e}async performActions(e){let t=this.#e.getContext(e.context),s=this.#t.get(t.top),r=this.#s(e,s);return await new Ce(s,this.#e,e.context,await Ce.isMacOS(t).catch(()=>!1)).dispatchActions(r),{}}async releaseActions(e){let t=this.#e.getContext(e.context),s=t.top,r=this.#t.get(s);return await new Ce(r,this.#e,e.context,await Ce.isMacOS(t).catch(()=>!1)).dispatchTickActions(r.cancelList.reverse()),this.#t.delete(s),{}}async setFiles(e){let s=await this.#e.getContext(e.context).getOrCreateHiddenSandbox(),r;try{r=await s.callFunction(String(function(c){if(!(this instanceof HTMLInputElement))return this instanceof Element?1:0;if(this.type!=="file")return 2;if(this.disabled)return 3;if(c>1&&!this.multiple)return 4}),!1,e.element,[{type:"number",value:e.files.length}])}catch{throw new Y(`Could not find element ${e.element.sharedId}`)}if(_(r.type==="success"),r.result.type==="number")switch(r.result.value){case 0:throw new ce(`Could not find element ${e.element.sharedId}`);case 1:throw new be(`Element ${e.element.sharedId} is not a input`);case 2:throw new be(`Input element ${e.element.sharedId} is not a file type`);case 3:throw new be(`Input element ${e.element.sharedId} is disabled`);case 4:throw new be("Cannot set multiple files on a non-multiple input element")}if(e.files.length===0)return await s.callFunction(String(function(){if(this.files?.length===0){this.dispatchEvent(new Event("cancel",{bubbles:!0}));return}this.files=new DataTransfer().files,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0}))}),!1,e.element),{};let i=[];for(let a=0;a<e.files.length;++a){let c=await s.callFunction(String(function(y){return this.files?.item(y)}),!1,e.element,[{type:"number",value:0}],"root");if(_(c.type==="success"),c.result.type!=="object")break;let{handle:d}=c.result;_(d!==void 0);let{path:u}=await s.cdpClient.sendCommand("DOM.getFileInfo",{objectId:d});i.push(u),s.disown(d).catch(void 0)}i.sort();let o=[...e.files].sort();if(i.length!==e.files.length||o.some((a,c)=>i[c]!==a)){let{objectId:a}=await s.deserializeForCdp(e.element);_(a!==void 0),await s.cdpClient.sendCommand("DOM.setFileInputFiles",{files:e.files,objectId:a})}else await s.callFunction(String(function(){this.dispatchEvent(new Event("cancel",{bubbles:!0}))}),!1,e.element);return{}}#s(e,t){let s=[];for(let r of e.actions){switch(r.type){case"pointer":{r.parameters??={pointerType:"mouse"},r.parameters.pointerType??="mouse";let o=t.getOrCreate(r.id,"pointer",r.parameters.pointerType);if(o.subtype!==r.parameters.pointerType)throw new x(`Expected input source ${r.id} to be ${o.subtype}; got ${r.parameters.pointerType}.`);o.resetClickCount();break}default:t.getOrCreate(r.id,r.type)}let i=r.actions.map(o=>({id:r.id,action:o}));for(let o=0;o<i.length;o++)s.length===o&&s.push([]),s[o].push(i[o])}return s}};function ln(n){return"atob"in globalThis?globalThis.atob(n):Buffer.from(n,"base64").toString("ascii")}function vr(n){let e=n.reduce((t,s)=>`${t}${s.name}: ${s.value.value}\r
4
4
  `,"");return new TextEncoder().encode(e).length}function hn(n){return po(new TextEncoder().encode(n))}function po(n){let t=[];for(let r=0;r<n.length;r+=65534){let i=n.subarray(r,r+65534);t.push(String.fromCodePoint.apply(null,i))}let s=t.join("");return btoa(s)}function es(n){return n?Object.entries(n).map(([e,t])=>({name:e,value:{type:"string",value:t}})):[]}function ts(n){if(n!==void 0)return n.map(({name:e,value:t})=>({name:e,value:t.value}))}function pn(n){return n===void 0?void 0:{name:"Cookie",value:{type:"string",value:n.reduce((t,s,r)=>{r>0&&(t+=";");let i=s.value.type==="base64"?btoa(s.value.value):s.value.value;return t+=`${s.name}=${i}`,t},"")}}}function fn(n){switch(n){case"default":return"Default";case"cancel":return"CancelAuth";case"provideCredentials":return"ProvideCredentials"}}function at(n){let e={name:n.name,value:{type:"string",value:n.value},domain:n.domain,path:n.path,size:n.size,httpOnly:n.httpOnly,secure:n.secure,sameSite:n.sameSite===void 0?"none":fo(n.sameSite),...n.expires>=0?{expiry:Math.round(n.expires)}:void 0};return e["goog:session"]=n.session,e["goog:priority"]=n.priority,e["goog:sourceScheme"]=n.sourceScheme,e["goog:sourcePort"]=n.sourcePort,n.partitionKey!==void 0&&(e["goog:partitionKey"]=n.partitionKey),n.partitionKeyOpaque!==void 0&&(e["goog:partitionKeyOpaque"]=n.partitionKeyOpaque),e}function ss(n){return n.type==="base64"?ln(n.value):n.value}function mn(n,e){let t=ss(n.cookie.value),s={name:n.cookie.name,value:t,domain:n.cookie.domain,path:n.cookie.path??"/",secure:n.cookie.secure??!1,httpOnly:n.cookie.httpOnly??!1,...e.sourceOrigin!==void 0&&{partitionKey:{hasCrossSiteAncestor:!1,topLevelSite:e.sourceOrigin}},...n.cookie.expiry!==void 0&&{expires:n.cookie.expiry},...n.cookie.sameSite!==void 0&&{sameSite:mo(n.cookie.sameSite)}};return n.cookie["goog:url"]!==void 0&&(s.url=n.cookie["goog:url"]),n.cookie["goog:priority"]!==void 0&&(s.priority=n.cookie["goog:priority"]),n.cookie["goog:sourceScheme"]!==void 0&&(s.sourceScheme=n.cookie["goog:sourceScheme"]),n.cookie["goog:sourcePort"]!==void 0&&(s.sourcePort=n.cookie["goog:sourcePort"]),s}function fo(n){switch(n){case"Strict":return"strict";case"None":return"none";case"Lax":return"lax";default:return"lax"}}function mo(n){switch(n){case"none":return"None";case"strict":return"Strict";case"default":case"lax":return"Lax"}throw new x(`Unknown 'sameSite' value ${n}`)}function xr(n){return["ftp","file","http","https","ws","wss"].includes(n.replace(/:$/,""))}function go(n){return n.protocol.replace(/:$/,"")}function gn(n,e){let t=new URL(e);return!(n.protocol!==void 0&&n.protocol!==go(t)||n.hostname!==void 0&&n.hostname!==t.hostname||n.port!==void 0&&n.port!==t.port||n.pathname!==void 0&&n.pathname!==t.pathname||n.search!==void 0&&n.search!==t.search)}function wn(n){let e=0;for(let t of n)e+=atob(t.bytes??"").length;return e}function z(n,e=0){return!n||n<=0||n+e<=0?0:n+e}var je=class n{#e;#t;#s;#r;constructor(e,t,s,r){this.#s=s,this.#e=e,this.#t=t,this.#r=r}async addIntercept(e){this.#e.verifyTopLevelContextsList(e.contexts);let t=e.urlPatterns??[],s=n.parseUrlPatterns(t),r=this.#t.addIntercept({urlPatterns:s,phases:e.phases,contexts:e.contexts});return await this.#i(),{intercept:r}}async continueRequest(e){if(e.url!==void 0&&n.parseUrlString(e.url),e.method!==void 0&&!n.isMethodValid(e.method))throw new x(`Method '${e.method}' is invalid.`);e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["beforeRequestSent"]);try{await t.continueRequest(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async continueResponse(e){e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["authRequired","responseStarted"]);try{await t.continueResponse(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async continueWithAuth(e){let t=e.request;return await this.#a(t,["authRequired"]).continueWithAuth(e),{}}async failRequest({request:e}){let t=this.#o(e);if(t.interceptPhase==="authRequired")throw new x(`Request '${e}' in 'authRequired' phase cannot be failed`);if(!t.interceptPhase)throw new Le(`No blocked request found for network id '${e}'`);return await t.failRequest("Failed"),{}}async provideResponse(e){e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["beforeRequestSent","responseStarted","authRequired"]);try{await t.provideResponse(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async#i(){await Promise.all(this.#e.getAllContexts().map(e=>e.cdpTarget.toggleNetwork()))}async removeIntercept(e){return this.#t.removeIntercept(e.intercept),await this.#i(),{}}async setCacheBehavior(e){let t=this.#e.verifyTopLevelContextsList(e.contexts);if(t.size===0)return this.#t.defaultCacheBehavior=e.cacheBehavior,await Promise.all(this.#e.getAllContexts().map(r=>r.cdpTarget.toggleSetCacheDisabled())),{};let s=e.cacheBehavior==="bypass";return await Promise.all([...t.values()].map(r=>r.cdpTarget.toggleSetCacheDisabled(s))),{}}#o(e){let t=this.#t.getRequestById(e);if(!t)throw new Le(`Network request with ID '${e}' doesn't exist`);return t}#a(e,t){let s=this.#o(e);if(!s.interceptPhase)throw new Le(`No blocked request found for network id '${e}'`);if(s.interceptPhase&&!t.includes(s.interceptPhase))throw new x(`Blocked request for network id '${e}' is in '${s.interceptPhase}' phase`);return s}static validateHeaders(e){for(let t of e){let s;if(t.value.type==="string"?s=t.value.value:s=atob(t.value.value),s!==s.trim()||s.includes(`
5
5
  `)||s.includes("\0"))throw new x(`Header value '${s}' is not acceptable value`)}}static isMethodValid(e){return/^[!#$%&'*+\-.^_`|~a-zA-Z\d]+$/.test(e)}static parseUrlString(e){try{return new URL(e)}catch(t){throw new x(`Invalid URL '${e}': ${t}`)}}static parseUrlPatterns(e){return e.map(t=>{let s="",r=!0,i=!0,o=!0,a=!0,c=!0;switch(t.type){case"string":{s=qe(t.pattern);break}case"pattern":{if(t.protocol===void 0)r=!1,s+="http";else{if(t.protocol==="")throw new x("URL pattern must specify a protocol");if(t.protocol=qe(t.protocol),!t.protocol.match(/^[a-zA-Z+-.]+$/))throw new x("Forbidden characters");s+=t.protocol}let u=s.toLocaleLowerCase();if(s+=":",xr(u)&&(s+="//"),t.hostname===void 0)u!=="file"&&(s+="placeholder"),i=!1;else{if(t.hostname==="")throw new x("URL pattern must specify a hostname");if(t.protocol==="file")throw new x("URL pattern protocol cannot be 'file'");t.hostname=qe(t.hostname);let l=!1;for(let y of t.hostname){if(y==="/"||y==="?"||y==="#")throw new x("'/', '?', '#' are forbidden in hostname");if(!l&&y===":")throw new x("':' is only allowed inside brackets in hostname");y==="["&&(l=!0),y==="]"&&(l=!1)}s+=t.hostname}if(t.port===void 0)o=!1;else{if(t.port==="")throw new x("URL pattern must specify a port");if(t.port=qe(t.port),s+=":",!t.port.match(/^\d+$/))throw new x("Forbidden characters");s+=t.port}if(t.pathname===void 0)a=!1;else{if(t.pathname=qe(t.pathname),t.pathname[0]!=="/"&&(s+="/"),t.pathname.includes("#")||t.pathname.includes("?"))throw new x("Forbidden characters");s+=t.pathname}if(t.search===void 0)c=!1;else{if(t.search=qe(t.search),t.search[0]!=="?"&&(s+="?"),t.search.includes("#"))throw new x("Forbidden characters");s+=t.search}break}}let d=u=>{let l={"ftp:":21,"file:":null,"http:":80,"https:":443,"ws:":80,"wss:":443};if(xr(u.protocol)&&l[u.protocol]!==null&&(!u.port||String(l[u.protocol])===u.port))return"";if(u.port)return u.port};try{let u=new URL(s);return{protocol:r?u.protocol.replace(/:$/,""):void 0,hostname:i?u.hostname:void 0,port:o?d(u):void 0,pathname:a&&u.pathname?u.pathname:void 0,search:c?u.search:void 0}}catch(u){throw new x(`${u.message} '${s}'`)}})}static wrapInterceptionError(e){return e?.message.includes("Invalid header")||e?.message.includes("Unsafe header")?new x(e.message):e}async addDataCollector(e){if(e.userContexts!==void 0&&e.contexts!==void 0)throw new x("'contexts' and 'userContexts' are mutually exclusive");if(e.userContexts!==void 0&&await this.#s.verifyUserContextIdList(e.userContexts),e.contexts!==void 0){for(let s of e.contexts)if(!this.#e.getContext(s).isTopLevelContext())throw new x("Data collectors are available only on top-level browsing contexts")}let t=this.#t.addDataCollector(e);return await this.#i(),{collector:t}}async getData(e){return await this.#t.getCollectedData(e)}async removeDataCollector(e){return this.#t.removeDataCollector(e),await this.#i(),{}}disownData(e){return this.#t.disownData(e),{}}async#d(e,t){if(e===void 0&&t===void 0)return this.#e.getTopLevelContexts();if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let s=[];if(t!==void 0){if(t.length===0)throw new x("user context should be provided");await this.#s.verifyUserContextIdList(t);for(let r of t){let i=this.#e.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}}if(e!==void 0){if(e.length===0)throw new x("browsing context should be provided");for(let r of e){let i=this.#e.getContext(r);if(!i.isTopLevelContext())throw new x("The command is only supported on the top-level context");s.push(i)}}return[...new Set(s).values()]}async setExtraHeaders(e){let t=await this.#d(e.contexts,e.userContexts),s=vo(e.headers);return e.userContexts===void 0&&e.contexts===void 0&&this.#r.updateGlobalConfig({extraHeaders:s}),e.userContexts!==void 0&&e.userContexts.forEach(r=>{this.#r.updateUserContextConfig(r,{extraHeaders:s})}),e.contexts!==void 0&&e.contexts.forEach(r=>{this.#r.updateBrowsingContextConfig(r,{extraHeaders:s})}),await Promise.all(t.map(async r=>{let i=this.#r.getActiveConfig(r.id,r.userContext).extraHeaders??{};await r.setExtraHeaders(i)})),{}}};function qe(n){let e=new Set(["(",")","*","{","}"]),t="",s=!1;for(let r of n){if(!s){if(e.has(r))throw new x("Forbidden characters");if(r==="\\"){s=!0;continue}}t+=r,s=!1}return t}var wo=new Set([" "," ",`
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as p,d as m}from"./chunk-2OHANJ6Q.mjs";import{q as d}from"./chunk-LE44MD3O.mjs";import c from"node:fs";import u from"node:os";import s from"node:path";import{refusal as o,said as t}from"../browser/shared/i18n/index.mjs";var f=64*1024*1024,l=2e3;function h(i){let r;try{r=m(i)}catch{throw o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}try{let e=r.entries;if(e.length>l||e.reduce((n,{size:a})=>n+a,0)>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});return e.map(n=>({name:n.name,data:Buffer.from(r.read(n))}))}catch(e){throw e.code?e:o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}finally{r.close()}}function g(i){let r=s.resolve(String(i??"").trim().replace(/^"(.*)"$/,"$1")),e;try{e=c.statSync(r)}catch{throw o(t("\u627E\u4E0D\u5230 {0}",r),{code:"missing"})}if(e.isDirectory())return d(r);if(!e.isFile())throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});let n=Buffer.alloc(4),a=c.openSync(r,"r");try{c.readSync(a,n,0,4,0)}finally{c.closeSync(a)}if(!p(n))throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});return h(r)}function B(i){if(!p(i))throw o(t("\u9009\u7684\u6587\u4EF6\u4E0D\u662F zip"),{code:"kind"});if(i.length>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});let r=c.mkdtempSync(s.join(u.tmpdir(),"gallery-pack-")),e=s.join(r,"pack.zip");try{return c.writeFileSync(e,i),h(e)}finally{c.rmSync(r,{recursive:!0,force:!0})}}export{g as a,B as b};
2
+ import{b as p,d as m}from"./chunk-2OHANJ6Q.mjs";import{q as d}from"./chunk-KLQP46Y3.mjs";import c from"node:fs";import u from"node:os";import s from"node:path";import{refusal as o,said as t}from"../browser/shared/i18n/index.mjs";var f=64*1024*1024,l=2e3;function h(i){let r;try{r=m(i)}catch{throw o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}try{let e=r.entries;if(e.length>l||e.reduce((n,{size:a})=>n+a,0)>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});return e.map(n=>({name:n.name,data:Buffer.from(r.read(n))}))}catch(e){throw e.code?e:o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}finally{r.close()}}function g(i){let r=s.resolve(String(i??"").trim().replace(/^"(.*)"$/,"$1")),e;try{e=c.statSync(r)}catch{throw o(t("\u627E\u4E0D\u5230 {0}",r),{code:"missing"})}if(e.isDirectory())return d(r);if(!e.isFile())throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});let n=Buffer.alloc(4),a=c.openSync(r,"r");try{c.readSync(a,n,0,4,0)}finally{c.closeSync(a)}if(!p(n))throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});return h(r)}function B(i){if(!p(i))throw o(t("\u9009\u7684\u6587\u4EF6\u4E0D\u662F zip"),{code:"kind"});if(i.length>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});let r=c.mkdtempSync(s.join(u.tmpdir(),"gallery-pack-")),e=s.join(r,"pack.zip");try{return c.writeFileSync(e,i),h(e)}finally{c.rmSync(r,{recursive:!0,force:!0})}}export{g as a,B as b};
@@ -0,0 +1,5 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as $,b as u}from"./chunk-6GV3CBB2.mjs";import"./chunk-2OHANJ6Q.mjs";import{b as r,f as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{listCapabilities as k,readManifest as v}from"../browser/shared/extension-manifest.mjs";import x from"node:path";import d from"node:fs/promises";import{SIDEBAR_FILE as w,readSidebarText as E}from"../browser/shared/extension-sidebar.mjs";import{extensionSource as N,listExtensions as S,readExtension as I}from"../browser/shared/extensions.mjs";import{isExtensionId as y}from"../browser/shared/outline-shape.mjs";import{withOutlineLock as A}from"../browser/shared/outline.mjs";import{reportsDirectory as f}from"../browser/shared/paths.mjs";import{defaultWorkspace as p,ensureWorkspace as O,layoutOf as g}from"../browser/shared/workspace.mjs";var h=s=>`${s} ${s===1?"entry":"entries"}`;async function L(s){if(s.length>0)throw new r("list takes nothing: gallery extension check <id> reads one.");let o=await k();return S(f,{all:!0}).then(t=>{if(console.log(`Public columns: ${g(p()).extensions} (gallery extension new <id> "<title>").`),t.length===0){console.log(`No extensions visible from ${f}. Use gallery extension new <id> "<title>" (references/extensions.md says how to fill its entries).`);return}console.log(`${t.length} extension${t.length===1?"":"s"} visible from ${f}:`);for(let e of t){let n=e.missing?`no ${w}: it gives the sidebar no column`:e.error?`\u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`:`${e.title}, ${h(e.count)}${e.notes.length?`, ${e.notes.length} note${e.notes.length===1?"":"s"}`:""}`;console.log(` ${e.id} ${n}`),console.log(` ${e.file}`);let i=o.find(a=>a.id===e.id);i?.manifest&&console.log(` Script: ${!!i.manifest.workbench?.script}; backend: ${!!i.manifest.server}; enabled: ${i.enabled}`),i?.agent&&console.log(` Agent instructions: ${i.agent}`)}console.log("gallery extension check <id> prints what the sidebar shows of one.")})}function b(s,o,t=[]){for(let e of s){let n=e.url?e.url:"(no address: a click opens and closes what is under it)";t.push(`${" ".repeat(o)}${e.id} ${e.icon?`${e.icon} `:""}${e.title} ${n}`),b(e.children??[],o+1,t)}return t}async function F(s){if(s.length!==1)throw new r("Name one extension: gallery extension check <id>.");let[o]=s;if(!y(o))throw new r(`Not an extension's id: ${o} (its folder's name under extensions/: lowercase letters, digits and dashes, 48 at most).`);let t=await N(f,o);t||(console.error(`No extension "${o}" visible from ${f}: gallery extension list shows them.`),process.exit(1));let e=await I(t.root,o),n=t.file;if(e.missing){if(await v(t.folder).catch(()=>null)){console.log(`OK ${o}: extension.json (${t.folder})`);return}console.error(`FAIL ${n}: there is no ${w}; the folder gives the sidebar no column until it has one (references/extensions.md says how it is written).`),process.exit(1)}e.error&&(console.error(`FAIL ${n}: ${e.error.message}`),console.error(`The sidebar shows the column "${e.title}" with one row: \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`),process.exit(1)),console.log(`The sidebar shows the column ${e.title}${e.icon?` (${e.icon})`:""}, ${h(e.count)}, in the order the file gives (an entry with an address opens it beside the sidebar, one without opens and closes what is under it):`),console.log(e.title);for(let i of b(e.entries,1))console.log(i);for(let i of e.notes)console.log(`note: ${i.message}`);console.log(`OK ${o}: ${h(e.count)} (${n})`)}async function T(s){if(s.length!==2||!y(s[0]))throw new r('Use gallery extension new <id> "<title>".');let[o,t]=s,e=E(JSON.stringify({title:t,entries:[]}));if(e.error)throw new r(e.error.message);let n=p();if(!(await O(n)).ours)throw new r(`Not a Gallery workspace: ${n}`);let i=x.join(g(n).extensions,o),a=x.join(i,w);await A(n,async()=>{for(let l of[g(n).extensions,i]){await d.mkdir(l,{recursive:!0});let m=await d.lstat(l);if(!m.isDirectory()||m.isSymbolicLink())throw new r(`Not an ordinary directory: ${l}`)}try{await d.writeFile(a,JSON.stringify({title:e.sidebar.title,entries:[]},null,2)+`
3
+ `,{flag:"wx"})}catch(l){throw l.code==="EEXIST"?new r(`Already exists: ${a}. Read and edit this file instead.`):l}}),console.log(`Created public extension ${o}
4
+ ${a}`)}async function M(s){let[o,...t]=s;if(o==="new"){let{positional:e}=c({argv:t});return T(e)}if(o==="install"||o==="remove"){let{positional:e}=c({argv:t});if(e.length!==1)throw new r(`gallery extension ${o} <${o==="install"?"folder | zip":"id"}>`);if(o==="remove")await u(e[0]),console.log(`Removed extension ${e[0]}`);else{let n=await $(e[0]);console.log(`Installed ${n.id}: ${n.folder}
5
+ Next: enable it in Gallery Settings > Extensions. Its backend starts on first use after enabling.`),n.agent&&console.log(`Agent instructions: ${n.agent}`)}return}if(o==="list"){let{positional:e}=c({argv:t});return L(e)}if(o==="check"){let{positional:e}=c({argv:t});return F(e)}throw new r(o?`No such action: extension ${o} (new, list, check, install, remove).`:"Say what to do: gallery extension new <id> <title>, list or check <id>.")}export{M as run};
@@ -10,10 +10,10 @@ Error cause: ${lt(e)?e.stack:e}`)}this.#w()}#x(e){let r=Qt.createInterface(e),o=
10
10
  `)))};this.#t.on("exit",i),this.#t.on("error",i);let n=r>0?setTimeout(c,r):void 0;this.#h.on("line",d);let l=()=>{clearTimeout(n),this.#h.off("line",d),this.#t.off("exit",i),this.#t.off("error",i)};function c(){l(),a(new te(`Timed out after ${r} ms while waiting for the WS endpoint URL to appear in stdout!`))}for(let f of this.#n)d(f);function d(f){let p=f.match(e);p&&(l(),o(p[1]))}})}},rr=`Puppeteer was unable to kill the process which ran the browser binary.
11
11
  This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
12
12
  Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.
13
- If you think this is a bug, please report it on the Puppeteer issue tracker.`;function or(t){try{return process.kill(t,0)}catch(e){if(ar(e)&&e.code&&e.code==="ESRCH")return!1;throw e}}function lt(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function ar(t){return lt(t)&&("errno"in t||"code"in t||"path"in t||"syscall"in t)}var te=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}};import gr from"node:assert";import{spawnSync as Ne}from"node:child_process";import{existsSync as A,readFileSync as Cr}from"node:fs";import{mkdir as mt,unlink as Rr}from"node:fs/promises";import L from"node:os";import H from"node:path";var S=class{#e;constructor(e){this.#e=e}supports(e){return!0}getDownloadUrl(e){return this.#r(e.browser,e.platform,e.buildId)}#r(e,r,o){return new URL(K[e](r,o,this.#e))}getExecutablePath(e){return U[e.browser](e.platform,e.buildId)}getName(){return"DefaultProvider"}};import{spawnSync as sr,spawn as ir,execFile as nr}from"node:child_process";import{constants as lr,createReadStream as cr,createWriteStream as ur}from"node:fs";import{mkdir as oe,readdir as hr,symlink as dr}from"node:fs/promises";import*as v from"node:path";import{Stream as fr,Writable as mr}from"node:stream";import{pipeline as ct}from"node:stream/promises";import{promisify as De}from"node:util";var M=De(nr);async function ht(t,e,r){if(v.isAbsolute(e)||(e=v.resolve(process.cwd(),e)),t.endsWith(".zip"))await oe(e,{recursive:!0}),await xr(t,e,r);else if(t.endsWith(".tar.bz2"))await ut(t,e,"bzip2",r);else if(t.endsWith(".dmg"))await oe(e),await br(t,e);else if(t.endsWith(".exe")){let o=sr(t,[`/ExtractDir=${e}`],{env:{__compat_layer:"RunAsInvoker"}});if(o.status!==0)throw new Error(`Failed to extract ${t} to ${e}: ${o.output}`)}else if(t.endsWith(".tar.xz"))await ut(t,e,"xz");else throw new Error(`Unsupported archive format: ${t}`)}function pr(t){let e=new fr.Transform({transform(r,o,a){t.stdin.write(r,o)?a():t.stdin.once("drain",a)},flush(r){t.stdout.destroyed?r():(t.stdin.end(),t.stdout.on("close",r))}});return t.stdin.on("error",r=>{"code"in r&&r.code==="EPIPE"?e.emit("end"):e.destroy(r)}),t.stdout.on("data",r=>e.push(r)).on("error",r=>e.destroy(r)),t.once("close",()=>e.end()),e}var wr={xz:"xz",bzip2:"bzip2"};async function ut(t,e,r,o){let{unpackTar:a}=await import("./chunk-ZW2A6GBW.mjs");return await new Promise((i,n)=>{function l(f){return p=>{"code"in p&&p.code==="ENOENT"&&(p=new Error(`\`${f}\` utility is required to unpack this archive`,{cause:p})),n(p)}}let c=ir(wr[r],["-d"],{stdio:["pipe","pipe","inherit"]}).once("error",l(r)).once("exit",f=>{o?.(b.fileUtil)?.(`${r} exited, code=${f}`)}),d=a(e);d.once("error",l("tar")),d.once("finish",i),cr(t).pipe(pr(c)).pipe(d)})}async function br(t,e){let{stdout:r}=await M("hdiutil",["attach","-nobrowse","-noautoopen",t]),o=r.match(/\/Volumes\/(.*)/m);if(!o)throw new Error(`Could not find volume path in ${r}`);let a=o[0];try{let n=(await hr(a)).find(c=>typeof c=="string"&&c.endsWith(".app"));if(!n)throw new Error(`Cannot find app in ${a}`);let l=v.join(a,n);await M("cp",["-R",l,e])}finally{await M("hdiutil",["detach",a,"-quiet"])}}var j=class extends Error{};async function xr(t,e,r){for(let o of[Ir,Er])try{await o(t,e,r);return}catch(a){if(!(a instanceof j))throw a}throw new Error("Extraction failed: no zip archiver is available. Install `unzip` (or `tar.exe`/Powershell on Windows), or add the optional `yauzl` dependency.")}async function Er(t,e,r){let{default:o}=await import("yauzl").catch(()=>{throw new j("Extraction failed: The optional `yauzl` dependency is not installed.")}),a=De(o.open);try{let i=await a(t,{lazyEntries:!0});await new Promise((n,l)=>{i.on("error",l).on("end",n).on("entry",c=>{yr(i,c,e).then(()=>{i.readEntry()},l)}).readEntry()})}catch(i){throw new Error(`Extraction failed: ${t}`,{cause:i})}}async function Ir(t,e,r){try{if(process.platform==="win32"){let o=process.env.SystemRoot??process.env.SYSTEMROOT??"C:\\Windows";try{let a=`${o}\\System32\\tar.exe`;await M(a,["-xf",t,"-C",e]);return}catch(a){r?.(b.fileUtil)?.(`tar.exe extraction failed: ${a}`)}try{await M("powershell.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e]);return}catch(a){r?.(b.fileUtil)?.(`powershell.exe extraction failed: ${a}`)}await M("pwsh.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e])}else await M("unzip",["-o",t,"-d",e])}catch(o){throw o?.code==="ENOENT"?new j("Extraction failed: Required native binary ('tar.exe', 'powershell.exe', 'pwsh.exe' or 'unzip') was not found in the system PATH."):new Error(`Extraction failed: ${o?.stderr?.toString()||o?.message}`)}}function vr(t,e){let r=v.resolve(t),o=v.resolve(e);return o===r||o.startsWith(r+v.sep)}async function yr(t,e,r){let{S_IFMT:o,S_IFDIR:a,S_IFLNK:i}=lr,n=e.externalFileAttributes>>>16,l=(n&o)===a||e.fileName.endsWith("/")||e.versionMadeBy>>8===0&&e.externalFileAttributes===16,c=(n&o)===i,d=n===0?l?493:420:n&511,f=v.join(r,e.fileName);if(l){await oe(f,{recursive:!0,mode:d});return}await oe(v.dirname(f),{recursive:!0});let p=await De(t.openReadStream.bind(t))(e);if(c){let E=[];await ct(p,new mr({write(Te,Wr,It){Te instanceof Buffer&&E.push(Te),It()}}));let P=Buffer.concat(E).toString(),Et=v.resolve(v.dirname(f),P);if(!vr(r,Et))throw new Error(`Zip symlink "${e.fileName}" would point outside of the target directory.`);await dr(P,f);return}await ct(p,ur(f,{mode:d}))}var V=null,ae=class t{#e;#r=0;#o=0;#t=[];#s=!1;#a=0;#i=!1;constructor(e){this.#e=e}static createBarTicker(e,r,o=process.stderr){return(!V||V.#e!==o)&&(V=new t(o)),V.#n(e,r)}#c(){let e=this.#r++;return e>0&&this.#e.isTTY&&this.#e.write(`
13
+ If you think this is a bug, please report it on the Puppeteer issue tracker.`;function or(t){try{return process.kill(t,0)}catch(e){if(ar(e)&&e.code&&e.code==="ESRCH")return!1;throw e}}function lt(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function ar(t){return lt(t)&&("errno"in t||"code"in t||"path"in t||"syscall"in t)}var te=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}};import gr from"node:assert";import{spawnSync as Ne}from"node:child_process";import{existsSync as A,readFileSync as Cr}from"node:fs";import{mkdir as mt,unlink as Rr}from"node:fs/promises";import L from"node:os";import H from"node:path";var S=class{#e;constructor(e){this.#e=e}supports(e){return!0}getDownloadUrl(e){return this.#r(e.browser,e.platform,e.buildId)}#r(e,r,o){return new URL(K[e](r,o,this.#e))}getExecutablePath(e){return U[e.browser](e.platform,e.buildId)}getName(){return"DefaultProvider"}};import{spawnSync as sr,spawn as ir,execFile as nr}from"node:child_process";import{constants as lr,createReadStream as cr,createWriteStream as ur}from"node:fs";import{mkdir as oe,readdir as hr,symlink as dr}from"node:fs/promises";import*as v from"node:path";import{Stream as fr,Writable as mr}from"node:stream";import{pipeline as ct}from"node:stream/promises";import{promisify as De}from"node:util";var M=De(nr);async function ht(t,e,r){if(v.isAbsolute(e)||(e=v.resolve(process.cwd(),e)),t.endsWith(".zip"))await oe(e,{recursive:!0}),await xr(t,e,r);else if(t.endsWith(".tar.bz2"))await ut(t,e,"bzip2",r);else if(t.endsWith(".dmg"))await oe(e),await br(t,e);else if(t.endsWith(".exe")){let o=sr(t,[`/ExtractDir=${e}`],{env:{__compat_layer:"RunAsInvoker"}});if(o.status!==0)throw new Error(`Failed to extract ${t} to ${e}: ${o.output}`)}else if(t.endsWith(".tar.xz"))await ut(t,e,"xz");else throw new Error(`Unsupported archive format: ${t}`)}function pr(t){let e=new fr.Transform({transform(r,o,a){t.stdin.write(r,o)?a():t.stdin.once("drain",a)},flush(r){t.stdout.destroyed?r():(t.stdin.end(),t.stdout.on("close",r))}});return t.stdin.on("error",r=>{"code"in r&&r.code==="EPIPE"?e.emit("end"):e.destroy(r)}),t.stdout.on("data",r=>e.push(r)).on("error",r=>e.destroy(r)),t.once("close",()=>e.end()),e}var wr={xz:"xz",bzip2:"bzip2"};async function ut(t,e,r,o){let{unpackTar:a}=await import("./chunk-QR6A54KJ.mjs");return await new Promise((i,n)=>{function l(f){return p=>{"code"in p&&p.code==="ENOENT"&&(p=new Error(`\`${f}\` utility is required to unpack this archive`,{cause:p})),n(p)}}let c=ir(wr[r],["-d"],{stdio:["pipe","pipe","inherit"]}).once("error",l(r)).once("exit",f=>{o?.(b.fileUtil)?.(`${r} exited, code=${f}`)}),d=a(e);d.once("error",l("tar")),d.once("finish",i),cr(t).pipe(pr(c)).pipe(d)})}async function br(t,e){let{stdout:r}=await M("hdiutil",["attach","-nobrowse","-noautoopen",t]),o=r.match(/\/Volumes\/(.*)/m);if(!o)throw new Error(`Could not find volume path in ${r}`);let a=o[0];try{let n=(await hr(a)).find(c=>typeof c=="string"&&c.endsWith(".app"));if(!n)throw new Error(`Cannot find app in ${a}`);let l=v.join(a,n);await M("cp",["-R",l,e])}finally{await M("hdiutil",["detach",a,"-quiet"])}}var j=class extends Error{};async function xr(t,e,r){for(let o of[Ir,Er])try{await o(t,e,r);return}catch(a){if(!(a instanceof j))throw a}throw new Error("Extraction failed: no zip archiver is available. Install `unzip` (or `tar.exe`/Powershell on Windows), or add the optional `yauzl` dependency.")}async function Er(t,e,r){let{default:o}=await import("yauzl").catch(()=>{throw new j("Extraction failed: The optional `yauzl` dependency is not installed.")}),a=De(o.open);try{let i=await a(t,{lazyEntries:!0});await new Promise((n,l)=>{i.on("error",l).on("end",n).on("entry",c=>{yr(i,c,e).then(()=>{i.readEntry()},l)}).readEntry()})}catch(i){throw new Error(`Extraction failed: ${t}`,{cause:i})}}async function Ir(t,e,r){try{if(process.platform==="win32"){let o=process.env.SystemRoot??process.env.SYSTEMROOT??"C:\\Windows";try{let a=`${o}\\System32\\tar.exe`;await M(a,["-xf",t,"-C",e]);return}catch(a){r?.(b.fileUtil)?.(`tar.exe extraction failed: ${a}`)}try{await M("powershell.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e]);return}catch(a){r?.(b.fileUtil)?.(`powershell.exe extraction failed: ${a}`)}await M("pwsh.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e])}else await M("unzip",["-o",t,"-d",e])}catch(o){throw o?.code==="ENOENT"?new j("Extraction failed: Required native binary ('tar.exe', 'powershell.exe', 'pwsh.exe' or 'unzip') was not found in the system PATH."):new Error(`Extraction failed: ${o?.stderr?.toString()||o?.message}`)}}function vr(t,e){let r=v.resolve(t),o=v.resolve(e);return o===r||o.startsWith(r+v.sep)}async function yr(t,e,r){let{S_IFMT:o,S_IFDIR:a,S_IFLNK:i}=lr,n=e.externalFileAttributes>>>16,l=(n&o)===a||e.fileName.endsWith("/")||e.versionMadeBy>>8===0&&e.externalFileAttributes===16,c=(n&o)===i,d=n===0?l?493:420:n&511,f=v.join(r,e.fileName);if(l){await oe(f,{recursive:!0,mode:d});return}await oe(v.dirname(f),{recursive:!0});let p=await De(t.openReadStream.bind(t))(e);if(c){let E=[];await ct(p,new mr({write(Te,Wr,It){Te instanceof Buffer&&E.push(Te),It()}}));let P=Buffer.concat(E).toString(),Et=v.resolve(v.dirname(f),P);if(!vr(r,Et))throw new Error(`Zip symlink "${e.fileName}" would point outside of the target directory.`);await dr(P,f);return}await ct(p,ur(f,{mode:d}))}var V=null,ae=class t{#e;#r=0;#o=0;#t=[];#s=!1;#a=0;#i=!1;constructor(e){this.#e=e}static createBarTicker(e,r,o=process.stderr){return(!V||V.#e!==o)&&(V=new t(o)),V.#n(e,r)}#c(){let e=this.#r++;return e>0&&this.#e.isTTY&&this.#e.write(`
14
14
  `),e}#n(e,r){let o=this.#c();this.#t.push({title:e,total:r,downloaded:0,startTime:0,lastRendered:""});let a=!1;return i=>{let n=this.#t[o];n.startTime===0&&(n.startTime=Date.now()),n.downloaded+=i;let l=n.downloaded>=n.total;(l||Date.now()-this.#a>=100)&&this.#u(),l&&!a&&(a=!0,this.#l())}}#u(){this.#s||(this.#s=!0,queueMicrotask(()=>{this.#s=!1,this.#a=Date.now(),this.#d()}))}#h(e){let r=this.#t[e],o=Math.min(1,Math.max(0,r.downloaded/r.total)),a=Math.round(o*100),i=r.startTime>0?Date.now()-r.startTime:0,n=i>0?r.downloaded/i:0,l=n>0?(r.total-r.downloaded)/n/1e3:0,c=20,d=Math.round(c*o),f="=".repeat(d)+" ".repeat(c-d),p=o>=1?"unpacking":`${a}% ${l.toFixed(1)}s`;return`${r.title} [${f}] ${p} `}#d(){if(!this.#e.isTTY)return;let e=this.#r;if(e!==0){e>1&&this.#e.moveCursor(0,-(e-1));for(let r=0;r<e;r++){let o=this.#h(r);o!==this.#t[r].lastRendered&&(this.#e.cursorTo(0),this.#e.write(o),this.#e.clearLine(1),this.#t[r].lastRendered=o),r<e-1&&this.#e.moveCursor(0,1)}this.#e.cursorTo(0),this.#i&&(V=null,this.#e.write(`
15
15
  `))}}#l(){this.#o++,this.#o>=this.#r&&this.#r>0&&(this.#i=!0)}};var pt=new Map;function se(t){pt.set(t,process.hrtime())}function ie(t,e){let r=process.hrtime(),o=pt.get(t);if(!o)return;let a=r[0]*1e3+r[1]/1e6-(o[0]*1e3+o[1]/1e6);e?.(b.install)?.(`Duration for ${t}: ${a}ms`)}var B=class extends Error{};async function Sr(t){if(!t.platform)throw new Error("Platform must be defined");let e=t.logger,o=new C(t.cacheDir,t.logger).browserRoot(t.browser),a=[...t.providers||[]];t.baseUrl&&a.push(new S(t.baseUrl)),(!t.baseUrl||t.forceFallbackForTesting)&&a.push(new S);let i={browser:t.browser,platform:t.platform,buildId:t.buildId,progressCallback:t.downloadProgressCallback==="default"?await wt(t.browser,t.buildIdAlias??t.buildId):t.downloadProgressCallback},n=[];for(let d of a)try{if(!await d.supports(i)){e?.(b.install)?.(`Provider ${d.getName()} does not support ${t.browser} on ${t.platform}`);continue}d instanceof S||(e?.(b.install)?.(`\u26A0\uFE0F Using custom downloader: ${d.getName()}`),e?.(b.install)?.("\u26A0\uFE0F Puppeteer does not guarantee compatibility with non-default providers")),e?.(b.install)?.(`Trying provider: ${d.getName()} for ${t.browser} ${t.buildId}`);let f=await d.getDownloadUrl(i);if(!f){e?.(b.install)?.(`Provider ${d.getName()} returned no URL for ${t.browser} ${t.buildId}`);continue}return e?.(b.install)?.(`Successfully got URL from ${d.getName()}: ${f}`),A(o)||await mt(o,{recursive:!0}),await Ar(f,t,d,e)}catch(f){e?.(b.install)?.(`Provider ${d.getName()} failed: ${f.message}`),n.push({providerName:d.getName(),error:f})}let l=n.map(d=>` - ${d.providerName}: ${d.error.message}`).join(`
16
16
  `),c=`All providers failed for ${t.browser} ${t.buildId}:
17
17
  ${l}`;throw n.length>0&&n.every(d=>d.error instanceof B)?new B(c):new Error(c)}async function Le(t){if(t.platform??=y(),t.unpack??=!0,t.logger??=J,!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);return t.providers??=[],await Sr(t)}async function dt(t,e){if(process.platform!=="linux"||t.platform!==s.LINUX&&t.platform!==s.LINUX_ARM)return;let r=H.join(H.dirname(t.executablePath),"deb.deps");if(!A(r)){e?.(b.install)?.(`deb.deps file was not found at ${r}`);return}let o=Cr(r,"utf-8").split(`
18
- `).join(",");if(process.getuid?.()!==0)throw new Error("Installing system dependencies requires root privileges");let a=Ne("apt-get",["-v"]);if(a.status!==0)throw new Error("Failed to install system dependencies: apt-get does not seem to be available");if(e?.(b.install)?.(`Trying to install dependencies: ${o}`),a=Ne("apt-get",["satisfy","-y",o,"--no-install-recommends"]),a.status!==0)throw new Error(`Failed to install system dependencies: status=${a.status},error=${a.error},stdout=${a.stdout.toString("utf8")},stderr=${a.stderr.toString("utf8")}`);e?.(b.install)?.(`Installed system dependencies ${o}`)}async function Ar(t,e,r,o){if(!r)throw new Error("Provider is required for installation");if(e.platform??=y(),!e.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let a=e.downloadProgressCallback;a==="default"&&(a=await wt(e.browser,e.buildIdAlias??e.buildId));let i=decodeURIComponent(t.toString()).split("/").pop();gr(i,`A malformed download URL was found: ${t}.`);let n=new C(e.cacheDir,e.logger),l=n.browserRoot(e.browser),c=H.join(l,`${e.buildId}-${i}`);if(A(l)||await mt(l,{recursive:!0}),e.expectedHash&&o?.(b.install)?.(`Using provided checksum for ${i}: ${e.expectedHash}`),!e.unpack)return A(c)||(o?.(b.install)?.(`Downloading binary from ${t}`),se("download"),await le(t,c,a,e.expectedHash),ie("download",o)),c;let d=n.installationDir(e.browser,e.platform,e.buildId),f=await r.getExecutablePath({browser:e.browser,buildId:e.buildId,platform:e.platform});o?.(b.install)?.(`Using executable path from provider: ${f}`);let p=new _(n,e.browser,e.buildId,e.platform);r instanceof S||n.writeExecutablePath(e.browser,e.platform,e.buildId,f);try{if(A(d)){if(!A(p.executablePath))throw new B(`The browser folder (${d}) exists but the executable (${p.executablePath}) is missing. An earlier install of this build probably did not finish. Delete ${d} and install the browser again.`);return await ft(p,o),e.installDeps&&await dt(p,o),p}if(A(c))o?.(b.install)?.(`Using existing archive at ${c}`);else{o?.(b.install)?.(`Downloading binary from ${t}`);try{se("download"),await le(t,c,a,e.expectedHash)}finally{ie("download",o)}}o?.(b.install)?.(`Installing ${c} to ${d}`);try{se("extract"),await ht(c,d,e.logger)}finally{ie("extract",o)}if(e.buildIdAlias){let E=p.readMetadata();E.aliases[e.buildIdAlias]=e.buildId,p.writeMetadata(E)}return await ft(p,o),e.installDeps&&await dt(p,o),p}finally{A(c)&&await Rr(c)}}async function ft(t,e){if((t.platform===s.WIN32||t.platform===s.WIN64)&&t.browser===u.CHROME&&t.platform===y())try{se("permissions");let r=H.dirname(t.executablePath),o=H.join(r,"setup.exe");if(!A(o))return;Ne(H.join(r,"setup.exe"),["--configure-browser-in-directory="+r],{shell:!1})}finally{ie("permissions",e)}}async function $r(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot detect the browser platform for: ${L.platform()} (${L.arch()})`);new C(t.cacheDir).uninstall(t.browser,t.platform,t.buildId)}async function Dr(t){return new C(t.cacheDir).getInstalledBrowsers()}async function Nr(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let e=[...t.providers||[],new S(t.baseUrl)],r={browser:t.browser,platform:t.platform,buildId:t.buildId};for(let o of e){if(!await o.supports(r))continue;let a=await o.getDownloadUrl(r);if(a&&await Oe(a))return!0}return!1}function Lr(t,e,r,o){return new URL(K[t](e,r,o))}async function wt(t,e){let r,o=0;return(a,i)=>{r||(r=ae.createBarTicker(`Downloading ${t} ${e} - ${Pr(i)}`,i));let n=a-o;o=a,r(n)}}function Pr(t){let e=t/1e3/1e3;return`${Math.round(e*10)/10} MB`}import{spawn as Tr}from"node:child_process";import bt from"node:fs";import Mr from"node:os";import Br from"node:path";import{stdin as Or,stdout as Ur}from"node:process";import*as xt from"node:readline";function _r(t){return Object.values(u).includes(t)}function Hr(t){return Object.values(s).includes(t)}var Fr="3.2.3",Pe=class{#e;#r;#o;#t;#s;#a;#i;constructor(e,r){e||(e={}),typeof e=="string"&&(e={cachePath:e}),this.#e=e.cachePath??process.cwd(),this.#r=r,this.#o=e.scriptName??"@puppeteer/browsers",this.#t=e.version??Fr,this.#s=e.allowCachePathOverride??!0,this.#a=e.pinnedBrowsers,this.#i=e.prefixCommand}#c(e,r){return e.positional("browser",{description:"Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.",type:"string",coerce:o=>{let a={name:this.#d(o),buildId:this.#l(o)};if(!_r(a.name))throw new Error(`Unsupported browser '${a.name}'`);return a},demandOption:r})}#n(e){return e.option("platform",{type:"string",desc:"Platform that the binary needs to be compatible with.",choices:Object.values(s),default:y(),coerce:r=>{if(!Hr(r))throw new Error(`Unsupported platform '${r}'`);return r},defaultDescription:"Auto-detected"})}#u(e,r=!1){return this.#s?e.option("path",{type:"string",desc:"Path to the root folder for the browser downloads and installation. If a relative path is provided, it will be resolved relative to the current working directory. The installation folder structure is compatible with the cache structure used by Puppeteer.",defaultDescription:"Current working directory",...r?{}:{default:process.cwd()},demandOption:r}):e}async run(e){let{default:r}=await import("./chunk-74RPP2M2.mjs"),{hideBin:o}=await import("./chunk-LV24RY2E.mjs"),a=r(o(e)),i=a.scriptName(this.#o).version(this.#t);this.#i?i=i.command(this.#i.cmd,this.#i.description,n=>this.#h(n)):i=this.#h(i),await i.demandCommand(1).help().wrap(Math.min(120,a.terminalWidth())).parseAsync()}#h(e){let r=this.#a?"pinned":"latest",o=this.#a?"[browser]":"<browser>";return e.command(`install ${o}`,"Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (see --format).",a=>{this.#a&&a.example("$0 install","Install all pinned browsers"),a.example("$0 install chrome",`Install the ${r} available build of the Chrome browser.`).example("$0 install chrome@latest","Install the latest available build for the Chrome browser.").example("$0 install chrome@stable","Install the latest available build for the Chrome browser from the stable channel.").example("$0 install chrome@beta","Install the latest available build for the Chrome browser from the beta channel.").example("$0 install chrome@dev","Install the latest available build for the Chrome browser from the dev channel.").example("$0 install chrome@canary","Install the latest available build for the Chrome Canary browser.").example("$0 install chrome@115","Install the latest available build for Chrome 115.").example("$0 install chromedriver@canary","Install the latest available build for ChromeDriver Canary.").example("$0 install chromedriver@115","Install the latest available build for ChromeDriver 115.").example("$0 install chromedriver@115.0.5790","Install the latest available patch (115.0.5790.X) build for ChromeDriver.").example("$0 install chrome-headless-shell","Install the latest available chrome-headless-shell build.").example("$0 install chrome-headless-shell@beta","Install the latest available chrome-headless-shell build corresponding to the Beta channel.").example("$0 install chrome-headless-shell@118","Install the latest available chrome-headless-shell 118 build.").example("$0 install chromium@1083080","Install the revision 1083080 of the Chromium browser.").example("$0 install firefox","Install the latest nightly available build of the Firefox browser.").example("$0 install firefox@stable","Install the latest stable build of the Firefox browser.").example("$0 install firefox@beta","Install the latest beta build of the Firefox browser.").example("$0 install firefox@devedition","Install the latest devedition build of the Firefox browser.").example("$0 install firefox@esr","Install the latest ESR build of the Firefox browser.").example("$0 install firefox@nightly","Install the latest nightly build of the Firefox browser.").example("$0 install firefox@stable_111.0.1","Install a specific version of the Firefox browser.").example("$0 install firefox --platform mac","Install the latest Mac (Intel) build of the Firefox browser."),this.#s&&a.example("$0 install firefox --path /tmp/my-browser-cache","Install to the specified cache directory.");let i=this.#c(a,!this.#a),n=this.#n(i);return this.#u(n,!1).option("base-url",{type:"string",desc:"Base URL to download from"}).option("install-deps",{type:"boolean",desc:"Whether to attempt installing system dependencies (only supported on Linux, requires root privileges).",default:!1}).option("format",{type:"string",desc:"Format to use for the output. Supported placeholders: {{browser}}, {{buildId}}, {{path}}, {{platform}}",default:"{{browser}}@{{buildId}} {{path}}"})},async a=>{if(this.#a&&!a.browser){let i=await Promise.allSettled(Object.entries(this.#a).map(async([n,l])=>{l.skipDownload||await this.#p({...a,browser:{name:n,buildId:l.buildId}})}));for(let n of i)if(n.status==="rejected")throw n.reason}else await this.#p(a)}).command("launch <browser>","Launch the specified browser",a=>{a.example("$0 launch chrome@115.0.5790.170","Launch Chrome 115.0.5790.170").example("$0 launch firefox@112.0a1","Launch the Firefox browser identified by the milestone 112.0a1.").example("$0 launch chrome@115.0.5790.170 --detached","Launch the browser but detach the sub-processes.").example("$0 launch chrome@canary --system","Try to locate the Canary build of Chrome installed on the system and launch it.").example("$0 launch chrome@115.0.5790.170 -- --version","Launch Chrome 115.0.5790.170 and pass custom argument to the binary.");let i=a.parserConfiguration({"populate--":!0}),n=this.#c(i,!0),l=this.#n(n);return this.#u(l).option("detached",{type:"boolean",desc:"Detach the child process.",default:!1}).option("system",{type:"boolean",desc:"Search for a browser installed on the system instead of the cache folder.",default:!1}).option("dumpio",{type:"boolean",desc:"Forwards the browser's process stdout and stderr",default:!1})},async a=>{let i=a["--"]?.filter(l=>typeof l=="string");a.browser.buildId=this.#m(a.browser.buildId,a.browser.name);let n=a.system?Ae({browser:a.browser.name,channel:ue(a.browser.buildId),platform:a.platform}):re({browser:a.browser.name,buildId:a.browser.buildId,cacheDir:a.path??this.#e,platform:a.platform});$e({args:i,executablePath:n,dumpio:a.dumpio,detached:a.detached})}).command("clear",this.#s?"Removes all installed browsers from the specified cache directory":`Removes all installed browsers from ${this.#e}`,a=>this.#u(a,!0),async a=>{let i=a.path??this.#e,n=this.#r??xt.createInterface({input:Or,output:Ur});n.question(`Do you want to permanently and recursively delete the content of ${i} (yes/No)? `,l=>{if(n.close(),!["y","yes"].includes(l.toLowerCase().trim())){console.log("Cancelled.");return}new C(i).clear(),console.log(`${i} cleared.`)})}).command("list","List all installed browsers in the cache directory",a=>(a.example("$0 list","List all installed browsers in the cache directory"),this.#s&&a.example("$0 list --path /tmp/my-browser-cache","List browsers installed in the specified cache directory"),this.#u(a)),async a=>{let i=a.path??this.#e,l=new C(i).getInstalledBrowsers();for(let c of l)console.log(`${c.browser}@${c.buildId} (${c.platform}) ${c.executablePath}`)}).command("bisect <path>","(experimental) Bisect Chrome for Testing using the specified script. Downloads https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py to ~/bisect-builds.py if needed.",a=>a.positional("path",{type:"string",description:"Path to a script or test name to bisect.",demandOption:!0}).option("good",{type:"string",alias:"g",demandOption:!0,desc:"Last known good version"}).option("bad",{type:"string",alias:"b",demandOption:!0,desc:"First known bad version"}).option("cft",{type:"boolean",desc:"Use -cft",default:!0}),async a=>{let n=a.path.endsWith(".mjs")||a.path.endsWith(".cjs")||a.path.endsWith(".js")?`PUPPETEER_EXECUTABLE_PATH=%p node ${a.path}`:`BINARY=%p npm run ${a.path}`,l=Br.join(Mr.homedir(),"bisect-builds.py");if(!bt.existsSync(l)){console.log("Downloading bisect-builds.py...");let f=await fetch("https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py?format=TEXT");if(!f.ok)throw new Error(`Failed to download bisect-builds.py: ${f.statusText}`);let p=await f.text(),E=Buffer.from(p,"base64").toString("utf-8");bt.writeFileSync(l,E,{mode:493}),console.log(`Saved bisect-builds.py to ${l}`)}let c="python3",d=[l,"-g",a.good,"-b",a.bad,a.cft?"-cft":"-s","-v","--verify-range","--not-interactive","-c",n];await new Promise((f,p)=>{let E=Tr(c,d,{stdio:"inherit"});E.on("error",P=>{p(P)}),E.on("exit",P=>{P!==0?p(new Error(`Process exited with code ${P}`)):f()})})}).demandCommand(1).help()}#d(e){return e.split("@").shift()}#l(e){let r=e.split("@");return r.length===2?r[1]:this.#a?"pinned":"latest"}#m(e,r){if(e==="pinned"){let o=this.#a?.[r];if(!o||!o.buildId)throw new Error(`No pinned version found for ${r}`);return o.buildId}return e}async#p(e){if(!e.browser)throw new Error("No browser arg provided");if(!e.platform)throw new Error("Could not resolve the current platform");e.browser.buildId=this.#m(e.browser.buildId,e.browser.name);let r=e.browser.buildId;e.browser.buildId=await Ce(e.browser.name,e.platform,e.browser.buildId);try{await Le({browser:e.browser.name,buildId:e.browser.buildId,platform:e.platform,cacheDir:e.path??this.#e,downloadProgressCallback:"default",baseUrl:e.baseUrl,buildIdAlias:r!==e.browser.buildId?r:void 0,installDeps:e.installDeps})}catch(a){if(!(a instanceof B))throw a;let i=this.#i?`${this.#o} ${this.#i.cmd}`:this.#o;throw new Error(`${a.message}
18
+ `).join(",");if(process.getuid?.()!==0)throw new Error("Installing system dependencies requires root privileges");let a=Ne("apt-get",["-v"]);if(a.status!==0)throw new Error("Failed to install system dependencies: apt-get does not seem to be available");if(e?.(b.install)?.(`Trying to install dependencies: ${o}`),a=Ne("apt-get",["satisfy","-y",o,"--no-install-recommends"]),a.status!==0)throw new Error(`Failed to install system dependencies: status=${a.status},error=${a.error},stdout=${a.stdout.toString("utf8")},stderr=${a.stderr.toString("utf8")}`);e?.(b.install)?.(`Installed system dependencies ${o}`)}async function Ar(t,e,r,o){if(!r)throw new Error("Provider is required for installation");if(e.platform??=y(),!e.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let a=e.downloadProgressCallback;a==="default"&&(a=await wt(e.browser,e.buildIdAlias??e.buildId));let i=decodeURIComponent(t.toString()).split("/").pop();gr(i,`A malformed download URL was found: ${t}.`);let n=new C(e.cacheDir,e.logger),l=n.browserRoot(e.browser),c=H.join(l,`${e.buildId}-${i}`);if(A(l)||await mt(l,{recursive:!0}),e.expectedHash&&o?.(b.install)?.(`Using provided checksum for ${i}: ${e.expectedHash}`),!e.unpack)return A(c)||(o?.(b.install)?.(`Downloading binary from ${t}`),se("download"),await le(t,c,a,e.expectedHash),ie("download",o)),c;let d=n.installationDir(e.browser,e.platform,e.buildId),f=await r.getExecutablePath({browser:e.browser,buildId:e.buildId,platform:e.platform});o?.(b.install)?.(`Using executable path from provider: ${f}`);let p=new _(n,e.browser,e.buildId,e.platform);r instanceof S||n.writeExecutablePath(e.browser,e.platform,e.buildId,f);try{if(A(d)){if(!A(p.executablePath))throw new B(`The browser folder (${d}) exists but the executable (${p.executablePath}) is missing. An earlier install of this build probably did not finish. Delete ${d} and install the browser again.`);return await ft(p,o),e.installDeps&&await dt(p,o),p}if(A(c))o?.(b.install)?.(`Using existing archive at ${c}`);else{o?.(b.install)?.(`Downloading binary from ${t}`);try{se("download"),await le(t,c,a,e.expectedHash)}finally{ie("download",o)}}o?.(b.install)?.(`Installing ${c} to ${d}`);try{se("extract"),await ht(c,d,e.logger)}finally{ie("extract",o)}if(e.buildIdAlias){let E=p.readMetadata();E.aliases[e.buildIdAlias]=e.buildId,p.writeMetadata(E)}return await ft(p,o),e.installDeps&&await dt(p,o),p}finally{A(c)&&await Rr(c)}}async function ft(t,e){if((t.platform===s.WIN32||t.platform===s.WIN64)&&t.browser===u.CHROME&&t.platform===y())try{se("permissions");let r=H.dirname(t.executablePath),o=H.join(r,"setup.exe");if(!A(o))return;Ne(H.join(r,"setup.exe"),["--configure-browser-in-directory="+r],{shell:!1})}finally{ie("permissions",e)}}async function $r(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot detect the browser platform for: ${L.platform()} (${L.arch()})`);new C(t.cacheDir).uninstall(t.browser,t.platform,t.buildId)}async function Dr(t){return new C(t.cacheDir).getInstalledBrowsers()}async function Nr(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let e=[...t.providers||[],new S(t.baseUrl)],r={browser:t.browser,platform:t.platform,buildId:t.buildId};for(let o of e){if(!await o.supports(r))continue;let a=await o.getDownloadUrl(r);if(a&&await Oe(a))return!0}return!1}function Lr(t,e,r,o){return new URL(K[t](e,r,o))}async function wt(t,e){let r,o=0;return(a,i)=>{r||(r=ae.createBarTicker(`Downloading ${t} ${e} - ${Pr(i)}`,i));let n=a-o;o=a,r(n)}}function Pr(t){let e=t/1e3/1e3;return`${Math.round(e*10)/10} MB`}import{spawn as Tr}from"node:child_process";import bt from"node:fs";import Mr from"node:os";import Br from"node:path";import{stdin as Or,stdout as Ur}from"node:process";import*as xt from"node:readline";function _r(t){return Object.values(u).includes(t)}function Hr(t){return Object.values(s).includes(t)}var Fr="3.2.3",Pe=class{#e;#r;#o;#t;#s;#a;#i;constructor(e,r){e||(e={}),typeof e=="string"&&(e={cachePath:e}),this.#e=e.cachePath??process.cwd(),this.#r=r,this.#o=e.scriptName??"@puppeteer/browsers",this.#t=e.version??Fr,this.#s=e.allowCachePathOverride??!0,this.#a=e.pinnedBrowsers,this.#i=e.prefixCommand}#c(e,r){return e.positional("browser",{description:"Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.",type:"string",coerce:o=>{let a={name:this.#d(o),buildId:this.#l(o)};if(!_r(a.name))throw new Error(`Unsupported browser '${a.name}'`);return a},demandOption:r})}#n(e){return e.option("platform",{type:"string",desc:"Platform that the binary needs to be compatible with.",choices:Object.values(s),default:y(),coerce:r=>{if(!Hr(r))throw new Error(`Unsupported platform '${r}'`);return r},defaultDescription:"Auto-detected"})}#u(e,r=!1){return this.#s?e.option("path",{type:"string",desc:"Path to the root folder for the browser downloads and installation. If a relative path is provided, it will be resolved relative to the current working directory. The installation folder structure is compatible with the cache structure used by Puppeteer.",defaultDescription:"Current working directory",...r?{}:{default:process.cwd()},demandOption:r}):e}async run(e){let{default:r}=await import("./chunk-C564NU2H.mjs"),{hideBin:o}=await import("./chunk-4K5KC6V2.mjs"),a=r(o(e)),i=a.scriptName(this.#o).version(this.#t);this.#i?i=i.command(this.#i.cmd,this.#i.description,n=>this.#h(n)):i=this.#h(i),await i.demandCommand(1).help().wrap(Math.min(120,a.terminalWidth())).parseAsync()}#h(e){let r=this.#a?"pinned":"latest",o=this.#a?"[browser]":"<browser>";return e.command(`install ${o}`,"Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (see --format).",a=>{this.#a&&a.example("$0 install","Install all pinned browsers"),a.example("$0 install chrome",`Install the ${r} available build of the Chrome browser.`).example("$0 install chrome@latest","Install the latest available build for the Chrome browser.").example("$0 install chrome@stable","Install the latest available build for the Chrome browser from the stable channel.").example("$0 install chrome@beta","Install the latest available build for the Chrome browser from the beta channel.").example("$0 install chrome@dev","Install the latest available build for the Chrome browser from the dev channel.").example("$0 install chrome@canary","Install the latest available build for the Chrome Canary browser.").example("$0 install chrome@115","Install the latest available build for Chrome 115.").example("$0 install chromedriver@canary","Install the latest available build for ChromeDriver Canary.").example("$0 install chromedriver@115","Install the latest available build for ChromeDriver 115.").example("$0 install chromedriver@115.0.5790","Install the latest available patch (115.0.5790.X) build for ChromeDriver.").example("$0 install chrome-headless-shell","Install the latest available chrome-headless-shell build.").example("$0 install chrome-headless-shell@beta","Install the latest available chrome-headless-shell build corresponding to the Beta channel.").example("$0 install chrome-headless-shell@118","Install the latest available chrome-headless-shell 118 build.").example("$0 install chromium@1083080","Install the revision 1083080 of the Chromium browser.").example("$0 install firefox","Install the latest nightly available build of the Firefox browser.").example("$0 install firefox@stable","Install the latest stable build of the Firefox browser.").example("$0 install firefox@beta","Install the latest beta build of the Firefox browser.").example("$0 install firefox@devedition","Install the latest devedition build of the Firefox browser.").example("$0 install firefox@esr","Install the latest ESR build of the Firefox browser.").example("$0 install firefox@nightly","Install the latest nightly build of the Firefox browser.").example("$0 install firefox@stable_111.0.1","Install a specific version of the Firefox browser.").example("$0 install firefox --platform mac","Install the latest Mac (Intel) build of the Firefox browser."),this.#s&&a.example("$0 install firefox --path /tmp/my-browser-cache","Install to the specified cache directory.");let i=this.#c(a,!this.#a),n=this.#n(i);return this.#u(n,!1).option("base-url",{type:"string",desc:"Base URL to download from"}).option("install-deps",{type:"boolean",desc:"Whether to attempt installing system dependencies (only supported on Linux, requires root privileges).",default:!1}).option("format",{type:"string",desc:"Format to use for the output. Supported placeholders: {{browser}}, {{buildId}}, {{path}}, {{platform}}",default:"{{browser}}@{{buildId}} {{path}}"})},async a=>{if(this.#a&&!a.browser){let i=await Promise.allSettled(Object.entries(this.#a).map(async([n,l])=>{l.skipDownload||await this.#p({...a,browser:{name:n,buildId:l.buildId}})}));for(let n of i)if(n.status==="rejected")throw n.reason}else await this.#p(a)}).command("launch <browser>","Launch the specified browser",a=>{a.example("$0 launch chrome@115.0.5790.170","Launch Chrome 115.0.5790.170").example("$0 launch firefox@112.0a1","Launch the Firefox browser identified by the milestone 112.0a1.").example("$0 launch chrome@115.0.5790.170 --detached","Launch the browser but detach the sub-processes.").example("$0 launch chrome@canary --system","Try to locate the Canary build of Chrome installed on the system and launch it.").example("$0 launch chrome@115.0.5790.170 -- --version","Launch Chrome 115.0.5790.170 and pass custom argument to the binary.");let i=a.parserConfiguration({"populate--":!0}),n=this.#c(i,!0),l=this.#n(n);return this.#u(l).option("detached",{type:"boolean",desc:"Detach the child process.",default:!1}).option("system",{type:"boolean",desc:"Search for a browser installed on the system instead of the cache folder.",default:!1}).option("dumpio",{type:"boolean",desc:"Forwards the browser's process stdout and stderr",default:!1})},async a=>{let i=a["--"]?.filter(l=>typeof l=="string");a.browser.buildId=this.#m(a.browser.buildId,a.browser.name);let n=a.system?Ae({browser:a.browser.name,channel:ue(a.browser.buildId),platform:a.platform}):re({browser:a.browser.name,buildId:a.browser.buildId,cacheDir:a.path??this.#e,platform:a.platform});$e({args:i,executablePath:n,dumpio:a.dumpio,detached:a.detached})}).command("clear",this.#s?"Removes all installed browsers from the specified cache directory":`Removes all installed browsers from ${this.#e}`,a=>this.#u(a,!0),async a=>{let i=a.path??this.#e,n=this.#r??xt.createInterface({input:Or,output:Ur});n.question(`Do you want to permanently and recursively delete the content of ${i} (yes/No)? `,l=>{if(n.close(),!["y","yes"].includes(l.toLowerCase().trim())){console.log("Cancelled.");return}new C(i).clear(),console.log(`${i} cleared.`)})}).command("list","List all installed browsers in the cache directory",a=>(a.example("$0 list","List all installed browsers in the cache directory"),this.#s&&a.example("$0 list --path /tmp/my-browser-cache","List browsers installed in the specified cache directory"),this.#u(a)),async a=>{let i=a.path??this.#e,l=new C(i).getInstalledBrowsers();for(let c of l)console.log(`${c.browser}@${c.buildId} (${c.platform}) ${c.executablePath}`)}).command("bisect <path>","(experimental) Bisect Chrome for Testing using the specified script. Downloads https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py to ~/bisect-builds.py if needed.",a=>a.positional("path",{type:"string",description:"Path to a script or test name to bisect.",demandOption:!0}).option("good",{type:"string",alias:"g",demandOption:!0,desc:"Last known good version"}).option("bad",{type:"string",alias:"b",demandOption:!0,desc:"First known bad version"}).option("cft",{type:"boolean",desc:"Use -cft",default:!0}),async a=>{let n=a.path.endsWith(".mjs")||a.path.endsWith(".cjs")||a.path.endsWith(".js")?`PUPPETEER_EXECUTABLE_PATH=%p node ${a.path}`:`BINARY=%p npm run ${a.path}`,l=Br.join(Mr.homedir(),"bisect-builds.py");if(!bt.existsSync(l)){console.log("Downloading bisect-builds.py...");let f=await fetch("https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py?format=TEXT");if(!f.ok)throw new Error(`Failed to download bisect-builds.py: ${f.statusText}`);let p=await f.text(),E=Buffer.from(p,"base64").toString("utf-8");bt.writeFileSync(l,E,{mode:493}),console.log(`Saved bisect-builds.py to ${l}`)}let c="python3",d=[l,"-g",a.good,"-b",a.bad,a.cft?"-cft":"-s","-v","--verify-range","--not-interactive","-c",n];await new Promise((f,p)=>{let E=Tr(c,d,{stdio:"inherit"});E.on("error",P=>{p(P)}),E.on("exit",P=>{P!==0?p(new Error(`Process exited with code ${P}`)):f()})})}).demandCommand(1).help()}#d(e){return e.split("@").shift()}#l(e){let r=e.split("@");return r.length===2?r[1]:this.#a?"pinned":"latest"}#m(e,r){if(e==="pinned"){let o=this.#a?.[r];if(!o||!o.buildId)throw new Error(`No pinned version found for ${r}`);return o.buildId}return e}async#p(e){if(!e.browser)throw new Error("No browser arg provided");if(!e.platform)throw new Error("Could not resolve the current platform");e.browser.buildId=this.#m(e.browser.buildId,e.browser.name);let r=e.browser.buildId;e.browser.buildId=await Ce(e.browser.name,e.platform,e.browser.buildId);try{await Le({browser:e.browser.name,buildId:e.browser.buildId,platform:e.platform,cacheDir:e.path??this.#e,downloadProgressCallback:"default",baseUrl:e.baseUrl,buildIdAlias:r!==e.browser.buildId?r:void 0,installDeps:e.installDeps})}catch(a){if(!(a instanceof B))throw a;let i=this.#i?`${this.#o} ${this.#i.cmd}`:this.#o;throw new Error(`${a.message}
19
19
  You can also empty the whole browser cache with \`npx ${i} clear\` and then run \`npx ${i} install\` again.`,{cause:a})}let o=re({browser:e.browser.name,buildId:e.browser.buildId,cacheDir:e.path??this.#e,platform:e.platform});console.log(e.format.replace(/{{browser}}/g,e.browser.name).replace(/{{buildId}}/g,e.browser.buildId).replace(/{{path}}/g,o).replace(/{{platform}}/g,e.platform))}};function kr(t,e,r,o="zip"){return`${t}-${e}-${r}.${o}`}export{u as a,s as b,h as c,m as d,Ce as e,Xt as f,Yt as g,Re as h,y as i,_ as j,C as k,re as l,Ae as m,$e as n,er as o,tr as p,ee as q,te as r,S as s,Le as t,$r as u,Dr as v,Nr as w,Lr as x,Pe as y,kr as z};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a}from"./chunk-JEUK3ZO7.mjs";import"./chunk-TOE6DPLH.mjs";import{f as D}from"./chunk-WTEGUPFG.mjs";import{b as d,f as J,i as k}from"./chunk-4OZWXZE5.mjs";import{c as F}from"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import{a as A}from"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";import{existsSync as E}from"node:fs";import R from"node:fs/promises";import m from"node:path";import{iconKind as q}from"../browser/shared/emoji/icon-value.mjs";import{writeAtomic as z}from"../browser/shared/files.mjs";import{reportsDirectory as C}from"../browser/shared/paths.mjs";import{roleOf as M}from"../browser/shared/reports.mjs";import{documentDirectory as P,documentFiles as T,pageSlug as U}from"../browser/shared/workspace.mjs";var K=o=>o.replace(/\s+/g," ").trim(),_=o=>o.replace(/^[a-z]:\/(?:[^/]+\/)*?(?=icons\/(?:tabler\/)?[^/]+$)/i,"/"),h=o=>o===null?"none":JSON.stringify(o);async function ie(o){let{positional:u,values:c}=J({values:["--title","--icon","--description"],argv:o});if(u.length!==1)throw new d("Name one document, then what to set: --title, --icon, --description.");if(!["--title","--icon","--description"].some(e=>c.has(e)))throw new d('Say what to set: --title "<title>", --icon <emoji|none|\u2026>, --description "<text>".');let n=c.has("--title")?K(c.get("--title")):void 0,p=c.has("--description")?K(c.get("--description")):void 0;if(n==="")throw new d("--title takes the words of the title: a document's title is never empty.");if(p==="")throw new d("--description takes words: a document's description is never empty.");let t;if(c.has("--icon")){let e=_(c.get("--icon").trim()),f=e==="none"?"none":q(e);if(!f||/["<>&]/.test(e))throw new d(`Not a page icon: ${e} (an emoji, none, an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg, or a picture of the document's assets/).`);if(f==="glyph"&&!F(e))throw new d(`No such icon of the \u56FE\u6807 tab: ${e}.`);t=f==="none"?null:e}let{slug:w}=await k(u[0]),$=P(w,C);(w===await U(C)||await M($)==="instructions")&&(console.error(`${u[0]} is the \u5199\u4F5C\u504F\u597D page: only the user changes it.`),process.exit(1));let{html:r,json:s}=T($);E(r)||(console.error(`No document "${u[0]}": ${a(r)} does not exist (gallery list lists those there are).`),process.exit(1)),t&&q(t)==="image"&&!E(m.join($,...t.split("/")))&&(console.error(`No picture ${t} in ${a($)}: put it in its assets/ first.`),process.exit(1));let i;try{if(i=JSON.parse(await R.readFile(s,"utf8")),!i||typeof i!="object"||Array.isArray(i))throw new Error("not an object")}catch(e){console.error(`${a(s)} does not read (${e.code??e.message}): mend it first.`),process.exit(1)}let b=null,N=!1;for(let e=1;n!==void 0||t!==void 0;e++){let f=await R.readFile(r,"utf8"),v=A(f),y=D(v,{title:n,icon:t});if(y.missing&&(console.error(`${a(r)} has no title to ${n!==void 0?"set":"put the icon before"}: write it as an h1.doc-title in the page's header (writing-html.md, "The page").`),process.exit(1)),b=y.before,y.text===v)break;if(await z(r,y.text,{expect:f})){N=!0;break}e===3&&(console.error(`${a(r)} kept changing while it was being written (the page saving, or an Agent writing it?): nothing written. Run gallery set again.`),process.exit(1))}let l={...i};n!==void 0&&(l.title=n),p!==void 0&&(l.description=p),t===null?delete l.icon:t!==void 0&&(l.icon=t);let x=JSON.stringify(l)!==JSON.stringify(i);x&&await z(s,`${JSON.stringify(l,null,2)}
2
+ import{a}from"./chunk-JEUK3ZO7.mjs";import"./chunk-6NLXUKAY.mjs";import{f as D}from"./chunk-VRPVVMRB.mjs";import{b as d,f as J,i as k}from"./chunk-4OZWXZE5.mjs";import{c as F}from"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import{a as A}from"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{existsSync as E}from"node:fs";import R from"node:fs/promises";import m from"node:path";import{iconKind as q}from"../browser/shared/emoji/icon-value.mjs";import{writeAtomic as z}from"../browser/shared/files.mjs";import{reportsDirectory as C}from"../browser/shared/paths.mjs";import{roleOf as M}from"../browser/shared/reports.mjs";import{documentDirectory as P,documentFiles as T,pageSlug as U}from"../browser/shared/workspace.mjs";var K=o=>o.replace(/\s+/g," ").trim(),_=o=>o.replace(/^[a-z]:\/(?:[^/]+\/)*?(?=icons\/(?:tabler\/)?[^/]+$)/i,"/"),h=o=>o===null?"none":JSON.stringify(o);async function ie(o){let{positional:u,values:c}=J({values:["--title","--icon","--description"],argv:o});if(u.length!==1)throw new d("Name one document, then what to set: --title, --icon, --description.");if(!["--title","--icon","--description"].some(e=>c.has(e)))throw new d('Say what to set: --title "<title>", --icon <emoji|none|\u2026>, --description "<text>".');let n=c.has("--title")?K(c.get("--title")):void 0,p=c.has("--description")?K(c.get("--description")):void 0;if(n==="")throw new d("--title takes the words of the title: a document's title is never empty.");if(p==="")throw new d("--description takes words: a document's description is never empty.");let t;if(c.has("--icon")){let e=_(c.get("--icon").trim()),f=e==="none"?"none":q(e);if(!f||/["<>&]/.test(e))throw new d(`Not a page icon: ${e} (an emoji, none, an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg, or a picture of the document's assets/).`);if(f==="glyph"&&!F(e))throw new d(`No such icon of the \u56FE\u6807 tab: ${e}.`);t=f==="none"?null:e}let{slug:w}=await k(u[0]),$=P(w,C);(w===await U(C)||await M($)==="instructions")&&(console.error(`${u[0]} is the \u5199\u4F5C\u504F\u597D page: only the user changes it.`),process.exit(1));let{html:r,json:s}=T($);E(r)||(console.error(`No document "${u[0]}": ${a(r)} does not exist (gallery list lists those there are).`),process.exit(1)),t&&q(t)==="image"&&!E(m.join($,...t.split("/")))&&(console.error(`No picture ${t} in ${a($)}: put it in its assets/ first.`),process.exit(1));let i;try{if(i=JSON.parse(await R.readFile(s,"utf8")),!i||typeof i!="object"||Array.isArray(i))throw new Error("not an object")}catch(e){console.error(`${a(s)} does not read (${e.code??e.message}): mend it first.`),process.exit(1)}let b=null,N=!1;for(let e=1;n!==void 0||t!==void 0;e++){let f=await R.readFile(r,"utf8"),v=A(f),y=D(v,{title:n,icon:t});if(y.missing&&(console.error(`${a(r)} has no title to ${n!==void 0?"set":"put the icon before"}: write it as an h1.doc-title in the page's header (writing-html.md, "The page").`),process.exit(1)),b=y.before,y.text===v)break;if(await z(r,y.text,{expect:f})){N=!0;break}e===3&&(console.error(`${a(r)} kept changing while it was being written (the page saving, or an Agent writing it?): nothing written. Run gallery set again.`),process.exit(1))}let l={...i};n!==void 0&&(l.title=n),p!==void 0&&(l.description=p),t===null?delete l.icon:t!==void 0&&(l.icon=t);let x=JSON.stringify(l)!==JSON.stringify(i);x&&await z(s,`${JSON.stringify(l,null,2)}
3
3
  `);let S=m.basename(r),g=[];n!==void 0&&g.push(` title: ${h(b.title)} \u2192 ${h(n)} (${S}'s h1 and <title>, ${m.basename(s)})`),t!==void 0&&g.push(` icon: ${h(b.icon)} \u2192 ${h(t)} (${S}'s header, ${m.basename(s)})`),p!==void 0&&g.push(` description: ${h(typeof i.description=="string"?i.description:null)} \u2192 ${h(p)} (${m.basename(s)})`);let j=[...N?[a(r)]:[],...x?[a(s)]:[]];if(j.length===0){console.log(`Nothing to change: ${w} has ${g.length===1?"that already":"those already"}.`);return}console.log(`Set ${w}:`);for(let e of g)console.log(e);let O=j.length===1;console.log(`Re-read ${j.join(", ")} before editing ${O?"it":"them"}: gallery set wrote ${O?"it":"them"} (${[...N?[`${S}: its header`]:[],...x?[`${m.basename(s)}: ${["title","icon","description"].filter(e=>JSON.stringify(l[e])!==JSON.stringify(i[e])).join(", ")}`]:[]].join("; ")}).`)}export{ie as run};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,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}from"./chunk-3OFXMN6N.mjs";import"./chunk-SOD23RGL.mjs";import"./chunk-4DNHHJSL.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-3A5I2GJK.mjs";import"./chunk-XQRUG4G3.mjs";import"./chunk-JJNRIFND.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-CG3UHDKH.mjs";import"./chunk-4AMTKWDO.mjs";import"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};
2
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,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}from"./chunk-Q7P3Q5YX.mjs";import"./chunk-4KUO7R2M.mjs";import"./chunk-MKIBJTJZ.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-2KAVXMKG.mjs";import"./chunk-XZCFPKGO.mjs";import"./chunk-BN7M3IN7.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-USIHBCSW.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};