@testmuai/kane-cli 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatSurface-E7QKI4LA.js +8 -0
- package/dist/{ChromeProfilePicker-DK2A3NYY.js → ChromeProfilePicker-DGDWGCZD.js} +1 -1
- package/dist/{CliFeedbackPrompt-D5QDOBE2.js → CliFeedbackPrompt-SYCZXSME.js} +1 -1
- package/dist/{CliUploadProgress-AIZL7N6Z.js → CliUploadProgress-VDEAKXJY.js} +1 -1
- package/dist/{ConfigView-SDBCTYUU.js → ConfigView-HPKRQXMC.js} +1 -1
- package/dist/EvidenceViewOffer-F5YG54OC.js +2 -0
- package/dist/{FolderPicker-IVBHPPMW.js → FolderPicker-4NSDXQY5.js} +1 -1
- package/dist/{HelpView-YYYX4RKI.js → HelpView-ON6BFGJM.js} +1 -1
- package/dist/{InfoBox-MQV3XBT4.js → InfoBox-B23NZ6IG.js} +1 -1
- package/dist/{LinksBox-NCFNBUMW.js → LinksBox-TI26VFFH.js} +1 -1
- package/dist/{ProfilesView-6GXF6CP2.js → ProfilesView-CRO5AH3H.js} +1 -1
- package/dist/{ProjectPicker-W6XDGNDJ.js → ProjectPicker-3N7LJOXU.js} +1 -1
- package/dist/{SaveSessionPrompt-QF3P7ERS.js → SaveSessionPrompt-UTOEC5AW.js} +1 -1
- package/dist/SingleShotApp-Y3YDFQSD.js +2 -0
- package/dist/{SummaryBox-4SZI4XSO.js → SummaryBox-JK64EKC2.js} +1 -1
- package/dist/TestMdRunView-O6JTHV5W.js +2 -0
- package/dist/{WhoamiView-N3HAJ3TN.js → WhoamiView-6QSLPNF6.js} +1 -1
- package/dist/{auth-RXNBQZI2.js → auth-IKFVW3NX.js} +1 -1
- package/dist/bind-KCUSVJXG.js +12 -0
- package/dist/bootstrap-NFYYRGGR.js +2 -0
- package/dist/bridge-JSKEO4N3.js +2 -0
- package/dist/{changelog-MI3IPBJS.js → changelog-AAH2ZBYO.js} +1 -1
- package/dist/chat-committer-UUC6JTRJ.js +2 -0
- package/dist/chat-controller-T2FAI55V.js +2 -0
- package/dist/{chunk-CSGQIY7X.js → chunk-23VPUWBD.js} +3 -3
- package/dist/chunk-2UIHS2FH.js +2 -0
- package/dist/chunk-2WFZIQ62.js +2 -0
- package/dist/chunk-2WRBTLFN.js +13 -0
- package/dist/chunk-2YEHV2CX.js +2 -0
- package/dist/chunk-3Q6WAK6P.js +2 -0
- package/dist/{chunk-EN7NW7DU.js → chunk-4LTXE3IX.js} +1 -1
- package/dist/{chunk-NR23HZU4.js → chunk-4NFCAGRK.js} +1 -1
- package/dist/chunk-53IBTIL3.js +12 -0
- package/dist/{chunk-FCMLIK7P.js → chunk-5DBK6QNS.js} +1 -1
- package/dist/chunk-5DT7PIGB.js +5 -0
- package/dist/chunk-5FJJJNJK.js +4 -0
- package/dist/{chunk-BCH3JCND.js → chunk-5SXMV66P.js} +1 -1
- package/dist/{chunk-AV6E6WLY.js → chunk-5WXGMXGA.js} +2 -2
- package/dist/chunk-5ZQZOVWY.js +4 -0
- package/dist/{chunk-FMR2KPSK.js → chunk-6KPPGMO2.js} +1 -1
- package/dist/{chunk-77WMTCUQ.js → chunk-74HTO7K3.js} +1 -1
- package/dist/{chunk-FCHTL74E.js → chunk-7KORP5FF.js} +1 -1
- package/dist/chunk-7OYZR6JA.js +3 -0
- package/dist/chunk-7QJ75SYR.js +8 -0
- package/dist/{chunk-T7ZPMTGS.js → chunk-AECMF3T2.js} +1 -1
- package/dist/chunk-AFBKGZFG.js +2 -0
- package/dist/chunk-AFPHLUQ5.js +6 -0
- package/dist/chunk-AJ56AMT6.js +9 -0
- package/dist/{chunk-RODHDQU3.js → chunk-APPYQZFK.js} +1 -1
- package/dist/{chunk-XLKRV2JH.js → chunk-AXTGYOMK.js} +1 -1
- package/dist/{chunk-AYY7RYMK.js → chunk-B5RS2XZU.js} +2 -2
- package/dist/chunk-BB2W35TW.js +2 -0
- package/dist/chunk-BKHXPBWN.js +2 -0
- package/dist/{chunk-KCBS57IF.js → chunk-BXYWX4J3.js} +1 -1
- package/dist/chunk-C3T7TKAC.js +349 -0
- package/dist/{chunk-IQODWB32.js → chunk-CLGC7VEO.js} +1 -1
- package/dist/{chunk-6HYW5RFX.js → chunk-CUM23TLF.js} +1 -1
- package/dist/chunk-DBIBROYW.js +5 -0
- package/dist/chunk-DBKNJRJG.js +2 -0
- package/dist/chunk-DUAXZYAD.js +4 -0
- package/dist/chunk-DYW5C6II.js +2 -0
- package/dist/chunk-DZPGG4S6.js +7 -0
- package/dist/{chunk-GQ3NCBYR.js → chunk-EOLFTMWF.js} +1 -1
- package/dist/chunk-F7ISS545.js +2 -0
- package/dist/{chunk-CH3VWCRZ.js → chunk-FBHRBFHP.js} +1 -1
- package/dist/{chunk-X5P2T7MA.js → chunk-FDIPQRX4.js} +1 -1
- package/dist/chunk-GFKCTYCA.js +6 -0
- package/dist/{chunk-5WE4DHXL.js → chunk-GYNTNKNB.js} +1 -1
- package/dist/{chunk-RQYS3KGU.js → chunk-H32GM5G4.js} +1 -1
- package/dist/{chunk-4BAMZSFU.js → chunk-HYSFJSIG.js} +1 -1
- package/dist/chunk-I7TIGB7K.js +2 -0
- package/dist/chunk-IDX3TOPY.js +6 -0
- package/dist/{chunk-CVOGP253.js → chunk-IMR64OCZ.js} +1 -1
- package/dist/{chunk-3RZ63RBO.js → chunk-IOD3HQVW.js} +1 -1
- package/dist/{chunk-QBCS57EO.js → chunk-J5FBU425.js} +40 -40
- package/dist/chunk-JKM2PUHI.js +4 -0
- package/dist/{chunk-HOOXUO3X.js → chunk-JPWLGHPM.js} +1 -1
- package/dist/chunk-JZ26R6UL.js +2 -0
- package/dist/chunk-KBM3XHAM.js +2 -0
- package/dist/chunk-KCCSWEGA.js +4 -0
- package/dist/{chunk-J3EMJ7US.js → chunk-KQZA2QSC.js} +1 -1
- package/dist/{chunk-MV4UYTZT.js → chunk-KWIK22R6.js} +1 -1
- package/dist/chunk-L2TV4G56.js +4 -0
- package/dist/{chunk-VYMCE7UR.js → chunk-M6FKJKC6.js} +2 -2
- package/dist/{chunk-5YHVK2EO.js → chunk-MK7JUOYV.js} +1 -1
- package/dist/chunk-N2P4MI32.js +2 -0
- package/dist/{chunk-A2IQRVPR.js → chunk-O75ZHGJG.js} +1 -1
- package/dist/chunk-OR6MCL6Z.js +2 -0
- package/dist/chunk-ORQNKZ2Z.js +5 -0
- package/dist/{chunk-GRB66C5S.js → chunk-OS4VSIHT.js} +1 -1
- package/dist/{chunk-E5PWL3BG.js → chunk-OUJQVBUT.js} +3 -3
- package/dist/{chunk-SBZWFULF.js → chunk-PLOWZLG5.js} +1 -1
- package/dist/chunk-QIGPXYMF.js +19 -0
- package/dist/chunk-QOFZSHSC.js +47 -0
- package/dist/{chunk-2XMJ6YAE.js → chunk-R5T4RLF5.js} +1 -1
- package/dist/chunk-R7QAS6LZ.js +4 -0
- package/dist/{chunk-YHQFYZJ5.js → chunk-RDNFVZEB.js} +1 -1
- package/dist/{chunk-67SSEGDO.js → chunk-SFII7HPP.js} +1 -1
- package/dist/{chunk-4SJC64KQ.js → chunk-SL6PCVM2.js} +1 -1
- package/dist/{chunk-QQUZF2DZ.js → chunk-STVP2XHO.js} +1 -1
- package/dist/chunk-TH47OOBV.js +4 -0
- package/dist/chunk-TRJUD3XJ.js +5 -0
- package/dist/{chunk-XIXR63FI.js → chunk-UC7MNPIN.js} +1 -1
- package/dist/chunk-UD7KKHPW.js +5 -0
- package/dist/chunk-VAYBKR76.js +4 -0
- package/dist/chunk-VFII6C46.js +2 -0
- package/dist/chunk-VGFTNLQQ.js +2 -0
- package/dist/{chunk-AIMINJVP.js → chunk-VHZ4S57N.js} +1 -1
- package/dist/chunk-VLWMMOMF.js +6 -0
- package/dist/chunk-VMM4LC4V.js +10 -0
- package/dist/{chunk-DFDDUMG5.js → chunk-VOOPWFHW.js} +1 -1
- package/dist/{chunk-4GLYNAK7.js → chunk-VRLUNZAK.js} +1 -1
- package/dist/chunk-VRVFPMCR.js +2 -0
- package/dist/{chunk-WREVEATJ.js → chunk-VT54ARGE.js} +1 -1
- package/dist/{chunk-LGVHW4ZA.js → chunk-VWKVUOXU.js} +1 -1
- package/dist/chunk-W4B5LOEX.js +4 -0
- package/dist/{chunk-K7USHLVZ.js → chunk-W5TTF7GB.js} +3 -3
- package/dist/chunk-WXHQYYD5.js +2 -0
- package/dist/{chunk-44IWSV6L.js → chunk-XUS4WKDS.js} +1 -1
- package/dist/chunk-XWKUZJCP.js +2 -0
- package/dist/chunk-YTHQNN2L.js +3 -0
- package/dist/{chunk-K4VIM4RM.js → chunk-ZBOWFJB2.js} +2 -2
- package/dist/chunk-ZMNJBUAO.js +2 -0
- package/dist/{chunk-MTHCUBDF.js → chunk-ZRASQ63J.js} +1 -1
- package/dist/{chunk-B4LLKQTK.js → chunk-ZUGCHQFC.js} +1 -1
- package/dist/committer-SWEWEYNX.js +2 -0
- package/dist/{config-5GOFF5F4.js → config-CWZV6XPT.js} +1 -1
- package/dist/cover-cmd-NWIRJY5Z.js +3 -0
- package/dist/{credentials-GXDXVMXW.js → credentials-YHTJGKEO.js} +1 -1
- package/dist/descriptor-OEUZZCOK.js +2 -0
- package/dist/design-committer-VYT6NU3T.js +2 -0
- package/dist/dispatch-WVNXB7AD.js +2 -0
- package/dist/docx-convert-CHLJUTFH.js +2 -0
- package/dist/dossier-KTLTGT2X.js +3 -0
- package/dist/evidence-IVDNXWPL.js +2 -0
- package/dist/evolve-cmd-XBX4SX5H.js +2 -0
- package/dist/{exit-manager-MXUD7GQ7.js → exit-manager-XZL4KIJU.js} +1 -1
- package/dist/explain-UAAQWHYR.js +2 -0
- package/dist/{explain-cmd-NWIYH5MI.js → explain-cmd-75MCF2ZV.js} +1 -1
- package/dist/{explain-cmd-DBUTPZHA.js → explain-cmd-IZEHWZV5.js} +1 -1
- package/dist/extract-bind-5OWELRME.js +10 -0
- package/dist/extract-cmd-ZRYMJ6IC.js +5 -0
- package/dist/feeder-C3TOJPKK.js +2 -0
- package/dist/gaps-cmd-XBRXKXDL.js +3 -0
- package/dist/{gate-B6C6KLFA.js → gate-54BRAE7N.js} +1 -1
- package/dist/{generate-headless-LZ4HRSQ4.js → generate-headless-D6BISWDC.js} +2 -2
- package/dist/{headless-io-PWW6YKH2.js → headless-io-66RG5NN5.js} +1 -1
- package/dist/identity-ADZ4PAJF.js +2 -0
- package/dist/index.js +61 -62
- package/dist/ingest-EX72IEQT.js +2 -0
- package/dist/ingest-cmd-YTGOICTC.js +2 -0
- package/dist/interactive-bind-XSRD36MO.js +25 -0
- package/dist/lifecycle-cmd-EQSFAZG6.js +2 -0
- package/dist/list-cmd-IRJSUCM5.js +3 -0
- package/dist/{list-commands-WIVODSEL.js → list-commands-RCYHJ5Y3.js} +1 -1
- package/dist/locks-cmd-CSVSWY2Y.js +2 -0
- package/dist/logical-ids-TEBCQJGO.js +2 -0
- package/dist/login-flow-PYAPYCPY.js +2 -0
- package/dist/maintenance-cmd-MVFA6H74.js +2 -0
- package/dist/next-TRSKMBO5.js +2 -0
- package/dist/paths-JCYX6UWL.js +2 -0
- package/dist/pdf-convert-OZIRUADA.js +2 -0
- package/dist/{persist-recorded-session-J6Z2SCTT.js → persist-recorded-session-DTYCLXTQ.js} +1 -1
- package/dist/phase-seed-DIRETNU6.js +2 -0
- package/dist/pipeline-MXFOD6ES.js +2 -0
- package/dist/readmodel-XOYGGQ3S.js +2 -0
- package/dist/reconcile-cmd-EG6BOU3A.js +2 -0
- package/dist/reconcile-deps-HTT6IPHT.js +4 -0
- package/dist/reconcile-engine-JQNXALNY.js +2 -0
- package/dist/{recording-banner-IRFMIZSJ.js → recording-banner-76GCIPUN.js} +1 -1
- package/dist/records-IOZTZUZV.js +2 -0
- package/dist/{require-project-folder-XSBJGIVF.js → require-project-folder-ACRDP5ZB.js} +1 -1
- package/dist/{resolver-IDCGRPFJ.js → resolver-SRPCFW7P.js} +1 -1
- package/dist/revert-NQ7GEVSE.js +2 -0
- package/dist/review-cmd-L3V5UP5T.js +4 -0
- package/dist/run-GMZCDRDD.js +2 -0
- package/dist/run-TFRWPGXP.js +2 -0
- package/dist/run-channel-RGH4WIQX.js +2 -0
- package/dist/{run-test-md-QCERS7FQ.js → run-test-md-KEHSRMCM.js} +2 -2
- package/dist/sessions-GIEXOCE4.js +2 -0
- package/dist/sessions-cmd-ZVYGSRJ3.js +25 -0
- package/dist/{skill-installer-WAVEVCSG.js → skill-installer-HBN3A35K.js} +1 -1
- package/dist/spawner-GC5CFAJ7.js +2 -0
- package/dist/structured-answers-A43Q25CZ.js +5 -0
- package/dist/tcg-generate-V7YFNC5O.js +2 -0
- package/dist/testmd-actions-MNDOO76O.js +2 -0
- package/dist/token-refresh-3UYMCYG3.js +2 -0
- package/dist/trust-gate-EX7R2P4Y.js +2 -0
- package/dist/{validate-basic-IJKKRQRU.js → validate-basic-ZGWPBYB6.js} +1 -1
- package/dist/verdicts-SCETLY5J.js +2 -0
- package/dist/{version-check-O5GYZYTP.js → version-check-CJWKDAXV.js} +1 -1
- package/dist/{view-cmd-GQBFCPDL.js → view-cmd-SOVM64L2.js} +1 -1
- package/dist/walk-session-YUYRULPY.js +2 -0
- package/dist/with-telemetry-E7QWPGL6.js +2 -0
- package/package.json +6 -6
- package/dist/ChatSurface-PMEOJBZG.js +0 -8
- package/dist/EvidenceViewOffer-EOKJE2B6.js +0 -2
- package/dist/SingleShotApp-T673X7BS.js +0 -2
- package/dist/TestMdRunView-SNYEO6CS.js +0 -2
- package/dist/bind-NSGW5BBZ.js +0 -6
- package/dist/bootstrap-RPT3JOGD.js +0 -2
- package/dist/bridge-BTSWCJ3B.js +0 -2
- package/dist/chat-committer-OS7ULZMH.js +0 -2
- package/dist/chat-controller-QLORQWJZ.js +0 -2
- package/dist/chunk-3C5GMAM4.js +0 -2
- package/dist/chunk-3CJIMPQK.js +0 -14
- package/dist/chunk-4XSW6WZD.js +0 -5
- package/dist/chunk-5YPBPZUR.js +0 -2
- package/dist/chunk-6W6AIDLJ.js +0 -4
- package/dist/chunk-7E24OCGX.js +0 -2
- package/dist/chunk-7YPK6EDR.js +0 -4
- package/dist/chunk-DGIPQINV.js +0 -12
- package/dist/chunk-EV3EHXEI.js +0 -4
- package/dist/chunk-F7WKDMX7.js +0 -47
- package/dist/chunk-FHKDTM5L.js +0 -6
- package/dist/chunk-FPFOW6BS.js +0 -2
- package/dist/chunk-FRBYGSGJ.js +0 -4
- package/dist/chunk-GG43HSU2.js +0 -3
- package/dist/chunk-J2KSZUOO.js +0 -4
- package/dist/chunk-J44RN3FB.js +0 -2
- package/dist/chunk-JSF5JYZC.js +0 -9
- package/dist/chunk-KHQHVSZ6.js +0 -5
- package/dist/chunk-MAO5BAQI.js +0 -347
- package/dist/chunk-N4LMQR7C.js +0 -6
- package/dist/chunk-QM4S2APK.js +0 -2
- package/dist/chunk-RCTM7NGT.js +0 -2
- package/dist/chunk-RN4OSVTG.js +0 -6
- package/dist/chunk-UXPQRALY.js +0 -13
- package/dist/chunk-V3UE6RJP.js +0 -2
- package/dist/chunk-VJFFMOUA.js +0 -2
- package/dist/chunk-VOHQA2SP.js +0 -2
- package/dist/chunk-WTXHOWUP.js +0 -3
- package/dist/chunk-Y5RNCJAN.js +0 -19
- package/dist/chunk-Z2JSEL3I.js +0 -4
- package/dist/cover-cmd-SV3I23UM.js +0 -2
- package/dist/descriptor-KXDJ4XYD.js +0 -2
- package/dist/docx-convert-ZBVQO2LG.js +0 -2
- package/dist/dossier-KJSJPWOW.js +0 -3
- package/dist/evidence-VDNZ3K23.js +0 -2
- package/dist/evolve-cmd-BLSVVW4I.js +0 -2
- package/dist/explain-EBVIUS2X.js +0 -2
- package/dist/extract-bind-3SWPBZX6.js +0 -8
- package/dist/extract-cmd-HEX7F4IS.js +0 -6
- package/dist/gaps-cmd-CKCHH3HQ.js +0 -2
- package/dist/ingest-FIIO67ZN.js +0 -2
- package/dist/ingest-cmd-KRPZVB7W.js +0 -7
- package/dist/interactive-bind-PTAZVCE7.js +0 -10
- package/dist/lifecycle-cmd-32LG364Q.js +0 -2
- package/dist/list-cmd-UTZ2PQUK.js +0 -3
- package/dist/logical-ids-I7B3VJEH.js +0 -2
- package/dist/login-flow-GX7CTVWN.js +0 -2
- package/dist/maintenance-cmd-BZAGSYGI.js +0 -2
- package/dist/pdf-convert-S7VYE6AV.js +0 -2
- package/dist/pipeline-HT7FCEXA.js +0 -2
- package/dist/readmodel-S5RAQH3F.js +0 -2
- package/dist/reconcile-cmd-2VHBKFA5.js +0 -2
- package/dist/revert-RQJE56HF.js +0 -2
- package/dist/review-cmd-7LXGYHHQ.js +0 -4
- package/dist/run-4LTYFTF2.js +0 -2
- package/dist/run-YGJZ2SXX.js +0 -2
- package/dist/sessions-cmd-DTQYDZNT.js +0 -23
- package/dist/spawner-YNYB4Z7K.js +0 -2
- package/dist/tcg-generate-D35EMRMQ.js +0 -2
- package/dist/testmd-actions-NB5Z6QJ3.js +0 -2
- package/dist/token-refresh-OY3WLAKD.js +0 -2
- package/dist/walk-session-OPAEV4WR.js +0 -2
- /package/dist/{chunk-BC7UVJJB.js → chunk-CH273NAE.js} +0 -0
package/dist/chunk-F7WKDMX7.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ri,b as ii}from"./chunk-VOHQA2SP.js";import{b as ei}from"./chunk-NVGBE2DR.js";import{a as Rt,c as pt,e as Le}from"./chunk-UR6MHSHU.js";var di=pt(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.CHAR=`
|
|
3
|
-
\r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;wt.S=` \r
|
|
4
|
-
`;wt.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";wt.NAME_CHAR="-"+wt.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";wt.CHAR_RE=new RegExp("^["+wt.CHAR+"]$","u");wt.S_RE=new RegExp("^["+wt.S+"]+$","u");wt.NAME_START_CHAR_RE=new RegExp("^["+wt.NAME_START_CHAR+"]$","u");wt.NAME_CHAR_RE=new RegExp("^["+wt.NAME_CHAR+"]$","u");wt.NAME_RE=new RegExp("^["+wt.NAME_START_CHAR+"]["+wt.NAME_CHAR+"]*$","u");wt.NMTOKEN_RE=new RegExp("^["+wt.NAME_CHAR+"]+$","u");var tr=9,er=10,rr=13,ir=32;wt.S_LIST=[ir,er,rr,tr];function Ds(t){return t>=ir&&t<=55295||t===er||t===rr||t===tr||t>=57344&&t<=65533||t>=65536&&t<=1114111}wt.isChar=Ds;function ks(t){return t===ir||t===er||t===rr||t===tr}wt.isS=ks;function ci(t){return t>=65&&t<=90||t>=97&&t<=122||t===58||t===95||t===8204||t===8205||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}wt.isNameStartChar=ci;function Rs(t){return ci(t)||t>=48&&t<=57||t===45||t===46||t===183||t>=768&&t<=879||t>=8255&&t<=8256}wt.isNameChar=Rs});var _i=pt(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";ct.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";ct.S=` \r
|
|
5
|
-
`;ct.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";ct.NAME_CHAR="-"+ct.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";ct.CHAR_RE=new RegExp("^["+ct.CHAR+"]$","u");ct.RESTRICTED_CHAR_RE=new RegExp("^["+ct.RESTRICTED_CHAR+"]$","u");ct.S_RE=new RegExp("^["+ct.S+"]+$","u");ct.NAME_START_CHAR_RE=new RegExp("^["+ct.NAME_START_CHAR+"]$","u");ct.NAME_CHAR_RE=new RegExp("^["+ct.NAME_CHAR+"]$","u");ct.NAME_RE=new RegExp("^["+ct.NAME_START_CHAR+"]["+ct.NAME_CHAR+"]*$","u");ct.NMTOKEN_RE=new RegExp("^["+ct.NAME_CHAR+"]+$","u");var pi=9,xi=10,gi=13,mi=32;ct.S_LIST=[mi,xi,gi,pi];function Ss(t){return t>=1&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}ct.isChar=Ss;function Os(t){return t>=1&&t<=8||t===11||t===12||t>=14&&t<=31||t>=127&&t<=132||t>=134&&t<=159}ct.isRestrictedChar=Os;function Ns(t){return t===9||t===10||t===13||t>31&&t<127||t===133||t>159&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}ct.isCharAndNotRestricted=Ns;function Is(t){return t===mi||t===xi||t===gi||t===pi}ct.isS=Is;function vi(t){return t>=65&&t<=90||t>=97&&t<=122||t===58||t===95||t===8204||t===8205||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}ct.isNameStartChar=vi;function Ms(t){return vi(t)||t>=48&&t<=57||t===45||t===46||t===183||t>=768&&t<=879||t>=8255&&t<=8256}ct.isNameChar=Ms});var Ei=pt(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";Mt.NC_NAME_CHAR="-"+Mt.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";Mt.NC_NAME_START_CHAR_RE=new RegExp("^["+Mt.NC_NAME_START_CHAR+"]$","u");Mt.NC_NAME_CHAR_RE=new RegExp("^["+Mt.NC_NAME_CHAR+"]$","u");Mt.NC_NAME_RE=new RegExp("^["+Mt.NC_NAME_START_CHAR+"]["+Mt.NC_NAME_CHAR+"]*$","u");function wi(t){return t>=65&&t<=90||t===95||t>=97&&t<=122||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}Mt.isNCNameStartChar=wi;function Ls(t){return wi(t)||t===45||t===46||t>=48&&t<=57||t===183||t>=768&&t<=879||t>=8255&&t<=8256}Mt.isNCNameChar=Ls});var vr=pt(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.SaxesParser=ue.EVENTS=void 0;var ce=di(),Ps=_i(),mr=Ei(),Lt=ce.isS,Bs=ce.isChar,De=ce.isNameStartChar,Ci=ce.isNameChar,Li=ce.S_LIST,Us=ce.NAME_RE,Hs=Ps.isChar,Xs=mr.isNCNameStartChar,$s=mr.isNCNameChar,Ys=mr.NC_NAME_RE,$e="http://www.w3.org/XML/1998/namespace",fe="http://www.w3.org/2000/xmlns/",qs={__proto__:null,xml:$e,xmlns:fe},zs={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},Ct=-1,zt=-2,bi=0,Gs=1,nr=2,Ws=3,oe=4,Vs=5,js=6,Zs=7,sr=8,Qs=9,Ks=10,Js=11,ta=12,Nt=13,Pe=14,ar=15,ea=16,or=17,ra=18,ia=19,hr=20,na=21,sa=22,aa=23,Ti=24,lr=25,Be=26,yi=27,oa=28,ha=29,Ai=30,la=31,fa=32,Kt=33,ua=34,fr=35,ke=36,ur=37,ca=38,Fi=39,Di=40,da=41,ki=42,pa=43,xa=44,cr=9,$t=10,dr=13,Ri=32,Si=33,Pi=34,Re=38,Bi=39,Ue=45,He=47,ga=59,Vt=60,he=61,Tt=62,kt=63,Ui=91,le=93,Oi=133,Ni=8232,Xe=t=>t===Pi||t===Bi,Hi=[Pi,Bi],ma=[...Hi,Ui,Tt],va=[...Hi,Vt,le],_a=[he,kt,...Li],wa=[...Li,Tt,Re,Vt];function xr(t,e,r){switch(e){case"xml":r!==$e&&t.fail(`xml prefix must be bound to ${$e}.`);break;case"xmlns":r!==fe&&t.fail(`xmlns prefix must be bound to ${fe}.`);break;default:}switch(r){case fe:t.fail(e===""?`the default namespace may not be set to ${r}.`:`may not assign a prefix (even "xmlns") to the URI ${fe}.`);break;case $e:switch(e){case"xml":break;case"":t.fail(`the default namespace may not be set to ${r}.`);break;default:t.fail("may not assign the xml namespace to another prefix.")}break;default:}}function Ea(t,e){for(let r of Object.keys(e))xr(t,r,e[r])}var Ca=t=>Ys.test(t),ba=t=>Us.test(t),Jt=0,Ii=1,pr=2;ue.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var Mi={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},gr=class{constructor(e){this.opt=e??{},this.fragmentOpt=!!this.opt.fragment;let r=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,r){this.nameStartCheck=Xs,this.nameCheck=$s,this.isName=Ca,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},qs);let i=this.opt.additionalNamespaces;i!=null&&(Ea(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=De,this.nameCheck=Ci,this.isName=ba,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var e;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=Jt,this.attribList=[];let{fragmentOpt:r}=this;this.state=r?Nt:bi,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=r,this.xmlDeclPossible=!r,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(zs),(e=this.readyHandler)===null||e===void 0||e.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(e,r){this[Mi[e]]=r}off(e){this[Mi[e]]=void 0}makeError(e){var r;let i=(r=this.fileName)!==null&&r!==void 0?r:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+e)}fail(e){let r=this.makeError(e),i=this.errorHandler;if(i===void 0)throw r;return i(r),this}write(e){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let r=!1;e===null?(r=!0,e=""):typeof e=="object"&&(e=e.toString()),this.carriedFromPrevious!==void 0&&(e=`${this.carriedFromPrevious}${e}`,this.carriedFromPrevious=void 0);let i=e.length,n=e.charCodeAt(i-1);!r&&(n===dr||n>=55296&&n<=56319)&&(this.carriedFromPrevious=e[i-1],i--,e=e.slice(0,i));let{stateTable:s}=this;for(this.chunk=e,this.i=0;this.i<i;)s[this.state].call(this);return this.chunkPosition+=i,r?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:e,i:r}=this;if(this.prevI=r,this.i=r+1,r>=e.length)return Ct;let i=e.charCodeAt(r);if(this.column++,i<55296){if(i>=Ri||i===cr)return i;switch(i){case $t:return this.line++,this.column=0,this.positionAtNewLine=this.position,$t;case dr:return e.charCodeAt(r+1)===$t&&(this.i=r+2),this.line++,this.column=0,this.positionAtNewLine=this.position,zt;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(e.charCodeAt(r+1)-56320);return this.i=r+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){let{chunk:e,i:r}=this;if(this.prevI=r,this.i=r+1,r>=e.length)return Ct;let i=e.charCodeAt(r);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==Ni||i===cr)return i;switch(i){case $t:return this.line++,this.column=0,this.positionAtNewLine=this.position,$t;case dr:{let s=e.charCodeAt(r+1);(s===$t||s===Oi)&&(this.i=r+2)}case Oi:case Ni:return this.line++,this.column=0,this.positionAtNewLine=this.position,zt;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(e.charCodeAt(r+1)-56320);return this.i=r+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){let e=this.getCode();return e===zt?$t:e}unget(){this.i=this.prevI,this.column--}captureTo(e){let{i:r}=this,{chunk:i}=this;for(;;){let n=this.getCode(),s=n===zt,a=s?$t:n;if(a===Ct||e.includes(a))return this.text+=i.slice(r,this.prevI),a;s&&(this.text+=`${i.slice(r,this.prevI)}
|
|
6
|
-
`,r=this.i)}}captureToChar(e){let{i:r}=this,{chunk:i}=this;for(;;){let n=this.getCode();switch(n){case zt:this.text+=`${i.slice(r,this.prevI)}
|
|
7
|
-
`,r=this.i,n=$t;break;case Ct:return this.text+=i.slice(r),!1;default:}if(n===e)return this.text+=i.slice(r,this.prevI),!0}}captureNameChars(){let{chunk:e,i:r}=this;for(;;){let i=this.getCode();if(i===Ct)return this.name+=e.slice(r),Ct;if(!Ci(i))return this.name+=e.slice(r,this.prevI),i===zt?$t:i}}skipSpaces(){for(;;){let e=this.getCodeNorm();if(e===Ct||!Lt(e))return e}}setXMLVersion(e){this.currentXMLVersion=e,e==="1.0"?(this.isChar=Bs,this.getCode=this.getCode10):(this.isChar=Hs,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=Gs}sBeginWhitespace(){let e=this.i,r=this.skipSpaces();switch(this.prevI!==e&&(this.xmlDeclPossible=!1),r){case Vt:if(this.state=ar,this.text.length!==0)throw new Error("no-empty text at start");break;case Ct:break;default:this.unget(),this.state=Nt,this.xmlDeclPossible=!1}}sDoctype(){var e;let r=this.captureTo(ma);switch(r){case Tt:{(e=this.doctypeHandler)===null||e===void 0||e.call(this,this.text),this.text="",this.state=Nt,this.doctype=!0;break}case Ct:break;default:this.text+=String.fromCodePoint(r),r===Ui?this.state=oe:Xe(r)&&(this.state=Ws,this.q=r)}}sDoctypeQuote(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.q=null,this.state=nr)}sDTD(){let e=this.captureTo(va);e!==Ct&&(this.text+=String.fromCodePoint(e),e===le?this.state=nr:e===Vt?this.state=js:Xe(e)&&(this.state=Vs,this.q=e))}sDTDQuoted(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.state=oe,this.q=null)}sDTDOpenWaka(){let e=this.getCodeNorm();switch(this.text+=String.fromCodePoint(e),e){case Si:this.state=Zs,this.openWakaBang="";break;case kt:this.state=Js;break;default:this.state=oe}}sDTDOpenWakaBang(){let e=String.fromCodePoint(this.getCodeNorm()),r=this.openWakaBang+=e;this.text+=e,r!=="-"&&(this.state=r==="--"?sr:oe,this.openWakaBang="")}sDTDComment(){this.captureToChar(Ue)&&(this.text+="-",this.state=Qs)}sDTDCommentEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),this.state=e===Ue?Ks:sr}sDTDCommentEnded(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===Tt?this.state=oe:(this.fail("malformed comment."),this.state=sr)}sDTDPI(){this.captureToChar(kt)&&(this.text+="?",this.state=ta)}sDTDPIEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===Tt&&(this.state=oe)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:e}=this,{chunk:r}=this;t:for(;;)switch(this.getCode()){case zt:this.entity+=`${r.slice(e,this.prevI)}
|
|
8
|
-
`,e=this.i;break;case ga:{let{entityReturnState:i}=this,n=this.entity+r.slice(e,this.prevI);this.state=i;let s;n===""?(this.fail("empty entity name."),s="&;"):(s=this.parseEntity(n),this.entity=""),(i!==Nt||this.textHandler!==void 0)&&(this.text+=s);break t}case Ct:this.entity+=r.slice(e);break t;default:}}sOpenWaka(){let e=this.getCode();if(De(e))this.state=ua,this.unget(),this.xmlDeclPossible=!1;else switch(e){case He:this.state=pa,this.xmlDeclPossible=!1;break;case Si:this.state=ea,this.openWakaBang="",this.xmlDeclPossible=!1;break;case kt:this.state=aa;break;default:this.fail("disallowed character in tag name"),this.state=Nt,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=hr,this.openWakaBang="";break;case"--":this.state=or,this.openWakaBang="";break;case"DOCTYPE":this.state=nr,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(Ue)&&(this.state=ra)}sCommentEnding(){var e;let r=this.getCodeNorm();r===Ue?(this.state=ia,(e=this.commentHandler)===null||e===void 0||e.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(r)}`,this.state=or)}sCommentEnded(){let e=this.getCodeNorm();e!==Tt?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(e)}`,this.state=or):this.state=Nt}sCData(){this.captureToChar(le)&&(this.state=na)}sCDataEnding(){let e=this.getCodeNorm();e===le?this.state=sa:(this.text+=`]${String.fromCodePoint(e)}`,this.state=hr)}sCDataEnding2(){var e;let r=this.getCodeNorm();switch(r){case Tt:{(e=this.cdataHandler)===null||e===void 0||e.call(this,this.text),this.text="",this.state=Nt;break}case le:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(r)}`,this.state=hr}}sPIFirstChar(){let e=this.getCodeNorm();this.nameStartCheck(e)?(this.piTarget+=String.fromCodePoint(e),this.state=Ti):e===kt||Lt(e)?(this.fail("processing instruction without a target."),this.state=e===kt?Be:lr):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(e),this.state=Ti)}sPIRest(){let{chunk:e,i:r}=this;for(;;){let i=this.getCodeNorm();if(i===Ct){this.piTarget+=e.slice(r);return}if(!this.nameCheck(i)){this.piTarget+=e.slice(r,this.prevI);let n=i===kt;n||Lt(i)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=n?Kt:yi):this.state=n?Be:lr:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(i));break}}}sPIBody(){if(this.text.length===0){let e=this.getCodeNorm();e===kt?this.state=Be:Lt(e)||(this.text=String.fromCodePoint(e))}else this.captureToChar(kt)&&(this.state=Be)}sPIEnding(){var e;let r=this.getCodeNorm();if(r===Tt){let{piTarget:i}=this;i.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(e=this.piHandler)===null||e===void 0||e.call(this,{target:i,body:this.text}),this.piTarget=this.text="",this.state=Nt}else r===kt?this.text+="?":(this.text+=`?${String.fromCodePoint(r)}`,this.state=lr);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let e=this.skipSpaces();if(e===kt){this.state=Kt;return}e!==Ct&&(this.state=oa,this.name=String.fromCodePoint(e))}sXMLDeclName(){let e=this.captureTo(_a);if(e===kt){this.state=Kt,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(Lt(e)||e===he){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=e===he?Ai:ha}}sXMLDeclEq(){let e=this.getCodeNorm();if(e===kt){this.state=Kt,this.fail("XML declaration is incomplete.");return}Lt(e)||(e!==he&&this.fail("value required."),this.state=Ai)}sXMLDeclValueStart(){let e=this.getCodeNorm();if(e===kt){this.state=Kt,this.fail("XML declaration is incomplete.");return}Lt(e)||(Xe(e)?this.q=e:(this.fail("value must be quoted."),this.q=Ri),this.state=la)}sXMLDeclValue(){let e=this.captureTo([this.q,kt]);if(e===kt){this.state=Kt,this.text="",this.fail("XML declaration is incomplete.");return}if(e===Ct)return;let r=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let i=r;this.xmlDecl.version=i,/^1\.[0-9]+$/.test(i)?this.opt.forceXMLVersion||this.setXMLVersion(i):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(r)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=r;break;case"standalone":r!=="yes"&&r!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=r;break;default:}this.name="",this.state=fa}sXMLDeclSeparator(){let e=this.getCodeNorm();if(e===kt){this.state=Kt;return}Lt(e)||(this.fail("whitespace required."),this.unget()),this.state=yi}sXMLDeclEnding(){var e;this.getCodeNorm()===Tt?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(e=this.xmldeclHandler)===null||e===void 0||e.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=Nt):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var e;let r=this.captureNameChars();if(r===Ct)return;let i=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=i.ns=Object.create(null)),(e=this.openTagStartHandler)===null||e===void 0||e.call(this,i),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),r){case Tt:this.openTag();break;case He:this.state=fr;break;default:Lt(r)||this.fail("disallowed character in tag name."),this.state=ke}}sOpenTagSlash(){this.getCode()===Tt?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=ke)}sAttrib(){let e=this.skipSpaces();e!==Ct&&(De(e)?(this.unget(),this.state=ur):e===Tt?this.openTag():e===He?this.state=fr:this.fail("disallowed character in attribute name."))}sAttribName(){let e=this.captureNameChars();e===he?this.state=Fi:Lt(e)?this.state=ca:e===Tt?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):e!==Ct&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){let e=this.skipSpaces();switch(e){case Ct:return;case he:this.state=Fi;break;default:this.fail("attribute without value."),this.text="",this.name="",e===Tt?this.openTag():De(e)?(this.unget(),this.state=ur):(this.fail("disallowed character in attribute name."),this.state=ke)}}sAttribValue(){let e=this.getCodeNorm();Xe(e)?(this.q=e,this.state=Di):Lt(e)||(this.fail("unquoted attribute value."),this.state=ki,this.unget())}sAttribValueQuoted(){let{q:e,chunk:r}=this,{i}=this;for(;;)switch(this.getCode()){case e:this.pushAttrib(this.name,this.text+r.slice(i,this.prevI)),this.name=this.text="",this.q=null,this.state=da;return;case Re:this.text+=r.slice(i,this.prevI),this.state=Pe,this.entityReturnState=Di;return;case $t:case zt:case cr:this.text+=`${r.slice(i,this.prevI)} `,i=this.i;break;case Vt:this.text+=r.slice(i,this.prevI),this.fail("disallowed character.");return;case Ct:this.text+=r.slice(i);return;default:}}sAttribValueClosed(){let e=this.getCodeNorm();Lt(e)?this.state=ke:e===Tt?this.openTag():e===He?this.state=fr:De(e)?(this.fail("no whitespace between attributes."),this.unget(),this.state=ur):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){let e=this.captureTo(wa);switch(e){case Re:this.state=Pe,this.entityReturnState=ki;break;case Vt:this.fail("disallowed character.");break;case Ct:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",e===Tt?this.openTag():this.state=ke}}sCloseTag(){let e=this.captureNameChars();e===Tt?this.closeTag():Lt(e)?this.state=xa:e!==Ct&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case Tt:this.closeTag();break;case Ct:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:e,forbiddenState:r}=this,{chunk:i,textHandler:n}=this;t:for(;;)switch(this.getCode()){case Vt:{if(this.state=ar,n!==void 0){let{text:s}=this,a=i.slice(e,this.prevI);s.length!==0?(n(s+a),this.text=""):a.length!==0&&n(a)}r=Jt;break t}case Re:this.state=Pe,this.entityReturnState=Nt,n!==void 0&&(this.text+=i.slice(e,this.prevI)),r=Jt;break t;case le:switch(r){case Jt:r=Ii;break;case Ii:r=pr;break;case pr:break;default:throw new Error("impossible state")}break;case Tt:r===pr&&this.fail('the string "]]>" is disallowed in char data.'),r=Jt;break;case zt:n!==void 0&&(this.text+=`${i.slice(e,this.prevI)}
|
|
9
|
-
`),e=this.i,r=Jt;break;case Ct:n!==void 0&&(this.text+=i.slice(e));break t;default:r=Jt}this.forbiddenState=r}handleTextOutsideRoot(){let{i:e}=this,{chunk:r,textHandler:i}=this,n=!1;t:for(;;){let s=this.getCode();switch(s){case Vt:{if(this.state=ar,i!==void 0){let{text:a}=this,o=r.slice(e,this.prevI);a.length!==0?(i(a+o),this.text=""):o.length!==0&&i(o)}break t}case Re:this.state=Pe,this.entityReturnState=Nt,i!==void 0&&(this.text+=r.slice(e,this.prevI)),n=!0;break t;case zt:i!==void 0&&(this.text+=`${r.slice(e,this.prevI)}
|
|
10
|
-
`),e=this.i;break;case Ct:i!==void 0&&(this.text+=r.slice(e));break t;default:Lt(s)||(n=!0)}}n&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(e,r){var i;let{prefix:n,local:s}=this.qname(e),a={name:e,prefix:n,local:s,value:r};if(this.attribList.push(a),(i=this.attributeHandler)===null||i===void 0||i.call(this,a),n==="xmlns"){let o=r.trim();this.currentXMLVersion==="1.0"&&o===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[s]=o,xr(this,s,o)}else if(e==="xmlns"){let o=r.trim();this.topNS[""]=o,xr(this,"",o)}}pushAttribPlain(e,r){var i;let n={name:e,value:r};this.attribList.push(n),(i=this.attributeHandler)===null||i===void 0||i.call(this,n)}end(){var e,r;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let s=i.pop();this.fail(`unclosed tag: ${s.name}`)}this.state!==bi&&this.state!==Nt&&this.fail("unexpected end.");let{text:n}=this;return n.length!==0&&((e=this.textHandler)===null||e===void 0||e.call(this,n),this.text=""),this._closed=!0,(r=this.endHandler)===null||r===void 0||r.call(this),this._init(),this}resolve(e){var r,i;let n=this.topNS[e];if(n!==void 0)return n;let{tags:s}=this;for(let a=s.length-1;a>=0;a--)if(n=s[a].ns[e],n!==void 0)return n;return n=this.ns[e],n!==void 0?n:(i=(r=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(r,e)}qname(e){let r=e.indexOf(":");if(r===-1)return{prefix:"",local:e};let i=e.slice(r+1),n=e.slice(0,r);return(n===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${e}.`),{prefix:n,local:i}}processAttribsNS(){var e;let{attribList:r}=this,i=this.tag;{let{prefix:a,local:o}=this.qname(i.name);i.prefix=a,i.local=o;let h=i.uri=(e=this.resolve(a))!==null&&e!==void 0?e:"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),h===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),i.uri=a))}if(r.length===0)return;let{attributes:n}=i,s=new Set;for(let a of r){let{name:o,prefix:h,local:l}=a,p,f;h===""?(p=o==="xmlns"?fe:"",f=o):(p=this.resolve(h),p===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(h)}.`),p=h),f=`{${p}}${l}`),s.has(f)&&this.fail(`duplicate attribute: ${f}.`),s.add(f),a.uri=p,n[o]=a}this.attribList=[]}processAttribsPlain(){let{attribList:e}=this,r=this.tag.attributes;for(let{name:i,value:n}of e)r[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),r[i]=n;this.attribList=[]}openTag(){var e;this.processAttribs();let{tags:r}=this,i=this.tag;i.isSelfClosing=!1,(e=this.openTagHandler)===null||e===void 0||e.call(this,i),r.push(i),this.state=Nt,this.name=""}openSelfClosingTag(){var e,r,i;this.processAttribs();let{tags:n}=this,s=this.tag;s.isSelfClosing=!0,(e=this.openTagHandler)===null||e===void 0||e.call(this,s),(r=this.closeTagHandler)===null||r===void 0||r.call(this,s),(this.tag=(i=n[n.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=Nt,this.name=""}closeTag(){let{tags:e,name:r}=this;if(this.state=Nt,this.name="",r===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,n=e.length;for(;n-- >0;){let s=this.tag=e.pop();if(this.topNS=s.ns,i?.(s),s.name===r)break;this.fail("unexpected close tag.")}n===0?this.closedRoot=!0:n<0&&(this.fail(`unmatched closing tag: ${r}.`),this.text+=`</${r}>`)}parseEntity(e){if(e[0]!=="#"){let i=this.ENTITIES[e];return i!==void 0?i:(this.fail(this.isName(e)?"undefined entity.":"disallowed character in entity name."),`&${e};`)}let r=NaN;return e[1]==="x"&&/^#x[0-9a-f]+$/i.test(e)?r=parseInt(e.slice(2),16):/^#[0-9]+$/.test(e)&&(r=parseInt(e.slice(1),10)),this.isChar(r)?String.fromCodePoint(r):(this.fail("malformed character entity."),`&${e};`)}};ue.SaxesParser=gr});var wr=pt((mh,Ki)=>{"use strict";var La=Rt("util"),Qi=Rt("stream"),Yt=Ki.exports=function(){Qi.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};La.inherits(Yt,Qi);Yt.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))};Yt.prototype.write=function(t,e){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let r;return Buffer.isBuffer(t)?r=t:r=Buffer.from(t,e||this._encoding),this._buffers.push(r),this._buffered+=r.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused};Yt.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))};Yt.prototype.destroySoon=Yt.prototype.end;Yt.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()};Yt.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))};Yt.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))};Yt.prototype._processRead=function(t){this._reads.shift();let e=0,r=0,i=Buffer.alloc(t.length);for(;e<t.length;){let n=this._buffers[r++],s=Math.min(n.length,t.length-e);n.copy(i,e,0,s),e+=s,s!==n.length&&(this._buffers[--r]=n.slice(s))}r>0&&this._buffers.splice(0,r),this._buffered-=t.length,t.func.call(this,i)};Yt.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else if(this._buffered>=t.length)this._processRead(t);else break}this._buffers&&!this.writable&&this._end()}catch(t){this.emit("error",t)}}});var Cr=pt(Er=>{"use strict";var jt=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Er.getImagePasses=function(t,e){let r=[],i=t%8,n=e%8,s=(t-i)/8,a=(e-n)/8;for(let o=0;o<jt.length;o++){let h=jt[o],l=s*h.x.length,p=a*h.y.length;for(let f=0;f<h.x.length&&h.x[f]<i;f++)l++;for(let f=0;f<h.y.length&&h.y[f]<n;f++)p++;l>0&&p>0&&r.push({width:l,height:p,index:o})}return r};Er.getInterlaceIterator=function(t){return function(e,r,i){let n=e%jt[i].x.length,s=(e-n)/jt[i].x.length*8+jt[i].x[n],a=r%jt[i].y.length,o=(r-a)/jt[i].y.length*8+jt[i].y[a];return s*4+o*t*4}}});var br=pt((_h,Ji)=>{"use strict";Ji.exports=function(e,r,i){let n=e+r-i,s=Math.abs(n-e),a=Math.abs(n-r),o=Math.abs(n-i);return s<=a&&s<=o?e:a<=o?r:i}});var Tr=pt((wh,en)=>{"use strict";var Pa=Cr(),Ba=br();function tn(t,e,r){let i=t*e;return r!==8&&(i=Math.ceil(i/(8/r))),i}var pe=en.exports=function(t,e){let r=t.width,i=t.height,n=t.interlace,s=t.bpp,a=t.depth;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],n){let o=Pa.getImagePasses(r,i);for(let h=0;h<o.length;h++)this._images.push({byteWidth:tn(o[h].width,s,a),height:o[h].height,lineIndex:0})}else this._images.push({byteWidth:tn(r,s,a),height:i,lineIndex:0});a===8?this._xComparison=s:a===16?this._xComparison=s*2:this._xComparison=1};pe.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};pe.prototype._unFilterType1=function(t,e,r){let i=this._xComparison,n=i-1;for(let s=0;s<r;s++){let a=t[1+s],o=s>n?e[s-i]:0;e[s]=a+o}};pe.prototype._unFilterType2=function(t,e,r){let i=this._lastLine;for(let n=0;n<r;n++){let s=t[1+n],a=i?i[n]:0;e[n]=s+a}};pe.prototype._unFilterType3=function(t,e,r){let i=this._xComparison,n=i-1,s=this._lastLine;for(let a=0;a<r;a++){let o=t[1+a],h=s?s[a]:0,l=a>n?e[a-i]:0,p=Math.floor((l+h)/2);e[a]=o+p}};pe.prototype._unFilterType4=function(t,e,r){let i=this._xComparison,n=i-1,s=this._lastLine;for(let a=0;a<r;a++){let o=t[1+a],h=s?s[a]:0,l=a>n?e[a-i]:0,p=a>n&&s?s[a-i]:0,f=Ba(l,h,p);e[a]=o+f}};pe.prototype._reverseFilterLine=function(t){let e=t[0],r,i=this._images[this._imageIndex],n=i.byteWidth;if(e===0)r=t.slice(1,n+1);else switch(r=Buffer.alloc(n),e){case 1:this._unFilterType1(t,r,n);break;case 2:this._unFilterType2(t,r,n);break;case 3:this._unFilterType3(t,r,n);break;case 4:this._unFilterType4(t,r,n);break;default:throw new Error("Unrecognised filter type - "+e)}this.write(r),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=r,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}});var sn=pt((Eh,nn)=>{"use strict";var Ua=Rt("util"),rn=wr(),Ha=Tr(),Xa=nn.exports=function(t){rn.call(this);let e=[],r=this;this._filter=new Ha(t,{read:this.read.bind(this),write:function(i){e.push(i)},complete:function(){r.emit("complete",Buffer.concat(e))}}),this._filter.start()};Ua.inherits(Xa,rn)});var xe=pt((Ch,an)=>{"use strict";an.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Fr=pt((bh,on)=>{"use strict";var yr=[];(function(){for(let t=0;t<256;t++){let e=t;for(let r=0;r<8;r++)e&1?e=3988292384^e>>>1:e=e>>>1;yr[t]=e}})();var Ar=on.exports=function(){this._crc=-1};Ar.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=yr[(this._crc^t[e])&255]^this._crc>>>8;return!0};Ar.prototype.crc32=function(){return this._crc^-1};Ar.crc32=function(t){let e=-1;for(let r=0;r<t.length;r++)e=yr[(e^t[r])&255]^e>>>8;return e^-1}});var Dr=pt((Th,hn)=>{"use strict";var yt=xe(),$a=Fr(),Ft=hn.exports=function(t,e){this._options=t,t.checkCRC=t.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[yt.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[yt.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[yt.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[yt.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[yt.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[yt.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};Ft.prototype.start=function(){this.read(yt.PNG_SIGNATURE.length,this._parseSignature.bind(this))};Ft.prototype._parseSignature=function(t){let e=yt.PNG_SIGNATURE;for(let r=0;r<e.length;r++)if(t[r]!==e[r]){this.error(new Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),r=t.readUInt32BE(4),i="";for(let s=4;s<8;s++)i+=String.fromCharCode(t[s]);let n=!!(t[4]&32);if(!this._hasIHDR&&r!==yt.TYPE_IHDR){this.error(new Error("Expected IHDR on beggining"));return}if(this._crc=new $a,this._crc.write(Buffer.from(i)),this._chunks[r])return this._chunks[r](e);if(!n){this.error(new Error("Unsupported critical chunk type "+i));return}this.read(e+4,this._skipChunk.bind(this))};Ft.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};Ft.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),r=this._crc.crc32();if(this._options.checkCRC&&r!==e){this.error(new Error("Crc error - "+e+" - "+r));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))};Ft.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))};Ft.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),r=t.readUInt32BE(4),i=t[8],n=t[9],s=t[10],a=t[11],o=t[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(new Error("Unsupported bit depth "+i));return}if(!(n in yt.COLORTYPE_TO_BPP_MAP)){this.error(new Error("Unsupported color type"));return}if(s!==0){this.error(new Error("Unsupported compression method"));return}if(a!==0){this.error(new Error("Unsupported filter method"));return}if(o!==0&&o!==1){this.error(new Error("Unsupported interlace method"));return}this._colorType=n;let h=yt.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:r,depth:i,interlace:!!o,palette:!!(n&yt.COLORTYPE_PALETTE),color:!!(n&yt.COLORTYPE_COLOR),alpha:!!(n&yt.COLORTYPE_ALPHA),bpp:h,colorType:n}),this._handleChunkEnd()};Ft.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))};Ft.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let r=0;r<e;r++)this._palette.push([t[r*3],t[r*3+1],t[r*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};Ft.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))};Ft.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===yt.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(new Error("Transparency chunk must be after palette"));return}if(t.length>this._palette.length){this.error(new Error("More transparent colors than palette size"));return}for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}this._colorType===yt.COLORTYPE_GRAYSCALE&&this.transColor([t.readUInt16BE(0)]),this._colorType===yt.COLORTYPE_COLOR&&this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]),this._handleChunkEnd()};Ft.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))};Ft.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/yt.GAMMA_DIVISION),this._handleChunkEnd()};Ft.prototype._handleIDAT=function(t){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-t,this._parseIDAT.bind(this,t))};Ft.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===yt.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw new Error("Expected palette not found");this.inflateData(e);let r=t-e.length;r>0?this._handleIDAT(r):this._handleChunkEnd()};Ft.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))};Ft.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}});var kr=pt(fn=>{"use strict";var ln=Cr(),Ya=[function(){},function(t,e,r,i){if(i===e.length)throw new Error("Ran out of data");let n=e[i];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=255},function(t,e,r,i){if(i+1>=e.length)throw new Error("Ran out of data");let n=e[i];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=e[i+1]},function(t,e,r,i){if(i+2>=e.length)throw new Error("Ran out of data");t[r]=e[i],t[r+1]=e[i+1],t[r+2]=e[i+2],t[r+3]=255},function(t,e,r,i){if(i+3>=e.length)throw new Error("Ran out of data");t[r]=e[i],t[r+1]=e[i+1],t[r+2]=e[i+2],t[r+3]=e[i+3]}],qa=[function(){},function(t,e,r,i){let n=e[0];t[r]=n,t[r+1]=n,t[r+2]=n,t[r+3]=i},function(t,e,r){let i=e[0];t[r]=i,t[r+1]=i,t[r+2]=i,t[r+3]=e[1]},function(t,e,r,i){t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2],t[r+3]=i},function(t,e,r){t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2],t[r+3]=e[3]}];function za(t,e){let r=[],i=0;function n(){if(i===t.length)throw new Error("Ran out of data");let s=t[i];i++;let a,o,h,l,p,f,d,C;switch(e){default:throw new Error("unrecognised depth");case 16:d=t[i],i++,r.push((s<<8)+d);break;case 4:d=s&15,C=s>>4,r.push(C,d);break;case 2:p=s&3,f=s>>2&3,d=s>>4&3,C=s>>6&3,r.push(C,d,f,p);break;case 1:a=s&1,o=s>>1&1,h=s>>2&1,l=s>>3&1,p=s>>4&1,f=s>>5&1,d=s>>6&1,C=s>>7&1,r.push(C,d,f,p,l,h,o,a);break}}return{get:function(s){for(;r.length<s;)n();let a=r.slice(0,s);return r=r.slice(s),a},resetAfterLine:function(){r.length=0},end:function(){if(i!==t.length)throw new Error("extra data found")}}}function Ga(t,e,r,i,n,s){let a=t.width,o=t.height,h=t.index;for(let l=0;l<o;l++)for(let p=0;p<a;p++){let f=r(p,l,h);Ya[i](e,n,f,s),s+=i}return s}function Wa(t,e,r,i,n,s){let a=t.width,o=t.height,h=t.index;for(let l=0;l<o;l++){for(let p=0;p<a;p++){let f=n.get(i),d=r(p,l,h);qa[i](e,f,d,s)}n.resetAfterLine()}}fn.dataToBitMap=function(t,e){let r=e.width,i=e.height,n=e.depth,s=e.bpp,a=e.interlace,o;n!==8&&(o=za(t,n));let h;n<=8?h=Buffer.alloc(r*i*4):h=new Uint16Array(r*i*4);let l=Math.pow(2,n)-1,p=0,f,d;if(a)f=ln.getImagePasses(r,i),d=ln.getInterlaceIterator(r,i);else{let C=0;d=function(){let m=C;return C+=4,m},f=[{width:r,height:i}]}for(let C=0;C<f.length;C++)n===8?p=Ga(f[C],h,d,s,t,p):Wa(f[C],h,d,s,o,l);if(n===8){if(p!==t.length)throw new Error("extra data found")}else o.end();return h}});var Rr=pt((Ah,un)=>{"use strict";function Va(t,e,r,i,n){let s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let h=n[t[s]];if(!h)throw new Error("index "+t[s]+" not in palette");for(let l=0;l<4;l++)e[s+l]=h[l];s+=4}}function ja(t,e,r,i,n){let s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let h=!1;if(n.length===1?n[0]===t[s]&&(h=!0):n[0]===t[s]&&n[1]===t[s+1]&&n[2]===t[s+2]&&(h=!0),h)for(let l=0;l<4;l++)e[s+l]=0;s+=4}}function Za(t,e,r,i,n){let s=255,a=Math.pow(2,n)-1,o=0;for(let h=0;h<i;h++)for(let l=0;l<r;l++){for(let p=0;p<4;p++)e[o+p]=Math.floor(t[o+p]*s/a+.5);o+=4}}un.exports=function(t,e,r=!1){let i=e.depth,n=e.width,s=e.height,a=e.colorType,o=e.transColor,h=e.palette,l=t;return a===3?Va(t,l,n,s,h):(o&&ja(t,l,n,s,o),i!==8&&!r&&(i===16&&(l=Buffer.alloc(n*s*4)),Za(t,l,n,s,i))),l}});var pn=pt((Fh,dn)=>{"use strict";var Qa=Rt("util"),Sr=Rt("zlib"),cn=wr(),Ka=sn(),Ja=Dr(),to=kr(),eo=Rr(),Gt=dn.exports=function(t){cn.call(this),this._parser=new Ja(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};Qa.inherits(Gt,cn);Gt.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0};Gt.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Sr.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let r=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,i=Math.max(r,Sr.Z_MIN_CHUNK);this._inflate=Sr.createInflate({chunkSize:i});let n=r,s=this.emit.bind(this,"error");this._inflate.on("error",function(o){n&&s(o)}),this._filter.on("complete",this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on("data",function(o){n&&(o.length>n&&(o=o.slice(0,n)),n-=o.length,a(o))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)};Gt.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new Ka(this._bitmapInfo)};Gt.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t};Gt.prototype._handlePalette=function(t){this._bitmapInfo.palette=t};Gt.prototype._simpleTransparency=function(){this._metaData.alpha=!0};Gt.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};Gt.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))};Gt.prototype._complete=function(t){if(this.errord)return;let e;try{let r=to.dataToBitMap(t,this._bitmapInfo);e=eo(r,this._bitmapInfo,this._options.skipRescale),r=null}catch(r){this._handleError(r);return}this.emit("parsed",e)}});var gn=pt((Dh,xn)=>{"use strict";var Ut=xe();xn.exports=function(t,e,r,i){let n=[Ut.COLORTYPE_COLOR_ALPHA,Ut.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let m=(function(){let F=new ArrayBuffer(2);return new DataView(F).setInt16(0,256,!0),new Int16Array(F)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&m)return t}let s=i.bitDepth!==16?t:new Uint16Array(t.buffer),a=255,o=Ut.COLORTYPE_TO_BPP_MAP[i.inputColorType];o===4&&!i.inputHasAlpha&&(o=3);let h=Ut.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(a=65535,h*=2);let l=Buffer.alloc(e*r*h),p=0,f=0,d=i.bgColor||{};d.red===void 0&&(d.red=a),d.green===void 0&&(d.green=a),d.blue===void 0&&(d.blue=a);function C(){let m,F,w,T=a;switch(i.inputColorType){case Ut.COLORTYPE_COLOR_ALPHA:T=s[p+3],m=s[p],F=s[p+1],w=s[p+2];break;case Ut.COLORTYPE_COLOR:m=s[p],F=s[p+1],w=s[p+2];break;case Ut.COLORTYPE_ALPHA:T=s[p+1],m=s[p],F=m,w=m;break;case Ut.COLORTYPE_GRAYSCALE:m=s[p],F=m,w=m;break;default:throw new Error("input color type:"+i.inputColorType+" is not supported at present")}return i.inputHasAlpha&&(n||(T/=a,m=Math.min(Math.max(Math.round((1-T)*d.red+T*m),0),a),F=Math.min(Math.max(Math.round((1-T)*d.green+T*F),0),a),w=Math.min(Math.max(Math.round((1-T)*d.blue+T*w),0),a))),{red:m,green:F,blue:w,alpha:T}}for(let m=0;m<r;m++)for(let F=0;F<e;F++){let w=C(s,p);switch(i.colorType){case Ut.COLORTYPE_COLOR_ALPHA:case Ut.COLORTYPE_COLOR:i.bitDepth===8?(l[f]=w.red,l[f+1]=w.green,l[f+2]=w.blue,n&&(l[f+3]=w.alpha)):(l.writeUInt16BE(w.red,f),l.writeUInt16BE(w.green,f+2),l.writeUInt16BE(w.blue,f+4),n&&l.writeUInt16BE(w.alpha,f+6));break;case Ut.COLORTYPE_ALPHA:case Ut.COLORTYPE_GRAYSCALE:{let T=(w.red+w.green+w.blue)/3;i.bitDepth===8?(l[f]=T,n&&(l[f+1]=w.alpha)):(l.writeUInt16BE(T,f),n&&l.writeUInt16BE(w.alpha,f+2));break}default:throw new Error("unrecognised color Type "+i.colorType)}p+=o,f+=h}return l}});var _n=pt((kh,vn)=>{"use strict";var mn=br();function ro(t,e,r,i,n){for(let s=0;s<r;s++)i[n+s]=t[e+s]}function io(t,e,r){let i=0,n=e+r;for(let s=e;s<n;s++)i+=Math.abs(t[s]);return i}function no(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=t[e+a]-o;i[n+a]=h}}function so(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=t[e+s]-a;n+=Math.abs(o)}return n}function ao(t,e,r,i,n){for(let s=0;s<r;s++){let a=e>0?t[e+s-r]:0,o=t[e+s]-a;i[n+s]=o}}function oo(t,e,r){let i=0,n=e+r;for(let s=e;s<n;s++){let a=e>0?t[s-r]:0,o=t[s]-a;i+=Math.abs(o)}return i}function ho(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=e>0?t[e+a-r]:0,l=t[e+a]-(o+h>>1);i[n+a]=l}}function lo(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=e>0?t[e+s-r]:0,h=t[e+s]-(a+o>>1);n+=Math.abs(h)}return n}function fo(t,e,r,i,n,s){for(let a=0;a<r;a++){let o=a>=s?t[e+a-s]:0,h=e>0?t[e+a-r]:0,l=e>0&&a>=s?t[e+a-(r+s)]:0,p=t[e+a]-mn(o,h,l);i[n+a]=p}}function uo(t,e,r,i){let n=0;for(let s=0;s<r;s++){let a=s>=i?t[e+s-i]:0,o=e>0?t[e+s-r]:0,h=e>0&&s>=i?t[e+s-(r+i)]:0,l=t[e+s]-mn(a,o,h);n+=Math.abs(l)}return n}var co={0:ro,1:no,2:ao,3:ho,4:fo},po={0:io,1:so,2:oo,3:lo,4:uo};vn.exports=function(t,e,r,i,n){let s;if(!("filterType"in i)||i.filterType===-1)s=[0,1,2,3,4];else if(typeof i.filterType=="number")s=[i.filterType];else throw new Error("unrecognised filter types");i.bitDepth===16&&(n*=2);let a=e*n,o=0,h=0,l=Buffer.alloc((a+1)*r),p=s[0];for(let f=0;f<r;f++){if(s.length>1){let d=1/0;for(let C=0;C<s.length;C++){let m=po[s[C]](t,h,a,n);m<d&&(p=s[C],d=m)}}l[o]=p,o++,co[p](t,h,a,l,o,n),o+=a,h+=a}return l}});var Or=pt((Rh,wn)=>{"use strict";var Ot=xe(),xo=Fr(),go=gn(),mo=_n(),vo=Rt("zlib"),Zt=wn.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32*1024,t.deflateLevel=t.deflateLevel!=null?t.deflateLevel:9,t.deflateStrategy=t.deflateStrategy!=null?t.deflateStrategy:3,t.inputHasAlpha=t.inputHasAlpha!=null?t.inputHasAlpha:!0,t.deflateFactory=t.deflateFactory||vo.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType=typeof t.colorType=="number"?t.colorType:Ot.COLORTYPE_COLOR_ALPHA,t.inputColorType=typeof t.inputColorType=="number"?t.inputColorType:Ot.COLORTYPE_COLOR_ALPHA,[Ot.COLORTYPE_GRAYSCALE,Ot.COLORTYPE_COLOR,Ot.COLORTYPE_COLOR_ALPHA,Ot.COLORTYPE_ALPHA].indexOf(t.colorType)===-1)throw new Error("option color type:"+t.colorType+" is not supported at present");if([Ot.COLORTYPE_GRAYSCALE,Ot.COLORTYPE_COLOR,Ot.COLORTYPE_COLOR_ALPHA,Ot.COLORTYPE_ALPHA].indexOf(t.inputColorType)===-1)throw new Error("option input color type:"+t.inputColorType+" is not supported at present");if(t.bitDepth!==8&&t.bitDepth!==16)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};Zt.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Zt.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Zt.prototype.filterData=function(t,e,r){let i=go(t,e,r,this._options),n=Ot.COLORTYPE_TO_BPP_MAP[this._options.colorType];return mo(i,e,r,this._options,n)};Zt.prototype._packChunk=function(t,e){let r=e?e.length:0,i=Buffer.alloc(r+12);return i.writeUInt32BE(r,0),i.writeUInt32BE(t,4),e&&e.copy(i,8),i.writeInt32BE(xo.crc32(i.slice(4,i.length-4)),i.length-4),i};Zt.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*Ot.GAMMA_DIVISION),0),this._packChunk(Ot.TYPE_gAMA,e)};Zt.prototype.packIHDR=function(t,e){let r=Buffer.alloc(13);return r.writeUInt32BE(t,0),r.writeUInt32BE(e,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(Ot.TYPE_IHDR,r)};Zt.prototype.packIDAT=function(t){return this._packChunk(Ot.TYPE_IDAT,t)};Zt.prototype.packIEND=function(){return this._packChunk(Ot.TYPE_IEND,null)}});var Tn=pt((Sh,bn)=>{"use strict";var _o=Rt("util"),En=Rt("stream"),wo=xe(),Eo=Or(),Cn=bn.exports=function(t){En.call(this);let e=t||{};this._packer=new Eo(e),this._deflate=this._packer.createDeflate(),this.readable=!0};_o.inherits(Cn,En);Cn.prototype.pack=function(t,e,r,i){this.emit("data",Buffer.from(wo.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,r)),i&&this.emit("data",this._packer.packGAMA(i));let n=this._packer.filterData(t,e,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(s){this.emit("data",this._packer.packIDAT(s))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(n)}});var Rn=pt((Se,kn)=>{"use strict";var yn=Rt("assert").ok,ge=Rt("zlib"),Co=Rt("util"),An=Rt("buffer").kMaxLength;function te(t){if(!(this instanceof te))return new te(t);t&&t.chunkSize<ge.Z_MIN_CHUNK&&(t.chunkSize=ge.Z_MIN_CHUNK),ge.Inflate.call(this,t),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&t.maxLength!=null&&(this._maxLength=t.maxLength)}function bo(t){return new te(t)}function Fn(t,e){e&&process.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}te.prototype._processChunk=function(t,e,r){if(typeof r=="function")return ge.Inflate._processChunk.call(this,t,e,r);let i=this,n=t&&t.length,s=this._chunkSize-this._offset,a=this._maxLength,o=0,h=[],l=0,p;this.on("error",function(m){p=m});function f(m,F){if(i._hadError)return;let w=s-F;if(yn(w>=0,"have should not go down"),w>0){let T=i._buffer.slice(i._offset,i._offset+w);if(i._offset+=w,T.length>a&&(T=T.slice(0,a)),h.push(T),l+=T.length,a-=T.length,a===0)return!1}return(F===0||i._offset>=i._chunkSize)&&(s=i._chunkSize,i._offset=0,i._buffer=Buffer.allocUnsafe(i._chunkSize)),F===0?(o+=n-m,n=m,!0):!1}yn(this._handle,"zlib binding closed");let d;do d=this._handle.writeSync(e,t,o,n,this._buffer,this._offset,s),d=d||this._writeState;while(!this._hadError&&f(d[0],d[1]));if(this._hadError)throw p;if(l>=An)throw Fn(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+An.toString(16)+" bytes");let C=Buffer.concat(h,l);return Fn(this),C};Co.inherits(te,ge.Inflate);function To(t,e){if(typeof e=="string"&&(e=Buffer.from(e)),!(e instanceof Buffer))throw new TypeError("Not a string or buffer");let r=t._finishFlushFlag;return r==null&&(r=ge.Z_FINISH),t._processChunk(e,r)}function Dn(t,e){return To(new te(e),t)}kn.exports=Se=Dn;Se.Inflate=te;Se.createInflate=bo;Se.inflateSync=Dn});var Nr=pt((Oh,On)=>{"use strict";var Sn=On.exports=function(t){this._buffer=t,this._reads=[]};Sn.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})};Sn.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let t=this._reads[0];if(this._buffer.length&&(this._buffer.length>=t.length||t.allowLess)){this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}else break}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}});var In=pt(Nn=>{"use strict";var yo=Nr(),Ao=Tr();Nn.process=function(t,e){let r=[],i=new yo(t);return new Ao(e,{read:i.read.bind(i),write:function(s){r.push(s)},complete:function(){}}).start(),i.process(),Buffer.concat(r)}});var Bn=pt((Ih,Pn)=>{"use strict";var Mn=!0,Ln=Rt("zlib"),Fo=Rn();Ln.deflateSync||(Mn=!1);var Do=Nr(),ko=In(),Ro=Dr(),So=kr(),Oo=Rr();Pn.exports=function(t,e){if(!Mn)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r;function i(y){r=y}let n;function s(y){n=y}function a(y){n.transColor=y}function o(y){n.palette=y}function h(){n.alpha=!0}let l;function p(y){l=y}let f=[];function d(y){f.push(y)}let C=new Do(t);if(new Ro(e,{read:C.read.bind(C),error:i,metadata:s,gamma:p,palette:o,transColor:a,inflateData:d,simpleTransparency:h}).start(),C.process(),r)throw r;let F=Buffer.concat(f);f.length=0;let w;if(n.interlace)w=Ln.inflateSync(F);else{let x=((n.width*n.bpp*n.depth+7>>3)+1)*n.height;w=Fo(F,{chunkSize:x,maxLength:x})}if(F=null,!w||!w.length)throw new Error("bad png - invalid inflate data response");let T=ko.process(w,n);F=null;let S=So.dataToBitMap(T,n);T=null;let g=Oo(S,n,e.skipRescale);return n.data=g,n.gamma=l||0,n}});var $n=pt((Mh,Xn)=>{"use strict";var Un=!0,Hn=Rt("zlib");Hn.deflateSync||(Un=!1);var No=xe(),Io=Or();Xn.exports=function(t,e){if(!Un)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=e||{},i=new Io(r),n=[];n.push(Buffer.from(No.PNG_SIGNATURE)),n.push(i.packIHDR(t.width,t.height)),t.gamma&&n.push(i.packGAMA(t.gamma));let s=i.filterData(t.data,t.width,t.height),a=Hn.deflateSync(s,i.getDeflateOptions());if(s=null,!a||!a.length)throw new Error("bad png - invalid compressed data response");return n.push(i.packIDAT(a)),n.push(i.packIEND()),Buffer.concat(n)}});var Yn=pt(Ir=>{"use strict";var Mo=Bn(),Lo=$n();Ir.read=function(t,e){return Mo(t,e||{})};Ir.write=function(t,e){return Lo(t,e)}});var Gn=pt(zn=>{"use strict";var Po=Rt("util"),qn=Rt("stream"),Bo=pn(),Uo=Tn(),Ho=Yn(),It=zn.PNG=function(t){qn.call(this),t=t||{},this.width=t.width|0,this.height=t.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new Bo(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(e){this.data=e,this.emit("parsed",e)}.bind(this)),this._packer=new Uo(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Po.inherits(It,qn);It.sync=Ho;It.prototype.pack=function(){return!this.data||!this.data.length?(this.emit("error","No data provided"),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)};It.prototype.parse=function(t,e){if(e){let r,i;r=function(n){this.removeListener("error",i),this.data=n,e(null,this)}.bind(this),i=function(n){this.removeListener("parsed",r),e(n,null)}.bind(this),this.once("parsed",r),this.once("error",i)}return this.end(t),this};It.prototype.write=function(t){return this._parser.write(t),!0};It.prototype.end=function(t){this._parser.end(t)};It.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)};It.prototype._gamma=function(t){this.gamma=t};It.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit("close")};It.bitblt=function(t,e,r,i,n,s,a,o){if(r|=0,i|=0,n|=0,s|=0,a|=0,o|=0,r>t.width||i>t.height||r+n>t.width||i+s>t.height)throw new Error("bitblt reading outside image");if(a>e.width||o>e.height||a+n>e.width||o+s>e.height)throw new Error("bitblt writing outside image");for(let h=0;h<s;h++)t.data.copy(e.data,(o+h)*e.width+a<<2,(i+h)*t.width+r<<2,(i+h)*t.width+r+n<<2)};It.prototype.bitblt=function(t,e,r,i,n,s,a){return It.bitblt(this,t,e,r,i,n,s,a),this};It.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let r=0;r<t.width;r++){let i=t.width*e+r<<2;for(let n=0;n<3;n++){let s=t.data[i+n]/255;s=Math.pow(s,1/2.2/t.gamma),t.data[i+n]=Math.round(s*255)}}t.gamma=0}};It.prototype.adjustGamma=function(){It.adjustGamma(this)}});var jn=pt((Bh,Ye)=>{"use strict";var Vn=Vn||function(t){return Buffer.from(t).toString("base64")};function Xo(t){var e=this,r=Math.round,i=Math.floor,n=new Array(64),s=new Array(64),a=new Array(64),o=new Array(64),h,l,p,f,d=new Array(65535),C=new Array(65535),m=new Array(64),F=new Array(64),w=[],T=0,S=7,g=new Array(64),y=new Array(64),x=new Array(64),z=new Array(256),_=new Array(2048),X,R=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],U=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],O=[0,1,2,3,4,5,6,7,8,9,10,11],nt=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],k=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],mt=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],M=[0,1,2,3,4,5,6,7,8,9,10,11],I=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],tt=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function st(c){for(var N=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],H=0;H<64;H++){var L=i((N[H]*c+50)/100);L<1?L=1:L>255&&(L=255),n[R[H]]=L}for(var W=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],j=0;j<64;j++){var at=i((W[j]*c+50)/100);at<1?at=1:at>255&&(at=255),s[R[j]]=at}for(var ot=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],bt=0,gt=0;gt<8;gt++)for(var v=0;v<8;v++)a[bt]=1/(n[R[bt]]*ot[gt]*ot[v]*8),o[bt]=1/(s[R[bt]]*ot[gt]*ot[v]*8),bt++}function P(c,N){for(var H=0,L=0,W=new Array,j=1;j<=16;j++){for(var at=1;at<=c[j];at++)W[N[L]]=[],W[N[L]][0]=H,W[N[L]][1]=j,L++,H++;H*=2}return W}function vt(){h=P(U,O),l=P(mt,M),p=P(nt,k),f=P(I,tt)}function rt(){for(var c=1,N=2,H=1;H<=15;H++){for(var L=c;L<N;L++)C[32767+L]=H,d[32767+L]=[],d[32767+L][1]=H,d[32767+L][0]=L;for(var W=-(N-1);W<=-c;W++)C[32767+W]=H,d[32767+W]=[],d[32767+W][1]=H,d[32767+W][0]=N-1+W;c<<=1,N<<=1}}function G(){for(var c=0;c<256;c++)_[c]=19595*c,_[c+256>>0]=38470*c,_[c+512>>0]=7471*c+32768,_[c+768>>0]=-11059*c,_[c+1024>>0]=-21709*c,_[c+1280>>0]=32768*c+8421375,_[c+1536>>0]=-27439*c,_[c+1792>>0]=-5329*c}function B(c){for(var N=c[0],H=c[1]-1;H>=0;)N&1<<H&&(T|=1<<S),H--,S--,S<0&&(T==255?(u(255),u(0)):u(T),S=7,T=0)}function u(c){w.push(c)}function D(c){u(c>>8&255),u(c&255)}function ht(c,N){var H,L,W,j,at,ot,bt,gt,v=0,A,q=8,Et=64;for(A=0;A<q;++A){H=c[v],L=c[v+1],W=c[v+2],j=c[v+3],at=c[v+4],ot=c[v+5],bt=c[v+6],gt=c[v+7];var Z=H+gt,it=H-gt,xt=L+bt,$=L-bt,ft=W+ot,Dt=W-ot,_t=j+at,Bt=j-at,qt=Z+_t,Qt=Z-_t,ee=xt+ft,re=xt-ft;c[v]=qt+ee,c[v+4]=qt-ee;var me=(re+Qt)*.707106781;c[v+2]=Qt+me,c[v+6]=Qt-me,qt=Bt+Dt,ee=Dt+$,re=$+it;var ve=(qt-re)*.382683433,Oe=.5411961*qt+ve,_e=1.306562965*re+ve,we=ee*.707106781,Ee=it+we,Ce=it-we;c[v+5]=Ce+Oe,c[v+3]=Ce-Oe,c[v+1]=Ee+_e,c[v+7]=Ee-_e,v+=8}for(v=0,A=0;A<q;++A){H=c[v],L=c[v+8],W=c[v+16],j=c[v+24],at=c[v+32],ot=c[v+40],bt=c[v+48],gt=c[v+56];var $r=H+gt,Ge=H-gt,Yr=L+bt,qr=L-bt,zr=W+ot,Gr=W-ot,Wr=j+at,ls=j-at,be=$r+Wr,We=$r-Wr,Ne=Yr+zr,Ie=Yr-zr;c[v]=be+Ne,c[v+32]=be-Ne;var Vr=(Ie+We)*.707106781;c[v+16]=We+Vr,c[v+48]=We-Vr,be=ls+Gr,Ne=Gr+qr,Ie=qr+Ge;var jr=(be-Ie)*.382683433,Zr=.5411961*be+jr,Qr=1.306562965*Ie+jr,Kr=Ne*.707106781,Jr=Ge+Kr,ti=Ge-Kr;c[v+40]=ti+Zr,c[v+24]=ti-Zr,c[v+8]=Jr+Qr,c[v+56]=Jr-Qr,v++}var Me;for(A=0;A<Et;++A)Me=c[A]*N[A],m[A]=Me>0?Me+.5|0:Me-.5|0;return m}function lt(){D(65504),D(16),u(74),u(70),u(73),u(70),u(0),u(1),u(1),u(0),D(1),D(1),u(0),u(0)}function Q(c){if(c){D(65505),c[0]===69&&c[1]===120&&c[2]===105&&c[3]===102?D(c.length+2):(D(c.length+5+2),u(69),u(120),u(105),u(102),u(0));for(var N=0;N<c.length;N++)u(c[N])}}function K(c,N){D(65472),D(17),u(8),D(N),D(c),u(3),u(1),u(17),u(0),u(2),u(17),u(1),u(3),u(17),u(1)}function V(){D(65499),D(132),u(0);for(var c=0;c<64;c++)u(n[c]);u(1);for(var N=0;N<64;N++)u(s[N])}function b(){D(65476),D(418),u(0);for(var c=0;c<16;c++)u(U[c+1]);for(var N=0;N<=11;N++)u(O[N]);u(16);for(var H=0;H<16;H++)u(nt[H+1]);for(var L=0;L<=161;L++)u(k[L]);u(1);for(var W=0;W<16;W++)u(mt[W+1]);for(var j=0;j<=11;j++)u(M[j]);u(17);for(var at=0;at<16;at++)u(I[at+1]);for(var ot=0;ot<=161;ot++)u(tt[ot])}function E(c){typeof c>"u"||c.constructor!==Array||c.forEach(N=>{if(typeof N=="string"){D(65534);var H=N.length;D(H+2);var L;for(L=0;L<H;L++)u(N.charCodeAt(L))}})}function dt(){D(65498),D(12),u(3),u(1),u(0),u(2),u(17),u(3),u(17),u(0),u(63),u(0)}function Y(c,N,H,L,W){for(var j=W[0],at=W[240],ot,bt=16,gt=63,v=64,A=ht(c,N),q=0;q<v;++q)F[R[q]]=A[q];var Et=F[0]-H;H=F[0],Et==0?B(L[0]):(ot=32767+Et,B(L[C[ot]]),B(d[ot]));for(var Z=63;Z>0&&F[Z]==0;Z--);if(Z==0)return B(j),H;for(var it=1,xt;it<=Z;){for(var $=it;F[it]==0&&it<=Z;++it);var ft=it-$;if(ft>=bt){xt=ft>>4;for(var Dt=1;Dt<=xt;++Dt)B(at);ft=ft&15}ot=32767+F[it],B(W[(ft<<4)+C[ot]]),B(d[ot]),it++}return Z!=gt&&B(j),H}function J(){for(var c=String.fromCharCode,N=0;N<256;N++)z[N]=c(N)}this.encode=function(c,N){var H=new Date().getTime();N&&Pt(N),w=new Array,T=0,S=7,D(65496),lt(),E(c.comments),Q(c.exifBuffer),V(),K(c.width,c.height),b(),dt();var L=0,W=0,j=0;T=0,S=7,this.encode.displayName="_encode_";for(var at=c.data,ot=c.width,bt=c.height,gt=ot*4,v=ot*3,A,q=0,Et,Z,it,xt,$,ft,Dt,_t;q<bt;){for(A=0;A<gt;){for(xt=gt*q+A,$=xt,ft=-1,Dt=0,_t=0;_t<64;_t++)Dt=_t>>3,ft=(_t&7)*4,$=xt+Dt*gt+ft,q+Dt>=bt&&($-=gt*(q+1+Dt-bt)),A+ft>=gt&&($-=A+ft-gt+4),Et=at[$++],Z=at[$++],it=at[$++],g[_t]=(_[Et]+_[Z+256>>0]+_[it+512>>0]>>16)-128,y[_t]=(_[Et+768>>0]+_[Z+1024>>0]+_[it+1280>>0]>>16)-128,x[_t]=(_[Et+1280>>0]+_[Z+1536>>0]+_[it+1792>>0]>>16)-128;L=Y(g,a,L,h,p),W=Y(y,o,W,l,f),j=Y(x,o,j,l,f),A+=32}q+=8}if(S>=0){var Bt=[];Bt[1]=S+1,Bt[0]=(1<<S+1)-1,B(Bt)}if(D(65497),typeof Ye>"u")return new Uint8Array(w);return Buffer.from(w);var qt,Qt};function Pt(c){if(c<=0&&(c=1),c>100&&(c=100),X!=c){var N=0;c<50?N=Math.floor(5e3/c):N=Math.floor(200-c*2),st(N),X=c}}function Ht(){var c=new Date().getTime();t||(t=50),J(),vt(),rt(),G(),Pt(t);var N=new Date().getTime()-c}Ht()}typeof Ye<"u"?Ye.exports=Wn:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=Wn);function Wn(t,e){typeof e>"u"&&(e=50);var r=new Xo(e),i=r.encode(t,e);return{data:i,width:t.width,height:t.height}}});var Qn=pt((Uh,Lr)=>{"use strict";var Mr=(function(){"use strict";var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,i=799,n=3406,s=2276,a=1567,o=3784,h=5793,l=2896;function p(){}function f(S,g){for(var y=0,x=[],z,_,X=16;X>0&&!S[X-1];)X--;x.push({children:[],index:0});var R=x[0],U;for(z=0;z<X;z++){for(_=0;_<S[z];_++){for(R=x.pop(),R.children[R.index]=g[y];R.index>0;){if(x.length===0)throw new Error("Could not recreate Huffman Table");R=x.pop()}for(R.index++,x.push(R);x.length<=z;)x.push(U={children:[],index:0}),R.children[R.index]=U.children,R=U;y++}z+1<X&&(x.push(U={children:[],index:0}),R.children[R.index]=U.children,R=U)}return x[0].children}function d(S,g,y,x,z,_,X,R,U,O){var nt=y.precision,k=y.samplesPerLine,mt=y.scanLines,M=y.mcusPerLine,I=y.progressive,tt=y.maxH,st=y.maxV,P=g,vt=0,rt=0;function G(){if(rt>0)return rt--,vt>>rt&1;if(vt=S[g++],vt==255){var v=S[g++];if(v)throw new Error("unexpected marker: "+(vt<<8|v).toString(16))}return rt=7,vt>>>7}function B(v){for(var A=v,q;(q=G())!==null;){if(A=A[q],typeof A=="number")return A;if(typeof A!="object")throw new Error("invalid huffman sequence")}return null}function u(v){for(var A=0;v>0;){var q=G();if(q===null)return;A=A<<1|q,v--}return A}function D(v){var A=u(v);return A>=1<<v-1?A:A+(-1<<v)+1}function ht(v,A){var q=B(v.huffmanTableDC),Et=q===0?0:D(q);A[0]=v.pred+=Et;for(var Z=1;Z<64;){var it=B(v.huffmanTableAC),xt=it&15,$=it>>4;if(xt===0){if($<15)break;Z+=16;continue}Z+=$;var ft=e[Z];A[ft]=D(xt),Z++}}function lt(v,A){var q=B(v.huffmanTableDC),Et=q===0?0:D(q)<<U;A[0]=v.pred+=Et}function Q(v,A){A[0]|=G()<<U}var K=0;function V(v,A){if(K>0){K--;return}for(var q=_,Et=X;q<=Et;){var Z=B(v.huffmanTableAC),it=Z&15,xt=Z>>4;if(it===0){if(xt<15){K=u(xt)+(1<<xt)-1;break}q+=16;continue}q+=xt;var $=e[q];A[$]=D(it)*(1<<U),q++}}var b=0,E;function dt(v,A){for(var q=_,Et=X,Z=0;q<=Et;){var it=e[q],xt=A[it]<0?-1:1;switch(b){case 0:var $=B(v.huffmanTableAC),ft=$&15,Z=$>>4;if(ft===0)Z<15?(K=u(Z)+(1<<Z),b=4):(Z=16,b=1);else{if(ft!==1)throw new Error("invalid ACn encoding");E=D(ft),b=Z?2:3}continue;case 1:case 2:A[it]?A[it]+=(G()<<U)*xt:(Z--,Z===0&&(b=b==2?3:0));break;case 3:A[it]?A[it]+=(G()<<U)*xt:(A[it]=E<<U,b=0);break;case 4:A[it]&&(A[it]+=(G()<<U)*xt);break}q++}b===4&&(K--,K===0&&(b=0))}function Y(v,A,q,Et,Z){var it=q/M|0,xt=q%M,$=it*v.v+Et,ft=xt*v.h+Z;v.blocks[$]===void 0&&O.tolerantDecoding||A(v,v.blocks[$][ft])}function J(v,A,q){var Et=q/v.blocksPerLine|0,Z=q%v.blocksPerLine;v.blocks[Et]===void 0&&O.tolerantDecoding||A(v,v.blocks[Et][Z])}var Pt=x.length,Ht,c,N,H,L,W;I?_===0?W=R===0?lt:Q:W=R===0?V:dt:W=ht;var j=0,at,ot;Pt==1?ot=x[0].blocksPerLine*x[0].blocksPerColumn:ot=M*y.mcusPerColumn,z||(z=ot);for(var bt,gt;j<ot;){for(c=0;c<Pt;c++)x[c].pred=0;if(K=0,Pt==1)for(Ht=x[0],L=0;L<z;L++)J(Ht,W,j),j++;else for(L=0;L<z;L++){for(c=0;c<Pt;c++)for(Ht=x[c],bt=Ht.h,gt=Ht.v,N=0;N<gt;N++)for(H=0;H<bt;H++)Y(Ht,W,j,N,H);if(j++,j===ot)break}if(j===ot)do{if(S[g]===255&&S[g+1]!==0)break;g+=1}while(g<S.length-2);if(rt=0,at=S[g]<<8|S[g+1],at<65280)throw new Error("marker was not found");if(at>=65488&&at<=65495)g+=2;else break}return g-P}function C(S,g){var y=[],x=g.blocksPerLine,z=g.blocksPerColumn,_=x<<3,X=new Int32Array(64),R=new Uint8Array(64);function U(P,vt,rt){var G=g.quantizationTable,B,u,D,ht,lt,Q,K,V,b,E=rt,dt;for(dt=0;dt<64;dt++)E[dt]=P[dt]*G[dt];for(dt=0;dt<8;++dt){var Y=8*dt;if(E[1+Y]==0&&E[2+Y]==0&&E[3+Y]==0&&E[4+Y]==0&&E[5+Y]==0&&E[6+Y]==0&&E[7+Y]==0){b=h*E[0+Y]+512>>10,E[0+Y]=b,E[1+Y]=b,E[2+Y]=b,E[3+Y]=b,E[4+Y]=b,E[5+Y]=b,E[6+Y]=b,E[7+Y]=b;continue}B=h*E[0+Y]+128>>8,u=h*E[4+Y]+128>>8,D=E[2+Y],ht=E[6+Y],lt=l*(E[1+Y]-E[7+Y])+128>>8,V=l*(E[1+Y]+E[7+Y])+128>>8,Q=E[3+Y]<<4,K=E[5+Y]<<4,b=B-u+1>>1,B=B+u+1>>1,u=b,b=D*o+ht*a+128>>8,D=D*a-ht*o+128>>8,ht=b,b=lt-K+1>>1,lt=lt+K+1>>1,K=b,b=V+Q+1>>1,Q=V-Q+1>>1,V=b,b=B-ht+1>>1,B=B+ht+1>>1,ht=b,b=u-D+1>>1,u=u+D+1>>1,D=b,b=lt*s+V*n+2048>>12,lt=lt*n-V*s+2048>>12,V=b,b=Q*i+K*r+2048>>12,Q=Q*r-K*i+2048>>12,K=b,E[0+Y]=B+V,E[7+Y]=B-V,E[1+Y]=u+K,E[6+Y]=u-K,E[2+Y]=D+Q,E[5+Y]=D-Q,E[3+Y]=ht+lt,E[4+Y]=ht-lt}for(dt=0;dt<8;++dt){var J=dt;if(E[8+J]==0&&E[16+J]==0&&E[24+J]==0&&E[32+J]==0&&E[40+J]==0&&E[48+J]==0&&E[56+J]==0){b=h*rt[dt+0]+8192>>14,E[0+J]=b,E[8+J]=b,E[16+J]=b,E[24+J]=b,E[32+J]=b,E[40+J]=b,E[48+J]=b,E[56+J]=b;continue}B=h*E[0+J]+2048>>12,u=h*E[32+J]+2048>>12,D=E[16+J],ht=E[48+J],lt=l*(E[8+J]-E[56+J])+2048>>12,V=l*(E[8+J]+E[56+J])+2048>>12,Q=E[24+J],K=E[40+J],b=B-u+1>>1,B=B+u+1>>1,u=b,b=D*o+ht*a+2048>>12,D=D*a-ht*o+2048>>12,ht=b,b=lt-K+1>>1,lt=lt+K+1>>1,K=b,b=V+Q+1>>1,Q=V-Q+1>>1,V=b,b=B-ht+1>>1,B=B+ht+1>>1,ht=b,b=u-D+1>>1,u=u+D+1>>1,D=b,b=lt*s+V*n+2048>>12,lt=lt*n-V*s+2048>>12,V=b,b=Q*i+K*r+2048>>12,Q=Q*r-K*i+2048>>12,K=b,E[0+J]=B+V,E[56+J]=B-V,E[8+J]=u+K,E[48+J]=u-K,E[16+J]=D+Q,E[40+J]=D-Q,E[24+J]=ht+lt,E[32+J]=ht-lt}for(dt=0;dt<64;++dt){var Pt=128+(E[dt]+8>>4);vt[dt]=Pt<0?0:Pt>255?255:Pt}}T(_*z*8);for(var O,nt,k=0;k<z;k++){var mt=k<<3;for(O=0;O<8;O++)y.push(new Uint8Array(_));for(var M=0;M<x;M++){U(g.blocks[k][M],R,X);var I=0,tt=M<<3;for(nt=0;nt<8;nt++){var st=y[mt+nt];for(O=0;O<8;O++)st[tt+O]=R[I++]}}}return y}function m(S){return S<0?0:S>255?255:S}p.prototype={load:function(g){var y=new XMLHttpRequest;y.open("GET",g,!0),y.responseType="arraybuffer",y.onload=(function(){var x=new Uint8Array(y.response||y.mozResponseArrayBuffer);this.parse(x),this.onload&&this.onload()}).bind(this),y.send(null)},parse:function(g){var y=this.opts.maxResolutionInMP*1e3*1e3,x=0,z=g.length;function _(){var $=g[x]<<8|g[x+1];return x+=2,$}function X(){var $=_(),ft=g.subarray(x,x+$-2);return x+=ft.length,ft}function R($){var ft=1,Dt=1,_t,Bt;for(Bt in $.components)$.components.hasOwnProperty(Bt)&&(_t=$.components[Bt],ft<_t.h&&(ft=_t.h),Dt<_t.v&&(Dt=_t.v));var qt=Math.ceil($.samplesPerLine/8/ft),Qt=Math.ceil($.scanLines/8/Dt);for(Bt in $.components)if($.components.hasOwnProperty(Bt)){_t=$.components[Bt];var ee=Math.ceil(Math.ceil($.samplesPerLine/8)*_t.h/ft),re=Math.ceil(Math.ceil($.scanLines/8)*_t.v/Dt),me=qt*_t.h,ve=Qt*_t.v,Oe=ve*me,_e=[];T(Oe*256);for(var we=0;we<ve;we++){for(var Ee=[],Ce=0;Ce<me;Ce++)Ee.push(new Int32Array(64));_e.push(Ee)}_t.blocksPerLine=ee,_t.blocksPerColumn=re,_t.blocks=_e}$.maxH=ft,$.maxV=Dt,$.mcusPerLine=qt,$.mcusPerColumn=Qt}var U=null,O=null,nt=null,k,mt,M=[],I=[],tt=[],st=[],P=_(),vt=-1;if(this.comments=[],P!=65496)throw new Error("SOI not found");for(P=_();P!=65497;){var rt,G,B;switch(P){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var u=X();if(P===65534){var D=String.fromCharCode.apply(null,u);this.comments.push(D)}P===65504&&u[0]===74&&u[1]===70&&u[2]===73&&u[3]===70&&u[4]===0&&(U={version:{major:u[5],minor:u[6]},densityUnits:u[7],xDensity:u[8]<<8|u[9],yDensity:u[10]<<8|u[11],thumbWidth:u[12],thumbHeight:u[13],thumbData:u.subarray(14,14+3*u[12]*u[13])}),P===65505&&u[0]===69&&u[1]===120&&u[2]===105&&u[3]===102&&u[4]===0&&(this.exifBuffer=u.subarray(5,u.length)),P===65518&&u[0]===65&&u[1]===100&&u[2]===111&&u[3]===98&&u[4]===101&&u[5]===0&&(O={version:u[6],flags0:u[7]<<8|u[8],flags1:u[9]<<8|u[10],transformCode:u[11]});break;case 65499:for(var ht=_(),lt=ht+x-2;x<lt;){var Q=g[x++];T(256);var K=new Int32Array(64);if(Q>>4===0)for(G=0;G<64;G++){var V=e[G];K[V]=g[x++]}else if(Q>>4===1)for(G=0;G<64;G++){var V=e[G];K[V]=_()}else throw new Error("DQT: invalid table spec");M[Q&15]=K}break;case 65472:case 65473:case 65474:_(),k={},k.extended=P===65473,k.progressive=P===65474,k.precision=g[x++],k.scanLines=_(),k.samplesPerLine=_(),k.components={},k.componentsOrder=[];var b=k.scanLines*k.samplesPerLine;if(b>y){var E=Math.ceil((b-y)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${E}MP`)}var dt=g[x++],Y,J=0,Pt=0;for(rt=0;rt<dt;rt++){Y=g[x];var Ht=g[x+1]>>4,c=g[x+1]&15,N=g[x+2];if(Ht<=0||c<=0)throw new Error("Invalid sampling factor, expected values above 0");k.componentsOrder.push(Y),k.components[Y]={h:Ht,v:c,quantizationIdx:N},x+=3}R(k),I.push(k);break;case 65476:var H=_();for(rt=2;rt<H;){var L=g[x++],W=new Uint8Array(16),j=0;for(G=0;G<16;G++,x++)j+=W[G]=g[x];T(16+j);var at=new Uint8Array(j);for(G=0;G<j;G++,x++)at[G]=g[x];rt+=17+j,(L>>4===0?st:tt)[L&15]=f(W,at)}break;case 65501:_(),mt=_();break;case 65500:_(),_();break;case 65498:var ot=_(),bt=g[x++],gt=[],v;for(rt=0;rt<bt;rt++){v=k.components[g[x++]];var A=g[x++];v.huffmanTableDC=st[A>>4],v.huffmanTableAC=tt[A&15],gt.push(v)}var q=g[x++],Et=g[x++],Z=g[x++],it=d(g,x,k,gt,mt,q,Et,Z>>4,Z&15,this.opts);x+=it;break;case 65535:g[x]!==255&&x--;break;default:if(g[x-3]==255&&g[x-2]>=192&&g[x-2]<=254){x-=3;break}else if(P===224||P==225){if(vt!==-1)throw new Error(`first unknown JPEG marker at offset ${vt.toString(16)}, second unknown JPEG marker ${P.toString(16)} at offset ${(x-1).toString(16)}`);vt=x-1;let $=_();if(g[x+$-2]===255){x+=$-2;break}}throw new Error("unknown JPEG marker "+P.toString(16))}P=_()}if(I.length!=1)throw new Error("only single frame JPEGs supported");for(var rt=0;rt<I.length;rt++){var xt=I[rt].components;for(var G in xt)xt[G].quantizationTable=M[xt[G].quantizationIdx],delete xt[G].quantizationIdx}this.width=k.samplesPerLine,this.height=k.scanLines,this.jfif=U,this.adobe=O,this.components=[];for(var rt=0;rt<k.componentsOrder.length;rt++){var v=k.components[k.componentsOrder[rt]];this.components.push({lines:C(k,v),scaleX:v.h/k.maxH,scaleY:v.v/k.maxV})}},getData:function(g,y){var x=this.width/g,z=this.height/y,_,X,R,U,O,nt,k,mt,M,I,tt=0,st,P,vt,rt,G,B,u,D,ht,lt,Q,K=g*y*this.components.length;T(K);var V=new Uint8Array(K);switch(this.components.length){case 1:for(_=this.components[0],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],M=0;M<g;M++)st=O[0|M*_.scaleX*x],V[tt++]=st;break;case 2:for(_=this.components[0],X=this.components[1],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],M=0;M<g;M++)st=O[0|M*_.scaleX*x],V[tt++]=st,st=nt[0|M*X.scaleX*x],V[tt++]=st;break;case 3:for(Q=!0,this.adobe&&this.adobe.transformCode?Q=!0:typeof this.opts.colorTransform<"u"&&(Q=!!this.opts.colorTransform),_=this.components[0],X=this.components[1],R=this.components[2],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],k=R.lines[0|I*R.scaleY*z],M=0;M<g;M++)Q?(st=O[0|M*_.scaleX*x],P=nt[0|M*X.scaleX*x],vt=k[0|M*R.scaleX*x],D=m(st+1.402*(vt-128)),ht=m(st-.3441363*(P-128)-.71413636*(vt-128)),lt=m(st+1.772*(P-128))):(D=O[0|M*_.scaleX*x],ht=nt[0|M*X.scaleX*x],lt=k[0|M*R.scaleX*x]),V[tt++]=D,V[tt++]=ht,V[tt++]=lt;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(Q=!1,this.adobe&&this.adobe.transformCode?Q=!0:typeof this.opts.colorTransform<"u"&&(Q=!!this.opts.colorTransform),_=this.components[0],X=this.components[1],R=this.components[2],U=this.components[3],I=0;I<y;I++)for(O=_.lines[0|I*_.scaleY*z],nt=X.lines[0|I*X.scaleY*z],k=R.lines[0|I*R.scaleY*z],mt=U.lines[0|I*U.scaleY*z],M=0;M<g;M++)Q?(st=O[0|M*_.scaleX*x],P=nt[0|M*X.scaleX*x],vt=k[0|M*R.scaleX*x],rt=mt[0|M*U.scaleX*x],G=255-m(st+1.402*(vt-128)),B=255-m(st-.3441363*(P-128)-.71413636*(vt-128)),u=255-m(st+1.772*(P-128))):(G=O[0|M*_.scaleX*x],B=nt[0|M*X.scaleX*x],u=k[0|M*R.scaleX*x],rt=mt[0|M*U.scaleX*x]),V[tt++]=255-G,V[tt++]=255-B,V[tt++]=255-u,V[tt++]=255-rt;break;default:throw new Error("Unsupported color mode")}return V},copyToImageData:function(g,y){var x=g.width,z=g.height,_=g.data,X=this.getData(x,z),R=0,U=0,O,nt,k,mt,M,I,tt,st,P;switch(this.components.length){case 1:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)k=X[R++],_[U++]=k,_[U++]=k,_[U++]=k,y&&(_[U++]=255);break;case 3:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)tt=X[R++],st=X[R++],P=X[R++],_[U++]=tt,_[U++]=st,_[U++]=P,y&&(_[U++]=255);break;case 4:for(nt=0;nt<z;nt++)for(O=0;O<x;O++)M=X[R++],I=X[R++],k=X[R++],mt=X[R++],tt=255-m(M*(1-mt/255)+mt),st=255-m(I*(1-mt/255)+mt),P=255-m(k*(1-mt/255)+mt),_[U++]=tt,_[U++]=st,_[U++]=P,y&&(_[U++]=255);break;default:throw new Error("Unsupported color mode")}}};var F=0,w=0;function T(S=0){var g=F+S;if(g>w){var y=Math.ceil((g-w)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${y}MB`)}F=g}return p.resetMaxMemoryUsage=function(S){F=0,w=S},p.getBytesAllocated=function(){return F},p.requestMemoryAllocation=T,p})();typeof Lr<"u"?Lr.exports=Zn:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=Zn);function Zn(t,e={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},i={...r,...e},n=new Uint8Array(t),s=new Mr;s.opts=i,Mr.resetMaxMemoryUsage(i.maxMemoryUsageInMB*1024*1024),s.parse(n);var a=i.formatAsRGBA?4:3,o=s.width*s.height*a;try{Mr.requestMemoryAllocation(o);var h={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:i.useTArray?new Uint8Array(o):Buffer.alloc(o)};s.comments.length>0&&(h.comments=s.comments)}catch(l){throw l instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+o):l instanceof ReferenceError&&l.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):l}return s.copyToImageData(h,i.formatAsRGBA),h}});var Jn=pt((Hh,Kn)=>{"use strict";var $o=jn(),Yo=Qn();Kn.exports={encode:$o,decode:Yo}});import{createRequire as fs}from"module";var us=fs("/"),ae,cs,ds;try{ae=us("worker_threads"),cs=ae.Worker,ds=ae.isMarkedAsUntransferable}catch{}var St=Uint8Array,ie=Uint16Array,ps=Int32Array,ni=new St([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),si=new St([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xs=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ai=function(t,e){for(var r=new ie(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];for(var n=new ps(r[30]),i=1;i<30;++i)for(var s=r[i];s<r[i+1];++s)n[s]=s-r[i]<<5|i;return{b:r,r:n}},ae=ai(ni,2),oi=ae.b,gs=ae.r;oi[28]=258,gs[258]=28;var hi=ai(si,0),ms=hi.b,hh=hi.r,Qe=new ie(32768);for(ut=0;ut<32768;++ut)Wt=(ut&43690)>>1|(ut&21845)<<1,Wt=(Wt&52428)>>2|(Wt&13107)<<2,Wt=(Wt&61680)>>4|(Wt&3855)<<4,Qe[ut]=((Wt&65280)>>8|(Wt&255)<<8)>>1;var Wt,ut,ye=(function(t,e,r){for(var i=t.length,n=0,s=new ie(e);n<i;++n)t[n]&&++s[t[n]-1];var a=new ie(e);for(n=1;n<e;++n)a[n]=a[n-1]+s[n-1]<<1;var o;if(r){o=new ie(1<<e);var h=15-e;for(n=0;n<i;++n)if(t[n])for(var l=n<<4|t[n],p=e-t[n],f=a[t[n]-1]++<<p,d=f|(1<<p)-1;f<=d;++f)o[Qe[f]>>h]=l}else for(o=new ie(i),n=0;n<i;++n)t[n]&&(o[n]=Qe[a[t[n]-1]++]>>15-t[n]);return o}),Fe=new St(288);for(ut=0;ut<144;++ut)Fe[ut]=8;var ut;for(ut=144;ut<256;++ut)Fe[ut]=9;var ut;for(ut=256;ut<280;++ut)Fe[ut]=7;var ut;for(ut=280;ut<288;++ut)Fe[ut]=8;var ut,li=new St(32);for(ut=0;ut<32;++ut)li[ut]=5;var ut;var vs=ye(Fe,9,1);var _s=ye(li,5,1),Ve=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},Xt=function(t,e,r){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(e&7)&r},je=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},ws=function(t){return(t+7)/8|0},Ae=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new St(t.subarray(e,r))};var Es=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],At=function(t,e,r){var i=new Error(e||Es[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,At),!r)throw i;return i},Cs=function(t,e,r,i){var n=t.length,s=i?i.length:0;if(!n||e.f&&!e.l)return r||new St(0);var a=!r,o=a||e.i!=2,h=e.i;a&&(r=new St(n*3));var l=function(b){var E=r.length;if(b>E){var dt=new St(Math.max(E*2,b));dt.set(r),r=dt}},p=e.f||0,f=e.p||0,d=e.b||0,C=e.l,m=e.d,F=e.m,w=e.n,T=n*8;do{if(!C){p=Xt(t,f,1);var S=Xt(t,f+1,3);if(f+=3,S)if(S==1)C=vs,m=_s,F=9,w=5;else if(S==2){var z=Xt(t,f,31)+257,_=Xt(t,f+10,15)+4,X=z+Xt(t,f+5,31)+1;f+=14;for(var R=new St(X),U=new St(19),O=0;O<_;++O)U[xs[O]]=Xt(t,f+O*3,7);f+=_*3;for(var nt=Ve(U),k=(1<<nt)-1,mt=ye(U,nt,1),O=0;O<X;){var M=mt[Xt(t,f,k)];f+=M&15;var g=M>>4;if(g<16)R[O++]=g;else{var I=0,tt=0;for(g==16?(tt=3+Xt(t,f,3),f+=2,I=R[O-1]):g==17?(tt=3+Xt(t,f,7),f+=3):g==18&&(tt=11+Xt(t,f,127),f+=7);tt--;)R[O++]=I}}var st=R.subarray(0,z),P=R.subarray(z);F=Ve(st),w=Ve(P),C=ye(st,F,1),m=ye(P,w,1)}else At(1);else{var g=ws(f)+4,y=t[g-4]|t[g-3]<<8,x=g+y;if(x>n){h&&At(0);break}o&&l(d+y),r.set(t.subarray(g,x),d),e.b=d+=y,e.p=f=x*8,e.f=p;continue}if(f>T){h&&At(0);break}}o&&l(d+131072);for(var vt=(1<<F)-1,rt=(1<<w)-1,G=f;;G=f){var I=C[je(t,f)&vt],B=I>>4;if(f+=I&15,f>T){h&&At(0);break}if(I||At(2),B<256)r[d++]=B;else if(B==256){G=f,C=null;break}else{var u=B-254;if(B>264){var O=B-257,D=ni[O];u=Xt(t,f,(1<<D)-1)+oi[O],f+=D}var ht=m[je(t,f)&rt],lt=ht>>4;ht||At(3),f+=ht&15;var P=ms[lt];if(lt>3){var D=si[lt];P+=je(t,f)&(1<<D)-1,f+=D}if(f>T){h&&At(0);break}o&&l(d+131072);var Q=d+u;if(d<P){var K=s-P,V=Math.min(P,Q);for(K+d<0&&At(3);d<V;++d)r[d]=i[K+d]}for(;d<Q;++d)r[d]=r[d-P]}}e.l=C,e.p=G,e.b=d,e.f=p,C&&(p=1,e.m=F,e.d=m,e.n=w)}while(!p);return d!=r.length&&a?Ae(r,0,d):r.subarray(0,d)};var Te=new St(0);var ne=function(t,e){return t[e]|t[e+1]<<8},se=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},Ze=function(t,e){return se(t,e)+se(t,e+4)*4294967296};var bs=(function(){function t(e,r){typeof e=="function"&&(r=e,e={}),this.ondata=r;var i=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:i?i.length:0},this.o=new St(32768),this.p=new St(0),i&&this.o.set(i)}return t.prototype.e=function(e){if(this.ondata||At(5),this.d&&At(4),!this.p.length)this.p=e;else if(e.length){var r=new St(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length),this.p=r}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var r=this.s.b,i=Cs(this.p,this.s,this.o);this.ondata(Ae(i,r,this.s.b),this.d),this.o=Ae(i,this.s.b-32768),this.s.b=this.o.length,this.p=Ae(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,r){this.e(e),this.c(r)},t})();var Ke=typeof TextDecoder<"u"&&new TextDecoder,Ts=0;try{Ke.decode(Te,{stream:!0}),Ts=1}catch{}var ys=function(t){for(var e="",r=0;;){var i=t[r++],n=(i>127)+(i>223)+(i>239);if(r+n>t.length)return{s:e,r:Ae(t,r-1)};n?n==3?(i=((i&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|i>>10,56320|i&1023)):n&1?e+=String.fromCharCode((i&31)<<6|t[r++]&63):e+=String.fromCharCode((i&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(i)}};function As(t,e){if(e){for(var r="",i=0;i<t.length;i+=16384)r+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return r}else{if(Ke)return Ke.decode(t);var n=ys(t),s=n.s,r=n.r;return r.length&&At(8),s}}var Fs=function(t,e,r,i,n,s,a){var o=n==4294967295,h=s==4294967295,l=a==4294967295,p=e+r,f=o+h+l;if(i&&f){for(;e+4<p;e+=4+ne(t,e+2))if(ne(t,e)==1)return[o?Ze(t,e+4+8*h):n,h?Ze(t,e+4):s,l?Ze(t,e+4+8*(h+o)):a,1];i<2&&At(13)}return[n,s,a,0]};var Je=(function(){function t(){}return t.prototype.push=function(e,r){this.ondata(null,e,r)},t.compression=0,t})();var fi=(function(){function t(){var e=this;this.i=new bs(function(r,i){e.ondata(null,r,i)})}return t.prototype.push=function(e,r){try{this.i.push(e,r)}catch(i){this.ondata(i,null,r)}},t.compression=8,t})();var ui=(function(){function t(e){this.onfile=e,this.k=[],this.o={0:Je},this.p=Te}return t.prototype.push=function(e,r){var i=this;if(this.onfile||At(5),this.p||At(4),this.c>0){var n=Math.min(this.c,e.length),s=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(n),e.length)return this.push(e,r)}else{var a=0,o=0,h=void 0,l=void 0;this.p.length?e.length?(l=new St(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var p=l.length,f=this.c,d=f&&this.d,C=function(){var T=se(l,o);if(T==67324752){a=1,h=o,m.d=null,m.c=0;var S=ne(l,o+6),g=ne(l,o+8),y=S&2048,x=S&8,z=ne(l,o+26),_=ne(l,o+28);if(p>o+30+z+_){var X=[];m.k.unshift(X),a=2;var R=se(l,o+18),U=se(l,o+22),O=As(l.subarray(o+30,o+=30+z),!y),nt=Fs(l,o,_,2,R,U,0),k=nt[0],mt=nt[1],M=nt[3];x&&(k=-1-M),o+=_,m.c=k;var I,tt={name:O,compression:g,start:function(){if(tt.ondata||At(5),!k)tt.ondata(null,Te,!0);else{var st=i.o[g];st||tt.ondata(At(14,"unknown compression type "+g,1),null,!1),I=k<0?new st(O):new st(O,k,mt),I.ondata=function(G,B,u){tt.ondata(G,B,u)};for(var P=0,vt=X;P<vt.length;P++){var rt=vt[P];I.push(rt,!1)}i.k[0]==X&&i.c?i.d=I:I.push(Te,!0)}},terminate:function(){I&&I.terminate&&I.terminate()}};k>=0&&(tt.size=k,tt.originalSize=mt),m.onfile(tt)}return"break"}else if(f){if(T==134695760)return h=o+=12+(f==-2&&8),a=3,m.c=0,"break";if(T==33639248)return h=o-=4,a=3,m.c=0,"break"}},m=this;o<p-4;++o){var F=C();if(F==="break")break}if(this.p=Te,f<0){var w=a?l.subarray(0,h-12-(f==-2&&8)-(se(l,h-16)==134695760&&4)):l.subarray(0,o);d?d.push(w,!!a):this.k[+(a==2)].push(w)}if(a&2)return this.push(l.subarray(o),r);this.p=l.subarray(o)}r&&(this.c&&At(13),this.p=null)},t.prototype.register=function(e){this.o[e.compression]=e},t})();var Yi=Le(vr(),1);var Ta=1e4,ya=5e7,Aa=25e7,qi=5e6,zi=256,Gi=65536,_r=256,Wi=3e4,et=class extends Error{constructor(r,i){super(`${r}: ${i}`);this.code=r}},Fa="http://schemas.openxmlformats.org/package/2006/relationships",Da="http://schemas.openxmlformats.org/package/2006/content-types",ka=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument","http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument"]),Ra=["application/vnd.openxmlformats-officedocument.wordprocessingml.document.main","application/vnd.ms-word.document.main"];function Vi(t){return t.length===0?"empty name":t.includes("\\")?"backslash":t.includes("\0")?"NUL byte":t.startsWith("/")?"absolute path":/^[a-zA-Z]:/.test(t)?"drive letter":t.split("/").some(e=>e==="..")?"dot-dot segment":null}function Sa(t,e){let r=Math.max(0,t.length-65557),i=-1;for(let l=t.length-22;l>=r;l--)if(t.readUInt32LE(l)===101010256){i=l;break}if(i<0)throw new et("DOCX_UNREADABLE","not a zip archive (no end-of-central-directory)");let n=t.readUInt16LE(i+10);if(n>e)throw new et("DOCX_TOO_MANY_PARTS",`${n} entries > ${e} cap`);let s=t.readUInt32LE(i+16),a=[],o=new Set,h=s;for(let l=0;l<n;l++){if(h+46>t.length||t.readUInt32LE(h)!==33639248)throw new et("DOCX_UNREADABLE","malformed central directory");let p=t.readUInt32LE(h+16),f=t.readUInt16LE(h+28),d=t.readUInt16LE(h+30),C=t.readUInt16LE(h+32),m=t.subarray(h+46,h+46+f).toString("utf8"),F=Vi(m);if(F!==null)throw new et("DOCX_UNREADABLE",`unsafe entry name (${F}): ${JSON.stringify(m)}`);if(o.has(m))throw new et("DOCX_UNREADABLE",`duplicate entry: ${m}`);o.add(m),a.push({name:m,crc:p}),h+=46+f+d+C}return a}function Oa(t,e){let r=new Map,i=0,n=null,s=o=>{n||(n=o)},a=new ui(o=>{let h=Vi(o.name);if(h!==null){s(new et("DOCX_UNREADABLE",`unsafe entry name (${h}): ${JSON.stringify(o.name)}`));return}let l=[],p=0;o.ondata=(f,d,C)=>{if(f){s(new et("DOCX_UNREADABLE",`entry ${o.name}: ${f.message??String(f)}`));return}if(d&&d.length>0){if(p+=d.length,i+=d.length,p>e.maxPartBytes){s(new et("DOCX_PART_TOO_LARGE",`${o.name}: ${p} actual bytes > ${e.maxPartBytes} cap`));return}if(i>e.maxTotalBytes){s(new et("DOCX_BOMB",`total actual inflated bytes exceed ${e.maxTotalBytes} cap`));return}l.push(d)}C&&!n&&r.set(o.name,Buffer.concat(l))},o.start()});a.register(Je),a.register(fi);try{for(let o=0;o<t.length;o+=65536)if(a.push(t.subarray(o,Math.min(o+65536,t.length)),o+65536>=t.length),n)throw n}catch(o){throw o instanceof et?o:new et("DOCX_UNREADABLE",`zip stream: ${o instanceof Error?o.message:String(o)}`)}if(n)throw n;return r}function ji(t,e,r){let i=new Yi.SaxesParser({xmlns:!0}),n=null;if(i.on("doctype",()=>{n=new et("DOCX_UNREADABLE",`DOCTYPE not allowed (${e})`)}),i.on("error",s=>{n=n??new et("DOCX_UNREADABLE",`${e}: ${s.message}`)}),i.on("opentag",s=>{if(n)return;let a={};for(let[o,h]of Object.entries(s.attributes))a[h.local||o]=h.value;r(s.uri??"",s.local,a)}),i.write(t).close(),n)throw n}function Xi(t,e){let r=new Map;return ji(t,e,(i,n,s)=>{i===Fa&&n==="Relationship"&&s.Id&&s.Type&&s.Target!==void 0&&r.set(s.Id,{type:s.Type,target:s.Target,targetMode:s.TargetMode==="External"?"External":"Internal"})}),r}function Na(t){let e=new Map,r=new Map;return ji(t,"[Content_Types].xml",(i,n,s)=>{i===Da&&(n==="Default"&&s.Extension&&s.ContentType?e.set(s.Extension.toLowerCase(),s.ContentType):n==="Override"&&s.PartName&&s.ContentType&&r.set(s.PartName.replace(/^\//,""),s.ContentType))}),{defaults:e,overrides:r}}function Ia(t,e){let r=t.overrides.get(e);if(r)return r;let i=e.lastIndexOf(".");if(!(i<0))return t.defaults.get(e.slice(i+1).toLowerCase())}function $i(t,e){if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.includes("\\")||e.includes("\0"))return null;let r;try{r=decodeURIComponent(e)}catch{return null}let i=r.startsWith("/")?[]:t.split("/").slice(0,-1).filter(n=>n.length>0);for(let n of r.split("/"))if(!(n===""||n===".")){if(n===".."){if(i.length===0)return null;i.pop();continue}i.push(n)}return i.length>0?i.join("/"):null}var Ma=Buffer.from([208,207,17,224,161,177,26,225]);function de(t){try{return t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191?new TextDecoder("utf-8",{fatal:!0}).decode(t.subarray(3)):t.length>=2&&t[0]===255&&t[1]===254?new TextDecoder("utf-16le",{fatal:!0}).decode(t.subarray(2)):t.length>=2&&t[0]===254&&t[1]===255?new TextDecoder("utf-16be",{fatal:!0}).decode(t.subarray(2)):new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw new et("DOCX_UNREADABLE","XML part is not valid UTF-8/UTF-16 text")}}function Zi(t,e){if(t.length>=8&&t.subarray(0,8).equals(Ma))throw new et("DOCX_ENCRYPTED_OR_LEGACY","password-protected Office file (or a legacy .doc renamed .docx) \u2014 remove the password / save as .docx and re-ingest");let r={maxEntries:e?.maxEntries??Ta,maxPartBytes:e?.maxPartBytes??ya,maxTotalBytes:e?.maxTotalBytes??Aa},i=Sa(t,r.maxEntries),n=Oa(t,r),s=new Map(i.map(d=>[d.name,d]));if(n.size!==i.length)throw new et("DOCX_UNREADABLE",`central directory lists ${i.length} entries, stream produced ${n.size}`);for(let[d,C]of n){let m=s.get(d);if(!m)throw new et("DOCX_UNREADABLE",`entry ${d} missing from central directory`);if(ii(C)!==m.crc)throw new et("DOCX_UNREADABLE",`CRC mismatch: ${d}`)}let a=n.get("_rels/.rels");if(!a)throw new et("DOCX_NOT_WORDPROCESSING","no package relationships (_rels/.rels missing)");let o=Xi(de(a),"_rels/.rels"),h=null;for(let d of o.values()){if(!ka.has(d.type)||d.targetMode!=="Internal")continue;let C=$i("",d.target);if(C!==null&&n.has(C)){h=C;break}}if(h===null)throw new et("DOCX_NOT_WORDPROCESSING","this zip is not a Word document (no officeDocument relationship)");let l=n.get("[Content_Types].xml");if(!l)throw new et("DOCX_NOT_WORDPROCESSING","package has no [Content_Types].xml");let p=Ia(Na(de(l)),h);if(!p||!Ra.some(d=>p.startsWith(d)))throw new et("DOCX_NOT_WORDPROCESSING",`this zip is not a Word document (main part content type: ${p??"unknown"} \u2014 pptx/xlsx or unknown package)`);let f=new Map;return{parts:n,mainPart:h,relsFor(d){let C=f.get(d);if(C)return C;let m=d.lastIndexOf("/"),F=`${m>=0?d.slice(0,m+1):""}_rels/${m>=0?d.slice(m+1):d}.rels`,w=n.get(F),T=w?Xi(de(w),F):new Map;return f.set(d,T),T},resolveTarget:$i}}var ts=Le(Gn(),1),es=Le(Jn(),1);function rs(t){return t.length>=24&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?t.toString("latin1",12,16)!=="IHDR"?{format:"png"}:{format:"png",width:t.readUInt32BE(16),height:t.readUInt32BE(20)}:t.length>=4&&t[0]===255&&t[1]===216&&t[2]===255?{format:"jpeg",...qo(t)}:t.length>=16&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"?{format:"webp",...zo(t)}:t.length>=4&&t.toString("latin1",0,4).startsWith("GIF8")?{format:"gif"}:t.length>=2&&t[0]===66&&t[1]===77?{format:"bmp"}:t.length>=4&&(t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42)?{format:"tiff"}:t.length>=44&&t.readUInt32LE(0)===1&&t.toString("latin1",40,44)===" EMF"?{format:"emf"}:t.length>=4&&(t[0]===215&&t[1]===205&&t[2]===198&&t[3]===154||t[0]===1&&t[1]===0&&t[2]===9&&t[3]===0)?{format:"wmf"}:{format:"unknown"}}function qo(t){let e=2;for(;e+9<t.length;){if(t[e]!==255)return{};let r=t[e+1];if(r===216||r>=208&&r<=215){e+=2;continue}let i=t.readUInt16BE(e+2);if(r>=192&&r<=207&&r!==196&&r!==200&&r!==204)return{height:t.readUInt16BE(e+5),width:t.readUInt16BE(e+7)};if(i<2)return{};e+=2+i}return{}}function zo(t){let e=t.toString("latin1",12,16);if(e==="VP8X"&&t.length>=30)return{width:1+t.readUIntLE(24,3),height:1+t.readUIntLE(27,3)};if(e==="VP8 "&&t.length>=30)return t[23]!==157||t[24]!==1||t[25]!==42?{}:{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383};if(e==="VP8L"&&t.length>=25){if(t[20]!==47)return{};let r=t.readUInt32LE(21);return{width:(r&16383)+1,height:(r>>>14&16383)+1}}return{}}function is(t,e){try{if(e==="png"){let r=ts.PNG.sync.read(t);return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}if(e==="jpeg"){let r=es.decode(t,{useTArray:!0,maxMemoryUsageInMB:512});return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}return null}catch{return null}}var ss=Le(vr(),1);var qe=new Set(["http://schemas.openxmlformats.org/wordprocessingml/2006/main","http://purl.oclc.org/ooxml/wordprocessingml/main"]),Go=new Set(["http://schemas.openxmlformats.org/drawingml/2006/main","http://purl.oclc.org/ooxml/drawingml/main"]),Wo=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/math","http://purl.oclc.org/ooxml/officeDocument/math"]),ns="urn:schemas-microsoft-com:vml",Pr="http://schemas.openxmlformats.org/markup-compatibility/2006",ze=class{constructor(e,r,i=n=>this.tokens.push(n)){this.partName=e;this.budget=r;this.sink=i}tokens=[];storyRefs=[];stack=[];skipUntilDepth=[];fields=[];runVanish=[];acStack=[];txbxDepths=[];drawing=null;failed=null;setSink(e){this.sink=e}fail(e){this.failed||(this.failed=e)}abort(e){throw!this.failed&&e instanceof et&&(this.failed=e),e}emit(e){this.failed||(this.drawing&&e.t==="text"&&this.txbxDepths.length>0&&(this.drawing.emittedContent=!0),this.sink(e))}suppressed(){return this.skipUntilDepth.length>0}inInstruction(){return this.fields.some(e=>!e.hasSeparate)}parent(){return this.stack.length>=2?this.stack[this.stack.length-2]:void 0}depth(){return this.stack.length}onOpen(e,r,i){if(this.failed)return;this.budget.nodesRemaining-=1,this.budget.nodesRemaining<0&&this.abort(new et("DOCX_UNREADABLE",`XML node budget exhausted (${this.partName})`)),(this.budget.nodesRemaining&4095)===0&&this.budget.deadline!==void 0&&Date.now()>this.budget.deadline&&this.abort(new et("DOCX_UNREADABLE",`conversion budget exhausted (${this.partName})`)),this.stack.push({uri:e,local:r});let n=this.depth();if(n>_r&&this.abort(new et("DOCX_UNREADABLE",`XML nesting exceeds ${_r} (${this.partName})`)),this.suppressed())return;if(e===Pr&&r==="AlternateContent"){this.acStack.push({branchTaken:!1});return}if(e===Pr&&(r==="Choice"||r==="Fallback")){let a=this.acStack[this.acStack.length-1];if(!a)return;a.branchTaken?this.skipUntilDepth.push(n):a.branchTaken=!0;return}let s=qe.has(e);if((s&&r==="txbxContent"||e===ns&&r==="textbox")&&this.txbxDepths.push(n),s&&(r==="del"||r==="moveFrom"||r==="sdtPr"||r==="delText"||r==="pPrChange"||r==="rPrChange"||r==="sectPrChange"||r==="tblPrChange"||r==="trPrChange"||r==="tcPrChange")){this.skipUntilDepth.push(n);return}if(Wo.has(e)&&(r==="oMath"||r==="oMathPara")){this.emit({t:"marker",value:"[equation omitted]"}),this.skipUntilDepth.push(n);return}if(s&&r==="altChunk"){this.emit({t:"marker",value:"[embedded content omitted]"}),this.skipUntilDepth.push(n);return}if(s&&r==="tabs"){this.skipUntilDepth.push(n);return}if(s){switch(r){case"r":this.runVanish.push(!1);break;case"vanish":{let a=i.val;this.parent()?.local==="rPr"&&a!=="false"&&a!=="0"&&this.runVanish.length>0&&(this.runVanish[this.runVanish.length-1]=!0);break}case"fldChar":{let a=i.fldCharType;if(a==="begin")this.fields.push({hasSeparate:!1});else if(a==="separate"){let o=this.fields[this.fields.length-1];o&&(o.hasSeparate=!0)}else if(a==="end"){let o=this.fields.pop();o&&!o.hasSeparate&&this.emit({t:"marker",value:"[field: no stored result]"})}break}case"tab":this.parent()?.local==="r"&&!this.textSuppressed()&&this.emit({t:"tab"});break;case"br":case"cr":this.textSuppressed()||this.emit({t:"break"});break;case"noBreakHyphen":this.textSuppressed()||this.emit({t:"text",value:"\u2011"});break;case"softHyphen":break;case"sym":this.textSuppressed()||this.emit({t:"marker",value:"[symbol]"});break;case"numPr":this.parent()?.local==="pPr"&&this.emit({t:"marker",value:"- "});break;case"footnoteReference":i.id!==void 0&&!this.textSuppressed()&&this.emit({t:"note-ref",noteKind:"footnote",id:i.id});break;case"endnoteReference":i.id!==void 0&&!this.textSuppressed()&&this.emit({t:"note-ref",noteKind:"endnote",id:i.id});break;case"headerReference":case"footerReference":{let a=i.id;if(a){let o=i.type==="first"?"first":i.type==="even"?"even":"default";this.storyRefs.push({kind:r==="headerReference"?"header":"footer",type:o,relId:a})}break}case"drawing":this.drawing||(this.drawing={relId:null,kind:"drawing",external:!1,found:!1,emittedContent:!1});break;case"pict":case"object":this.drawing||(this.drawing={relId:null,kind:"vml",external:!1,found:!1,emittedContent:!1});break}return}if(Go.has(e)&&r==="blip"&&this.drawing&&!this.drawing.found){let a=this.relAttr(i,"embed"),o=this.relAttr(i,"link");a?(this.drawing.relId=a,this.drawing.external=!1,this.drawing.found=!0):o&&(this.drawing.relId=o,this.drawing.external=!0,this.drawing.found=!0);return}if(e===ns&&r==="imagedata"&&this.drawing&&!this.drawing.found){let a=this.relAttr(i,"id")??i.relid;a&&(this.drawing.relId=a,this.drawing.kind="vml",this.drawing.found=!0);return}}onClose(){let e=this.depth();this.skipUntilDepth[this.skipUntilDepth.length-1]===e&&this.skipUntilDepth.pop(),this.txbxDepths[this.txbxDepths.length-1]===e&&this.txbxDepths.pop();let i=this.stack.pop();if(!(!i||this.failed)&&!this.suppressed()){if(i.uri===Pr&&i.local==="AlternateContent"){this.acStack.pop();return}if(qe.has(i.uri))switch(i.local){case"r":this.runVanish.pop();break;case"p":this.emit({t:"para-end"});break;case"tc":this.emit({t:"table-cell-end"});break;case"tr":this.emit({t:"table-row-end"});break;case"drawing":case"pict":case"object":{let n=this.drawing;if(this.drawing=null,!n)break;n.found?this.emit({t:"image",relId:n.relId,kind:n.kind,external:n.external}):n.emittedContent||this.emit({t:"marker",value:"[object omitted: drawing]"});break}}}}onText(e){if(this.failed||this.suppressed()||e.length===0)return;let r=this.stack[this.stack.length-1];!r||!qe.has(r.uri)||r.local==="t"&&(this.textSuppressed()||(this.budget.textCharsRemaining!==void 0&&(this.budget.textCharsRemaining-=e.length,this.budget.textCharsRemaining<0&&this.abort(new Error(`PROJECTION_TOO_LARGE: projection text exceeds the conversion cap during the walk (${this.partName}) \u2014 split the document and re-ingest`))),this.emit({t:"text",value:e})))}textSuppressed(){return this.inInstruction()?!0:this.runVanish.length>0&&this.runVanish[this.runVanish.length-1]}relAttr(e,r){return e[r]}run(e){let r=new ss.SaxesParser({xmlns:!0});if(r.on("doctype",()=>{this.fail(new et("DOCX_UNREADABLE",`DOCTYPE not allowed (${this.partName})`))}),r.on("error",i=>{this.fail(new et("DOCX_UNREADABLE",`${this.partName}: ${i.message}`))}),r.on("opentag",i=>{let n={},s=Object.entries(i.attributes);s.length>zi&&this.abort(new et("DOCX_UNREADABLE",`too many attributes (${this.partName})`));for(let[a,o]of s)o.value.length>Gi&&this.abort(new et("DOCX_UNREADABLE",`oversized attribute (${this.partName})`)),n[o.local||a]=o.value;this.onOpen(i.uri??"",i.local,n)}),r.on("closetag",()=>this.onClose()),r.on("text",i=>this.onText(i)),r.write(e).close(),this.failed)throw this.failed}};function as(t,e){let r=e.budget??{nodesRemaining:Number.MAX_SAFE_INTEGER},i=new ze(e.partName,r);return i.run(t),{tokens:i.tokens,storyRefs:i.storyRefs}}var Br=class extends ze{notes=new Map;current=null;noteDepth=0;constructor(e,r){super(e,r),this.setSink(i=>this.current?.push(i))}onOpen(e,r,i){super.onOpen(e,r,i),!(!qe.has(e)||r!=="footnote"&&r!=="endnote")&&(i.type!==void 0&&i.type!=="normal"||(this.current=[],i.id!==void 0&&this.notes.set(i.id,this.current),this.noteDepth=this.depth()))}onClose(){let e=this.depth();super.onClose(),this.noteDepth===e&&(this.current=null,this.noteDepth=0)}};function os(t,e){let r=new Br(e.partName,e.budget??{nodesRemaining:Number.MAX_SAFE_INTEGER});return r.run(t),r.notes}var jo="v1",Zo="1.0.0+saxes6.0.0+fflate0.8.3+pngjs7.0.0+jpeg-js0.4.4",Qo=64,Ko=16,Jo=12e6,th=6e6,eh=5e7,rh=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes","http://purl.oclc.org/ooxml/officeDocument/relationships/footnotes"]),ih=new Set(["http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes","http://purl.oclc.org/ooxml/officeDocument/relationships/endnotes"]),nh={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},sh=new Set(["png","jpeg","webp"]);function ah(t){if(t==="body")return"in body";if(t.startsWith("header:"))return"in header";if(t.startsWith("footer:"))return"in footer";let e=/^(footnote|endnote):(.+)$/.exec(t);return e?`in ${e[1]} ${e[2]}`:`in ${t}`}var Xr=class{constructor(e,r){this.pkg=e;this.caps=r}inventory=[];blobs=new Map;delivered=[];n=0;deliveredBytes=0;firstRefByFp=new Map;count(){return this.n}occurrence(e,r,i){this.n+=1;let n=`i${this.n}`,s=ah(i),a=(w,T,S)=>{this.inventory.push({ref:n,loc:i,media_type:w,...S?.blob?{blob:S.blob}:{},...S?.appearance?{appearance:S.appearance}:{},delivery:T,...S?.duplicate_of?{duplicate_of:S.duplicate_of}:{}})},o=w=>`[img#${n} omitted: ${w}]`,h=e.relId!==null?this.pkg.relsFor(r).get(e.relId):void 0;if(e.external||h?.targetMode==="External")return a("application/octet-stream","external-image-not-fetched"),o("external-image-not-fetched");let l=h?this.pkg.resolveTarget(r,h.target):null,p=l!==null?this.pkg.parts.get(l):void 0;if(!p)return a("application/octet-stream","undecodable"),o("undecodable");let f=rs(p),d=nh[f.format],C=ei(p);if(this.blobs.set(C,p),!sh.has(f.format)){let w=f.format==="gif"||f.format==="bmp"||f.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";return a(d,w,{blob:C}),o(w)}if(f.width===void 0||f.height===void 0||f.width*f.height>this.caps.maxPixels)return a(d,"undecodable",{blob:C}),o("undecodable");let m;if(f.format==="png"||f.format==="jpeg"){let w=is(p,f.format);if(w===null)return a(d,"undecodable",{blob:C}),o("undecodable");m=ri(w.data,{width:w.width,height:w.height,channels:w.channels})}if(f.width<this.caps.dimensionFloor||f.height<this.caps.dimensionFloor)return a(d,"below-dimension-floor",{blob:C,appearance:m}),o("below-dimension-floor");let F=this.firstRefByFp.get(C);return F!==void 0?(a(d,"duplicate",{blob:C,appearance:m,duplicate_of:F}),`[img#${n}: image ${s} \u2014 same as img#${F}; cite img#${F}]`):p.byteLength>this.caps.imageMaxBytes?(a(d,"image-too-large",{blob:C,appearance:m}),o("image-too-large")):this.deliveredBytes+p.byteLength>this.caps.visionByteBudget?(a(d,"vision-byte-budget-reached",{blob:C,appearance:m}),o("vision-byte-budget-reached")):this.delivered.length>=this.caps.imageCap?(a(d,"image-cap-reached",{blob:C,appearance:m}),o("image-cap-reached")):(this.firstRefByFp.set(C,n),this.deliveredBytes+=p.byteLength,this.delivered.push(n),a(d,"selected",{blob:C,appearance:m}),`[img#${n}: image ${s}]`)}};function Ur(t,e){let r=[];for(let i of t)switch(i.t){case"text":r.push(i.value);break;case"tab":r.push(" ");break;case"break":r.push(`
|
|
11
|
-
`);break;case"para-end":r.push(`
|
|
12
|
-
`);break;case"table-cell-end":r[r.length-1]===`
|
|
13
|
-
`&&r.pop(),r.push(" ");break;case"table-row-end":r[r.length-1]===" "&&r.pop(),r.push(`
|
|
14
|
-
`);break;case"marker":r.push(i.value);break;case"note-ref":r.push(`[${i.noteKind} ${i.id}]`);break;case"image":{let n=e(i);n!==null&&r.push(n);break}}return r.join("")}function Hr(t){let e=0;for(let r of t)r.t==="text"&&(e+=r.value.length);return e}function hs(t,e,r){let i=t.parts.get(e);if(!i)throw new et("DOCX_UNREADABLE",`referenced part missing: ${e}`);return as(de(i),{partName:e,budget:r})}async function Zh(t,e){let r=Date.now()+(e?.budgetMs??Wi),i=m=>{if(Date.now()>r)throw new et("DOCX_UNREADABLE",`conversion budget exhausted (${m})`)},n=Zi(t),s={nodesRemaining:qi,textCharsRemaining:2*4e5,deadline:r},a={dimensionFloor:e?.caps?.dimensionFloor??Qo,imageCap:e?.caps?.imageCap??Ko,visionByteBudget:e?.caps?.visionByteBudget??Jo,imageMaxBytes:e?.caps?.imageMaxBytes??th,maxPixels:e?.caps?.maxPixels??eh},o=new Xr(n,a),h=hs(n,n.mainPart,s);i(n.mainPart);let l=Hr(h.tokens),p=[Ur(h.tokens,m=>o.occurrence(m,n.mainPart,"body"))],f=n.relsFor(n.mainPart),d=new Set;for(let m of["header","footer"])for(let F of h.storyRefs.filter(w=>w.kind===m)){let w=f.get(F.relId);if(!w||w.targetMode!=="Internal")continue;let T=n.resolveTarget(n.mainPart,w.target);if(T===null||!n.parts.has(T)||d.has(T))continue;d.add(T);let S=hs(n,T,s);i(T),l+=Hr(S.tokens);let g=F.type==="default"?`[${m}]`:`[${m} ${F.type}]`;p.push(`${g}
|
|
15
|
-
${Ur(S.tokens,y=>o.occurrence(y,T,`${m}:${T}`))}`)}for(let[m,F]of[["footnote",rh],["endnote",ih]]){let w=[];for(let g of h.tokens)g.t==="note-ref"&&g.noteKind===m&&!w.includes(g.id)&&w.push(g.id);if(w.length===0)continue;let T=null;for(let g of f.values())if(F.has(g.type)&&g.targetMode==="Internal"){T=n.resolveTarget(n.mainPart,g.target);break}if(T===null||!n.parts.has(T))continue;let S=os(de(n.parts.get(T)),{partName:T,budget:s});i(T);for(let g of w){let y=S.get(g);if(!y)continue;l+=Hr(y);let x=T;p.push(`[${m} ${g}]
|
|
16
|
-
${Ur(y,z=>o.occurrence(z,x,`${m}:${g}`))}`)}}if(l===0&&o.count()===0)throw new et("DOCX_NO_TEXT","no extractable text or images \u2014 nothing citable in this document");let C=p.join("");return C.endsWith(`
|
|
17
|
-
`)||(C+=`
|
|
18
|
-
`),{projection:C,inventory:o.inventory,blobs:o.blobs,delivered:o.delivered,converter:{name:"ooxml-walk",version:Zo,policy:jo}}}export{rs as a,is as b,jo as c,Zo as d,Qo as e,Ko as f,Jo as g,th as h,eh as i,Ur as j,Zh as k};
|
|
19
|
-
/*! Bundled license information:
|
|
20
|
-
|
|
21
|
-
xmlchars/xml/1.0/ed5.js:
|
|
22
|
-
(**
|
|
23
|
-
* Character classes and associated utilities for the 5th edition of XML 1.0.
|
|
24
|
-
*
|
|
25
|
-
* @author Louis-Dominique Dubeau
|
|
26
|
-
* @license MIT
|
|
27
|
-
* @copyright Louis-Dominique Dubeau
|
|
28
|
-
*)
|
|
29
|
-
|
|
30
|
-
xmlchars/xml/1.1/ed2.js:
|
|
31
|
-
(**
|
|
32
|
-
* Character classes and associated utilities for the 2nd edition of XML 1.1.
|
|
33
|
-
*
|
|
34
|
-
* @author Louis-Dominique Dubeau
|
|
35
|
-
* @license MIT
|
|
36
|
-
* @copyright Louis-Dominique Dubeau
|
|
37
|
-
*)
|
|
38
|
-
|
|
39
|
-
xmlchars/xmlns/1.0/ed3.js:
|
|
40
|
-
(**
|
|
41
|
-
* Character class utilities for XML NS 1.0 edition 3.
|
|
42
|
-
*
|
|
43
|
-
* @author Louis-Dominique Dubeau
|
|
44
|
-
* @license MIT
|
|
45
|
-
* @copyright Louis-Dominique Dubeau
|
|
46
|
-
*)
|
|
47
|
-
*/
|
package/dist/chunk-FHKDTM5L.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{existsSync as f,mkdirSync as K,readFileSync as l,readdirSync as L,renameSync as y,rmSync as _,writeFileSync as $,openSync as q,closeSync as F}from"fs";import{randomBytes as H}from"crypto";import{join as w}from"path";var d=class extends Error{constructor(t,i){super(`${t}: ${i}`);this.code=t}},R=1440*60*1e3,A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,N=n=>w(n,"sessions"),O=(n,e)=>w(N(n),e),g=(n,e)=>w(O(n,e),"state.json"),m=(n,e)=>w(O(n,e),".lock"),E=n=>(n?.now??(()=>new Date))();function P(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function v(n,e){let t=`${n}.tmp-${process.pid}`;$(t,e,{mode:384}),y(t,n)}function b(n,e,t,i=0){if(i>20)throw new d("SESSION_LOCKED",`${e}: lock contention did not settle`);let o=m(n,e),s=H(8).toString("hex"),a=JSON.stringify({pid:process.pid,ts:t.toISOString(),nonce:s})+`
|
|
3
|
-
`;try{let r=q(o,"wx",384);return $(r,a),F(r),s}catch(r){if(r.code!=="EEXIST")throw r;let p=!1,u;try{let c=JSON.parse(l(o,"utf8")),h=t.getTime()-new Date(c.ts).getTime();p=!P(c.pid)||h>=R,u=c.nonce}catch{p=!0}if(!p)throw new d("SESSION_LOCKED",`${e} is held by another live process`);let S=`${o}.break-${s}`;try{y(o,S);let c;try{c=JSON.parse(l(S,"utf8"))}catch{c=null}if(c===null||c.nonce===u)_(S,{force:!0});else try{y(S,o)}catch{_(S,{force:!0})}}catch(c){if(c.code!=="ENOENT")throw c}return b(n,e,t,i+1)}}function C(n,e,t,i,o){let s=()=>{try{if(JSON.parse(l(m(n,e),"utf8")).nonce!==i)throw new d("SESSION_LOCK_LOST",`${e} lock was taken over`)}catch(r){throw r instanceof d?r:new d("SESSION_LOCK_LOST",`${e} lock file unreadable/gone`)}},a=()=>v(g(n,e),JSON.stringify(t)+`
|
|
4
|
-
`);return{get state(){return t},isApplied:r=>t.applied_events.includes(r),markApplied(r){s(),t={...t,applied_events:[...new Set([...t.applied_events,...r])].sort()},a()},save(r){s();let{agent_state:p,pending:u,assumed:S,read_basis:c,corpus_cursor:h,expires_at:I,force:k,conv_source:x,held_receipts:T,force_scope:D,user_session_id:J}=r;t={...t,...p!==void 0?{agent_state:p}:{},...u!==void 0?{pending:u}:{},...S!==void 0?{assumed:S}:{},...c!==void 0?{read_basis:c}:{},...h!==void 0?{corpus_cursor:h}:{},...I!==void 0?{expires_at:I}:{},...k!==void 0?{force:k}:{},...x!==void 0?{conv_source:x}:{},...T!==void 0?{held_receipts:T}:{},...D!==void 0?{force_scope:D}:{},...J!==void 0?{user_session_id:J}:{}},a()},complete(){s(),_(O(n,e),{recursive:!0,force:!0})},release(){try{s(),_(m(n,e),{force:!0})}catch(r){if(r instanceof d||r.code==="ENOENT")return;throw r}}}}function X(n,e,t){if(!A.test(e.sid))throw new d("SESSION_MISSING",`bad sid ${JSON.stringify(e.sid)}`);let i=E(t);if(f(g(n,e.sid)))throw new d("SESSION_LOCKED",`${e.sid} already exists \u2014 resume it`);K(O(n,e.sid),{recursive:!0,mode:448});let o=b(n,e.sid,i),s={schema:1,applied_events:[],...e};return v(g(n,e.sid),JSON.stringify(s)+`
|
|
5
|
-
`),C(n,e.sid,s,o,t)}function z(n,e,t){if(!A.test(e)||!f(g(n,e)))throw new d("SESSION_MISSING",`no session ${e}`);let i=E(t),o=b(n,e,i),s=JSON.parse(l(g(n,e),"utf8"));if(new Date(s.expires_at).getTime()<=i.getTime())throw _(m(n,e),{force:!0}),new d("SESSION_EXPIRED",`${e} expired at ${s.expires_at}`);let a={...s,expires_at:new Date(i.getTime()+R).toISOString()};return v(g(n,e),JSON.stringify(a)+`
|
|
6
|
-
`),C(n,e,a,o,t)}function Q(n,e){let t=g(n,e);return f(t)?JSON.parse(l(t,"utf8")):null}function Z(n){let e=N(n);if(!f(e))return[];let t=[];for(let i of L(e)){let o=g(n,i);if(f(o))try{let s=JSON.parse(l(o,"utf8"));t.push({sid:s.sid,mode:s.mode,created_at:s.created_at,expires_at:s.expires_at,pendingCount:s.pending.questions.length+s.pending.proposals.length,verb:s.verb,use_case:s.use_case})}catch{t.push({sid:i,mode:"?",created_at:"",expires_at:"",pendingCount:0,corrupt:!0})}}return t.sort((i,o)=>i.created_at<o.created_at?-1:1)}function B(n,e){let t=E(e),i=[],o=[],s=N(n);if(!f(s))return{removed:i,skipped:o};for(let a of L(s)){if(e?.sid&&a!==e.sid)continue;let r=!1,p=!1;try{let u=JSON.parse(l(g(n,a),"utf8"));r=new Date(u.expires_at).getTime()<=t.getTime()}catch{p=!0}if(e?.sid||e?.all||r||p&&e?.all){try{let u=JSON.parse(l(m(n,a),"utf8"));if(P(u.pid)&&u.pid!==process.pid){o.push({sid:a,reason:`in use by live pid ${u.pid}`});continue}}catch{}_(O(n,a),{recursive:!0,force:!0}),i.push(a)}}return{removed:i,skipped:o}}export{d as a,X as b,z as c,Q as d,Z as e,B as f};
|
package/dist/chunk-FPFOW6BS.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-WAOCHXJ5.js";import{a as c}from"./chunk-NLCCBXXV.js";import{a as o}from"./chunk-RZ4F3BHX.js";var u=class{constructor(e,r,t,s){this.controllerBaseUrl=e;this.getOAuthToken=r;this.directBasicAuth=t;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let r;if(this.directBasicAuth)r=new a(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;r=new a(this.controllerBaseUrl,s)}let t=await r.getTmsCredentials();return this.directBasicAuth&&!t.access_key&&(t.access_key=this.directBasicAuth.access_key),this._cached=t,this._lastError=null,this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:t.username,org_id:t.org_id,user_id:t.user_id}),t}catch(r){return this._lastError=r instanceof Error?r:new Error(String(r)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,r={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let t=await this.resolve();if(!t)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...r,headers:{...r.headers,Authorization:c(i.username,i.access_key)}}),l=await o(e,s(t));if(l.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return o(e,s(i))}return l}};function f(n){if(!n)return"network";let e=/failed:\s*(\d{3})\b/.exec(n.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{u as a,f as b};
|
package/dist/chunk-FRBYGSGJ.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as q}from"./chunk-6HYW5RFX.js";import{a as b,b as S,d as C}from"./chunk-J2KSZUOO.js";import{a as R,e as I,f as j,g as L,h as F}from"./chunk-5YPBPZUR.js";import{existsSync as E,mkdirSync as P,readFileSync as k,renameSync as J,rmSync as W,writeFileSync as K}from"fs";import{dirname as V,join as y}from"path";var O=o=>y(o,"derived"),D=o=>y(O(o),"index.json");function U(o,e){let r=e.startsWith("sha256:")?e.slice(7):e;return y(O(o),"nodes",r.slice(0,2),r.slice(2)+".json")}function $(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],conv:{},media:{}}}function M(o){let e=D(o);if(!E(e))return null;try{let r=JSON.parse(k(e,"utf8"));return r.superseded===void 0||r.names===void 0||r.archivedReason===void 0||r.appliedEvents===void 0||r.conv===void 0||r.media===void 0||r.exec===void 0||r.reverse!==void 0?null:r}catch{return null}}function T(o,e){P(V(o),{recursive:!0});let r=`${o}.tmp-${process.pid}`;K(r,e),J(r,o)}function w(o,e,r,p,f={}){let u=f.writeNodeFiles!==!1,h=new Set(e.extracted),m=new Set(e.appliedEvents);r.forEach((i,v)=>{for(let n of i.nodes){let s=U(o,n.cid);u&&!E(s)&&T(s,JSON.stringify({label:n.label,content:n.content})+`
|
|
3
|
-
`),!(n.cid in e.trust)&&n.content.derived===!0&&(e.trust[n.cid]="derived"),e.nodeLabel[n.cid]=n.label}i.proposal_id!=null&&typeof i.extraction_of=="string"&&h.add(i.extraction_of),i.design_of&&((e.design_of??={})[i.design_of.uc_cid]={engine:i.design_of.engine,seq:i.seq});for(let n of i.executions??[])((e.exec??={})[n.about]??=[]).push(n);for(let n of i.edges){let{quote:s,...t}=n.props,c=e.forward[n.src]??=[];c.some(a=>a.ecid===n.ecid)||c.push({...n,props:t}),i.proposal_id!=null&&n.type===I.DERIVES&&typeof n.props.source_cid=="string"&&h.add(n.props.source_cid)}for(let n of i.review)n.resolution==="approved"||n.resolution==="edited"?(e.trust[n.id]="trusted",delete e.archivedReason[n.id]):n.resolution==="rejected"?(e.trust[n.id]="archived",n.reason?e.archivedReason[n.id]=n.reason:delete e.archivedReason[n.id]):n.resolution==="reset"&&(e.trust[n.id]="derived",delete e.archivedReason[n.id]);for(let n of i.supersessions)n.kind==="node"?n.new===n.old?delete e.superseded[n.old]:e.superseded[n.old]=n.new:e.superseded[n.ecid]=null;for(let n of i.names??[])e.names[n.slug]=n.cid;for(let[n,s]of Object.entries(i.source_head_moves))e.heads[n]=s;for(let n of i.event_ids??[])m.add(n);if(i.media)for(let[n,s]of Object.entries(i.media)){let t=i.source_head_moves[n];typeof t=="string"&&(e.media[t]=s)}if(i.conv){let n=i.source_head_moves[i.conv.source_id];if(typeof n=="string"){let s=e.conv[i.conv.source_id],t=s&&s.chain.length>0?s.chain[s.chain.length-1]:null;i.conv.append_of===t?e.conv[i.conv.source_id]={turns:i.conv.turn,chain:[...s?.chain??[],n]}:e.conv[i.conv.source_id]={turns:i.conv.turn,chain:[n]}}}for(let[n,s]of Object.entries(i.source_head_moves))i.conv?.source_id!==n&&e.conv[n]!==void 0&&(e.conv[n]=typeof s=="string"?{turns:e.conv[n].turns,chain:[s]}:{turns:e.conv[n].turns,chain:[]});e.applied={seq:i.seq,hash:p[v]}}),e.extracted=[...h].sort(),e.appliedEvents=[...m].sort()}function x(o,e){T(D(o),JSON.stringify(e)+`
|
|
4
|
-
`)}function Y(o){let e=y(o,"meta.json");if(E(e))try{let r=JSON.parse(k(e,"utf8"));if(r.schema!==R||r.canonicalizer!=="v1")throw new b(`schema fence: store is ${r.schema}/${r.canonicalizer}, this build is ${R}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(r){throw r instanceof b?r:new b(`corrupt meta.json in ${o} \u2014 fix or remove it`)}}function z(o){Y(o);let e=M(o);if(e===null){e=$();let{records:f,hashes:u}=S(o);return w(o,e,f,u),x(o,e),e}let{records:r,hashes:p}=C(o,e.applied.seq,e.applied.hash);return r.length>0&&(w(o,e,r,p),x(o,e)),e}function X(o){return W(O(o),{recursive:!0,force:!0}),z(o)}function ee(o){let e=[],r=[],p=[];try{({records:r,hashes:p}=S(o))}catch(s){return{ok:!1,issues:[s instanceof b?s.message:String(s)],records:0}}let f=$();w(o,f,r,p,{writeNodeFiles:!1});let u=M(o),h=0,m=f;if(u!==null&&u.applied.seq<r.length){let s=u.applied.seq;u.applied.hash===(s===0?null:p[s-1])&&(h=r.length-s,m=$(),w(o,m,r.slice(0,s),p.slice(0,s),{writeNodeFiles:!1}))}if(u===null)e.push("derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let s=t=>JSON.stringify(N(t));for(let t of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","conv","media","design_of","exec"])s(m[t])!==s(u[t])&&e.push(`derived drift in index.${t} (run kane-cli context rebuild)`)}let i=new Set;for(let s of Object.values(f.forward))for(let t of s)i.add(t.ecid);let v=new Set;for(let s of r)for(let t of s.supersessions)t.kind==="node"?(t.old in f.nodeLabel||e.push(`SUPERSEDE_UNKNOWN_OLD: ${t.old} (record ${s.seq})`),t.new!==null&&t.new!==t.old&&!(t.new in f.nodeLabel)&&e.push(`SUPERSEDE_UNKNOWN_NEW: ${String(t.new)} (record ${s.seq})`),t.new===t.old?v.delete(t.old):(v.has(t.old)&&e.push(`DOUBLE_SUPERSEDE: ${t.old} re-superseded while live (record ${s.seq})`),v.add(t.old))):i.has(t.ecid)||e.push(`SUPERSEDE_UNKNOWN_ECID: ${t.ecid} (record ${s.seq})`);for(let s of Object.keys(f.superseded)){let t=new Set,c=s;for(;c!==null&&c in f.superseded;){if(t.has(c)){e.push(`SUPERSEDE_CYCLE: chain from ${s} revisits ${c}`);break}t.add(c),c=f.superseded[c]}}for(let[s,t]of Object.entries(f.names))t in f.nodeLabel||e.push(`NAME_UNKNOWN_TARGET: slug ${s} \u2192 ${t} not in the graph`);for(let s of r)for(let t of s.edges){let c=f.nodeLabel[t.src]??"(unknown)",a=f.nodeLabel[t.dst]??"(unknown)";for(let d of F(t.type,c,a,t.props))e.push(`${d.code}: ${t.ecid} ${d.detail}`)}let n=new Map;for(let s of Object.values(f.forward))for(let t of s){if(t.ecid in f.superseded)continue;let c=n.get(t.type)??[];c.push(t),n.set(t.type,c)}for(let[s,t]of n){let c=L(s);if(c?.acyclic){let a=new Map;for(let l of t)a.set(l.src,[...a.get(l.src)??[],l.dst]);let d=new Map,g=l=>{d.set(l,1);for(let _ of a.get(l)??[])if(d.get(_)===1||d.get(_)===void 0&&g(_))return!0;return d.set(l,2),!1};for(let l of a.keys())if(d.get(l)===void 0&&g(l)){e.push(`EDGE_CYCLE: live ${s} edges form a cycle reachable from ${l}`);break}}if(c?.cardinality==="one-live-per-src"||c?.cardinality==="one-live-per-src-and-dst"){let a=new Map;for(let d of t)d.dst in f.superseded||a.set(d.src,(a.get(d.src)??0)+1);for(let[d,g]of a)g>1&&e.push(`CARDINALITY_VIOLATION: ${g} live ${s} edges from ${d} (one-live-per-src)`)}if(c?.cardinality==="one-live-per-src-and-dst"){let a=new Map;for(let d of t)d.src in f.superseded||d.dst in f.superseded||a.set(d.dst,(a.get(d.dst)??0)+1);for(let[d,g]of a)g>1&&e.push(`CARDINALITY_VIOLATION: ${g} live ${s} edges onto ${d} (one-live-per-dst)`)}}for(let[s,t]of Object.entries(m.nodeLabel)){let c=U(o,s);if(!E(c)){e.push(`missing node file for ${s} (run kane-cli context rebuild)`);continue}try{let a=JSON.parse(k(c,"utf8"));(a.label!==t||q(a.label,a.content)!==s)&&e.push(`node file content mismatch for ${s} (run kane-cli context rebuild)`);for(let d of j(a.label,a.content))e.push(`${d.code}: ${s} ${d.detail}`)}catch{e.push(`corrupt node file for ${s} (run kane-cli context rebuild)`)}}return{ok:e.length===0,issues:e,records:r.length,...h>0?{pending:h}:{}}}function N(o){return Array.isArray(o)?o.map(N):o&&typeof o=="object"?Object.fromEntries(Object.entries(o).sort(([e],[r])=>e<r?-1:1).map(([e,r])=>[e,N(r)])):o}export{U as a,z as b,X as c,ee as d};
|
package/dist/chunk-GG43HSU2.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
function m(e,t){return e.byLabel(t).filter(({cid:i})=>!e.superseded.has(i)&&e.trust.get(i)!=="archived")}function p(e,t,i){return e.displayNameOf(t)??String(i.title??i.text??t)}function f(e,t){let i=m(e,"scenario");if(t){let n=e.resolve(t);if(n){let s=new Set([n.cid,n.tip,e.tipOf(n.cid)]);i=i.filter(({cid:a})=>e.edgesFrom(a).some(l=>l.type==="belongs_to"&&(s.has(l.dst)||s.has(e.tipOf(l.dst)))))}}let o=new Set;for(let{cid:n}of i)o.add(n),o.add(e.tipOf(n));let c=m(e,"test").filter(({cid:n})=>!t||e.edgesFrom(n).some(s=>s.type==="automates"&&(o.has(s.dst)||o.has(e.tipOf(s.dst))))),r=new Set;for(let n of c)for(let s of e.edgesFrom(n.cid))s.type==="automates"&&r.add(e.tipOf(s.dst));let d=i.filter(({cid:n})=>!r.has(n)&&!r.has(e.tipOf(n))).map(({cid:n,content:s})=>p(e,n,s));return{live_scenarios:i.length,live_tests:c.length,missing:d}}function g(e){return e.length<=12?e.join(", "):`${e.slice(0,12).join(", ")} +${e.length-12} more`}function T(e,t){let i=e.committed.length===0?"committed: nothing new":`committed: ${g(e.committed.map(a=>a.temp_ref?`${a.temp_ref} \u2192 ${a.logical_id??a.cid}`:a.logical_id??a.cid))}`,o=[];e.reused&&o.push(`reused: ${e.reused}`),e.rejected?.length&&o.push(`rejected: ${g(e.rejected.map(a=>`${a.ref} (${a.reason})`))}`),e.warnings?.length&&o.push(`warnings: ${g(e.warnings)}`);let c=[`RECEIPT (commit ${e.commitN}, ${e.phase})`,i,...o],r,d;if(e.verb==="design")r=f(t,e.ucRef),c.push(`parity: ${r.live_scenarios} scenario(s) live \xB7 ${r.live_tests} test(s) live`+(r.missing.length?` \xB7 missing tests: ${g(r.missing)}`:"")),d=r.missing.length>0?`next: emit tests for the ${r.missing.length} scenario(s) listed \u2014 1:1, strict. Never re-emit committed items; reference them by the ids above.`:"next: every live scenario has a test. Address open gaps, or finish.";else{let a=m(t,"usecase").length;c.push(`parity: ${a} use-case(s) live`),d="next: refine via chat ops using the ids above. Never re-emit committed items."}c.push(d);let n=c.join(`
|
|
3
|
-
`);for(;Buffer.byteLength(n,"utf8")>6e3;)n=n.slice(0,Math.floor(n.length*.9))+"\u2026";let s={type:"receipt",verb:e.verb,commit_n:e.commitN,phase:e.phase,committed:e.committed,reused:e.reused??0,rejected:e.rejected??[],warnings:e.warnings??[],...r?{parity:{live_scenarios:r.live_scenarios,live_tests:r.live_tests,missing:r.missing}}:{},next:d};return{text:n,event:s}}var h={graph_search_similar:"search graph",graph_get_node:"read node",graph_get_edges:"read edges",graph_match_by_type:"match by type",graph_find_by_provenance:"trace provenance",graph_stale_nodes:"check stale",ask_user:"ask",finalize_proposal:"propose use-cases",chat_turn:"apply changes",read_image:"read image",source_read:"read source",source_grep:"search source",finalize_design:"propose design",expand_bva:"expand boundaries",covering_array:"combine classes",dedupe_candidates:"dedupe",budget_cut:"trim to budget"};function v(e){let t=h[e.name],i=e.status==="error"||e.status==="aborted"?" \u2717":"",o=e.detail?` \u2014 ${e.detail}`:"";return t?`\u2692 ${t}${o}${i}`:`\u2692 working\u2026${o}${i}`}function u(e){return v(e).replace(/^\S+ /,"")}function A(){return{currentAttempt:null,liveThinking:"",thinkingLog:[],activity:[]}}var _={dedup_candidate:"checking a possible duplicate",ambiguity:"asking to resolve an ambiguity",validation_repair:"repairing a validation failure",finalize:"finalizing the proposal",terminal_call:"putting the result together",validation_failed:"fixing a validation issue",no_tool_calls:"nudging a stalled turn",evidence_readback:"reading the evidence back",evidence_search:"searching the evidence",provenance_check:"checking provenance"};function y(e){return _[e.reason_code]??e.reason_code.replace(/_/g," ")}function b(e){let t=u({name:e.name});return e.status==="started"?`\u2192 ${t}\u2026`:e.status==="error"||e.status==="aborted"?`\u2717 ${t}`:`\u2713 ${t}`}function k(e,t){return t.turn_id!==e.turn_id?t.turn_id<e.turn_id:t.attempt<e.attempt}function S(e,t){let i=e.currentAttempt;if(i===null||i.turn_id!==t.turn_id||i.attempt!==t.attempt){if(i!==null&&k(i,t))return e;e={...e,currentAttempt:{turn_id:t.turn_id,attempt:t.attempt},liveThinking:""}}switch(t.type){case"reasoning_delta":return{...e,liveThinking:e.liveThinking+t.text};case"reasoning_done":return t.present?{...e,thinkingLog:[...e.thinkingLog,{text:e.liveThinking,tookMs:t.took_ms}],liveThinking:""}:{...e,liveThinking:""};case"tool_activity":return{...e,activity:[...e.activity,{name:t.name,status:t.status,label:b(t)}]};case"decision_activity":return{...e,activity:[...e.activity,{name:t.action,status:"decision",label:y(t)}]}}}export{T as a,v as b,u as c,A as d,y as e,S as f};
|
package/dist/chunk-J2KSZUOO.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as g}from"./chunk-5YPBPZUR.js";import{a as C,b as _}from"./chunk-IAHKTEET.js";import{closeSync as $,existsSync as O,fsyncSync as x,mkdirSync as b,openSync as v,readFileSync as y,readdirSync as N,renameSync as P,rmSync as A,writeFileSync as k}from"fs";import{join as p}from"path";var i=class extends Error{};function S(e,r){if(e.schema_version!==void 0&&e.schema_version!==g)throw new i(`record ${r} is stamped ${e.schema_version}, this build reads ${g} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new i(`record ${r}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}function F(e){b(e,{recursive:!0});let r=p(e,".lock"),t=Date.now()+2e3;for(;;)try{let n=v(r,"wx");return k(n,`${process.pid}
|
|
3
|
-
`),$(n),()=>{try{A(r)}catch{}}}catch(n){if(n.code!=="EEXIST")throw n;if(Date.now()>t)throw new i(`.context is locked by another process \u2014 remove ${r} if that process is gone`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}var J=/^\d{6}-[0-9a-f]{12}\.json$/,f=e=>p(e,"commits");function w(e){return"sha256:"+_(Buffer.from(C(e),"utf8"))}function R(e){let r=f(e);return O(r)?N(r).filter(t=>J.test(t)).sort():[]}function B(e){let r=R(e),t=[],n=[],c=null;return r.forEach((s,h)=>{let d=y(p(f(e),s),"utf8"),o;try{o=JSON.parse(d)}catch(l){throw new i(`corrupt commit record ${s}: ${String(l)}`)}if(o.seq!==h+1)throw new i(`sequence gap: expected seq ${h+1}, ${s} has ${o.seq}`);if(o.prev_hash!==c)throw new i(`broken chain at ${s}: prev_hash ${String(o.prev_hash)} != ${String(c)}`);S(o,s);let m=w(o),a=s.slice(7,19);if(!m.slice(7).startsWith(a))throw new i(`tampered record ${s}: content hash ${m} does not match filename`);t.push(o),n.push(m),c=m}),{records:t,hashes:n}}function E(e){let r=R(e);if(r.length===0)return null;let t=r[r.length-1],n=y(p(f(e),t),"utf8"),c;try{c=JSON.parse(n)}catch(h){throw new i(`corrupt tail record ${t}: ${String(h)}`)}S(c,t);let s=w(c);if(!s.slice(7).startsWith(t.slice(7,19)))throw new i(`tampered tail record ${t}: content hash ${s} does not match filename`);if(c.seq!==r.length)throw new i(`sequence gap at tail: ${r.length} record files but tail seq is ${c.seq}`);return{seq:c.seq,hash:s}}function T(e){return E(e)?.hash??null}function z(e,r,t){let n=R(e);if(n.length<r)throw new i(`derived state is ahead of the record log (applied seq ${r}, ${n.length} records) \u2014 run kane-cli context rebuild`);let c=[],s=[],h=t;for(let d=r;d<n.length;d++){let o=n[d],m=y(p(f(e),o),"utf8"),a;try{a=JSON.parse(m)}catch(u){throw new i(`corrupt commit record ${o}: ${String(u)}`)}if(a.seq!==d+1)throw new i(`sequence gap: expected seq ${d+1}, ${o} has ${a.seq}`);if(a.prev_hash!==h)throw new i(`broken chain at ${o}: prev_hash ${String(a.prev_hash)} != ${String(h)}`);S(a,o);let l=w(a);if(!l.slice(7).startsWith(o.slice(7,19)))throw new i(`tampered record ${o}: content hash ${l} does not match filename`);c.push(a),s.push(l),h=l}return{records:c,hashes:s}}function G(e,r,t={}){let n=F(e);try{return j(e,r,t)}finally{n()}}function j(e,r,t){let n=E(e),c=(n?.seq??0)+1,s=n?.hash??null;if(t.expectPrev!==void 0&&t.expectPrev!==s)throw new i(`concurrent append detected: validated against ${String(t.expectPrev)} but the chain head is ${String(s)} \u2014 re-open and retry`);let h={seq:c,prev_hash:s,...r,schema_version:g,parents:s===null?[]:[s]},d=w(h),o=f(e);b(o,{recursive:!0});let m=`${String(c).padStart(6,"0")}-${d.slice(7,19)}.json`,a=p(o,m),l=a+".tmp",u=v(l,"w");try{k(u,JSON.stringify(h)+`
|
|
4
|
-
`),x(u)}finally{$(u)}P(l,a);try{let q=v(o,"r");x(q),$(q)}catch{}return{seq:c,hash:d,file:a,record:h}}export{i as a,B as b,T as c,z as d,G as e};
|
package/dist/chunk-J44RN3FB.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as d}from"./chunk-FHKDTM5L.js";function c(e){return{id:e.id,text:e.question,risk:["high","med","low"].includes(e.risk)?e.risk:"med",rationale:e.rationale,options:e.options.map(n=>({label:n.label,detail:n.description??""})),recommended_index:e.recommendedOptionIndex,allow_free_text:e.allowFreeText,kind:e.kind,consequence:e.consequence,evidence_count:e.evidence_count,multi_select:e.multiSelect}}function l(e){return{id:e.id,header:e.kind??"question",question:e.text,kind:e.kind??"clarify",multiSelect:e.multi_select??!1,options:e.options.map((n,s)=>({id:`o${s}`,label:n.label,description:n.detail||void 0})),recommendedOptionIndex:e.recommended_index,risk:e.risk,rationale:e.rationale,consequence:e.consequence??"",evidence_count:e.evidence_count,allowFreeText:e.allow_free_text}}function m(e,n){e.save({agent_state:n.agent_state,pending:{questions:n.pending.questions.map(l),proposals:n.pending.proposals??[]},assumed:n.assumed.map(s=>({questionId:s.question_id,optionId:s.option_id,flagged:!0,eventId:`assumed:${n.sid}:${s.question_id}`}))}),e.release()}function f(e,n,s){let t=d(e,n),o=[];for(let[i,a]of Object.entries(t.state.read_basis))(s.heads.get(i)??null)!==a&&o.push(i);let r=t.state.pending.questions.filter(i=>!t.isApplied(`resolveq:${n}:${i.id}`)&&!t.isApplied(`assumed:${n}:${i.id}`));return{handle:t,represent:[...t.state.pending.proposals],questions:r,staleBasis:o}}export{c as a,m as b,f as c};
|
package/dist/chunk-JSF5JYZC.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as F}from"./chunk-JFAFKHDX.js";import{a as I}from"./chunk-YKTYVJBN.js";import{d as Y,f as Z}from"./chunk-GG43HSU2.js";import{a as J}from"./chunk-DNNZ353O.js";import{a as W}from"./chunk-7E24OCGX.js";import{b as X}from"./chunk-FRBYGSGJ.js";import{n as K}from"./chunk-6W6AIDLJ.js";import{a as z}from"./chunk-6HYW5RFX.js";import{e as Q}from"./chunk-J2KSZUOO.js";import{d as U,f as H}from"./chunk-5YPBPZUR.js";import{a as B,c as j}from"./chunk-B4LLKQTK.js";function mt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{readFileSync as Re,writeFileSync as Ce,renameSync as Te,mkdirSync as Me}from"fs";import{dirname as De,join as Fe}from"path";var O=1,Ne=720*60*1e3;function N(t){return Fe(j,"embeddings",`alias-${t}.json`)}function q(t,e=Date.now()){return t!==null&&e-t.fetchedAt<Ne}function ee(t){try{let e=JSON.parse(Re(t,"utf-8"));return e.wrapperVersion!==O||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:O,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(t,e,n=N(t)){let r=ee(n)?.purposes?.[e];return!r||typeof r.alias!="string"||typeof r.dims!="number"||typeof r.fetchedAt!="number"?null:{alias:r.alias,dims:r.dims,fetchedAt:r.fetchedAt}}function ne(t,e,n,s=N(t)){try{Me(De(s),{recursive:!0});let a=ee(s)?.purposes??{};a[e]={alias:n.alias,dims:n.dims,fetchedAt:Date.now()};let o={wrapperVersion:O,writtenByVersion:B,purposes:a},u=`${s}.tmp`;Ce(u,JSON.stringify(o,null,2)+`
|
|
3
|
-
`),Te(u,s)}catch(r){process.stderr.write(`[embed] Failed to save alias cache: ${r instanceof Error?r.message:String(r)}
|
|
4
|
-
`)}}function Le(t){return t.TESTMUAI_ENV==="stage"?"stage":"prod"}function re(t){let e=t.env??process.env,n=t.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(n)return{authorization:`Basic ${n}`};let s=t.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function se(t,e={}){let n=e.env??process.env,s=Le(n),r=e.aliasCacheFile??N(s),a=e.now??Date.now,o=te(s,t,r);if(q(o,a()))return{alias:o.alias,dims:o.dims};let d=`${I(n)}/assurance/embed/alias?purpose=${encodeURIComponent(t)}`,m=await(e.fetchImpl??fetch)(d,{method:"GET",headers:re(e)});if(!m.ok)throw new Error(`embed alias resolve failed: ${m.status}`);let c=await m.json();return ne(s,t,{alias:c.alias,dims:c.dims},r),{alias:c.alias,dims:c.dims}}async function ie(t,e,n={}){let s=n.env??process.env,r=I(s),a=await(n.fetchImpl??fetch)(`${r}/assurance/embed`,{method:"POST",headers:{...re(n),"content-type":"application/json"},body:JSON.stringify({purpose:t,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{randomBytes as it}from"crypto";function oe(t,e){let n=Math.min(t.length,e.length),s=0,r=0,a=0;for(let o=0;o<n;o++)s+=t[o]*e[o],r+=t[o]*t[o],a+=e[o]*e[o];return r===0||a===0?0:s/(Math.sqrt(r)*Math.sqrt(a))}function ae(t,e,n){return n*t+(1-n)*e}var ce=.7;import{readFileSync as Ge,writeFileSync as Ie,renameSync as Oe,mkdirSync as Pe}from"fs";import{dirname as Ve,join as le}from"path";function Be(t){return le(t,"embeddings")}function je(t){let e=t.indexOf(":");return e>=0?t.slice(e+1):t}function de(t,e,n){let s=je(n);return le(Be(t),e,s.slice(0,2),`${s.slice(2)}.f32`)}function ue(t,e,n){try{let s=Ge(de(t,e,n)),r=new Float32Array(Math.floor(s.length/4));for(let a=0;a<r.length;a++)r[a]=s.readFloatLE(a*4);return r}catch{return null}}function me(t,e,n,s){try{let r=de(t,e,n);Pe(Ve(r),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let u=0;u<s.length;u++)a.writeFloatLE(s[u],u*4);let o=`${r}.tmp`;Ie(o,a),Oe(o,r)}catch(r){process.stderr.write(`[embed] Failed to cache vector: ${r instanceof Error?r.message:String(r)}
|
|
5
|
-
`)}}var Ue=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar"],He=["source_read","source_grep"],ze=[...Ue,...He],he=50,P=200,_e=10,ye=50,fe=20,Qe=200,Xe=50;function L(t,e,n){let s=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(s,n))}function R(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new b(`param "${e}" must be a non-empty string`);return n}function $(t,e){let n=t[e];if(n==null)return null;if(typeof n!="string")throw new b(`param "${e}" must be a string when present`);return n}var b=class extends Error{};function V(t,e){let n=t.getNode(e);return n?{cid:e,label:n.label,content:n.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function pe(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function we(t,...e){let n=pe(t);if(n.size===0)return 0;let s=t.trim().toLowerCase(),r=0;for(let a of e){let o=pe(a);if(o.size===0)continue;let u=0;for(let c of n)o.has(c)&&u++;let d=n.size+o.size-u,m=d===0?0:u/d;s&&a.toLowerCase().includes(s)&&(m=Math.max(m,.9)),r=Math.max(r,m)}return r}function Ke(t,e){let n=R(e,"cid"),s=$(e,"type"),r=$(e,"direction")??"both";if(!["out","in","both"].includes(r))throw new b('param "direction" must be out|in|both');let a=L(e.limit,he,P),o=[];return(r==="out"||r==="both")&&o.push(...t.edgesFrom(n)),(r==="in"||r==="both")&&o.push(...t.edgesInto(n)),o.filter(u=>s==null||u.type===s).slice(0,a)}function We(t,e){let n=R(e,"source_id"),s=t.heads.get(n)??null,r=[];for(let a of t.nodeLabel.keys()){let o=t.derivesInto(a).filter(d=>d.props.source_id===n).map(d=>({source_cid:d.props.source_cid,anchor:d.props.anchor??null}));if(o.length===0)continue;let u=V(t,a);if(u&&(r.push({...u,pins:o,pinned_to_head:s!=null&&o.some(d=>d.source_cid===s)}),r.length>=P))break}return r}function Je(t,e){let n=R(e,"label"),s=$(e,"trust"),r=$(e,"freshness"),a=L(e.limit,he,P),o=[];for(let{cid:u}of t.byLabel(n)){let d=V(t,u);if(d&&!(s!=null&&d.trust!==s)&&!(r!=null&&d.freshness!==r)&&(o.push(d),o.length>=a))break}return o}function Ye(t){return t.staleList().map(({cid:e,state:n})=>{let s=t.getNode(e);return{cid:e,state:n,label:s?.label??null,title:s?.content.title??null}})}function Ze(t,e){let n=R(e,"text"),s=$(e,"label")??"usecase",r=L(e.k,_e,ye),a=[];for(let{cid:o,content:u}of t.byLabel(s)){let d=String(u.title??""),m=String(u.summary??""),c=we(n,d,m);c<=0||a.push({cid:o,title:d,summary:m,score:Math.round(c*1e3)/1e3,trust:t.trust.get(o)??null,freshness:t.stale(o)})}return a.sort((o,u)=>u.score-o.score||o.cid.localeCompare(u.cid)),a.slice(0,r)}function be(t,e,n){let s=t.heads.get(n);if(typeof s!="string"){let a=[...t.heads.keys()].sort().join(", ");throw new b(`unknown source_id "${n}" \u2014 known: ${a||"(none)"}`)}if(t.mediaOf(s).format==="image")throw new b(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=J(e,t,s);if(r==null)throw new b(`source "${n}" blob is missing from the store`);return{head:s,lines:r.toString("utf8").replace(/\n$/,"").split(`
|
|
6
|
-
`)}}function qe(t,e,n){return t.slice(e-1,n).map((s,r)=>`${String(e+r).padStart(4,"0")}| ${s}`).join(`
|
|
7
|
-
`)}function et(t,e,n){let s=R(e,"source_id"),r=$(e,"anchor"),a=e.line_range;if(r!=null&&a!=null)throw new b("give anchor OR line_range, not both");let{head:o,lines:u}=be(t,n,s),d=u.length,m,c;if(r!=null){let f=/^L(\d+)-L(\d+)$/.exec(r);if(!f)throw new b(`anchor "${r}" is not L<a>-L<b>`);let _=Number(f[1]),x=Number(f[2]);if(_<1||x<_||x>d)throw new b(`anchor "${r}" does not resolve (source has ${d} lines)`);m=Math.max(1,_-fe),c=Math.min(d,x+fe)}else if(a!=null){if(!Array.isArray(a)||a.length!==2||!a.every(x=>Number.isInteger(x)))throw new b('param "line_range" must be [from_line, to_line]');let[f,_]=a;if(f<1||_<f)throw new b('param "line_range" must be 1-based with from \u2264 to');if(f>d)throw new b(`line_range starts past the end (source has ${d} lines)`);m=f,c=Math.min(_,d)}else m=1,c=d;return c=Math.min(c,m+Qe-1),{window:qe(u,m,c),from_line:m,to_line:c,source_cid:o}}function tt(t,e,n){let s=R(e,"pattern"),r=$(e,"source_id"),a;try{a=new RegExp(s,"u")}catch(m){throw new b(`invalid pattern: ${m instanceof Error?m.message:String(m)}`)}let o=r!=null?[r]:[...t.heads.keys()].sort(),u=[],d=!1;e:for(let m of o){if(r==null){let f=t.heads.get(m);if(typeof f!="string"||t.mediaOf(f).format==="image")continue}let{lines:c}=be(t,n,m);for(let f=0;f<c.length;f++)if(a.test(c[f])){if(u.length>=Xe){d=!0;break e}u.push({source_id:m,line:f+1,text:c[f]})}}return{matches:u,truncated:d}}function nt(t,e,n,s){try{switch(e){case"get_node":return{ok:!0,result:V(t,R(n,"cid"))};case"get_edges":return{ok:!0,result:Ke(t,n)};case"find_by_provenance":return{ok:!0,result:We(t,n)};case"match_by_type":return{ok:!0,result:Je(t,n)};case"stale_nodes":return{ok:!0,result:Ye(t)};case"search_similar":return{ok:!0,result:Ze(t,n)};case"source_read":case"source_grep":{if(s==null)throw new b("source text unavailable (no context store)");return{ok:!0,result:(e==="source_read"?et:tt)(t,n,s)}}default:return{ok:!1,error:`unknown method: ${e} \u2014 available: ${ze.join(", ")}`}}}catch(r){return r instanceof b?{ok:!1,error:`${e}: ${r.message}`}:{ok:!1,error:`${e}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}}var ge="assurance.sim";function rt(t){return[t.title,t.summary,t.description].filter(Boolean).join(`
|
|
8
|
-
`)}async function st(t,e,n){let s=R(e,"text"),r=$(e,"label")??"usecase",a=L(e.k,_e,ye),o=[];for(let{cid:d,content:m}of t.byLabel(r)){if(t.superseded.has(d))continue;let c=String(m.title??""),f=String(m.summary??""),_=String(m.description??"");o.push({cid:d,title:c,summary:f,description:_,lex:we(s,c,f,_)})}let u=d=>{let m=[];for(let c of o){let f=d(c);f.score<=0||m.push({cid:c.cid,title:c.title,summary:c.summary,score:Math.round(f.score*1e3)/1e3,trust:t.trust.get(c.cid)??null,freshness:t.stale(c.cid),...f.dense!==void 0?{dense_score:Math.round(f.dense*1e3)/1e3,lexical_score:Math.round(c.lex*1e3)/1e3}:{}})}return m.sort((c,f)=>f.score-c.score||c.cid.localeCompare(f.cid)),m.slice(0,a)};try{let d=n.readVector??ue,m=n.writeVector??me,c=n.alpha??ce,{alias:f}=await n.resolveAlias(ge),_=new Map,x=[],T=[];for(let g of o){let S=d(n.contextDir,f,g.cid);S?_.set(g.cid,S):(x.push(g.cid),T.push(rt(g)))}let{vectors:p}=await n.embed(ge,[s,...T]),w=Float32Array.from(p[0]);for(let g=0;g<x.length;g++){let S=Float32Array.from(p[g+1]);_.set(x[g],S),m(n.contextDir,f,x[g],S)}return u(g=>{let S=_.get(g.cid),k=S?oe(w,S):0;return{score:ae(k,g.lex,c),dense:k}})}catch{return u(d=>({score:d.lex}))}}async function ve(t,e,n,s){if(e==="search_similar"&&s)try{return{ok:!0,result:await st(t,n,s)}}catch(r){return r instanceof b?{ok:!1,error:`${e}: ${r.message}`}:{ok:!1,error:`${e}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}return nt(t,e,n,s?.contextDir)}var ot=2,xe=10,at=2;function Se(t,e,n){return t.map(s=>{let r=e.find(a=>a.id===s.id);return r&&r.selected_index!=null&&r.selected_index>=0&&r.selected_index<s.options.length?{id:s.id,resolution:"answered",selected_index:r.selected_index,free_text:null}:r&&r.free_text!=null&&s.allow_free_text?{id:s.id,resolution:"answered",selected_index:-1,free_text:r.free_text}:n.explicitAcceptDefaults?{id:s.id,resolution:"assumed-default",selected_index:s.recommended_index,flagged:!0}:{id:s.id,resolution:"deferred",selected_index:null}})}async function Ft(t,e,n,s,r=()=>{},a){let o=(i,l)=>r(i,l,t.session_id),u=(process.env.ASSURANCE_LOG_LEVEL??"info").toLowerCase()==="debug",d={contextDir:e.contextDir,resolveAlias:i=>se(i,{env:process.env,auth:e.auth}),embed:(i,l)=>ie(i,l,{env:process.env,auth:e.auth})},m=0,c=e.agent(t,{auth:e.auth,onWarn:i=>{o("warn",i),e.out(i)},onStderr:i=>o("agent_stderr",i)}),f=null,_=null,x,T=e.chat?.attachSender?.(i=>c.send(i));e.initialMessage&&(c.send({type:"user_message",message_id:`msg-${t.session_id}-${it(3).toString("hex")}`,text:e.initialMessage}),o("user_message_sent",{chars:e.initialMessage.length,...u?{text:e.initialMessage}:{}}),e.emit?.({type:"message_sent",sid:t.session_id,chars:e.initialMessage.length}),e.chat?.note(`delivered your message to the agent: "${e.initialMessage}"`));let p,w=0,g=0,S=0,k,v=Y(),A=e.progress??e.out;try{for await(let i of c.events){try{e.chat?.onAgentEvent(i)}catch(l){o("chat_mirror_error",{event_type:i.type,message:l instanceof Error?l.message:String(l)})}if(i.type==="reasoning_delta"?(m+=i.text.length,process.env.KANE_TRACE_REASONING&&o("reasoning_delta",i.text)):o(i.type,i),i.type==="reasoning_done"&&o("reasoning_chars",m),i.type==="progress")A(`\u2026 ${i.stage}${i.n?` #${i.n}`:""}`),e.emit?.({type:"agent_activity",kind:"progress",label:`${i.stage}${i.n?` #${i.n}`:""}`});else if(i.type==="reasoning_delta"||i.type==="reasoning_done"||i.type==="tool_activity"||i.type==="decision_activity"){e.onStreamEvent?.(i);let l=v;if(v=Z(v,i),v===l)continue;i.type==="reasoning_delta"?v.liveThinking===i.text&&A("\u2237 thinking\u2026"):i.type==="reasoning_done"?i.present&&(A(`thought for ${(i.took_ms/1e3).toFixed(1)}s`),e.emit?.({type:"agent_activity",kind:"thinking_done",label:`thought for ${(i.took_ms/1e3).toFixed(1)}s`})):i.type==="tool_activity"?i.status!=="done"&&(A(v.activity[v.activity.length-1].label),e.emit?.({type:"agent_activity",kind:"tool",label:v.activity[v.activity.length-1].label})):(A(`\xB7 ${v.activity[v.activity.length-1].label}`),e.emit?.({type:"agent_activity",kind:"decision",label:v.activity[v.activity.length-1].label}))}else if(i.type==="usage")k=i.total_credits,e.emit?.({type:"usage",credits:i.credits,total_credits:i.total_credits});else if(i.type==="graph_query"){let l=await ve(e.graphSlot?.current??s,i.method,i.params??{},d),E=l.ok?{type:"graph_result",id:i.id,ok:!0,result:l.result}:{type:"graph_result",id:i.id,ok:!1,error:l.error};o("graph_result",u?{id:i.id,method:i.method,ok:l.ok,result:l.ok?l.result:l.error}:{id:i.id,method:i.method,ok:l.ok}),c.send(E)}else if(i.type==="session_paused")x=i;else if(i.type==="ask_user"){i.text&&(e.chat?e.chat.ledger({kind:"agent",text:i.text}):e.out(i.text));let l=t.mode;if(l!=="interactive"){let h=i.questions.filter(y=>y.risk==="high");if(l==="ci"&&h.length>0){p=h,c.kill();break}if(l==="agent"&&h.length>0){o("pause_requested",{high:h.map(y=>y.id)}),c.send({type:"pause"});continue}let C=Se(i.questions,[],{explicitAcceptDefaults:!0});w+=C.length;for(let y of C)o("assumed_default",{id:y.id,resolution:y.resolution}),e.emit?.({type:"assumed_default",id:y.id,selected_index:y.selected_index,risk:i.questions.find(D=>D.id===y.id)?.risk});let M={type:"user_response",answers:C.map(y=>({id:y.id,selected_index:y.resolution==="deferred"?null:y.selected_index,free_text:null}))};c.send(M);continue}let E=await e.ask(i.questions),Ae=Se(i.questions,E,{explicitAcceptDefaults:!1}),Ee={type:"user_response",answers:i.questions.map(h=>{let C=E.find(y=>y.id===h.id);if(C?.free_text!=null){let y=n.get(h.id)??0;if(!h.allow_free_text||y>=ot){let D=h.options[h.recommended_index]?.label??"recommended option";if(w+=1,e.emit?.({type:"assumed_default",id:h.id,selected_index:h.recommended_index,risk:h.risk}),e.chat?.noteCoercion)e.chat.noteCoercion(h,D);else{let G=h.text.replace(/\?+\s*$/,""),$e=G.length<=36?G:`${G.slice(0,33)}\u2026`;e.out(`note: couldn't use a typed answer for "${$e}" \u2014 kept the recommended option (${D})`)}return{id:h.id,selected_index:h.recommended_index,free_text:null}}return n.set(h.id,y+1),{id:h.id,selected_index:null,free_text:C.free_text}}let M=Ae.find(y=>y.id===h.id);return M.resolution==="deferred"?{id:h.id,selected_index:null,free_text:null}:{id:h.id,selected_index:M.selected_index,free_text:null}})};c.send(Ee)}else if(i.type==="chat_ops"&&!e.chat){let l=i.chat_ops??i,E=Array.isArray(l.ops)?l.ops.length:0;if(E===0)l.text&&e.out(l.text),c.send({type:"session_complete"}),o("headless_zero_op_chat_turn_complete",{chars:l.text?.length??0});else if(S<at)S+=1,c.send({type:"user_message",message_id:`nochat-${t.session_id}-${S}`,text:"[auto-repair] chat ops are unavailable in this mode \u2014 commit through finalize_design, or finish if nothing remains."}),o("headless_chat_ops_nudge",{n:S,ops:E});else{_="agent kept sending chat ops in a mode with no chat plane",e.out("error: agent kept sending chat ops in a mode with no chat plane \u2014 closing the session"),o("headless_chat_ops_terminal",{ops:E}),c.kill();break}}else if(i.type===(a.terminalEventType??"proposal")){let l=await a.onProposalEvent(i[i.type]);if(f=l.proposal,l.error&&(_=l.error),l.receipt)e.emit?.(l.receipt.event),t.mode!=="interactive"?(g+=1,l.sessionComplete||g>=xe?(l.sessionComplete||(e.out(`warning: ${xe} commits without completion \u2014 closing the session (runaway guard)`),o("receipt_runaway_cap",{commits:g})),c.send({type:"session_complete"}),o("session_complete_sent",{commit_n:l.receipt.event.commit_n,runaway:!l.sessionComplete})):(c.send({type:"user_message",message_id:`receipt-${t.session_id}-${String(l.receipt.event.commit_n??0)}`,text:l.receipt.text}),o("receipt_sent",{commit_n:l.receipt.event.commit_n,chars:l.receipt.text.length}))):e.chat?.holdReceipt&&(e.chat.holdReceipt(l.receipt.text),o("receipt_held",{commit_n:l.receipt.event.commit_n}));else if(l.error&&t.mode!=="interactive"){e.out("error: commit failed with no repair channel \u2014 closing the session"),o("headless_commit_error_terminal",{error:l.error}),c.kill();break}}else if(i.type==="error"){_=i.message;let l=i.failed_proposal;l&&o("failed_proposal",l)}}}finally{c.kill(),T?.()}return{proposal:f,error:_,paused:x,highRisk:p,...w>0?{assumedDefaults:w}:{},...k!==void 0?{creditsTotal:k}:{}}}var ct=3,lt={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function ke(t){let{contextDir:e,graph:n,watermark:s,by:r}=t,{signals:a}=F(e,s),o=a.filter(p=>p.event_id===void 0||n.appliedEvents.has(p.event_id)),u=new Map;for(let p of o){let w=p.event_id??`${p.ts}|${p.id}|${p.verdict}|${p.polarity}`;u.has(`${w}|${p.polarity}|${p.verdict}`)||u.set(`${w}|${p.polarity}|${p.verdict}`,p)}let d=[...u.values()].sort((p,w)=>(p.event_id??p.ts)<(w.event_id??w.ts)?-1:1),m=new Map;for(let p of d){let w=`${p.verdict}|${p.tag??""}`,g=m.get(w)??{verdict:p.verdict,tag:p.tag,events:new Set};g.events.add(p.event_id??p.ts),m.set(w,g)}let c=[],f=[],_=new Set,x=0;for(let[,p]of[...m.entries()].sort(([w],[g])=>w<g?-1:1)){if(p.events.size<ct)continue;let g={derived:!0,statement:`${p.verdict}${p.tag?`/${p.tag}`:""} recurs (${p.events.size} distinct events) \u2014 bias future proposals ${p.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:lt[p.verdict]??"usage",learned_from:[...p.events].sort()},S=H("stylenote",g);if(S.length>0)return{record:null,errors:S.map(A=>({code:A.code,detail:A.detail})),minted:0};let k=z("stylenote",g);if(n.hasNode(k))continue;c.push({cid:k,label:U.STYLENOTE,content:g});let v=K("stylenote",A=>_.has(A),n.names.keys());v!==null&&(_.add(v),f.push({cid:k,slug:v,by:r})),x+=1}return c.length===0?{record:null,errors:null,minted:0}:{record:Q(e,{ts:new Date().toISOString(),proposal_id:null,nodes:c,edges:[],review:[],supersessions:[],source_head_moves:{},...f.length>0?{names:f}:{}},{expectPrev:n.latestHash}).record,errors:null,minted:x}}var dt={kind:"system",id:"distiller"};function zt(t,e=n=>process.stderr.write(n+`
|
|
9
|
-
`)){try{let n=W(t),{watermark:s}=F(t),r=ke({contextDir:t,graph:n,watermark:s,by:dt});if(r.errors){let a=r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ");return e(`warning: style-note distill skipped \u2014 ${a}`),{minted:0,error:a}}if(r.minted>0)try{X(t)}catch{}return{minted:r.minted,error:null}}catch(n){let s=n instanceof Error?n.message:String(n);return e(`warning: style-note distill skipped \u2014 ${s}`),{minted:0,error:s}}}export{mt as a,ve as b,se as c,ie as d,ot as e,Se as f,Ft as g,zt as h};
|
package/dist/chunk-KHQHVSZ6.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as M,b as B,c as oe,d as A}from"./chunk-2YQ6TW77.js";import{a as F}from"./chunk-WAOCHXJ5.js";import{b as z}from"./chunk-CJJXT5DO.js";import{a as U}from"./chunk-2WVKOZ6W.js";import{a as j}from"./chunk-NLCCBXXV.js";import{a as O}from"./chunk-RZ4F3BHX.js";import{e as se}from"./chunk-UR6MHSHU.js";import{readFileSync as te,existsSync as C,readdirSync as Re,mkdirSync as D,writeFileSync as x}from"fs";import{readFile as ie,unlink as Ae}from"fs/promises";import{join as E}from"path";import{randomUUID as P}from"crypto";var re="/home/kaneai/Downloads";function N(t){return`${re}/${t}`}function $(t){return"FILE__"+t.replace(/[^A-Za-z0-9]/g,"_")}function S(t){let e=t?.media;return!e||!e.name||!e.media_url?null:{media_id:e.media_id??"",name:e.name,media_url:e.media_url,type:e.type??"doc"}}function K(t){return t?t.includes(`
|
|
3
|
-
`)?t.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean):t.split(". ").map(e=>e.trim()).filter(Boolean).map(e=>e.endsWith(".")?e:e+"."):[]}function L(t,e){return!t||!e?t:t.replace(/\{\{(.+?)\}\}/g,(i,n)=>{let s=e[n];return s?s.value:i}).replace(/\$\{(.+?)\}/g,(i,n)=>{let s=e[n];return s?s.value:i})}var ae={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD"},G={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},le=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function X(t,e){if(t==="analyze"){let n=e?.action_params?.analyzer_type??"";return G[n]}let i=ae[t];return i||console.warn(`[migrator] UNKNOWN action_type "${t}" \u2014 falling back to "${t.toUpperCase()}"; explicit mapping required`),i??t.toUpperCase()}function Y(t,e){if(!t||!e)return"";try{let i=new Date(t);return isNaN(i.getTime())?"":new Date(i.getTime()+e).toISOString()}catch{return""}}function H(t){try{return JSON.parse(t.output_value??"{}")}catch{return{}}}function ce(t){let e=t.output_variable??"";if(!e)return"[]";let n={...H(t)};return delete n.body,JSON.stringify([{name:e,unique_key:(t.action_id??"").replace(/-/g,"").slice(0,8)||P().replace(/-/g,"").slice(0,8),value:n,variable_description:"API Response"}])}function ue(t,e,i){let n=t.action_params??{},s=le.has(e)?"Vision Agent":"Operation Agent",a={operation_type:e};if(e==="OPEN"&&(a.url=n.url??""),e==="SET_VARIABLE"&&(a.variable_name=t.output_variable??n.key??"",a.variable_value=t.output_value??""),e==="UPLOAD_FILE"){let f=S(n);f&&(a.value=N(f.name))}let o={},l={},r=t.action_instruction??"",c=n.text??"",u=n.url??"",p=[["intent",r],["value",c],["url",u]];for(let[f,h]of Object.entries(i)){let b=String(h);if(f.startsWith("secrets."))for(let[I,v]of p)v.includes(b)&&(l[I]=f);for(let[I,v]of p)v.includes(b)&&!(I in o)&&(o[I]=v)}let _=t.action_type,d={operation:t.action_instruction??"",agent:s,operation_dict:a,reasoning:_==="analyze"?n.query??"":t.intent??t.action_instruction??"",variable:o,secrets:l,params:{}};_==="analyze"&&typeof n.code=="string"&&n.code&&(d.code=n.code),_==="analyze"&&typeof n.code_js=="string"&&n.code_js&&(d.code_js=n.code_js),_==="analyze"&&typeof n.condition_expression=="string"&&n.condition_expression&&(d.condition_expression=n.condition_expression),n.uses_websocket===!0&&(d.uses_websocket=!0),n.uses_sse===!0&&(d.uses_sse=!0),_==="analyze"&&n.analyzer_type==="textual_visual"&&(typeof n.wrapped_js=="string"&&(d.wrapped_js=n.wrapped_js),Array.isArray(n.locators)&&(d.locators=n.locators),typeof n.operator=="string"&&(d.operator=n.operator),Array.isArray(n.transforms)&&(d.transforms=n.transforms),typeof n.query=="string"&&(d.query=n.query),typeof n.expected_value=="string"&&(d.expected_value=n.expected_value),typeof n.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=n.needs_unit_conversion),typeof n.condition=="string"&&(d.condition=n.condition));let m={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[_];return m&&n[m]!==void 0&&(d[m]=n[m]),_==="set_clipboard"&&typeof n.html=="string"&&n.html&&(d.html=n.html),d}function de(t){let e=t.assertion_tree??{};if(typeof e.passed=="boolean")return e.passed;let i=e.sub_results??[];return i.length===0?e.status==="passed":(e.composite_operator??"and")==="or"?i.some(s=>s.passed===!0):i.every(s=>s.passed===!0)}function W(t){return t.map(e=>({description:e.description??"",store_key:e.store_key??"",expected_value:e.expected??"",extracted_value:e.extracted_value??"",operator:e.operator??"equals",transforms:e.transforms??[]}))}function _e(t){let e=t.assertion_tree??{},i=e.sub_results??[],n=W(i);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:i,sub_checks:n,composite_operator:e.composite_operator??"and",verification:e.verification??"",claim:e.description??""}}function pe(t){let i=(t.action_params??{}).assertion_tree??{},n=i.sub_results??[],s=W(n);return[{operation:t.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:n,sub_checks:s,composite_operator:i.composite_operator??"and",verification:"",claim:i.description??t.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function ge(t,e,i,n){let s=t.visual_data;if(!s||s.x==null||s.y==null)return null;let a=e?`${e}/test_screenshots`:"";return{x:s.x,y:s.y,confidence:0,bbox:s.bbox??null,bbox_source:s.bbox?"accessibility_tree":"fallback",viewport_width:s.viewport_width??1280,viewport_height:s.viewport_height??800,scale_factor:null,raw_image_url:a?`${a}/untagged_screenshot/${i}.${n?.get(i)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function fe(t){if(!t)return"";let e=t;return typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.frameInfo)&&(e=t.frameInfo),!Array.isArray(e)||e.length===0?"":JSON.stringify(e)}function V(t,e={},i="",n){let s=t.action_type,a=X(s,t),o=t.action_params??{},l=t.coordinates??null,r=t.selectors??null,c=!!(r&&r.length>0),u=t.timestamp??"",p=t.duration_ms??0,_=t.variables_used??{},d=t.action_id??P(),g=P(),m=Y(u,p),f="",h="";if(s==="navigate")h=o.url??"",f=h;else if(s==="type"||s==="fill")f=o.text??"";else if(s==="press_key")f=o.key??"";else if(s==="wait")f=String(o.ms??o.timeout_ms??"");else if(s==="evaluate_js")f=o.script??"";else if(s==="upload_files"){let y=S(o);y&&(f=N(y.name))}else s==="analyze"&&a==="SET_VARIABLE"&&(f=t.output_value??"");let b="";s==="go_back"?b="back":s==="go_forward"&&(b="forward");let I=L(f,e),v=L(h,e),k=L(t.action_instruction??"",e),R=ue(t,a,_);return{operation_id:d,instruction_id:g,instruction:k,intent:k,operation_start:u,operation_end:m,status:t.status??"",command:a,name:"",target:"",value:I,message:"",operation_dict:"",frame:fe(t.frame_info),error_message:t.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(R),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:i?`${i}/test_screenshots/untagged_screenshot/${d}.${n?.get(d)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:v,navigation_direction:b,tagified_image_url:"",query_variable_name:t.output_variable??"",query_variable_value:t.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:a==="ASSERTION"?de(o):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(o.tab_index??""),tab_identifier:String(o.tab_identifier??""),scroll_value:o.amount??1,scroll_direction:o.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:s==="evaluate_js"?o.script??"":"",code_error:"",hide:!1,dismiss_dialog:!1,use_v2_mobile_tagging:!1,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:l!==null&&!c,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:c?null:l?.x??null,y_coord:c?null:l?.y??null,target_x_coord:o.target_x??null,target_y_coord:o.target_y??null,source_description:o.source_description??null,target_description:o.target_description??null,use_coordinates:l!==null&&!c,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:c?r.map(y=>({type:y.isXPath?"xpath":"css",...y})):"",selector_target:"",math_result_variable_name:"",math_result_variable_value:"",expression_tree:a==="ASSERTION"?_e(o):o.expression_tree??{},assertion_tree:o.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:a==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},start_coordinates:o.source_coordinates?{x:o.source_coordinates[0],y:o.source_coordinates[1]}:{},end_coordinates:o.target_coordinates?{x:o.target_coordinates[0],y:o.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:s==="api"?{request:t.action_params?.api_data?.request??{}}:{},output_variables:s==="api"?t.output_variable?{[t.output_variable]:null}:{}:t.output_variable?{[t.output_variable]:t.output_value??""}:{},visual_context:ge(t,i,d,n),reasoning:s==="analyze"?o.query??"":t.intent??t.action_instruction??""}}function q(t,e,i={}){let n=t.action_type,s=X(n,t),a=t.timestamp??"",o=t.duration_ms??0,l=Y(a,o),r=s==="ASSERTION"||s==="MATHEMATICAL_OPERATION";return{instruction_id:e.instruction_id,instruction_class:r?"non_driver_action":"driver_action",module_id:"",instruction:L(t.action_instruction??"",i),command:s,error:null,parent_instruction_id:"",classification_layer_resp:s==="ASSERTION"?pe(t):[],classification_error:{},operations:[e],status:t.status??"",start_timestamp:a,end_timestamp:l,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&t.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&t.action_params?.analyzer_type?.startsWith("devtool_")?t.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?t.action_params?.script??"":"",user_variables:n==="api"?ce(t):"[]",api_data:n==="api"?{request:t.action_params?.api_data?.request??{},response:H(t)}:{},params_used:!1,hard_assertion:s==="ASSERTION"?t.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?t.action_params?.query??"":t.intent??t.action_instruction??""}}function me(t,e=[]){let i=t.action_params??{},n=i.branches??[],s=i.winning_index??-1,a=i.sub_results??[],o={};for(let r of a){let c=r.sub_results;if(c)for(let u of c){let p=u.store_key;p&&(o[p]=u)}}let l=n.map((r,c)=>{let u=c===s,p=(r.sub_checks??[]).map(_=>{let d=o[_.store_key];return{description:_.description,store_key:_.store_key,expected_value:_.expected_value,stored_value:d?.extracted_value??_.stored_value,operator:_.operator??d?.operator??"equals",transforms:_.transforms??d?.transforms??[]}});if(p.length===0&&r.condition&&a.length>0){let d=a.find(g=>g.branch_index===c)?.sub_results??[];d.length>0&&(p=d.map(g=>({description:g.description??r.condition,store_key:g.store_key??"",expected_value:g.expected??"true",stored_value:g.extracted_value??void 0,operator:g.operator??"equals",transforms:g.transforms??[]})))}return{branch_index:c,condition:r.condition??null,branch_type:r.branch_type??"sub_objective",passed:u,sub_objective:null,custom_event:r.custom_event??null,children:u?e:[],sub_checks:r.condition?p:[],composite_operator:r.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${P().slice(0,8)}`,instruction:t.action_instruction??"",instruction_class:"driver_action",command:"",status:t.status??"success",resolved_branch_index:s,branches:l,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:t.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function J(t,e,i){for(let n of t)n.content_type==="instruction"&&"generative_id"in n&&(n.generative_id=e,n.generative_objective=i)}function w(t,e={},i="",n,s){let a=[],o=0;for(;o<t.length;){let l=t[o],r=l.action_type;if(!s?.keepFailedActions&&l.status==="error"&&r!=="assert"&&r!=="if_else"&&r!=="child_agent_start"&&r!=="child_agent_end"&&!(l.until_condition&&!l.error)){o+=1;continue}if(r==="analyze"&&!G[l.action_params?.analyzer_type??""]){o+=1;continue}if(r==="child_agent_start"){let c=l.action_params?.child_id??"",u=l.action_params?.objective??"",p=[];o+=1;let _=1,d="error",g;for(;o<t.length&&_>0;){let R=t[o],y=R.action_type;if(y==="child_agent_start")_+=1;else if(y==="child_agent_end"&&(_-=1,_===0)){d=R.status??"success",g=R,o+=1;break}_>0&&p.push(R),o+=1}let m=w(p,e,i,n);J(m,c,u);let f=g?.action_params?.result_code??null,h=g?.action_params?.reason_code??null,b=g?.action_params?.error_message??null,I=g?.action_params?.summary??null,v=g?.action_params?.one_liner??null,k=d==="error";a.push({content_type:"generative_block",instruction_id:`generative_block_${c}`,generative_id:c,objective:u,status:d,children:m,error_message:k?b??null:null,error_code:k?h??null:null,result_code:f??null,bifurcation_context:[],approach_reason:K(I),one_liner:v??null});continue}else if(r==="child_agent_end"){o+=1;continue}else if(r==="if_else"){o+=1;let c=[];for(;o<t.length&&t[o].action_type==="child_agent_start";){let u=t[o],p=u.action_params?.child_id??"",_=u.action_params?.objective??"",d=[];o+=1;let g=1,m="error";for(;o<t.length&&g>0;){let h=t[o];if(h.action_type==="child_agent_start")g+=1;else if(h.action_type==="child_agent_end"&&(g-=1,g===0)){m=h.status??"success",o+=1;break}g>0&&d.push(h),o+=1}let f=w(d,e,i,n);c.push(...f)}a.push(me(l,c));continue}else if(r==="query_tool"){o+=1;continue}else if(l.until_condition){let c=V(l,e,i,n),u=q(l,c,e),p=typeof l.until_condition_met=="boolean"?l.until_condition_met:l.status==="success";a.push({content_type:"until_block",instruction_id:`until_${P().slice(0,8)}`,condition:l.until_condition,max_retries:l.until_max_retries??10,settle_ms:l.until_settle_ms??500,current_count:0,condition_met:p,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:l.status??"success"})}else{let c=V(l,e,i,n),u=q(l,c,e);a.push(u)}o+=1}return a}function T(t,e={},i="",n,s){let a=[];for(let o of t){let l=w(o.records,e,i,n,s);if(l.length===0)continue;let r=P().replace(/-/g,"");J(l,r,o.objective);let c=l.some(d=>"status"in d&&typeof d.status=="string"?d.status==="error"||d.status==="failed":!1),u=o.resultCode?parseInt(o.resultCode,10):null,p=u!==null&&!isNaN(u)&&u>=200,_=c||p?"error":"success";a.push({content_type:"generative_block",instruction_id:`generative_block_${r}`,generative_id:r,objective:o.objective,status:_,children:l,error_message:_==="error"?o.errorMessage??null:null,error_code:_==="error"?o.reasonCode??null:null,result_code:o.resultCode??null,bifurcation_context:[],approach_reason:K(o.summary),one_liner:o.oneLiner??null})}return{instructions:a}}var Z=se(oe(),1);import{createWriteStream as he}from"fs";import{readFile as Ee}from"fs/promises";import{join as be,basename as Ie}from"path";import{tmpdir as ve}from"os";var ye=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function Q(t){let e=be(ve(),`${Ie(t)}_artifacts.zip`);return new Promise((i,n)=>{let s=he(e),a=(0,Z.default)("zip",{zlib:{level:6}});s.on("close",()=>i(e)),a.on("error",n),a.pipe(s),a.glob("**/*",{cwd:t,ignore:ye}),a.finalize()})}async function ee(t){return Ee(t)}async function Pe(t,e){return ie(z(t,e))}function ke(t){return{key:"artifacts",content_type:"application/zip",filename:`${t}.evidence`}}var ne=class{config;controller;testId;constructor(e){this.config=e,this.controller=new F(e.controllerBaseUrl,e.auth),this.testId=e.testId}log(e,i,n,s){this.config.log?.(e,i,n,s)}async execute(){let{onProgress:e}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let i=this.config.evidence,n=null;if(this.config.shouldUploadArtifacts!==!1){e("convert","running");let l=this.collectNdjsonPerRun(),r=l.reduce((m,f)=>m+f.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:r,run_groups:l.length});let c=this.config.variables??{};this.log("info","PIPELINE_CONVERT_VARS","Variables for template resolution",{keys:Object.keys(c)});let{instructions:u}=l.length>0?T(l,c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let p=this.buildExecutionEnvelope(u),_=Buffer.from(JSON.stringify(p));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(_.length/1024).toFixed(1)});let d=E(this.config.sessionDir,"execution.json");x(d,JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=i?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let m=E(g,"auteur");D(m,{recursive:!0}),x(E(m,"execution.json"),JSON.stringify(p,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(m,"execution.json")})}if(e("convert","done"),i)n=_;else{e("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let m=null,f;try{m=await Q(this.config.sessionDir),f=await ee(m),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(f.length/1024/1024).toFixed(1),path:m}),e("zip","done",`${(f.length/1024/1024).toFixed(1)}MB`)}finally{m&&await Ae(m).catch(()=>{})}e("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(f.length/1024/1024).toFixed(1),blob_size_kb:+(_.length/1024).toFixed(1)}),await Promise.all([A(h.urls.artifacts.upload_url,f,"application/zip"),A(h.urls.blob.upload_url,_,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}}else{let l=this.collectNdjsonPerRun(),r=this.config.variables??{},{instructions:c}=l.length>0?T(l,r,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0}):{instructions:[]},u=this.buildExecutionEnvelope(c),p=E(this.config.sessionDir,"execution.json");x(p,JSON.stringify(u,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:p});let _=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(_){let d=E(_,"auteur");D(d,{recursive:!0});let g=this.readAuthoredExecution();x(E(d,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:g?"authored":"run_envelope"})}e("convert","skipped"),e("zip","skipped"),e("presign","skipped"),e("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){e("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),e("atomic_replace","done")}catch(l){let r=l instanceof Error?l.message:String(l);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:r}),e("atomic_replace","failed",r),l}}else e("atomic_replace","skipped");let s,a;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){e("commit_lock","running");let l=await this.config.onCommitLock();if(l.ok)s=l.testcaseId,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:s??"none"}),e("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:l.reason,message:l.message}),e("commit_lock","failed",`${l.reason??"unknown"}: ${l.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${l.reason??"unknown"}`}}else e("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){e("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let l=new U(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),r=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(s=(await l.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:r})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:s??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(s)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}e("finalize","done")}else e("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(s&&this.config.shareApiBaseUrl)try{a=await this.generateShareLink(s),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:a})}catch(l){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(l)})}if(i&&n){let l=null;e("zip","running");try{await i.sealFn({testcaseId:s,shareId:a}),l=i.sealedPackPath?await ie(i.sealedPackPath):await Pe(i.executionId,i.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:i.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(l.length/1024/1024).toFixed(1)})}catch(r){let c=r instanceof Error?r.message:String(r);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:i.executionId,error:c})}if(l){e("zip","done",`${(l.length/1024/1024).toFixed(1)}MB`),e("presign","running");let r=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[ke(i.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:r.urls.artifacts?.blob_url,blob_url:r.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(l.length/1024/1024).toFixed(1),blob_size_kb:+(n.length/1024).toFixed(1)}),await Promise.all([A(r.urls.artifacts.upload_url,l,"application/zip"),A(r.urls.blob.upload_url,n,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}else{e("zip","skipped"),e("presign","running");let r=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(n.length/1024).toFixed(1)}),await A(r.urls.blob.upload_url,n,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),e("upload","done")}}let o;if(this.config.codeExport?.enabled&&s){let l=!1;try{await this.triggerCodeExport(s),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),l=!0}catch(r){let c=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:c}),e("code_export","failed",`trigger failed: ${c}`)}if(l){e("code_export","running","Waiting for code generation\u2026");try{o=await this.pollAndDownloadCode(s,e),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),e("code_export","done",o)}catch(r){let c=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:c}),e("code_export","failed",c)}}}else e("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:s,shareId:a,codeExportDir:o}}catch(i){return{success:!1,testId:this.testId,error:i instanceof Error?i.message:String(i)}}}async runCodeExport(e,i){let n=i??this.config.onProgress,s=!1;try{await this.triggerCodeExport(e),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:e}),s=!0}catch(a){let o=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:o}),n("code_export","failed",`trigger failed: ${o}`)}if(s){n("code_export","running","Waiting for code generation\u2026");try{let a=await this.pollAndDownloadCode(e,n);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:a}),n("code_export","done",a),a}catch(a){let o=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:o}),n("code_export","failed",o);return}}}collectNdjsonPerRun(){let e=[],i=this.config.runObjectives??[],n=this.config.runMetadata??[],s=this.config.evidence??this.config.evidenceRead;for(let a=0;a<this.config.runDirs.length;a++){let o=this.config.runDirs[a],l=i[a]||this.config.firstObjective,r=n[a],c=s?this.readNdjsonFromFile(E(s.packTestDir,"logs",`${s.runIndices?.[a]??a}-actions.ndjson`)):this.readNdjsonFromDir(o);c.length>0&&e.push({objective:l,records:c,resultCode:r?.resultCode,reasonCode:r?.reasonCode,errorMessage:r?.errorMessage,summary:r?.summary,oneLiner:r?.oneLiner})}if(e.length===0){let a=E(this.config.sessionDir,"runs");if(C(a))try{let l=Re(a,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>r.name).sort();for(let r of l){let c=E(a,r),u=this.readNdjsonFromDir(c);u.length>0&&e.push({objective:this.config.firstObjective,records:u})}}catch{}}return e}readNdjsonFromDir(e){let i=[E(e,"run-test","actions.ndjson"),E(e,"actions.ndjson")];for(let n of i)if(C(n))return this.readNdjsonFromFile(n);return[]}readNdjsonFromFile(e){let i=[];if(!C(e))return i;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:e});let n=te(e,"utf-8");for(let s of n.split(`
|
|
5
|
-
`)){let a=s.trim();if(a)try{i.push(JSON.parse(a))}catch{}}return i}async generateShareLink(e){let i=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:i,testcase_id:e});let n={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[e],entityType:"Test Case Details",expiresAt:7})},s=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:s,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let a=s?await this.config.authResolver.fetch(i,n):await O(i,{...n,headers:{...n.headers,Authorization:this.buildAuthHeader()}});if(!a.ok)throw new Error(`Share link API failed: ${a.status} ${await a.text()}`);let o=await a.json();if(!o.shareId)throw new Error("Share link API returned no shareId");return o.shareId}async triggerCodeExport(e){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:i,body:n}=M({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e,codeExport:this.config.codeExport});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:i});let s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)},a=this.config.authResolver?await this.config.authResolver.fetch(i,s):await O(i,{...s,headers:{...s.headers,Authorization:this.buildAuthHeader()}});if(!a.ok)throw new Error(`Code export failed: ${a.status} ${await a.text()}`)}async pollAndDownloadCode(e,i){let n=B({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e}),s=this.config.exitTimeoutMs??3e5,a=5e3,o=Date.now()+s;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:n,timeout_ms:s});let l=(r,c)=>this.config.authResolver?this.config.authResolver.fetch(r,c):O(r,{...c,headers:{...c?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<o;){let r=await l(n,{method:"GET",headers:{Accept:"application/json"}});if(!r.ok){let d=await r.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:r.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${r.status}`)}let u=(await r.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!u){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),i("code_export","running","Waiting for code generation\u2026"),await this.sleep(a);continue}let p=u.status.toLowerCase();if(p==="in progress"||p==="in_progress"||p==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),i("code_export","running","Generating code\u2026"),await this.sleep(a);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let _=this.config.codeExportDir??E(this.config.sessionDir,"code-export");D(_,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:_}),i("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let d of u.url){let g=E(_,d.file_name),m=await O(d.file_url);if(!m.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:m.status});continue}let f=await m.text();x(g,f,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:f.length})}return _}throw new Error("Code export timed out")}sleep(e){return new Promise(i=>setTimeout(i,e))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:j(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let e=this.config.authoredExecutionPath;if(!e)return null;try{let i=te(e,"utf8");return JSON.parse(i),i}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:e}),null}}buildExecutionEnvelope(e){let i=this.config.runStatuses.every(r=>r==="passed")?"success":"error",n=this.config.variableIds??{},s=[];if(this.config.variables)for(let[r,c]of Object.entries(this.config.variables)){if(c.secret)continue;let u=r.startsWith("global.")?r.slice(7):r;s.push({id:n[u]??0,name:u,value:c.value,session_value:c.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let a=[],o=[],l=new Set;for(let r of this.collectNdjsonPerRun())for(let c of r.records)if(c.output_variable&&c.output_value!=null&&a.push({name:c.output_variable,value:String(c.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),c.action_type==="upload_files"){let u=S(c.action_params);if(u){let p=u.media_id||u.media_url;if(!l.has(p)){l.add(p),o.push({media_url:u.media_url,media_id:u.media_id,name:u.name,type:u.type});let _=N(u.name);a.push({name:$(u.name),value:_,value_type:"string",variable_description:`variable for ${_}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:i,commit_id:this.config.commitId,instructions:e,modules:[],uploaded_files:o,test_params:[],test_level_variables:JSON.stringify(a),test_global_variables:s,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{Pe as a,ke as b,ne as c};
|