@heycys/gallery 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/assets/preview/runtime.js +156 -0
- package/assets/preview/shell.html +107 -0
- package/assets/writing-preferences.md +1 -1
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/page/annotate/card.mjs +6 -0
- package/browser/editor/page/annotate/index.mjs +22 -2
- package/browser/editor/page/columns/index.mjs +1 -1
- package/browser/editor/page/conflicts.mjs +1 -1
- package/browser/editor/page/drag/index.mjs +1 -1
- package/browser/editor/page/editor.mjs +39 -3
- package/browser/editor/page/focus.mjs +104 -0
- package/browser/editor/page/handle/index.mjs +14 -2
- package/browser/editor/page/links/index.mjs +2 -2
- package/browser/editor/page/quiet.mjs +3 -3
- package/browser/editor/page/resize/index.mjs +1 -1
- package/browser/editor/page/session.mjs +4 -1
- package/browser/editor/page/ui.mjs +1 -1
- package/browser/shared/annotations.mjs +22 -3
- package/browser/shared/block-packs.mjs +13 -4
- package/browser/shared/document-look.mjs +14 -0
- package/browser/shared/drafts.mjs +1 -1
- package/browser/shared/extension-manifest.mjs +40 -12
- package/browser/shared/favorite-merge.mjs +17 -0
- package/browser/shared/favorites.mjs +77 -0
- package/browser/shared/i18n/en.mjs +123 -24
- package/browser/shared/outline-ops.mjs +109 -0
- package/browser/shared/outline.mjs +6 -0
- package/browser/shared/pages.mjs +20 -8
- package/browser/shared/paths.mjs +5 -2
- package/browser/shared/preference-documents.mjs +137 -0
- package/browser/shared/presence.mjs +94 -0
- package/browser/shared/preview-server.mjs +8 -5
- package/browser/shared/qa-levels.mjs +9 -1
- package/browser/shared/session.mjs +4 -0
- package/browser/shared/shipped-blocks.mjs +22 -4
- package/browser/shared/startup.mjs +101 -0
- package/browser/shared/workspace-columns.mjs +1 -1
- package/browser/shared/workspace-look.mjs +21 -8
- package/browser/shared/workspace-registry.mjs +6 -3
- package/browser/shared/workspace.mjs +37 -10
- package/browser/shared/writing-preferences.mjs +2 -42
- package/dist/chunk-25LYSMAE.mjs +2 -0
- package/dist/chunk-2I6ZVC5O.mjs +2 -0
- package/dist/{chunk-M4NRDYI5.mjs → chunk-2MYTOOP6.mjs} +1 -1
- package/dist/chunk-2VNENLER.mjs +2 -0
- package/dist/chunk-3FERXZF5.mjs +4 -0
- package/dist/chunk-3M6SBBGU.mjs +2 -0
- package/dist/chunk-3VCAAF34.mjs +2 -0
- package/dist/{chunk-WD4U6XXT.mjs → chunk-3ZTRLGSA.mjs} +1 -1
- package/dist/chunk-4FRA5AUE.mjs +2 -0
- package/dist/chunk-4LR2QEC2.mjs +4 -0
- package/dist/chunk-56SVJENP.mjs +966 -0
- package/dist/chunk-5CQISL2G.mjs +4 -0
- package/dist/{chunk-RRKJMHNX.mjs → chunk-5I5ZDDWC.mjs} +5 -5
- package/dist/chunk-5IHDLEB4.mjs +10 -0
- package/dist/chunk-5LRDMV7O.mjs +2 -0
- package/dist/chunk-5MVUYRKG.mjs +5 -0
- package/dist/chunk-5TLLIZT7.mjs +2 -0
- package/dist/chunk-6ILJWFYW.mjs +4 -0
- package/dist/chunk-6N25CJ6Y.mjs +3 -0
- package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-7DTINW6U.mjs} +2 -2
- package/dist/chunk-7KWAGKIK.mjs +2 -0
- package/dist/chunk-7WNUOAFK.mjs +2 -0
- package/dist/chunk-7XCRW5RC.mjs +2 -0
- package/dist/{chunk-BYNPEUDS.mjs → chunk-7XSDTILF.mjs} +1 -1
- package/dist/chunk-ABKYFOVR.mjs +2 -0
- package/dist/chunk-AMUF7PUN.mjs +2 -0
- package/dist/{chunk-FJLM7YE7.mjs → chunk-B2EIMERT.mjs} +2 -2
- package/dist/{chunk-QNECWMGR.mjs → chunk-B45IAAU6.mjs} +1 -1
- package/dist/chunk-B6RAGF4R.mjs +2 -0
- package/dist/chunk-BSJKFE7I.mjs +4 -0
- package/dist/chunk-C72EEVLK.mjs +2 -0
- package/dist/chunk-CRAUKZ23.mjs +4 -0
- package/dist/chunk-F4CT35KL.mjs +2 -0
- package/dist/chunk-F63BNJLG.mjs +2 -0
- package/dist/chunk-FBKUPS44.mjs +2 -0
- package/dist/chunk-FL52ZL5Z.mjs +15 -0
- package/dist/chunk-FOZCU4VW.mjs +2 -0
- package/dist/chunk-G5HV7BC3.mjs +2 -0
- package/dist/{chunk-ERLAIBOA.mjs → chunk-GB5SOYQJ.mjs} +2 -2
- package/dist/chunk-GN3SG3IF.mjs +2 -0
- package/dist/{chunk-6QWQXHAV.mjs → chunk-HFTBVEZK.mjs} +1 -1
- package/dist/chunk-IOW5HLRK.mjs +2 -0
- package/dist/chunk-IQ3GJNTI.mjs +6 -0
- package/dist/chunk-K6SPFBUJ.mjs +2 -0
- package/dist/chunk-K7Y7SPTS.mjs +2 -0
- package/dist/chunk-L2IJCEUH.mjs +2 -0
- package/dist/{chunk-GPIWQ4X4.mjs → chunk-L3VT6LM4.mjs} +1 -1
- package/dist/chunk-L4WLQYFC.mjs +5 -0
- package/dist/{chunk-NLDF35P5.mjs → chunk-LAMCAGK6.mjs} +1 -1
- package/dist/chunk-LHGKPMTI.mjs +2 -0
- package/dist/chunk-LJZIYVNA.mjs +3 -0
- package/dist/chunk-LSVCTLS2.mjs +2 -0
- package/dist/chunk-LZY74XTP.mjs +2 -0
- package/dist/chunk-MC4LRSVH.mjs +2 -0
- package/dist/chunk-MCEXN4G5.mjs +2 -0
- package/dist/chunk-MTLAOCFF.mjs +181 -0
- package/dist/chunk-MZ66LN3B.mjs +2 -0
- package/dist/chunk-N5QWJRRI.mjs +2 -0
- package/dist/chunk-NF4MMOUB.mjs +2 -0
- package/dist/chunk-NHJYAJ73.mjs +3 -0
- package/dist/chunk-NRSD7SVY.mjs +2 -0
- package/dist/chunk-NT23I4XW.mjs +2 -0
- package/dist/chunk-NUALABIS.mjs +3 -0
- package/dist/chunk-NW6LAU22.mjs +2 -0
- package/dist/chunk-NWWHDGKF.mjs +5 -0
- package/dist/chunk-OFRCVMSJ.mjs +2 -0
- package/dist/chunk-OKVQQ3CX.mjs +4 -0
- package/dist/chunk-OM24O4KR.mjs +8 -0
- package/dist/{chunk-4B2TB5K2.mjs → chunk-PBMOC7KA.mjs} +2 -2
- package/dist/chunk-PVTCP43W.mjs +2 -0
- package/dist/chunk-Q62HZAJS.mjs +2 -0
- package/dist/chunk-QBJWIR3Q.mjs +2 -0
- package/dist/chunk-QDSEZX7Z.mjs +6 -0
- package/dist/chunk-QR4V4A2Z.mjs +15 -0
- package/dist/{chunk-QVGOPHOF.mjs → chunk-QRLVVZ3R.mjs} +1 -1
- package/dist/chunk-QW3QG67J.mjs +2 -0
- package/dist/chunk-R2T2EVWY.mjs +8 -0
- package/dist/{chunk-JJNHKGTD.mjs → chunk-R5RERE6G.mjs} +1 -1
- package/dist/chunk-RFHEWT3Y.mjs +5 -0
- package/dist/chunk-RS2Z2JQP.mjs +2 -0
- package/dist/chunk-S6YEC4GE.mjs +16 -0
- package/dist/chunk-SHZLMGGW.mjs +2 -0
- package/dist/chunk-TALJQM2O.mjs +2 -0
- package/dist/chunk-TLNJWEFY.mjs +22 -0
- package/dist/{chunk-ZLS2FRS6.mjs → chunk-TQZU7D7C.mjs} +1 -1
- package/dist/chunk-UTKNWYBA.mjs +2 -0
- package/dist/chunk-V3TM3TEN.mjs +2 -0
- package/dist/chunk-V3XROSP5.mjs +7 -0
- package/dist/{chunk-6QBHU4DF.mjs → chunk-V5JTW2LH.mjs} +1 -1
- package/dist/chunk-VAXLSISW.mjs +4 -0
- package/dist/chunk-VBHI3RG6.mjs +2 -0
- package/dist/{chunk-CRDG6EF2.mjs → chunk-VKZJRGDR.mjs} +1 -1
- package/dist/chunk-VZXZM7NS.mjs +2 -0
- package/dist/chunk-WDS6HEPE.mjs +2 -0
- package/dist/chunk-WHGANNEY.mjs +13 -0
- package/dist/chunk-WMJWC4QY.mjs +56 -0
- package/dist/{chunk-UTMAY3WK.mjs → chunk-WWONJJQS.mjs} +1 -1
- package/dist/chunk-X4WNLFIK.mjs +2 -0
- package/dist/chunk-XNNCQROX.mjs +11 -0
- package/dist/chunk-XRYECF23.mjs +170 -0
- package/dist/{chunk-225ALKYI.mjs → chunk-Z4NEXXFK.mjs} +1 -1
- package/dist/{chunk-PKVK6WFC.mjs → chunk-ZFVF2YPV.mjs} +2 -2
- package/dist/chunk-ZM2IX3R2.mjs +2 -0
- package/dist/chunk-ZNGGDUZI.mjs +2 -0
- package/dist/chunk-ZOEJQOKT.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/update-fetch.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/package.json +1 -1
- package/release.json +3 -3
- package/skill/SKILL.md +54 -148
- package/skill/references/building-blocks.md +4 -4
- package/skill/references/charts-and-figures.md +73 -0
- package/skill/references/extensions.md +47 -4
- package/skill/references/pages-and-data.md +22 -3
- package/skill/references/preference-files.md +7 -0
- package/skill/references/previews.md +17 -0
- package/skill/references/writing-html.md +21 -82
- package/web/assets/index-B4uUluLM.js +15 -0
- package/web/assets/index-C3vHT8sH.css +1 -0
- package/web/index.html +2 -2
- package/dist/chunk-2HS7ZBPU.mjs +0 -2
- package/dist/chunk-3F57LEN5.mjs +0 -2
- package/dist/chunk-4OZWXZE5.mjs +0 -5
- package/dist/chunk-5GK7HS62.mjs +0 -2
- package/dist/chunk-6GV3CBB2.mjs +0 -2
- package/dist/chunk-6NLXUKAY.mjs +0 -4
- package/dist/chunk-6XD6U3QA.mjs +0 -5
- package/dist/chunk-6Y3HYOBM.mjs +0 -2
- package/dist/chunk-7EFHNQ5B.mjs +0 -3
- package/dist/chunk-7M2BQQGZ.mjs +0 -2
- package/dist/chunk-7UZUQQ7Q.mjs +0 -554
- package/dist/chunk-ALZ6ZENZ.mjs +0 -3
- package/dist/chunk-BX5AKINW.mjs +0 -15
- package/dist/chunk-DR73Y2UJ.mjs +0 -3
- package/dist/chunk-EURLTOTZ.mjs +0 -4
- package/dist/chunk-F4ZA6JRZ.mjs +0 -3
- package/dist/chunk-FNCCVGKX.mjs +0 -2
- package/dist/chunk-FOJ3K5Z3.mjs +0 -6
- package/dist/chunk-FQ72LZHB.mjs +0 -2
- package/dist/chunk-G7N7YFVD.mjs +0 -2
- package/dist/chunk-GIRXJBGC.mjs +0 -2
- package/dist/chunk-GKOBB6DH.mjs +0 -2
- package/dist/chunk-GMJD7ID3.mjs +0 -2
- package/dist/chunk-GQJMVSSN.mjs +0 -2
- package/dist/chunk-HX4DLE3J.mjs +0 -10
- package/dist/chunk-IS7N3N6Q.mjs +0 -168
- package/dist/chunk-JEUK3ZO7.mjs +0 -2
- package/dist/chunk-JPG2LBQM.mjs +0 -11
- package/dist/chunk-JYK5WJPM.mjs +0 -2
- package/dist/chunk-KLQP46Y3.mjs +0 -4
- package/dist/chunk-L55NOXBE.mjs +0 -4
- package/dist/chunk-LCB6MARS.mjs +0 -5
- package/dist/chunk-LJLVCU6W.mjs +0 -16
- package/dist/chunk-LMUZQK5O.mjs +0 -2
- package/dist/chunk-NMF3IPYA.mjs +0 -13
- package/dist/chunk-ONKC4BCC.mjs +0 -2
- package/dist/chunk-OU6ZZVBX.mjs +0 -5
- package/dist/chunk-PUOQ65NC.mjs +0 -2
- package/dist/chunk-QJAVCTY7.mjs +0 -2
- package/dist/chunk-QP7BOHE4.mjs +0 -2
- package/dist/chunk-S3SX3COT.mjs +0 -20
- package/dist/chunk-SQ3FQCCN.mjs +0 -8
- package/dist/chunk-T4Y2ZSVX.mjs +0 -4
- package/dist/chunk-TANZRINB.mjs +0 -2
- package/dist/chunk-UGWMMEJ5.mjs +0 -15
- package/dist/chunk-UTF7GBQU.mjs +0 -4
- package/dist/chunk-V4ZHRALW.mjs +0 -170
- package/dist/chunk-XBNFXWAW.mjs +0 -6
- package/dist/chunk-XZV72SQ4.mjs +0 -2
- package/dist/chunk-YFJB534W.mjs +0 -2
- package/dist/chunk-Z6OKLRHC.mjs +0 -2
- package/dist/chunk-ZMHUDYLV.mjs +0 -2
- package/web/assets/index-D8P8uhDW.js +0 -15
- package/web/assets/index-FLb9jCfl.css +0 -1
- /package/dist/{chunk-PAREWQGB.mjs → chunk-NOGQX56R.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-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`
|
|
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-7DTINW6U.mjs";import"./chunk-YEY3RSFQ.mjs";import"./chunk-UH4SIXTR.mjs";import"./chunk-Y34NR5JL.mjs";import{b as xt,c as T}from"./chunk-W7XHE4CT.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([" "," ",`
|
|
@@ -0,0 +1,4 @@
|
|
|
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 v,b as x,c as w,d as y,i as h}from"./chunk-56SVJENP.mjs";import{readFileSync as j,realpathSync as b}from"node:fs";import p from"node:path";import{fileURLToPath as N}from"node:url";var A=p.dirname(N(import.meta.url));function O(s=A){for(let e=s;;e=p.dirname(e)){try{let n=JSON.parse(j(p.join(e,"package.json"),"utf8"));if(n.name==="@heycys/gallery")return n.version}catch{}if(p.dirname(e)===e)return"0.0.0"}}var S={init:()=>import("./chunk-WWONJJQS.mjs"),new:()=>import("./chunk-FOZCU4VW.mjs"),import:()=>import("./chunk-IQ3GJNTI.mjs"),open:()=>import("./chunk-Q62HZAJS.mjs"),serve:()=>import("./chunk-CRAUKZ23.mjs"),sandbox:()=>import("./chunk-QDSEZX7Z.mjs"),preview:()=>import("./chunk-R2T2EVWY.mjs"),preferences:()=>import("./chunk-NHJYAJ73.mjs"),stop:()=>import("./chunk-QRLVVZ3R.mjs"),startup:()=>import("./chunk-VBHI3RG6.mjs"),check:()=>import("./chunk-RS2Z2JQP.mjs"),export:()=>import("./chunk-5LRDMV7O.mjs"),qa:()=>import("./chunk-NT23I4XW.mjs"),list:()=>import("./chunk-7XSDTILF.mjs"),workspaces:()=>import("./chunk-7XCRW5RC.mjs"),move:()=>import("./chunk-C72EEVLK.mjs"),set:()=>import("./chunk-NUALABIS.mjs"),link:()=>import("./chunk-TALJQM2O.mjs"),extension:()=>import("./chunk-WMJWC4QY.mjs"),block:()=>import("./chunk-GN3SG3IF.mjs"),page:()=>import("./chunk-K7Y7SPTS.mjs"),skill:()=>import("./chunk-3ZTRLGSA.mjs"),trash:()=>import("./chunk-AMUF7PUN.mjs"),duplicate:()=>import("./chunk-QW3QG67J.mjs"),copy:()=>import("./chunk-2I6ZVC5O.mjs"),favorite:()=>import("./chunk-7KWAGKIK.mjs"),column:()=>import("./chunk-OFRCVMSJ.mjs"),notes:()=>import("./chunk-5CQISL2G.mjs"),status:()=>import("./chunk-N5QWJRRI.mjs"),history:()=>import("./chunk-3VCAAF34.mjs"),revert:()=>import("./chunk-FBKUPS44.mjs"),doctor:()=>import("./chunk-ABKYFOVR.mjs"),emoji:()=>import("./chunk-K6SPFBUJ.mjs")},L=new Set(["stop","startup","init","skill","workspaces","preview","doctor","status"]),C=(s,e)=>`${s.split(`
|
|
3
|
+
`)[0]} (gallery ${e?`${e} --help`:"help"} says more)`,g=s=>/^--.|^-[A-Za-z]/.test(s);function G(s){let e=s.indexOf("--"),n=e===-1?s:s.slice(0,e),u=e===-1?[]:s.slice(e),i=[],l=null;for(let t=0;t<n.length;t++){let r=n[t];if(r==="--workspace"||r.startsWith("--workspace=")){let o=r.includes("=")?r.slice(r.indexOf("=")+1):t+1<n.length&&!g(n[t+1])?n[++t]:"";if(!o)return{error:"--workspace takes a folder: --workspace <dir>",usage:h};if(l!==null&&p.resolve(l)!==p.resolve(o))return{error:`Two workspaces named: ${l} and ${o}.`,usage:h};l=o;continue}i.push(r)}if(i[0]==="--version"||i[0]==="-v"||i[0]==="-V")return i.length===1&&u.length===0?{version:!0}:{error:"--version takes nothing else.",usage:h};if(i.length===0||i[0]==="help"||i[0]==="--help"||i[0]==="-h"){let t=i[0]==="help"?i[1]:void 0;if(t===void 0)return{help:h};if(!Object.hasOwn(w,t))return{error:`No such command: ${t} (${v.join(", ")}).`,usage:h};let r=y(t,i.slice(2).find(o=>!g(o)));return r.unknown?{error:`No such ${x[t]??t} command: ${i.slice(2).find(o=>!g(o))} (${r.unknown.join(", ")}).`,usage:w[t],command:x[t]??t}:{help:r.text}}let[d,...c]=i,a=x[d]??d;if(!Object.hasOwn(S,a))return{error:g(a)?`Unknown option: ${a} (the command comes first: gallery <command> [options]).`:`No such command: ${a} (${v.join(", ")}).`,usage:h};let k=[...c,...u];if(c.some(t=>t==="--help"||t==="-h"))return{help:y(a,c[0]!==void 0&&!g(c[0])?c[0]:void 0).text??y(a).text};if(a==="init"){let t=new Set(["--from","--name"]),r=[];for(let o=0;o<c.length;o++)t.has(c[o])?o++:g(c[o])||r.push(c[o]);if(r.push(...u.slice(1)),r.length>1)return{error:"Name one folder at most.",usage:w.init,command:a};if(r.length===1){if(l!==null&&p.resolve(l)!==p.resolve(r[0]))return{error:`Two workspaces named: ${r[0]} and --workspace ${l}.`,usage:w.init,command:a};l=r[0]}}return{command:a,argv:k,flag:l}}var R=(s,e)=>`Cannot write the workspace ${s} (${e}): allow Gallery to write there, or pass --workspace <a folder you may write>.`,T=(s,e=!0)=>e?`${p.join(s,"gallery.json")} is not Gallery's (another program's file of that name): pass --workspace <another folder> for Gallery's documents.`:`${p.join(s,"gallery.json")} does not read as JSON: mend the file, or pass --workspace <another folder> for Gallery's documents.`,W=new Set(["doctor","serve","startup"]);async function I(s,e,n=O()){let u=e.includes("--")?e.slice(0,e.indexOf("--")):e;if(W.has(s)||u.includes("--json"))return null;try{let{attentionNotes:i,galleryRun:l,viaNpx:d}=await import("./chunk-NRSD7SVY.mjs"),c=i(n);return c.length?`\u9700\u8981\u5904\u7406\uFF1A${c.join("\uFF1B")}\uFF08\u8FD0\u884C ${l("doctor",n,d())}\uFF09`:null}catch{return null}}async function U(s=process.argv.slice(2)){process.stdout.on("error",o=>{throw o.code==="EPIPE"&&process.exit(process.exitCode??0),o});let e=G(s);if(e.version){let o=O();console.log(o);try{let{versionNotes:m}=await import("./chunk-NRSD7SVY.mjs");for(let f of m(o))console.log(f)}catch{}return}if(e.help)return void console.log(e.help);e.error&&(console.error(`${e.error}
|
|
4
|
+
${C(e.usage,e.command)}`),process.exit(2));let{command:n,flag:u}=e,{UsageError:i,usageFailureText:l}=await import("./chunk-L3VT6LM4.mjs"),d=async o=>{try{await(await S[n]()).run(e.argv,{command:n,version:O(),...o})}catch(m){if(!(m instanceof i))throw m;console.error(l(w[n],m.message,m.synopsis)),process.exitCode=2}};if(n==="sandbox")return d({flag:u});let{findWorkspace:c,defaultWorkspace:a}=await import("../browser/shared/workspace.mjs"),k=c({flag:u}),r=["page","block","extension","preferences"].includes(n)&&!(n==="block"&&e.argv.find(o=>!o.startsWith("-"))==="try")?{root:a(),how:"default"}:k;if(process.env.GALLERY_SANDBOX&&r.root!==a()){console.error("Sandbox commands must use the sandbox workspace."),process.exitCode=2;return}if(process.env.GALLERY_SANDBOX&&n==="serve"){console.error("Use gallery sandbox to start a sandbox service."),process.exitCode=2;return}if(process.env.GALLERY_WORKSPACE=r.root,!L.has(n)){let{ensureWorkspace:o}=await import("../browser/shared/workspace.mjs");try{await o(a());let{ours:f,reads:E}=await o(r.root,{state:n!=="init"||r.root===a()});f||(console.error(T(r.root,E)),process.exit(1))}catch(f){if(!f.code)throw f;console.error(R(r.root,f.code)),process.exit(1)}let{registerQuietly:m}=await import("../browser/shared/workspace-registry.mjs");await m(r.root)}if(await d({workspace:r.root,how:r.how,documents:k.root}),process.exitCode!==2){let o=await I(n,e.argv);o&&(process.exitCode?console.error:console.log)(o)}}var $=s=>{try{return b.native(s)}catch{return null}};process.argv[1]&&$(process.argv[1])===$(N(import.meta.url))&&U();export{O as a,G as b,R as c,T as d,I as e,U as f};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 n,f as o}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{startup as s}from"../browser/shared/startup.mjs";async function p(i){let{positional:a}=o({argv:i}),[t="status"]=a;if(a.length>1||!["status","enable","disable","run"].includes(t))throw new n("gallery startup status|enable|disable|run");if(t==="run"){let r=await s().status();if(!r.available||!r.requested)return;let{serverFor:l}=await import("./chunk-IOW5HLRK.mjs"),e=await l({command:"gallery startup run"});e.ok||(console.error(e.message),process.exitCode=1);return}let u=t==="status"?await s().status():await s().set(t==="enable");console.log(JSON.stringify(u))}export{p 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{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-
|
|
2
|
+
import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-QR4V4A2Z.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-NOGQX56R.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 D,b as F,c as C,d as M}from"./chunk-OKVQQ3CX.mjs";import{b as L}from"./chunk-X4WNLFIK.mjs";import{l as j,t as x,w as v}from"./chunk-QR4V4A2Z.mjs";import{a as b}from"./chunk-HYMEEXKN.mjs";import{a as y,j as $}from"./chunk-L4WLQYFC.mjs";import u from"node:fs/promises";import I from"node:path";import{BLOCK_ID as N}from"../browser/shared/ids.mjs";import{attr as f,elementsOf as R,walk as S}from"../browser/shared/html-tree.mjs";import{RESERVED as E,documentFiles as G}from"../browser/shared/workspace.mjs";var z=n=>n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`:`${n[0]}`;function O(n){let l=b(n),r=[],t=[];S(l,o=>{let i=f(o,"data-block-id");if(i!==void 0&&!N.test(i)&&r.push({id:i,line:(o.sourceCodeLocation?.attrs?.["data-block-id"]??o.sourceCodeLocation)?.startLine}),o.tagName==="li"&&f(o,"data-block-id")===void 0){let s=R(o).find(d=>d.tagName==="p"&&f(d,"data-block-id")!==void 0&&N.test(f(d,"data-block-id")));s&&t.push({line:o.sourceCodeLocation?.startLine,id:f(s,"data-block-id"),at:s.sourceCodeLocation?.startLine})}},{inTemplates:!1});let a=[];if(r.length){let o=r.slice(0,6).map(({id:i,line:s})=>`${i?`"${i}"`:"an empty one"} (line ${s})`);a.push(`data-block-id is not an id Gallery made: ${z(o)}${r.length>6?` and ${r.length-6} more`:""}; an id is eight lowercase letters and digits, a letter first, and only Gallery makes one: take the attribute off the element (gallery export gives every block an id), and write none for a new block`)}for(let{line:o,id:i,at:s}of t.slice(0,6))a.push(`line ${o}: the list item has no data-block-id but the paragraph in it has one ("${i}", line ${s}): an id stays on the item the words belong to, not on a paragraph in it; put "${i}" on the <li> and take it off the <p> (a paragraph held by an item has an id of its own, or none, besides the item's)`);return t.length>6&&a.push(`${t.length-6} more list items have no data-block-id over a paragraph that has one (lines ${t.slice(6).map(({line:o})=>o).join(", ")})`),a}async function A(n){let l=new Map,r=await u.readdir(n,{withFileTypes:!0}).catch(()=>[]);for(let t of r){if(!t.isDirectory()||t.name.startsWith(".")||E.has(t.name))continue;let a=G(I.join(n,t.name));a.old||(await u.readFile(a.json,"utf8").then(i=>JSON.parse(i),()=>null))?.instructions!==!0||!await u.stat(a.html).then(()=>!0,()=>!1)||l.set(t.name,`doc.json says "instructions": true, which marks the \u5199\u4F5C\u504F\u597D page (the user's writing preferences): Gallery lists, checks and exports no folder that carries it and moves it into .gallery/pages/ when it next migrates the workspace. A document never has it: take "instructions" out of doc.json`)}return l}import{reportsDirectory as g}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as T}from"../browser/shared/workspace.mjs";var B=()=>`No documents in ${g} yet: gallery new <slug> "<title>" makes one.`;async function oe(n){let l=await A(g),r=n.indexOf("--"),t=n.filter((e,p)=>(r===-1||p<r)&&!y(e)),a=t.filter(e=>l.has(e)),o=n.filter(e=>!a.includes(e)),i=t.length>0&&a.length===t.length,{slugs:s,options:d}=i?{slugs:[],options:new Set(n.includes("--allow-failures")?["--allow-failures"]:[])}:await $({options:["--allow-failures"],argv:o,noneIsAll:!0}),w=t.length===0||n.includes("--all")?[...l.keys()]:a;s.length===0&&w.length===0&&(console.error(B()),process.exit(1)),await L(s),await C(s),await M(s);let{reports:m,failures:c}=s.length?await j(s,{prepare:D()}):{reports:[],failures:new Map};for(let e of m){let p=O(e.written??e.html);p.length&&c.set(e.slug,[...c.get(e.slug)??[],...p])}for(let e of w)c.set(e,[...c.get(e)??[],l.get(e)]);let h=m.filter(e=>!c.has(e.slug));for(let e of h)console.log(`OK ${e.slug}`);for(let e of s)T(K(e,g)).both&&console.log(`note ${e}: both doc.html and report.html: report.html is not read`);x(m),F(m);let k=h.length+c.size;console.log(`Checked ${k} document${k===1?"":"s"}: ${h.length} passed, ${c.size} failed.`),await v(c,{allow:d.has("--allow-failures")})}export{B as a,oe as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-WHGANNEY.mjs";import"./chunk-S6YEC4GE.mjs";import"./chunk-V3XROSP5.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-OKVQQ3CX.mjs";import"./chunk-X4WNLFIK.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-2MYTOOP6.mjs";import"./chunk-LHGKPMTI.mjs";import"./chunk-TLNJWEFY.mjs";import"./chunk-ZOEJQOKT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-QR4V4A2Z.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-TQZU7D7C.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-6N25CJ6Y.mjs";import"./chunk-F4CT35KL.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-6ILJWFYW.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-NOGQX56R.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};
|
|
@@ -0,0 +1,13 @@
|
|
|
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{c as Oe,f as we,g as ge,h as $e,i as qe,j as ne,l as Q,m as Ge,n as Ae,o as Ke,p as Ve,q as ze,r as w,t as Qe,u as Ye}from"./chunk-S6YEC4GE.mjs";import{N as Xe}from"./chunk-V3XROSP5.mjs";import{a as G}from"./chunk-5TLLIZT7.mjs";import{n as Ne,r as Je}from"./chunk-OM24O4KR.mjs";import{a as me}from"./chunk-2MYTOOP6.mjs";import{b as Ue,d as We,h as pe,i as Ze}from"./chunk-LHGKPMTI.mjs";import{e as Te,g as te}from"./chunk-TLNJWEFY.mjs";import{b as Se}from"./chunk-VRPVVMRB.mjs";import{a as Be}from"./chunk-HYMEEXKN.mjs";import{b as S,i as Pe}from"./chunk-L4WLQYFC.mjs";import{f as Ee,j as He}from"./chunk-TKWEX4FD.mjs";import{randomBytes as Ct}from"node:crypto";import{existsSync as It}from"node:fs";import T from"node:fs/promises";import L from"node:path";import{isInstance as Re,isSlot as jt,partOf as Mt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as ke,FALLBACK as Rt,FIELDS as Dt,INSTANCE as ft,PACKAGE_ID as _t,SLOT as Ft}from"../browser/shared/components/installed.mjs";import{attr as ce,walk as Ht}from"../browser/shared/html-tree.mjs";import{defaultWorkspace as Pt,documentDirectory as Bt,documentFiles as Jt,layoutOf as oe,packageFolders as Ut,slugTaken as Wt}from"../browser/shared/workspace.mjs";var et=10,Ce=6,Zt=3,qt=100,De=1024,_e=900,Gt=4e3,le=3e4,Kt=1500,Ie=3e4,je=500,Vt=5e3,zt=200,tt=20,nt=160,ye=12,Qt=3600*1e3,Yt=["p","pi","pin"],he=e=>new Promise(t=>setTimeout(t,e));async function at(e){let{_keyDefinitions:t}=await import("./chunk-43B75J5T.mjs"),n=Object.hasOwn(t,e)?[e]:e.split("+"),a=new Set(["Control","Shift","Alt","Meta"]);if(n.some(o=>!Object.hasOwn(t,o))||n.slice(0,-1).some(o=>!a.has(o)))throw new S(`Not a key: ${e} (a key as a browser names it, Enter, Space, Escape, Tab, ArrowRight, a letter or a digit, after modifiers joined by "+": Shift+Tab, Control+Enter).`);return n}var ie={press:"<selector>",drag:'<selector>, with "to": <selector>',key:"[<selector>, <key>]",type:"[<selector>, <words>]",select:"[<selector>, <value>]"};async function ut(e,t=null){let n=h=>new S(t?`${t[0].toUpperCase()}${t.slice(1)}: ${h}`:`${h[0].toUpperCase()}${h.slice(1)}`);if(!e||typeof e!="object"||Array.isArray(e))throw n(`a step is an object naming one gesture: ${Object.entries(ie).map(([h,d])=>`"${h}": ${d}`).join(", ")}, and "then": <key> after it.`);let a=Object.keys(e).filter(h=>!Object.hasOwn(ie,h)&&!["to","then","replace"].includes(h));if(a.length)throw n(`no such field: ${a.join(", ")} (a step names one of ${Object.keys(ie).join(", ")}, "to" with a drag, "replace": true with typing and "then" after any).`);let o=Object.keys(ie).filter(h=>e[h]!==void 0),s=h=>t?`"${h}"`:`--${h}`;if(o.length!==1)throw n(o.length?`one gesture at a time: ${o.map(s).join(" or ")}.`:t?`name the gesture: ${Object.keys(ie).map(s).join(", ")}.`:"Say the gesture: --press <selector>, --drag <selector> --to <selector>, --key <selector> <key>, --type <selector> <words> or --select <selector> <value>; or --steps <file>.");let[i]=o;if(e.to!==void 0&&i!=="drag")throw n(`${s("to")} goes with ${s("drag")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}.`);if(i==="drag"&&e.to===void 0)throw n(`${s("drag")} takes ${s("to")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}, where it is dropped.`);if(e.replace!==void 0&&i!=="type")throw n(`${s("replace")} goes with ${s("type")}: it selects what the field holds before the words go in.`);if(e.replace!==void 0&&e.replace!==!0)throw n(`${s("replace")} is true: ${t?'"replace": true':"--replace"} selects what the field holds before the words go in.`);let l=(h,d)=>{if(typeof h!="string"||!h)throw n(`${d} is words: ${JSON.stringify(h)}.`);return h},c=(h,d)=>{if(!Array.isArray(h)||h.length!==2)throw n(`${s(i)} takes ${t?`[<selector>, ${d}]`:`<selector> ${d}`}.`);return[l(h[0],"a selector"),l(h[1],d)]},r={kind:i};if(i==="press"&&(r.at=l(e.press,"a selector")),i==="drag"&&Object.assign(r,{at:l(e.drag,"a selector"),to:l(e.to,"a selector")}),i==="key"){let[h,d]=c(e.key,"<key>");Object.assign(r,{at:h,key:d,keys:await at(d)})}return i==="type"&&([r.at,r.text]=c(e.type,"<words>"),e.replace&&(r.replace=!0)),i==="select"&&([r.at,r.value]=c(e.select,"<value>")),e.then!==void 0&&(r.then={key:l(e.then,"a key"),keys:await at(l(e.then,"a key"))}),r}async function Xt(e,t={},n=!1){if(n&&e.has("--steps"))throw new S('--steps <file> holds every gesture: --replace goes in a step of it, as { "type": [".name", "\u65B0\u540D\u5B57"], "replace": true }, not beside it.');if(e.has("--steps")){let o=["--press","--drag","--to","--key","--type","--select","--then"].filter(s=>e.has(s));if(o.length)throw new S(`--steps <file> holds every gesture: ${o.join(", ")} goes in it, not beside it.`);return null}let a={};for(let o of["press","drag","to","then"])e.has(`--${o}`)&&(a[o]=e.get(`--${o}`));for(let o of["key","type","select"])e.has(`--${o}`)&&(a[o]=[e.get(`--${o}`),t[`--${o}`]]);return n&&(a.replace=!0),ut(a)}async function en(e){let t=L.basename(e),n;try{n=await T.readFile(e,"utf8")}catch(s){throw new S(`No steps file: ${G(e)} (${s.code??ne(s)}).`)}let a;try{a=JSON.parse(n.replace(/^/,""))}catch(s){throw new S(`${t} is no JSON: ${ne(s)}. A steps file is a list of steps, as [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`)}if(!Array.isArray(a)||a.length===0)throw new S(`${t} holds no list of steps: write [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`);if(a.length>tt)throw new S(`${t} holds ${a.length} steps, and a trial makes ${tt} at most: try fewer at a time.`);let o=[];for(let[s,i]of a.entries())o.push(await ut(i,`step ${s+1} of ${t}`));return o}var pt=e=>{let t=e.parentNode;for(;t&&!Re(t);)t=t.parentNode;return t??null},tn=(e,t)=>{for(let n=e.parentNode;n&&n!==t;n=n.parentNode)if(jt(n))return ce(n,Ft);return null};function wt(e){let t=[];return Ht(Be(e),n=>{if(!Re(n))return;let a=pt(n);t.push({element:n,id:ce(n,ke),blockId:ce(n,"data-block-id")??null,line:n.sourceCodeLocation?.startLine,in:a?{id:ce(a,ke),line:a.sourceCodeLocation?.startLine,slot:tn(n,a)}:null})},{inTemplates:!1}),t}var gt=({line:e,in:t},n)=>`${n}:${e}${t?`, in ${t.slot?`the slot ${t.slot} of `:""}${t.id} at ${n}:${t.line}`:""}`,nn=(e,{id:t,blockId:n})=>n??(e.filter(a=>a.id===t).length===1?t:null);function an(e,t,{slug:n,name:a}){let o=()=>e.map(c=>` ${nn(e,c)??"(no id yet: gallery export gives it one)"} ${c.id} at ${gt(c,a)}`).join(`
|
|
3
|
+
`);if(t===null){if(e.length===1)return 0;throw new S(`${n} holds ${e.length} instances: name one, gallery block try ${n} <instance id> \u2026
|
|
4
|
+
${o()}`)}let s=e.findIndex(({blockId:c})=>c===t);if(s>=0)return s;let i=t.includes("/")?t:`local/${t}`,l=_t.test(i)?e.flatMap((c,r)=>c.id===i?[r]:[]):[];if(l.length===1)return l[0];throw new S(l.length?`${n} holds ${l.length} instances of ${i}: name one by its id
|
|
5
|
+
${o()}`:`${n} holds no instance ${t}:
|
|
6
|
+
${o()}`)}var on=e=>e.replace(/\s+data-block-id="[^"]*"/g,""),ot=e=>on(Se(e).text),sn=(e,t)=>(typeof t=="function"?t(e):wt(e)[t]?.element)??null;function st(e,t,n){let a=sn(e,t);if(!a||ce(a,ke)!==n.id)return null;let o=[],s=Object.entries(n.parts).map(([r,{at:h}])=>{let d=Mt(a,h).filter(u=>u.sourceCodeLocation?.endTag&&!Re(u)&&pt(u)===a).map(({sourceCodeLocation:{startTag:u,endTag:f}})=>({start:u.endOffset,end:f.startOffset}));return o.push(...d),{name:r,text:d.map(({start:u,end:f})=>e.slice(u,f)).join(`
|
|
7
|
+
`)}}),i=o.sort((r,h)=>r.start-h.start||h.end-r.end).filter((r,h)=>!o.slice(0,h).some(d=>d.start<=r.start&&r.end<=d.end)),l="",c=0;for(let{start:r,end:h}of i)l+=e.slice(c,r),c=h;return{parts:s,outside:l+e.slice(c)}}function rn(e,t,n,a){let[o,s]=[st(e,n,a),st(t,n,a)];return!o||!s?{parts:[],outside:null,gone:!0}:{parts:o.parts.flatMap(({name:l,text:c},r)=>c===s.parts[r].text?[]:[{name:l,...Ae(c,s.parts[r].text),how:Ve(c,s.parts[r].text),runs:Ke(c,s.parts[r].text)}]),outside:o.outside===s.outside?null:Ae(o.outside,s.outside),gone:!1}}function cn(e){let t=n=>n.length>nt?`${n.slice(0,nt)}\u2026`:n;return e.flatMap(({name:n,runs:a=[]})=>{let o=a.flatMap(({removed:l,added:c})=>[...l.map(r=>`- ${t(r)}`),...c.map(r=>`+ ${t(r)}`)]),s=e.length>1?" ":" ",i=o.slice(0,ye).map(l=>`${s}${l}`);return o.length>ye&&i.push(`${s}\u2026 ${o.length-ye} more line${o.length-ye===1?"":"s"}`),e.length>1?[` ${n}:`,...i]:i})}async function ln(e,t=null){let{components:n,marker:a}=oe(e);return await mt([t,a,n].filter(Boolean))+me+te+je}async function dn(e,{directory:t,files:n,text:a}){let{scratch:o}=oe(e);await T.mkdir(o,{recursive:!0});let s;do s=`try-${Ct(4).toString("hex")}`;while(Wt(s,e)||It(L.join(o,s)));let i=L.join(o,s);await T.mkdir(i),await T.cp(L.join(t,"assets"),L.join(i,"assets"),{recursive:!0}).catch(c=>{if(c.code!=="ENOENT")throw c}),await T.copyFile(n.json,L.join(i,L.basename(n.json))).catch(c=>{if(c.code!=="ENOENT")throw c});let l=L.join(i,L.basename(n.html));return await T.writeFile(l,a),{slug:s,folder:i,file:l}}async function $t(e,t){let{scratch:n,state:a}=oe(e);await T.rm(L.join(n,t),{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});for(let o of await T.readdir(a).catch(()=>[]))await T.rm(L.join(a,o,t),{recursive:!0,force:!0,maxRetries:3,retryDelay:100}).catch(()=>{})}async function hn(e,t=Date.now()){let{scratch:n}=oe(e);for(let a of await T.readdir(n,{withFileTypes:!0}).catch(()=>[])){if(!a.isDirectory()||!/^try-[a-f0-9]{8}$/.test(a.name))continue;let{mtimeMs:o}=await T.stat(L.join(n,a.name)).catch(()=>({mtimeMs:t}));t-o>=Qt&&await $t(e,a.name)}}async function mt(e){let t=[...e];for(let a of e)for(let o of await T.readdir(a,{recursive:!0,withFileTypes:!0}).catch(()=>[]))t.push(L.join(o.parentPath,o.name));let n=await Promise.all(t.map(a=>T.stat(a).then(({mtimeMs:o})=>o,()=>0)));return Math.max(...n)}var fn=e=>fetch(`${e}/__gallery/workspace/components`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t?.packages)?t.packages:null,()=>null);async function un(e,t,n){let{components:a,marker:o}=oe(e),s=Ut(e).find(m=>m.id.toLowerCase()===t)?.folder??L.join(a,...t.split("/")),[i,l]=await Promise.all([mt([o,s]),fn(n)]),{packages:c,problems:r,settings:h}=Ee(e),d=l?.find(m=>m.id===t)??null,u=l?d?.state??"none":null,f=u==="normal"||u==="hidden",g=h.disabled.includes(t),y=r.get(t),b=y&&!g&&f?He("en",y.problem):null,p=l!==null&&c.has(t)&&!f;return{by:i+(b?Te:me+te),held:b,behind:p,off:g,stamp:(c.get(t)??y)?.stamp??null,state:u,reason:d?.reason?.en??null}}var yt=({state:e,reason:t})=>e==="none"?"no such custom block":t?`it as not loading (${t})`:"it turned off";function pn(e,{said:t,unparsed:n=null,off:a,behind:o=!1,state:s,reason:i}){let l="the instance shows what it holds, read-only, so a reader can do nothing with it";return n?`${l}: its kit.js did not parse, so no component of it started, and the console says ${n}`:t.length?`${l}: its component failed as the page started it, and the console says ${t.join("; ")}`:a?`${l}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868`:o?`${l}: the server has not taken ${e} as components/ holds it, where it loads: its catalog in use has ${yt({state:s,reason:i})}`:s==="disabled"&&!i?`${l}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868`:s==="broken"||s==="disabled"?`${l}: the server has ${e} as not loading (${i}): gallery block check ${e} says why`:s==="none"?`${l}: the server has not taken ${e} as components/ holds it (its catalog in use has no such custom block)`:s?`${l}: the page was served before the server took ${e} as components/ holds it, and did not load itself again with it`:`${l}: its component failed or never started, and the console said nothing of it`}var wn=(e,t,n)=>t.held?`${e} does not load as components/ holds it (${t.held}), and the server keeps it as it was until components/ has not changed for ${Te/1e3}s, as it keeps a custom block written file by file`:t.behind?`components/ holds ${e} as loading, and the server's catalog in use still has ${yt(t)}: it takes what components/ holds once that has not changed for ${te/1e3}s`:n?`${e} or gallery.json changed a moment ago, and the server takes the change once components/ has not changed for ${te/1e3}s, the page served before loading itself again for it`:`the server took ${e} as components/ holds it, and the page served before is to load itself again with it`,gn=(e,t,n)=>t.held?`the server still keeps ${e} as it was`:t.behind?`the server has still not taken ${e} as components/ holds it`:`the server took ${e} as components/ holds it, and the page did not load itself again with it in ${n/1e3}s`;async function $n({root:e,id:t,origin:n,loadedAt:a,loaded:o,told:s=Vt,say:i=l=>console.log(l)}){let l=Date.now(),c,r=0,h=0,d=!1;for(;;await he(zt)){let u=await un(e,t,n),f=Date.now();c!==void 0&&u.stamp!==c&&(r=f),c=u.stamp,u.behind&&!h&&(h=f);let g=Math.max(u.by,...[r,h].filter(Boolean).map(b=>b+me+te)),y=o()?"the page loaded itself again":u.off?`gallery.json turns ${t} off now`:a>=g?`the page was asked for after the server took ${t} as components/ holds it`:f>g+s?gn(t,u,s):null;if(y)return d&&i(`Waited ${((f-l)/1e3).toFixed(1)}s: ${y}`),u;d||g-f<=je&&f-l<=je||(d=!0,i(`Waiting: ${wn(t,u,g>f)}, ${Math.ceil((g+s-f)/1e3)}s more at most`))}}function mn({instance:e,at:t,card:n}){return typeof n=="string"?[...[...document.querySelectorAll(".gallery-board > .gallery-card")].find(o=>o.getAttribute("data-card-id")===n)?.children??[]].find(o=>o.matches(e))??null:[...document.querySelectorAll(e)][t]??null}function yn(e,t){let n=f=>`<${f.localName}${f.classList.length?` class="${f.getAttribute("class")}"`:""}>`,a;try{a=e.querySelector(t)}catch{return{invalid:!0}}if(!a)return{none:!0,held:[...new Set([...e.querySelectorAll("[class]")].filter(f=>f.getClientRects().length>0).flatMap(f=>[...f.classList].map(g=>`.${g}`)))].slice(0,16)};let o=((a instanceof HTMLElement?a.innerText:a.textContent)??"").replace(/\s+/g," ").trim(),s={named:n(a),words:o.length>40?`${o.slice(0,40)}\u2026`:o},i=[...a.getClientRects()].filter(({width:f,height:g})=>f>0&&g>0);if(!i.length)return{...s,hidden:!0};let{left:l,top:c,right:r,bottom:h,width:d,height:u}=i.reduce((f,g)=>f.width*f.height>=g.width*g.height?f:g);return{...s,box:{left:l,top:c,right:r,bottom:h,x:l+d/2,y:c+u/2}}}function kn(e,{selector:t,x:n,y:a}){let o=e.querySelector(t),s=document.elementFromPoint(n,a);return!s||o.contains(s)?null:`<${s.localName}${s.classList.length?` class="${s.getAttribute("class")}"`:""}>`}function bn(e,{at:t,to:n}){let[a,o]=[e.querySelector(t),e.querySelector(n)];return a===o?"same":a.contains(o)?"inside":null}function kt(e){let t=a=>a instanceof Element?`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`:"the page",n={edits:[],taken:0,states:[],started:null,dropped:null,effect:null};addEventListener("doc-component-edit",a=>{a.target===e&&(n.edits.push({taken:a.defaultPrevented,parts:(a.detail?.parts??[]).map(({name:o})=>o)}),a.defaultPrevented&&(n.taken+=1))}),new MutationObserver(a=>{for(let{oldValue:o}of a)n.states.push(o);n.states.push(document.documentElement.getAttribute("data-ge-save"))}).observe(document.documentElement,{attributes:!0,attributeFilter:["data-ge-save"],attributeOldValue:!0}),document.addEventListener("dragstart",a=>{n.started=t(a.target)},!0),document.addEventListener("drop",a=>{n.dropped=t(a.target)},!0),document.addEventListener("dragend",a=>{n.effect=a.dataTransfer?.dropEffect??null},!0),globalThis.__galleryTry=n}function vn(){return Object.assign(globalThis.__galleryTry,{edits:[],started:null,dropped:null,effect:null}),{taken:globalThis.__galleryTry.taken}}function bt(e){let t=[...e.querySelectorAll("input, select, textarea")].map(n=>n instanceof HTMLInputElement&&["checkbox","radio"].includes(n.type)?n.checked?"ticked":"not ticked":n.value);return{words:(e.innerText??"").replace(/\s+/g," ").trim(),fields:t}}function xn(e){let n=(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??"").replace(/\s+/g," ").trim();return n.length>40?`${n.slice(0,40)}\u2026`:n}function En(e){let t=document.activeElement,n="";if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{n=t.value.slice(t.selectionStart??0,t.selectionEnd??0)}catch{}else{let o=getSelection();o&&!o.isCollapsed&&e.contains(o.anchorNode)&&(n=o.toString())}let a=n.replace(/\s+/g," ").trim();return a.length>40?`${a.slice(0,40)}\u2026`:a}function Sn(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{return t.selectionStart===null?null:t.selectionEnd===t.value.length}catch{return null}let n=getSelection();if(!n?.rangeCount||!e.contains(n.focusNode))return null;let a=document.createRange();return a.selectNodeContents(e),a.setStart(n.focusNode,n.focusOffset),a.toString().trim()===""}function Tn(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){t.select();return}let n=document.createRange();n.selectNodeContents(e),getSelection()?.removeAllRanges(),getSelection()?.addRange(n)}function it(e){let t=document.activeElement;return t&&(t===e||e.contains(t)||t instanceof HTMLElement&&t.isContentEditable&&t.contains(e))?null:`<${t?.localName??"body"}>`}function Nn(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){try{t.setSelectionRange(t.value.length,t.value.length)}catch{}return}let n=document.createRange();n.selectNodeContents(e),n.collapse(!1),getSelection()?.removeAllRanges(),getSelection()?.addRange(n)}function On(e,{selector:t,value:n}){let a=e.querySelector(t);if(!(a instanceof HTMLSelectElement))return{notSelect:`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`};let o=[...a.options],s=o.find(i=>i.value===n)??o.find(i=>i.textContent.trim()===n);return s?a.disabled||s.disabled?{disabled:!0}:(a.focus(),s.selected=!0,a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),{chosen:s.textContent.trim()}):{options:o.map(i=>i.value===i.textContent.trim()?i.value:`${i.value} (${i.textContent.trim()})`)}}async function Fe(e,{still:t,step:n,wait:a=0}){let o=globalThis.__galleryQueries??null,s=Date.now()+a,i=()=>o!==null&&o.pending.size>0&&Date.now()<s,l=()=>new Promise(r=>{requestAnimationFrame(r),setTimeout(r,100)});await l(),await l();let c=e.outerHTML;for(let r=0,h=Date.now()+t;r<3;){if(Date.now()>h)return null;await new Promise(u=>setTimeout(u,n));let d=e.outerHTML;i()?(r=0,h=Date.now()+t):r=d===c?r+1:0,c=d}return c}function An(e,t,{left:n,top:a,right:o,bottom:s}){let i=0;for(let[l,c,r,h]of[[e.x,t.x,n,o],[e.y,t.y,a,s]]){if(c===l)continue;let[d,u]=[(r-l)/(c-l),(h-l)/(c-l)];i=Math.max(i,Math.min(d,u))}return i*Math.hypot(t.x-e.x,t.y-e.y)}function Ln(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y),a=c=>n===0?{x:e.x,y:e.y}:{x:e.x+(t.x-e.x)*c/n,y:e.y+(t.y-e.y)*c/n},o=Math.min(Ce,n),s=An(e,t,t)-Zt,i=s>o?s:n,l=[a(o/2),a(o)];for(let c=1;c<=et;c++)l.push(a(o+(i-o)*c/et));return i!==n&&l.push({x:t.x,y:t.y}),l}var de={press:"press",drag:"drag",key:"key",type:"typing",select:"choice"},ae=(e,{named:t,words:n})=>`${e} (${t}${n?` "${n}"`:""})`,rt=e=>Object.assign(new S(e),{unfound:!0});async function vt(e,t){let n=t.slice(0,-1);for(let a of n)await e.keyboard.down(a);await e.keyboard.press(t.at(-1));for(let a of n.toReversed())await e.keyboard.up(a)}async function Cn(e,t,n){let a=!1;for(let[o]of n.matchAll(/[\x00-\x7f]+|[^\x00-\x7f]+/gu)){if(/^[\x00-\x7f]/.test(o)){await e.keyboard.type(o);continue}a=!0;for(let s of Yt)await t.send("Input.imeSetComposition",{text:s,selectionStart:s.length,selectionEnd:s.length});await t.send("Input.insertText",{text:o})}return a?/[\x00-\x7f]/.test(n)?"its ASCII key by key and the rest through an input method":"through an input method, composed then committed":"key by key"}async function In(e,t,n,a){let o=await jn(e,t,n,a);return n.then?(await vt(e,n.then.keys),{...o,said:`${o.said}, then ${n.then.key} pressed where the focus was`}):o}async function jn(e,t,n,a){let o=async c=>{let r=await w(t.evaluate(yn,c),"the page was asked what the selector finds");if(r.invalid)throw new S(`Not a selector: ${c}.`);if(r.none)throw rt(`Nothing in the instance is ${c}${r.held.length?`: what it shows has ${r.held.join(", ")}`:": it shows nothing with a class"}.`);if(r.hidden)throw rt(`${c} finds ${r.named} in the instance, which is not shown (it has no box on the page), so a reader cannot reach it: name what it shows.`);return r},s=await o(n.at);if(n.kind==="press"){let{x:c,y:r}=s.box,h=await w(t.evaluate(kn,{selector:n.at,x:c,y:r}),"the page was asked what stands at the press");return await e.mouse.move(c,r),await e.mouse.down(),await e.mouse.up(),{said:`a press on ${ae(n.at,s)}, with the pointer at its middle`,over:h}}if(n.kind==="drag"){let c=await o(n.to),r=await w(t.evaluate(bn,{at:n.at,to:n.to}),"the page was asked where the drag ends");if(r)throw new S(`${r==="same"?`--drag and --to find the same element, ${s.named}`:`--to ${n.to} finds ${c.named}, which stands in what --drag ${n.at} finds, ${s.named}`}: a drag ends where it is dropped, on another element of the instance (another column, another row), which --to names.`);if(Math.hypot(c.box.x-s.box.x,c.box.y-s.box.y)<Ce)throw new S(`The middles of what --drag ${n.at} and --to ${n.to} find stand less than ${Ce}px apart, too near for a drag to start: name with --to where it is dropped, further off.`);let h=Ln(s.box,c.box);await e.mouse.move(s.box.x,s.box.y),await e.mouse.down();for(let{x:d,y:u}of h)await e.mouse.move(d,u);return await he(qt),await e.mouse.up(),{said:`a drag of ${ae(n.at,s)} to ${ae(n.to,c)}, with the pointer in ${h.length} moves, released as it comes onto it`}}if(n.kind==="select"){let c=await w(t.evaluate(On,{selector:n.at,value:n.value}),"the page was asked to choose the option");if(c.notSelect)throw new S(`${n.at} finds ${c.notSelect} in the instance, which is no <select>: --select names a <select> the instance draws, and the option by its value or its words.`);if(c.options)throw new S(`${n.at} has no option ${JSON.stringify(n.value)}: ${c.options.length?`its options are ${c.options.join(", ")}`:"it has no option"}.`);if(c.disabled)throw new S(`${n.at} or its option ${JSON.stringify(n.value)} is disabled, so a reader cannot choose it.`);return{said:`${JSON.stringify(c.chosen)} chosen in ${ae(n.at,s)}, as a reader picks an option`}}let i=await t.$(n.at);if(n.kind==="type"){let c=!1,r=await w(e.evaluate(xn,i),"the page was asked what the field holds");await w(e.evaluate(it,i),"the page was asked where the focus is")&&(await e.mouse.click(s.box.x,s.box.y),await w(e.evaluate(Nn,i),"the caret went to the end"),c=!0),n.replace&&await w(e.evaluate(Tn,i),"all the field holds was selected");let h=await w(e.evaluate(it,i),"the page was asked where the focus is"),d=await w(e.evaluate(En,i),"the page was asked what is selected"),u=c||!r||n.replace||d?!0:await w(e.evaluate(Sn,i),"the page was asked where the caret is"),f=await Cn(e,a,n.text),g=c?", pressed first":", where the focus was",y='(--replace, or "replace": true in a step, puts them in its place)',b=n.replace?`${g}, ${r?`all it held (${JSON.stringify(r)}) selected first (--replace), so that the words took its place`:"nothing in it to replace"}`:d?`${g}, ${d===r?"all it held":"part of it"} (${JSON.stringify(d)}) selected already (a step before), so that the words took its place`:c?`, pressed first and the caret at its end${r?`: it held ${JSON.stringify(r)}, and the words went after it ${y}`:""}`:r?u===!1?`, where the focus was, the caret inside what it held (${JSON.stringify(r)}), where a step before left it (a press puts it where the pointer lands, an arrow key moves it), so that the words went in there, not after it ${y}`:u?`, where the focus was, the caret at its end: it held ${JSON.stringify(r)}, and the words went after it ${y}`:`, where the focus was: it held ${JSON.stringify(r)}, and the words went in at the caret, where a step before left it ${y}`:", where the focus was";return{said:`${JSON.stringify(n.text)} typed in ${ae(n.at,s)}${b}, ${f}`,unfocused:h,typed:!0}}await w(i.focus(),"the focus went to the element");let l=await w(e.evaluate(c=>document.activeElement===c||c.contains(document.activeElement)?null:`<${document.activeElement?.localName??"body"}>`,i),"the page was asked where the focus is");return await vt(e,n.keys),{said:`${n.key} pressed with the focus given to ${ae(n.at,s)}, as Tab gives it`,unfocused:l}}var xt=e=>fetch(`${e}/__gallery/workspace/info`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok,()=>!1);async function Mn(e,t,n){let a=Date.now();for(let o=0,s=0;;await he(100)){let{seen:i,now:l}=await w(e.evaluate(r=>({seen:globalThis.__galleryTry.states.slice(r),now:document.documentElement.getAttribute("data-ge-save")}),t),"the page was asked where saving stands"),c=l!=="saved"||i.some(r=>r!=="saved");if(c&&l==="saved")return"saved";if(l==="stopped"||l==="reloading")return l;if(o=l==="held"?o+1:0,o>=3)return"held";if(s=l==="offline"?s+1:0,s>0&&s%10===0&&!await xt(n))return"offline";if(!c&&Date.now()-a>Kt)return"unchanged";if(Date.now()-a>Ie)return l}}var Rn=e=>({held:"a card waits for a reader: someone else changed the part meanwhile, and the page held its write for the reader there, which closing the page dropped",offline:"the page could not reach the server (offline)",stopped:"the page stopped saving (stopped): the server refused its write",reloading:"the page loaded itself again (doc.html or a custom block it holds changed meanwhile)",waiting:`it waited ${Ie/1e3}s to be saved and never was`,syncing:`its save took more than ${Ie/1e3}s`})[e];function Dn(e,{parts:t,outside:n,gone:a},{gesture:o,name:s,held:i=!1,scratch:l=!1,aside:c="data-block-id aside"}){if(l)return{unverified:`${e}${!a&&t.length?`, the copy holding what the ${o} wrote, ${Q(t)}`:""}: the trial was made on a scratch copy, gone now, and ${s} holds nothing of it`};let r=n?`; outside the instance's parts -${n.removed} +${n.added} lines someone else wrote meanwhile, which stay`:"";return a?{unverified:`${e}, and ${s} holds the instance no more where it stood: someone else wrote the file meanwhile`}:t.length===0?{unverified:`${e}: ${s} is as it was${n?" in the instance's parts":""} (${c})${r}`}:i?{unverified:`${e}: what ${s} holds of ${Q(t)} is someone else's, which stays${r}`}:{unverified:`${e}: ${s} holds what the ${o} wrote, ${Q(t)}, kept (--keep)${r}`}}function _n(e,t,{over:n,unfocused:a,refusals:o,name:s}){let i=[];return n&&i.push(`the press landed on ${n}, which stands over it there`),a&&i.push(e==="type"?`the element takes no typing (a field or an editable element), so the words went to ${a}`:`the element takes no focus (a button, a field or a tabindex), so the key went to ${a}`),t.started&&!t.dropped?i.push(`an HTML5 drag started (dragstart on ${t.started}) and nothing took its drop where it was released (dragend's dropEffect ${t.effect??"none"}): a list a card is dropped on cancels dragenter as well as dragover (preventDefault), or a release as the pointer comes onto it drops nothing`):t.dropped&&t.edits.length===0&&i.push(`it was dropped on ${t.dropped}, and no context.edit came of it`),t.edits.some(({taken:l})=>l)?i.push("context.edit was taken, and its change left what the parts hold as it was"):t.edits.length?i.push(`context.edit was called and the page refused it${o.length?`: the console says ${o.join("; ")}`:""}`):t.started||i.push(e==="type"?"no context.edit came of it: the component answers no typing there, or writes what was typed only on a key or as the field loses the focus (then Enter, --then Enter), or asked while context.canEdit() was false":`no context.edit came of it: the component answers no ${de[e]} there, or asked while context.canEdit() was false`),`the ${de[e]} wrote nothing to ${s}: ${i.join("; ")}`}async function Et(e,t){await qe(e);let n={own:new Map,others:new Map,dialogs:new Map,pending:[],page:0,from:0},a=new RegExp(`/__gallery/components/${t}/kit\\.js[^:\\s)]*:(\\d+)`),o=(i,l,{at:c="",unparsed:r=!1}={})=>{if(l<n.from)return;let h=i.split(`
|
|
8
|
+
`)[0],d=a.exec(i)??a.exec(c);i.includes(t)||d?n.own.set(h,{line:Number(d?.[1])||null,page:l,unparsed:r&&a.test(c)}):n.others.set(h,{page:l})};e.on("request",i=>{i.isNavigationRequest()&&i.frame()===e.mainFrame()&&(n.page+=1)}),e.on("console",i=>{if(!["error","warn","warning"].includes(i.type())||/^Failed to load resource/.test(i.text()))return;let{page:l}=n;n.pending.push(Promise.all(i.args().map(c=>c.evaluate(r=>r instanceof Error?r.stack:String(r)).catch(()=>""))).then(c=>o(c.join(" ")||i.text(),l)))});let s=await ze(e,{add:i=>n.dialogs.set(i,{page:n.page})});return s.on("Runtime.exceptionThrown",({exceptionDetails:{exception:i,text:l,url:c,lineNumber:r,stackTrace:h}})=>{o(i?.description??String(i?.value??l),n.page,{at:c?`${c}:${r+1}`:"",unparsed:!h&&i?.className==="SyntaxError"})}),await s.send("Runtime.enable"),n}function Fn(e){e.from=e.page;for(let t of[e.own,e.others,e.dialogs])for(let[n,{page:a}]of t)a<e.from&&t.delete(n)}var re=e=>Promise.race([Promise.all(e.pending),he(2e3)]);async function Hn(e){let t=n=>e.waitForSelector(n,{timeout:le}).catch(a=>{if(a.name==="TimeoutError")throw a;return e.waitForSelector(n,{timeout:le})});try{return await t("[data-doc-ready]"),await t("html[data-ge-editing][data-ge-save]"),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&document.documentElement.getAttribute("data-ge-save")==="saved",{timeout:le}),!0}catch(n){if(n.name!=="TimeoutError")throw n;return!1}}async function St(e,{where:t,id:n}){let a=await w(e.evaluateHandle(mn,{instance:ft,...t}),"the page was asked for the instance"),o=await w(a.evaluate((s,{fallback:i,id:l})=>!(s instanceof Element)||s.getAttribute("data-doc-component")!==l?null:(DocKit.reveal?.(s),{fallback:s.hasAttribute(i),height:s.getBoundingClientRect().height}),{fallback:Rt,id:n}),"the page was asked for the instance");return o?(await e.setViewport({width:De,height:Math.min(Gt,Math.max(_e,Math.ceil(o.height)+240))}),await w(a.evaluate(s=>s.scrollIntoView({block:"center",behavior:"instant"})),"the instance was brought into view"),await w(a.evaluate(Fe,{still:we,step:ge,wait:$e}),"the instance held still"),{host:a,fallback:o.fallback}):null}function Pn({at:e,found:t}){return{where:{at:e},ready:Hn,saves:n=>({mark:()=>w(n.evaluate(()=>globalThis.__galleryTry.states.length),"the page was asked where saving stands"),until:(a,o)=>Mn(n,a,o)}),changes:(n,a)=>rn(ot(n),ot(a),e,t),plain:(n,a,o)=>a===n&&Se(n).changes.length>0&&o.parts.length>0,stayed:Rn,outside:"others",aside:"data-block-id aside",inside:Tt}}async function Bn(e){return w(e.evaluate(({instance:t,fields:n})=>{let a=document.activeElement;return a instanceof HTMLElement&&a.closest(t)&&a.matches(n)?(a.blur(),!0):!1},{instance:ft,fields:Dt}),"the focus left the instance's field")}async function Jn(e){await e.keyboard.down("Control"),await e.keyboard.press("z"),await e.keyboard.up("Control")}var Un=e=>`${e}${[11,12,13].includes(e%100)?"th":["th","st","nd","rd"][e%10]??"th"}`,Wn=3,Le=(e,t)=>e.length===1?`the ${de[e[0].kind]}`:`step ${t+1}`,K=e=>e.length===1?`the ${de[e[0].kind]}`:"the steps";function Zn(e,t){if(e.words!==t.words){let a=0;for(;a<e.words.length&&e.words[a]===t.words[a];)a++;let o=s=>JSON.stringify(`${a>20?"\u2026":""}${s.slice(Math.max(0,a-20),a+30)}${s.length>a+30?"\u2026":""}`);return`its words read ${o(e.words)} there and ${o(t.words)} here`}let n=e.fields.findIndex((a,o)=>a!==t.fields[o]);if(n>=0||e.fields.length!==t.fields.length){let a=n>=0?n:Math.min(e.fields.length,t.fields.length);return`its field ${a+1} (of ${e.fields.length}) holds ${JSON.stringify(e.fields[a]??null)} there and ${JSON.stringify(t.fields[a]??null)} here`}return null}var ct=["ticked","not ticked"],qn=["true","false","checked","done"],Gn={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Me=e=>new Set(e.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]),lt=e=>e.replace(/<[^>]*>/g," ").replace(/"(?:[^"\\]|\\.)*"\s*:/g," ").replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,(t,n,a,o)=>{let s=n?Number(n):a?Number.parseInt(a,16):null;return s!==null?s<=1114111?String.fromCodePoint(s):t:Gn[o.toLowerCase()]??t}),dt=e=>qn.map(t=>(e.join(`
|
|
9
|
+
`).toLowerCase().match(new RegExp(`\\b${t}\\b`,"g"))??[]).length).join();function Kn(e){let t=new Set,n=!1;for(let{parts:a}of e)for(let{runs:o=[]}of a)for(let{removed:s,added:i}of o){let[l,c]=[Me(s.map(lt).join(`
|
|
10
|
+
`)),Me(i.map(lt).join(`
|
|
11
|
+
`))];for(let r of c)l.has(r)||t.add(r);for(let r of l)c.has(r)||t.add(r);dt(s)!==dt(i)&&(n=!0)}return{words:t,ticks:n}}function Vn(e,t,n){let a=({words:d,fields:u})=>Me([d,...u.filter(f=>!ct.includes(f))].join(" ")),[o,s]=[a(e),a(t)],i=[...[...o].filter(d=>!s.has(d)),...[...s].filter(d=>!o.has(d))],l=d=>/[^\x00-\x7f]/.test(d),c=d=>[...n.words].some(u=>u===d||[d,u].every(f=>[...f].length>=2)&&[u,d].some(f=>l(f))&&(d.includes(u)||u.includes(d))),r=i.filter(c),h=d=>JSON.stringify(d.fields.filter(u=>ct.includes(u)));return n.ticks&&h(e)!==h(t)&&r.push("a box ticked"),r}async function zn(e,{root:t,address:n,fresh:a,steps:o,keep:s,file:i,name:l,line:c,found:r,out:h,host:d}){let u=await w(e.createBrowserContext(),"a browser context opened"),f=await w(u.newPage(),"a tab opened"),g=await w(Et(f,r.id),"the tab was set to listen"),y=d.saves(f),b=[g],p={problems:[],notes:[],steps:[]},m=($,A=`${l}:${c}`)=>p.problems.push({where:A,what:$}),D=!s,N=D?`the copy of ${l}`:l,F=new URL(n).origin,C=0,B=0;f.on("request",$=>{!$.isNavigationRequest()||$.frame()!==f.mainFrame()||(C+=1,B=Date.now())});let I=null,P=null,M=async()=>d.changes(P,await T.readFile(i,"utf8").catch(()=>"")),k=($,A,v=!1)=>({...p,unverified:Dn($,A,{gesture:o.length===1?de[o[0].kind]:"steps",name:l,held:v,scratch:D,aside:d.aside}).unverified}),O=d.stayed,W=await w(f.createCDPSession(),"the tab opened a session");await w(f.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),"the tab was set to tell when the page takes edits"),await w(f.setViewport({width:De,height:_e}),"the window was sized"),await w(f.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came");try{await w(f.goto(n,{waitUntil:"load",timeout:0}),"the page opened",Oe);let $=null,A=null;for(let x=1;!$;x++){let E=C;try{if(!await d.ready(f))return{...p,unverified:`the page did not come to edit in ${le/1e3}s, so nothing was tried`};if($=await St(f,{where:d.where,id:r.id}),!$)return{...p,unverified:`the page does not hold the instance where ${l} has it (${l} changed meanwhile?), so nothing was tried`};if(await he(Math.max(0,await ln(t,D?null:i)-Date.now())),$.fallback&&(A=await $n({root:t,id:r.id,origin:F,loadedAt:B,loaded:()=>C!==E})),C!==E)throw new Error("the page loaded itself again");if($.fallback)break;if(P=await T.readFile(i,"utf8"),await w($.host.evaluate(kt),"the page was asked to listen"),C!==E)throw new Error("the page loaded itself again")}catch(j){if(C===E||x===Wn)throw j;$=null,Fn(g)}}let{host:v}=$;if($.fallback){await re(g);let x=[...g.own].map(([E,{line:j,unparsed:V}])=>({words:`${E}${j?` (kit.js:${j})`:""}`,unparsed:V}));return g.own.clear(),m(pn(r.id,{said:x.map(({words:E})=>E),unparsed:x.find(({unparsed:E})=>E)?.words??null,...A})),await ht(v,p,h,d.framed)}I=C;let H=P,Y=null;for(let[x,E]of o.entries()){let j=Le(o,x),{taken:V}=await w(f.evaluate(vn),"the page was asked to listen"),fe=await y.mark(),Z=await In(f,v,E,W),z=await y.until(fe,F),q=await T.readFile(i,"utf8").catch(()=>""),J=d.changes(H,q);if(p.steps.push({said:Z.said,parts:J.parts,outside:J.outside,plain:d.plain(P,H,J),taken:V}),C>I)return k(`after ${j}, ${O("reloading")}`,await M());if(O(z))return k(`after ${j}, ${O(z)}`,await M(),z==="held");if(J.gone)return k(`after ${j}`,await M());Y={step:E,gestured:Z,heard:await w(f.evaluate(()=>globalThis.__galleryTry),"the page was asked what it heard")};for(let{name:ve,how:R}of J.parts)R&&p.notes.push({where:`${l}:${c}`,what:`${j}'s write lays the part ${ve} out anew (${R}): ${Ge}`});J.parts.length&&(p.steps.at(-1).before=H),H=q}await ht(v,p,h,d.framed);let be=await w(v.evaluate(Fe,{still:we,step:ge,wait:$e}).then(()=>v.evaluate(bt)),"the instance held still"),_=p.steps.filter(({parts:x})=>x.length),X=p.steps.map(x=>x.outside).filter(Boolean);if(d.outside==="problem"?p.steps.forEach((x,E)=>{x.outside&&m(`${Le(o,E)} changed ${l} outside ${d.outsideSaid(x.outside)}`)}):X.length&&(p.others={removed:X.reduce((x,{removed:E})=>x+E,0),added:X.reduce((x,{added:E})=>x+E,0)}),_.length===0){await re(g);let x=[...g.own.keys()].filter(j=>j.includes("context.edit"));for(let j of x)g.own.delete(j);let E=_n(Y.step.kind,Y.heard,{...Y.gestured,refusals:x,name:N});return m(o.length===1?E:`none of the ${o.length} steps wrote anything to ${N}; of the last, step ${o.length}, ${E}`),p}if(!s){let x=await y.mark();if(await Bn(f)){let Z=await y.until(x,F);if(C>I)return k(`as the focus left the instance's field, ${O("reloading")}`,await M());if(O(Z))return k(`as the focus left the instance's field, ${O(Z)}`,await M(),Z==="held")}let E=await w(f.evaluate(()=>globalThis.__galleryTry.taken),"the page was asked what it took"),j=o.length===1,V=0,fe=0;e:for(let[Z,z]of[..._.entries()].toReversed()){let q=Le(o,p.steps.indexOf(z)),J=Math.max(1,(_[Z+1]?.taken??E)-z.taken),ve=R=>j?R===1?"one Ctrl+Z":`${R} Ctrl+Z`:`${R===1?"the Ctrl+Z":`${R} Ctrl+Z`} for ${q}`;for(let R=1;;R++){let se=R===1?`the Ctrl+Z for ${q}`:`the ${Un(R)} Ctrl+Z for ${q}`,At=await y.mark();await Jn(f);let ue=await y.until(At,F),Lt=await T.readFile(i,"utf8").catch(()=>""),xe=d.changes(z.before,Lt);if(C>I)return k(`after ${se}, ${O("reloading")}`,await M());if(O(ue))return k(`after ${se}, ${O(ue)}`,await M(),ue==="held");if(xe.gone)return k(`after ${se}`,await M());if(ue==="unchanged"){m(`${R===1&&j?"one Ctrl+Z":se} wrote nothing, so ${N} keeps what ${q} wrote: a reader's undo does not take it back (the component keeps Ctrl+Z from the page where the focus is, or wrote by no context.edit)`);break e}if(xe.parts.length===0){fe+=R;break}if(R>=J){m(`after ${ve(R)}${J>1?", one for each write the page took of it,":""} ${N} is not as it was${j?"":` before ${q}`}, ${Q(xe.parts)} still differing: a reader's undo does not give it back (the component writes again as it hears the part change)`);break e}}V+=1}V===_.length&&Object.assign(p,{undone:V,presses:fe})}if(p.problems.length)return p;await pe(f.close());let Ot=x=>p.notes.push({where:`${l}:${c}`,what:x}),ee=await Yn(u,{...await a(H),host:d,found:r,after:be,written:Kn(_),out:h,hearings:b,problem:m,note:Ot,called:K(o)});return p.readBack=ee.back,p.aside=ee.aside??!1,ee.picture&&(p.fresh=ee.picture),ee.unverified?p.unverified=`${ee.unverified}, so it was not read back`:p.others&&(p.unverified=`someone else wrote ${l} meanwhile, outside the instance's parts (the user's page, an Agent), which stays: try it again once the file holds still`),p}catch($){if($ instanceof S){if(p.steps.length&&($.made=p),!$.unfound||(await re(g),g.own.size===0&&g.dialogs.size===0))throw $;return m(`${$.message[0].toLowerCase()}${$.message.slice(1).replace(/\.$/,"")}; its component did not draw it, and the console says why`),p}let A=I===null?null:await M();if(A&&C>I)return k(`after a gesture, ${O("reloading")}`,A);if(await Ye(e)){let v=`the browser went while waiting until ${$.doing??"the page answered"}`;return A?k(v,A):{...p,unverified:`${v}, so nothing was tried`}}return $.stuck?m(`the page stopped answering while waiting until ${$.doing}: a script that never ends, or a component that changes what it hears`,"the page"):m(`the trial stopped: ${ne($)}`,"the page"),p}finally{let $=new Set;for(let A of b){await re(A);for(let[v,{line:H}]of A.own)!$.has(v)&&$.add(v)&&p.problems.push({where:H?`kit.js:${H}`:"the page",what:`the console says ${v}`});for(let v of A.others.keys())!$.has(v)&&$.add(v)&&p.notes.push({where:"the page",what:`the console says ${v}`});for(let v of A.dialogs.keys())!$.has(v)&&$.add(v)&&p.problems.push({where:"the page",what:`it opened a dialog (${v}), which stops a reader's page until it is answered: show what it says in the instance`})}await pe(u.close())}}function Qn(e,t,n,a){console.log(`FAIL ${e}: ${Qe(t)}, so nothing was tried and the browser was closed${a?"":`; the copy of ${n} was taken away`}. A script that never ends does this, and so may a browser that stalled: run the command once more`),process.exitCode=1}async function Yn(e,{address:t,file:n,host:a,found:o,after:s,written:i,out:l,hearings:c,problem:r,note:h,called:d}){let u=await w(e.newPage(),"a tab opened");c.push(await w(Et(u,o.id),"the fresh tab was set to listen"));let f=a.saves(u),g=c.at(-1),y=new URL(t).origin;await w(u.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),"the fresh tab was set to tell when the page takes edits"),await w(u.setViewport({width:De,height:_e}),"the window was sized"),await w(u.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came");let b=`a fresh page of what ${d} wrote`,p={back:!1};try{let m=await T.readFile(n,"utf8");if(await w(u.goto(t,{waitUntil:"load",timeout:0}),"the fresh page opened",Oe),!await a.ready(u))return{back:!1,unverified:`${b} did not come to edit in ${le/1e3}s`};let D=await St(u,{where:a.where,id:o.id});if(!D)return r(`${b} does not hold the instance where the file has it: what the steps wrote is no instance of ${o.id} as the page reads it`),p;if(D.fallback){await re(g);let k=[...g.own].map(([O,{line:W}])=>`${O}${W?` (kit.js:${W})`:""}`);return g.own.clear(),r(`${b} shows the instance in its fallback, what it holds read-only: its component failed as the page started it, ${k.length?`and the console says ${k.join("; ")}`:"and the console said nothing of it"}: what ${d} wrote is what its mount cannot read`),p}await w(D.host.evaluate(kt),"the fresh page was asked to listen");let N=await f.until(await f.mark(),y);if(N==="offline")return{back:!1,unverified:`${b}: ${a.stayed(N)}`};if(N!=="unchanged"&&N!=="saved")return r(`${b}: ${a.stayed(N)??N}`),p;let F=a.changes(m,await T.readFile(n,"utf8").catch(()=>""));if(F.gone)return{back:!1,unverified:`${b}: its file holds the instance no more where it stood (someone else wrote it meanwhile)`};if(N==="saved"||F.parts.length)return r(`${b} writes ${F.parts.length?Q(F.parts):"it again"} with no gesture as it opens, so that a page would write each time it opened: draw what the parts hold as they are, and write on a gesture alone`),p;let C=await w(D.host.evaluate(Fe,{still:we,step:ge,wait:$e}).then(()=>D.host.evaluate(bt)),"the fresh page's instance held still"),B=Zn(s,C);if(!B)return{back:!0};let I=L.join(l,"fresh.png");await w(D.host.screenshot({path:I}),"the fresh page's instance was pictured").catch(()=>{});let P=`${b} shows the instance otherwise than the page did after ${d.replace(/^the steps$/,"the last step")}: ${B}`,M=Vn(s,C,i);return M.length?(r(`${P} (the fresh page's picture: ${G(I)}), and what differs is of what ${d} wrote (${M.slice(0,3).map(k=>k==="a box ticked"?k:JSON.stringify(k)).join(", ")}). What it draws of what it wrote is to come from its parts alone, read as it wrote them: a value kept in memory, or written in a form its mount does not read, is gone on the next page`),{...p,picture:I}):(h(`${P}; none of it is of what ${d} wrote, and a fresh page keeps no filter or tab chosen, no editor left open, no words typed and not committed (--then Enter commits them), and need not. Its picture: ${G(I)}. What a reader keeps belongs in a part`),{back:!0,aside:!0,picture:I})}catch(m){return await xt(y)?(m.stuck?r(`${b} stopped answering while waiting until ${m.doing}: a script that never ends, or a component that changes what it hears`,"the page"):r(`${b} could not be read back: ${ne(m)}`,"the page"),p):{back:!1,unverified:`the server stopped answering as ${b} opened`}}finally{await pe(u.close())}}async function ht(e,t,n,a=null){let o=L.join(n,"after.png");try{let s=a?await w(e.evaluateHandle(a),"the instance's frame was found"):e;await w(s.screenshot({path:o}),"the instance was pictured"),t.picture=o}catch(s){if(s.stuck)throw s}return t}var U={gesture:"Gesture: ",step:"Step ",wrote:"Wrote: ",undone:"Undone: ",kept:"Kept (--keep): ",readBack:"Read back: ",picture:"Picture of the instance after "},Tt="nothing outside the instance changed (data-block-id aside)",Xn="open it: no one has looked at it for you";function ea({slug:e,name:t,steps:n,keep:a,host:o=null},s){let i=n.length>1,l=a?t:`the copy of ${t}`,c=o?.aside??"data-block-id aside",r=Nt({name:t,several:i,keep:a,host:o},s.steps),h=s.steps.filter(({parts:p})=>p.length),d=a&&h.some(({plain:p})=>p)?", its plain HTML the kit's markup":"",u=s.presses??s.undone;if(a&&h.length)r.push(`${U.kept}${t} holds what ${K(n)} wrote`);else if(s.undone){let p=i?u===s.undone?`${u} Ctrl+Z, one for each step that wrote, the last first, each giving ${l} back as it was before its step`:`${u} Ctrl+Z for the ${s.undone} step${s.undone===1?"":"s"} that wrote, one for each write the page took, the last first, each step's giving ${l} back as it was before it`:u===1?`one Ctrl+Z, and ${l} is as it was`:`${u} Ctrl+Z, one for each write the page took of ${K(n)}, and ${l} is as it was`;r.push(`${U.undone}${p} (${c}${d})`)}s.readBack&&r.push(`${U.readBack}${a?`${t} opened again in a fresh page`:`a fresh page of what ${K(n)} wrote (a copy of it)`}: the instance mounts, writes nothing as it opens, and shows what the page showed after ${i?"the last step":K(n)}${s.aside?` of what ${i?"they":"it"} wrote; what else the page showed there, which nothing wrote, it does not (the note)`:""}`);for(let{where:p,what:m}of s.problems)r.push(` FAIL ${p}: ${m}`);for(let{where:p,what:m}of s.notes)r.push(` note ${p}: ${m}`);s.picture&&r.push(`${U.picture}${i?"the last step":K(n)}: ${G(s.picture)} (${Xn})`);let f=[s.picture,s.fresh].filter(Boolean);f.length&&r.push(Xe([{folder:L.dirname(f[0]),files:f}]));let g=s.problems.length;if(g)return{lines:[...r,`FAIL ${e}: ${g} problem${g===1?"":"s"}`],code:1};if(s.unverified)return{lines:[...r,`UNVERIFIED ${e}: ${s.unverified}`],code:3};let y=[...new Set(h.flatMap(({parts:p})=>p.map(({name:m})=>m)))].join(" and "),b=a?", kept (--keep)":`, ${u===1?"one Ctrl+Z":`${u} Ctrl+Z`} took ${i?"them":"it"} back`;return{lines:[...r,`OK ${e}: ${K(n)} wrote ${y}${b}, and a fresh page read ${i?"them":"it"} back${a?"":`; ${t} not written (a scratch copy)`}`],code:0}}function Nt({several:e,keep:t,host:n=null},a){let o=[];for(let[s,i]of a.entries()){if(o.push(e?`${U.step}${s+1}: ${i.said}`:`${U.gesture}${i.said}`),i.parts.length===0){e&&o.push(`${U.wrote}nothing`);continue}let l=t&&i.plain?"; and the page wrote the document's plain HTML as the kit's markup, as its first save of an edit does (gallery check and gallery export say what, by line, once), which stays":"",c=i.outside?n?.outside==="problem"?`; and outside ${n.outsideSaid(i.outside)}`:`; outside the instance's parts -${i.outside.removed} +${i.outside.added} lines someone else wrote meanwhile (the user's page, an Agent), which stay`:`; ${n?.inside??Tt}`;o.push(`${U.wrote}${Q(i.parts)}${c}${l}`,...cn(i.parts))}return o}function ta({name:e,steps:t,keep:n,host:a=null},o){let s=o.steps.length,i=s===1?"step 1":`steps 1 to ${s}`,l=o.steps.some(({parts:h})=>h.length),c=Nt({name:e,several:t.length>1,keep:n,host:a},o.steps),r=`step ${s+1} was not made, for the mistake below`;return n?c.push(l?`${U.kept}${e} holds what ${i} wrote, which stays; ${r}`:`Not made: ${r}; ${i} wrote nothing to ${e}`):c.push(`Not made: ${r}; ${i} ${l?"wrote to":"made"} a scratch copy, gone now, and ${e} holds nothing of ${s===1?"it":"them"}`),c}async function ba(e,{named:t,values:n,seconds:a={},keep:o,replace:s=!1,home:i=Pt()}){let l=await Xt(n,a,s),c=l?[l]:null;if(t.length===0)throw new S("Name the document: gallery block try <slug> [<instance id>] and the gesture.");if(t.length>2)throw new S("gallery block try takes a document and an instance's id at most.");let r=n.has("--steps")?L.resolve(n.get("--steps")):null,h=c??await en(r),{slug:d,block:u}=await Pe(t[0]),f=Bt(d,e),g=Jt(f),y=g.html,b=await T.readFile(y,"utf8").catch(()=>null);b===null&&(console.error(`No document "${d}": ${G(y)} does not exist (gallery list lists those there are).`),process.exit(1));let p=wt(b);p.length===0&&(console.error(`${d} holds no instance of a custom block (an element with ${ke}): gallery block list says which there are, and gallery block show <id> how to write one.`),process.exit(1));let m=L.basename(y),D=an(p,t[1]??u,{slug:d,name:m}),{id:N,line:F}=p[D],C=Ee(i),B=C.packages.get(N);if(!B){let k=C.problems.get(N);console.error(k?.off?`${N} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its instances show what they hold, read-only, so a reader can do nothing with them.`:k?`${N} does not load, so its instances show what they hold, read-only: gallery block check ${N} says why.`:`No component ${N} in this workspace, so its instance shows what it holds, read-only: gallery block list says which there are.`),process.exit(1)}console.log(`${N} in ${d}, ${gt(p[D],m)}: ${G(y)}`),r&&console.log(`Steps: ${h.length} from ${G(r)}, made one after another in one page`);let I=await Je({slug:d,command:`gallery block try ${d}`});if(!I.ok){console.log(`UNVERIFIED ${d}: ${I.message}`),process.exitCode=3;return}await hn(e);let P=[],M=async k=>{let O=await dn(e,{directory:f,files:g,text:k});return P.push(O.slug),O};try{let k=o?{slug:d,file:y}:await M(b),O=Ne(I.port,k.slug);console.log(o?`Page: ${O} (the document's page alone, editable: the Agent's own; --keep: what ${K(h)} write stays in ${m}; the server runs on after this command)`:`Page: ${O} (a scratch copy of ${d}, its page alone, editable, made for this trial and gone at its end: ${m} is not written, and no page of the user's shows the trial; the server runs on after this command)`);let W=Ue();if(!W){console.log(`UNVERIFIED ${d}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let $;try{$=await Ze({executablePath:W,args:We()})}catch(v){console.log(`UNVERIFIED ${d}: the browser ${W} did not start, twice, each time with a fresh profile (${ne(v)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let A=L.join(oe(e).qa,d,"try");try{await T.rm(A,{recursive:!0,force:!0}),await T.mkdir(A,{recursive:!0});let v=async _=>{if(o)return{address:O,file:k.file};let X=await M(_);return{address:Ne(I.port,X.slug),file:X.file}},H;try{H=await zn($.browser,{root:i,address:O,fresh:v,steps:h,keep:o,file:k.file,name:m,line:F,found:B,out:A,host:Pn({at:D,found:B})})}catch(_){if(_ instanceof S&&_.made&&console.log(ta({name:m,steps:h,keep:o},_.made).join(`
|
|
12
|
+
`)),_.stuck)return Qn(d,_,m,o);throw _}let{lines:Y,code:be}=ea({slug:d,name:m,steps:h,keep:o},H);console.log(Y.join(`
|
|
13
|
+
`)),process.exitCode=be}finally{await $.close()}}finally{for(let k of P)await $t(e,k)}}export{le as a,Kt as b,Ie as c,at as d,ie as e,ut as f,Xt as g,en as h,wt as i,gt as j,an as k,on as l,ot as m,st as n,rn as o,cn as p,ln as q,dn as r,$t as s,hn as t,un as u,pn as v,$n as w,Fe as x,Ln as y,Dn as z,_n as A,Et as B,Fn as C,Pn as D,K as E,Zn as F,Me as G,Kn as H,Vn as I,zn as J,Qn as K,U as L,Tt as M,Xn as N,ea as O,ta as P,ba as Q};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 U,b as X,c as W}from"./chunk-MZ66LN3B.mjs";import{b as F,d as B,i as D}from"./chunk-LHGKPMTI.mjs";import"./chunk-2OHANJ6Q.mjs";import{b as p,f as _}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{spawn as Z}from"node:child_process";import{randomBytes as Q}from"node:crypto";import P from"node:fs/promises";import T from"node:path";import{packageRoot as ee}from"../browser/shared/paths.mjs";var te=(s,o,i)=>s.replace(new RegExp(String.raw`(?:file:///)?(?:[A-Za-z]:)?[^\s'"()]*?gallery-sandboxes[\\/][^\\/\s]+[\\/]home[\\/]extensions[\\/]`+i+String.raw`(?![\w-])`,"g"),()=>o).replace(new RegExp(String.raw`https?://127\.0\.0\.1:\d+/__gallery/extensions/`+i+String.raw`/files/(?:@revision/[0-9a-f]+/)?`,"g"),()=>o+T.sep);async function ne(s,o,i){let e=[],n=new Set,t=`/__gallery/extensions/${o}/api/`;s.on("request",h=>{h.url().includes(t)&&n.add(h)}),s.on("requestfailed",h=>{n.delete(h)&&e.push({method:h.method(),path:"/"+h.url().split(t)[1],status:"failed",body:h.failure()?.errorText??""})}),s.on("response",async h=>{let y=h.request();if(!n.has(y))return;let b=await h.text().catch(()=>"");e.push({method:y.method(),path:"/"+h.url().split(t)[1],status:h.status(),body:b.replace(/\s+/g," ").slice(0,200)}),n.delete(y)});let r=await s.evaluate((h,y)=>{let b=[...document.querySelectorAll('.gallery-extension-slot [data-extension="'+CSS.escape(h)+'"] button')],x=d=>d.getAttribute("aria-label")||d.textContent.trim(),O=b.find(d=>x(d)===y)??b.find(d=>d.textContent.includes(y));if(!O)return{pressed:!1,labels:b.map(x)};let $=globalThis.__galleryCheckToasts=[],w=()=>{for(let d of document.querySelectorAll(".toast")){let u=d.textContent.trim();u&&!$.some(k=>k.text===u)&&$.push({text:u,error:d.classList.contains("error")})}};return new MutationObserver(w).observe(document.body,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),O.click(),{pressed:!0,labels:[]}},o,i);if(!r.pressed)return{...r,requests:e,toasts:[]};let a=Date.now(),c=Date.now();for(;Date.now()-a<15e3;)if(await new Promise(h=>setTimeout(h,100)),n.size)c=Date.now();else if(Date.now()-a>=1e3&&Date.now()-c>=500)break;let m=await s.evaluate(()=>globalThis.__galleryCheckToasts??[]);return{...r,requests:e,toasts:m}}async function Y(s,o,{shot:i,press:e}={}){try{return await oe(s,o,{shot:i,press:e})}catch(n){throw n.message=te(n.message,s,o.id??T.basename(s)),n}}async function oe(s,o,{shot:i,press:e}){let n="check-"+Q(6).toString("hex"),t=T.join(ee,"bin","gallery.mjs"),r=Z(process.execPath,[t,"sandbox","--name",n,"--extension",s],{windowsHide:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,GALLERY_NO_BROWSER:"1",GALLERY_NO_AUTOSTART:"1"}}),a="",c,m,h,y=new Promise(b=>r.once("exit",b));try{c=await new Promise((w,d)=>{let u=setTimeout(()=>d(new Error(`Extension sandbox did not start within 90 seconds.
|
|
3
|
+
`+a.slice(-3e3))),9e4),k=(l,g)=>{clearTimeout(u),l?d(l):w(g)};r.once("error",l=>k(l)),r.once("exit",l=>k(new Error(`Sandbox exited (${l}): ${a.slice(-3e3)}`)));let G=l=>{a=(a+l).slice(-2e4);let g=/地址:(http:\/\/127\.0\.0\.1:\d+)\//.exec(a)?.[1];g&&k(null,g)};r.stdout.on("data",G),r.stderr.on("data",G)}),m=(await fetch(c+"/__gallery/workspace/info").then(w=>w.json())).token;let x=()=>fetch(c+"/__gallery/extensions").then(w=>w.json()),O=(await x()).extensions,$=O.find(w=>w.manifest?.id===o.id)??O[0];if(!$?.enabled)throw new Error("Sandbox could not enable extension.");if(o.server){let w=await fetch(`${c}/__gallery/extensions/${$.id}/api/health`,{headers:{Origin:c,"X-Gallery-Token":m},signal:AbortSignal.timeout(15e3)}),d=(await x()).extensions.find(u=>u.id===$.id);if(d?.backend?.state!=="running"){let u=await P.readFile(d.backend.log,"utf8").catch(()=>"");throw new Error(`Backend failed (exit code ${d.backend.exitCode??"?"}):
|
|
4
|
+
${u.trim().split(/\r?\n/).slice(-20).join(`
|
|
5
|
+
`)}`)}await w.body?.cancel(),console.log("Backend: listening")}if(e&&!o.workbench)throw new Error("--press presses a button of the workbench script, and extension.json declares none (workbench.script).");if(o.workbench||i){let w=F();if(!w)throw new Error("Chrome or Edge is required to check extension UI.");h=await D({executablePath:w,args:B()});let d=await h.browser.newPage();await d.setViewport({width:1280,height:800});let u=[];d.on("pageerror",l=>{String(l.stack).includes(`/__gallery/extensions/${$.id}/files/`)&&u.push(l.message)}),await d.goto(c+"/#@home",{waitUntil:"networkidle2"}),await d.waitForFunction(()=>!!window.gallery,{timeout:15e3});let k=(await x()).extensions.find(l=>l.id===$.id);if(k?.workbenchError&&u.push(k.workbenchError),u.length)throw new Error([...new Set(u)].join(`
|
|
6
|
+
`));let G=await d.evaluate(l=>["sidebar-footer","topbar-end"].map(g=>({slot:g,buttons:[...document.querySelectorAll(".gallery-extension-slot."+g+' [data-extension="'+CSS.escape(l)+'"] button')].map(S=>S.getAttribute("aria-label")||S.textContent.trim())})),$.id);for(let l of G)console.log(`${l.slot}: ${l.buttons.join(", ")||"(no buttons)"}`);if(e){let l=await ne(d,$.id,e);if(!l.pressed)throw new Error(`No slot button "${e}": ${l.labels.length?`the buttons are ${l.labels.map(f=>JSON.stringify(f)).join(", ")}`:"the extension shows none"} (--press takes a button's aria-label or its words).`);console.log(`Pressed: ${e}`);for(let{method:f,path:j,status:C,body:J}of l.requests)console.log(` ${f} api${j} \u2192 ${C}${J?` ${J}`:""}`);l.requests.length||console.log(" no request to the backend (api/)");for(let{text:f,error:j}of l.toasts)console.log(` toast${j?" (error)":""}: ${f}`);let g=[...l.requests.filter(({status:f})=>f==="failed"||f>=400).map(({method:f,path:j,status:C})=>`${f} api${j} answered ${C}`),...l.toasts.filter(({error:f})=>f).map(({text:f})=>`an error toast: ${f}`),...u],S=(await x()).extensions.find(f=>f.id===$.id);if(S?.workbenchError&&!g.includes(S.workbenchError)&&g.push(S.workbenchError),g.length){let f=o.server?await P.readFile(S?.backend?.log??"","utf8").catch(()=>""):"",j=f.trim()?`
|
|
7
|
+
Backend log (last 20 lines):
|
|
8
|
+
`+f.trim().split(/\r?\n/).slice(-20).join(`
|
|
9
|
+
`):"";throw new Error(`the press: ${[...new Set(g)].join("; ")}${j}`)}}i&&(await P.mkdir(T.dirname(T.resolve(i)),{recursive:!0}),await d.screenshot({path:T.resolve(i)}),console.log(`Screenshot: ${T.resolve(i)}`))}}finally{await h?.close(),c&&m?await fetch(c+"/__gallery/workspace/stop",{method:"POST",headers:{Origin:c,"Content-Type":"application/json","X-Gallery-Token":m},body:"{}"}).catch(()=>{}):r.exitCode===null&&r.kill();let b;await Promise.race([y,new Promise(x=>{b=setTimeout(()=>{r.kill(),x()},1e4)})]),clearTimeout(b)}}import v from"node:fs/promises";import E from"node:path";import{extensionDirectory as se}from"../browser/shared/extension-manifest.mjs";import{defaultWorkspace as z,ensureWorkspace as re}from"../browser/shared/workspace.mjs";import{withOutlineLock as ie}from"../browser/shared/outline.mjs";var ae=(s,o,i)=>`// The workbench side: activate(api) runs when the extension is enabled (and again after each edit of a
|
|
10
|
+
// file here); what it returns runs when it is disabled or reloaded.
|
|
11
|
+
export function activate(api) {
|
|
12
|
+
const button = document.createElement('button');
|
|
13
|
+
button.className = 'extension-${s}-button';
|
|
14
|
+
button.textContent = ${JSON.stringify(o)};
|
|
15
|
+
button.setAttribute('aria-label', ${JSON.stringify(o)});
|
|
16
|
+
${i?` button.addEventListener('click', async () => {
|
|
17
|
+
try {
|
|
18
|
+
// The backend's /hello, through Gallery's proxy: /__gallery/extensions/<id>/api/<path> is its /<path>.
|
|
19
|
+
const response = await fetch('/__gallery/extensions/${s}/api/hello', { headers: { 'X-Gallery-Token': await api.token() } });
|
|
20
|
+
const answer = await response.json();
|
|
21
|
+
api.toast(response.ok ? answer.message : \`\${response.status}: \${answer.error ?? 'failed'}\`, { tone: response.ok ? 'info' : 'error' });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
api.toast(String(error), { tone: 'error' });
|
|
24
|
+
}
|
|
25
|
+
});`:` button.addEventListener('click', () => api.toast(${JSON.stringify(o)}));`}
|
|
26
|
+
api.slot('sidebar-footer').append(button);
|
|
27
|
+
return () => button.remove();
|
|
28
|
+
}
|
|
29
|
+
`,le=s=>`.extension-${s}-button { border:0; border-radius:6px; padding:6px 10px; background:var(--bacIntTra); color:var(--texPri); font:inherit; cursor:pointer; }
|
|
30
|
+
.extension-${s}-button:hover { background:var(--bacTerTra); }
|
|
31
|
+
`,ce=s=>`// The backend: Gallery starts it on the first request to /__gallery/extensions/<id>/api/*, gives it a port
|
|
32
|
+
// (GALLERY_EXTENSION_PORT), restarts it when a file here changes, and stops it with Gallery.
|
|
33
|
+
import http from 'node:http';
|
|
34
|
+
const server = http.createServer((request, response) => {
|
|
35
|
+
response.setHeader('Content-Type', 'application/json');
|
|
36
|
+
const { pathname } = new URL(request.url, 'http://localhost');
|
|
37
|
+
if (pathname === '/health') return response.end(JSON.stringify({ ok: true, pid: process.pid }));
|
|
38
|
+
if (pathname === '/hello' && request.method === 'GET') return response.end(JSON.stringify({ ok: true, message: ${JSON.stringify(`${s}\uFF1A\u540E\u53F0\u5DF2\u8FDE\u4E0A`)} }));
|
|
39
|
+
response.statusCode = 404;
|
|
40
|
+
response.end(JSON.stringify({ ok: false, error: \`no route \${request.method} \${pathname}\` }));
|
|
41
|
+
});
|
|
42
|
+
server.listen(Number(process.env.GALLERY_EXTENSION_PORT), process.env.GALLERY_EXTENSION_HOST || '127.0.0.1');
|
|
43
|
+
process.on('SIGTERM', () => server.close());
|
|
44
|
+
`,de=(s,o,{ui:i,server:e})=>`# ${o}
|
|
45
|
+
|
|
46
|
+
Edit this extension in its own folder. Use Gallery's public slot, toast, confirm and menu API for UI.
|
|
47
|
+
Read references/extensions.md (in the Gallery skill's folder) for the API and lifecycle.
|
|
48
|
+
${i&&e?`The button in the sidebar's footer (workbench.js) asks the backend's GET /hello (server.mjs) through \`/__gallery/extensions/${s}/api/hello\` with the \`X-Gallery-Token\` header, and shows its answer in a toast.
|
|
49
|
+
`:""}Run \`gallery extension check ${s}\` after changes; it tests an isolated copy${i&&e?`, and \`--press ${JSON.stringify(o)}\` presses the button there and says what the backend answered`:""}.
|
|
50
|
+
Enable in the user's Gallery only when requested: \`gallery extension enable ${s}\`.
|
|
51
|
+
`;async function M(s,o,{ui:i,server:e}){let n=se(s);await re(z());let t={};await ie(z(),async()=>{if(await v.mkdir(E.dirname(n),{recursive:!0}),(await v.lstat(E.dirname(n))).isSymbolicLink())throw new Error("Extensions directory cannot be a symlink.");await v.mkdir(n);let a={id:s,name:o,version:"0.1.0",description:"",agent:"AGENT.md",...i?{workbench:{script:"workbench.js",style:"workbench.css"}}:{},...e?{server:{command:["node","server.mjs"]}}:{}};t["extension.json"]="the manifest: name, version, the workbench files, the backend command",await v.writeFile(E.join(n,"extension.json"),JSON.stringify(a,null,2)+`
|
|
52
|
+
`),i&&(await v.writeFile(E.join(n,"workbench.js"),ae(s,o,e)),await v.writeFile(E.join(n,"workbench.css"),le(s)),t["workbench.js"]=e?"activate(api): a button in the sidebar's footer that asks the backend's /hello and shows the answer":"activate(api): a button in the sidebar's footer",t["workbench.css"]="the button's look"),e&&(await v.writeFile(E.join(n,"server.mjs"),ce(o)),t["server.mjs"]="the backend: GET /health and GET /hello, JSON"),await v.writeFile(E.join(n,"AGENT.md"),de(s,o,{ui:i,server:e})),t["AGENT.md"]="how an Agent uses this extension (no secrets here)"});let r=Math.max(...Object.keys(t).map(a=>a.length));console.log([`Created extension ${s}: ${n}`,...Object.entries(t).map(([a,c])=>` ${a.padEnd(r)} ${c}`),`It runs as it stands. Edit its files, then gallery extension check ${s}${i&&e?` --press ${JSON.stringify(o)}`:""}`,`Enable when ready: gallery extension enable ${s}`,`Agent instructions: ${E.join(n,"AGENT.md")}`].join(`
|
|
53
|
+
`))}import{listCapabilities as he,readManifest as fe,setExtensionEnabled as ue}from"../browser/shared/extension-manifest.mjs";import{answerOf as we,readAnnouncement as pe}from"../browser/shared/preview-server.mjs";import N from"node:path";import L from"node:fs/promises";import{SIDEBAR_FILE as H,readSidebarText as me}from"../browser/shared/extension-sidebar.mjs";import{extensionSource as ge,listExtensions as be,readExtension as $e}from"../browser/shared/extensions.mjs";import{isExtensionId as q}from"../browser/shared/outline-shape.mjs";import{withOutlineLock as xe}from"../browser/shared/outline.mjs";import{reportsDirectory as A}from"../browser/shared/paths.mjs";import{defaultWorkspace as K,ensureWorkspace as ye,layoutOf as R}from"../browser/shared/workspace.mjs";var I=s=>`${s} ${s===1?"entry":"entries"}`;async function ke(s,o=!1){if(s.length>0)throw new p("list takes nothing: gallery extension check <id> reads one.");let i=await he(),e=await pe();if(e&&await we(e,2e3)==="yes"){let n=await fetch(`http://127.0.0.1:${e.port}/__gallery/extensions`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.json()).catch(()=>null);n?.ok&&(i=n.extensions)}return be(A,{all:!0}).then(n=>{if(o){console.log(JSON.stringify(n.map(t=>{let r=i.find(c=>c.id===t.id),a=r?.manifest;return{id:t.id,name:a?.name??t.id,version:a?.version??null,description:a?.description??null,folder:r?.folder??N.dirname(t.file),enabled:!!r?.enabled,error:r?.error??null,column:t.missing?null:{title:t.title,count:t.count,file:t.file},backend:r?.backend??null,workbenchError:r?.workbenchError??null,agent:r?.agent??null}}),null,2));return}if(console.log(`Extensions: ${R(K()).extensions} (gallery extension new <id> "<name>" [--ui] [--server]).`),n.length===0){console.log(`No extensions visible from ${A}. See gallery help extension and references/extensions.md to create one.`);return}console.log(`${n.length} extension${n.length===1?"":"s"} visible from ${A}:`);for(let t of n){let r=i.find(c=>c.id===t.id),a=t.missing?r?.manifest?"":`no ${H}: it gives the sidebar no column`:t.error?`\u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${t.error.message}`:`${t.title}, ${I(t.count)}${t.notes.length?`, ${t.notes.length} note${t.notes.length===1?"":"s"}`:""}`;console.log(` ${t.id} ${a}`),console.log(` ${t.missing&&r?.manifest?N.join(r.folder,"extension.json"):t.file}`),r?.manifest&&console.log(` ${r.manifest.name??t.id}${r.manifest.version?` ${r.manifest.version}`:""}; Script: ${!!r.manifest.workbench?.script}; backend: ${!!r.manifest.server}; enabled: ${r.enabled}`),r?.agent&&console.log(` Agent instructions: ${r.agent}`)}console.log("gallery extension check <id> validates a column or tests a program in an isolated sandbox.")})}function V(s,o,i=[]){for(let e of s){let n=e.url?e.url:"(no address: a click opens and closes what is under it)";i.push(`${" ".repeat(o)}${e.id} ${e.icon?`${e.icon} `:""}${e.title} ${n}`),V(e.children??[],o+1,i)}return i}async function ve(s,o,i){if(s.length!==1)throw new p("Name one extension: gallery extension check <id>.");let[e]=s;if(!q(e))throw new p(`Not an extension's id: ${e} (its folder's name under extensions/: lowercase letters, digits and dashes, 48 at most).`);let n=await ge(A,e);n||(console.error(`No extension "${e}" visible from ${A}: gallery extension list shows them.`),process.exit(1));let t=await $e(n.root,e),r=n.file,a,c=await L.lstat(N.join(n.folder,"extension.json")).catch(()=>null);if(i&&!c)throw new p("--press presses a workbench button of an extension.json's workbench script; a sidebar column has none.");if(c){try{a=await fe(n.folder),await Y(n.folder,a,{shot:o,press:i})}catch(m){console.error("FAIL "+N.join(n.folder,"extension.json")+": "+m.message),process.exitCode=1;return}if(console.log("OK "+e+": extension.json ("+n.folder+")"),t.missing)return}else if(t.missing){console.error("FAIL "+r+": there is no sidebar.json or extension.json"),process.exitCode=1;return}t.error&&(console.error(`FAIL ${r}: ${t.error.message}`),console.error(`The sidebar shows the column "${t.title}" with one row: \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${t.error.message}`),process.exit(1)),console.log(`The sidebar shows the column ${t.title}${t.icon?` (${t.icon})`:""}, ${I(t.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(t.title);for(let m of V(t.entries,1))console.log(m);for(let m of t.notes)console.log(`note: ${m.message}`);console.log(`OK ${e}: ${I(t.count)} (${r})`)}async function Ee(s){if(s.length!==2||!q(s[0]))throw new p('Use gallery extension new <id> "<title>".');let[o,i]=s,e=me(JSON.stringify({title:i,entries:[]}));if(e.error)throw new p(e.error.message);let n=K();if(!(await ye(n)).ours)throw new p(`Not a Gallery workspace: ${n}`);let t=N.join(R(n).extensions,o),r=N.join(t,H);await xe(n,async()=>{for(let a of[R(n).extensions,t]){await L.mkdir(a,{recursive:!0});let c=await L.lstat(a);if(!c.isDirectory()||c.isSymbolicLink())throw new p(`Not an ordinary directory: ${a}`)}try{await L.writeFile(r,JSON.stringify({title:e.sidebar.title,entries:[]},null,2)+`
|
|
54
|
+
`,{flag:"wx"})}catch(a){throw a.code==="EEXIST"?new p(`Already exists: ${r}. Read and edit this file instead.`):a}}),console.log(`Created public extension ${o}
|
|
55
|
+
${r}`)}async function Ze(s){let[o,...i]=s;if(o==="new"){let{positional:e,options:n}=_({argv:i,options:["--ui","--server"]});if(n.size){if(e.length!==2||!q(e[0])||!e[1].trim()||e[1].length>200)throw new p('Use gallery extension new <id> "<name>" [--ui] [--server].');return M(e[0],e[1],{ui:n.has("--ui"),server:n.has("--server")})}return Ee(e)}if(o==="install"||o==="remove"){let{positional:e,options:n}=_({argv:i,options:o==="install"?["--enable"]:[]});if(e.length!==1)throw new p(`gallery extension ${o} <${o==="install"?"folder | zip":"id"}>`);if(o==="remove")await W(e[0]),console.log(`Removed extension ${e[0]}`);else{let t=await X(e[0],{enable:n.has("--enable")});console.log(`${{installed:"\u5DF2\u5B89\u88C5",updated:"\u5DF2\u66F4\u65B0",unchanged:"\u672A\u53D8\u66F4"}[t.did]} ${t.id}${t.version?` ${t.version}`:""}\uFF08${t.enabled?"\u5DF2\u542F\u7528":"\u672A\u542F\u7528"}\uFF09
|
|
56
|
+
${t.folder}`),t.agent&&console.log(`Agent instructions: ${t.agent}`)}return}if(o==="enable"||o==="disable"){let{positional:e}=_({argv:i});if(e.length!==1)throw new p(`gallery extension ${o} <id>`);let n={id:e[0],enabled:o==="enable"};await U("",n)||await ue(n),console.log(`${n.enabled?"\u5DF2\u542F\u7528":"\u5DF2\u5173\u95ED"} ${n.id}`);return}if(o==="list"){let{positional:e,options:n}=_({argv:i,options:["--json"]});return ke(e,n.has("--json"))}if(o==="check"){let{positional:e,values:n}=_({argv:i,values:["--shot","--press"]});return ve(e,n.get("--shot"),n.get("--press"))}throw new p(o?`No such action: extension ${o} (new, list, check, install, remove, enable, disable).`:"Say what to do: gallery extension new <id> <title>, list or check <id>.")}export{Ze as run};
|