@dipoleml/dcode-cli 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-NOTICES.md +1081 -12
- package/dist/dcode.cjs +59253 -45604
- package/dist/packages/browser-use-plugin/README.md +12 -12
- package/dist/packages/browser-use-plugin/docs/api.json +1 -1
- package/dist/packages/browser-use-plugin/docs/overview.md +5 -4
- package/dist/packages/browser-use-plugin/docs/workflow.md +1 -1
- package/dist/packages/browser-use-plugin/scripts/build.mjs +1 -0
- package/dist/packages/browser-use-plugin/skills/control-browser/SKILL.md +10 -7
- package/dist/packages/bundled-skills/skills/dynamic-workflows/SKILL.md +760 -687
- package/dist/packages/bundled-skills/skills/dynamic-workflows/examples.md +310 -1
- package/dist/packages/bundled-skills/skills/dynamic-workflows/patterns.md +336 -4
- package/dist/packages/node-repl-host/.dcode-plugin/plugin.json +1 -1
- package/dist/packages/node-repl-host/dist/mcp/server.js +9 -14
- package/dist/packages/node-repl-host/scripts/build.mjs +1 -0
- package/dist/provider/dcode-builtin.json +6612 -202
- package/node_modules/@dcode/contracts/dist/compact/index.d.ts +7 -7
- package/node_modules/@dcode/contracts/dist/config/index.d.ts +1 -1
- package/node_modules/@dcode/contracts/dist/events/event-reducer.js +1 -0
- package/node_modules/@dcode/contracts/dist/events/in-memory-session-event-store.js +3 -2
- package/node_modules/@dcode/contracts/dist/events/session-event-retention.d.ts +8 -0
- package/node_modules/@dcode/contracts/dist/events/session-event-retention.js +18 -0
- package/node_modules/@dcode/contracts/dist/events/session.events.d.ts +94 -16
- package/node_modules/@dcode/contracts/dist/events/session.events.js +10 -0
- package/node_modules/@dcode/contracts/dist/hooks/index.d.ts +134 -134
- package/node_modules/@dcode/contracts/dist/hooks/workspace-hook-trust.d.ts +14 -14
- package/node_modules/@dcode/contracts/dist/index.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/index.js +2 -0
- package/node_modules/@dcode/contracts/dist/interfaces/browser-control.port.d.ts +22 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.d.ts +92 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.js +9 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.js +7 -3
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-workspace.port.js +8 -3
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.d.ts +119 -18
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.js +13 -0
- package/node_modules/@dcode/contracts/dist/interfaces/index.d.ts +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/index.js +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.d.ts +161 -1
- package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.js +17 -0
- package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.d.ts +15 -15
- package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.js +1 -1
- package/node_modules/@dcode/contracts/dist/interfaces/permission.port.d.ts +15 -1
- package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.d.ts +19 -0
- package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.js +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.d.ts +4 -2
- package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.js +5 -0
- package/node_modules/@dcode/contracts/dist/interfaces/session.port.d.ts +92 -3
- package/node_modules/@dcode/contracts/dist/interfaces/session.port.js +4 -1
- package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.d.ts +25 -0
- package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.js +1 -0
- package/node_modules/@dcode/contracts/dist/model/index.d.ts +15 -1
- package/node_modules/@dcode/contracts/dist/model/index.js +5 -0
- package/node_modules/@dcode/contracts/dist/model/invocation-context.d.ts +6 -1
- package/node_modules/@dcode/contracts/dist/plugins/index.d.ts +23 -0
- package/node_modules/@dcode/contracts/dist/plugins/index.js +2 -1
- package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.js +2 -0
- package/node_modules/@dcode/contracts/dist/telemetry/index.d.ts +5 -1
- package/node_modules/@dcode/contracts/dist/telemetry/index.js +12 -0
- package/node_modules/@dcode/contracts/dist/tools/agent.d.ts +12 -12
- package/node_modules/@dcode/contracts/dist/tools/amend-workflow.d.ts +39 -15
- package/node_modules/@dcode/contracts/dist/tools/amend-workflow.js +12 -6
- package/node_modules/@dcode/contracts/dist/tools/automation.d.ts +32 -32
- package/node_modules/@dcode/contracts/dist/tools/automation.js +1 -1
- package/node_modules/@dcode/contracts/dist/tools/bash.d.ts +16 -16
- package/node_modules/@dcode/contracts/dist/tools/bash.js +1 -1
- package/node_modules/@dcode/contracts/dist/tools/create-workflow.d.ts +365 -66
- package/node_modules/@dcode/contracts/dist/tools/create-workflow.js +92 -11
- package/node_modules/@dcode/contracts/dist/tools/edit.d.ts +16 -16
- package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.d.ts +6 -6
- package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.js +5 -1
- package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.d.ts +729 -0
- package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.js +102 -0
- package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.d.ts +136 -28
- package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.js +36 -0
- package/node_modules/@dcode/contracts/dist/tools/grep.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/tools/grep.js +4 -0
- package/node_modules/@dcode/contracts/dist/tools/index.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/tools/index.js +4 -0
- package/node_modules/@dcode/contracts/dist/tools/list-saved-workflows.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/list-workflow-runs.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/node-repl.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/off-peak.d.ts +3 -3
- package/node_modules/@dcode/contracts/dist/tools/off-peak.js +2 -2
- package/node_modules/@dcode/contracts/dist/tools/performance.d.ts +22 -22
- package/node_modules/@dcode/contracts/dist/tools/plan-mode.d.ts +12 -12
- package/node_modules/@dcode/contracts/dist/tools/plan-mode.js +6 -4
- package/node_modules/@dcode/contracts/dist/tools/read-session-context.d.ts +86 -13
- package/node_modules/@dcode/contracts/dist/tools/read-session-context.js +37 -6
- package/node_modules/@dcode/contracts/dist/tools/read.d.ts +38 -38
- package/node_modules/@dcode/contracts/dist/tools/save-workflow.d.ts +21 -10
- package/node_modules/@dcode/contracts/dist/tools/save-workflow.js +22 -2
- package/node_modules/@dcode/contracts/dist/tools/saved-workflow.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/tools/send-message.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/skill.js +1 -0
- package/node_modules/@dcode/contracts/dist/tools/task-output.d.ts +6 -6
- package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.d.ts +1228 -259
- package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.js +41 -0
- package/node_modules/@dcode/contracts/dist/tools/webfetch.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/workflow-observation-display.d.ts +20 -20
- package/node_modules/@dcode/contracts/dist/tools/workflow-settings.d.ts +55 -0
- package/node_modules/@dcode/contracts/dist/tools/workflow-settings.js +86 -0
- package/node_modules/@dcode/contracts/dist/tools/workflow.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/write.d.ts +18 -18
- package/node_modules/@dcode/contracts/dist/workflow/index.d.ts +98 -98
- package/node_modules/@dcode/contracts/dist/workflow/script.d.ts +12 -12
- package/node_modules/@dcode/i18n/dist/index.js +2 -2
- package/node_modules/@dcode/i18n/dist/locale.d.ts +1 -1
- package/node_modules/@dcode/i18n/dist/locale.js +4 -4
- package/node_modules/@dcode/i18n/dist/locales/en-US.js +5 -5
- package/node_modules/@dcode/i18n/dist/locales/fr-CA.d.ts +3 -0
- package/node_modules/@dcode/i18n/dist/locales/fr-CA.js +354 -0
- package/node_modules/@dcode/model-option-map/package.json +1 -1
- package/node_modules/@dcode/shared/dist/api-key-usage-scene.d.ts +7 -0
- package/node_modules/@dcode/shared/dist/api-key-usage-scene.js +6 -0
- package/node_modules/@dcode/shared/dist/attachment-source.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/attachment-source.js +4 -0
- package/node_modules/@dcode/shared/dist/background-bash-output.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/bots.d.ts +763 -15
- package/node_modules/@dcode/shared/dist/bots.js +236 -2
- package/node_modules/@dcode/shared/dist/browser-use/command-metadata.d.ts +2 -2
- package/node_modules/@dcode/shared/dist/browser-use/commands.d.ts +4 -3
- package/node_modules/@dcode/shared/dist/browser-use/commands.js +3 -1
- package/node_modules/@dcode/shared/dist/browser-use/nodeReplBroker.d.ts +5 -4
- package/node_modules/@dcode/shared/dist/browser-use/result.d.ts +6 -6
- package/node_modules/@dcode/shared/dist/channel-mention.d.ts +173 -0
- package/node_modules/@dcode/shared/dist/channel-mention.js +120 -0
- package/node_modules/@dcode/shared/dist/channels.d.ts +128 -1
- package/node_modules/@dcode/shared/dist/channels.js +66 -0
- package/node_modules/@dcode/shared/dist/clientConfig.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/clientConfig.js +18 -2
- package/node_modules/@dcode/shared/dist/cloudContent.d.ts +160 -0
- package/node_modules/@dcode/shared/dist/cloudContent.js +116 -0
- package/node_modules/@dcode/shared/dist/coding-plan-subscription.d.ts +59 -0
- package/node_modules/@dcode/shared/dist/conversation-message-projection-policy.js +2 -0
- package/node_modules/@dcode/shared/dist/conversation-share.d.ts +351 -47
- package/node_modules/@dcode/shared/dist/conversation-share.js +8 -6
- package/node_modules/@dcode/shared/dist/conversationSelection.d.ts +23 -0
- package/node_modules/@dcode/shared/dist/conversationSelection.js +30 -0
- package/node_modules/@dcode/shared/dist/database-startup.d.ts +5 -5
- package/node_modules/@dcode/shared/dist/dcode-agent-model-state.js +14 -6
- package/node_modules/@dcode/shared/dist/dcode-agent-policy.d.ts +16 -1
- package/node_modules/@dcode/shared/dist/dcode-agent-policy.js +17 -1
- package/node_modules/@dcode/shared/dist/dcode-agent-runtime.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol/index.d.ts +1733 -318
- package/node_modules/@dcode/shared/dist/dcode-protocol/index.js +555 -24
- package/node_modules/@dcode/shared/dist/dcode-protocol/trace.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol/trace.js +10 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.d.ts +30 -20
- package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.js +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/apply.js +12 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.js +3 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.d.ts +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.js +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.d.ts +359 -28
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.js +67 -45
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/controller.d.ts +170 -65
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.d.ts +20 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.js +15 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.d.ts +34 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.js +45 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.d.ts +1453 -278
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.js +45 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.js +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.d.ts +173 -6
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.js +29 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.d.ts +731 -125
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.js +23 -11
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.d.ts +30 -11
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.js +35 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index.d.ts +40 -25
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.d.ts +1444 -216
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.js +3 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/telemetry.d.ts +62 -58
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.d.ts +185 -50
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.js +31 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.d.ts +7145 -1002
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.js +18 -5
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-assembler.js +2 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-fault.js +4 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-reassembly.js +5 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.d.ts +29 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.js +64 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.d.ts +13 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.js +23 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-observation-display.d.ts +14 -14
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.d.ts +52 -8
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.js +22 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.js +2 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.d.ts +21 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.js +44 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.js +3 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-caps.js +5 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.d.ts +26 -19
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.js +40 -32
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.d.ts +4 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.js +4 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.d.ts +12 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.js +44 -6
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.d.ts +2 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.js +17 -10
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.d.ts +33 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.js +202 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-phases.js +10 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.js +29 -22
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-started.js +5 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-tables.js +2 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-unlisted.js +6 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.d.ts +125 -40
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.js +101 -26
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-workspace.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workspace-hook-review.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-session-content-profile.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/dcode-session-content-profile.js +49 -0
- package/node_modules/@dcode/shared/dist/dcode-slash-command-help.js +4 -4
- package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.d.ts +6 -1
- package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.js +13 -1
- package/node_modules/@dcode/shared/dist/dcode-task-types-core.d.ts +12 -2
- package/node_modules/@dcode/shared/dist/dcode-task-types.d.ts +23 -0
- package/node_modules/@dcode/shared/dist/dcodeEndpoint.d.ts +20 -1
- package/node_modules/@dcode/shared/dist/dcodeEndpoint.js +98 -17
- package/node_modules/@dcode/shared/dist/desktopMenu.js +48 -48
- package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.d.ts +35 -6
- package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.js +45 -6
- package/node_modules/@dcode/shared/dist/env.d.ts +5 -4
- package/node_modules/@dcode/shared/dist/env.js +9 -9
- package/node_modules/@dcode/shared/dist/errors.d.ts +24 -0
- package/node_modules/@dcode/shared/dist/errors.js +54 -0
- package/node_modules/@dcode/shared/dist/execution-state.d.ts +4 -2
- package/node_modules/@dcode/shared/dist/execution-state.js +1 -1
- package/node_modules/@dcode/shared/dist/feedback.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/gen-ui/contract.d.ts +140 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.example.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.example.js +36 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.js +196 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.test.js +75 -0
- package/node_modules/@dcode/shared/dist/gen-ui/index.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/index.js +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/module.d.ts +7 -0
- package/node_modules/@dcode/shared/dist/gen-ui/module.js +7 -0
- package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.d.ts +202 -0
- package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.js +126 -0
- package/node_modules/@dcode/shared/dist/helpAppConfig.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/helpAppConfig.js +2 -2
- package/node_modules/@dcode/shared/dist/highspeed.d.ts +181 -0
- package/node_modules/@dcode/shared/dist/highspeed.js +112 -0
- package/node_modules/@dcode/shared/dist/index.d.ts +27 -5
- package/node_modules/@dcode/shared/dist/index.js +24 -2
- package/node_modules/@dcode/shared/dist/localTtft.d.ts +27 -27
- package/node_modules/@dcode/shared/dist/marketingTouch.d.ts +930 -0
- package/node_modules/@dcode/shared/dist/marketingTouch.js +170 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/appTools.d.ts +83 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/appTools.js +124 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/content.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/content.js +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.d.ts +241 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.d.ts +31 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.js +42 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.js +101 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.js +64 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.d.ts +47 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.js +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/index.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/index.js +9 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/instance.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/instance.js +11 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/module.d.ts +12 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/module.js +12 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.js +73 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.d.ts +101 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.js +107 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.js +55 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/schemas.d.ts +78 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/schemas.js +65 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.d.ts +39 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.js +199 -0
- package/node_modules/@dcode/shared/dist/mcp.d.ts +6 -2
- package/node_modules/@dcode/shared/dist/memory.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/memory.js +2 -0
- package/node_modules/@dcode/shared/dist/model-execution.d.ts +31 -0
- package/node_modules/@dcode/shared/dist/model-execution.js +38 -0
- package/node_modules/@dcode/shared/dist/networkCapture.d.ts +49 -0
- package/node_modules/@dcode/shared/dist/networkCapture.js +41 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.d.ts +6 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.js +16 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.test.js +30 -0
- package/node_modules/@dcode/shared/dist/node/networkCapture.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/node/networkCapture.js +96 -0
- package/node_modules/@dcode/shared/dist/node/officialPluginCache.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/node/subagentMarkdownMigration.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/node.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/node.js +2 -0
- package/node_modules/@dcode/shared/dist/output-style.d.ts +17 -0
- package/node_modules/@dcode/shared/dist/output-style.js +2 -0
- package/node_modules/@dcode/shared/dist/platform.d.ts +149 -1
- package/node_modules/@dcode/shared/dist/platform.js +2 -0
- package/node_modules/@dcode/shared/dist/platformUpdate.d.ts +61 -0
- package/node_modules/@dcode/shared/dist/platformUpdate.js +2 -0
- package/node_modules/@dcode/shared/dist/plugin-marketplaces.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/plugin-marketplaces.js +20 -14
- package/node_modules/@dcode/shared/dist/project-access-token-client.d.ts +42 -0
- package/node_modules/@dcode/shared/dist/project-access-token-client.js +260 -0
- package/node_modules/@dcode/shared/dist/project-access-token-response.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/project-access-token-response.js +9 -0
- package/node_modules/@dcode/shared/dist/project-access-token.d.ts +45 -0
- package/node_modules/@dcode/shared/dist/project-access-token.js +164 -0
- package/node_modules/@dcode/shared/dist/protocol.d.ts +41 -4
- package/node_modules/@dcode/shared/dist/protocol.js +1 -1
- package/node_modules/@dcode/shared/dist/provider-provisioning.d.ts +26 -2
- package/node_modules/@dcode/shared/dist/provider-provisioning.js +19 -3
- package/node_modules/@dcode/shared/dist/providers.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/providers.js +1 -1
- package/node_modules/@dcode/shared/dist/remote-workspace-identity.d.ts +6 -1
- package/node_modules/@dcode/shared/dist/remote-workspace-identity.js +35 -1
- package/node_modules/@dcode/shared/dist/remoteAppConfig.js +1 -1
- package/node_modules/@dcode/shared/dist/remoteEnvironmentKey.js +19 -0
- package/node_modules/@dcode/shared/dist/remoteTarget.d.ts +14 -1
- package/node_modules/@dcode/shared/dist/remoteTarget.js +4 -0
- package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.d.ts +27 -0
- package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.js +43 -0
- package/node_modules/@dcode/shared/dist/rendererActionTrace.d.ts +35 -35
- package/node_modules/@dcode/shared/dist/request-security-edition/index.d.ts +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/index.js +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/policy.d.ts +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/policy.js +5 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.d.ts +19 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.js +29 -0
- package/node_modules/@dcode/shared/dist/rewardsBridge.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/rewardsBridge.js +80 -0
- package/node_modules/@dcode/shared/dist/rewardsEmbedded.d.ts +37 -0
- package/node_modules/@dcode/shared/dist/rewardsEmbedded.js +50 -0
- package/node_modules/@dcode/shared/dist/sessionCreateTelemetry.d.ts +3 -3
- package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.js +212 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-parser.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-parser.js +200 -0
- package/node_modules/@dcode/shared/dist/subagent-profile.d.ts +82 -0
- package/node_modules/@dcode/shared/dist/subagent-profile.js +28 -0
- package/node_modules/@dcode/shared/dist/subagent-runtime-config.d.ts +135 -0
- package/node_modules/@dcode/shared/dist/subagent-runtime-config.js +39 -0
- package/node_modules/@dcode/shared/dist/subagents-types.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/task-realtime-core.d.ts +57 -24
- package/node_modules/@dcode/shared/dist/task-realtime-core.js +8 -2
- package/node_modules/@dcode/shared/dist/test-ids-workflow.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/test-ids-workflow.js +5 -0
- package/node_modules/@dcode/shared/dist/test-ids.d.ts +25 -0
- package/node_modules/@dcode/shared/dist/test-ids.js +25 -0
- package/node_modules/@dcode/shared/dist/tool-identity.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/tool-identity.js +4 -0
- package/node_modules/@dcode/shared/dist/tool-plan-adapter.js +14 -1
- package/node_modules/@dcode/shared/dist/usage-stats.d.ts +13 -0
- package/node_modules/@dcode/shared/dist/validation.d.ts +1461 -85
- package/node_modules/@dcode/shared/dist/validation.js +423 -14
- package/node_modules/@dcode/shared/dist/validationAppSettings.d.ts +71 -15
- package/node_modules/@dcode/shared/dist/validationAppSettings.js +74 -12
- package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.js +40 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.d.ts +183 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.js +562 -0
- package/node_modules/@dcode/shared/dist/web-remote-control.d.ts +645 -0
- package/node_modules/@dcode/shared/dist/web-remote-control.js +174 -0
- package/node_modules/@dcode/shared/package.json +5 -2
- package/node_modules/@dcode/tui/dist/app-approval-panel.js +3 -2
- package/node_modules/@dcode/tui/dist/app-approval.d.ts +3 -1
- package/node_modules/@dcode/tui/dist/app-approval.js +9 -5
- package/node_modules/@dcode/tui/dist/app-compact-timeline.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-compact-timeline.js +5 -2
- package/node_modules/@dcode/tui/dist/app-empty-transcript.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-empty-transcript.js +1 -1
- package/node_modules/@dcode/tui/dist/app-file-mentions.d.ts +2 -0
- package/node_modules/@dcode/tui/dist/app-file-mentions.js +2 -2
- package/node_modules/@dcode/tui/dist/app-input-pane.d.ts +38 -0
- package/node_modules/@dcode/tui/dist/app-input-pane.js +19 -19
- package/node_modules/@dcode/tui/dist/app-input-status.d.ts +17 -0
- package/node_modules/@dcode/tui/dist/app-input-status.js +4 -4
- package/node_modules/@dcode/tui/dist/app-input.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-input.js +1 -1
- package/node_modules/@dcode/tui/dist/app-markdown-theme.d.ts +2 -1
- package/node_modules/@dcode/tui/dist/app-markdown-theme.js +1 -1
- package/node_modules/@dcode/tui/dist/app-markdown.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-markdown.js +1 -1
- package/node_modules/@dcode/tui/dist/app-mode-command.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-mode-command.js +4 -4
- package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.d.ts +5 -0
- package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.js +1 -1
- package/node_modules/@dcode/tui/dist/app-mode.d.ts +1 -1
- package/node_modules/@dcode/tui/dist/app-mode.js +1 -1
- package/node_modules/@dcode/tui/dist/app-model-ref.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-model-ref.js +1 -1
- package/node_modules/@dcode/tui/dist/app-motion.d.ts +13 -0
- package/node_modules/@dcode/tui/dist/app-motion.js +17 -7
- package/node_modules/@dcode/tui/dist/app-session-event-handler.d.ts +33 -0
- package/node_modules/@dcode/tui/dist/app-session-event-handler.js +4 -4
- package/node_modules/@dcode/tui/dist/app-shiki-diff-view.d.ts +18 -1
- package/node_modules/@dcode/tui/dist/app-shiki-diff-view.js +3 -3
- package/node_modules/@dcode/tui/dist/app-shiki-highlighter.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-shiki-highlighter.js +7 -2
- package/node_modules/@dcode/tui/dist/app-sidebar-layout.d.ts +10 -0
- package/node_modules/@dcode/tui/dist/app-sidebar-layout.js +4 -4
- package/node_modules/@dcode/tui/dist/app-submit.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-submit.js +1 -1
- package/node_modules/@dcode/tui/dist/app-thought-components.d.ts +7 -0
- package/node_modules/@dcode/tui/dist/app-thought-components.js +2 -2
- package/node_modules/@dcode/tui/dist/app-tool-transcript.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-tool-transcript.js +3 -0
- package/node_modules/@dcode/tui/dist/app-view.d.ts +27 -0
- package/node_modules/@dcode/tui/dist/app-view.js +1 -1
- package/node_modules/@dcode/tui/dist/app-workflow-card.js +1 -1
- package/node_modules/@dcode/tui/dist/app-workflow-seed.d.ts +18 -1
- package/node_modules/@dcode/tui/dist/app-workflow-seed.js +4 -4
- package/node_modules/@dcode/tui/dist/index.js +5118 -2579
- package/node_modules/@dcode/tui/dist/tui.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/tui.js +1 -1
- package/node_modules/@dcode/tui/dist/types.d.ts +1 -1
- package/node_modules/oniguruma-parser/LICENSE +1 -1
- package/node_modules/oniguruma-parser/README.md +15 -61
- package/node_modules/oniguruma-parser/dist/oniguruma-parser.min.js +4 -4
- package/node_modules/oniguruma-parser/dist/parser/parse.js +1 -1
- package/node_modules/oniguruma-parser/dist/traverser/traverse.js +1 -1
- package/node_modules/oniguruma-parser/package.json +5 -5
- package/node_modules/oniguruma-to-es/dist/cjs/generate.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/cjs/index.js +121 -120
- package/node_modules/oniguruma-to-es/dist/cjs/subclass.d.ts +2 -2
- package/node_modules/oniguruma-to-es/dist/cjs/transform.d.ts +3 -5
- package/node_modules/oniguruma-to-es/dist/cjs/unicode.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/esm/generate.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/esm/index.js +1 -3
- package/node_modules/oniguruma-to-es/dist/esm/subclass.d.ts +2 -2
- package/node_modules/oniguruma-to-es/dist/esm/transform.d.ts +3 -5
- package/node_modules/oniguruma-to-es/dist/esm/unicode.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/index.min.js +6 -6
- package/node_modules/oniguruma-to-es/package.json +5 -5
- package/package.json +5 -5
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { type CliRenderer } from "@mbears/opentui-core";
|
|
1
2
|
import type { TuiOptions } from "./types.js";
|
|
2
3
|
export declare const runTui: (options: TuiOptions) => Promise<number>;
|
|
4
|
+
/** Renderer lifecycle shared by the interactive entrypoint and native terminal tests. */
|
|
5
|
+
export declare function runTuiWithRenderer(options: TuiOptions, renderer: CliRenderer): Promise<number>;
|
|
3
6
|
//# sourceMappingURL=tui.d.ts.map
|
|
@@ -46,7 +46,7 @@ export const runTui = async (options) => {
|
|
|
46
46
|
return runTuiWithRenderer(options, renderer);
|
|
47
47
|
};
|
|
48
48
|
/** Renderer lifecycle shared by the interactive entrypoint and native terminal tests. */
|
|
49
|
-
async function runTuiWithRenderer(options, renderer) {
|
|
49
|
+
export async function runTuiWithRenderer(options, renderer) {
|
|
50
50
|
let exitCode = 0;
|
|
51
51
|
let startupError;
|
|
52
52
|
let destroyed = false;
|
|
@@ -3,7 +3,7 @@ import type { ModelSelection, DCodeModelOption } from "@dcode/shared";
|
|
|
3
3
|
import type { CollaborationMode, InputDelivery, ModelUsageSummary, McpServerStatus, PermissionBrokerRequest, PermissionBrokerRequestOptions, PermissionBrokerResult, SessionEvent, SessionProjection, SupportedLocale, ToolResultDisplayPayload, UiThemeMode, UiThemePreference, TurnId, TurnSteerResult } from "@dcode/contracts";
|
|
4
4
|
export type TuiContextUsage = Pick<SessionProjection, "contextUsed" | "contextWindow">;
|
|
5
5
|
export type TuiSessionMetadata = Pick<TuiSubmitPromptResult, "locale" | "model" | "theme" | "thoughtLevel" | "modelOptions" | "effortOptions" | "loginRequired">;
|
|
6
|
-
export type TuiSwitchableMode = Extract<CollaborationMode, "plan" | "build" | "edit" | "yolo">;
|
|
6
|
+
export type TuiSwitchableMode = Extract<CollaborationMode, "plan" | "build" | "edit" | "yolo" | "guarded">;
|
|
7
7
|
export type TuiSetModeResult = {
|
|
8
8
|
mode: CollaborationMode;
|
|
9
9
|
response?: string;
|
|
@@ -29,45 +29,18 @@ npm install oniguruma-parser
|
|
|
29
29
|
|
|
30
30
|
```js
|
|
31
31
|
import {toOnigurumaAst} from 'oniguruma-parser';
|
|
32
|
-
|
|
33
|
-
const ast = toOnigurumaAst('^.*');
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
<details>
|
|
37
|
-
<summary>Using CommonJS require</summary>
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
const {toOnigurumaAst} = require('oniguruma-parser-cjs');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
> **Note:** [oniguruma-parser-cjs](https://github.com/RedCMD/oniguruma-parser-cjs) is a third-party CommonJS wrapper for this library. It might not always be up to date with the latest version.
|
|
44
|
-
</details>
|
|
45
|
-
|
|
46
|
-
<details>
|
|
47
|
-
<summary>Using a CDN and global name</summary>
|
|
48
|
-
|
|
49
|
-
```html
|
|
50
|
-
<script src="https://cdn.jsdelivr.net/npm/oniguruma-parser/dist/oniguruma-parser.min.js"></script>
|
|
51
|
-
<script>
|
|
52
|
-
const {toOnigurumaAst} = OnigurumaParser;
|
|
53
|
-
</script>
|
|
54
32
|
```
|
|
55
33
|
|
|
56
|
-
> **Note:** This bundle includes a subset of all available exports. See [`src/bundle.ts`](https://github.com/slevithan/oniguruma-parser/blob/main/src/bundle.ts).
|
|
57
|
-
</details>
|
|
58
|
-
|
|
59
|
-
### Additional modules
|
|
60
|
-
|
|
61
34
|
The following modules are available in addition to the root `'oniguruma-parser'` export:
|
|
62
35
|
|
|
63
|
-
- [Parser](https://github.com/slevithan/oniguruma-parser/blob/main/src/parser/README.md): Includes numerous functions and types for constructing and working with `OnigurumaAst` nodes. Also includes the
|
|
64
|
-
- [Traverser](https://github.com/slevithan/oniguruma-parser/blob/main/src/traverser/README.md): Traverse and transform an `OnigurumaAst`.
|
|
65
|
-
- [Generator](https://github.com/slevithan/oniguruma-parser/blob/main/src/generator/README.md): Convert an `OnigurumaAst` to pattern and flags strings.
|
|
66
|
-
- [Optimizer](https://github.com/slevithan/oniguruma-parser/blob/main/src/optimizer/README.md): Minify and improve the performance of Oniguruma regexes.
|
|
36
|
+
- [Parser module](https://github.com/slevithan/oniguruma-parser/blob/main/src/parser/README.md): Includes numerous functions and types for constructing and working with `OnigurumaAst` nodes. Also includes the `parse` function, wrapped by `toOnigurumaAst`.
|
|
37
|
+
- [Traverser module](https://github.com/slevithan/oniguruma-parser/blob/main/src/traverser/README.md): Traverse and transform an `OnigurumaAst`.
|
|
38
|
+
- [Generator module](https://github.com/slevithan/oniguruma-parser/blob/main/src/generator/README.md): Convert an `OnigurumaAst` to pattern and flags strings.
|
|
39
|
+
- [Optimizer module](https://github.com/slevithan/oniguruma-parser/blob/main/src/optimizer/README.md): Minify and improve the performance of Oniguruma regexes.
|
|
67
40
|
|
|
68
|
-
##
|
|
41
|
+
## 🌿 Convert a pattern to an AST
|
|
69
42
|
|
|
70
|
-
|
|
43
|
+
To parse an Oniguruma pattern (with optional flags and compile-time options) and return an AST, call `toOnigurumaAst`, which uses the following type definition:
|
|
71
44
|
|
|
72
45
|
```ts
|
|
73
46
|
function toOnigurumaAst(
|
|
@@ -87,15 +60,15 @@ For example:
|
|
|
87
60
|
```js
|
|
88
61
|
import {toOnigurumaAst} from 'oniguruma-parser';
|
|
89
62
|
|
|
90
|
-
const ast = toOnigurumaAst('
|
|
63
|
+
const ast = toOnigurumaAst('A.*');
|
|
91
64
|
console.log(ast);
|
|
92
65
|
/* →
|
|
93
66
|
{ type: 'Regex',
|
|
94
67
|
body: [
|
|
95
68
|
{ type: 'Alternative',
|
|
96
69
|
body: [
|
|
97
|
-
{ type: '
|
|
98
|
-
|
|
70
|
+
{ type: 'Character',
|
|
71
|
+
value: 65,
|
|
99
72
|
},
|
|
100
73
|
{ type: 'Quantifier',
|
|
101
74
|
kind: 'greedy',
|
|
@@ -126,15 +99,15 @@ console.log(ast);
|
|
|
126
99
|
|
|
127
100
|
An error is thrown if the provided pattern or flags aren't valid in Oniguruma.
|
|
128
101
|
|
|
129
|
-
> **Note:** `toOnigurumaAst` is a wrapper around the [parser module](https://github.com/slevithan/oniguruma-parser/blob/main/src/parser/README.md)'s `parse` function that automatically
|
|
102
|
+
> **Note:** `toOnigurumaAst` is a wrapper around the [parser module](https://github.com/slevithan/oniguruma-parser/blob/main/src/parser/README.md)'s `parse` function that makes it easier to use by automatically providing the appropriate Unicode property validation data.
|
|
130
103
|
|
|
131
104
|
## 🌀 Traverse and transform an AST
|
|
132
105
|
|
|
133
|
-
See details and examples in the [traverser module](https://github.com/slevithan/oniguruma-parser/blob/main/src/traverser/README.md)
|
|
106
|
+
See details and examples in the [traverser module's readme](https://github.com/slevithan/oniguruma-parser/blob/main/src/traverser/README.md).
|
|
134
107
|
|
|
135
108
|
## ↩️ Convert an AST to a pattern
|
|
136
109
|
|
|
137
|
-
See details and examples in the [generator module](https://github.com/slevithan/oniguruma-parser/blob/main/src/generator/README.md)
|
|
110
|
+
See details and examples in the [generator module's readme](https://github.com/slevithan/oniguruma-parser/blob/main/src/generator/README.md).
|
|
138
111
|
|
|
139
112
|
## 🪄 Optimize regexes
|
|
140
113
|
|
|
@@ -154,7 +127,7 @@ Becomes:
|
|
|
154
127
|
|
|
155
128
|
Optimized regexes always match exactly the same strings.
|
|
156
129
|
|
|
157
|
-
See more details and examples in the [optimizer module](https://github.com/slevithan/oniguruma-parser/blob/main/src/optimizer/README.md)
|
|
130
|
+
See more details and examples in the [optimizer module's readme](https://github.com/slevithan/oniguruma-parser/blob/main/src/optimizer/README.md).
|
|
158
131
|
|
|
159
132
|
> [!TIP]
|
|
160
133
|
> 🧪 Try the [optimizer demo](https://slevithan.github.io/oniguruma-parser/demo/).
|
|
@@ -173,7 +146,7 @@ The following rarely-used features throw errors since they aren't yet supported:
|
|
|
173
146
|
- Conditionals: `(?(…)…)`, etc.
|
|
174
147
|
- Non-built-in callouts: `(?{…})`, etc.
|
|
175
148
|
- Numbered *forward* backreferences (incl. relative `\k<+N>`) and backreferences with recursion level (`\k<N+N>`, etc.).
|
|
176
|
-
- Flags `D` `P` `S` `W` `y{g}` `y{w}` within pattern modifiers, and whole-pattern
|
|
149
|
+
- Flags `D` `P` `S` `W` `y{g}` `y{w}` within pattern modifiers, and whole-pattern modifiers `C` `I` `L`.
|
|
177
150
|
|
|
178
151
|
Despite these gaps, more than 99.99% of real-world Oniguruma regexes are supported, based on a sample of ~55k regexes used in TextMate grammars (conditionals were used in three regexes, and other unsupported features weren't used at all). Some of the Oniguruma features above are so exotic that they aren't used in *any* public code on GitHub.
|
|
179
152
|
|
|
@@ -199,16 +172,6 @@ The following don't yet throw errors, but should:
|
|
|
199
172
|
- Such subroutines error at compile time in Oniguruma.
|
|
200
173
|
</details>
|
|
201
174
|
|
|
202
|
-
<details>
|
|
203
|
-
<summary>Future AST node types</summary>
|
|
204
|
-
|
|
205
|
-
Support for most of the currently unsupported features above will be added to the `OnigurumaAst` structure using existing node types (`Character`, `AbsenceFunction`, `Backreference`, etc.). However, the following node types will be added when their corresponding features are supported:
|
|
206
|
-
|
|
207
|
-
- `CharacterSequence`: New node type for code point sequences; will contain two or more `Character` nodes.
|
|
208
|
-
- `Conditional`: New node type for all conditional kinds.
|
|
209
|
-
- `Callout`: New node type for unnamed callouts.
|
|
210
|
-
</details>
|
|
211
|
-
|
|
212
175
|
### Behavior differences
|
|
213
176
|
|
|
214
177
|
#### Unenclosed four-digit backreferences
|
|
@@ -287,18 +250,9 @@ Contributions are welcome. See the [guide](https://github.com/slevithan/onigurum
|
|
|
287
250
|
|
|
288
251
|
Created by [Steven Levithan](https://github.com/slevithan) and [contributors](https://github.com/slevithan/oniguruma-parser/graphs/contributors).
|
|
289
252
|
|
|
290
|
-
### Sponsors and backers
|
|
291
|
-
|
|
292
|
-
[<img src="https://github.com/roboflow.png" width="40" height="40">](https://github.com/roboflow)
|
|
293
|
-
|
|
294
|
-
### Past sponsors
|
|
295
|
-
|
|
296
|
-
[<img src="https://github.com/antfu.png" width="40" height="40">](https://github.com/antfu)
|
|
297
|
-
[<img src="https://github.com/brc-dd.png" width="40" height="40">](https://github.com/brc-dd)
|
|
298
|
-
|
|
299
253
|
If you want to support this project, I'd love your help by contributing improvements ([guide](https://github.com/slevithan/oniguruma-parser/blob/main/CONTRIBUTING.md)), sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) ongoing development.
|
|
300
254
|
|
|
301
|
-
|
|
255
|
+
MIT License.
|
|
302
256
|
|
|
303
257
|
<!-- Badges -->
|
|
304
258
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var OnigurumaParser=(()=>{var ne=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,
|
|
1
|
+
"use strict";var OnigurumaParser=(()=>{var ne=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},st=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of at(t))!ot.call(e,i)&&i!==r&&ne(e,i,{get:()=>t[i],enumerable:!(a=nt(t,i))||a.enumerable});return e};var lt=e=>st(ne({},"__esModule",{value:!0}),e);var mr={};it(mr,{OnigUnicodePropertyMap:()=>G,generate:()=>H,getOptionalOptimizations:()=>le,optimize:()=>rt,parse:()=>M,toOnigurumaAst:()=>Ee,traverse:()=>Y});function y(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function pe(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}var U=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),c=String.raw;function m(e,t){if(e==null)throw new Error(t??"Value expected");return e}function H(e){let t=[],r=e,a={inCharClass:!1,lastNode:r,parent:e},i=o=>{a.lastNode=r,r=o,dt(a.lastNode)===o&&(a.parent=a.lastNode,t.push(a.parent));let s=m(ut[o.type],`Unexpected node type "${o.type}"`)(o,a,i);return ft(a.parent)===o&&(t.pop(),a.parent=t.at(-1)??e),s};return{pattern:e.body.map(i).join("|"),flags:i(e.flags)}}var ut={AbsenceFunction({body:e,kind:t},r,a){if(t!=="repeater")throw new Error(`Unexpected absence function kind "${t}"`);return`(?~${e.map(a).join("|")})`},Alternative({body:e},t,r){return e.map(r).join("")},Assertion({kind:e,negate:t}){return e==="text_segment_boundary"?t?c`\Y`:c`\y`:e==="word_boundary"?t?c`\B`:c`\b`:m({line_end:"$",line_start:"^",search_start:c`\G`,string_end:c`\z`,string_end_newline:c`\Z`,string_start:c`\A`}[e],`Unexpected assertion kind "${e}"`)},Backreference({ref:e}){return typeof e=="number"?"\\"+e:`\\k<${e}>`},CapturingGroup({body:e,name:t},r,a){return`(${t?`?${t.includes(">")?`'${t}'`:`<${t}>`}`:""}${e.map(a).join("|")})`},Character(e,{inCharClass:t,lastNode:r,parent:a}){let{value:i}=e;if(ce.has(i))return ce.get(i);let o=r.type==="Backreference";if(i<32||i>126&&i<160||i>262143||o&&_t(i))return i>127?`\\x{${i.toString(16).toUpperCase()}}`:`\\x${i.toString(16).toUpperCase().padStart(2,"0")}`;let n=String.fromCodePoint(i),s=!1;if(t){let l=a.type==="CharacterClass",p=l&&a.body[0]===e,d=l&&a.body.at(-1)===e;n==="^"?s=p&&!a.negate:n==="]"?s=!p:n==="-"?s=!p&&!d:s=ct.has(n)}else s=pt.has(n);return`${s?"\\":""}${n}`},CharacterClass({body:e,kind:t,negate:r},a,i){function o(){return a.parent.type==="CharacterClass"&&a.parent.kind==="intersection"&&t==="union"&&!e.length?"":`[${r?"^":""}${e.map(i).join(t==="intersection"?"&&":"")}]`}if(!a.inCharClass){a.inCharClass=!0;let n=o();return a.inCharClass=!1,n}return o()},CharacterClassRange({min:e,max:t},r,a){return`${a(e)}-${a(t)}`},CharacterSet({kind:e,negate:t,value:r},{inCharClass:a}){switch(e){case"any":return c`\O`;case"digit":return t?c`\D`:c`\d`;case"dot":return".";case"hex":return t?c`\H`:c`\h`;case"newline":return t?c`\N`:c`\R`;case"posix":return a?`[:${t?"^":""}${r}:]`:`${t?c`\P`:c`\p`}{${r}}`;case"property":return`${t?c`\P`:c`\p`}{${r}}`;case"space":return t?c`\S`:c`\s`;case"text_segment":return c`\X`;case"word":return t?c`\W`:c`\w`;default:throw new Error(`Unexpected character set kind "${e}"`)}},Directive({kind:e,flags:t}){if(e==="flags"){let{enable:r={},disable:a={}}=t,i=$(r),o=$(a);return i||o?`(?${i}${o?`-${o}`:""})`:""}if(e==="keep")return c`\K`;throw new Error(`Unexpected directive kind "${e}"`)},Flags(e){return $(e)},Group({atomic:e,body:t,flags:r},a,i){let o=t.map(i).join("|");return`(?${ht(e,r)}${o})`},LookaroundAssertion({body:e,kind:t,negate:r},a,i){return`(?${`${t==="lookahead"?"":"<"}${r?"!":"="}`}${e.map(i).join("|")})`},NamedCallout({kind:e,tag:t,arguments:r}){if(e==="custom")throw new Error(`Unexpected named callout kind "${e}"`);return`(*${e.toUpperCase()}${t?`[${t}]`:""}${r?`{${r.join(",")}}`:""})`},Quantifier(e,{parent:t},r){let{body:a,kind:i,max:o,min:n}=e;if(n===1/0)throw new Error("Invalid quantifier: infinite min");if(n>o)throw new Error(`Invalid quantifier: min "${n}" > max "${o}"`);let s=a.type==="Quantifier"&&a.kind==="greedy",l=t.type==="Quantifier"&&t.kind==="possessive"&&t.min===1&&t.max===1/0,p=i==="greedy"&&l,d;de(e)&&!p&&(!n&&o===1&&!s?d="?":!n&&o===1/0?d="*":n===1&&o===1/0&&(!(s&&de(a))||i==="possessive")&&(d="+"));let _=!d;if(_)if(i==="possessive"){if(n===o)throw new Error(`Invalid possessive quantifier: min and max are equal "${n}"`);if(o===1/0)throw new Error(`Invalid possessive quantifier: min "${n}" with infinite max"`);d=`{${o},${n}}`}else n===o?d=`{${n}}`:d=`{${n},${o===1/0?"":o}}`;let u={greedy:"",lazy:"?",possessive:_?"":"+"}[i];return`${r(a)}${d}${u}`},Subroutine({ref:e}){return typeof e=="string"&&e.includes(">")?c`\g'${e}'`:c`\g<${e}>`}},pt=new Set(["$","(",")","*","+",".","?","[","\\","^","{","|"]),ct=new Set(["&","-","[","\\","]","^"]),ce=new Map([[7,c`\a`],[9,c`\t`],[10,c`\n`],[11,c`\v`],[12,c`\f`],[13,c`\r`],[27,c`\e`],[8232,c`\u2028`],[8233,c`\u2029`],[65279,c`\uFEFF`]]);function dt(e){return"body"in e?Array.isArray(e.body)?e.body[0]??null:e.body:"min"in e&&e.min.type?e.min:null}function ft(e){return"body"in e?Array.isArray(e.body)?e.body.at(-1)??null:e.body:"max"in e&&e.max.type?e.max:null}function $({ignoreCase:e,dotAll:t,extended:r,digitIsAscii:a,posixIsAscii:i,spaceIsAscii:o,wordIsAscii:n,textSegmentMode:s}){return`${e?"i":""}${t?"m":""}${r?"x":""}${a?"D":""}${i?"P":""}${o?"S":""}${n?"W":""}${s?m({grapheme:"y{g}",word:"y{w}"}[s],`Unexpected text segment mode "${s}"`):""}`}function ht(e,t){if(e)return">";let r="";if(t){let{enable:a={},disable:i={}}=t,o=$(a),n=$(i);r=`${o}${n?`-${n}`:""}`}return`${r}:`}function _t(e){return e>47&&e<58}function de({min:e,max:t}){return!e&&t===1||!e&&t===1/0||e===1&&t===1/0}var ge=c`\[\^?`,Ce=`c.? | C(?:-.?)?|${c`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${c`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${c`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${c`o\{[^\}]*\}?`}|${c`\d{1,3}`}`,oe=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Q=new RegExp(c`
|
|
2
2
|
\\ (?:
|
|
3
3
|
${Ce}
|
|
4
4
|
| [gk]<[^>]*>?
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
| ${ge}
|
|
30
30
|
| &&
|
|
31
31
|
| .
|
|
32
|
-
`.replace(/\s+/g,""),"gsu");function be(e,t={}){let r={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let
|
|
33
|
-
`,n);return{lastIndex:a===-1?t.length:a}}if(/^\s$/.test(r)){let a=/\s+/y;return a.lastIndex=n,{lastIndex:a.exec(t)?a.lastIndex:n}}}if(r===".")return{token:T("dot",r)};if(r==="^"||r==="$"){let a=e.singleline?{"^":c`\A`,$:c`\Z`}[r]:r;return{token:fe(a,r)}}return r==="|"?{token:Ct(r)}:oe.test(r)?{tokens:Ut(r)}:{token:A(y(r),r)}}function yt(e,t,r){let n=[he(t[1]==="^",t)],o=1,i;for(ae.lastIndex=r;i=ae.exec(e);){let a=i[0];if(a[0]==="["&&a[1]!==":")o++,n.push(he(a[1]==="^",a));else if(a==="]"){if(n.at(-1).type==="CharacterClassOpen")n.push(A(93,a));else if(o--,n.push(bt(a)),!o)break}else{let s=gt(a);Array.isArray(s)?n.push(...s):n.push(s)}}return{tokens:n,lastIndex:ae.lastIndex||e.length}}function gt(e){if(e[0]==="\\")return Ne(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!U.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return T("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Nt(e):e==="&&"?It(e):A(y(e),e)}function Ne(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Tt(e);if("dDhHsSwW".includes(r))return Ot(e);if(e.startsWith(c`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Mt(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let n=e.split(/\\x/).slice(1).map(s=>parseInt(s,16)),o=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(n)),i=new TextEncoder;return[...o].map(s=>{let l=[...i.encode(s)].map(p=>`\\x${p.toString(16)}`).join("");return A(y(s),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return A(Lt(e),e);if(_e.has(r))return A(_e.get(r),e);if(/\d/.test(r))return kt(t,e);if(e==="\\")throw new Error(c`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return A(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Ct(e){return{type:"Alternator",raw:e}}function fe(e,t){return{type:"Assertion",kind:e,raw:t}}function Ie(e){return{type:"Backreference",raw:e}}function A(e,t){return{type:"Character",value:e,raw:t}}function bt(e){return{type:"CharacterClassClose",raw:e}}function Nt(e){return{type:"CharacterClassHyphen",raw:e}}function It(e){return{type:"CharacterClassIntersector",raw:e}}function he(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function T(e,t,r={}){return{type:"CharacterSet",kind:e,...r,raw:t}}function ke(e,t,r={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:m(r.flags),raw:t}}function kt(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function At(e){return{type:"GroupClose",raw:e}}function P(e,t,r={}){return{type:"GroupOpen",kind:e,...r,raw:t}}function St(e,t,r,n){return{type:"NamedCallout",kind:e,tag:t,arguments:r,raw:n}}function xt(e,t,r,n){return{type:"Quantifier",kind:e,min:t,max:r,raw:n}}function vt(e){return{type:"Subroutine",raw:e}}var wt=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),_e=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Tt(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return A(y(t.toUpperCase())-64,e)}function Et(e,t){let{on:r,off:n}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;n??="";let o=(t.getCurrentModX()||r.includes("x"))&&!n.includes("x"),i=ye(r),a=ye(n),s={};if(i&&(s.enable=i),a&&(s.disable=a),e.endsWith(")"))return t.replaceCurrentModX(o),ke("flags",e,{flags:s});if(e.endsWith(":"))return t.pushModX(o),t.numOpenGroups++,P("group",e,{...(i||a)&&{flags:s}});throw new Error(`Unexpected flag modifier "${e}"`)}function Pt(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:r,tag:n,args:o}=t.groups;if(!r)throw new Error(`Invalid named callout "${e}"`);if(n==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let i=o?o.split(",").filter(d=>d!=="").map(d=>/^[+-]?\d+$/.test(d)?+d:d):[],[a,s,l]=i,p=wt.has(r)?r.toLowerCase():"custom";switch(p){case"fail":case"mismatch":case"skip":if(i.length>0)throw new Error(`Named callout arguments not allowed "${i}"`);break;case"error":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(typeof a=="string")throw new Error(`Named callout argument must be a number "${a}"`);break;case"max":if(!i.length||i.length>2)throw new Error(`Named callout must have one or two arguments "${i}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(i.length===2&&(typeof s=="number"||!/^[<>X]$/.test(s)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case"count":case"total_count":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(i.length===1&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);break;case"cmp":if(i.length!==3)throw new Error(`Named callout must have three arguments "${i}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(typeof s=="number"||!/^(?:[<>!=]=|[<>])$/.test(s))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${r}"`);default:throw new Error(`Unexpected named callout kind "${p}"`)}return St(p,n??null,o?.split(",")??null,e)}function me(e){let t=null,r,n;if(e[0]==="{"){let{minStr:o,maxStr:i}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,a=1e5;if(+o>a||i&&+i>a)throw new Error("Quantifier value unsupported in Oniguruma");if(r=+o,n=i===void 0?+o:i===""?1/0:+i,r>n&&(t="possessive",[r,n]=[n,r]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else r=e[0]==="+"?1:0,n=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return xt(t,r,n,e)}function Ot(e){let t=e[1].toLowerCase();return T({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Mt(e){let{p:t,neg:r,value:n}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return T("property",e,{value:n,negate:t==="P"&&!r||t==="p"&&!!r})}function ye(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Gt(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let r=0;r<e.length;r++){let n=e[r];if(!"imxDPSWy".includes(n))throw new Error(`Invalid flag "${n}"`);if(n==="y"){if(!/^y{[gw]}/.test(e.slice(r)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[r+2]==="g"?"grapheme":"word",r+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[n]]=!0}return t}function Lt(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Ft(e,t){let{raw:r,inCharClass:n}=e,o=r.slice(1);if(!n&&(o!=="0"&&o.length===1||o[0]!=="0"&&+o<=t))return[Ie(r)];let i=[],a=o.match(/^[0-7]+|\d/g);for(let s=0;s<a.length;s++){let l=a[s],p;if(s===0&&l!=="8"&&l!=="9"){if(p=parseInt(l,8),p>127)throw new Error(c`Octal encoded byte above 177 unsupported "${r}"`)}else p=y(l);i.push(A(p,(s===0?"\\":"")+l))}return i}function Ut(e){let t=[],r=new RegExp(oe,"gy"),n;for(;n=r.exec(e);){let o=n[0];if(o[0]==="{"){let i=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(o);if(i){let{min:a,max:s}=i.groups;if(+a>+s&&o.endsWith("?")){r.lastIndex--,t.push(me(o.slice(0,-1)));continue}}}t.push(me(o))}return t}function O(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let r=e.body[0];return!t||Object.keys(t).every(n=>t[n]===r[n])}function b(e){return!(!$t.has(e.type)||e.type==="AbsenceFunction"&&e.kind!=="repeater")}var $t=new Set(["AbsenceFunction","CapturingGroup","Group","LookaroundAssertion","Regex"]);function E(e){return Dt.has(e.type)}var Dt=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function M(e,t={}){let r={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},n=be(e,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline}}),o=(u,h)=>{let f=n.tokens[i.nextIndex];switch(i.parent=u,i.nextIndex++,f.type){case"Alternator":return N();case"Assertion":return Kt(f);case"Backreference":return Rt(f,i);case"Character":return K(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return Bt(f,i,h);case"CharacterClassOpen":return Vt(f,i,h);case"CharacterSet":return jt(f,i);case"Directive":return Zt(f.kind,{flags:f.flags});case"GroupOpen":return zt(f,i,h);case"NamedCallout":return Yt(f.kind,f.tag,f.arguments);case"Quantifier":return Ht(f,i);case"Subroutine":return Qt(f,i);default:throw new Error(`Unexpected token type "${f.type}"`)}},i={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:r.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:r.skipBackrefValidation,skipLookbehindValidation:r.skipLookbehindValidation,skipPropertyNameValidation:r.skipPropertyNameValidation,subroutines:[],tokens:n.tokens,unicodePropertyMap:r.unicodePropertyMap,walk:o},a=tr(qt(n.flags)),s=a.body[0];for(;i.nextIndex<n.tokens.length;){let u=o(s,{});u.type==="Alternative"?(a.body.push(u),s=u):s.body.push(u)}let{capturingGroups:l,hasNumberedRef:p,namedGroupsByName:d,subroutines:_}=i;if(p&&d.size&&!r.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:u}of _)if(typeof u=="number"){if(u>l.length)throw new Error("Subroutine uses a group number that's not defined");u&&(l[u-1].isSubroutined=!0)}else if(d.has(u)){if(d.get(u).length>1)throw new Error(c`Subroutine uses a duplicate group name "\g<${u}>"`);d.get(u)[0].isSubroutined=!0}else throw new Error(c`Subroutine uses a group name that's not defined "\g<${u}>"`);return a}function Kt({kind:e}){return Xt(m({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===c`\B`||e===c`\Y`})}function Rt({raw:e},t){let r=/^\\k[<']/.test(e),n=r?e.slice(3,-1):e.slice(1),o=(i,a=!1)=>{let s=t.capturingGroups.length,l=!1;if(i>s)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Ae(a?s+1-i:i,{orphan:l})};if(r){let i=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);if(i)return o(+i.groups.num,!!i.groups.sign);if(/[-+]/.test(n))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(n))throw new Error(`Group name not defined to the left "${e}"`);return Ae(n)}return o(+n)}function Bt(e,t,r){let{tokens:n,walk:o}=t,i=t.parent,a=i.body.at(-1),s=n[t.nextIndex];if(!r.isCheckingRangeEnd&&a&&a.type!=="CharacterClass"&&a.type!=="CharacterClassRange"&&s&&s.type!=="CharacterClassOpen"&&s.type!=="CharacterClassClose"&&s.type!=="CharacterClassIntersector"){let l=o(i,{...r,isCheckingRangeEnd:!0});if(a.type==="Character"&&l.type==="Character")return i.body.pop(),W(a,l);throw new Error("Invalid character class range")}return K(y("-"))}function Vt({negate:e},t,r){let{tokens:n,walk:o}=t,i=[D()],a=n[t.nextIndex],s=ve(a);for(;s.type!=="CharacterClassClose";){if(s.type==="CharacterClassIntersector")i.push(D()),t.nextIndex++;else{let p=i.at(-1);p.body.push(o(p,r))}s=ve(n[t.nextIndex],a)}let l=D({negate:e});return i.length===1?l.body=i[0].body:(l.kind="intersection",l.body=i.map(p=>p.body.length===1?p.body[0]:p)),t.nextIndex++,l}function jt({kind:e,negate:t,value:r},n){let{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:i,unicodePropertyMap:a}=n;if(e==="property"){let s=Z(r);if(U.has(s)&&!a?.has(s))e="posix",r=s;else return J(r,{negate:t,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:i,unicodePropertyMap:a})}return e==="posix"?er(r,{negate:t}):k(e,{negate:t})}function zt(e,t,r){let{tokens:n,capturingGroups:o,namedGroupsByName:i,skipLookbehindValidation:a,walk:s}=t,l=nr(e),p=l.type==="AbsenceFunction",d=xe(l),_=d&&l.negate;if(l.type==="CapturingGroup"&&(o.push(l),l.name&&pe(i,l.name,[]).push(l)),p&&r.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let u=we(n[t.nextIndex]);for(;u.type!=="GroupClose";){if(u.type==="Alternator")l.body.push(N()),t.nextIndex++;else{let h=l.body.at(-1),f=s(h,{...r,isInAbsenceFunction:r.isInAbsenceFunction||p,isInLookbehind:r.isInLookbehind||d,isInNegLookbehind:r.isInNegLookbehind||_});if(h.body.push(f),(d||r.isInLookbehind)&&!a){let C="Lookbehind includes a pattern not allowed by Oniguruma";if(_||r.isInNegLookbehind){if(Se(f)||f.type==="CapturingGroup")throw new Error(C)}else if(Se(f)||xe(f)&&f.negate)throw new Error(C)}}u=we(n[t.nextIndex])}return t.nextIndex++,l}function Ht({kind:e,min:t,max:r},n){let o=n.parent,i=o.body.at(-1);if(!i||!E(i))throw new Error("Quantifier requires a repeatable token");let a=X(e,t,r,i);return o.body.pop(),a}function Qt({raw:e},t){let{capturingGroups:r,subroutines:n}=t,o=e.slice(3,-1),i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(o);if(i){let s=+i.groups.num,l=r.length;if(t.hasNumberedRef=!0,o={"":s,"+":l+s,"-":l+1-s}[i.groups.sign],o<1)throw new Error("Invalid subroutine number")}else o==="0"&&(o=0);let a=rr(o);return n.push(a),a}function Wt(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:R(t?.body)}}function N(e){return{type:"Alternative",body:Te(e?.body)}}function Xt(e,t){let r={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(r.negate=!!t?.negate),r}function Ae(e,t){let r=!!t?.orphan;return{type:"Backreference",ref:e,...r&&{orphan:r}}}function Jt(e,t){let r={name:void 0,isSubroutined:!1,...t};if(r.name!==void 0&&!ar(r.name))throw new Error(`Group name "${r.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...r.name&&{name:r.name},...r.isSubroutined&&{isSubroutined:r.isSubroutined},body:R(t?.body)}}function K(e,t){let r={useLastValid:!1,...t};if(e>1114111){let n=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${n}}"`):new Error(`Invalid code point out of range in JS "\\x{${n}}"`)}return{type:"Character",value:e}}function D(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Te(e?.body)}}function W(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function k(e,t){let r=!!t?.negate,n={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(n.negate=r),(e==="text_segment"||e==="newline"&&!r)&&(n.variableLength=!0),n}function Zt(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:m(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function qt(e){return{type:"Flags",...e}}function S(e){let t=e?.atomic,r=e?.flags;if(t&&r)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...r&&{flags:r},body:R(e?.body)}}function ie(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:R(e?.body)}}function Yt(e,t,r){return{type:"NamedCallout",kind:e,tag:t,arguments:r}}function er(e,t){let r=!!t?.negate;if(!U.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:r}}function X(e,t,r,n){if(t>r)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:r,body:n}}function tr(e,t){return{type:"Regex",body:R(t?.body),flags:e}}function rr(e){return{type:"Subroutine",ref:e}}function J(e,t){let r={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},n=r.unicodePropertyMap?.get(Z(e));if(!n){if(r.normalizeUnknownPropertyNames)n=or(e);else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw new Error(c`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:n??e,negate:r.negate}}function nr({flags:e,kind:t,name:r,negate:n,number:o}){switch(t){case"absence_repeater":return Wt("repeater");case"atomic":return S({atomic:!0});case"capturing":return Jt(o,{name:r});case"group":return S({flags:e});case"lookahead":case"lookbehind":return ie({behind:t==="lookbehind",negate:n});default:throw new Error(`Unexpected group kind "${t}"`)}}function R(e){if(e===void 0)e=[N()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Te(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Se(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function xe(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function ar(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function or(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Z(e){return e.replace(/[- _]+/g,"").toLowerCase()}function ve(e,t){let r=t;return m(e,`Unclosed character class${r?.type==="Character"&&r.value===93&&r.raw==="]"?' (started with "]")':""}`)}function we(e){return m(e,"Unclosed group")}var G=new Map(`ASCII_Hex_Digit
|
|
32
|
+
`.replace(/\s+/g,""),"gsu");function be(e,t={}){let r={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let a=Gt(r.flags),i=[a.extended],o={captureGroup:r.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(u){i.push(u)},replaceCurrentModX(u){i[i.length-1]=u},singleline:r.rules.singleline},n=[],s;for(Q.lastIndex=0;s=Q.exec(e);){let u=mt(o,e,s[0],Q.lastIndex);u.tokens?n.push(...u.tokens):u.token&&n.push(u.token),u.lastIndex!==void 0&&(Q.lastIndex=u.lastIndex)}let l=[],p=0;n.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++p:u.raw==="("&&l.push(u)}),p||l.forEach((u,h)=>{u.kind="capturing",u.number=h+1});let d=p||l.length;return{tokens:n.map(u=>u.type==="EscapedNumber"?Ft(u,d):u).flat(),flags:a}}function mt(e,t,r,a){let[i,o]=r;if(r==="["||r==="[^"){let n=yt(t,r,a);return{tokens:n.tokens,lastIndex:n.lastIndex}}if(i==="\\"){if("AbBGyYzZ".includes(o))return{token:fe(r,r)};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:vt(r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:ke(r)}}if(o==="K")return{token:Ie("keep",r)};if(o==="N"||o==="R")return{token:T("newline",r,{negate:o==="N"})};if(o==="O")return{token:T("any",r)};if(o==="X")return{token:T("text_segment",r)};let n=Ne(r,{inCharClass:!1});return Array.isArray(n)?{tokens:n}:{token:n}}if(i==="("){if(o==="*")return{token:Pt(r)};if(r==="(?{")throw new Error(`Unsupported callout "${r}"`);if(r.startsWith("(?#")){if(t[a]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:a+1}}if(/^\(\?[-imx]+[:)]$/.test(r))return{token:Et(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("&&!e.captureGroup||r==="(?:")return{token:P("group",r)};if(r==="(?>")return{token:P("atomic",r)};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:P(r[2]==="<"?"lookbehind":"lookahead",r,{negate:r.endsWith("!")})};if(r==="("&&e.captureGroup||r.startsWith("(?<")&&r.endsWith(">")||r.startsWith("(?'")&&r.endsWith("'"))return{token:P("capturing",r,{...r!=="("&&{name:r.slice(3,-1)}})};if(r.startsWith("(?~")){if(r==="(?~|")throw new Error(`Unsupported absence function kind "${r}"`);return{token:P("absence_repeater",r)}}throw r==="(?("?new Error(`Unsupported conditional "${r}"`):new Error(`Invalid or unsupported group option "${r}"`)}if(r===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:At(r)}}if(e.getCurrentModX()){if(r==="#"){let n=t.indexOf(`
|
|
33
|
+
`,a);return{lastIndex:n===-1?t.length:n}}if(/^\s$/.test(r)){let n=/\s+/y;return n.lastIndex=a,{lastIndex:n.exec(t)?n.lastIndex:a}}}if(r===".")return{token:T("dot",r)};if(r==="^"||r==="$"){let n=e.singleline?{"^":c`\A`,$:c`\Z`}[r]:r;return{token:fe(n,r)}}return r==="|"?{token:Ct(r)}:oe.test(r)?{tokens:Ut(r)}:{token:A(y(r),r)}}function yt(e,t,r){let a=[he(t[1]==="^",t)],i=1,o;for(ae.lastIndex=r;o=ae.exec(e);){let n=o[0];if(n[0]==="["&&n[1]!==":")i++,a.push(he(n[1]==="^",n));else if(n==="]"){if(a.at(-1).type==="CharacterClassOpen")a.push(A(93,n));else if(i--,a.push(bt(n)),!i)break}else{let s=gt(n);Array.isArray(s)?a.push(...s):a.push(s)}}return{tokens:a,lastIndex:ae.lastIndex||e.length}}function gt(e){if(e[0]==="\\")return Ne(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!U.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return T("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Nt(e):e==="&&"?kt(e):A(y(e),e)}function Ne(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Tt(e);if("dDhHsSwW".includes(r))return Ot(e);if(e.startsWith(c`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Mt(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let a=e.split(/\\x/).slice(1).map(s=>parseInt(s,16)),i=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(a)),o=new TextEncoder;return[...i].map(s=>{let l=[...o.encode(s)].map(p=>`\\x${p.toString(16)}`).join("");return A(y(s),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return A(Lt(e),e);if(_e.has(r))return A(_e.get(r),e);if(/\d/.test(r))return It(t,e);if(e==="\\")throw new Error(c`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return A(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Ct(e){return{type:"Alternator",raw:e}}function fe(e,t){return{type:"Assertion",kind:e,raw:t}}function ke(e){return{type:"Backreference",raw:e}}function A(e,t){return{type:"Character",value:e,raw:t}}function bt(e){return{type:"CharacterClassClose",raw:e}}function Nt(e){return{type:"CharacterClassHyphen",raw:e}}function kt(e){return{type:"CharacterClassIntersector",raw:e}}function he(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function T(e,t,r={}){return{type:"CharacterSet",kind:e,...r,raw:t}}function Ie(e,t,r={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:m(r.flags),raw:t}}function It(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function At(e){return{type:"GroupClose",raw:e}}function P(e,t,r={}){return{type:"GroupOpen",kind:e,...r,raw:t}}function St(e,t,r,a){return{type:"NamedCallout",kind:e,tag:t,arguments:r,raw:a}}function xt(e,t,r,a){return{type:"Quantifier",kind:e,min:t,max:r,raw:a}}function vt(e){return{type:"Subroutine",raw:e}}var wt=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),_e=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Tt(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return A(y(t.toUpperCase())-64,e)}function Et(e,t){let{on:r,off:a}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;a??="";let i=(t.getCurrentModX()||r.includes("x"))&&!a.includes("x"),o=ye(r),n=ye(a),s={};if(o&&(s.enable=o),n&&(s.disable=n),e.endsWith(")"))return t.replaceCurrentModX(i),Ie("flags",e,{flags:s});if(e.endsWith(":"))return t.pushModX(i),t.numOpenGroups++,P("group",e,{...(o||n)&&{flags:s}});throw new Error(`Unexpected flag modifier "${e}"`)}function Pt(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:r,tag:a,args:i}=t.groups;if(!r)throw new Error(`Invalid named callout "${e}"`);if(a==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let o=i?i.split(",").filter(d=>d!=="").map(d=>/^[+-]?\d+$/.test(d)?+d:d):[],[n,s,l]=o,p=wt.has(r)?r.toLowerCase():"custom";switch(p){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof n=="string")throw new Error(`Named callout argument must be a number "${n}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof n=="string"&&!/^[A-Za-z_]\w*$/.test(n))throw new Error(`Named callout argument one must be a tag or number "${n}"`);if(o.length===2&&(typeof s=="number"||!/^[<>X]$/.test(s)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof n=="number"||!/^[<>X]$/.test(n)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${n}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof n=="string"&&!/^[A-Za-z_]\w*$/.test(n))throw new Error(`Named callout argument one must be a tag or number "${n}"`);if(typeof s=="number"||!/^(?:[<>!=]=|[<>])$/.test(s))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${r}"`);default:throw new Error(`Unexpected named callout kind "${p}"`)}return St(p,a??null,i?.split(",")??null,e)}function me(e){let t=null,r,a;if(e[0]==="{"){let{minStr:i,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,n=1e5;if(+i>n||o&&+o>n)throw new Error("Quantifier value unsupported in Oniguruma");if(r=+i,a=o===void 0?+i:o===""?1/0:+o,r>a&&(t="possessive",[r,a]=[a,r]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else r=e[0]==="+"?1:0,a=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return xt(t,r,a,e)}function Ot(e){let t=e[1].toLowerCase();return T({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Mt(e){let{p:t,neg:r,value:a}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return T("property",e,{value:a,negate:t==="P"&&!r||t==="p"&&!!r})}function ye(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Gt(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let r=0;r<e.length;r++){let a=e[r];if(!"imxDPSWy".includes(a))throw new Error(`Invalid flag "${a}"`);if(a==="y"){if(!/^y{[gw]}/.test(e.slice(r)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[r+2]==="g"?"grapheme":"word",r+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[a]]=!0}return t}function Lt(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Ft(e,t){let{raw:r,inCharClass:a}=e,i=r.slice(1);if(!a&&(i!=="0"&&i.length===1||i[0]!=="0"&&+i<=t))return[ke(r)];let o=[],n=i.match(/^[0-7]+|\d/g);for(let s=0;s<n.length;s++){let l=n[s],p;if(s===0&&l!=="8"&&l!=="9"){if(p=parseInt(l,8),p>127)throw new Error(c`Octal encoded byte above 177 unsupported "${r}"`)}else p=y(l);o.push(A(p,(s===0?"\\":"")+l))}return o}function Ut(e){let t=[],r=new RegExp(oe,"gy"),a;for(;a=r.exec(e);){let i=a[0];if(i[0]==="{"){let o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(i);if(o){let{min:n,max:s}=o.groups;if(+n>+s&&i.endsWith("?")){r.lastIndex--,t.push(me(i.slice(0,-1)));continue}}}t.push(me(i))}return t}function O(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let r=e.body[0];return!t||Object.keys(t).every(a=>t[a]===r[a])}function b(e){return!(!$t.has(e.type)||e.type==="AbsenceFunction"&&e.kind!=="repeater")}var $t=new Set(["AbsenceFunction","CapturingGroup","Group","LookaroundAssertion","Regex"]);function E(e){return Dt.has(e.type)}var Dt=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function M(e,t={}){let r={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},a=be(e,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline}}),i=(u,h)=>{let f=a.tokens[o.nextIndex];switch(o.parent=u,o.nextIndex++,f.type){case"Alternator":return N();case"Assertion":return Kt(f);case"Backreference":return Rt(f,o);case"Character":return K(f.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return Bt(f,o,h);case"CharacterClassOpen":return Vt(f,o,h);case"CharacterSet":return jt(f,o);case"Directive":return Zt(f.kind,{flags:f.flags});case"GroupOpen":return zt(f,o,h);case"NamedCallout":return Yt(f.kind,f.tag,f.arguments);case"Quantifier":return Ht(f,o);case"Subroutine":return Qt(f,o);default:throw new Error(`Unexpected token type "${f.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:r.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:r.skipBackrefValidation,skipLookbehindValidation:r.skipLookbehindValidation,skipPropertyNameValidation:r.skipPropertyNameValidation,subroutines:[],tokens:a.tokens,unicodePropertyMap:r.unicodePropertyMap,walk:i},n=tr(qt(a.flags)),s=n.body[0];for(;o.nextIndex<a.tokens.length;){let u=i(s,{});u.type==="Alternative"?(n.body.push(u),s=u):s.body.push(u)}let{capturingGroups:l,hasNumberedRef:p,namedGroupsByName:d,subroutines:_}=o;if(p&&d.size&&!r.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:u}of _)if(typeof u=="number"){if(u>l.length)throw new Error("Subroutine uses a group number that's not defined");u&&(l[u-1].isSubroutined=!0)}else if(d.has(u)){if(d.get(u).length>1)throw new Error(c`Subroutine uses a duplicate group name "\g<${u}>"`);d.get(u)[0].isSubroutined=!0}else throw new Error(c`Subroutine uses a group name that's not defined "\g<${u}>"`);return n}function Kt({kind:e}){return Xt(m({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===c`\B`||e===c`\Y`})}function Rt({raw:e},t){let r=/^\\k[<']/.test(e),a=r?e.slice(3,-1):e.slice(1),i=(o,n=!1)=>{let s=t.capturingGroups.length,l=!1;if(o>s)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Ae(n?s+1-o:o,{orphan:l})};if(r){let o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(a);if(o)return i(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(a))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(a))throw new Error(`Group name not defined to the left "${e}"`);return Ae(a)}return i(+a)}function Bt(e,t,r){let{tokens:a,walk:i}=t,o=t.parent,n=o.body.at(-1),s=a[t.nextIndex];if(!r.isCheckingRangeEnd&&n&&n.type!=="CharacterClass"&&n.type!=="CharacterClassRange"&&s&&s.type!=="CharacterClassOpen"&&s.type!=="CharacterClassClose"&&s.type!=="CharacterClassIntersector"){let l=i(o,{...r,isCheckingRangeEnd:!0});if(n.type==="Character"&&l.type==="Character")return o.body.pop(),W(n,l);throw new Error("Invalid character class range")}return K(y("-"))}function Vt({negate:e},t,r){let{tokens:a,walk:i}=t,o=a[t.nextIndex],n=[D()],s=ve(o);for(;s.type!=="CharacterClassClose";){if(s.type==="CharacterClassIntersector")n.push(D()),t.nextIndex++;else{let p=n.at(-1);p.body.push(i(p,r))}s=ve(a[t.nextIndex],o)}let l=D({negate:e});return n.length===1?l.body=n[0].body:(l.kind="intersection",l.body=n.map(p=>p.body.length===1?p.body[0]:p)),t.nextIndex++,l}function jt({kind:e,negate:t,value:r},a){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:n}=a;if(e==="property"){let s=Z(r);if(U.has(s)&&!n?.has(s))e="posix",r=s;else return J(r,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:n})}return e==="posix"?er(r,{negate:t}):I(e,{negate:t})}function zt(e,t,r){let{tokens:a,capturingGroups:i,namedGroupsByName:o,skipLookbehindValidation:n,walk:s}=t,l=nr(e),p=l.type==="AbsenceFunction",d=xe(l),_=d&&l.negate;if(l.type==="CapturingGroup"&&(i.push(l),l.name&&pe(o,l.name,[]).push(l)),p&&r.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let u=we(a[t.nextIndex]);for(;u.type!=="GroupClose";){if(u.type==="Alternator")l.body.push(N()),t.nextIndex++;else{let h=l.body.at(-1),f=s(h,{...r,isInAbsenceFunction:r.isInAbsenceFunction||p,isInLookbehind:r.isInLookbehind||d,isInNegLookbehind:r.isInNegLookbehind||_});if(h.body.push(f),(d||r.isInLookbehind)&&!n){let C="Lookbehind includes a pattern not allowed by Oniguruma";if(_||r.isInNegLookbehind){if(Se(f)||f.type==="CapturingGroup")throw new Error(C)}else if(Se(f)||xe(f)&&f.negate)throw new Error(C)}}u=we(a[t.nextIndex])}return t.nextIndex++,l}function Ht({kind:e,min:t,max:r},a){let i=a.parent,o=i.body.at(-1);if(!o||!E(o))throw new Error("Quantifier requires a repeatable token");let n=X(e,t,r,o);return i.body.pop(),n}function Qt({raw:e},t){let{capturingGroups:r,subroutines:a}=t,i=e.slice(3,-1),o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(o){let s=+o.groups.num,l=r.length;if(t.hasNumberedRef=!0,i={"":s,"+":l+s,"-":l+1-s}[o.groups.sign],i<1)throw new Error("Invalid subroutine number")}else i==="0"&&(i=0);let n=rr(i);return a.push(n),n}function Wt(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:R(t?.body)}}function N(e){return{type:"Alternative",body:Te(e?.body)}}function Xt(e,t){let r={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(r.negate=!!t?.negate),r}function Ae(e,t){let r=!!t?.orphan;return{type:"Backreference",ref:e,...r&&{orphan:r}}}function Jt(e,t){let r={name:void 0,isSubroutined:!1,...t};if(r.name!==void 0&&!ar(r.name))throw new Error(`Group name "${r.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...r.name&&{name:r.name},...r.isSubroutined&&{isSubroutined:r.isSubroutined},body:R(t?.body)}}function K(e,t){let r={useLastValid:!1,...t};if(e>1114111){let a=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${a}}"`):new Error(`Invalid code point out of range in JS "\\x{${a}}"`)}return{type:"Character",value:e}}function D(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Te(e?.body)}}function W(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function I(e,t){let r=!!t?.negate,a={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(a.negate=r),(e==="text_segment"||e==="newline"&&!r)&&(a.variableLength=!0),a}function Zt(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:m(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function qt(e){return{type:"Flags",...e}}function S(e){let t=e?.atomic,r=e?.flags;if(t&&r)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...r&&{flags:r},body:R(e?.body)}}function ie(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:R(e?.body)}}function Yt(e,t,r){return{type:"NamedCallout",kind:e,tag:t,arguments:r}}function er(e,t){let r=!!t?.negate;if(!U.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:r}}function X(e,t,r,a){if(t>r)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:r,body:a}}function tr(e,t){return{type:"Regex",body:R(t?.body),flags:e}}function rr(e){return{type:"Subroutine",ref:e}}function J(e,t){let r={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},a=r.unicodePropertyMap?.get(Z(e));if(!a){if(r.normalizeUnknownPropertyNames)a=or(e);else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw new Error(c`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:a??e,negate:r.negate}}function nr({flags:e,kind:t,name:r,negate:a,number:i}){switch(t){case"absence_repeater":return Wt("repeater");case"atomic":return S({atomic:!0});case"capturing":return Jt(i,{name:r});case"group":return S({flags:e});case"lookahead":case"lookbehind":return ie({behind:t==="lookbehind",negate:a});default:throw new Error(`Unexpected group kind "${t}"`)}}function R(e){if(e===void 0)e=[N()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Te(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Se(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function xe(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function ar(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function or(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Z(e){return e.replace(/[- _]+/g,"").toLowerCase()}function ve(e,t){return m(e,`${t?.type==="Character"&&t.value===93?"Empty":"Unclosed"} character class`)}function we(e){return m(e,"Unclosed group")}var G=new Map(`ASCII_Hex_Digit
|
|
34
34
|
Adlam
|
|
35
35
|
Ahom
|
|
36
36
|
Alphabetic
|
|
@@ -900,5 +900,5 @@ In_Tags
|
|
|
900
900
|
In_Variation_Selectors_Supplement
|
|
901
901
|
In_Supplementary_Private_Use_Area_A
|
|
902
902
|
In_Supplementary_Private_Use_Area_B
|
|
903
|
-
In_No_Block`.split(/\s/).map(e=>[Z(e),e]));function Ee(e,t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");return M(e,{flags:t.flags??"",rules:{captureGroup:t.rules?.captureGroup??!1,singleline:t.rules?.singleline??!1},unicodePropertyMap:G})}function Y(e,t,r=null){function n(i,a){for(let s=0;s<i.length;s++){let l=o(i[s],a,s,i);s=Math.max(-1,s+l)}}function o(i,a=null,s=null,l=null){let p=0,d=!1,_={node:i,parent:a,key:s,container:l,root:e,remove(){q(l).splice(Math.max(0,L(s)+p),1),p--,d=!0},removeAllNextSiblings(){return q(l).splice(L(s)+1)},removeAllPrevSiblings(){let g=L(s)+p;return p-=g,q(l).splice(0,Math.max(0,g))},replaceWith(g,F={}){let re=!!F.traverse;l?l[Math.max(0,L(s)+p)]=g:m(a,"Can't replace root node")[s]=g,re&&o(g,a,s,l),d=!0},replaceWithMultiple(g,F={}){let re=!!F.traverse;if(q(l).splice(Math.max(0,L(s)+p),1,...g),p+=g.length-1,re){let ue=0;for(let z=0;z<g.length;z++)ue+=o(g[z],a,L(s)+z+ue,l)}d=!0},skip(){d=!0}},{type:u}=i,h=t["*"],f=t[u],C=typeof h=="function"?h:h?.enter,j=typeof f=="function"?f:f?.enter;if(C?.(_,r),j?.(_,r),!d)switch(u){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":n(i.body,i);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(i.min,i,"min"),o(i.max,i,"max");break;case"Quantifier":o(i.body,i,"body");break;case"Regex":n(i.body,i),o(i.flags,i,"flags");break;default:throw new Error(`Unexpected node type "${u}"`)}return f?.exit?.(_,r),h?.exit?.(_,r),p}return o(e),e}function q(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function L(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}var Oe={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=[],r=[];for(let n of e.body){let o=n.body[0];n.body.length===1&&(o.type==="Character"||o.type==="CharacterClass"||o.type==="CharacterSet"&&ir.has(o.kind))?r.push(o):(r.length&&(t.push(Pe(r)),r=[]),t.push(n))}r.length&&t.push(Pe(r)),e.body=t}};function Pe(e){let t=N(),r=e.length>1?D({body:e}):e[0];return r&&t.body.push(r),t}var ir=new Set(["digit","hex","posix","property","space","word"]);var Me={CapturingGroup({node:e,parent:t,replaceWithMultiple:r}){if(t.type==="Quantifier"||e.body.length>1||e.isSubroutined)return;let n=e.body[0],o=n.body,i=o[0],a=o.length>1?o.at(-1):null,s=i&&i.type==="Assertion",l=a&&a.type==="Assertion",p=s?1:0,d=o.length-(l?1:0);if(s||l){n.body=o.slice(p,d);let _=[];s&&_.push(i),_.push(e),l&&_.push(a),r(_,{traverse:!0})}}};var Ge={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=[],r=!1,n=0;for(;!r;){t.push(e.body[0].body[n]);for(let a of e.body){let s=a.body[n];if(!s||!x(s)||!v(s,t[n])){r=!0;break}}n++}if(t.pop(),!t.length)return;for(let a of e.body)a.body=a.body.slice(t.length);let o=N({body:t}),i=S({body:e.body});i.body.every(a=>!a.body.length)||o.body.push(i),e.body=[o]}};function x(e){return e.type==="Assertion"||e.type==="Character"||e.type==="CharacterSet"}function v(e,t){if(e.type!==t.type)return!1;if(e.type==="Assertion"||e.type==="CharacterSet")return e.kind===t.kind&&e.negate===t.negate;if(e.type==="Character")return e.value===t.value;throw new Error(`Unexpected node type "${e.type}"`)}var Le={"*"({node:e}){if(!b(e))return;let t=2,r=e.body.length;if(r<t*2||r%t)return;let n=[...e.body.slice(0,t).map(h=>h.body)],o=Array.from({length:t},()=>[]),i=Array(t).fill(!1),a=Math.max(...n.map(h=>h.length));for(let h=0;h<a;h++)for(let f=0;f<t;f++)if(!i[f]){let C=n[f][h];!C||!x(C)||!sr(C,e.body,f,h,t)?i[f]=!0:o[f].push(C)}if(!o.some(h=>h.length))return;let s=[],l=0;for(let h=0;h<r;h++)s.push(N({body:e.body[h].body.slice(o[l].length)})),l=l<t-1?l+1:0;for(let h=0;h<r/t;h++){let f=s.slice(h*t,h*t+t);for(let C=1;C<f.length;C++){let j=f[C].body;if(j.length!==f[0].body.length||!j.every((g,F)=>x(g)&&v(g,f[0].body[F])))return}}let p=[];for(let h=0;h<t;h++)p.push(N({body:o[h]}));let d=S({body:p}),_=N({body:[d]}),u=S({body:s.filter((h,f)=>f%t)});u.body.every(h=>!h.body.length)?e.body=d.body:(_.body.push(u),e.body=[_])}};function sr(e,t,r,n,o){for(let i=r;i<t.length;i+=o){let s=t[i].body[n];if(!s||!v(s,e))return!1}return!0}var Fe={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=e.body[0].body,r=[],n=!1,o=0;for(;!n;){let s=t.length-1-o;r.push(t[s]);for(let l of e.body){let p=l.body.length-1-o,d=l.body[p];if(!d||!x(d)||!v(d,r[o])){n=!0;break}}o++}if(r.pop(),!r.length||r.length<3&&r[0].type!=="Assertion"&&r.length*(e.body.length-1)<4&&!e.body.some((s,l,p)=>{let d=p[l-1],_=r.length;return s.body.length-_<2&&d&&d.body.length-_<2}))return;r.reverse();for(let s of e.body)s.body=s.body.slice(0,-r.length);let i=N(),a=S({body:e.body});a.body.every(s=>!s.body.length)||i.body.push(a),i.body.push(...r),e.body=[i]}};var $e={CharacterClass({node:e}){if(e.kind!=="union"||!e.body.length)return;let t=[];for(let a of e.body)a.type==="CharacterSet"&&t.some(s=>s.type===a.type&&s.kind===a.kind&&s.negate===a.negate&&s.value===a.value)||t.push(a);e.body=t;let r=[],n=[];for(let a of e.body)a.type==="Character"||a.type==="CharacterClassRange"?n.push(a):r.push(a);if(!n.length)return;n.sort((a,s)=>{let l=a.type==="Character"?a.value:a.min.value,p=s.type==="Character"?s.value:s.min.value;return l-p});let o=[n[0]];for(let a=1;a<n.length;a++){let s=n[a],l=o.at(-1),p=s.type==="Character"?s.value:s.min.value,d=l.type==="Character"?l.value:l.max.value;if(p<=d+1)if(l.type==="Character"&&s.type==="Character")l.value!==s.value&&(o[o.length-1]=W(l,s));else if(l.type==="Character"&&s.type==="CharacterClassRange")o[o.length-1]=W(K(l.value),s.max);else if(l.type==="CharacterClassRange"&&s.type==="Character")l.max.value=Math.max(s.value,l.max.value);else if(l.type==="CharacterClassRange"&&s.type==="CharacterClassRange")l.max.value=Math.max(s.max.value,l.max.value);else throw new Error("Unexpected merge case");else o.push(s)}let i=o.flatMap(a=>{if(a.type==="CharacterClassRange"){let s=a.max.value-a.min.value;if(a.min.value>262143&&s>1)return a;if(s){if(s===1)return[a.min,a.max];if(s===2)return[a.min,K(a.min.value+1),a.max]}else return a.min}return a});e.body=[...i.filter(a=>Ue(a)),...i.filter(a=>!Ue(a)),...r]}};function Ue(e){return e.type==="Character"&&(e.value===45||e.value===93)}var Ke={"*"({node:e}){if(!b(e)||e.body.length<2)return;let{body:t}=e,r=[t[0]],n=t[0];for(let o=1;o<t.length;o++){let i=t[o],a=i.body,s=n.body,l=Math.abs(a.length-s.length);if(l){if(l===1){let p=s.length>a.length,d=p?a:a.slice(0,-1),_=p?s.slice(0,-1):s;if(De(d,_)){if(p){let u=m(s.at(-1));if(E(u))if(u.type==="Quantifier")if(u.min){if(u.min===1&&u.kind!=="lazy"){u.min=0;continue}}else continue;else{s.pop(),s.push(X("greedy",0,1,u));continue}}else if(s.length>0||t.length===2){let u=m(a.at(-1));if(E(u))if(u.type==="Quantifier"){if(u.kind!=="possessive"){if(u.min<=1&&u.kind==="lazy"){u.min=0,s.push(u);continue}else if(!u.min&&u.max===1){u.kind="lazy",s.push(u);continue}}}else{s.push(X("lazy",0,1,u));continue}}}}}else if(De(a,s))continue;r.push(i),n=i}e.body=r}};function De(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!x(e[r])||!x(t[r])||!v(e[r],t[r]))return!1;return!0}var Re={Quantifier({node:e}){let{body:t,max:r}=e;if(r!==1/0||t.type!=="Group"||t.atomic)return;let n=t.body[0];if(!O(n,{type:"Quantifier"}))return;let o=n.body[0];o.kind==="possessive"||o.min>1||o.max<2||(o.min?o.min===1&&(n.body[0]=o.body):o.max=1)}};var Be={AbsenceFunction({node:e,remove:t}){ee(e)&&t()},Group({node:e,remove:t}){ee(e)&&t()},LookaroundAssertion({node:e,remove:t}){ee(e)&&t()},Quantifier({node:e,remove:t}){let r=e.body;for(;r.type==="Quantifier";)r=r.body;ee(r)&&t()}};function se(e){return e.body.every(t=>!t.body.length)}function ee(e){switch(e.type){case"AbsenceFunction":return e.kind==="repeater"&&se(e);case"Group":return se(e);case"LookaroundAssertion":return!e.negate&&se(e);default:return!1}}var ze={Flags({node:e}){e.extended=!1,e.textSegmentMode==="grapheme"&&(e.textSegmentMode=null)},Directive({node:e,remove:t}){e.kind==="flags"&&(je(e),Ve(e)&&t())},Group({node:e}){e.flags&&(je(e),Ve(e))}};function Ve(e){let{flags:t}=e;return t&&!t.enable&&!t.disable?(delete e.flags,!0):!1}function je({flags:e}){if(!e)throw new Error("Expected flags");e.enable&&delete e.enable.extended,e.disable&&delete e.disable.extended,lr(e)}function lr(e){e.enable&&!Object.keys(e.enable).length&&delete e.enable,e.disable&&!Object.keys(e.disable).length&&delete e.disable}var He={NamedCallout({node:e,replaceWith:t}){let{arguments:r,kind:n}=e;if(n==="fail"){t(ie({negate:!0}));return}if(!r)return;let o=r.filter(i=>i!=="").map(i=>typeof i=="string"&&/^[+-]?\d+$/.test(i)?+i:i);e.arguments=o.length?o:null}};var Qe={CharacterClass({node:e,parent:t,replaceWith:r,replaceWithMultiple:n}){let{body:o,kind:i,negate:a}=e;if(t.type!=="CharacterClass"||i!=="union"||!o.length)return;let s=o[0];if(O(t,{type:"CharacterClass",kind:"union"})){t.negate=t.negate!==a,n(o,{traverse:!0});return}a||(t.kind==="union"?n(o,{traverse:!0}):O(e)&&r(s,{traverse:!0}))}};var We={CharacterClass({node:e,parent:t,replaceWith:r}){let{body:n,kind:o,negate:i}=e;if(!i||o!=="union"||n.length!==1)return;let a=n[0];if(a.type==="CharacterSet")a.negate=!a.negate,r(a);else if(t.type!=="CharacterClass"&&a.type==="Character"&&a.value===10){if(t.type==="Quantifier"&&t.kind!=="lazy")return;r(k("newline",{negate:!0}))}}};var Xe={CharacterClass({node:e,parent:t,replaceWith:r}){let{body:n,kind:o,negate:i}=e,a=n[0];t.type==="CharacterClass"||i||o!=="union"||n.length!==1||a.type!=="Character"&&a.type!=="CharacterSet"||r(a,{traverse:!0})}};var Ze={"*"({node:e}){b(e)&&ur(e)&&(e.body=e.body[0].body[0].body)},Group({node:e,parent:t,replaceWithMultiple:r}){let{atomic:n,body:o,flags:i}=e,a=o[0].body;if(o.length>1||t.type==="Quantifier")return;let s=!1;n?a.every(({type:l})=>Je.has(l))&&(s=!0):i||(s=!0),s&&r(a,{traverse:!0})},Quantifier({node:e}){if(e.body.type!=="Group")return;let t=e.body;if(t.body.length>1)return;let r=t.body[0].body;if(r.length!==1)return;let n=r[0];!E(n)||t.atomic&&!Je.has(n.type)||t.flags||(e.body=n)}},Je=new Set(["Assertion","Backreference","Character","CharacterClass","CharacterSet","Directive","NamedCallout"]);function ur({body:e}){let t=e[0].body;return e.length===1&&t.length===1&&t[0].type==="Group"&&!t[0].atomic&&!t[0].flags&&t[0].body.length>1}var qe={CharacterSet({node:e,parent:t,root:r,replaceWith:n}){let{kind:o,negate:i,value:a}=e,s=null;o==="property"&&(a==="Decimal_Number"||a==="Nd")&&!r.flags.digitIsAscii&&!r.flags.posixIsAscii||o==="posix"&&a==="digit"?s=k("digit",{negate:i}):o==="property"&&(a==="ASCII_Hex_Digit"||a==="AHex")||o==="posix"&&a==="xdigit"?s=k("hex",{negate:i}):o==="property"&&(a==="White_Space"||a==="WSpace")&&!r.flags.spaceIsAscii&&!r.flags.posixIsAscii||o==="posix"&&a==="space"?s=k("space",{negate:i}):t.type!=="CharacterClass"&&o==="property"&&!i&&a==="Any"&&(s=k("any")),s&&n(s)},CharacterClass({node:e,root:t}){if(e.kind!=="union")return;let r={rangeDigit0To9:!1,rangeAToFLower:!1,rangeAToFUpper:!1,unicodeL:!1,unicodeM:!1,unicodeN:!1,unicodePc:!1};for(let n of e.body)n.type==="CharacterClassRange"?(r.rangeDigit0To9||=w(n,I.n0,I.n9),r.rangeAToFLower||=w(n,I.a,I.f),r.rangeAToFUpper||=w(n,I.A,I.F)):n.type==="CharacterSet"&&(r.unicodeL||=B(n,"L"),r.unicodeM||=B(n,"M"),r.unicodeN||=B(n,"N"),r.unicodePc||=B(n,"Pc",{includeSupercategories:!0}));r.rangeDigit0To9&&r.rangeAToFUpper&&r.rangeAToFLower&&(e.body=e.body.filter(n=>!(w(n,I.n0,I.n9)||w(n,I.a,I.f)||w(n,I.A,I.F))),e.body.push(k("hex"))),r.unicodeL&&r.unicodeM&&r.unicodeN&&r.unicodePc&&!t.flags.wordIsAscii&&!t.flags.posixIsAscii&&(e.body=e.body.filter(n=>!B(n,["L","M","N","Pc"],{includeSubcategories:!0})),e.body.push(k("word")))}},I={n0:y("0"),n9:y("9"),A:y("A"),F:y("F"),a:y("a"),f:y("f")};function w(e,t,r){return e.type==="CharacterClassRange"&&e.min.value===t&&e.max.value===r}function B(e,t,r={}){if(e.type!=="CharacterSet"||e.kind!=="property"||e.negate)return!1;let n=Array.isArray(t)?t:[t],o=[];for(let i of n){o.push(i);let a=V[i]?.full,s=Ye[i],l=V[i]?.sub;a&&o.push(a),r.includeSupercategories&&s&&(o.push(s),o.push(V[s].full)),r.includeSubcategories&&l&&o.push(...l)}return o.includes(e.value)}var pr=["Ll","Lm","Lo","Lt","Lu"],cr=["Mc","Me","Mn"],dr=["Nd","Nl","No"],fr=["Pc","Pd","Pe","Pf","Pi","Po","Ps"],V={L:{full:"Letter",sub:pr},M:{full:"Mark",sub:cr},N:{full:"Number",sub:dr},P:{full:"Punctuation",sub:fr}},Ye={};for(let e of Object.keys(V))for(let t of V[e].sub)Ye[t]=e;var et={CharacterSet({node:e}){if(e.kind!=="property")return;let t=hr.get(e.value);t&&(e.value=t)}},hr=new Map([["Other","C"],["Control","Cc"],["Format","Cf"],["Unassigned","Cn"],["Private_Use","Co"],["Surrogate","Cs"],["Letter","L"],["Cased_Letter","LC"],["Lowercase_Letter","Ll"],["Modifier_Letter","Lm"],["Other_Letter","Lo"],["Titlecase_Letter","Lt"],["Uppercase_Letter","Lu"],["Mark","M"],["Combining_Mark","M"],["Spacing_Mark","Mc"],["Enclosing_Mark","Me"],["Nonspacing_Mark","Mn"],["Number","N"],["Decimal_Number","Nd"],["Letter_Number","Nl"],["Other_Number","No"],["Punctuation","P"],["punct","P"],["Connector_Punctuation","Pc"],["Dash_Punctuation","Pd"],["Close_Punctuation","Pe"],["Final_Punctuation","Pf"],["Initial_Punctuation","Pi"],["Other_Punctuation","Po"],["Open_Punctuation","Ps"],["Symbol","S"],["Currency_Symbol","Sc"],["Modifier_Symbol","Sk"],["Math_Symbol","Sm"],["Other_Symbol","So"],["Separator","Z"],["Line_Separator","Zl"],["Paragraph_Separator","Zp"],["Space_Separator","Zs"],["ASCII_Hex_Digit","AHex"],["Bidi_Control","Bidi_C"],["Case_Ignorable","CI"],["Changes_When_Casefolded","CWCF"],["Changes_When_Casemapped","CWCM"],["Changes_When_Lowercased","CWL"],["Changes_When_Titlecased","CWT"],["Changes_When_Uppercased","CWU"],["Default_Ignorable_Code_Point","DI"],["Deprecated","Dep"],["Diacritic","Dia"],["Emoji_Component","EComp"],["Emoji_Modifier","EMod"],["Emoji_Modifier_Base","EBase"],["Emoji_Presentation","EPres"],["Extended_Pictographic","ExtPict"],["Extender","Ext"],["Grapheme_Base","Gr_Base"],["Grapheme_Extend","Gr_Ext"],["Grapheme_Link","Gr_Link"],["Hex_Digit","Hex"],["IDS_Binary_Operator","IDSB"],["IDS_Trinary_Operator","IDST"],["IDS_Unary_Operator","IDSU"],["ID_Continue","IDC"],["ID_Start","IDS"],["Ideographic","Ideo"],["Join_Control","Join_C"],["Logical_Order_Exception","LOE"],["Noncharacter_Code_Point","NChar"],["Other_Alphabetic","OAlpha"],["Other_Default_Ignorable_Code_Point","ODI"],["Other_Grapheme_Extend","OGr_Ext"],["Other_ID_Continue","OIDC"],["Other_ID_Start","OIDS"],["Other_Lowercase","OLower"],["Other_Math","OMath"],["Other_Uppercase","OUpper"],["Pattern_Syntax","Pat_Syn"],["Pattern_White_Space","Pat_WS"],["Prepended_Concatenation_Mark","PCM"],["Quotation_Mark","QMark"],["Regional_Indicator","RI"],["Sentence_Terminal","STerm"],["Soft_Dotted","SD"],["Terminal_Punctuation","Term"],["Unified_Ideograph","UIdeo"],["Variation_Selector","VS"],["White_Space","WSpace"],["XID_Continue","XIDC"],["XID_Start","XIDS"]]);var tt={CharacterSet({node:e,root:t,replaceWith:r}){let{kind:n,negate:o,value:i}=e,a=null;n==="posix"&&i==="cntrl"&&!t.flags.posixIsAscii&&(a=J("Cc",{negate:o})),a&&r(a)},CharacterClassRange({node:e,replaceWith:t}){w(e,0,1114111)&&t(J("Any"))}};var te=new Map([["alternationToClass",Oe],["exposeAnchors",Me],["extractPrefix",Ge],["extractPrefix2",Le],["extractSuffix",Fe],["optionalize",Ke],["preventReDoS",Re],["removeEmptyGroups",Be],["removeUselessFlags",ze],["simplifyCallouts",He],["unnestUselessClasses",Qe],["unwrapNegationWrappers",We],["unwrapUselessClasses",Xe],["unwrapUselessGroups",Ze],["useShorthands",qe],["useUnicodeAliases",et],["useUnicodeProps",tt],["mergeRanges",$e]]);function rt(e,t){let r=_r(t),n=M(e,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline},skipBackrefValidation:r.rules.allowOrphanBackrefs,unicodePropertyMap:G}),o=Object.assign(le(),r.override);for(let l of te.keys())o[l]||delete o[l];let i=Object.keys(o),a={pattern:e,flags:r.flags},s=0;do{if(++s>200)throw new Error("Optimization exceeded maximum iterations; possible infinite loop");e=a.pattern;for(let l of i)Y(n,te.get(l));a=H(n)}while(e!==a.pattern);return a}function _r(e={}){return{flags:"",override:{},...e,rules:{allowOrphanBackrefs:!1,captureGroup:!1,singleline:!1,...e.rules}}}function le(e={}){let t={};for(let r of te.keys())t[r]=!e.disable;return t}return lt(mr);})();
|
|
903
|
+
In_No_Block`.split(/\s/).map(e=>[Z(e),e]));function Ee(e,t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");return M(e,{flags:t.flags??"",rules:{captureGroup:t.rules?.captureGroup??!1,singleline:t.rules?.singleline??!1},unicodePropertyMap:G})}function Y(e,t,r=null){function a(o,n){for(let s=0;s<o.length;s++){let l=i(o[s],n,s,o);s=Math.max(-1,s+l)}}function i(o,n=null,s=null,l=null){let p=0,d=!1,_={node:o,parent:n,key:s,container:l,root:e,remove(){q(l).splice(Math.max(0,L(s)+p),1),p--,d=!0},removeAllNextSiblings(){return q(l).splice(L(s)+1)},removeAllPrevSiblings(){let g=L(s)+p;return p-=g,q(l).splice(0,Math.max(0,g))},replaceWith(g,F={}){let re=!!F.traverse;l?l[Math.max(0,L(s)+p)]=g:m(n,"Can't replace root node")[s]=g,re&&i(g,n,s,l),d=!0},replaceWithMultiple(g,F={}){let re=!!F.traverse;if(q(l).splice(Math.max(0,L(s)+p),1,...g),p+=g.length-1,re){let ue=0;for(let z=0;z<g.length;z++)ue+=i(g[z],n,L(s)+z+ue,l)}d=!0},skip(){d=!0}},{type:u}=o,h=t["*"],f=t[u],C=typeof h=="function"?h:h?.enter,j=typeof f=="function"?f:f?.enter;if(C?.(_,r),j?.(_,r),!d)switch(u){case"AbsenceFunction":case"CapturingGroup":case"Group":a(o.body,o);break;case"Alternative":case"CharacterClass":a(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":i(o.min,o,"min"),i(o.max,o,"max");break;case"LookaroundAssertion":a(o.body,o);break;case"Quantifier":i(o.body,o,"body");break;case"Regex":a(o.body,o),i(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${u}"`)}return f?.exit?.(_,r),h?.exit?.(_,r),p}return i(e),e}function q(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function L(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}var Oe={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=[],r=[];for(let a of e.body){let i=a.body[0];a.body.length===1&&(i.type==="Character"||i.type==="CharacterClass"||i.type==="CharacterSet"&&ir.has(i.kind))?r.push(i):(r.length&&(t.push(Pe(r)),r=[]),t.push(a))}r.length&&t.push(Pe(r)),e.body=t}};function Pe(e){let t=N(),r=e.length>1?D({body:e}):e[0];return r&&t.body.push(r),t}var ir=new Set(["digit","hex","posix","property","space","word"]);var Me={CapturingGroup({node:e,parent:t,replaceWithMultiple:r}){if(t.type==="Quantifier"||e.body.length>1||e.isSubroutined)return;let a=e.body[0],i=a.body,o=i[0],n=i.length>1?i.at(-1):null,s=o&&o.type==="Assertion",l=n&&n.type==="Assertion",p=s?1:0,d=i.length-(l?1:0);if(s||l){a.body=i.slice(p,d);let _=[];s&&_.push(o),_.push(e),l&&_.push(n),r(_,{traverse:!0})}}};var Ge={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=[],r=!1,a=0;for(;!r;){t.push(e.body[0].body[a]);for(let n of e.body){let s=n.body[a];if(!s||!x(s)||!v(s,t[a])){r=!0;break}}a++}if(t.pop(),!t.length)return;for(let n of e.body)n.body=n.body.slice(t.length);let i=N({body:t}),o=S({body:e.body});o.body.every(n=>!n.body.length)||i.body.push(o),e.body=[i]}};function x(e){return e.type==="Assertion"||e.type==="Character"||e.type==="CharacterSet"}function v(e,t){if(e.type!==t.type)return!1;if(e.type==="Assertion"||e.type==="CharacterSet")return e.kind===t.kind&&e.negate===t.negate;if(e.type==="Character")return e.value===t.value;throw new Error(`Unexpected node type "${e.type}"`)}var Le={"*"({node:e}){if(!b(e))return;let t=2,r=e.body.length;if(r<t*2||r%t)return;let a=[...e.body.slice(0,t).map(h=>h.body)],i=Array.from({length:t},()=>[]),o=Array(t).fill(!1),n=Math.max(...a.map(h=>h.length));for(let h=0;h<n;h++)for(let f=0;f<t;f++)if(!o[f]){let C=a[f][h];!C||!x(C)||!sr(C,e.body,f,h,t)?o[f]=!0:i[f].push(C)}if(!i.some(h=>h.length))return;let s=[],l=0;for(let h=0;h<r;h++)s.push(N({body:e.body[h].body.slice(i[l].length)})),l=l<t-1?l+1:0;for(let h=0;h<r/t;h++){let f=s.slice(h*t,h*t+t);for(let C=1;C<f.length;C++){let j=f[C].body;if(j.length!==f[0].body.length||!j.every((g,F)=>x(g)&&v(g,f[0].body[F])))return}}let p=[];for(let h=0;h<t;h++)p.push(N({body:i[h]}));let d=S({body:p}),_=N({body:[d]}),u=S({body:s.filter((h,f)=>f%t)});u.body.every(h=>!h.body.length)?e.body=d.body:(_.body.push(u),e.body=[_])}};function sr(e,t,r,a,i){for(let o=r;o<t.length;o+=i){let s=t[o].body[a];if(!s||!v(s,e))return!1}return!0}var Fe={"*"({node:e}){if(!b(e)||e.body.length<2)return;let t=e.body[0].body,r=[],a=!1,i=0;for(;!a;){let s=t.length-1-i;r.push(t[s]);for(let l of e.body){let p=l.body.length-1-i,d=l.body[p];if(!d||!x(d)||!v(d,r[i])){a=!0;break}}i++}if(r.pop(),!r.length||r.length<3&&r[0].type!=="Assertion"&&r.length*(e.body.length-1)<4&&!e.body.some((s,l,p)=>{let d=p[l-1],_=r.length;return s.body.length-_<2&&d&&d.body.length-_<2}))return;r.reverse();for(let s of e.body)s.body=s.body.slice(0,-r.length);let o=N(),n=S({body:e.body});n.body.every(s=>!s.body.length)||o.body.push(n),o.body.push(...r),e.body=[o]}};var $e={CharacterClass({node:e}){if(e.kind!=="union"||!e.body.length)return;let t=[];for(let n of e.body)n.type==="CharacterSet"&&t.some(s=>s.type===n.type&&s.kind===n.kind&&s.negate===n.negate&&s.value===n.value)||t.push(n);e.body=t;let r=[],a=[];for(let n of e.body)n.type==="Character"||n.type==="CharacterClassRange"?a.push(n):r.push(n);if(!a.length)return;a.sort((n,s)=>{let l=n.type==="Character"?n.value:n.min.value,p=s.type==="Character"?s.value:s.min.value;return l-p});let i=[a[0]];for(let n=1;n<a.length;n++){let s=a[n],l=i.at(-1),p=s.type==="Character"?s.value:s.min.value,d=l.type==="Character"?l.value:l.max.value;if(p<=d+1)if(l.type==="Character"&&s.type==="Character")l.value!==s.value&&(i[i.length-1]=W(l,s));else if(l.type==="Character"&&s.type==="CharacterClassRange")i[i.length-1]=W(K(l.value),s.max);else if(l.type==="CharacterClassRange"&&s.type==="Character")l.max.value=Math.max(s.value,l.max.value);else if(l.type==="CharacterClassRange"&&s.type==="CharacterClassRange")l.max.value=Math.max(s.max.value,l.max.value);else throw new Error("Unexpected merge case");else i.push(s)}let o=i.flatMap(n=>{if(n.type==="CharacterClassRange"){let s=n.max.value-n.min.value;if(n.min.value>262143&&s>1)return n;if(s){if(s===1)return[n.min,n.max];if(s===2)return[n.min,K(n.min.value+1),n.max]}else return n.min}return n});e.body=[...o.filter(n=>Ue(n)),...o.filter(n=>!Ue(n)),...r]}};function Ue(e){return e.type==="Character"&&(e.value===45||e.value===93)}var Ke={"*"({node:e}){if(!b(e)||e.body.length<2)return;let{body:t}=e,r=[t[0]],a=t[0];for(let i=1;i<t.length;i++){let o=t[i],n=o.body,s=a.body,l=Math.abs(n.length-s.length);if(l){if(l===1){let p=s.length>n.length,d=p?n:n.slice(0,-1),_=p?s.slice(0,-1):s;if(De(d,_)){if(p){let u=m(s.at(-1));if(E(u))if(u.type==="Quantifier")if(u.min){if(u.min===1&&u.kind!=="lazy"){u.min=0;continue}}else continue;else{s.pop(),s.push(X("greedy",0,1,u));continue}}else if(s.length>0||t.length===2){let u=m(n.at(-1));if(E(u))if(u.type==="Quantifier"){if(u.kind!=="possessive"){if(u.min<=1&&u.kind==="lazy"){u.min=0,s.push(u);continue}else if(!u.min&&u.max===1){u.kind="lazy",s.push(u);continue}}}else{s.push(X("lazy",0,1,u));continue}}}}}else if(De(n,s))continue;r.push(o),a=o}e.body=r}};function De(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!x(e[r])||!x(t[r])||!v(e[r],t[r]))return!1;return!0}var Re={Quantifier({node:e}){let{body:t,max:r}=e;if(r!==1/0||t.type!=="Group"||t.atomic)return;let a=t.body[0];if(!O(a,{type:"Quantifier"}))return;let i=a.body[0];i.kind==="possessive"||i.min>1||i.max<2||(i.min?i.min===1&&(a.body[0]=i.body):i.max=1)}};var Be={AbsenceFunction({node:e,remove:t}){ee(e)&&t()},Group({node:e,remove:t}){ee(e)&&t()},LookaroundAssertion({node:e,remove:t}){ee(e)&&t()},Quantifier({node:e,remove:t}){let r=e.body;for(;r.type==="Quantifier";)r=r.body;ee(r)&&t()}};function se(e){return e.body.every(t=>!t.body.length)}function ee(e){switch(e.type){case"AbsenceFunction":return e.kind==="repeater"&&se(e);case"Group":return se(e);case"LookaroundAssertion":return!e.negate&&se(e);default:return!1}}var ze={Flags({node:e}){e.extended=!1,e.textSegmentMode==="grapheme"&&(e.textSegmentMode=null)},Directive({node:e,remove:t}){e.kind==="flags"&&(je(e),Ve(e)&&t())},Group({node:e}){e.flags&&(je(e),Ve(e))}};function Ve(e){let{flags:t}=e;return t&&!t.enable&&!t.disable?(delete e.flags,!0):!1}function je({flags:e}){if(!e)throw new Error("Expected flags");e.enable&&delete e.enable.extended,e.disable&&delete e.disable.extended,lr(e)}function lr(e){e.enable&&!Object.keys(e.enable).length&&delete e.enable,e.disable&&!Object.keys(e.disable).length&&delete e.disable}var He={NamedCallout({node:e,replaceWith:t}){let{arguments:r,kind:a}=e;if(a==="fail"){t(ie({negate:!0}));return}if(!r)return;let i=r.filter(o=>o!=="").map(o=>typeof o=="string"&&/^[+-]?\d+$/.test(o)?+o:o);e.arguments=i.length?i:null}};var Qe={CharacterClass({node:e,parent:t,replaceWith:r,replaceWithMultiple:a}){let{body:i,kind:o,negate:n}=e;if(t.type!=="CharacterClass"||o!=="union"||!i.length)return;let s=i[0];if(O(t,{type:"CharacterClass",kind:"union"})){t.negate=t.negate!==n,a(i,{traverse:!0});return}n||(t.kind==="union"?a(i,{traverse:!0}):O(e)&&r(s,{traverse:!0}))}};var We={CharacterClass({node:e,parent:t,replaceWith:r}){let{body:a,kind:i,negate:o}=e;if(!o||i!=="union"||a.length!==1)return;let n=a[0];if(n.type==="CharacterSet")n.negate=!n.negate,r(n);else if(t.type!=="CharacterClass"&&n.type==="Character"&&n.value===10){if(t.type==="Quantifier"&&t.kind!=="lazy")return;r(I("newline",{negate:!0}))}}};var Xe={CharacterClass({node:e,parent:t,replaceWith:r}){let{body:a,kind:i,negate:o}=e,n=a[0];t.type==="CharacterClass"||o||i!=="union"||a.length!==1||n.type!=="Character"&&n.type!=="CharacterSet"||r(n,{traverse:!0})}};var Ze={"*"({node:e}){b(e)&&ur(e)&&(e.body=e.body[0].body[0].body)},Group({node:e,parent:t,replaceWithMultiple:r}){let{atomic:a,body:i,flags:o}=e,n=i[0].body;if(i.length>1||t.type==="Quantifier")return;let s=!1;a?n.every(({type:l})=>Je.has(l))&&(s=!0):o||(s=!0),s&&r(n,{traverse:!0})},Quantifier({node:e}){if(e.body.type!=="Group")return;let t=e.body;if(t.body.length>1)return;let r=t.body[0].body;if(r.length!==1)return;let a=r[0];!E(a)||t.atomic&&!Je.has(a.type)||t.flags||(e.body=a)}},Je=new Set(["Assertion","Backreference","Character","CharacterClass","CharacterSet","Directive","NamedCallout"]);function ur({body:e}){let t=e[0].body;return e.length===1&&t.length===1&&t[0].type==="Group"&&!t[0].atomic&&!t[0].flags&&t[0].body.length>1}var qe={CharacterSet({node:e,parent:t,root:r,replaceWith:a}){let{kind:i,negate:o,value:n}=e,s=null;i==="property"&&(n==="Decimal_Number"||n==="Nd")&&!r.flags.digitIsAscii&&!r.flags.posixIsAscii||i==="posix"&&n==="digit"?s=I("digit",{negate:o}):i==="property"&&(n==="ASCII_Hex_Digit"||n==="AHex")||i==="posix"&&n==="xdigit"?s=I("hex",{negate:o}):i==="property"&&(n==="White_Space"||n==="WSpace")&&!r.flags.spaceIsAscii&&!r.flags.posixIsAscii||i==="posix"&&n==="space"?s=I("space",{negate:o}):t.type!=="CharacterClass"&&i==="property"&&!o&&n==="Any"&&(s=I("any")),s&&a(s)},CharacterClass({node:e,root:t}){if(e.kind!=="union")return;let r={rangeDigit0To9:!1,rangeAToFLower:!1,rangeAToFUpper:!1,unicodeL:!1,unicodeM:!1,unicodeN:!1,unicodePc:!1};for(let a of e.body)a.type==="CharacterClassRange"?(r.rangeDigit0To9||=w(a,k.n0,k.n9),r.rangeAToFLower||=w(a,k.a,k.f),r.rangeAToFUpper||=w(a,k.A,k.F)):a.type==="CharacterSet"&&(r.unicodeL||=B(a,"L"),r.unicodeM||=B(a,"M"),r.unicodeN||=B(a,"N"),r.unicodePc||=B(a,"Pc",{includeSupercategories:!0}));r.rangeDigit0To9&&r.rangeAToFUpper&&r.rangeAToFLower&&(e.body=e.body.filter(a=>!(w(a,k.n0,k.n9)||w(a,k.a,k.f)||w(a,k.A,k.F))),e.body.push(I("hex"))),r.unicodeL&&r.unicodeM&&r.unicodeN&&r.unicodePc&&!t.flags.wordIsAscii&&!t.flags.posixIsAscii&&(e.body=e.body.filter(a=>!B(a,["L","M","N","Pc"],{includeSubcategories:!0})),e.body.push(I("word")))}},k={n0:y("0"),n9:y("9"),A:y("A"),F:y("F"),a:y("a"),f:y("f")};function w(e,t,r){return e.type==="CharacterClassRange"&&e.min.value===t&&e.max.value===r}function B(e,t,r={}){if(e.type!=="CharacterSet"||e.kind!=="property"||e.negate)return!1;let a=Array.isArray(t)?t:[t],i=[];for(let o of a){i.push(o);let n=V[o]?.full,s=Ye[o],l=V[o]?.sub;n&&i.push(n),r.includeSupercategories&&s&&(i.push(s),i.push(V[s].full)),r.includeSubcategories&&l&&i.push(...l)}return i.includes(e.value)}var pr=["Ll","Lm","Lo","Lt","Lu"],cr=["Mc","Me","Mn"],dr=["Nd","Nl","No"],fr=["Pc","Pd","Pe","Pf","Pi","Po","Ps"],V={L:{full:"Letter",sub:pr},M:{full:"Mark",sub:cr},N:{full:"Number",sub:dr},P:{full:"Punctuation",sub:fr}},Ye={};for(let e of Object.keys(V))for(let t of V[e].sub)Ye[t]=e;var et={CharacterSet({node:e}){if(e.kind!=="property")return;let t=hr.get(e.value);t&&(e.value=t)}},hr=new Map([["Other","C"],["Control","Cc"],["Format","Cf"],["Unassigned","Cn"],["Private_Use","Co"],["Surrogate","Cs"],["Letter","L"],["Cased_Letter","LC"],["Lowercase_Letter","Ll"],["Modifier_Letter","Lm"],["Other_Letter","Lo"],["Titlecase_Letter","Lt"],["Uppercase_Letter","Lu"],["Mark","M"],["Combining_Mark","M"],["Spacing_Mark","Mc"],["Enclosing_Mark","Me"],["Nonspacing_Mark","Mn"],["Number","N"],["Decimal_Number","Nd"],["Letter_Number","Nl"],["Other_Number","No"],["Punctuation","P"],["punct","P"],["Connector_Punctuation","Pc"],["Dash_Punctuation","Pd"],["Close_Punctuation","Pe"],["Final_Punctuation","Pf"],["Initial_Punctuation","Pi"],["Other_Punctuation","Po"],["Open_Punctuation","Ps"],["Symbol","S"],["Currency_Symbol","Sc"],["Modifier_Symbol","Sk"],["Math_Symbol","Sm"],["Other_Symbol","So"],["Separator","Z"],["Line_Separator","Zl"],["Paragraph_Separator","Zp"],["Space_Separator","Zs"],["ASCII_Hex_Digit","AHex"],["Bidi_Control","Bidi_C"],["Case_Ignorable","CI"],["Changes_When_Casefolded","CWCF"],["Changes_When_Casemapped","CWCM"],["Changes_When_Lowercased","CWL"],["Changes_When_Titlecased","CWT"],["Changes_When_Uppercased","CWU"],["Default_Ignorable_Code_Point","DI"],["Deprecated","Dep"],["Diacritic","Dia"],["Emoji_Component","EComp"],["Emoji_Modifier","EMod"],["Emoji_Modifier_Base","EBase"],["Emoji_Presentation","EPres"],["Extended_Pictographic","ExtPict"],["Extender","Ext"],["Grapheme_Base","Gr_Base"],["Grapheme_Extend","Gr_Ext"],["Grapheme_Link","Gr_Link"],["Hex_Digit","Hex"],["IDS_Binary_Operator","IDSB"],["IDS_Trinary_Operator","IDST"],["IDS_Unary_Operator","IDSU"],["ID_Continue","IDC"],["ID_Start","IDS"],["Ideographic","Ideo"],["Join_Control","Join_C"],["Logical_Order_Exception","LOE"],["Noncharacter_Code_Point","NChar"],["Other_Alphabetic","OAlpha"],["Other_Default_Ignorable_Code_Point","ODI"],["Other_Grapheme_Extend","OGr_Ext"],["Other_ID_Continue","OIDC"],["Other_ID_Start","OIDS"],["Other_Lowercase","OLower"],["Other_Math","OMath"],["Other_Uppercase","OUpper"],["Pattern_Syntax","Pat_Syn"],["Pattern_White_Space","Pat_WS"],["Prepended_Concatenation_Mark","PCM"],["Quotation_Mark","QMark"],["Regional_Indicator","RI"],["Sentence_Terminal","STerm"],["Soft_Dotted","SD"],["Terminal_Punctuation","Term"],["Unified_Ideograph","UIdeo"],["Variation_Selector","VS"],["White_Space","WSpace"],["XID_Continue","XIDC"],["XID_Start","XIDS"]]);var tt={CharacterSet({node:e,root:t,replaceWith:r}){let{kind:a,negate:i,value:o}=e,n=null;a==="posix"&&o==="cntrl"&&!t.flags.posixIsAscii&&(n=J("Cc",{negate:i})),n&&r(n)},CharacterClassRange({node:e,replaceWith:t}){w(e,0,1114111)&&t(J("Any"))}};var te=new Map([["alternationToClass",Oe],["exposeAnchors",Me],["extractPrefix",Ge],["extractPrefix2",Le],["extractSuffix",Fe],["optionalize",Ke],["preventReDoS",Re],["removeEmptyGroups",Be],["removeUselessFlags",ze],["simplifyCallouts",He],["unnestUselessClasses",Qe],["unwrapNegationWrappers",We],["unwrapUselessClasses",Xe],["unwrapUselessGroups",Ze],["useShorthands",qe],["useUnicodeAliases",et],["useUnicodeProps",tt],["mergeRanges",$e]]);function rt(e,t){let r=_r(t),a=M(e,{flags:r.flags,rules:{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline},skipBackrefValidation:r.rules.allowOrphanBackrefs,unicodePropertyMap:G}),i=Object.assign(le(),r.override);for(let l of te.keys())i[l]||delete i[l];let o=Object.keys(i),n={pattern:e,flags:r.flags},s=0;do{if(++s>200)throw new Error("Optimization exceeded maximum iterations; possible infinite loop");e=n.pattern;for(let l of o)Y(a,te.get(l));n=H(a)}while(e!==n.pattern);return n}function _r(e={}){return{flags:"",override:{},...e,rules:{allowOrphanBackrefs:!1,captureGroup:!1,singleline:!1,...e.rules}}}function le(e={}){let t={};for(let r of te.keys())t[r]=!e.disable;return t}return lt(mr);})();
|
|
904
904
|
//# sourceMappingURL=oniguruma-parser.min.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import{tokenize as q}from"../tokenizer/tokenize.js";import{cpOf as H,getOrInsert as Z,PosixClassNames as x,r as y,throwIfNullish as g}from"../utils.js";import{hasOnlyChild as Y,isAlternativeContainer as j,isQuantifiable as S}from"./node-utils.js";function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r,rules:{captureGroup:!1,singleline:!1,...r.rules}},o=q(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(p,N)=>{const u=o.tokens[t.nextIndex];switch(t.parent=p,t.nextIndex++,u.type){case"Alternator":return b();case"Assertion":return W(u);case"Backreference":return X(u,t);case"Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case"CharacterClassHyphen":return ee(u,t,N);case"CharacterClassOpen":return re(u,t,N);case"CharacterSet":return ne(u,t);case"Directive":return I(u.kind,{flags:u.flags});case"GroupOpen":return te(u,t,N);case"NamedCallout":return U(u.kind,u.tag,u.arguments);case"Quantifier":return oe(u,t);case"Subroutine":return ae(u,t);default:throw new Error(`Unexpected token type "${u.type}"`)}},t={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:o.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},d=B(T(o.flags));let s=d.body[0];for(;t.nextIndex<o.tokens.length;){const p=i(s,{});p.type==="Alternative"?(d.body.push(p),s=p):s.body.push(p)}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=t;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=!0)}else if(c.has(p)){if(c.get(p).length>1)throw new Error(y`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0}else throw new Error(y`Subroutine uses a group name that's not defined "\g<${p}>"`);return d}function W({kind:e}){return F(g({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===y`\B`||e===y`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),o=n?e.slice(3,-1):e.slice(1),i=(t,d=!1)=>{const s=r.capturingGroups.length;let a=!1;if(t>s)if(r.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=!0,k(d?s+1-t:t,{orphan:a})};if(n){const t=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(o);if(t)return i(+t.groups.num,!!t.groups.sign);if(/[-+]/.test(o))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(o))throw new Error(`Group name not defined to the left "${e}"`);return k(o)}return i(+o)}function ee(e,r,n){const{tokens:o,walk:i}=r,t=r.parent,d=t.body.at(-1),s=o[r.nextIndex];if(!n.isCheckingRangeEnd&&d&&d.type!=="CharacterClass"&&d.type!=="CharacterClassRange"&&s&&s.type!=="CharacterClassOpen"&&s.type!=="CharacterClassClose"&&s.type!=="CharacterClassIntersector"){const a=i(t,{...n,isCheckingRangeEnd:!0});if(d.type==="Character"&&a.type==="Character")return t.body.pop(),L(d,a);throw new Error("Invalid character class range")}return m(H("-"))}function re({negate:e},r,n){const{tokens:o,walk:i}=r,t=[C()],d=o[r.nextIndex];let s=z(d);for(;s.type!=="CharacterClassClose";){if(s.type==="CharacterClassIntersector")t.push(C()),r.nextIndex++;else{const l=t.at(-1);l.body.push(i(l,n))}s=z(o[r.nextIndex],d)}const a=C({negate:e});return t.length===1?a.body=t[0].body:(a.kind="intersection",a.body=t.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},o){const{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:t,unicodePropertyMap:d}=o;if(e==="property"){const s=w(n);if(x.has(s)&&!d?.has(s))e="posix",n=s;else return Q(n,{negate:r,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:t,unicodePropertyMap:d})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:o,capturingGroups:i,namedGroupsByName:t,skipLookbehindValidation:d,walk:s}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(i.push(a),a.name&&Z(t,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(o[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else{const N=a.body.at(-1),u=s(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!d){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(o[r.nextIndex])}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},o){const i=o.parent,t=i.body.at(-1);if(!t||!S(t))throw new Error("Quantifier requires a repeatable token");const d=_(e,r,n,t);return i.body.pop(),d}function ae({raw:e},r){const{capturingGroups:n,subroutines:o}=r;let i=e.slice(3,-1);const t=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(t){const s=+t.groups.num,a=n.length;if(r.hasNumberedRef=!0,i={"":s,"+":a+s,"-":a+1-s}[t.groups.sign],i<1)throw new Error("Invalid subroutine number")}else i==="0"&&(i=0);const d=O(i);return o.push(d),d}function G(e,r){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return{type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:!1,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:!1,...r};if(e>1114111){const o=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${o}}"`):new Error(`Invalid code point out of range in JS "\\x{${o}}"`)}return{type:"Character",value:e}}function C(e){const r={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,o={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(o.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(o.variableLength=!0),o}function I(e,r={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:g(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return{type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return{type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!x.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,o){if(r>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:r,max:n,body:o}}function B(e,r){return{type:"Regex",body:h(r?.body),flags:e}}function O(e){return{type:"Subroutine",ref:e}}function Q(e,r){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r};let o=n.unicodePropertyMap?.get(w(e));if(!o){if(n.normalizeUnknownPropertyNames)o=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(y`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:o??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:o,number:i}){switch(r){case"absence_repeater":return G("repeater");case"atomic":return A({atomic:!0});case"capturing":return P(i,{name:n});case"group":return A({flags:e});case"lookahead":case"lookbehind":return K({behind:r==="lookbehind",negate:o});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){const n=r;return g(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function D(e){return g(e,"Unclosed group")}export{G as createAbsenceFunction,b as createAlternative,F as createAssertion,k as createBackreference,P as createCapturingGroup,m as createCharacter,C as createCharacterClass,L as createCharacterClassRange,E as createCharacterSet,I as createDirective,T as createFlags,A as createGroup,K as createLookaroundAssertion,U as createNamedCallout,R as createPosixClass,_ as createQuantifier,B as createRegex,O as createSubroutine,Q as createUnicodeProperty,Y as hasOnlyChild,j as isAlternativeContainer,S as isQuantifiable,J as parse,w as slug};
|
|
1
|
+
"use strict";import{tokenize as q}from"../tokenizer/tokenize.js";import{cpOf as H,getOrInsert as Z,PosixClassNames as x,r as y,throwIfNullish as g}from"../utils.js";import{hasOnlyChild as Y,isAlternativeContainer as j,isQuantifiable as S}from"./node-utils.js";function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r,rules:{captureGroup:!1,singleline:!1,...r.rules}},t=q(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,N)=>{const u=t.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,u.type){case"Alternator":return b();case"Assertion":return W(u);case"Backreference":return X(u,o);case"Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case"CharacterClassHyphen":return ee(u,o,N);case"CharacterClassOpen":return re(u,o,N);case"CharacterSet":return ne(u,o);case"Directive":return I(u.kind,{flags:u.flags});case"GroupOpen":return te(u,o,N);case"NamedCallout":return U(u.kind,u.tag,u.arguments);case"Quantifier":return oe(u,o);case"Subroutine":return ae(u,o);default:throw new Error(`Unexpected token type "${u.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:t.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=B(T(t.flags));let d=i.body[0];for(;o.nextIndex<t.tokens.length;){const p=s(d,{});p.type==="Alternative"?(i.body.push(p),d=p):d.body.push(p)}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=o;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=!0)}else if(c.has(p)){if(c.get(p).length>1)throw new Error(y`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0}else throw new Error(y`Subroutine uses a group name that's not defined "\g<${p}>"`);return i}function W({kind:e}){return F(g({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===y`\B`||e===y`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),t=n?e.slice(3,-1):e.slice(1),s=(o,i=!1)=>{const d=r.capturingGroups.length;let a=!1;if(o>d)if(r.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=!0,k(i?d+1-o:o,{orphan:a})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(t))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(t))throw new Error(`Group name not defined to the left "${e}"`);return k(t)}return s(+t)}function ee(e,r,n){const{tokens:t,walk:s}=r,o=r.parent,i=o.body.at(-1),d=t[r.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const a=s(o,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&a.type==="Character")return o.body.pop(),L(i,a);throw new Error("Invalid character class range")}return m(H("-"))}function re({negate:e},r,n){const{tokens:t,walk:s}=r,o=t[r.nextIndex],i=[C()];let d=z(o);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")i.push(C()),r.nextIndex++;else{const l=i.at(-1);l.body.push(s(l,n))}d=z(t[r.nextIndex],o)}const a=C({negate:e});return i.length===1?a.body=i[0].body:(a.kind="intersection",a.body=i.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},t){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i}=t;if(e==="property"){const d=w(n);if(x.has(d)&&!i?.has(d))e="posix",n=d;else return Q(n,{negate:r,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:t,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:d}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(s.push(a),a.name&&Z(o,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(t[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else{const N=a.body.at(-1),u=d(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!i){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(t[r.nextIndex])}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},t){const s=t.parent,o=s.body.at(-1);if(!o||!S(o))throw new Error("Quantifier requires a repeatable token");const i=_(e,r,n,o);return s.body.pop(),i}function ae({raw:e},r){const{capturingGroups:n,subroutines:t}=r;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const d=+o.groups.num,a=n.length;if(r.hasNumberedRef=!0,s={"":d,"+":a+d,"-":a+1-d}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=O(s);return t.push(i),i}function G(e,r){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return{type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:!1,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:!1,...r};if(e>1114111){const t=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:"Character",value:e}}function C(e){const r={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,t={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(t.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(t.variableLength=!0),t}function I(e,r={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:g(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return{type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return{type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!x.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,t){if(r>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:r,max:n,body:t}}function B(e,r){return{type:"Regex",body:h(r?.body),flags:e}}function O(e){return{type:"Subroutine",ref:e}}function Q(e,r){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r};let t=n.unicodePropertyMap?.get(w(e));if(!t){if(n.normalizeUnknownPropertyNames)t=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(y`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:t??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:t,number:s}){switch(r){case"absence_repeater":return G("repeater");case"atomic":return A({atomic:!0});case"capturing":return P(s,{name:n});case"group":return A({flags:e});case"lookahead":case"lookbehind":return K({behind:r==="lookbehind",negate:t});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){return g(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function D(e){return g(e,"Unclosed group")}export{G as createAbsenceFunction,b as createAlternative,F as createAssertion,k as createBackreference,P as createCapturingGroup,m as createCharacter,C as createCharacterClass,L as createCharacterClassRange,E as createCharacterSet,I as createDirective,T as createFlags,A as createGroup,K as createLookaroundAssertion,U as createNamedCallout,R as createPosixClass,_ as createQuantifier,B as createRegex,O as createSubroutine,Q as createUnicodeProperty,Y as hasOnlyChild,j as isAlternativeContainer,S as isQuantifiable,J as parse,w as slug};
|
|
2
2
|
//# sourceMappingURL=parse.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import{throwIfNullish as A}from"../utils.js";function S(a,v,N=null){function
|
|
1
|
+
"use strict";import{throwIfNullish as A}from"../utils.js";function S(a,v,N=null){function u(e,s){for(let t=0;t<e.length;t++){const r=n(e[t],s,t,e);t=Math.max(-1,t+r)}}function n(e,s=null,t=null,r=null){let i=0,c=!1;const d={node:e,parent:s,key:t,container:r,root:a,remove(){f(r).splice(Math.max(0,l(t)+i),1),i--,c=!0},removeAllNextSiblings(){return f(r).splice(l(t)+1)},removeAllPrevSiblings(){const o=l(t)+i;return i-=o,f(r).splice(0,Math.max(0,o))},replaceWith(o,y={}){const b=!!y.traverse;r?r[Math.max(0,l(t)+i)]=o:A(s,"Can't replace root node")[t]=o,b&&n(o,s,t,r),c=!0},replaceWithMultiple(o,y={}){const b=!!y.traverse;if(f(r).splice(Math.max(0,l(t)+i),1,...o),i+=o.length-1,b){let g=0;for(let x=0;x<o.length;x++)g+=n(o[x],s,l(t)+x+g,r)}c=!0},skip(){c=!0}},{type:m}=e,h=v["*"],p=v[m],R=typeof h=="function"?h:h?.enter,P=typeof p=="function"?p:p?.enter;if(R?.(d,N),P?.(d,N),!c)switch(m){case"AbsenceFunction":case"CapturingGroup":case"Group":u(e.body,e);break;case"Alternative":case"CharacterClass":u(e.body,e);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":n(e.min,e,"min"),n(e.max,e,"max");break;case"LookaroundAssertion":u(e.body,e);break;case"Quantifier":n(e.body,e,"body");break;case"Regex":u(e.body,e),n(e.flags,e,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return p?.exit?.(d,N),h?.exit?.(d,N),i}return n(a),a}function f(a){if(!Array.isArray(a))throw new Error("Container expected");return a}function l(a){if(typeof a!="number")throw new Error("Numeric key expected");return a}export{S as traverse};
|
|
2
2
|
//# sourceMappingURL=traverse.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oniguruma-parser",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Parse, validate, traverse, transform, and optimize Oniguruma regular expressions",
|
|
5
5
|
"author": "Steven Levithan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"parser"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"esbuild": "^0.
|
|
52
|
-
"rimraf": "^6.1
|
|
53
|
-
"typescript": "^
|
|
54
|
-
"vitest": "^
|
|
51
|
+
"esbuild": "^0.25.3",
|
|
52
|
+
"rimraf": "^6.0.1",
|
|
53
|
+
"typescript": "^5.8.3",
|
|
54
|
+
"vitest": "^3.1.2"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -19,7 +19,7 @@ Generates a Regex+ compatible `pattern`, `flags`, and `options` from a Regex+ AS
|
|
|
19
19
|
export function generate(ast: RegexPlusAst, options?: ToRegExpOptions): {
|
|
20
20
|
pattern: string;
|
|
21
21
|
flags: string;
|
|
22
|
-
options:
|
|
22
|
+
options: any;
|
|
23
23
|
_captureTransfers: Map<number, Array<number>>;
|
|
24
24
|
_hiddenCaptures: Array<number>;
|
|
25
25
|
};
|