@humain/humain-code 0.4.18 → 0.5.3
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/CHANGELOG.md +284 -1
- package/README.md +3 -1
- package/dist/agent-monitor/client.d.ts +2 -2
- package/dist/agent-monitor/client.d.ts.map +1 -1
- package/dist/agent-monitor/client.js +3 -2
- package/dist/agent-monitor/client.js.map +1 -1
- package/dist/bundle/agent-monitor.js +1 -1
- package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +67 -0
- package/dist/bundle/chunks/anthropic.js +10 -9
- package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +15 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +152 -200
- package/dist/bundle/chunks/chunk-2GCMACT4.js +1956 -0
- package/dist/bundle/chunks/{chunk-QEF72EIZ.js → chunk-A6B2QMA7.js} +40 -96
- package/dist/bundle/chunks/{chunk-YMBXWW36.js → chunk-AO6FF5JL.js} +9 -8
- package/dist/bundle/chunks/{chunk-OWLBGSXY.js → chunk-CN3Q5UNB.js} +388 -310
- package/dist/bundle/chunks/{chunk-SCIGZFN5.js → chunk-DNGJMRJW.js} +11 -11
- package/dist/bundle/chunks/chunk-DU6POZ7E.js +10 -0
- package/dist/bundle/chunks/chunk-EY3LZOUP.js +1963 -0
- package/dist/bundle/chunks/{chunk-G6ABHCPB.js → chunk-FO2NYB6O.js} +655 -663
- package/dist/bundle/chunks/{chunk-RXOCQRBG.js → chunk-GEISZXXH.js} +1 -1
- package/dist/bundle/chunks/{chunk-OKALNPTJ.js → chunk-HIZWUSPN.js} +24 -24
- package/dist/bundle/chunks/{chunk-MVYV6MJY.js → chunk-HT5YN3LX.js} +1 -1
- package/dist/bundle/chunks/chunk-IDU5BNNI.js +15 -0
- package/dist/bundle/chunks/{chunk-TIFFHHW6.js → chunk-JCXXRCP6.js} +5 -5
- package/dist/bundle/chunks/{chunk-QYCOHSI7.js → chunk-KKCMWB63.js} +8 -7
- package/dist/bundle/chunks/{chunk-L5OUCJ7N.js → chunk-L2VKM23Q.js} +87 -13
- package/dist/bundle/chunks/{chunk-SCBU5WOP.js → chunk-M74U5X4S.js} +30 -23
- package/dist/bundle/chunks/{chunk-AWCJWXGD.js → chunk-MIJHJNNQ.js} +3 -2
- package/dist/bundle/chunks/{chunk-Y26OS23T.js → chunk-N7CQ3UV3.js} +4 -4
- package/dist/bundle/chunks/{chunk-XQZG5HPT.js → chunk-O4DO5RWS.js} +11 -6
- package/dist/bundle/chunks/{chunk-P4UKLIQB.js → chunk-ODJUBJK2.js} +4 -4
- package/dist/bundle/chunks/chunk-OR25QDSS.js +365 -0
- package/dist/bundle/chunks/{chunk-7PRU6YW3.js → chunk-OZNC2W4B.js} +306 -286
- package/dist/bundle/chunks/{chunk-Z33NNMNB.js → chunk-PH7UP57J.js} +1 -1
- package/dist/bundle/chunks/{chunk-HPSQKIWK.js → chunk-PS7DGA7B.js} +1 -1
- package/dist/bundle/chunks/chunk-QW6PTCAB.js +10 -0
- package/dist/bundle/chunks/{chunk-5CDES42D.js → chunk-QWXPGBAG.js} +1 -1
- package/dist/bundle/chunks/{chunk-NCQ6WAQK.js → chunk-ROZV2IYD.js} +1 -1
- package/dist/bundle/chunks/{chunk-3XDL5ZE4.js → chunk-RTXDU3AA.js} +148 -122
- package/dist/bundle/chunks/{chunk-FZUJXM6D.js → chunk-UDB6NI4G.js} +309 -240
- package/dist/bundle/chunks/{chunk-3UXBFT4Q.js → chunk-UJLCKIMZ.js} +1906 -1661
- package/dist/bundle/chunks/chunk-UTNHGOFS.js +88 -0
- package/dist/bundle/chunks/{chunk-H2FY3PEV.js → chunk-V62QBESW.js} +4 -3
- package/dist/bundle/chunks/{chunk-NSMMDV3N.js → chunk-XA7CJAYH.js} +4 -3
- package/dist/bundle/chunks/chunk-XQX7S3GM.js +7 -0
- package/dist/bundle/chunks/{chunk-7VY5IL74.js → chunk-Y3OPKKDR.js} +3 -77
- package/dist/bundle/chunks/chunk-YFOLLX5D.js +23 -0
- package/dist/bundle/chunks/{chunk-YRCLNWFV.js → chunk-ZI7TK7HM.js} +1 -1
- package/dist/bundle/chunks/{chunk-V76YPIMT.js → chunk-ZR4GF4WU.js} +21 -15
- package/dist/bundle/chunks/{cli-2NKM2RNJ.js → cli-ENEFJH2B.js} +1 -1
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-T7TPP7SQ.js +4 -0
- package/dist/bundle/chunks/codemode-worker.js +27 -27
- package/dist/bundle/chunks/compat-CJBWWYHE.js +13 -0
- package/dist/bundle/chunks/{dist-XVXV2CL4.js → dist-IBUWEKEE.js} +3 -3
- package/dist/bundle/chunks/{dist-ZJIYY3GA.js → dist-RKNCFFGM.js} +452 -448
- package/dist/bundle/chunks/dist-YFMJEHPH.js +8 -0
- package/dist/bundle/chunks/{dist-cjs-AXBW3N4F.js → dist-cjs-HTASUQXQ.js} +82 -80
- package/dist/bundle/chunks/{easter-egg-3d-VGJ77XZQ.js → easter-egg-3d-YOPLCOVW.js} +2 -2
- package/dist/bundle/chunks/es-YEFEOGR3.js +1905 -0
- package/dist/bundle/chunks/{esm-GIR7QH65.js → esm-R6HJ4QEG.js} +5 -5
- package/dist/bundle/chunks/{event-streams-NXFTZDSF.js → event-streams-BR2IL6C5.js} +1 -1
- package/dist/bundle/chunks/{execute-ZBEZNJ4E.js → execute-2JXEKQ2X.js} +17 -8
- package/dist/bundle/chunks/{extract-RFWEHH6W.js → extract-OTCGZGTL.js} +50 -47
- package/dist/bundle/chunks/github-copilot.js +44 -40
- package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +21 -0
- package/dist/bundle/chunks/google-vertex-UM5MAALA.js +25 -0
- package/dist/bundle/chunks/host-ZHEL5XQW.js +2 -0
- package/dist/bundle/chunks/{https-proxy-agent-7CAXVAFH.js → https-proxy-agent-JQICCRPH.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-AGCW7HYN.js → llama-cpp-classify-B3G57LVR.js} +5 -5
- package/dist/bundle/chunks/{mistral-conversations-G3GN6CMT.js → mistral-conversations-AH72RLXK.js} +11 -11
- package/dist/bundle/chunks/{node-A6SZ3T7E.js → node-SJPZTR4K.js} +190 -190
- package/dist/bundle/chunks/{node-DZCAT4Q6.js → node-VSA4ZN7D.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +2 -2
- package/dist/bundle/chunks/{openai-codex-responses-FJFDAWHI.js → openai-codex-responses-L366637C.js} +48 -47
- package/dist/bundle/chunks/openai-codex.js +10 -9
- package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +83 -0
- package/dist/bundle/chunks/{openai-decisions-HESOHYZB.js → openai-decisions-WOWUC65P.js} +1 -1
- package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +26 -0
- package/dist/bundle/chunks/openrouter-images-5K47HDAT.js +8 -0
- package/dist/bundle/chunks/openrouter.js +10 -9
- package/dist/bundle/chunks/{pi-messages-SAOV3JNW.js → pi-messages-MOQQDZBK.js} +5 -4
- package/dist/bundle/chunks/radius.js +9 -8
- package/dist/bundle/chunks/{runtime-HJEUOD4R.js → runtime-K3F2QDQP.js} +1 -1
- package/dist/bundle/chunks/typesafe-system-one-43OCHGKP.js +3 -0
- package/dist/bundle/chunks/{undici-4BK3MVJV.js → undici-EK3EUI2E.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +5 -0
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/flow/package.json +4 -4
- package/dist/bundle/index.js +6 -6
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +3 -1
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/broker/broker.d.ts +6 -2
- package/dist/coordination/broker/broker.d.ts.map +1 -1
- package/dist/coordination/broker/broker.js +20 -8
- package/dist/coordination/broker/broker.js.map +1 -1
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +4 -2
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/discovery.d.ts +10 -3
- package/dist/coordination/transport/discovery.d.ts.map +1 -1
- package/dist/coordination/transport/discovery.js +18 -5
- package/dist/coordination/transport/discovery.js.map +1 -1
- package/dist/core/agent-session.d.ts +35 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +163 -40
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-subscription-usage.d.ts +47 -0
- package/dist/core/anthropic-subscription-usage.d.ts.map +1 -0
- package/dist/core/anthropic-subscription-usage.js +170 -0
- package/dist/core/anthropic-subscription-usage.js.map +1 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +7 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/client-identity.d.ts +13 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +25 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/codex-usage.d.ts +37 -1
- package/dist/core/codex-usage.d.ts.map +1 -1
- package/dist/core/codex-usage.js +104 -11
- package/dist/core/codex-usage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +2 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +14 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +86 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +3 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/model-config.d.ts +920 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +18 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +20 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +33 -7
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +9 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +123 -14
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/output-guard.d.ts +13 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +101 -11
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +7 -2
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/safe-credential-error.d.ts +11 -0
- package/dist/core/safe-credential-error.d.ts.map +1 -0
- package/dist/core/safe-credential-error.js +14 -0
- package/dist/core/safe-credential-error.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +12 -10
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +4 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +242 -26
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +3 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +6 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +93 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +37 -12
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +102 -24
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +3 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/usage/index.d.ts +15 -0
- package/dist/extensions/usage/index.d.ts.map +1 -0
- package/dist/extensions/usage/index.js +110 -0
- package/dist/extensions/usage/index.js.map +1 -0
- package/dist/extensions/usage/overview.d.ts +90 -0
- package/dist/extensions/usage/overview.d.ts.map +1 -0
- package/dist/extensions/usage/overview.js +215 -0
- package/dist/extensions/usage/overview.js.map +1 -0
- package/dist/extensions/usage/popup.d.ts +21 -0
- package/dist/extensions/usage/popup.d.ts.map +1 -0
- package/dist/extensions/usage/popup.js +98 -0
- package/dist/extensions/usage/popup.js.map +1 -0
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +21 -2
- package/dist/humain/bundled-extension-names.d.ts +6 -0
- package/dist/humain/bundled-extension-names.d.ts.map +1 -0
- package/dist/humain/bundled-extension-names.js +9 -0
- package/dist/humain/bundled-extension-names.js.map +1 -0
- package/dist/humain/gateway/catalog.d.ts +36 -0
- package/dist/humain/gateway/catalog.d.ts.map +1 -0
- package/dist/humain/gateway/catalog.js +74 -0
- package/dist/humain/gateway/catalog.js.map +1 -0
- package/dist/humain/gateway/client.d.ts +58 -0
- package/dist/humain/gateway/client.d.ts.map +1 -0
- package/dist/humain/gateway/client.js +212 -0
- package/dist/humain/gateway/client.js.map +1 -0
- package/dist/humain/gateway/constants.d.ts +23 -0
- package/dist/humain/gateway/constants.d.ts.map +1 -0
- package/dist/humain/gateway/constants.js +32 -0
- package/dist/humain/gateway/constants.js.map +1 -0
- package/dist/humain/gateway/http.d.ts +18 -0
- package/dist/humain/gateway/http.d.ts.map +1 -0
- package/dist/humain/gateway/http.js +274 -0
- package/dist/humain/gateway/http.js.map +1 -0
- package/dist/humain/gateway/login.d.ts +13 -0
- package/dist/humain/gateway/login.d.ts.map +1 -0
- package/dist/humain/gateway/login.js +121 -0
- package/dist/humain/gateway/login.js.map +1 -0
- package/dist/humain/gateway/provider.d.ts +34 -0
- package/dist/humain/gateway/provider.d.ts.map +1 -0
- package/dist/humain/gateway/provider.js +253 -0
- package/dist/humain/gateway/provider.js.map +1 -0
- package/dist/humain/gateway/secret-store.d.ts +19 -0
- package/dist/humain/gateway/secret-store.d.ts.map +1 -0
- package/dist/humain/gateway/secret-store.js +252 -0
- package/dist/humain/gateway/secret-store.js.map +1 -0
- package/dist/humain/gateway/session-store.d.ts +42 -0
- package/dist/humain/gateway/session-store.d.ts.map +1 -0
- package/dist/humain/gateway/session-store.js +175 -0
- package/dist/humain/gateway/session-store.js.map +1 -0
- package/dist/humain/index.d.ts +2 -2
- package/dist/humain/index.d.ts.map +1 -1
- package/dist/humain/index.js +5 -2
- package/dist/humain/index.js.map +1 -1
- package/dist/humain/login-menu.d.ts +14 -0
- package/dist/humain/login-menu.d.ts.map +1 -0
- package/dist/humain/login-menu.js +21 -0
- package/dist/humain/login-menu.js.map +1 -0
- package/dist/humain/node-http.d.ts.map +1 -1
- package/dist/humain/node-http.js +6 -31
- package/dist/humain/node-http.js.map +1 -1
- package/dist/humain/redact-assistant-message.d.ts +4 -0
- package/dist/humain/redact-assistant-message.d.ts.map +1 -0
- package/dist/humain/redact-assistant-message.js +34 -0
- package/dist/humain/redact-assistant-message.js.map +1 -0
- package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/anysearch.js +3 -3
- package/dist/humain/web-access/vendor/anysearch.js.map +1 -1
- package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/bocha.js +3 -3
- package/dist/humain/web-access/vendor/bocha.js.map +1 -1
- package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/brightdata-unlocker.js +2 -2
- package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -1
- package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/brightdata.js +3 -3
- package/dist/humain/web-access/vendor/brightdata.js.map +1 -1
- package/dist/humain/web-access/vendor/ceramic.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ceramic.js +2 -2
- package/dist/humain/web-access/vendor/ceramic.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +3 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +2 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/deepseek.d.ts +11 -1
- package/dist/humain/web-access/vendor/deepseek.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/deepseek.js +170 -5
- package/dist/humain/web-access/vendor/deepseek.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +63 -6
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +5 -3
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +33 -7
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/index.d.ts +1 -0
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +18 -3
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/jina-search.js +6 -4
- package/dist/humain/web-access/vendor/jina-search.js.map +1 -1
- package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/kagi.js +4 -4
- package/dist/humain/web-access/vendor/kagi.js.map +1 -1
- package/dist/humain/web-access/vendor/keenable.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/keenable.js +2 -2
- package/dist/humain/web-access/vendor/keenable.js.map +1 -1
- package/dist/humain/web-access/vendor/linkup.d.ts +6 -0
- package/dist/humain/web-access/vendor/linkup.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/linkup.js +167 -0
- package/dist/humain/web-access/vendor/linkup.js.map +1 -0
- package/dist/humain/web-access/vendor/mistral-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/mistral-search.js +3 -3
- package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
- package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/ollama.js +4 -4
- package/dist/humain/web-access/vendor/ollama.js.map +1 -1
- package/dist/humain/web-access/vendor/parallel.js +6 -7
- package/dist/humain/web-access/vendor/parallel.js.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/perplexity.js +4 -3
- package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
- package/dist/humain/web-access/vendor/querit.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/querit.js +3 -3
- package/dist/humain/web-access/vendor/querit.js.map +1 -1
- package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/search1api.js +3 -3
- package/dist/humain/web-access/vendor/search1api.js.map +1 -1
- package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/searchinfinity.js +3 -3
- package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -1
- package/dist/humain/web-access/vendor/serpapi.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpapi.js +6 -5
- package/dist/humain/web-access/vendor/serpapi.js.map +1 -1
- package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpbase.js +4 -4
- package/dist/humain/web-access/vendor/serpbase.js.map +1 -1
- package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serpdive.js +3 -3
- package/dist/humain/web-access/vendor/serpdive.js.map +1 -1
- package/dist/humain/web-access/vendor/serper.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serper.js +5 -4
- package/dist/humain/web-access/vendor/serper.js.map +1 -1
- package/dist/humain/web-access/vendor/serply.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/serply.js +2 -2
- package/dist/humain/web-access/vendor/serply.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +3 -1
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +27 -2
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/valyu.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/valyu.js +3 -3
- package/dist/humain/web-access/vendor/valyu.js.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.d.ts +2 -0
- package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/web-tool-core.js +3 -0
- package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/xai-search.js +51 -8
- package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.js +3 -3
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -1
- package/dist/humain/web-access/vendor/you.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/you.js +2 -2
- package/dist/humain/web-access/vendor/you.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +32 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +14 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +62 -7
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +6 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/easter-egg-3d.js +1 -1
- package/dist/modes/interactive/components/easter-egg-3d.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +10 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +141 -66
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +16 -3
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +11 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +17 -4
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +5 -4
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.js +11 -9
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/themed-text.js +3 -2
- package/dist/modes/interactive/components/themed-text.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +17 -6
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +3 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +4 -2
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +15 -17
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +143 -158
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -5
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +3 -2
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +3 -2
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +45 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +10 -6
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +3 -3
- package/docs/coordination.md +1 -1
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +133 -10
- package/docs/humain-code.md +13 -1
- package/docs/index.md +1 -1
- package/docs/models-configuration.md +197 -0
- package/docs/models.md +24 -6
- package/docs/providers.md +58 -2
- package/docs/quickstart.md +8 -1
- package/docs/settings.md +1 -1
- package/docs/slash-commands.md +10 -0
- package/docs/tui.md +70 -0
- package/docs/windows.md +16 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/package.json +2 -2
- package/npm-shrinkwrap.json +243 -219
- package/package.json +21 -20
- package/schemas/models.schema.json +84 -30
- package/schemas/settings.schema.json +19 -0
- package/src/coordination/UPSTREAM.md +36 -3
- package/src/coordination/upstream.json +3 -3
- package/src/humain/web-access/UPSTREAM.md +72 -1
- package/src/humain/web-access/upstream.json +5 -4
- package/dist/bundle/chunks/anthropic-messages-TSNY5MWH.js +0 -67
- package/dist/bundle/chunks/azure-openai-responses-Z4DCXO2G.js +0 -15
- package/dist/bundle/chunks/chunk-26EAEXO5.js +0 -167
- package/dist/bundle/chunks/chunk-2ZFUMXOZ.js +0 -1790
- package/dist/bundle/chunks/chunk-5K5RFXXO.js +0 -74
- package/dist/bundle/chunks/chunk-PY7SOXCA.js +0 -10
- package/dist/bundle/chunks/chunk-UGJAAWNC.js +0 -7
- package/dist/bundle/chunks/chunk-UGXYG7HN.js +0 -22
- package/dist/bundle/chunks/chunk-VEYTRNQC.js +0 -5
- package/dist/bundle/chunks/chunk-X3O5MCKJ.js +0 -7
- package/dist/bundle/chunks/chunk-YLYOJQQX.js +0 -1951
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MUJQ6LT2.js +0 -4
- package/dist/bundle/chunks/compat-VDGEZSVM.js +0 -13
- package/dist/bundle/chunks/dist-LKDZAEUQ.js +0 -7
- package/dist/bundle/chunks/es-N6YFJOD7.js +0 -1901
- package/dist/bundle/chunks/google-generative-ai-4OVYRP24.js +0 -21
- package/dist/bundle/chunks/google-vertex-3WQAZJQD.js +0 -25
- package/dist/bundle/chunks/host-63SNKK5Y.js +0 -2
- package/dist/bundle/chunks/openai-completions-IC7WRLTI.js +0 -82
- package/dist/bundle/chunks/openai-responses-XXCYDFSM.js +0 -24
- package/dist/bundle/chunks/openrouter-images-DT2HMZNO.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-HCMGHK6A.js +0 -2
- package/dist/bundle/chunks/virtual-modules-CFJTDIXL.js +0 -5
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -85
- package/dist/core/provider-attribution.js.map +0 -1
- /package/dist/bundle/chunks/{chunk-WZMA7HAJ.js → chunk-XQRYOCHA.js} +0 -0
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{buildCopilotDynamicHeaders,hasCopilotVisionInput}from"./chunk-JEJQVFWK.js";import{iterateSseMessages}from"./chunk-YZMQXAJM.js";import{retryProviderRequest}from"./chunk-Z33NNMNB.js";import"./chunk-MVYV6MJY.js";import{cacheJsonSerialization}from"./chunk-Q7VXYXY3.js";import{adjustMaxTokensForThinking,buildBaseOptions,clampMaxTokensToContext,getJsonSchemaToolParameters,getPiUserAgent,resolveJsonSchemaStrictSampling,splitErrorToolResultImages,transformMessages}from"./chunk-TIFFHHW6.js";
|
|
3
|
-
import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{createRequestObserver,headersToRecord}from"./chunk-5CDES42D.js";import{ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV}from"./chunk-KQM7ZGL6.js";import{getProviderEnvValue}from"./chunk-FACBDLFU.js";import{parseJsonWithRepair,parseStreamingJson,parseStreamingJsonWhileStreaming,
|
|
4
|
-
parseToolCallArguments}from"./chunk-YDBNMIA3.js";import{calculateCost,getCurrentTools,getInitialSystemMessage,getSystemMessageText,renderSystemMessageUpdate,resolveTranscript}from"./chunk-5K5RFXXO.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import{appendAssistantMessageDiagnostic}from"./chunk-VEYTRNQC.js";import{Anthropic}from"./chunk-FZUJXM6D.js";import"./chunk-JXWJOIH4.js";function resolveCacheRetention(cacheRetention,env){return cacheRetention||(getProviderEnvValue("HUMAIN_TERMINAL_CACHE_RETENTION",env)==="long"||getProviderEnvValue("PI_CACHE_RETENTION",env)==="long"?"long":"short")}function getCacheControl(model,cacheRetention,env){let retention=resolveCacheRetention(cacheRetention,env);if(retention==="none")return{retention};let ttl=retention==="long"&&getAnthropicCompat(model).supportsLongCacheRetention?"1h":void 0;return{retention,cacheControl:{type:"ephemera\
|
|
5
|
-
l",...ttl&&{ttl}}}}var claudeCodeVersion="2.1.280",claudeCodeTools=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],ccToolLookup=new Map(claudeCodeTools.map(t=>[t.toLowerCase(),t])),toClaudeCodeName=name=>ccToolLookup.get(name.toLowerCase())??name,fromClaudeCodeName=(name,tools)=>{if(tools&&tools.length>0){let lowerName=name.toLowerCase(),matchedTool=tools.find(tool=>tool.
|
|
6
|
-
name.toLowerCase()===lowerName);if(matchedTool)return matchedTool.name}return name};function convertImageBlock(image){return{type:"image",source:{type:"base64",media_type:image.mimeType,data:image.data}}}function convertContentBlocks(content){if(!content.some(c=>c.type==="image"))return sanitizeSurrogates(content.map(c=>c.text).join(`
|
|
7
|
-
`));let blocks=content.map(block=>block.type==="text"?{type:"text",text:sanitizeSurrogates(block.text)}:convertImageBlock(block));return blocks.some(b=>b.type==="text")||blocks.unshift({type:"text",text:"(see attached image)"}),blocks}var FINE_GRAINED_TOOL_STREAMING_BETA="fine-grained-tool-streaming-2025-05-14",INTERLEAVED_THINKING_BETA="interleaved-thinking-2025-05-14",SERVER_SIDE_FALLBACK_BETA="server-side-fallback-2026-07-01",MID_CONVERSATION_OUTPUT_CONFIG_BETA="mid-conversation-output-config\
|
|
8
|
-
-2026-07-01",THINKING_BINDING_CONTROLS_BETA="thinking-binding-controls-2026-08-01",INLINE_TOOLS_BETA="inline-tools-2026-09-15",DEFERRED_TOOL_PLACEHOLDER={name:"__pi_deferred_placeholder__",description:"Reserved placeholder. Never available. Never call this.",input_schema:{type:"object",properties:{},required:[]},defer_loading:!0};function shouldUseServerSideFallbackBeta(model){return(model.compat?.allowedFallbackModels?.length??0)>0}function getAnthropicCompat(model){let isOpenRouter=model.provider===
|
|
9
|
-
"openrouter"||model.baseUrl.includes("openrouter.ai");return{supportsEagerToolInputStreaming:model.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:model.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:model.compat?.sendSessionAffinityHeaders??isOpenRouter,sessionAffinityFormat:model.compat?.sessionAffinityFormat??(isOpenRouter?"openrouter":void 0),supportsCacheControlOnTools:model.compat?.supportsCacheControlOnTools??!0,supportsTemperature:model.compat?.supportsTemperature??
|
|
10
|
-
!0,allowEmptySignature:model.compat?.allowEmptySignature??!1,supportsStrictTools:model.compat?.supportsStrictTools??!1,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsMidConvoToolChanges:model.compat?.supportsMidConvoToolChanges??!1}}function mergeHeaders(...headerSources){let merged={};for(let headers of headerSources)headers&&Object.assign(merged,headers);return merged}function mergeClientHeaders(...headerSources){return mergeHeaders({"User-Agent":getPiUserAgent()},
|
|
11
|
-
...headerSources)}function hasHeader(headers,name){if(!headers)return!1;let expected=name.toLowerCase();for(let[key,value]of Object.entries(headers))if(key.toLowerCase()===expected&&value!==null&&value.trim().length>0)return!0;return!1}function hasRequestAuth(apiKey,headers){return!!apiKey||hasHeader(headers,"authorization")||hasHeader(headers,"x-api-key")||hasHeader(headers,"cf-aig-authorization")}function assertRequestAuth(provider,apiKey,headers){if(!hasRequestAuth(apiKey,headers))throw new Error(
|
|
12
|
-
`No API key for provider: ${provider}`)}var PiAnthropic=class extends Anthropic{_shouldResolveDefaultCredentials(){return!1}};function getAnthropicFederation(model,apiKey,headers,env){if(model.provider!=="anthropic"||hasRequestAuth(apiKey,headers))return;let federationRuleId=getProviderEnvValue(ANTHROPIC_FEDERATION_RULE_ID_ENV,env),organizationId=getProviderEnvValue(ANTHROPIC_ORGANIZATION_ID_ENV,env),identityTokenFile=getProviderEnvValue(ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,env);if(!(!federationRuleId||
|
|
13
|
-
!organizationId||!identityTokenFile))return{organization_id:organizationId,workspace_id:getProviderEnvValue(ANTHROPIC_WORKSPACE_ID_ENV,env),authentication:{type:"oidc_federation",federation_rule_id:federationRuleId,service_account_id:getProviderEnvValue(ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,env),identity_token:{source:"file",path:identityTokenFile}}}}var federationClient,ANTHROPIC_MESSAGE_EVENTS=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","conte\
|
|
14
|
-
nt_block_stop"]);async function*iterateAnthropicEvents(response,signal){if(!response.body)throw new Error("Attempted to iterate over an Anthropic response with no body");let sawMessageStart=!1,sawMessageEnd=!1;for await(let sse of iterateSseMessages(response.body,{signal})){if(sse.event==="error")throw new Error(sse.data);if(ANTHROPIC_MESSAGE_EVENTS.has(sse.event??""))try{let event=parseJsonWithRepair(sse.data);event.type==="message_start"?sawMessageStart=!0:event.type==="message_stop"&&(sawMessageEnd=
|
|
15
|
-
!0),yield event}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Could not parse Anthropic SSE event ${sse.event}: ${message}; data=${sse.data}; raw=${sse.raw.join("\\n")}`)}}if(sawMessageStart&&!sawMessageEnd)throw new Error("Anthropic stream ended before message_stop")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,getAnthropicCompat(model).supportsMidConvoSystemMessages),currentTools=getCurrentTools(
|
|
16
|
-
normalizedContext.messages);return(async()=>{let output={role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:{usageIncomplete:!0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let client,isOAuth,usageModel=model,inputUsageIncomplete=!0,optionalUsage={},inputTransformations,suppliedClient=options?.client;if(suppliedClient)client=suppliedClient,isOAuth=
|
|
17
|
-
!1;else{let apiKey=options?.apiKey,federation=getAnthropicFederation(model,apiKey,options?.headers,options?.env);federation||assertRequestAuth(model.provider,apiKey,options?.headers);let copilotDynamicHeaders;if(model.provider==="github-copilot"){let hasImages=hasCopilotVisionInput(normalizedContext.messages);copilotDynamicHeaders=buildCopilotDynamicHeaders({messages:normalizedContext.messages,hasImages})}let cacheSessionId=resolveCacheRetention(options?.cacheRetention,options?.env)==="none"?void 0:
|
|
18
|
-
options?.sessionId,created=createClient(model,apiKey,options?.headers,options?.fetch,copilotDynamicHeaders,cacheSessionId,federation);client=created.client,isOAuth=created.isOAuthToken}let observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),observeMiddleware=async(request,next,ctx)=>(ctx.options!==void 0&&typeof request.body=="string"&&await observe(request.body),next(request)),requestOptions={...options?.signal?{signal:options.signal}:{},
|
|
19
|
-
...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},...options?.onRequest?{middleware:[observeMiddleware]}:{},maxRetries:0},disablePreferredStrictTools=!1,usedPayloadHook=!1,response;for(;;){options?.signal?.throwIfAborted();let built=buildParams(model,normalizedContext,isOAuth,options,disablePreferredStrictTools);built.providerThinkingLevel&&(output.providerThinkingLevel=built.providerThinkingLevel);let params=built.params,onPayload=options?.onPayload;usedPayloadHook||=!!onPayload;let nextParams=await onPayload?.
|
|
20
|
-
call(options,params,model);nextParams!==void 0&&(params={...nextParams,stream:!0}),!usedPayloadHook&&!suppliedClient&&cacheJsonSerialization(params.messages);try{response=await retryProviderRequest(()=>client.beta.messages.create(params,requestOptions).asResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});break}catch(error){if(options?.signal?.aborted||disablePreferredStrictTools||!built.hasPreferredStrictTools||!(error instanceof Anthropic.
|
|
21
|
-
APIError)||error.status!==400||error.type!=="invalid_request_error"||!["The compiled grammar is too large","Too many strict tools (","Schemas contains too many parameters with union types ("].some(message=>error.message.includes(message)))throw error;disablePreferredStrictTools=!0,appendAssistantMessageDiagnostic(output,{type:"anthropic_strict_tools_fallback",timestamp:Date.now(),error:{message:error.message},details:{reason:"strict_tool_limits_exceeded"}})}}await options?.onResponse?.({status:response.
|
|
22
|
-
status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output});let blocks=output.content;for await(let event of iterateAnthropicEvents(response,options?.signal))if(await options?.onProviderStreamEvent?.(event,model),event.type==="message_start"){output.responseId=event.message.id;let transformations=event.message.input_transformations;Array.isArray(transformations)&&(inputTransformations=transformations);let responseModel=event.message.model;responseModel!==
|
|
23
|
-
model.id&&(output.responseModel=responseModel);let fallbackCost=responseModel===model.id?void 0:model.compat?.allowedFallbackModels?.find(fallback=>fallback.provider===model.provider&&fallback.model===responseModel)?.cost;usageModel=fallbackCost?{...model,id:responseModel,cost:fallbackCost}:model,inputUsageIncomplete=hasIncompleteUsage([event.message.usage?.input_tokens]),optionalUsage.cacheRead=event.message.usage?.cache_read_input_tokens,optionalUsage.cacheWrite=event.message.usage?.cache_creation_input_tokens,
|
|
24
|
-
optionalUsage.cacheWrite1h=event.message.usage?.cache_creation?.ephemeral_1h_input_tokens,output.usage.input=event.message.usage?.input_tokens||0,output.usage.output=event.message.usage?.output_tokens||0,output.usage.cacheRead=event.message.usage?.cache_read_input_tokens||0,output.usage.cacheWrite=event.message.usage?.cache_creation_input_tokens||0,output.usage.cacheWrite1h=event.message.usage?.cache_creation?.ephemeral_1h_input_tokens||0,output.usage.totalTokens=output.usage.input+output.usage.
|
|
25
|
-
output+output.usage.cacheRead+output.usage.cacheWrite,calculateCost(usageModel,output.usage)}else if(event.type==="content_block_start"){if(event.content_block.type==="fallback"){if(output.content.length>0)throw new Error("Anthropic performed an unsupported mid-output model fallback");continue}if(event.content_block.type==="text"){let block={type:"text",text:event.content_block.text??"",index:event.index};output.content.push(block),stream2.push({type:"text_start",contentIndex:output.content.length-
|
|
26
|
-
1,partial:output})}else if(event.content_block.type==="thinking"){let block={type:"thinking",thinking:event.content_block.thinking??"",thinkingSignature:event.content_block.signature??"",index:event.index};output.content.push(block),stream2.push({type:"thinking_start",contentIndex:output.content.length-1,partial:output})}else if(event.content_block.type==="redacted_thinking"){let block={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:event.content_block.data,redacted:!0,index:event.
|
|
27
|
-
index};output.content.push(block),stream2.push({type:"thinking_start",contentIndex:output.content.length-1,partial:output})}else if(event.content_block.type==="tool_use"){let block={type:"toolCall",id:event.content_block.id,name:isOAuth?fromClaudeCodeName(event.content_block.name,currentTools):event.content_block.name,arguments:event.content_block.input??{},partialJson:"",index:event.index};output.content.push(block),stream2.push({type:"toolcall_start",contentIndex:output.content.length-1,partial:output})}}else if(event.
|
|
28
|
-
type==="content_block_delta"){if(event.delta.type==="text_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="text"&&(block.text+=event.delta.text,stream2.push({type:"text_delta",contentIndex:index,delta:event.delta.text,partial:output}))}else if(event.delta.type==="thinking_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="thinking"&&(block.thinking+=event.delta.thinking,stream2.push({type:"thi\
|
|
29
|
-
nking_delta",contentIndex:index,delta:event.delta.thinking,partial:output}))}else if(event.delta.type==="input_json_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="toolCall"&&(block.partialJson+=event.delta.partial_json,block.arguments=parseStreamingJsonWhileStreaming(block,block.partialJson,block.arguments),stream2.push({type:"toolcall_delta",contentIndex:index,delta:event.delta.partial_json,partial:output}))}else if(event.delta.type==="sign\
|
|
30
|
-
ature_delta"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&block.type==="thinking"&&(block.thinkingSignature=block.thinkingSignature||"",block.thinkingSignature+=event.delta.signature)}}else if(event.type==="content_block_stop"){let index=blocks.findIndex(b=>b.index===event.index),block=blocks[index];block&&(delete block.index,block.type==="text"?stream2.push({type:"text_end",contentIndex:index,content:block.text,partial:output}):block.type==="thinking"?stream2.
|
|
31
|
-
push({type:"thinking_end",contentIndex:index,content:block.thinking,partial:output}):block.type==="toolCall"&&(Object.assign(block,parseToolCallArguments(block.partialJson)),delete block.partialJson,stream2.push({type:"toolcall_end",contentIndex:index,toolCall:block,partial:output})))}else if(event.type==="message_delta"){let transformations=event.input_transformations;if(Array.isArray(transformations)&&(inputTransformations=transformations),event.delta.stop_reason){output.rawStopReason=event.delta.
|
|
32
|
-
stop_reason;let stopReasonResult=mapStopReason(event.delta.stop_reason,event.delta.stop_details);output.stopReason=stopReasonResult.stopReason,stopReasonResult.errorMessage&&(output.errorMessage=stopReasonResult.errorMessage)}if(event.usage){event.usage.input_tokens!=null&&(output.usage.input=event.usage.input_tokens,inputUsageIncomplete=hasIncompleteUsage([event.usage.input_tokens])),event.usage.output_tokens!=null&&(output.usage.output=event.usage.output_tokens),event.usage.cache_read_input_tokens!==
|
|
33
|
-
void 0&&(optionalUsage.cacheRead=event.usage.cache_read_input_tokens),event.usage.cache_read_input_tokens!=null&&(output.usage.cacheRead=event.usage.cache_read_input_tokens),event.usage.cache_creation_input_tokens!==void 0&&(optionalUsage.cacheWrite=event.usage.cache_creation_input_tokens),event.usage.cache_creation_input_tokens!=null&&(output.usage.cacheWrite=event.usage.cache_creation_input_tokens);let cacheCreation=event.usage.cache_creation;cacheCreation?.ephemeral_1h_input_tokens!==void 0&&
|
|
34
|
-
(optionalUsage.cacheWrite1h=cacheCreation.ephemeral_1h_input_tokens),cacheCreation?.ephemeral_1h_input_tokens!=null&&(output.usage.cacheWrite1h=cacheCreation.ephemeral_1h_input_tokens);let thinkingTokens=event.usage.output_tokens_details?.thinking_tokens;thinkingTokens!==void 0&&(optionalUsage.reasoning=thinkingTokens),event.delta.stop_reason&&(output.usage.usageIncomplete=inputUsageIncomplete||hasIncompleteUsage([event.usage.output_tokens],[event.usage.input_tokens,...Object.values(optionalUsage)])),
|
|
35
|
-
thinkingTokens!=null&&(output.usage.reasoning=thinkingTokens)}output.usage.totalTokens=output.usage.input+output.usage.output+output.usage.cacheRead+output.usage.cacheWrite,output.usage.usageIncomplete||=hasIncompleteUsage([output.usage.totalTokens]),calculateCost(usageModel,output.usage)}if(options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Anthropic stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason===
|
|
36
|
-
"error")throw new Error(output.errorMessage||"An unknown error occurred");for(let block of blocks)if(block.type==="toolCall"&&block.partialJson!==void 0){if(output.stopReason!=="length")throw new Error(`Anthropic stream completed with an unfinished tool call: ${block.name} (${block.id})`);block.arguments=parseStreamingJson(block.partialJson),delete block.partialJson}inputTransformations&&inputTransformations.length>0&&appendAssistantMessageDiagnostic(output,{type:"anthropic_input_transformations",
|
|
37
|
-
timestamp:Date.now(),details:{transformations:inputTransformations.map(transformation=>({type:transformation.type??void 0,path:transformation.path??void 0,reason:transformation.reason??void 0}))}}),stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){for(let block of output.content){delete block.index;let partialJson=block.partialJson;block.type==="toolCall"&&partialJson!==void 0&&(block.arguments=parseStreamingJson(partialJson)),delete block.partialJson}
|
|
38
|
-
output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=error instanceof Error?error.message:JSON.stringify(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2};function mapThinkingLevelToEffort(model,level){let mapped=level?model.thinkingLevelMap?.[level]:void 0;if(typeof mapped=="string")return mapped;switch(level){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}
|
|
39
|
-
var streamSimple=(model,context,options)=>{getAnthropicFederation(model,options?.apiKey,options?.headers,options?.env)||assertRequestAuth(model.provider,options?.apiKey,options?.headers);let base={...buildBaseOptions(model,context,options,options?.apiKey),toolChoice:options?.toolChoice};if(!options?.reasoning)return stream(model,context,{...base,thinkingEnabled:!1});if(model.compat?.forceAdaptiveThinking===!0){let effort=mapThinkingLevelToEffort(model,options.reasoning);return stream(model,context,
|
|
40
|
-
{...base,thinkingEnabled:!0,effort})}let adjusted=adjustMaxTokensForThinking(base.maxTokens,model.maxTokens,options.reasoning,options.thinkingBudgets),maxTokens=clampMaxTokensToContext(model,context,adjusted.maxTokens);return stream(model,context,{...base,maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(adjusted.thinkingBudget,Math.max(0,maxTokens-1024))})};function isOAuthToken(apiKey){return apiKey.startsWith("sk-ant-oat")}function createClient(model,apiKey,optionsHeaders,fetch,dynamicHeaders,sessionId,federation){
|
|
41
|
-
if(model.provider==="github-copilot")return{client:new PiAnthropic({apiKey:null,authToken:apiKey??null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeClientHeaders({accept:"application/json","anthropic-dangerous-direct-browser-access":"true"},model.headers,dynamicHeaders,optionsHeaders)}),isOAuthToken:!1};if(apiKey&&isOAuthToken(apiKey))return{client:new PiAnthropic({apiKey:null,authToken:apiKey,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeClientHeaders(
|
|
42
|
-
{accept:"application/json","anthropic-dangerous-direct-browser-access":"true","user-agent":`claude-cli/${claudeCodeVersion}`,"x-app":"cli"},model.headers,optionsHeaders)}),isOAuthToken:!0};let compat=getAnthropicCompat(model),sessionAffinityHeaders={};if(sessionId&&compat.sendSessionAffinityHeaders){let header=compat.sessionAffinityFormat==="openrouter"?"x-session-id":"x-session-affinity";sessionAffinityHeaders[header]=sessionId}let defaultHeaders=mergeClientHeaders({accept:"application/json","a\
|
|
43
|
-
nthropic-dangerous-direct-browser-access":"true"},sessionAffinityHeaders,model.headers,optionsHeaders);if(federation){let key=JSON.stringify([model.baseUrl,federation]);if(federationClient?.key!==key||federationClient.fetch!==fetch){let client2=new PiAnthropic({apiKey:null,authToken:null,config:federation,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch});federationClient={key,fetch,client:client2}}return{client:federationClient.client.withOptions({defaultHeaders}),isOAuthToken:!1}}return{
|
|
44
|
-
client:new PiAnthropic({apiKey:apiKey??null,authToken:null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders}),isOAuthToken:!1}}function getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options){let configuredFeatures;for(let headers of[model.headers,options?.headers])for(let[name,value]of Object.entries(headers??{}))name.toLowerCase()==="anthropic-beta"&&(configuredFeatures=value);if(configuredFeatures===null)return[];if(configuredFeatures!==void 0)return[...new Set(
|
|
45
|
-
configuredFeatures.split(",").map(feature=>feature.trim()).filter(feature=>feature.length>0))];let features=[];return isOAuthToken2&&features.push("claude-code-20250219","oauth-2025-04-20"),shouldUseFineGrainedToolStreamingBeta(model,context)&&features.push(FINE_GRAINED_TOOL_STREAMING_BETA),model.reasoning&&options?.thinkingEnabled===!0&&(options.interleavedThinking??!0)&&model.compat?.forceAdaptiveThinking!==!0&&features.push(INTERLEAVED_THINKING_BETA),shouldUseServerSideFallbackBeta(model)&&features.
|
|
46
|
-
push(SERVER_SIDE_FALLBACK_BETA),model.compat?.supportsMidConvoEffort===!0&&features.push(MID_CONVERSATION_OUTPUT_CONFIG_BETA,THINKING_BINDING_CONTROLS_BETA),nativeToolChanges&&features.push(INLINE_TOOLS_BETA),[...new Set(features)]}function buildParams(model,context,isOAuthToken2,options,disablePreferredStrictTools=!1){let{cacheControl}=getCacheControl(model,options?.cacheRetention,options?.env),compat=getAnthropicCompat(model),initialSystemMessage=getInitialSystemMessage(context.messages),initialSystemText=initialSystemMessage?
|
|
47
|
-
getSystemMessageText(initialSystemMessage):"",transformedMessages=transformMessages(context.messages,model,normalizeToolCallId),conversationMessages=initialSystemMessage?transformedMessages.slice(1):transformedMessages,hasPreferredStrictTools=!1,convertToolDefinitions=(tools,toolCacheControl2)=>{let definitions=convertTools(tools,isOAuthToken2,compat.supportsEagerToolInputStreaming,compat.supportsStrictTools,toolCacheControl2,disablePreferredStrictTools);return definitions.some((definition,index)=>{
|
|
48
|
-
let config=tools[index].constrainedSampling;return definition.strict===!0&&config&&config.type==="json_schema"&&config.strict==="prefer"})&&(hasPreferredStrictTools=!0),definitions},initialTools=initialSystemMessage?.toolsAdded??[],nativeToolChanges=compat.supportsMidConvoSystemMessages&&compat.supportsMidConvoToolChanges&&initialTools.length>0,thinkingDisabled=model.reasoning&&options?.thinkingEnabled===!1&&model.thinkingLevelMap?.off!==null,effortMessages=model.compat?.supportsMidConvoEffort===
|
|
49
|
-
!0&&!thinkingDisabled,converted=convertMessages(conversationMessages,isOAuthToken2,cacheControl,compat.allowEmptySignature,effortMessages?model.provider:void 0,nativeToolChanges?convertToolDefinitions:void 0),activeEffort=options?.effort??"high",betaFeatures=getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options),params={model:model.id,messages:effortMessages?insertThinkingLevelMessages(converted,activeEffort):converted.messages,max_tokens:options?.maxTokens??model.maxTokens,stream:!0,
|
|
50
|
-
...betaFeatures.length>0?{betas:betaFeatures}:{}};isOAuthToken2?(params.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...cacheControl?{cache_control:cacheControl}:{}}],initialSystemText&¶ms.system.push({type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}})):initialSystemText&&(params.system=[{type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}}]),options?.
|
|
51
|
-
temperature!==void 0&&!options?.thinkingEnabled&&model.compat?.supportsMidConvoEffort!==!0&&compat.supportsTemperature&&(params.temperature=options.temperature);let toolCacheControl=compat.supportsCacheControlOnTools?cacheControl:void 0;if(nativeToolChanges)params.tools=[...convertToolDefinitions(initialTools,toolCacheControl),DEFERRED_TOOL_PLACEHOLDER];else{let tools=getCurrentTools(context.messages);tools.length>0&&(params.tools=convertToolDefinitions(tools,toolCacheControl))}if(thinkingDisabled)
|
|
52
|
-
params.thinking={type:"disabled"};else if(effortMessages)params.thinking={type:"adaptive",display:options?.thinkingDisplay??"summarized",block_binding:{prefix_mismatch_behavior:"drop_block"}},params.output_config={effort:"high"};else if(model.reasoning&&options?.thinkingEnabled){let display=options.thinkingDisplay??"summarized";model.compat?.forceAdaptiveThinking===!0?(params.thinking={type:"adaptive",display},options.effort&&(params.output_config={effort:options.effort})):params.thinking={type:"\
|
|
53
|
-
enabled",budget_tokens:options.thinkingBudgetTokens||1024,display}}if(options?.metadata){let userId=options.metadata.user_id;typeof userId=="string"&&(params.metadata={user_id:userId})}options?.toolChoice&&(typeof options.toolChoice=="string"?params.tool_choice={type:options.toolChoice}:params.tool_choice=options.toolChoice);let allowedFallbackModels=model.compat?.allowedFallbackModels;return allowedFallbackModels&&allowedFallbackModels.length>0&&(params.fallbacks=allowedFallbackModels.map(fallback=>({
|
|
54
|
-
model:fallback.model}))),{params,hasPreferredStrictTools,providerThinkingLevel:effortMessages?activeEffort:void 0}}function normalizeToolCallId(id){return id.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function convertToolResult(msg,content=msg.content){return{type:"tool_result",tool_use_id:msg.toolCallId,content:convertContentBlocks(content),is_error:msg.isError}}function convertMessages(transformedMessages,isOAuthToken2,cacheControl,allowEmptySignature=!1,managedProvider,convertToolDefinitions){
|
|
55
|
-
let params=[],assistantLevels=new Map,pendingSystemMessages=[],flushPendingSystemMessages=()=>{params.push(...pendingSystemMessages),pendingSystemMessages.length=0};for(let i=0;i<transformedMessages.length;i++){let msg=transformedMessages[i];if(msg.role==="system"){let text=renderSystemMessageUpdate(msg),blocks=[];if(text.length>0&&blocks.push({type:"text",text:sanitizeSurrogates(text)}),convertToolDefinitions){let added=msg.toolsAdded??[],redefined=new Set(added.map(tool=>tool.name));for(let tool of msg.
|
|
56
|
-
toolsRemoved??[])redefined.has(tool.name)||blocks.push({type:"tool_removal",tool:{type:"tool_reference",name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name}});for(let definition of convertToolDefinitions(added))blocks.push({type:"tool_addition",tool:{type:"tool_definition",definition}})}blocks.length>0&&pendingSystemMessages.push({role:"system",content:blocks})}else if(msg.role==="user")if(typeof msg.content=="string")msg.content.trim().length>0&¶ms.push({role:"user",content:sanitizeSurrogates(
|
|
57
|
-
msg.content)});else{let filteredBlocks=msg.content.map(item=>item.type==="text"?{type:"text",text:sanitizeSurrogates(item.text)}:convertImageBlock(item)).filter(b=>b.type==="text"?b.text.trim().length>0:!0);if(filteredBlocks.length===0)continue;params.push({role:"user",content:filteredBlocks})}else if(msg.role==="assistant"){flushPendingSystemMessages();let blocks=[];for(let block of msg.content)if(block.type==="text"){if(block.text.trim().length===0)continue;blocks.push({type:"text",text:sanitizeSurrogates(
|
|
58
|
-
block.text)})}else if(block.type==="thinking"){if(block.redacted){blocks.push({type:"redacted_thinking",data:block.thinkingSignature});continue}let thinkingSignature=block.thinkingSignature,hasThinkingSignature=!!thinkingSignature&&thinkingSignature.trim().length>0;if(block.thinking.trim().length===0&&!hasThinkingSignature)continue;hasThinkingSignature?blocks.push({type:"thinking",thinking:sanitizeSurrogates(block.thinking),signature:thinkingSignature}):blocks.push(allowEmptySignature?{type:"thi\
|
|
59
|
-
nking",thinking:sanitizeSurrogates(block.thinking),signature:""}:{type:"text",text:sanitizeSurrogates(block.thinking)})}else block.type==="toolCall"&&blocks.push({type:"tool_use",id:block.id,name:isOAuthToken2?toClaudeCodeName(block.name):block.name,input:block.arguments??{}});if(blocks.length===0)continue;let messageIndex=params.length;params.push({role:"assistant",content:blocks}),managedProvider!==void 0&&msg.api==="anthropic-messages"&&msg.provider===managedProvider&&isAnthropicEffort(msg.providerThinkingLevel)&&
|
|
60
|
-
assistantLevels.set(messageIndex,msg.providerThinkingLevel)}else if(msg.role==="toolResult"){let toolResults=[],errorImages=[],j=i;for(;j<transformedMessages.length&&transformedMessages[j].role==="toolResult";){let toolMsg=transformedMessages[j],split=splitErrorToolResultImages(toolMsg);toolResults.push(convertToolResult(toolMsg,split?.content)),split&&errorImages.push({type:"text",text:split.caption},...split.images.map(convertImageBlock)),j++}i=j-1,params.push({role:"user",content:[...toolResults,
|
|
61
|
-
...errorImages]})}}if(flushPendingSystemMessages(),cacheControl&¶ms.length>0){let lastMessage=params[params.length-1];if(lastMessage.role==="user"||lastMessage.role==="system")if(Array.isArray(lastMessage.content)){let lastBlock=lastMessage.content[lastMessage.content.length-1];lastBlock&&(lastBlock.type==="text"||lastBlock.type==="image"||lastBlock.type==="tool_result"||lastBlock.type==="tool_addition"||lastBlock.type==="tool_removal")&&(lastBlock.cache_control=cacheControl)}else typeof lastMessage.
|
|
62
|
-
content=="string"&&(lastMessage.content=[{type:"text",text:lastMessage.content,cache_control:cacheControl}])}return{messages:params,assistantLevels}}function isAnthropicEffort(value){return value==="low"||value==="medium"||value==="high"||value==="xhigh"||value==="max"}function insertThinkingLevelMessages(converted,activeEffort){let messages=[];for(let index=0;index<converted.messages.length;index++){let historicalEffort=converted.assistantLevels.get(index);historicalEffort!==void 0&&messages.push(
|
|
63
|
-
{role:"system",content:[],output_config:{effort:historicalEffort}}),messages.push(converted.messages[index])}return messages.push({role:"system",content:[],output_config:{effort:activeEffort}}),messages}function shouldUseFineGrainedToolStreamingBeta(model,context){return getCurrentTools(context.messages).length>0&&!getAnthropicCompat(model).supportsEagerToolInputStreaming}var ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS=new Set(["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","ma\
|
|
64
|
-
xItems","uniqueItems","minContains","maxContains","minProperties","maxProperties"]),ANTHROPIC_STRICT_STRING_FORMATS=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),isAnthropicStrictUnsupportedKeyword=(key,value)=>ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS.has(key)?!0:key==="minItems"?value!==0&&value!==1:key==="format"?typeof value!="string"||!ANTHROPIC_STRICT_STRING_FORMATS.has(value):!1;function convertTools(tools,isOAuthToken2,supportsEagerToolInputStreaming,supportsStrictTools,cacheControl,disablePreferredStrictTools=!1){
|
|
65
|
-
return tools?tools.map((tool,index)=>{let config=tool.constrainedSampling,strict=disablePreferredStrictTools&&config&&config.type==="json_schema"&&config.strict==="prefer"?void 0:resolveJsonSchemaStrictSampling(tool,supportsStrictTools,isAnthropicStrictUnsupportedKeyword),parameters=getJsonSchemaToolParameters(tool,strict),schema=parameters,legacyInputSchema={type:"object",properties:schema.properties??{},required:schema.required??[]},inputSchema=strict===!0?{...parameters,...legacyInputSchema}:
|
|
66
|
-
legacyInputSchema;return{name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name,description:tool.description,...supportsEagerToolInputStreaming?{eager_input_streaming:!0}:{},...strict===!0?{strict:!0}:{},input_schema:inputSchema,...cacheControl&&index===tools.length-1?{cache_control:cacheControl}:{}}}):[]}function mapStopReason(reason,stopDetails){switch(reason){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"\
|
|
67
|
-
refusal":return{stopReason:"error",errorMessage:stopDetails?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error",errorMessage:"Provider stopped with: sensitive"};default:throw new Error(`Unhandled stop reason: ${reason}`)}}export{stream,streamSimple};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{convertResponsesMessages,convertResponsesTools,processResponsesStream}from"./chunk-V76YPIMT.js";import{iterateOpenAIStream}from"./chunk-RXOCQRBG.js";import{clampOpenAIPromptCacheKey}from"./chunk-PRRNXB7S.js";import{AzureOpenAI}from"./chunk-7PRU6YW3.js";import"./chunk-YZMQXAJM.js";import{retryProviderRequest}from"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import"./chunk-PJACZCIR.js";import{
|
|
3
|
-
cacheJsonSerialization}from"./chunk-Q7VXYXY3.js";import{buildBaseOptions,createGrammarToolInputProperties,getPiUserAgent,resolveSamplingParams}from"./chunk-TIFFHHW6.js";import"./chunk-YTVFIA3A.js";import"./chunk-L2ZPNLYD.js";import{createRequestObserver,headersToRecord,observeFetch}from"./chunk-5CDES42D.js";import{resolveAzureConfig,resolveDeploymentName}from"./chunk-CIA6V3BP.js";import"./chunk-FACBDLFU.js";import"./chunk-YDBNMIA3.js";import{clampThinkingLevel,
|
|
4
|
-
getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-5K5RFXXO.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import"./chunk-VEYTRNQC.js";import"./chunk-JXWJOIH4.js";var AZURE_TOOL_CALL_PROVIDERS=new Set(["openai","openai-codex","opencode","azure"]),OPENAI_RESPONSES_MIN_OUTPUT_TOKENS=16;function formatAzureOpenAIError(error){return formatProviderError(normalizeProviderError(error),"Azure OpenAI API error")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,model.compat?.supportsMidConvoSystemMessages);return(async()=>{let deploymentName=resolveDeploymentName(model,options),output={role:"\
|
|
5
|
-
assistant",content:[],api:"azure-openai-responses",provider:model.provider,model:model.id,usage:{usageIncomplete:!0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),client=createClient(
|
|
6
|
-
model,apiKey,options,observeFetch(options?.fetch,observe)),grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages),model.compat?.supportsOpenAIGrammarTools??!1),params=buildParams(model,normalizedContext,options,deploymentName,grammarToolInputProperties),onPayload=options?.onPayload,nextParams=await onPayload?.call(options,params,model);nextParams!==void 0&&(params=nextParams),onPayload||cacheJsonSerialization(params.input);let requestOptions={...options?.
|
|
7
|
-
signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},maxRetries:0},{data:openaiStream,response}=await retryProviderRequest(()=>client.responses.create(params,requestOptions).withResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});if(await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output}),await processResponsesStream(
|
|
8
|
-
iterateOpenAIStream(openaiStream,response,client),output,stream2,model,{onProviderStreamEvent:options?.onProviderStreamEvent,grammarToolInputProperties}),options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");stream2.push({type:"done",reason:output.stopReason,
|
|
9
|
-
message:output}),stream2.end()}catch(error){for(let block of output.content)delete block.index,delete block.partialJson,delete block.customInput;output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=formatAzureOpenAIError(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2},streamSimple=(model,context,options)=>{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let base={
|
|
10
|
-
...buildBaseOptions(model,context,options,apiKey),toolChoice:options?.toolChoice},clampedReasoning=options?.reasoning?clampThinkingLevel(model,options.reasoning):void 0;return stream(model,context,{...base,reasoningEffort:clampedReasoning==="off"?void 0:clampedReasoning})};function createClient(model,apiKey,options,fetch){let headers={"User-Agent":getPiUserAgent(),...model.headers};options?.headers&&Object.assign(headers,options.headers);let{baseUrl,apiVersion}=resolveAzureConfig(model,options);
|
|
11
|
-
return new AzureOpenAI({apiKey,apiVersion,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:headers,baseURL:baseUrl})}function buildParams(model,context,options,deploymentName,grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(context.messages),model.compat?.supportsOpenAIGrammarTools??!1)){let supportsAdditionalTools=model.compat?.supportsAdditionalTools??!1,supportsToolSearch=model.compat?.supportsToolSearch??!1,transcriptTools=resolveTranscriptTools(context.messages,supportsAdditionalTools||
|
|
12
|
-
supportsToolSearch),messages=convertResponsesMessages(model,context,AZURE_TOOL_CALL_PROVIDERS,{grammarToolInputProperties,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools,supportsToolSearch,toolOptions:{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1}}),params={model:deploymentName,input:messages,stream:!0,prompt_cache_key:clampOpenAIPromptCacheKey(options?.sessionId),
|
|
13
|
-
store:!1};options?.maxTokens&&(params.max_output_tokens=Math.max(options.maxTokens,OPENAI_RESPONSES_MIN_OUTPUT_TOKENS)),options?.temperature!==void 0&&(params.temperature=options?.temperature),transcriptTools.requestTools.length>0&&(params.tools=convertResponsesTools(transcriptTools.requestTools,{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1})),options?.toolChoice!==void 0&&(params.tool_choice=options.toolChoice);let reasoningEffort=options?.
|
|
14
|
-
reasoningEffort??(options?.reasoningSummary?"medium":void 0);if(model.reasoning)if(reasoningEffort){let effort=options?.reasoningEffort?model.thinkingLevelMap?.[options.reasoningEffort]??options.reasoningEffort:reasoningEffort;params.reasoning={effort,summary:options?.reasoningSummary||"auto"},params.include=["reasoning.encrypted_content"]}else model.thinkingLevelMap?.off!==null&&(params.reasoning={effort:model.thinkingLevelMap?.off??"none"});let samplingParams=resolveSamplingParams(model,reasoningEffort??
|
|
15
|
-
"off",options?.samplingParams);return samplingParams&&Object.assign(params,samplingParams),params}export{stream,streamSimple};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{__commonJS,__esm,__export,__require}from"./chunk-JXWJOIH4.js";var require_StyleSheet=__commonJS({"node_modules/cssom/lib/StyleSheet.js"(exports){var CSSOM={};CSSOM.StyleSheet=function(){this.parentStyleSheet=null};exports.StyleSheet=CSSOM.StyleSheet}});var require_CSSRule=__commonJS({"node_modules/cssom/lib/CSSRule.js"(exports){var CSSOM={};CSSOM.CSSRule=function(){this.parentRule=null,this.parentStyleSheet=null};CSSOM.CSSRule.UNKNOWN_RULE=0;CSSOM.CSSRule.STYLE_RULE=1;CSSOM.CSSRule.CHARSET_RULE=2;CSSOM.CSSRule.IMPORT_RULE=3;CSSOM.CSSRule.MEDIA_RULE=4;CSSOM.CSSRule.FONT_FACE_RULE=5;CSSOM.CSSRule.PAGE_RULE=6;CSSOM.CSSRule.KEYFRAMES_RULE=7;CSSOM.CSSRule.KEYFRAME_RULE=8;CSSOM.CSSRule.MARGIN_RULE=9;CSSOM.CSSRule.NAMESPACE_RULE=10;CSSOM.CSSRule.COUNTER_STYLE_RULE=
|
|
3
|
-
11;CSSOM.CSSRule.SUPPORTS_RULE=12;CSSOM.CSSRule.DOCUMENT_RULE=13;CSSOM.CSSRule.FONT_FEATURE_VALUES_RULE=14;CSSOM.CSSRule.VIEWPORT_RULE=15;CSSOM.CSSRule.REGION_STYLE_RULE=16;CSSOM.CSSRule.prototype={constructor:CSSOM.CSSRule};exports.CSSRule=CSSOM.CSSRule}});var require_CSSStyleRule=__commonJS({"node_modules/cssom/lib/CSSStyleRule.js"(exports){var CSSOM={CSSStyleDeclaration:require_CSSStyleDeclaration().CSSStyleDeclaration,CSSRule:require_CSSRule().CSSRule};CSSOM.CSSStyleRule=function(){CSSOM.CSSRule.call(this),this.selectorText="",this.style=new CSSOM.CSSStyleDeclaration,this.style.parentRule=this};CSSOM.CSSStyleRule.prototype=new CSSOM.CSSRule;CSSOM.CSSStyleRule.prototype.constructor=CSSOM.CSSStyleRule;CSSOM.CSSStyleRule.prototype.type=1;Object.defineProperty(
|
|
4
|
-
CSSOM.CSSStyleRule.prototype,"cssText",{get:function(){var text;return this.selectorText?text=this.selectorText+" {"+this.style.cssText+"}":text="",text},set:function(cssText){var rule=CSSOM.CSSStyleRule.parse(cssText);this.style=rule.style,this.selectorText=rule.selectorText}});CSSOM.CSSStyleRule.parse=function(ruleText){for(var i=0,state="selector",index,j=i,buffer="",SIGNIFICANT_WHITESPACE={selector:!0,value:!0},styleRule=new CSSOM.CSSStyleRule,name,priority="",character;character=ruleText.charAt(
|
|
5
|
-
i);i++)switch(character){case" ":case" ":case"\r":case`
|
|
6
|
-
`:case"\f":if(SIGNIFICANT_WHITESPACE[state])switch(ruleText.charAt(i-1)){case" ":case" ":case"\r":case`
|
|
7
|
-
`:case"\f":break;default:buffer+=" ";break}break;case'"':if(j=i+1,index=ruleText.indexOf('"',j)+1,!index)throw'" is missing';buffer+=ruleText.slice(i,index),i=index-1;break;case"'":if(j=i+1,index=ruleText.indexOf("'",j)+1,!index)throw"' is missing";buffer+=ruleText.slice(i,index),i=index-1;break;case"/":if(ruleText.charAt(i+1)==="*"){if(i+=2,index=ruleText.indexOf("*/",i),index===-1)throw new SyntaxError("Missing */");i=index+1}else buffer+=character;break;case"{":state==="selector"&&(styleRule.
|
|
8
|
-
selectorText=buffer.trim(),buffer="",state="name");break;case":":state==="name"?(name=buffer.trim(),buffer="",state="value"):buffer+=character;break;case"!":state==="value"&&ruleText.indexOf("!important",i)===i?(priority="important",i+=9):buffer+=character;break;case";":state==="value"?(styleRule.style.setProperty(name,buffer.trim(),priority),priority="",buffer="",state="name"):buffer+=character;break;case"}":if(state==="value")styleRule.style.setProperty(name,buffer.trim(),priority),priority="",
|
|
9
|
-
buffer="";else{if(state==="name")break;buffer+=character}state="selector";break;default:buffer+=character;break}return styleRule};exports.CSSStyleRule=CSSOM.CSSStyleRule}});var require_CSSStyleSheet=__commonJS({"node_modules/cssom/lib/CSSStyleSheet.js"(exports){var CSSOM={StyleSheet:require_StyleSheet().StyleSheet,CSSStyleRule:require_CSSStyleRule().CSSStyleRule};CSSOM.CSSStyleSheet=function(){CSSOM.StyleSheet.call(this),this.cssRules=[]};CSSOM.CSSStyleSheet.prototype=new CSSOM.StyleSheet;CSSOM.CSSStyleSheet.prototype.constructor=CSSOM.CSSStyleSheet;CSSOM.CSSStyleSheet.prototype.insertRule=function(rule,index){if(index<0||index>this.cssRules.length)throw new RangeError(
|
|
10
|
-
"INDEX_SIZE_ERR");var cssRule=CSSOM.parse(rule).cssRules[0];return cssRule.parentStyleSheet=this,this.cssRules.splice(index,0,cssRule),index};CSSOM.CSSStyleSheet.prototype.deleteRule=function(index){if(index<0||index>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(index,1)};CSSOM.CSSStyleSheet.prototype.toString=function(){for(var result="",rules=this.cssRules,i=0;i<rules.length;i++)result+=rules[i].cssText+`
|
|
11
|
-
`;return result};exports.CSSStyleSheet=CSSOM.CSSStyleSheet;CSSOM.parse=require_parse().parse}});var require_MediaList=__commonJS({"node_modules/cssom/lib/MediaList.js"(exports){var CSSOM={};CSSOM.MediaList=function(){this.length=0};CSSOM.MediaList.prototype={constructor:CSSOM.MediaList,get mediaText(){return Array.prototype.join.call(this,", ")},set mediaText(value){for(var values=value.split(","),length=this.length=values.length,i=0;i<length;i++)this[i]=values[i].trim()},appendMedium:function(medium){Array.prototype.indexOf.call(this,medium)===-1&&(this[this.length]=medium,this.length++)},
|
|
12
|
-
deleteMedium:function(medium){var index=Array.prototype.indexOf.call(this,medium);index!==-1&&Array.prototype.splice.call(this,index,1)}};exports.MediaList=CSSOM.MediaList}});var require_CSSImportRule=__commonJS({"node_modules/cssom/lib/CSSImportRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,CSSStyleSheet:require_CSSStyleSheet().CSSStyleSheet,MediaList:require_MediaList().MediaList};CSSOM.CSSImportRule=function(){CSSOM.CSSRule.call(this),this.href="",this.media=new CSSOM.MediaList,this.styleSheet=new CSSOM.CSSStyleSheet};CSSOM.CSSImportRule.prototype=new CSSOM.CSSRule;CSSOM.CSSImportRule.prototype.constructor=CSSOM.CSSImportRule;CSSOM.CSSImportRule.prototype.
|
|
13
|
-
type=3;Object.defineProperty(CSSOM.CSSImportRule.prototype,"cssText",{get:function(){var mediaText=this.media.mediaText;return"@import url("+this.href+")"+(mediaText?" "+mediaText:"")+";"},set:function(cssText){for(var i=0,state="",buffer="",index,character;character=cssText.charAt(i);i++)switch(character){case" ":case" ":case"\r":case`
|
|
14
|
-
`:case"\f":state==="after-import"?state="url":buffer+=character;break;case"@":!state&&cssText.indexOf("@import",i)===i&&(state="after-import",i+=6,buffer="");break;case"u":if(state==="url"&&cssText.indexOf("url(",i)===i){if(index=cssText.indexOf(")",i+1),index===-1)throw i+': ")" not found';i+=4;var url=cssText.slice(i,index);url[0]===url[url.length-1]&&(url[0]==='"'||url[0]==="'")&&(url=url.slice(1,-1)),this.href=url,i=index,state="media"}break;case'"':if(state==="url"){if(index=cssText.indexOf(
|
|
15
|
-
'"',i+1),!index)throw i+`: '"' not found`;this.href=cssText.slice(i+1,index),i=index,state="media"}break;case"'":if(state==="url"){if(index=cssText.indexOf("'",i+1),!index)throw i+`: "'" not found`;this.href=cssText.slice(i+1,index),i=index,state="media"}break;case";":state==="media"&&buffer&&(this.media.mediaText=buffer.trim());break;default:state==="media"&&(buffer+=character);break}}});exports.CSSImportRule=CSSOM.CSSImportRule}});var require_CSSGroupingRule=__commonJS({"node_modules/cssom/lib/CSSGroupingRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule};CSSOM.CSSGroupingRule=function(){CSSOM.CSSRule.call(this),this.cssRules=[]};CSSOM.CSSGroupingRule.prototype=new CSSOM.CSSRule;CSSOM.CSSGroupingRule.prototype.constructor=CSSOM.CSSGroupingRule;CSSOM.CSSGroupingRule.prototype.insertRule=function(rule,index){if(index<0||index>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var cssRule=CSSOM.parse(rule).
|
|
16
|
-
cssRules[0];return cssRule.parentRule=this,this.cssRules.splice(index,0,cssRule),index};CSSOM.CSSGroupingRule.prototype.deleteRule=function(index){if(index<0||index>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(index,1)[0].parentRule=null};exports.CSSGroupingRule=CSSOM.CSSGroupingRule}});var require_CSSConditionRule=__commonJS({"node_modules/cssom/lib/CSSConditionRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,CSSGroupingRule:require_CSSGroupingRule().CSSGroupingRule};CSSOM.CSSConditionRule=function(){CSSOM.CSSGroupingRule.call(this),this.cssRules=[]};CSSOM.CSSConditionRule.prototype=new CSSOM.CSSGroupingRule;CSSOM.CSSConditionRule.prototype.constructor=CSSOM.CSSConditionRule;CSSOM.CSSConditionRule.prototype.conditionText="";CSSOM.CSSConditionRule.prototype.cssText=
|
|
17
|
-
"";exports.CSSConditionRule=CSSOM.CSSConditionRule}});var require_CSSMediaRule=__commonJS({"node_modules/cssom/lib/CSSMediaRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,CSSGroupingRule:require_CSSGroupingRule().CSSGroupingRule,CSSConditionRule:require_CSSConditionRule().CSSConditionRule,MediaList:require_MediaList().MediaList};CSSOM.CSSMediaRule=function(){CSSOM.CSSConditionRule.call(this),this.media=new CSSOM.MediaList};CSSOM.CSSMediaRule.prototype=new CSSOM.CSSConditionRule;CSSOM.CSSMediaRule.prototype.constructor=CSSOM.CSSMediaRule;
|
|
18
|
-
CSSOM.CSSMediaRule.prototype.type=4;Object.defineProperties(CSSOM.CSSMediaRule.prototype,{conditionText:{get:function(){return this.media.mediaText},set:function(value){this.media.mediaText=value},configurable:!0,enumerable:!0},cssText:{get:function(){for(var cssTexts=[],i=0,length=this.cssRules.length;i<length;i++)cssTexts.push(this.cssRules[i].cssText);return"@media "+this.media.mediaText+" {"+cssTexts.join("")+"}"},configurable:!0,enumerable:!0}});exports.CSSMediaRule=CSSOM.CSSMediaRule}});var require_CSSSupportsRule=__commonJS({"node_modules/cssom/lib/CSSSupportsRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,CSSGroupingRule:require_CSSGroupingRule().CSSGroupingRule,CSSConditionRule:require_CSSConditionRule().CSSConditionRule};CSSOM.CSSSupportsRule=function(){CSSOM.CSSConditionRule.call(this)};CSSOM.CSSSupportsRule.prototype=new CSSOM.CSSConditionRule;CSSOM.CSSSupportsRule.prototype.constructor=CSSOM.CSSSupportsRule;CSSOM.CSSSupportsRule.prototype.type=12;Object.defineProperty(
|
|
19
|
-
CSSOM.CSSSupportsRule.prototype,"cssText",{get:function(){for(var cssTexts=[],i=0,length=this.cssRules.length;i<length;i++)cssTexts.push(this.cssRules[i].cssText);return"@supports "+this.conditionText+" {"+cssTexts.join("")+"}"}});exports.CSSSupportsRule=CSSOM.CSSSupportsRule}});var require_CSSFontFaceRule=__commonJS({"node_modules/cssom/lib/CSSFontFaceRule.js"(exports){var CSSOM={CSSStyleDeclaration:require_CSSStyleDeclaration().CSSStyleDeclaration,CSSRule:require_CSSRule().CSSRule};CSSOM.CSSFontFaceRule=function(){CSSOM.CSSRule.call(this),this.style=new CSSOM.CSSStyleDeclaration,this.style.parentRule=this};CSSOM.CSSFontFaceRule.prototype=new CSSOM.CSSRule;CSSOM.CSSFontFaceRule.prototype.constructor=CSSOM.CSSFontFaceRule;CSSOM.CSSFontFaceRule.prototype.type=5;Object.defineProperty(
|
|
20
|
-
CSSOM.CSSFontFaceRule.prototype,"cssText",{get:function(){return"@font-face {"+this.style.cssText+"}"}});exports.CSSFontFaceRule=CSSOM.CSSFontFaceRule}});var require_CSSHostRule=__commonJS({"node_modules/cssom/lib/CSSHostRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule};CSSOM.CSSHostRule=function(){CSSOM.CSSRule.call(this),this.cssRules=[]};CSSOM.CSSHostRule.prototype=new CSSOM.CSSRule;CSSOM.CSSHostRule.prototype.constructor=CSSOM.CSSHostRule;CSSOM.CSSHostRule.prototype.type=1001;Object.defineProperty(CSSOM.CSSHostRule.prototype,"cssText",{get:function(){for(var cssTexts=[],i=0,length=this.cssRules.length;i<length;i++)cssTexts.push(
|
|
21
|
-
this.cssRules[i].cssText);return"@host {"+cssTexts.join("")+"}"}});exports.CSSHostRule=CSSOM.CSSHostRule}});var require_CSSKeyframeRule=__commonJS({"node_modules/cssom/lib/CSSKeyframeRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,CSSStyleDeclaration:require_CSSStyleDeclaration().CSSStyleDeclaration};CSSOM.CSSKeyframeRule=function(){CSSOM.CSSRule.call(this),this.keyText="",this.style=new CSSOM.CSSStyleDeclaration,this.style.parentRule=this};CSSOM.CSSKeyframeRule.prototype=new CSSOM.CSSRule;CSSOM.CSSKeyframeRule.prototype.constructor=CSSOM.CSSKeyframeRule;CSSOM.CSSKeyframeRule.prototype.
|
|
22
|
-
type=8;Object.defineProperty(CSSOM.CSSKeyframeRule.prototype,"cssText",{get:function(){return this.keyText+" {"+this.style.cssText+"} "}});exports.CSSKeyframeRule=CSSOM.CSSKeyframeRule}});var require_CSSKeyframesRule=__commonJS({"node_modules/cssom/lib/CSSKeyframesRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule};CSSOM.CSSKeyframesRule=function(){CSSOM.CSSRule.call(this),this.name="",this.cssRules=[]};CSSOM.CSSKeyframesRule.prototype=new CSSOM.CSSRule;CSSOM.CSSKeyframesRule.prototype.constructor=CSSOM.CSSKeyframesRule;CSSOM.CSSKeyframesRule.prototype.type=7;Object.defineProperty(CSSOM.CSSKeyframesRule.prototype,"cssText",{get:function(){for(var cssTexts=[],i=0,length=this.
|
|
23
|
-
cssRules.length;i<length;i++)cssTexts.push(" "+this.cssRules[i].cssText);return"@"+(this._vendorPrefix||"")+"keyframes "+this.name+` {
|
|
24
|
-
`+cssTexts.join(`
|
|
25
|
-
`)+`
|
|
26
|
-
}`}});exports.CSSKeyframesRule=CSSOM.CSSKeyframesRule}});var require_CSSValue=__commonJS({"node_modules/cssom/lib/CSSValue.js"(exports){var CSSOM={};CSSOM.CSSValue=function(){};CSSOM.CSSValue.prototype={constructor:CSSOM.CSSValue,set cssText(text){var name=this._getConstructorName();throw new Error('DOMException: property "cssText" of "'+name+'" is readonly and can not be replaced with "'+text+'"!')},get cssText(){var name=this._getConstructorName();throw new Error('getter "cssText" of "'+name+'" is not implemented!')},_getConstructorName:function(){var s=this.
|
|
27
|
-
constructor.toString(),c=s.match(/function\s([^\(]+)/),name=c[1];return name}};exports.CSSValue=CSSOM.CSSValue}});var require_CSSValueExpression=__commonJS({"node_modules/cssom/lib/CSSValueExpression.js"(exports){var CSSOM={CSSValue:require_CSSValue().CSSValue};CSSOM.CSSValueExpression=function(token,idx){this._token=token,this._idx=idx};CSSOM.CSSValueExpression.prototype=new CSSOM.CSSValue;CSSOM.CSSValueExpression.prototype.constructor=CSSOM.CSSValueExpression;CSSOM.CSSValueExpression.prototype.parse=function(){for(var token=this._token,idx=this._idx,character="",expression="",error="",info,paren=[];;++idx){
|
|
28
|
-
if(character=token.charAt(idx),character===""){error="css expression error: unfinished expression!";break}switch(character){case"(":paren.push(character),expression+=character;break;case")":paren.pop(character),expression+=character;break;case"/":(info=this._parseJSComment(token,idx))?info.error?error="css expression error: unfinished comment in expression!":idx=info.idx:(info=this._parseJSRexExp(token,idx))?(idx=info.idx,expression+=info.text):expression+=character;break;case"'":case'"':info=this.
|
|
29
|
-
_parseJSString(token,idx,character),info?(idx=info.idx,expression+=info.text):expression+=character;break;default:expression+=character;break}if(error||paren.length===0)break}var ret;return error?ret={error}:ret={idx,expression},ret};CSSOM.CSSValueExpression.prototype._parseJSComment=function(token,idx){var nextChar=token.charAt(idx+1),text;if(nextChar==="/"||nextChar==="*"){var startIdx=idx,endIdx,commentEndChar;if(nextChar==="/"?commentEndChar=`
|
|
30
|
-
`:nextChar==="*"&&(commentEndChar="*/"),endIdx=token.indexOf(commentEndChar,startIdx+1+1),endIdx!==-1)return endIdx=endIdx+commentEndChar.length-1,text=token.substring(idx,endIdx+1),{idx:endIdx,text};var error="css expression error: unfinished comment in expression!";return{error}}else return!1};CSSOM.CSSValueExpression.prototype._parseJSString=function(token,idx,sep){var endIdx=this._findMatchedIdx(token,idx,sep),text;return endIdx===-1?!1:(text=token.substring(idx,endIdx+sep.length),{idx:endIdx,
|
|
31
|
-
text})};CSSOM.CSSValueExpression.prototype._parseJSRexExp=function(token,idx){var before=token.substring(0,idx).replace(/\s+$/,""),legalRegx=[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/],isLegal=legalRegx.some(function(reg){return reg.test(before)});if(isLegal){var sep="/";return this._parseJSString(token,idx,sep)}else return!1};CSSOM.CSSValueExpression.prototype._findMatchedIdx=
|
|
32
|
-
function(token,idx,sep){for(var startIdx=idx,endIdx,NOT_FOUND=-1;;)if(endIdx=token.indexOf(sep,startIdx+1),endIdx===-1){endIdx=NOT_FOUND;break}else{var text=token.substring(idx+1,endIdx),matched=text.match(/\\+$/);if(!matched||matched[0]%2===0)break;startIdx=endIdx}var nextNewLineIdx=token.indexOf(`
|
|
33
|
-
`,idx+1);return nextNewLineIdx<endIdx&&(endIdx=NOT_FOUND),endIdx};exports.CSSValueExpression=CSSOM.CSSValueExpression}});var require_MatcherList=__commonJS({"node_modules/cssom/lib/MatcherList.js"(exports){var CSSOM={};CSSOM.MatcherList=function(){this.length=0};CSSOM.MatcherList.prototype={constructor:CSSOM.MatcherList,get matcherText(){return Array.prototype.join.call(this,", ")},set matcherText(value){for(var values=value.split(","),length=this.length=values.length,i=0;i<length;i++)this[i]=values[i].trim()},appendMatcher:function(matcher){Array.prototype.indexOf.call(this,matcher)===-1&&(this[this.length]=matcher,
|
|
34
|
-
this.length++)},deleteMatcher:function(matcher){var index=Array.prototype.indexOf.call(this,matcher);index!==-1&&Array.prototype.splice.call(this,index,1)}};exports.MatcherList=CSSOM.MatcherList}});var require_CSSDocumentRule=__commonJS({"node_modules/cssom/lib/CSSDocumentRule.js"(exports){var CSSOM={CSSRule:require_CSSRule().CSSRule,MatcherList:require_MatcherList().MatcherList};CSSOM.CSSDocumentRule=function(){CSSOM.CSSRule.call(this),this.matcher=new CSSOM.MatcherList,this.cssRules=[]};CSSOM.CSSDocumentRule.prototype=new CSSOM.CSSRule;CSSOM.CSSDocumentRule.prototype.constructor=CSSOM.CSSDocumentRule;CSSOM.CSSDocumentRule.prototype.type=10;Object.defineProperty(CSSOM.CSSDocumentRule.prototype,
|
|
35
|
-
"cssText",{get:function(){for(var cssTexts=[],i=0,length=this.cssRules.length;i<length;i++)cssTexts.push(this.cssRules[i].cssText);return"@-moz-document "+this.matcher.matcherText+" {"+cssTexts.join("")+"}"}});exports.CSSDocumentRule=CSSOM.CSSDocumentRule}});var require_parse=__commonJS({"node_modules/cssom/lib/parse.js"(exports){var CSSOM={};CSSOM.parse=function(token){for(var i=0,state="before-selector",index,buffer="",valueParenthesisDepth=0,SIGNIFICANT_WHITESPACE={selector:!0,value:!0,"value-parenthesis":!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,conditionBlock:!0,"documentRule-begin":!0},styleSheet=new CSSOM.CSSStyleSheet,currentScope=styleSheet,parentRule,ancestorRules=[],hasAncestors=!1,prevScope,name,priority="",styleRule,mediaRule,
|
|
36
|
-
supportsRule,importRule,fontFaceRule,keyframesRule,documentRule,hostRule,atKeyframesRegExp=/@(-(?:\w+-)+)?keyframes/g,parseError=function(message){var lines=token.substring(0,i).split(`
|
|
37
|
-
`),lineCount=lines.length,charCount=lines.pop().length+1,error=new Error(message+" (line "+lineCount+", char "+charCount+")");throw error.line=lineCount,error.char=charCount,error.styleSheet=styleSheet,error},character;character=token.charAt(i);i++)switch(character){case" ":case" ":case"\r":case`
|
|
38
|
-
`:case"\f":SIGNIFICANT_WHITESPACE[state]&&(buffer+=character);break;case'"':index=i+1;do index=token.indexOf('"',index)+1,index||parseError('Unmatched "');while(token[index-2]==="\\");switch(buffer+=token.slice(i,index),i=index-1,state){case"before-value":state="value";break;case"importRule-begin":state="importRule";break}break;case"'":index=i+1;do index=token.indexOf("'",index)+1,index||parseError("Unmatched '");while(token[index-2]==="\\");switch(buffer+=token.slice(i,index),i=index-1,state){case"\
|
|
39
|
-
before-value":state="value";break;case"importRule-begin":state="importRule";break}break;case"/":token.charAt(i+1)==="*"?(i+=2,index=token.indexOf("*/",i),index===-1?parseError("Missing */"):i=index+1):buffer+=character,state==="importRule-begin"&&(buffer+=" ",state="importRule");break;case"@":if(token.indexOf("@-moz-document",i)===i){state="documentRule-begin",documentRule=new CSSOM.CSSDocumentRule,documentRule.__starts=i,i+=13,buffer="";break}else if(token.indexOf("@media",i)===i){state="atBloc\
|
|
40
|
-
k",mediaRule=new CSSOM.CSSMediaRule,mediaRule.__starts=i,i+=5,buffer="";break}else if(token.indexOf("@supports",i)===i){state="conditionBlock",supportsRule=new CSSOM.CSSSupportsRule,supportsRule.__starts=i,i+=8,buffer="";break}else if(token.indexOf("@host",i)===i){state="hostRule-begin",i+=4,hostRule=new CSSOM.CSSHostRule,hostRule.__starts=i,buffer="";break}else if(token.indexOf("@import",i)===i){state="importRule-begin",i+=6,buffer+="@import";break}else if(token.indexOf("@font-face",i)===i){state=
|
|
41
|
-
"fontFaceRule-begin",i+=9,fontFaceRule=new CSSOM.CSSFontFaceRule,fontFaceRule.__starts=i,buffer="";break}else{atKeyframesRegExp.lastIndex=i;var matchKeyframes=atKeyframesRegExp.exec(token);if(matchKeyframes&&matchKeyframes.index===i){state="keyframesRule-begin",keyframesRule=new CSSOM.CSSKeyframesRule,keyframesRule.__starts=i,keyframesRule._vendorPrefix=matchKeyframes[1],i+=matchKeyframes[0].length-1,buffer="";break}else state==="selector"&&(state="atRule")}buffer+=character;break;case"{":state===
|
|
42
|
-
"selector"||state==="atRule"?(styleRule.selectorText=buffer.trim(),styleRule.style.__starts=i,buffer="",state="before-name"):state==="atBlock"?(mediaRule.media.mediaText=buffer.trim(),parentRule&&ancestorRules.push(parentRule),currentScope=parentRule=mediaRule,mediaRule.parentStyleSheet=styleSheet,buffer="",state="before-selector"):state==="conditionBlock"?(supportsRule.conditionText=buffer.trim(),parentRule&&ancestorRules.push(parentRule),currentScope=parentRule=supportsRule,supportsRule.parentStyleSheet=
|
|
43
|
-
styleSheet,buffer="",state="before-selector"):state==="hostRule-begin"?(parentRule&&ancestorRules.push(parentRule),currentScope=parentRule=hostRule,hostRule.parentStyleSheet=styleSheet,buffer="",state="before-selector"):state==="fontFaceRule-begin"?(parentRule&&(fontFaceRule.parentRule=parentRule),fontFaceRule.parentStyleSheet=styleSheet,styleRule=fontFaceRule,buffer="",state="before-name"):state==="keyframesRule-begin"?(keyframesRule.name=buffer.trim(),parentRule&&(ancestorRules.push(parentRule),
|
|
44
|
-
keyframesRule.parentRule=parentRule),keyframesRule.parentStyleSheet=styleSheet,currentScope=parentRule=keyframesRule,buffer="",state="keyframeRule-begin"):state==="keyframeRule-begin"?(styleRule=new CSSOM.CSSKeyframeRule,styleRule.keyText=buffer.trim(),styleRule.__starts=i,buffer="",state="before-name"):state==="documentRule-begin"&&(documentRule.matcher.matcherText=buffer.trim(),parentRule&&(ancestorRules.push(parentRule),documentRule.parentRule=parentRule),currentScope=parentRule=documentRule,
|
|
45
|
-
documentRule.parentStyleSheet=styleSheet,buffer="",state="before-selector");break;case":":state==="name"?(name=buffer.trim(),buffer="",state="before-value"):buffer+=character;break;case"(":if(state==="value")if(buffer.trim()==="expression"){var info=new CSSOM.CSSValueExpression(token,i).parse();info.error?parseError(info.error):(buffer+=info.expression,i=info.idx)}else state="value-parenthesis",valueParenthesisDepth=1,buffer+=character;else state==="value-parenthesis"&&valueParenthesisDepth++,buffer+=
|
|
46
|
-
character;break;case")":state==="value-parenthesis"&&(valueParenthesisDepth--,valueParenthesisDepth===0&&(state="value")),buffer+=character;break;case"!":state==="value"&&token.indexOf("!important",i)===i?(priority="important",i+=9):buffer+=character;break;case";":switch(state){case"value":styleRule.style.setProperty(name,buffer.trim(),priority),priority="",buffer="",state="before-name";break;case"atRule":buffer="",state="before-selector";break;case"importRule":importRule=new CSSOM.CSSImportRule,
|
|
47
|
-
importRule.parentStyleSheet=importRule.styleSheet.parentStyleSheet=styleSheet,importRule.cssText=buffer+character,styleSheet.cssRules.push(importRule),buffer="",state="before-selector";break;default:buffer+=character;break}break;case"}":switch(state){case"value":styleRule.style.setProperty(name,buffer.trim(),priority),priority="";case"before-name":case"name":styleRule.__ends=i+1,parentRule&&(styleRule.parentRule=parentRule),styleRule.parentStyleSheet=styleSheet,currentScope.cssRules.push(styleRule),
|
|
48
|
-
buffer="",currentScope.constructor===CSSOM.CSSKeyframesRule?state="keyframeRule-begin":state="before-selector";break;case"keyframeRule-begin":case"before-selector":case"selector":for(parentRule||parseError("Unexpected }"),hasAncestors=ancestorRules.length>0;ancestorRules.length>0;){if(parentRule=ancestorRules.pop(),parentRule.constructor.name==="CSSMediaRule"||parentRule.constructor.name==="CSSSupportsRule"){prevScope=currentScope,currentScope=parentRule,currentScope.cssRules.push(prevScope);break}
|
|
49
|
-
ancestorRules.length===0&&(hasAncestors=!1)}hasAncestors||(currentScope.__ends=i+1,styleSheet.cssRules.push(currentScope),currentScope=styleSheet,parentRule=null),buffer="",state="before-selector";break}break;default:switch(state){case"before-selector":state="selector",styleRule=new CSSOM.CSSStyleRule,styleRule.__starts=i;break;case"before-name":state="name";break;case"before-value":state="value";break;case"importRule-begin":state="importRule";break}buffer+=character;break}return styleSheet};exports.
|
|
50
|
-
parse=CSSOM.parse;CSSOM.CSSStyleSheet=require_CSSStyleSheet().CSSStyleSheet;CSSOM.CSSStyleRule=require_CSSStyleRule().CSSStyleRule;CSSOM.CSSImportRule=require_CSSImportRule().CSSImportRule;CSSOM.CSSGroupingRule=require_CSSGroupingRule().CSSGroupingRule;CSSOM.CSSMediaRule=require_CSSMediaRule().CSSMediaRule;CSSOM.CSSConditionRule=require_CSSConditionRule().CSSConditionRule;CSSOM.CSSSupportsRule=require_CSSSupportsRule().CSSSupportsRule;CSSOM.CSSFontFaceRule=require_CSSFontFaceRule().CSSFontFaceRule;
|
|
51
|
-
CSSOM.CSSHostRule=require_CSSHostRule().CSSHostRule;CSSOM.CSSStyleDeclaration=require_CSSStyleDeclaration().CSSStyleDeclaration;CSSOM.CSSKeyframeRule=require_CSSKeyframeRule().CSSKeyframeRule;CSSOM.CSSKeyframesRule=require_CSSKeyframesRule().CSSKeyframesRule;CSSOM.CSSValueExpression=require_CSSValueExpression().CSSValueExpression;CSSOM.CSSDocumentRule=require_CSSDocumentRule().CSSDocumentRule}});var require_CSSStyleDeclaration=__commonJS({"node_modules/cssom/lib/CSSStyleDeclaration.js"(exports){var CSSOM={};CSSOM.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}};CSSOM.CSSStyleDeclaration.prototype={constructor:CSSOM.CSSStyleDeclaration,getPropertyValue:function(name){return this[name]||""},setProperty:function(name,value,priority){if(this[name]){var index=Array.prototype.indexOf.call(this,name);index<0&&(this[this.length]=name,this.length++)}else this[this.
|
|
52
|
-
length]=name,this.length++;this[name]=value+"",this._importants[name]=priority},removeProperty:function(name){if(!(name in this))return"";var index=Array.prototype.indexOf.call(this,name);if(index<0)return"";var prevValue=this[name];return this[name]="",Array.prototype.splice.call(this,index,1),prevValue},getPropertyCSSValue:function(){},getPropertyPriority:function(name){return this._importants[name]||""},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var properties=[],
|
|
53
|
-
i=0,length=this.length;i<length;++i){var name=this[i],value=this.getPropertyValue(name),priority=this.getPropertyPriority(name);priority&&(priority=" !"+priority),properties[i]=name+": "+value+priority+";"}return properties.join(" ")},set cssText(text){var i,name;for(i=this.length;i--;)name=this[i],this[name]="";Array.prototype.splice.call(this,0,this.length),this._importants={};var dummyRule=CSSOM.parse("#bogus{"+text+"}").cssRules[0].style,length=dummyRule.length;for(i=0;i<length;++i)name=dummyRule[i],
|
|
54
|
-
this.setProperty(dummyRule[i],dummyRule.getPropertyValue(name),dummyRule.getPropertyPriority(name))}};exports.CSSStyleDeclaration=CSSOM.CSSStyleDeclaration;CSSOM.parse=require_parse().parse}});var require_clone=__commonJS({"node_modules/cssom/lib/clone.js"(exports){var CSSOM={CSSStyleSheet:require_CSSStyleSheet().CSSStyleSheet,CSSRule:require_CSSRule().CSSRule,CSSStyleRule:require_CSSStyleRule().CSSStyleRule,CSSGroupingRule:require_CSSGroupingRule().CSSGroupingRule,CSSConditionRule:require_CSSConditionRule().CSSConditionRule,CSSMediaRule:require_CSSMediaRule().CSSMediaRule,CSSSupportsRule:require_CSSSupportsRule().CSSSupportsRule,CSSStyleDeclaration:require_CSSStyleDeclaration().CSSStyleDeclaration,
|
|
55
|
-
CSSKeyframeRule:require_CSSKeyframeRule().CSSKeyframeRule,CSSKeyframesRule:require_CSSKeyframesRule().CSSKeyframesRule};CSSOM.clone=function clone(stylesheet){var cloned=new CSSOM.CSSStyleSheet,rules=stylesheet.cssRules;if(!rules)return cloned;for(var i=0,rulesLength=rules.length;i<rulesLength;i++){var rule=rules[i],ruleClone=cloned.cssRules[i]=new rule.constructor,style=rule.style;if(style){for(var styleClone=ruleClone.style=new CSSOM.CSSStyleDeclaration,j=0,styleLength=style.length;j<styleLength;j++){
|
|
56
|
-
var name=styleClone[j]=style[j];styleClone[name]=style[name],styleClone._importants[name]=style.getPropertyPriority(name)}styleClone.length=style.length}rule.hasOwnProperty("keyText")&&(ruleClone.keyText=rule.keyText),rule.hasOwnProperty("selectorText")&&(ruleClone.selectorText=rule.selectorText),rule.hasOwnProperty("mediaText")&&(ruleClone.mediaText=rule.mediaText),rule.hasOwnProperty("conditionText")&&(ruleClone.conditionText=rule.conditionText),rule.hasOwnProperty("cssRules")&&(ruleClone.cssRules=
|
|
57
|
-
clone(rule).cssRules)}return cloned};exports.clone=CSSOM.clone}});var require_lib=__commonJS({"node_modules/cssom/lib/index.js"(exports){"use strict";exports.CSSStyleDeclaration=require_CSSStyleDeclaration().CSSStyleDeclaration;exports.CSSRule=require_CSSRule().CSSRule;exports.CSSGroupingRule=require_CSSGroupingRule().CSSGroupingRule;exports.CSSConditionRule=require_CSSConditionRule().CSSConditionRule;exports.CSSStyleRule=require_CSSStyleRule().CSSStyleRule;exports.MediaList=require_MediaList().MediaList;exports.CSSMediaRule=require_CSSMediaRule().CSSMediaRule;
|
|
58
|
-
exports.CSSSupportsRule=require_CSSSupportsRule().CSSSupportsRule;exports.CSSImportRule=require_CSSImportRule().CSSImportRule;exports.CSSFontFaceRule=require_CSSFontFaceRule().CSSFontFaceRule;exports.CSSHostRule=require_CSSHostRule().CSSHostRule;exports.StyleSheet=require_StyleSheet().StyleSheet;exports.CSSStyleSheet=require_CSSStyleSheet().CSSStyleSheet;exports.CSSKeyframesRule=require_CSSKeyframesRule().CSSKeyframesRule;exports.CSSKeyframeRule=require_CSSKeyframeRule().CSSKeyframeRule;exports.
|
|
59
|
-
MatcherList=require_MatcherList().MatcherList;exports.CSSDocumentRule=require_CSSDocumentRule().CSSDocumentRule;exports.CSSValue=require_CSSValue().CSSValue;exports.CSSValueExpression=require_CSSValueExpression().CSSValueExpression;exports.parse=require_parse().parse;exports.clone=require_clone().clone}});var require_canvas_shim=__commonJS({"node_modules/linkedom/commonjs/canvas-shim.cjs"(exports,module){var Canvas=class{constructor(width,height){this.width=width,this.height=height}getContext(){return null}toDataURL(){return""}};module.exports={createCanvas:(width,height)=>new Canvas(width,height)}}});var require_canvas=__commonJS({"node_modules/linkedom/commonjs/canvas.cjs"(exports,module){try{module.exports=__require("canvas")}catch{module.exports=require_canvas_shim()}}});function trueFunc(){return!0}function falseFunc(){return!1}var init_dist=__esm({"node_modules/boolbase/dist/index.js"(){}});var SelectorType,AttributeAction,init_types=__esm({"node_modules/css-what/dist/types.js"(){(function(SelectorType2){SelectorType2.Attribute="attribute",SelectorType2.Pseudo="pseudo",SelectorType2.PseudoElement="pseudo-element",SelectorType2.Tag="tag",SelectorType2.Universal="universal",SelectorType2.Adjacent="adjacent",SelectorType2.Child="child",SelectorType2.Descendant="descendant",SelectorType2.Parent="parent",SelectorType2.Sibling="sibling",SelectorType2.ColumnCombinator="column-combinator"})(
|
|
60
|
-
SelectorType||(SelectorType={}));(function(AttributeAction2){AttributeAction2.Any="any",AttributeAction2.Element="element",AttributeAction2.End="end",AttributeAction2.Equals="equals",AttributeAction2.Exists="exists",AttributeAction2.Hyphen="hyphen",AttributeAction2.Not="not",AttributeAction2.Start="start"})(AttributeAction||(AttributeAction={}))}});function isTraversal(selector){switch(selector.type){case SelectorType.Adjacent:case SelectorType.Child:case SelectorType.Descendant:case SelectorType.Parent:case SelectorType.Sibling:case SelectorType.ColumnCombinator:return!0;case SelectorType.Attribute:case SelectorType.Pseudo:case SelectorType.PseudoElement:case SelectorType.Tag:case SelectorType.Universal:return!1}}function funescape(_,escaped,escapedWhitespace){let high=Number.parseInt(escaped,16)-65536;return Number.isNaN(high)||escapedWhitespace?
|
|
61
|
-
escaped:high<0?String.fromCharCode(high+65536):String.fromCharCode(high>>10|55296,high&1023|56320)}function unescapeCSS(cssString){return cssString.replace(reEscape,funescape)}function isQuote(c){return c===CharCode.SingleQuote||c===CharCode.DoubleQuote}function isWhitespace(c){return c===CharCode.Space||c===CharCode.Tab||c===CharCode.NewLine||c===CharCode.FormFeed||c===CharCode.CarriageReturn}function parse(selector){let subselects2=[],endIndex=parseSelector(subselects2,`${selector}`,0);if(endIndex<
|
|
62
|
-
selector.length)throw new Error(`Unmatched selector: ${selector.slice(endIndex)}`);return subselects2}function parseSelector(subselects2,selector,selectorIndex){let tokens=[];function getName2(offset){let match=selector.slice(selectorIndex+offset).match(reName);if(!match)throw new Error(`Expected name, found ${selector.slice(selectorIndex)}`);let[name]=match;return selectorIndex+=offset+name.length,unescapeCSS(name)}function stripWhitespace(offset){for(selectorIndex+=offset;selectorIndex<selector.
|
|
63
|
-
length&&isWhitespace(selector.charCodeAt(selectorIndex));)selectorIndex++}function readValueWithParenthesis(){selectorIndex+=1;let start=selectorIndex;for(let counter=1;selectorIndex<selector.length;selectorIndex++)switch(selector.charCodeAt(selectorIndex)){case CharCode.BackSlash:{selectorIndex+=1;break}case CharCode.LeftParenthesis:{counter+=1;break}case CharCode.RightParenthesis:{if(counter-=1,counter===0)return unescapeCSS(selector.slice(start,selectorIndex++));break}}throw new Error("Parent\
|
|
64
|
-
hesis not matched")}function ensureNotTraversal(){if(tokens.length>0&&isTraversal(tokens[tokens.length-1]))throw new Error("Did not expect successive traversals.")}function addTraversal(type){if(tokens.length>0&&tokens[tokens.length-1].type===SelectorType.Descendant){tokens[tokens.length-1].type=type;return}ensureNotTraversal(),tokens.push({type})}function addSpecialAttribute(name,action){tokens.push({type:SelectorType.Attribute,name,action,value:getName2(1),namespace:null,ignoreCase:"quirks"})}
|
|
65
|
-
function finalizeSubselector(){if(tokens.length>0&&tokens[tokens.length-1].type===SelectorType.Descendant&&tokens.pop(),tokens.length===0)throw new Error("Empty sub-selector");subselects2.push(tokens)}if(stripWhitespace(0),selector.length===selectorIndex)return selectorIndex;loop:for(;selectorIndex<selector.length;){let firstChar=selector.charCodeAt(selectorIndex);switch(firstChar){case CharCode.Space:case CharCode.Tab:case CharCode.NewLine:case CharCode.FormFeed:case CharCode.CarriageReturn:{(tokens.
|
|
66
|
-
length===0||tokens[0].type!==SelectorType.Descendant)&&(ensureNotTraversal(),tokens.push({type:SelectorType.Descendant})),stripWhitespace(1);break}case CharCode.GreaterThan:{addTraversal(SelectorType.Child),stripWhitespace(1);break}case CharCode.LessThan:{addTraversal(SelectorType.Parent),stripWhitespace(1);break}case CharCode.Tilde:{addTraversal(SelectorType.Sibling),stripWhitespace(1);break}case CharCode.Plus:{addTraversal(SelectorType.Adjacent),stripWhitespace(1);break}case CharCode.Period:{addSpecialAttribute(
|
|
67
|
-
"class",AttributeAction.Element);break}case CharCode.Hash:{addSpecialAttribute("id",AttributeAction.Equals);break}case CharCode.LeftSquareBracket:{stripWhitespace(1);let name,namespace=null;selector.charCodeAt(selectorIndex)===CharCode.Pipe?name=getName2(1):selector.startsWith("*|",selectorIndex)?(namespace="*",name=getName2(2)):(name=getName2(0),selector.charCodeAt(selectorIndex)===CharCode.Pipe&&selector.charCodeAt(selectorIndex+1)!==CharCode.Equal&&(namespace=name,name=getName2(1))),stripWhitespace(
|
|
68
|
-
0);let action=AttributeAction.Exists,possibleAction=actionTypes.get(selector.charCodeAt(selectorIndex));if(possibleAction){if(action=possibleAction,selector.charCodeAt(selectorIndex+1)!==CharCode.Equal)throw new Error("Expected `=`");stripWhitespace(2)}else selector.charCodeAt(selectorIndex)===CharCode.Equal&&(action=AttributeAction.Equals,stripWhitespace(1));let value="",ignoreCase=null;if(action!=="exists"){if(isQuote(selector.charCodeAt(selectorIndex))){let quote=selector.charCodeAt(selectorIndex);
|
|
69
|
-
selectorIndex+=1;let sectionStart=selectorIndex;for(;selectorIndex<selector.length&&selector.charCodeAt(selectorIndex)!==quote;)selectorIndex+=selector.charCodeAt(selectorIndex)===CharCode.BackSlash?2:1;if(selector.charCodeAt(selectorIndex)!==quote)throw new Error("Attribute value didn't end");value=unescapeCSS(selector.slice(sectionStart,selectorIndex)),selectorIndex+=1}else{let valueStart=selectorIndex;for(;selectorIndex<selector.length&&!isWhitespace(selector.charCodeAt(selectorIndex))&&selector.
|
|
70
|
-
charCodeAt(selectorIndex)!==CharCode.RightSquareBracket;)selectorIndex+=selector.charCodeAt(selectorIndex)===CharCode.BackSlash?2:1;value=unescapeCSS(selector.slice(valueStart,selectorIndex))}switch(stripWhitespace(0),selector.charCodeAt(selectorIndex)|32){case CharCode.LowerI:{ignoreCase=!0,stripWhitespace(1);break}case CharCode.LowerS:{ignoreCase=!1,stripWhitespace(1);break}}}if(selector.charCodeAt(selectorIndex)!==CharCode.RightSquareBracket)throw new Error("Attribute selector didn't terminat\
|
|
71
|
-
e");selectorIndex+=1;let attributeSelector={type:SelectorType.Attribute,name,action,value,namespace,ignoreCase};tokens.push(attributeSelector);break}case CharCode.Colon:{if(selector.charCodeAt(selectorIndex+1)===CharCode.Colon){tokens.push({type:SelectorType.PseudoElement,name:getName2(2).toLowerCase(),data:selector.charCodeAt(selectorIndex)===CharCode.LeftParenthesis?readValueWithParenthesis():null});break}let name=getName2(1).toLowerCase();if(pseudosToPseudoElements.has(name)){tokens.push({type:SelectorType.
|
|
72
|
-
PseudoElement,name,data:null});break}let data=null;if(selector.charCodeAt(selectorIndex)===CharCode.LeftParenthesis)if(unpackPseudos.has(name)){if(isQuote(selector.charCodeAt(selectorIndex+1)))throw new Error(`Pseudo-selector ${name} cannot be quoted`);if(data=[],selectorIndex=parseSelector(data,selector,selectorIndex+1),selector.charCodeAt(selectorIndex)!==CharCode.RightParenthesis)throw new Error(`Missing closing parenthesis in :${name} (${selector})`);selectorIndex+=1}else{if(data=readValueWithParenthesis(),
|
|
73
|
-
stripQuotesFromPseudos.has(name)){let quot=data.charCodeAt(0);quot===data.charCodeAt(data.length-1)&&isQuote(quot)&&(data=data.slice(1,-1))}data=unescapeCSS(data)}tokens.push({type:SelectorType.Pseudo,name,data});break}case CharCode.Comma:{finalizeSubselector(),tokens=[],stripWhitespace(1);break}default:{if(selector.startsWith("/*",selectorIndex)){let endIndex=selector.indexOf("*/",selectorIndex+2);if(endIndex===-1)throw new Error("Comment was not terminated");selectorIndex=endIndex+2,tokens.length===
|
|
74
|
-
0&&stripWhitespace(0);break}let namespace=null,name;if(firstChar===CharCode.Asterisk)selectorIndex+=1,name="*";else if(firstChar===CharCode.Pipe){if(name="",selector.charCodeAt(selectorIndex+1)===CharCode.Pipe){addTraversal(SelectorType.ColumnCombinator),stripWhitespace(2);break}}else if(reName.test(selector.slice(selectorIndex)))name=getName2(0);else break loop;selector.charCodeAt(selectorIndex)===CharCode.Pipe&&selector.charCodeAt(selectorIndex+1)!==CharCode.Pipe&&(namespace=name,selector.charCodeAt(
|
|
75
|
-
selectorIndex+1)===CharCode.Asterisk?(name="*",selectorIndex+=2):name=getName2(1)),tokens.push(name==="*"?{type:SelectorType.Universal,namespace}:{type:SelectorType.Tag,name,namespace})}}}return finalizeSubselector(),selectorIndex}var reName,reEscape,CharCode,actionTypes,unpackPseudos,pseudosToPseudoElements,stripQuotesFromPseudos,init_parse=__esm({"node_modules/css-what/dist/parse.js"(){init_types();reName=/^[^#\\]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\u00B0-\uFFFF-])+/,reEscape=/\\([\da-f]{1,6}\s?|(\s)|.)/gi;
|
|
76
|
-
(function(CharCode2){CharCode2[CharCode2.LeftParenthesis=40]="LeftParenthesis",CharCode2[CharCode2.RightParenthesis=41]="RightParenthesis",CharCode2[CharCode2.LeftSquareBracket=91]="LeftSquareBracket",CharCode2[CharCode2.RightSquareBracket=93]="RightSquareBracket",CharCode2[CharCode2.Comma=44]="Comma",CharCode2[CharCode2.Period=46]="Period",CharCode2[CharCode2.Colon=58]="Colon",CharCode2[CharCode2.SingleQuote=39]="SingleQuote",CharCode2[CharCode2.DoubleQuote=34]="DoubleQuote",CharCode2[CharCode2.
|
|
77
|
-
Plus=43]="Plus",CharCode2[CharCode2.Tilde=126]="Tilde",CharCode2[CharCode2.QuestionMark=63]="QuestionMark",CharCode2[CharCode2.ExclamationMark=33]="ExclamationMark",CharCode2[CharCode2.Slash=47]="Slash",CharCode2[CharCode2.Equal=61]="Equal",CharCode2[CharCode2.Dollar=36]="Dollar",CharCode2[CharCode2.Pipe=124]="Pipe",CharCode2[CharCode2.Circumflex=94]="Circumflex",CharCode2[CharCode2.Asterisk=42]="Asterisk",CharCode2[CharCode2.GreaterThan=62]="GreaterThan",CharCode2[CharCode2.LessThan=60]="LessTh\
|
|
78
|
-
an",CharCode2[CharCode2.Hash=35]="Hash",CharCode2[CharCode2.LowerI=105]="LowerI",CharCode2[CharCode2.LowerS=115]="LowerS",CharCode2[CharCode2.BackSlash=92]="BackSlash",CharCode2[CharCode2.Space=32]="Space",CharCode2[CharCode2.Tab=9]="Tab",CharCode2[CharCode2.NewLine=10]="NewLine",CharCode2[CharCode2.FormFeed=12]="FormFeed",CharCode2[CharCode2.CarriageReturn=13]="CarriageReturn"})(CharCode||(CharCode={}));actionTypes=new Map([[CharCode.Tilde,AttributeAction.Element],[CharCode.Circumflex,AttributeAction.
|
|
79
|
-
Start],[CharCode.Dollar,AttributeAction.End],[CharCode.Asterisk,AttributeAction.Any],[CharCode.ExclamationMark,AttributeAction.Not],[CharCode.Pipe,AttributeAction.Hyphen]]),unpackPseudos=new Set(["has","not","matches","is","where","host","host-context"]),pseudosToPseudoElements=new Set(["before","after","first-line","first-letter"]);stripQuotesFromPseudos=new Set(["contains","icontains"])}});var init_dist2=__esm({"node_modules/css-what/dist/index.js"(){init_parse();init_types()}});function isTag(element){return element.type===ElementType.Tag||element.type===ElementType.Script||element.type===ElementType.Style}var ElementType,Root,Text,Directive,Comment,Script,Style,Tag,CDATA,Doctype,init_dist3=__esm({"node_modules/domhandler/node_modules/domelementtype/dist/index.js"(){(function(ElementType4){ElementType4.Root="root",ElementType4.Text="text",ElementType4.Directive="directive",ElementType4.Comment="comment",ElementType4.Script="script",ElementType4.Style="style",ElementType4.
|
|
80
|
-
Tag="tag",ElementType4.CDATA="cdata",ElementType4.Doctype="doctype"})(ElementType||(ElementType={}));Root=ElementType.Root,Text=ElementType.Text,Directive=ElementType.Directive,Comment=ElementType.Comment,Script=ElementType.Script,Style=ElementType.Style,Tag=ElementType.Tag,CDATA=ElementType.CDATA,Doctype=ElementType.Doctype}});function isTag2(node){return isTag(node)}function isCDATA(node){return node.type===ElementType.CDATA}function isText(node){return node.type===ElementType.Text}function isComment(node){return node.type===ElementType.Comment}function hasChildren(node){return Object.hasOwn(node,"children")}var init_node=__esm({"node_modules/domhandler/dist/node.js"(){init_dist3()}});var init_dist4=__esm({"node_modules/domhandler/dist/index.js"(){init_node()}});function filter(test,node,recurse=!0,limit=Number.POSITIVE_INFINITY){return find(test,Array.isArray(node)?node:[node],recurse,limit)}function find(test,nodes,recurse,limit){let result=[],nodeStack=[Array.isArray(nodes)?nodes:[nodes]],indexStack=[0];for(;;){if(indexStack[0]>=nodeStack[0].length){if(indexStack.length===1)return result;nodeStack.shift(),indexStack.shift();continue}let element=nodeStack[0][indexStack[0]++];if(test(element)&&(result.push(element),--limit<=0))return result;recurse&&hasChildren(
|
|
81
|
-
element)&&element.children.length>0&&(indexStack.unshift(0),nodeStack.unshift(element.children))}}function findOne(test,nodes,recurse=!0){let searchedNodes=Array.isArray(nodes)?nodes:[nodes];for(let node of searchedNodes){if(isTag2(node)&&test(node))return node;if(recurse&&hasChildren(node)&&node.children.length>0){let found=findOne(test,node.children,!0);if(found)return found}}return null}function existsOne(test,nodes){return(Array.isArray(nodes)?nodes:[nodes]).some(node=>isTag2(node)&&test(node)||
|
|
82
|
-
hasChildren(node)&&existsOne(test,node.children))}function findAll(test,nodes){let result=[],nodeStack=[Array.isArray(nodes)?nodes:[nodes]],indexStack=[0];for(;;){if(indexStack[0]>=nodeStack[0].length){if(nodeStack.length===1)return result;nodeStack.shift(),indexStack.shift();continue}let element=nodeStack[0][indexStack[0]++];isTag2(element)&&test(element)&&result.push(element),hasChildren(element)&&element.children.length>0&&(indexStack.unshift(0),nodeStack.unshift(element.children))}}var init_querying=__esm(
|
|
83
|
-
{"node_modules/domutils/dist/querying.js"(){init_dist4()}});function getAttribCheck(attrib,value){return typeof value=="function"?element=>isTag2(element)&&value(element.attribs[attrib]):element=>isTag2(element)&&element.attribs[attrib]===value}function combineFuncs(a,b){return element=>a(element)||b(element)}function compileTest(options){let funcs=Object.keys(options).map(key=>{let value=options[key];return Object.hasOwn(Checks,key)?Checks[key](value):getAttribCheck(key,value)});return funcs.length===0?null:funcs.reduce(combineFuncs)}function testElement(options,node){
|
|
84
|
-
let test=compileTest(options);return test?test(node):!0}function getElements(options,nodes,recurse,limit=Number.POSITIVE_INFINITY){let test=compileTest(options);return test?filter(test,nodes,recurse,limit):[]}function getElementById(id,nodes,recurse=!0){return Array.isArray(nodes)||(nodes=[nodes]),findOne(getAttribCheck("id",id),nodes,recurse)}function getElementsByTagName(tagName,nodes,recurse=!0,limit=Number.POSITIVE_INFINITY){return filter(Checks.tag_name(tagName),nodes,recurse,limit)}function getElementsByClassName(className,nodes,recurse=!0,limit=Number.
|
|
85
|
-
POSITIVE_INFINITY){return filter(getAttribCheck("class",className),nodes,recurse,limit)}function getElementsByTagType(type,nodes,recurse=!0,limit=Number.POSITIVE_INFINITY){return filter(Checks.tag_type(type),nodes,recurse,limit)}var Checks,init_legacy=__esm({"node_modules/domutils/dist/legacy.js"(){init_dist4();init_querying();Checks={tag_name(name){return typeof name=="function"?element=>isTag2(element)&&name(element.name):name==="*"?isTag2:element=>isTag2(element)&&element.name===name},tag_type(type){
|
|
86
|
-
return typeof type=="function"?element=>type(element.type):element=>element.type===type},tag_contains(data){return typeof data=="function"?element=>isText(element)&&data(element.data):element=>isText(element)&&element.data===data}}}});var ElementType2,Root2,Text2,Directive2,Comment2,Script2,Style2,Tag2,CDATA2,Doctype2,init_dist5=__esm({"node_modules/dom-serializer/node_modules/domelementtype/dist/index.js"(){(function(ElementType4){ElementType4.Root="root",ElementType4.Text="text",ElementType4.Directive="directive",ElementType4.Comment="comment",ElementType4.Script="script",ElementType4.Style="style",ElementType4.Tag="tag",ElementType4.CDATA="cdata",ElementType4.Doctype="doctype"})(ElementType2||(ElementType2={}));Root2=ElementType2.
|
|
87
|
-
Root,Text2=ElementType2.Text,Directive2=ElementType2.Directive,Comment2=ElementType2.Comment,Script2=ElementType2.Script,Style2=ElementType2.Style,Tag2=ElementType2.Tag,CDATA2=ElementType2.CDATA,Doctype2=ElementType2.Doctype}});function getEscape(char){return char===34?""":char===38?"&":char===39?"'":char===60?"<":char===62?">":" "}function isXmlEscapable(code){return code>=128||code>=32&&code<64&&(XML_BITSET_VALUE>>>code&1)===1}function encodeXML(input){let{length}=input,out,last=0,index=0;for(;index<length;){let char=input.charCodeAt(index);if(!isXmlEscapable(char)){let bound=Math.min(index+32,length),next=index+1;for(;next<bound&&!isXmlEscapable(input.charCodeAt(next));)next++;if(next<bound){
|
|
88
|
-
index=next;continue}if(next>=length||(xmlEncodeRegex.lastIndex=next,!xmlEncodeRegex.test(input)))break;index=xmlEncodeRegex.lastIndex-1;continue}if(out===void 0?out=input.substring(0,index):last!==index&&(out+=input.substring(last,index)),char<64){out+=getEscape(char),last=index+=1;continue}let cp=input.codePointAt(index);out+=`&#x${cp.toString(16)};`,cp!==char&&index++,last=index+=1}return out===void 0?input:(last<length&&(out+=input.substr(last)),out)}function escapeWithRegex(re,data){if(re.lastIndex=
|
|
89
|
-
0,!re.test(data))return data;let out="",last=0;do{let index=re.lastIndex-1;last!==index&&(out+=data.substring(last,index));let char=data.charCodeAt(index);out+=getEscape(char),last=index+1}while(re.test(data));return out+data.substring(last)}function escapeAttribute(data){return escapeWithRegex(attributeEscapeRegex,data)}function escapeText(data){return escapeWithRegex(textEscapeRegex,data)}var XML_BITSET_VALUE,xmlEncodeRegex,attributeEscapeRegex,textEscapeRegex,init_escape=__esm({"node_modules/\
|
|
90
|
-
dom-serializer/node_modules/entities/dist/escape.js"(){XML_BITSET_VALUE=1342177476,xmlEncodeRegex=/["&'<>\u0080-\uFFFF]/g;attributeEscapeRegex=/["&\u{A0}]/gu;textEscapeRegex=/[&<>\u{A0}]/gu}});var EntityLevel,EncodingMode,init_dist6=__esm({"node_modules/dom-serializer/node_modules/entities/dist/index.js"(){init_escape();(function(EntityLevel2){EntityLevel2[EntityLevel2.XML=0]="XML",EntityLevel2[EntityLevel2.HTML=1]="HTML"})(EntityLevel||(EntityLevel={}));(function(EncodingMode2){EncodingMode2[EncodingMode2.UTF8=0]="UTF8",EncodingMode2[EncodingMode2.ASCII=1]="ASCII",EncodingMode2[EncodingMode2.Extensive=2]="Extensive",EncodingMode2[EncodingMode2.Attribute=3]="Attribute",EncodingMode2[EncodingMode2.
|
|
91
|
-
Text=4]="Text"})(EncodingMode||(EncodingMode={}))}});var elementNames,attributeNames,init_foreign_names=__esm({"node_modules/dom-serializer/dist/foreign-names.js"(){elementNames=new Map("altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotL\
|
|
92
|
-
ight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath".split(" ").map(name=>[name.toLowerCase(),name])),attributeNames=new Map("definitionURL attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves path\
|
|
93
|
-
Length patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" ").map(name=>[name.toLowerCase(),name]))}});function render(node,options={}){let nodes="length"in node?node:[node],xmlMode=options.xmlMode??!1,output="";for(let index=0;index<nodes.length;index++)output+=renderNode(nodes[index],options,xmlMode);return output}function renderChildren(children,options,xmlMode){let output="";for(let index=0;index<children.length;index++)output+=renderNode(children[index],options,xmlMode);return output}function renderNode(node,options,xmlMode){switch(node.type){case Root2:return renderChildren(node.children,options,
|
|
94
|
-
xmlMode);case Directive2:return`<${node.data}>`;case Comment2:return`<!--${node.data}-->`;case CDATA2:return`<![CDATA[${node.children[0].data}]]>`;case Script2:case Style2:case Tag2:return renderTag(node,options,xmlMode);case Text2:{let element=node,data=element.data||"";return(options.encodeEntities??options.decodeEntities)!==!1&&!(!xmlMode&&element.parent&&unencodedElements.has(element.parent.name))?xmlMode||options.encodeEntities!=="utf8"?encodeXML(data):escapeText(data):data}}}function renderTag(element,options,xmlMode){
|
|
95
|
-
xmlMode==="foreign"&&(element.name=elementNames.get(element.name)??element.name,element.parent&&foreignModeIntegrationPoints.has(element.parent.name)&&(xmlMode=!1)),!xmlMode&&foreignElements.has(element.name)&&(xmlMode="foreign");let{name,children}=element,isVoid=!xmlMode&&voidElements.has(name),tag=`<${name}${formatAttributes(element.attribs,options,xmlMode)}`;return children.length===0&&(xmlMode?options.selfClosingTags!==!1:options.selfClosingTags&&isVoid)?tag+=xmlMode?"/>":" />":(tag+=">",children.
|
|
96
|
-
length>0&&(tag+=renderChildren(children,options,xmlMode)),isVoid||(tag+=`</${name}>`)),tag}function replaceQuotes(value){return value.replaceAll('"',""")}function formatAttributes(attributes,options,xmlMode){if(!attributes)return"";let encode=(options.encodeEntities??options.decodeEntities)===!1?replaceQuotes:xmlMode||options.encodeEntities!=="utf8"?encodeXML:escapeAttribute,isForeign=xmlMode==="foreign",showEmpty=!!(options.emptyAttrs??xmlMode),result="";for(let key in attributes){if(!Object.
|
|
97
|
-
hasOwn(attributes,key))continue;let value=attributes[key],k=isForeign?attributeNames.get(key)??key:key;result+=!showEmpty&&(value==null||value==="")?` ${k}`:` ${k}="${encode(value==null?"":String(value))}"`}return result}var unencodedElements,voidElements,foreignElements,foreignModeIntegrationPoints,dist_default,init_dist7=__esm({"node_modules/dom-serializer/dist/index.js"(){init_dist5();init_dist6();init_foreign_names();unencodedElements=new Set("style script xmp iframe noembed noframes plainte\
|
|
98
|
-
xt noscript".split(" ")),voidElements=new Set("area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr".split(" ")),foreignElements=new Set(["svg","math"]),foreignModeIntegrationPoints=new Set("mi mo mn ms mtext annotation-xml foreignObject desc title".split(" "));dist_default=render}});var ElementType3,Root3,Text3,Directive3,Comment3,Script3,Style3,Tag3,CDATA3,Doctype3,init_dist8=__esm({"node_modules/domutils/node_modules/domelementtype/dist/index.js"(){(function(ElementType4){ElementType4.Root="root",ElementType4.Text="text",ElementType4.Directive="directive",ElementType4.Comment="comment",ElementType4.Script="script",ElementType4.Style="style",ElementType4.Tag="tag",ElementType4.CDATA="cdata",ElementType4.Doctype="doctype"})(ElementType3||(ElementType3={}));Root3=ElementType3.
|
|
99
|
-
Root,Text3=ElementType3.Text,Directive3=ElementType3.Directive,Comment3=ElementType3.Comment,Script3=ElementType3.Script,Style3=ElementType3.Style,Tag3=ElementType3.Tag,CDATA3=ElementType3.CDATA,Doctype3=ElementType3.Doctype}});function getOuterHTML(node,options){return dist_default(node,options)}function getInnerHTML(node,options){return hasChildren(node)?node.children.map(node2=>getOuterHTML(node2,options)).join(""):""}function getText(node){return Array.isArray(node)?node.map(getText).join(""):isTag2(node)?node.name==="br"?`
|
|
100
|
-
`:getText(node.children):isCDATA(node)?getText(node.children):isText(node)?node.data:""}function textContent(node){return Array.isArray(node)?node.map(textContent).join(""):hasChildren(node)&&!isComment(node)?textContent(node.children):isText(node)?node.data:""}function innerText(node){return Array.isArray(node)?node.map(innerText).join(""):hasChildren(node)&&(node.type===ElementType3.Tag||isCDATA(node))?innerText(node.children):isText(node)?node.data:""}var init_stringify=__esm({"node_modules/d\
|
|
101
|
-
omutils/dist/stringify.js"(){init_dist7();init_dist8();init_dist4()}});function getFeed(document){let feedRoot=getOneElement(isValidFeed,document);return feedRoot?feedRoot.name==="feed"?getAtomFeed(feedRoot):getRssFeed(feedRoot):null}function getAtomFeed(feedRoot){let childs=feedRoot.children,feed={type:"atom",items:getElementsByTagName("entry",childs).map(item=>{let{children}=item,entry={media:getMediaElements(children)};addConditionally(entry,"id","id",children),addConditionally(entry,"title","title",children);let href2=getOneElement("link",children)?.attribs.href;
|
|
102
|
-
href2&&(entry.link=href2);let description=fetch("summary",children)||fetch("content",children);description&&(entry.description=description);let pubDate=fetch("updated",children);return pubDate&&(entry.pubDate=new Date(pubDate)),entry})};addConditionally(feed,"id","id",childs),addConditionally(feed,"title","title",childs);let href=getOneElement("link",childs)?.attribs.href;href&&(feed.link=href),addConditionally(feed,"description","subtitle",childs);let updated=fetch("updated",childs);return updated&&
|
|
103
|
-
(feed.updated=new Date(updated)),addConditionally(feed,"author","email",childs,!0),feed}function getRssFeed(feedRoot){let childs=getOneElement("channel",feedRoot.children)?.children??[],feed={type:feedRoot.name.substr(0,3),id:"",items:getElementsByTagName("item",feedRoot.children).map(item=>{let{children}=item,entry={media:getMediaElements(children)};addConditionally(entry,"id","guid",children),addConditionally(entry,"title","title",children),addConditionally(entry,"link","link",children),addConditionally(
|
|
104
|
-
entry,"description","description",children);let pubDate=fetch("pubDate",children)||fetch("dc:date",children);return pubDate&&(entry.pubDate=new Date(pubDate)),entry})};addConditionally(feed,"title","title",childs),addConditionally(feed,"link","link",childs),addConditionally(feed,"description","description",childs);let updated=fetch("lastBuildDate",childs);return updated&&(feed.updated=new Date(updated)),addConditionally(feed,"author","managingEditor",childs,!0),feed}function getMediaElements(where){
|
|
105
|
-
return getElementsByTagName("media:content",where).map(element=>{let{attribs}=element,media={medium:attribs.medium,isDefault:!!attribs.isDefault};for(let attrib of MEDIA_KEYS_STRING)attribs[attrib]&&(media[attrib]=attribs[attrib]);for(let attrib of MEDIA_KEYS_INT)attribs[attrib]&&(media[attrib]=Number.parseInt(attribs[attrib],10));return attribs.expression&&(media.expression=attribs.expression),media})}function getOneElement(tagName,node){return getElementsByTagName(tagName,node,!0,1)[0]}function fetch(tagName,where,recurse=!1){
|
|
106
|
-
return textContent(getElementsByTagName(tagName,where,recurse,1)).trim()}function addConditionally(object,property,tagName,where,recurse=!1){let value=fetch(tagName,where,recurse);value&&(object[property]=value)}function isValidFeed(value){return value==="rss"||value==="feed"||value==="rdf:RDF"}var MEDIA_KEYS_STRING,MEDIA_KEYS_INT,init_feeds=__esm({"node_modules/domutils/dist/feeds.js"(){init_legacy();init_stringify();MEDIA_KEYS_STRING=["url","type","lang"],MEDIA_KEYS_INT=["fileSize","bitrate","\
|
|
107
|
-
framerate","samplingrate","channels","duration","height","width"]}});function removeSubsets(nodes){let index=nodes.length;for(;--index>=0;){let node=nodes[index];if(index>0&&nodes.lastIndexOf(node,index-1)>=0){nodes.splice(index,1);continue}for(let ancestor=node.parent;ancestor;ancestor=ancestor.parent)if(nodes.includes(ancestor)){nodes.splice(index,1);break}}return nodes}function compareDocumentPosition(nodeA,nodeB){let aParents=[],bParents=[];if(nodeA===nodeB)return 0;let current=hasChildren(nodeA)?nodeA:nodeA.parent;for(;current;)aParents.unshift(current),current=
|
|
108
|
-
current.parent;for(current=hasChildren(nodeB)?nodeB:nodeB.parent;current;)bParents.unshift(current),current=current.parent;let maxIndex=Math.min(aParents.length,bParents.length),index=0;for(;index<maxIndex&&aParents[index]===bParents[index];)index++;if(index===0)return DocumentPosition.DISCONNECTED;let sharedParent=aParents[index-1],siblings=sharedParent.children,aSibling=aParents[index],bSibling=bParents[index];return siblings.indexOf(aSibling)>siblings.indexOf(bSibling)?sharedParent===nodeB?DocumentPosition.
|
|
109
|
-
FOLLOWING|DocumentPosition.CONTAINED_BY:DocumentPosition.FOLLOWING:sharedParent===nodeA?DocumentPosition.PRECEDING|DocumentPosition.CONTAINS:DocumentPosition.PRECEDING}function uniqueSort(nodes){return nodes=nodes.filter((node,index,array)=>!array.includes(node,index+1)),nodes.sort((a,b)=>{let relative=compareDocumentPosition(a,b);return relative&DocumentPosition.PRECEDING?-1:relative&DocumentPosition.FOLLOWING?1:0}),nodes}var DocumentPosition,init_helpers=__esm({"node_modules/domutils/dist/help\
|
|
110
|
-
ers.js"(){init_dist4();(function(DocumentPosition2){DocumentPosition2[DocumentPosition2.DISCONNECTED=1]="DISCONNECTED",DocumentPosition2[DocumentPosition2.PRECEDING=2]="PRECEDING",DocumentPosition2[DocumentPosition2.FOLLOWING=4]="FOLLOWING",DocumentPosition2[DocumentPosition2.CONTAINS=8]="CONTAINS",DocumentPosition2[DocumentPosition2.CONTAINED_BY=16]="CONTAINED_BY"})(DocumentPosition||(DocumentPosition={}))}});function removeElement(element){if(element.prev&&(element.prev.next=element.next),element.next&&(element.next.prev=element.prev),element.parent){let childs=element.parent.children,childsIndex=childs.lastIndexOf(element);childsIndex!==-1&&childs.splice(childsIndex,1)}element.next=null,element.prev=null,element.parent=null}function replaceElement(element,replacement){if(replacement.prev=element.prev,replacement.prev&&(replacement.prev.next=replacement),replacement.next=element.next,replacement.next&&
|
|
111
|
-
(replacement.next.prev=replacement),replacement.parent=element.parent,replacement.parent){let{children}=replacement.parent,elementIndex=children.lastIndexOf(element);if(elementIndex===-1)return;children[elementIndex]=replacement,element.parent=null}}function appendChild(parent,child){if(removeElement(child),child.next=null,child.parent=parent,parent.children.push(child)>1){let sibling=parent.children[parent.children.length-2];sibling.next=child,child.prev=sibling}else child.prev=null}function append(element,next){
|
|
112
|
-
removeElement(next);let{parent}=element,currentNext=element.next;if(next.next=currentNext,next.prev=element,element.next=next,next.parent=parent,currentNext){if(currentNext.prev=next,parent){let childs=parent.children;childs.splice(childs.lastIndexOf(currentNext),0,next)}}else parent&&parent.children.push(next)}function prependChild(parent,child){if(removeElement(child),child.parent=parent,child.prev=null,parent.children.unshift(child)===1)child.next=null;else{let sibling=parent.children[1];sibling.
|
|
113
|
-
prev=child,child.next=sibling}}function prepend(element,previous){removeElement(previous);let{parent}=element;if(parent){let childs=parent.children;childs.splice(childs.indexOf(element),0,previous)}element.prev&&(element.prev.next=previous),previous.parent=parent,previous.prev=element.prev,previous.next=element,element.prev=previous}var init_manipulation=__esm({"node_modules/domutils/dist/manipulation.js"(){}});function getChildren(element){return hasChildren(element)?element.children:[]}function getParent(element){return element.parent||null}function getSiblings(element){let parent=getParent(element);if(parent!=null)return getChildren(parent);let siblings=[element],{prev,next}=element;for(;prev!=null;)siblings.unshift(prev),{prev}=prev;for(;next!=null;)siblings.push(next),{next}=next;return siblings}function getAttributeValue(element,name){let{attribs}=element;return attribs?.[name]}function hasAttrib(element,name){
|
|
114
|
-
let{attribs}=element;return attribs!=null&&Object.hasOwn(attribs,name)&&attribs[name]!=null}function getName(element){return element.name}function nextElementSibling(element){let{next}=element;for(;next!==null&&!isTag2(next);)({next}=next);return next}function prevElementSibling(element){let{prev}=element;for(;prev!==null&&!isTag2(prev);)({prev}=prev);return prev}var init_traversal=__esm({"node_modules/domutils/dist/traversal.js"(){init_dist4()}});var dist_exports2={};__export(dist_exports2,{DocumentPosition:()=>DocumentPosition,append:()=>append,appendChild:()=>appendChild,compareDocumentPosition:()=>compareDocumentPosition,existsOne:()=>existsOne,filter:()=>filter,find:()=>find,findAll:()=>findAll,findOne:()=>findOne,getAttributeValue:()=>getAttributeValue,getChildren:()=>getChildren,getElementById:()=>getElementById,getElements:()=>getElements,getElementsByClassName:()=>getElementsByClassName,getElementsByTagName:()=>getElementsByTagName,
|
|
115
|
-
getElementsByTagType:()=>getElementsByTagType,getFeed:()=>getFeed,getInnerHTML:()=>getInnerHTML,getName:()=>getName,getOuterHTML:()=>getOuterHTML,getParent:()=>getParent,getSiblings:()=>getSiblings,getText:()=>getText,hasAttrib:()=>hasAttrib,innerText:()=>innerText,nextElementSibling:()=>nextElementSibling,prepend:()=>prepend,prependChild:()=>prependChild,prevElementSibling:()=>prevElementSibling,removeElement:()=>removeElement,removeSubsets:()=>removeSubsets,replaceElement:()=>replaceElement,testElement:()=>testElement,
|
|
116
|
-
textContent:()=>textContent,uniqueSort:()=>uniqueSort});var init_dist9=__esm({"node_modules/domutils/dist/index.js"(){init_feeds();init_helpers();init_legacy();init_manipulation();init_querying();init_stringify();init_traversal()}});function escapeRegex(value){return value.replace(reChars,"\\$&")}function shouldIgnoreCase(selector,options){return typeof selector.ignoreCase=="boolean"?selector.ignoreCase:selector.ignoreCase==="quirks"?!!options.quirksMode:!options.xmlMode&&caseInsensitiveAttributes.has(selector.name)}var reChars,whitespaceRe,caseInsensitiveAttributes,attributeRules,init_attributes=__esm({"node_modules/css-select/dist/attributes.js"(){init_dist();reChars=/[-[\]{}()*+?.,\\^$|#\s]/g,whitespaceRe=/\s/;caseInsensitiveAttributes=
|
|
117
|
-
new Set(["accept","accept-charset","align","alink","axis","bgcolor","charset","checked","clear","codetype","color","compact","declare","defer","dir","direction","disabled","enctype","face","frame","hreflang","http-equiv","lang","language","link","media","method","multiple","nohref","noresize","noshade","nowrap","readonly","rel","rev","rules","scope","scrolling","selected","shape","target","text","type","valign","valuetype","vlink"]);attributeRules={equals(next,data,options){let{adapter}=options,
|
|
118
|
-
{name}=data,{value}=data;return shouldIgnoreCase(data,options)?(value=value.toLowerCase(),element=>{let attribute=adapter.getAttributeValue(element,name);return attribute!=null&&attribute.length===value.length&&attribute.toLowerCase()===value&&next(element)}):element=>adapter.getAttributeValue(element,name)===value&&next(element)},hyphen(next,data,options){let{adapter}=options,{name}=data,{value}=data,{length}=value;return shouldIgnoreCase(data,options)?(value=value.toLowerCase(),function(element){
|
|
119
|
-
let attribute=adapter.getAttributeValue(element,name);return attribute!=null&&(attribute.length===length||attribute.charAt(length)==="-")&&attribute.substr(0,length).toLowerCase()===value&&next(element)}):function(element){let attribute=adapter.getAttributeValue(element,name);return attribute!=null&&(attribute.length===length||attribute.charAt(length)==="-")&&attribute.substr(0,length)===value&&next(element)}},element(next,data,options){let{adapter}=options,{name,value}=data;if(whitespaceRe.test(
|
|
120
|
-
value))return falseFunc;let regex=new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`,shouldIgnoreCase(data,options)?"i":"");return function(node){let attribute=adapter.getAttributeValue(node,name);return attribute!=null&&attribute.length>=value.length&®ex.test(attribute)&&next(node)}},exists(next,{name},{adapter}){return element=>adapter.hasAttrib(element,name)&&next(element)},start(next,data,options){let{adapter}=options,{name}=data,{value}=data,{length}=value;return length===0?falseFunc:shouldIgnoreCase(
|
|
121
|
-
data,options)?(value=value.toLowerCase(),element=>{let attribute=adapter.getAttributeValue(element,name);return attribute!=null&&attribute.length>=length&&attribute.substr(0,length).toLowerCase()===value&&next(element)}):element=>!!adapter.getAttributeValue(element,name)?.startsWith(value)&&next(element)},end(next,data,options){let{adapter}=options,{name}=data,{value}=data,length=-value.length;return length===0?falseFunc:shouldIgnoreCase(data,options)?(value=value.toLowerCase(),element=>adapter.
|
|
122
|
-
getAttributeValue(element,name)?.substr(length).toLowerCase()===value&&next(element)):element=>!!adapter.getAttributeValue(element,name)?.endsWith(value)&&next(element)},any(next,data,options){let{adapter}=options,{name,value}=data;if(value==="")return falseFunc;if(shouldIgnoreCase(data,options)){let regex=new RegExp(escapeRegex(value),"i");return function(element){let attribute=adapter.getAttributeValue(element,name);return attribute!=null&&attribute.length>=value.length&®ex.test(attribute)&&
|
|
123
|
-
next(element)}}return element=>!!adapter.getAttributeValue(element,name)?.includes(value)&&next(element)},not(next,data,options){let{adapter}=options,{name}=data,{value}=data;return value===""?element=>!!adapter.getAttributeValue(element,name)&&next(element):shouldIgnoreCase(data,options)?(value=value.toLowerCase(),element=>{let attribute=adapter.getAttributeValue(element,name);return(attribute==null||attribute.length!==value.length||attribute.toLowerCase()!==value)&&next(element)}):element=>adapter.
|
|
124
|
-
getAttributeValue(element,name)!==value&&next(element)}}}});function findAll2(query,nodes,options){let{adapter,xmlMode=!1}=options,result=[],nodeStack=[nodes],indexStack=[0];for(;;){if(indexStack[0]>=nodeStack[0].length){if(nodeStack.length===1)return result;nodeStack.shift(),indexStack.shift();continue}let element=nodeStack[0][indexStack[0]++];if(adapter.isTag(element)&&(query(element)&&result.push(element),xmlMode||adapter.getName(element)!=="template")){let children=adapter.getChildren(element);children.length>0&&(nodeStack.unshift(children),indexStack.
|
|
125
|
-
unshift(0))}}}function findOne2(query,nodes,options){let{adapter,xmlMode=!1}=options,nodeStack=[nodes],indexStack=[0];for(;;){if(indexStack[0]>=nodeStack[0].length){if(nodeStack.length===1)return null;nodeStack.shift(),indexStack.shift();continue}let element=nodeStack[0][indexStack[0]++];if(adapter.isTag(element)){if(query(element))return element;if(xmlMode||adapter.getName(element)!=="template"){let children=adapter.getChildren(element);children.length>0&&(nodeStack.unshift(children),indexStack.
|
|
126
|
-
unshift(0))}}}}function getNextSiblings(element,adapter){let siblings=adapter.getSiblings(element);if(siblings.length<=1)return[];let elementIndex=siblings.indexOf(element);return elementIndex===-1||elementIndex===siblings.length-1?[]:siblings.slice(elementIndex+1).filter(adapter.isTag)}function getElementParent(node,adapter){let parent=adapter.getParent(node);return parent!=null&&adapter.isTag(parent)?parent:null}var init_querying2=__esm({"node_modules/css-select/dist/helpers/querying.js"(){}});var textControl,aliases,init_aliases=__esm({"node_modules/css-select/dist/pseudo-selectors/aliases.js"(){textControl="input:is([type=text i],[type=search i],[type=url i],[type=tel i],[type=email i],[type=password i],[type=date i],[type=month i],[type=week i],[type=time i],[type=datetime-local i],[type=number i])",aliases={"any-link":":is(a, area, link)[href]",link:":any-link:not(:visited)",disabled:`:is(
|
|
127
|
-
:is(button, input, select, textarea, optgroup, option)[disabled],
|
|
128
|
-
optgroup[disabled] > option,
|
|
129
|
-
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
|
|
130
|
-
)`,enabled:":is(button, input, select, textarea, optgroup, option, fieldset):not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], :selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])","read-only":`[readonly]:is(textarea, ${textControl})`,"read-write":`:not([readonly]):is(textarea, ${textControl})`,selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
|
|
131
|
-
checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"}}});function compile(parsed){let a=parsed[0],b=parsed[1]-1;if(b<0&&a<=0)return falseFunc;if(a===-1)return index=>index<=b;if(a===0)return index=>index===b;if(a===1)return b<0?trueFunc:index=>index>=b;let absA=Math.abs(a),bModulo=(b%absA+absA)%absA;return a>1?index=>index>=b&&index%absA===bModulo:index=>index<=b&&index%absA===bModulo}var init_compile=__esm({"node_modules/nth-check/dist/compile.js"(){init_dist()}});function parse2(formula){switch(formula=formula.trim().toLowerCase(),formula){case"even":return[2,0];case"odd":return[2,1]}let index=0,a=0,sign=readSign(),number=readNumber();if(index<formula.length&&formula.charAt(index)==="n"&&(index++,a=sign*(number??1),skipWhitespace(),index<formula.length?(sign=readSign(),skipWhitespace(),number=readNumber()):sign=number=0),number===null||index<formula.length)throw new Error(`n-th rule couldn't be parsed ('${formula}')`);return[a,sign*number];function readSign(){
|
|
132
|
-
switch(formula.charAt(index)){case"-":return index++,-1;case"+":{index++;break}}return 1}function readNumber(){let start=index,value=0;for(;index<formula.length&&formula.charCodeAt(index)>=ZERO&&formula.charCodeAt(index)<=NINE;)value=value*10+(formula.charCodeAt(index)-ZERO),index++;return index===start?null:value}function skipWhitespace(){for(;index<formula.length&&whitespace.has(formula.charCodeAt(index));)index++}}var whitespace,ZERO,NINE,init_parse2=__esm({"node_modules/nth-check/dist/parse.\
|
|
133
|
-
js"(){whitespace=new Set([9,10,12,13,32]),ZERO=48,NINE=57}});function nthCheck(formula){return compile(parse2(formula))}var init_dist10=__esm({"node_modules/nth-check/dist/index.js"(){init_compile();init_parse2()}});function cacheParentResults(next,{adapter,cacheResults},matches){if(cacheResults===!1||typeof WeakMap>"u")return element=>next(element)&&matches(element);let resultCache=new WeakMap;function addResultToCache(element){let result=matches(element);return resultCache.set(element,result),result}return function(element){if(!next(element))return!1;if(resultCache.has(element))return resultCache.get(element)??!1;let node=element;do{let parent=getElementParent(node,adapter);if(parent===null)return addResultToCache(
|
|
134
|
-
element);node=parent}while(!resultCache.has(node));return resultCache.get(node)?addResultToCache(element):!1}}var init_cache=__esm({"node_modules/css-select/dist/helpers/cache.js"(){init_querying2()}});function copyOptions(options){let{context:_,rootFunc:__,...copied}=options;return copied}var init_options=__esm({"node_modules/css-select/dist/helpers/options.js"(){}});function extendedFilter(tag,range){if(range[0]!=="*"&&range[0]!==tag[0])return!1;let tagIndex=1;for(let rangeIndex=1;rangeIndex<range.length;rangeIndex++)if(range[rangeIndex]!=="*"){for(;tagIndex<tag.length&&tag[tagIndex]!==range[rangeIndex];)if(tag[tagIndex++].length<=1)return!1;if(tagIndex>=tag.length)return!1;tagIndex++}return!0}function compileNth(reverse,ofType){return function(next,rule,options,context,compileToken2){let{adapter,equals}=options,ofMatch=ofType?null:rule.match(nthOfRegex),nthCheck2=nthCheck(
|
|
135
|
-
ofMatch?ofMatch[1].trim():rule);if(nthCheck2===falseFunc)return falseFunc;let ofSelector=ofMatch&&compileToken2?compileToken2(parse(ofMatch[2].trim()),copyOptions(options),context):void 0;if(ofSelector===falseFunc)return falseFunc;if(nthCheck2===trueFunc&&!ofSelector)return element=>getElementParent(element,adapter)!==null&&next(element);let shouldCount=ofSelector?(_element,sibling)=>ofSelector(sibling):ofType?(element,sibling)=>adapter.getName(sibling)===adapter.getName(element):trueFunc;return reverse?
|
|
136
|
-
function(element){if(ofSelector&&!ofSelector(element))return!1;let siblings=adapter.getSiblings(element),pos=0;for(let index=siblings.length-1;index>=0;index--){let sibling=siblings[index];if(equals(element,sibling))break;adapter.isTag(sibling)&&shouldCount(element,sibling)&&pos++}return nthCheck2(pos)&&next(element)}:function(element){if(ofSelector&&!ofSelector(element))return!1;let siblings=adapter.getSiblings(element),pos=0;for(let sibling of siblings){if(equals(element,sibling))break;adapter.
|
|
137
|
-
isTag(sibling)&&shouldCount(element,sibling)&&pos++}return nthCheck2(pos)&&next(element)}}}function dynamicStatePseudo(name){return function(next,_rule,{adapter}){let filterFunction=adapter[name];return typeof filterFunction!="function"?falseFunc:function(element){return filterFunction(element)&&next(element)}}}var nthOfRegex,filters,init_filters=__esm({"node_modules/css-select/dist/pseudo-selectors/filters.js"(){init_dist();init_dist2();init_dist10();init_cache();init_options();init_querying2();
|
|
138
|
-
nthOfRegex=/^(.+?)\s+of\s+(.+)$/is;filters={contains(next,text,options){let{getText:getText2}=options.adapter;return cacheParentResults(next,options,element=>getText2(element).includes(text))},icontains(next,text,options){let itext=text.toLowerCase(),{getText:getText2}=options.adapter;return cacheParentResults(next,options,element=>getText2(element).toLowerCase().includes(itext))},"nth-child":compileNth(!1,!1),"nth-last-child":compileNth(!0,!1),"nth-of-type":compileNth(!1,!0),"nth-last-of-type":compileNth(
|
|
139
|
-
!0,!0),root(next,_rule,{adapter}){return element=>getElementParent(element,adapter)===null&&next(element)},scope(next,rule,options,context){let{equals}=options;return!context||context.length===0?filters.root(next,rule,options):context.length===1?element=>equals(context[0],element)&&next(element):element=>context.includes(element)&&next(element)},lang(next,code,{adapter}){let ranges=code.split(",").map(r=>r.trim()).filter(r=>r.length>0).map(r=>r.replace(/^['"]|['"]$/g,"").toLowerCase().split("-"));
|
|
140
|
-
return function(element){let node=element;for(;node!=null;){let value=adapter.getAttributeValue(node,"xml:lang")??adapter.getAttributeValue(node,"lang");if(value!=null){if(!value)return ranges.some(r=>r[0]==="")&&next(element);let tag=value.toLowerCase().split("-");return ranges.some(r=>extendedFilter(tag,r))&&next(element)}let parent=adapter.getParent(node);node=parent!=null&&adapter.isTag(parent)?parent:null}return ranges.some(r=>r[0]==="")&&next(element)}},hover:dynamicStatePseudo("isHovered"),
|
|
141
|
-
visited:dynamicStatePseudo("isVisited"),active:dynamicStatePseudo("isActive")}}});function verifyPseudoArguments(pseudoClassCondition,name,subselect,argumentIndex){if(subselect===null){if(pseudoClassCondition.length>argumentIndex)throw new Error(`Pseudo-class :${name} requires an argument`)}else if(pseudoClassCondition.length===argumentIndex)throw new Error(`Pseudo-class :${name} doesn't have any arguments`)}var isDocumentWhiteSpace,pseudos,init_pseudos=__esm({"node_modules/css-select/dist/pseudo-selectors/pseudos.js"(){isDocumentWhiteSpace=/^[ \t\r\n]*$/,pseudos={empty(element,{
|
|
142
|
-
adapter}){let children=adapter.getChildren(element);return children.every(element2=>!adapter.isTag(element2))&&children.every(element2=>isDocumentWhiteSpace.test(adapter.getText(element2)))},"first-child"(element,{adapter,equals}){if(adapter.prevElementSibling)return adapter.prevElementSibling(element)==null;let firstChild=adapter.getSiblings(element).find(sibling=>adapter.isTag(sibling));return firstChild!=null&&equals(element,firstChild)},"last-child"(element,{adapter,equals}){let siblings=adapter.
|
|
143
|
-
getSiblings(element);for(let index=siblings.length-1;index>=0;index--){if(equals(element,siblings[index]))return!0;if(adapter.isTag(siblings[index]))break}return!1},"first-of-type"(element,{adapter,equals}){let siblings=adapter.getSiblings(element),elementName=adapter.getName(element);for(let currentSibling of siblings){if(equals(element,currentSibling))return!0;if(adapter.isTag(currentSibling)&&adapter.getName(currentSibling)===elementName)break}return!1},"last-of-type"(element,{adapter,equals}){
|
|
144
|
-
let siblings=adapter.getSiblings(element),elementName=adapter.getName(element);for(let index=siblings.length-1;index>=0;index--){let currentSibling=siblings[index];if(equals(element,currentSibling))return!0;if(adapter.isTag(currentSibling)&&adapter.getName(currentSibling)===elementName)break}return!1},"only-of-type"(element,{adapter,equals}){let elementName=adapter.getName(element);return adapter.getSiblings(element).every(sibling=>equals(element,sibling)||!adapter.isTag(sibling)||adapter.getName(
|
|
145
|
-
sibling)!==elementName)},"only-child"(element,{adapter,equals}){return adapter.getSiblings(element).every(sibling=>equals(element,sibling)||!adapter.isTag(sibling))}}}});function isTraversal2(token){return token.type==="_flexibleDescendant"||isTraversal(token)}function sortRules(array){let ratings=array.map(getQuality);for(let index=1;index<array.length;index++){let procNew=ratings[index];if(!(procNew<0))for(let currentIndex=index;currentIndex>0&&procNew<ratings[currentIndex-1];currentIndex--){let token=array[currentIndex];array[currentIndex]=array[currentIndex-1],array[currentIndex-1]=token,ratings[currentIndex]=ratings[currentIndex-1],ratings[currentIndex-1]=procNew}}}
|
|
146
|
-
function getAttributeQuality(token){switch(token.action){case AttributeAction.Exists:return 10;case AttributeAction.Equals:return token.name==="id"?9:8;case AttributeAction.Not:return 7;case AttributeAction.Start:return 6;case AttributeAction.End:return 6;case AttributeAction.Any:return 5;case AttributeAction.Hyphen:return 4;case AttributeAction.Element:return 3}}function getQuality(token){switch(token.type){case SelectorType.Universal:return 50;case SelectorType.Tag:return 30;case SelectorType.
|
|
147
|
-
Attribute:return Math.floor(getAttributeQuality(token)/(token.ignoreCase?2:1));case SelectorType.Pseudo:return token.data?token.name==="has"||token.name==="contains"||token.name==="icontains"?0:Array.isArray(token.data)?Math.max(0,Math.min(...token.data.map(d=>Math.min(...d.map(getQuality))))):2:3;default:return-1}}function includesScopePseudo(t){return t.type===SelectorType.Pseudo&&(t.name==="scope"||Array.isArray(t.data)&&t.data.some(data=>data.some(includesScopePseudo)))}var init_selectors=__esm(
|
|
148
|
-
{"node_modules/css-select/dist/helpers/selectors.js"(){init_dist2()}});function hasDependsOnCurrentElement(selector){return selector.some(sel=>sel.length>0&&(isTraversal2(sel[0])||sel.some(includesScopePseudo)))}var PLACEHOLDER_ELEMENT,is,subselects,init_subselects=__esm({"node_modules/css-select/dist/pseudo-selectors/subselects.js"(){init_dist();init_cache();init_options();init_querying2();init_selectors();PLACEHOLDER_ELEMENT={};is=(next,token,options,context,compileToken2)=>{let compiledToken=compileToken2(token,copyOptions(options),context);return compiledToken===
|
|
149
|
-
trueFunc?next:compiledToken===falseFunc?falseFunc:element=>compiledToken(element)&&next(element)},subselects={is,matches:is,where:is,not(next,token,options,context,compileToken2){let compiledToken=compileToken2(token,copyOptions(options),context);return compiledToken===falseFunc?next:compiledToken===trueFunc?falseFunc:element=>!compiledToken(element)&&next(element)},has(next,subselect,options,_context,compileToken2){let{adapter}=options,copiedOptions=copyOptions(options);copiedOptions.relativeSelector=
|
|
150
|
-
!0;let context=subselect.some(s=>s.some(isTraversal2))?[PLACEHOLDER_ELEMENT]:void 0,skipCache=hasDependsOnCurrentElement(subselect),compiled=compileToken2(subselect,copiedOptions,context);if(compiled===falseFunc)return falseFunc;if(context&&compiled!==trueFunc)return skipCache?element=>{if(!next(element))return!1;context[0]=element;let childs=adapter.getChildren(element);return findOne2(compiled,compiled.shouldTestNextSiblings?[...childs,...getNextSiblings(element,adapter)]:childs,options)!==null}:
|
|
151
|
-
cacheParentResults(next,options,element=>(context[0]=element,findOne2(compiled,adapter.getChildren(element),options)!==null));let hasOne=element=>findOne2(compiled,adapter.getChildren(element),options)!==null;return skipCache?element=>next(element)&&hasOne(element):cacheParentResults(next,options,hasOne)}}}});function compilePseudoSelector(next,selector,options,context,compileToken2){let{name,data}=selector;if(Array.isArray(data)){if(!(name in subselects))throw new Error(`Unknown pseudo-class :${name}(${data})`);return subselects[name](next,data,options,context,compileToken2)}let userPseudo=options.pseudos?.[name],stringPseudo=typeof userPseudo=="string"?userPseudo:aliases[name];if(typeof stringPseudo=="string"){if(data!=null)throw new Error(`Pseudo ${name} doesn't have any arguments`);let alias=parse(
|
|
152
|
-
stringPseudo);return subselects.is(next,alias,options,context,compileToken2)}if(typeof userPseudo=="function")return verifyPseudoArguments(userPseudo,name,data,1),element=>userPseudo(element,data)&&next(element);if(name in filters)return filters[name](next,data,options,context,compileToken2);if(name in pseudos){let pseudo=pseudos[name];return verifyPseudoArguments(pseudo,name,data,2),element=>pseudo(element,options,data)&&next(element)}throw new Error(`Unknown pseudo-class :${name}`)}var init_pseudo_selectors=__esm(
|
|
153
|
-
{"node_modules/css-select/dist/pseudo-selectors/index.js"(){init_dist2();init_aliases();init_filters();init_pseudos();init_subselects()}});function compileGeneralSelector(next,selector,options,context,compileToken2,hasExpensiveSubselector){let{adapter,equals,cacheResults}=options;switch(selector.type){case SelectorType.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case SelectorType.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case SelectorType.Attribute:{if(selector.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-sel\
|
|
154
|
-
ect");return(!options.xmlMode||options.lowerCaseAttributeNames)&&(selector.name=selector.name.toLowerCase()),attributeRules[selector.action](next,selector,options)}case SelectorType.Pseudo:return compilePseudoSelector(next,selector,options,context,compileToken2);case SelectorType.Tag:{if(selector.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name}=selector;return(!options.xmlMode||options.lowerCaseTags)&&(name=name.toLowerCase()),function(element){
|
|
155
|
-
return adapter.getName(element)===name&&next(element)}}case SelectorType.Descendant:{if(!hasExpensiveSubselector||cacheResults===!1||typeof WeakMap>"u")return function(element){let current=element;for(;current=getElementParent(current,adapter);)if(next(current))return!0;return!1};let resultCache=new WeakMap;return function(element){let current=element,result;for(;current=getElementParent(current,adapter);){let cached=resultCache.get(current);if(cached===void 0){if(result??={matches:!1},result.matches=
|
|
156
|
-
next(current),resultCache.set(current,result),result.matches)return!0}else return result&&(result.matches=cached.matches),cached.matches}return!1}}case"_flexibleDescendant":return function(element){let current=element;do{if(next(current))return!0;current=getElementParent(current,adapter)}while(current);return!1};case SelectorType.Parent:return function(element){return adapter.getChildren(element).some(element2=>adapter.isTag(element2)&&next(element2))};case SelectorType.Child:return function(element){
|
|
157
|
-
let parent=getElementParent(element,adapter);return parent!==null&&next(parent)};case SelectorType.Sibling:return function(element){let siblings=adapter.getSiblings(element);for(let currentSibling of siblings){if(equals(element,currentSibling))break;if(adapter.isTag(currentSibling)&&next(currentSibling))return!0}return!1};case SelectorType.Adjacent:return adapter.prevElementSibling?function(element){let previous=adapter.prevElementSibling(element);return previous!=null&&next(previous)}:function(element){
|
|
158
|
-
let siblings=adapter.getSiblings(element),lastElement;for(let currentSibling of siblings){if(equals(element,currentSibling))break;adapter.isTag(currentSibling)&&(lastElement=currentSibling)}return!!lastElement&&next(lastElement)};case SelectorType.Universal:{if(selector.namespace!=null&&selector.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return next}}}var init_general=__esm({"node_modules/css-select/dist/general.js"(){init_dist2();init_attributes();
|
|
159
|
-
init_querying2();init_pseudo_selectors()}});function absolutize(token,{adapter},context){let hasContext=!!context?.every(element=>element===PLACEHOLDER_ELEMENT||adapter.isTag(element)&&getElementParent(element,adapter)!==null);for(let t of token){if(!(t.length>0&&isTraversal2(t[0])&&t[0].type!==SelectorType.Descendant))if(hasContext&&!t.some(includesScopePseudo))t.unshift(DESCENDANT_TOKEN);else continue;t.unshift(SCOPE_TOKEN)}}function compileToken(token,options,compilationContext){for(let rules of token)sortRules(rules);let{context=compilationContext,
|
|
160
|
-
rootFunc:rootFunction=trueFunc}=options,isArrayContext=Array.isArray(context),finalContext=context&&(Array.isArray(context)?context:[context]);if(options.relativeSelector!==!1)absolutize(token,options,finalContext);else if(token.some(t=>t.length>0&&isTraversal2(t[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let shouldTestNextSiblings=!1,query=falseFunc;combineLoop:for(let rules of token){if(rules.length>=2){let[first,second]=rules;first.
|
|
161
|
-
type!==SelectorType.Pseudo||first.name!=="scope"||(isArrayContext&&second.type===SelectorType.Descendant?rules[1]=FLEXIBLE_DESCENDANT_TOKEN:(second.type===SelectorType.Adjacent||second.type===SelectorType.Sibling)&&(shouldTestNextSiblings=!0))}let next=rootFunction,hasExpensiveSubselector=!1;for(let rule of rules)if(next=compileGeneralSelector(next,rule,options,finalContext,compileToken,hasExpensiveSubselector),getQuality(rule)===0&&(hasExpensiveSubselector=!0),next===falseFunc)continue combineLoop;
|
|
162
|
-
if(next===rootFunction)return rootFunction;query=query===falseFunc?next:or(query,next)}return query.shouldTestNextSiblings=shouldTestNextSiblings,query}function or(a,b){return element=>a(element)||b(element)}var DESCENDANT_TOKEN,FLEXIBLE_DESCENDANT_TOKEN,SCOPE_TOKEN,init_compile2=__esm({"node_modules/css-select/dist/compile.js"(){init_dist();init_dist2();init_general();init_querying2();init_selectors();init_subselects();DESCENDANT_TOKEN={type:SelectorType.Descendant},FLEXIBLE_DESCENDANT_TOKEN={type:"\
|
|
163
|
-
_flexibleDescendant"},SCOPE_TOKEN={type:SelectorType.Pseudo,name:"scope",data:null}}});var dist_exports4={};__export(dist_exports4,{_compileUnsafe:()=>_compileUnsafe,compile:()=>compile2,default:()=>dist_default2,is:()=>is2,prepareContext:()=>prepareContext,selectAll:()=>selectAll,selectOne:()=>selectOne});function convertOptionFormats(options){let finalOptions=options??defaultOptions;return finalOptions.adapter??=defaultOptions.adapter,finalOptions.equals??=finalOptions.adapter?.equals??defaultEquals,finalOptions}function compile2(selector,options,context){let convertedOptions=convertOptionFormats(
|
|
164
|
-
options),next=_compileUnsafe(selector,convertedOptions,context);return next===falseFunc?falseFunc:element=>convertedOptions.adapter.isTag(element)&&next(element)}function _compileUnsafe(selector,options,context){return compileToken(typeof selector=="string"?parse(selector):selector,convertOptionFormats(options),context)}function getSelectorFunction(searchFunction){return function(query,elements,options){let convertedOptions=convertOptionFormats(options);typeof query!="function"&&(query=_compileUnsafe(
|
|
165
|
-
query,convertedOptions,elements));let filteredElements=prepareContext(elements,convertedOptions.adapter,query.shouldTestNextSiblings);return searchFunction(query,filteredElements,convertedOptions)}}function prepareContext(elements,adapter,shouldTestNextSiblings=!1){return shouldTestNextSiblings&&(elements=appendNextSiblings(elements,adapter)),Array.isArray(elements)?adapter.removeSubsets(elements):adapter.getChildren(elements)}function appendNextSiblings(element,adapter){let elements=Array.isArray(
|
|
166
|
-
element)?[...element]:[element],elementsLength=elements.length;for(let index=0;index<elementsLength;index++){let nextSiblings=getNextSiblings(elements[index],adapter);elements.push(...nextSiblings)}return elements}function is2(element,query,options){return(typeof query=="function"?query:compile2(query,options))(element)}var defaultEquals,defaultOptions,selectAll,selectOne,dist_default2,init_dist11=__esm({"node_modules/css-select/dist/index.js"(){init_dist();init_dist2();init_dist4();init_dist9();
|
|
167
|
-
init_compile2();init_querying2();defaultEquals=(a,b)=>a===b,defaultOptions={adapter:{...dist_exports2,isTag:isTag2},equals:defaultEquals};selectAll=getSelectorFunction((query,elements,options)=>query===falseFunc||!elements||elements.length===0?[]:findAll2(query,elements,options)),selectOne=getSelectorFunction((query,elements,options)=>query===falseFunc||!elements||elements.length===0?null:findOne2(query,elements,options));dist_default2=selectAll}});export{compile2 as compile,is2 as is,dist_exports4 as dist_exports,init_dist11 as init_dist,require_lib,require_canvas};
|