@austinthesing/magic-shell 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/cli.js +793 -3368
  2. package/dist/index.js +781 -589
  3. package/dist/tui.js +793 -3368
  4. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -15249,11 +15249,11 @@ class FFIRenderLib {
15249
15249
  }
15250
15250
  textBufferViewGetSelection(view) {
15251
15251
  const packedInfo = this.textBufferViewGetSelectionInfo(view);
15252
- if (packedInfo === 0xffff_ffff_ffff_ffffn) {
15252
+ if (packedInfo === 0xffffffffffffffffn) {
15253
15253
  return null;
15254
15254
  }
15255
15255
  const start = Number(packedInfo >> 32n);
15256
- const end = Number(packedInfo & 0xffff_ffffn);
15256
+ const end = Number(packedInfo & 0xffffffffn);
15257
15257
  return { start, end };
15258
15258
  }
15259
15259
  textBufferViewGetSelectionInfo(view) {
@@ -15699,11 +15699,11 @@ class FFIRenderLib {
15699
15699
  }
15700
15700
  editorViewGetSelection(view) {
15701
15701
  const packedInfo = this.opentui.symbols.editorViewGetSelection(view);
15702
- if (packedInfo === 0xffff_ffff_ffff_ffffn) {
15702
+ if (packedInfo === 0xffffffffffffffffn) {
15703
15703
  return null;
15704
15704
  }
15705
15705
  const start = Number(packedInfo >> 32n);
15706
- const end = Number(packedInfo & 0xffff_ffffn);
15706
+ const end = Number(packedInfo & 0xffffffffn);
15707
15707
  return { start, end };
15708
15708
  }
15709
15709
  editorViewSetLocalSelection(view, anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
@@ -27672,725 +27672,8 @@ class TimelineEngine {
27672
27672
  }
27673
27673
  }
27674
27674
  var engine = new TimelineEngine;
27675
- var noop = () => {};
27676
- var DEFAULT_DEBUG_PLUGIN_ERRORS = false;
27677
- var DEFAULT_MAX_PLUGIN_ERRORS = 100;
27678
- function normalizeError(error) {
27679
- if (error instanceof Error) {
27680
- return error;
27681
- }
27682
- if (typeof error === "string") {
27683
- return new Error(error);
27684
- }
27685
- return new Error(`Unknown plugin error: ${String(error)}`);
27686
- }
27687
-
27688
- class SlotRegistry {
27689
- plugins = [];
27690
- sortedPluginsCache = null;
27691
- listeners = new Set;
27692
- errorListeners = new Set;
27693
- pluginErrors = [];
27694
- registrationOrder = 0;
27695
- batchDepth = 0;
27696
- batchedNotify = false;
27697
- rendererInstance;
27698
- hostContext;
27699
- options;
27700
- constructor(renderer, context, options = {}) {
27701
- this.rendererInstance = renderer;
27702
- this.hostContext = context;
27703
- this.options = {
27704
- debugPluginErrors: options.debugPluginErrors ?? DEFAULT_DEBUG_PLUGIN_ERRORS,
27705
- maxPluginErrors: options.maxPluginErrors ?? DEFAULT_MAX_PLUGIN_ERRORS,
27706
- onPluginError: options.onPluginError
27707
- };
27708
- }
27709
- get renderer() {
27710
- return this.rendererInstance;
27711
- }
27712
- get context() {
27713
- return this.hostContext;
27714
- }
27715
- configure(options) {
27716
- if ("debugPluginErrors" in options) {
27717
- this.options.debugPluginErrors = options.debugPluginErrors ?? DEFAULT_DEBUG_PLUGIN_ERRORS;
27718
- }
27719
- if ("maxPluginErrors" in options) {
27720
- this.options.maxPluginErrors = options.maxPluginErrors ?? DEFAULT_MAX_PLUGIN_ERRORS;
27721
- }
27722
- if ("onPluginError" in options) {
27723
- this.options.onPluginError = options.onPluginError;
27724
- }
27725
- }
27726
- register(plugin) {
27727
- if (this.plugins.some((entry) => entry.plugin.id === plugin.id)) {
27728
- throw new Error(`Plugin with id "${plugin.id}" is already registered`);
27729
- }
27730
- try {
27731
- plugin.setup?.(this.hostContext, this.rendererInstance);
27732
- } catch (error) {
27733
- this.reportPluginError({
27734
- pluginId: plugin.id,
27735
- phase: "setup",
27736
- source: "registry",
27737
- error
27738
- });
27739
- return noop;
27740
- }
27741
- this.plugins.push({
27742
- plugin,
27743
- registrationOrder: this.registrationOrder++,
27744
- cachedOrder: plugin.order ?? 0,
27745
- cachedId: plugin.id
27746
- });
27747
- this.invalidateSortedPluginsCache();
27748
- this.notifyListeners();
27749
- return () => {
27750
- this.unregister(plugin.id);
27751
- };
27752
- }
27753
- unregister(id) {
27754
- const index = this.plugins.findIndex((entry2) => entry2.plugin.id === id);
27755
- if (index === -1) {
27756
- return false;
27757
- }
27758
- const [entry] = this.plugins.splice(index, 1);
27759
- this.invalidateSortedPluginsCache();
27760
- try {
27761
- entry?.plugin.dispose?.();
27762
- } catch (error) {
27763
- this.reportPluginError({
27764
- pluginId: id,
27765
- phase: "dispose",
27766
- source: "registry",
27767
- error
27768
- });
27769
- }
27770
- this.notifyListeners();
27771
- return true;
27772
- }
27773
- updateOrder(id, order) {
27774
- const entry = this.plugins.find((pluginEntry) => pluginEntry.plugin.id === id);
27775
- if (!entry) {
27776
- return false;
27777
- }
27778
- if ((entry.plugin.order ?? 0) === order) {
27779
- return true;
27780
- }
27781
- entry.plugin.order = order;
27782
- entry.cachedOrder = order;
27783
- this.invalidateSortedPluginsCache();
27784
- this.notifyListeners();
27785
- return true;
27786
- }
27787
- clear() {
27788
- if (this.plugins.length === 0) {
27789
- return;
27790
- }
27791
- const plugins = [...this.plugins];
27792
- this.plugins = [];
27793
- this.invalidateSortedPluginsCache();
27794
- for (const entry of plugins) {
27795
- try {
27796
- entry.plugin.dispose?.();
27797
- } catch (error) {
27798
- this.reportPluginError({
27799
- pluginId: entry.plugin.id,
27800
- phase: "dispose",
27801
- source: "registry",
27802
- error
27803
- });
27804
- }
27805
- }
27806
- this.notifyListeners();
27807
- }
27808
- subscribe(listener) {
27809
- this.listeners.add(listener);
27810
- return () => {
27811
- this.listeners.delete(listener);
27812
- };
27813
- }
27814
- onPluginError(listener) {
27815
- this.errorListeners.add(listener);
27816
- return () => {
27817
- this.errorListeners.delete(listener);
27818
- };
27819
- }
27820
- batch(run) {
27821
- this.batchDepth += 1;
27822
- try {
27823
- return run();
27824
- } finally {
27825
- this.batchDepth -= 1;
27826
- if (this.batchDepth === 0 && this.batchedNotify) {
27827
- this.batchedNotify = false;
27828
- this.flushListeners();
27829
- }
27830
- }
27831
- }
27832
- getPluginErrors() {
27833
- return this.pluginErrors;
27834
- }
27835
- clearPluginErrors() {
27836
- this.pluginErrors = [];
27837
- }
27838
- reportPluginError(report) {
27839
- const event = {
27840
- pluginId: report.pluginId,
27841
- slot: report.slot,
27842
- phase: report.phase,
27843
- source: report.source ?? "registry",
27844
- error: normalizeError(report.error),
27845
- timestamp: Date.now()
27846
- };
27847
- this.pluginErrors.push(event);
27848
- if (this.pluginErrors.length > this.options.maxPluginErrors) {
27849
- this.pluginErrors.splice(0, this.pluginErrors.length - this.options.maxPluginErrors);
27850
- }
27851
- if (this.options.debugPluginErrors) {
27852
- const slotLabel = event.slot ? ` slot="${event.slot}"` : "";
27853
- console.debug(`[SlotRegistry][PluginError] plugin="${event.pluginId}" phase="${event.phase}" source="${event.source}"${slotLabel}`);
27854
- console.debug(event.error);
27855
- }
27856
- for (const listener of this.errorListeners) {
27857
- try {
27858
- listener(event);
27859
- } catch (error) {
27860
- console.error("Error in plugin error listener:", error);
27861
- }
27862
- }
27863
- try {
27864
- this.options.onPluginError?.(event);
27865
- } catch (error) {
27866
- console.error("Error in plugin error callback:", error);
27867
- }
27868
- return event;
27869
- }
27870
- resolve(slot) {
27871
- return this.resolveEntries(slot).map((entry) => entry.renderer);
27872
- }
27873
- resolveEntries(slot) {
27874
- const slotRenderers = [];
27875
- for (const entry of this.getSortedPlugins()) {
27876
- const renderer = entry.plugin.slots[slot];
27877
- if (renderer) {
27878
- slotRenderers.push({
27879
- id: entry.plugin.id,
27880
- renderer
27881
- });
27882
- }
27883
- }
27884
- return slotRenderers;
27885
- }
27886
- getSortedPlugins() {
27887
- this.syncPluginSortMetadata();
27888
- if (this.sortedPluginsCache) {
27889
- return this.sortedPluginsCache;
27890
- }
27891
- this.sortedPluginsCache = [...this.plugins].sort((left, right) => {
27892
- const leftOrder = left.cachedOrder;
27893
- const rightOrder = right.cachedOrder;
27894
- if (leftOrder !== rightOrder) {
27895
- return leftOrder - rightOrder;
27896
- }
27897
- if (left.registrationOrder !== right.registrationOrder) {
27898
- return left.registrationOrder - right.registrationOrder;
27899
- }
27900
- return left.cachedId.localeCompare(right.cachedId);
27901
- });
27902
- return this.sortedPluginsCache;
27903
- }
27904
- syncPluginSortMetadata() {
27905
- let hasChanges = false;
27906
- for (const entry of this.plugins) {
27907
- const nextOrder = entry.plugin.order ?? 0;
27908
- const nextId = entry.plugin.id;
27909
- if (entry.cachedOrder !== nextOrder || entry.cachedId !== nextId) {
27910
- entry.cachedOrder = nextOrder;
27911
- entry.cachedId = nextId;
27912
- hasChanges = true;
27913
- }
27914
- }
27915
- if (hasChanges) {
27916
- this.invalidateSortedPluginsCache();
27917
- }
27918
- }
27919
- invalidateSortedPluginsCache() {
27920
- this.sortedPluginsCache = null;
27921
- }
27922
- notifyListeners() {
27923
- if (this.batchDepth > 0) {
27924
- this.batchedNotify = true;
27925
- return;
27926
- }
27927
- this.flushListeners();
27928
- }
27929
- flushListeners() {
27930
- for (const listener of this.listeners) {
27931
- try {
27932
- listener();
27933
- } catch (error) {
27934
- console.error("Error in slot registry listener:", error);
27935
- }
27936
- }
27937
- }
27938
- }
27939
27675
  var slotRegistriesByRenderer = new WeakMap;
27940
- function asArray(value) {
27941
- if (!value) {
27942
- return [];
27943
- }
27944
- return Array.isArray(value) ? [...value] : [value];
27945
- }
27946
- function ensureValidNode(node, pluginId, mount) {
27947
- if (!node) {
27948
- throw new Error(`Plugin "${pluginId}" did not return a renderable node`);
27949
- }
27950
- if (typeof node.then === "function") {
27951
- throw new Error(`Plugin "${pluginId}" returned an async value. Core slots require synchronous renderers.`);
27952
- }
27953
- if (!(node instanceof BaseRenderable)) {
27954
- throw new Error(`Plugin "${pluginId}" must return a BaseRenderable`);
27955
- }
27956
- if (node === mount) {
27957
- throw new Error(`Plugin "${pluginId}" returned the slot mount container as its node`);
27958
- }
27959
- if (node.parent && node.parent !== mount) {
27960
- throw new Error(`Plugin "${pluginId}" returned a renderable already attached to another parent`);
27961
- }
27962
- }
27963
- function resolveCoreSlotEntries(registry, slot) {
27964
- return registry.resolveEntries(slot).map((entry) => {
27965
- const wrappedRenderer = entry.renderer;
27966
- return {
27967
- id: entry.id,
27968
- renderer: (ctx, data) => wrappedRenderer(ctx, data),
27969
- ownership: wrappedRenderer.__coreSlotOwnership ?? "host",
27970
- managedSlot: wrappedRenderer.__coreManagedSlot
27971
- };
27972
- });
27973
- }
27974
-
27975
- class SlotRenderable extends Renderable {
27976
- _mode;
27977
- _slotRegistry;
27978
- _slotName;
27979
- _data;
27980
- _fallbackOption;
27981
- _pluginFailurePlaceholder;
27982
- _disposed = false;
27983
- _mountedNodes = [];
27984
- _pluginNodes = new Map;
27985
- _activePluginIds = new Set;
27986
- _fallbackNodes = null;
27987
- _unsubscribe = null;
27988
- constructor(ctx, options) {
27989
- super(ctx, options);
27990
- this._slotRegistry = options.registry;
27991
- this._slotName = options.name;
27992
- this._data = options.data ?? {};
27993
- this._mode = options.mode ?? "append";
27994
- this._fallbackOption = options.fallback;
27995
- this._pluginFailurePlaceholder = options.pluginFailurePlaceholder;
27996
- this._unsubscribe = this._slotRegistry.subscribe(() => this.refresh());
27997
- try {
27998
- this.refresh();
27999
- } catch (error) {
28000
- this._cleanupAll();
28001
- throw error;
28002
- }
28003
- }
28004
- get mode() {
28005
- return this._mode;
28006
- }
28007
- set mode(value) {
28008
- this._mode = value;
28009
- this.refresh();
28010
- }
28011
- get data() {
28012
- return this._data;
28013
- }
28014
- set data(value) {
28015
- this._data = value;
28016
- this.refresh();
28017
- }
28018
- refresh() {
28019
- if (this._disposed) {
28020
- return;
28021
- }
28022
- const allEntries = resolveCoreSlotEntries(this._slotRegistry, this._slotName);
28023
- const activeEntries = this._mode === "single_winner" && allEntries.length > 0 ? [allEntries[0]] : allEntries;
28024
- const nextActivePluginIds = new Set(activeEntries.map((entry) => entry.id));
28025
- const registeredPluginIds = new Set(allEntries.map((entry) => entry.id));
28026
- this._cleanupInactivePluginNodes(nextActivePluginIds, registeredPluginIds);
28027
- for (const entry of activeEntries) {
28028
- let state = this._pluginNodes.get(entry.id);
28029
- const shouldRender = !state || state.ownership === "plugin" && state.nodes.length === 0 || state.dataRef !== this._data;
28030
- if (shouldRender) {
28031
- const previousState = state;
28032
- try {
28033
- const node = entry.renderer(this._slotRegistry.context, this._data);
28034
- ensureValidNode(node, entry.id, this);
28035
- state = {
28036
- nodes: [node],
28037
- ownership: entry.ownership,
28038
- managedSlot: entry.managedSlot ?? state?.managedSlot,
28039
- dataRef: this._data
28040
- };
28041
- } catch (error) {
28042
- const failure = this._slotRegistry.reportPluginError({
28043
- pluginId: entry.id,
28044
- slot: String(this._slotName),
28045
- phase: "render",
28046
- source: "core",
28047
- error
28048
- });
28049
- state = {
28050
- nodes: this._resolvePluginFailurePlaceholder(failure),
28051
- ownership: "host",
28052
- managedSlot: entry.managedSlot ?? state?.managedSlot,
28053
- dataRef: this._data
28054
- };
28055
- }
28056
- if (previousState) {
28057
- this._cleanupReplacedPluginNodes(previousState, state.nodes);
28058
- }
28059
- this._pluginNodes.set(entry.id, state);
28060
- }
28061
- if (!this._activePluginIds.has(entry.id)) {
28062
- const activeState = this._pluginNodes.get(entry.id);
28063
- if (activeState) {
28064
- this._callManagedHook(entry.id, activeState.managedSlot, "onActivate", "setup");
28065
- }
28066
- }
28067
- }
28068
- const desiredNodes = [];
28069
- if (this._mode === "append" || activeEntries.length === 0) {
28070
- desiredNodes.push(...this._ensureFallbackNodes());
28071
- }
28072
- for (const entry of activeEntries) {
28073
- const state = this._pluginNodes.get(entry.id);
28074
- if (state) {
28075
- desiredNodes.push(...state.nodes);
28076
- }
28077
- }
28078
- if (this._mode !== "append" && desiredNodes.length === 0) {
28079
- desiredNodes.push(...this._ensureFallbackNodes());
28080
- }
28081
- this._reconcileMountedNodes(desiredNodes);
28082
- this._activePluginIds = nextActivePluginIds;
28083
- }
28084
- destroySelf() {
28085
- this._cleanupAll();
28086
- }
28087
- _cleanupAll() {
28088
- if (this._disposed) {
28089
- return;
28090
- }
28091
- this._disposed = true;
28092
- this._unsubscribe?.();
28093
- this._unsubscribe = null;
28094
- for (const [pluginId, state] of this._pluginNodes) {
28095
- if (this._activePluginIds.has(pluginId)) {
28096
- this._callManagedHook(pluginId, state.managedSlot, "onDeactivate", "dispose");
28097
- }
28098
- this._callManagedHook(pluginId, state.managedSlot, "onDispose", "dispose");
28099
- for (const node of state.nodes) {
28100
- this._detachNodeFromMount(node);
28101
- }
28102
- if (state.ownership === "host") {
28103
- for (const node of state.nodes) {
28104
- node.destroyRecursively();
28105
- }
28106
- }
28107
- }
28108
- this._pluginNodes.clear();
28109
- this._activePluginIds = new Set;
28110
- if (this._fallbackNodes) {
28111
- for (const node of this._fallbackNodes) {
28112
- node.destroyRecursively();
28113
- }
28114
- this._fallbackNodes = null;
28115
- }
28116
- this._mountedNodes = [];
28117
- }
28118
- _ensureFallbackNodes() {
28119
- if (this._fallbackNodes !== null) {
28120
- return this._fallbackNodes;
28121
- }
28122
- const source = typeof this._fallbackOption === "function" ? this._fallbackOption() : this._fallbackOption;
28123
- const nodes = asArray(source);
28124
- for (const node of nodes) {
28125
- ensureValidNode(node, "fallback", this);
28126
- }
28127
- this._fallbackNodes = nodes;
28128
- return this._fallbackNodes;
28129
- }
28130
- _callManagedHook(pluginId, managedSlot, hook, phase) {
28131
- const callback = managedSlot?.[hook];
28132
- if (!callback) {
28133
- return;
28134
- }
28135
- try {
28136
- callback(this._slotRegistry.context);
28137
- } catch (error) {
28138
- this._slotRegistry.reportPluginError({
28139
- pluginId,
28140
- slot: String(this._slotName),
28141
- phase,
28142
- source: "core",
28143
- error
28144
- });
28145
- }
28146
- }
28147
- _detachNodeFromMount(node) {
28148
- if (node.parent === this) {
28149
- this.remove(node);
28150
- }
28151
- }
28152
- _cleanupInactivePluginNodes(nextActivePluginIds, registeredPluginIds) {
28153
- for (const [pluginId, state] of this._pluginNodes) {
28154
- if (nextActivePluginIds.has(pluginId)) {
28155
- continue;
28156
- }
28157
- if (this._activePluginIds.has(pluginId)) {
28158
- this._callManagedHook(pluginId, state.managedSlot, "onDeactivate", "dispose");
28159
- }
28160
- for (const node of state.nodes) {
28161
- this._detachNodeFromMount(node);
28162
- }
28163
- if (!registeredPluginIds.has(pluginId)) {
28164
- this._callManagedHook(pluginId, state.managedSlot, "onDispose", "dispose");
28165
- if (state.ownership === "host") {
28166
- for (const node of state.nodes) {
28167
- node.destroyRecursively();
28168
- }
28169
- }
28170
- this._pluginNodes.delete(pluginId);
28171
- continue;
28172
- }
28173
- if (state.ownership === "host") {
28174
- for (const node of state.nodes) {
28175
- node.destroyRecursively();
28176
- }
28177
- this._pluginNodes.delete(pluginId);
28178
- continue;
28179
- }
28180
- state.nodes = [];
28181
- }
28182
- }
28183
- _cleanupReplacedPluginNodes(previousState, nextNodes) {
28184
- const retainedNodes = new Set(nextNodes);
28185
- for (const node of previousState.nodes) {
28186
- if (retainedNodes.has(node)) {
28187
- continue;
28188
- }
28189
- this._detachNodeFromMount(node);
28190
- if (previousState.ownership === "host") {
28191
- node.destroyRecursively();
28192
- }
28193
- }
28194
- }
28195
- _resolvePluginFailurePlaceholder(failure) {
28196
- if (!this._pluginFailurePlaceholder) {
28197
- return [];
28198
- }
28199
- try {
28200
- const placeholderSource = this._pluginFailurePlaceholder(failure, this._slotRegistry.context);
28201
- const placeholderNodes = asArray(placeholderSource);
28202
- for (const node of placeholderNodes) {
28203
- ensureValidNode(node, `${failure.pluginId}:error-placeholder`, this);
28204
- }
28205
- return placeholderNodes;
28206
- } catch (placeholderError) {
28207
- this._slotRegistry.reportPluginError({
28208
- pluginId: failure.pluginId,
28209
- slot: String(this._slotName),
28210
- phase: "error_placeholder",
28211
- source: "core",
28212
- error: placeholderError
28213
- });
28214
- return [];
28215
- }
28216
- }
28217
- _reconcileMountedNodes(desiredNodes) {
28218
- const desiredNodeSet = new Set(desiredNodes);
28219
- for (const node of this._mountedNodes) {
28220
- if (!desiredNodeSet.has(node)) {
28221
- if (node.parent === this) {
28222
- this.remove(node);
28223
- }
28224
- }
28225
- }
28226
- for (let index = 0;index < desiredNodes.length; index++) {
28227
- const node = desiredNodes[index];
28228
- if (node.parent !== this) {
28229
- this.add(node, index);
28230
- continue;
28231
- }
28232
- const childAtIndex = this.getChildren()[index];
28233
- if (childAtIndex !== node) {
28234
- this.add(node, index);
28235
- }
28236
- }
28237
- this._mountedNodes = [...desiredNodes];
28238
- }
28239
- }
28240
- function parseIcyMetadata(bytes, decoder2) {
28241
- const decoded = decoder2.decode(bytes);
28242
- const nul = decoded.indexOf("\x00");
28243
- const text = nul === -1 ? decoded : decoded.slice(0, nul);
28244
- if (text.length === 0)
28245
- return null;
28246
- const fields = Object.create(null);
28247
- let found = false;
28248
- let offset = 0;
28249
- while (offset < text.length) {
28250
- const separator = text.indexOf("='", offset);
28251
- if (separator === -1)
28252
- break;
28253
- const key = text.slice(offset, separator);
28254
- if (key.length === 0 || /[';=]/.test(key))
28255
- break;
28256
- const end = text.indexOf("';", separator + 2);
28257
- if (end === -1)
28258
- break;
28259
- Object.defineProperty(fields, key, {
28260
- configurable: true,
28261
- enumerable: true,
28262
- writable: true,
28263
- value: text.slice(separator + 2, end)
28264
- });
28265
- found = true;
28266
- offset = end + 2;
28267
- }
28268
- return found ? Object.freeze(fields) : null;
28269
- }
28270
27676
  var EMPTY_FIELDS = Object.freeze(Object.create(null));
28271
- function copyHeaders(headers) {
28272
- const copy = Object.create(null);
28273
- for (const [name, value] of Object.entries(headers ?? {}))
28274
- copy[name.toLowerCase()] = value;
28275
- return Object.freeze(copy);
28276
- }
28277
- function fieldsEqual(left, right) {
28278
- const keys = Object.keys(left);
28279
- return keys.length === Object.keys(right).length && keys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);
28280
- }
28281
-
28282
- class IcyStreamDemuxer {
28283
- initialMetadata;
28284
- audioRemaining;
28285
- metadata = null;
28286
- metadataOffset = 0;
28287
- fields = EMPTY_FIELDS;
28288
- interval;
28289
- decoder;
28290
- headers;
28291
- constructor(options) {
28292
- if (!Number.isSafeInteger(options.metadataInterval) || options.metadataInterval < 0) {
28293
- throw new TypeError("metadataInterval must be a non-negative safe integer");
28294
- }
28295
- this.interval = options.metadataInterval;
28296
- try {
28297
- this.decoder = new TextDecoder(options.metadataEncoding ?? "iso-8859-1");
28298
- } catch {
28299
- throw new TypeError(`Unsupported metadataEncoding: ${options.metadataEncoding}`);
28300
- }
28301
- this.headers = copyHeaders(options.headers);
28302
- this.audioRemaining = this.interval;
28303
- this.initialMetadata = Object.freeze({ format: "icy", headers: this.headers, fields: this.fields });
28304
- }
28305
- *push(chunk) {
28306
- if (this.interval === 0) {
28307
- if (chunk.byteLength > 0)
28308
- yield { type: "audio", data: chunk };
28309
- return;
28310
- }
28311
- let offset = 0;
28312
- while (offset < chunk.byteLength) {
28313
- if (this.audioRemaining > 0) {
28314
- const length2 = Math.min(this.audioRemaining, chunk.byteLength - offset);
28315
- yield { type: "audio", data: chunk.subarray(offset, offset + length2) };
28316
- offset += length2;
28317
- this.audioRemaining -= length2;
28318
- continue;
28319
- }
28320
- if (this.metadata == null) {
28321
- const metadataLength = (chunk[offset] ?? 0) * 16;
28322
- offset += 1;
28323
- if (metadataLength === 0) {
28324
- this.audioRemaining = this.interval;
28325
- continue;
28326
- }
28327
- this.metadata = new Uint8Array(metadataLength);
28328
- this.metadataOffset = 0;
28329
- }
28330
- const metadata = this.metadata;
28331
- const length = Math.min(metadata.byteLength - this.metadataOffset, chunk.byteLength - offset);
28332
- metadata.set(chunk.subarray(offset, offset + length), this.metadataOffset);
28333
- offset += length;
28334
- this.metadataOffset += length;
28335
- if (this.metadataOffset !== metadata.byteLength)
28336
- continue;
28337
- const fields = parseIcyMetadata(metadata, this.decoder);
28338
- this.metadata = null;
28339
- this.metadataOffset = 0;
28340
- this.audioRemaining = this.interval;
28341
- if (fields != null && !fieldsEqual(this.fields, fields)) {
28342
- this.fields = fields;
28343
- yield {
28344
- type: "metadata",
28345
- metadata: Object.freeze({ format: "icy", headers: this.headers, fields })
28346
- };
28347
- }
28348
- }
28349
- }
28350
- *flush() {
28351
- if (this.interval === 0)
28352
- return;
28353
- if (this.audioRemaining === 0 || this.metadata != null) {
28354
- throw new Error("ICY stream ended inside a metadata block");
28355
- }
28356
- }
28357
- }
28358
- function createIcyStreamDemuxer(options) {
28359
- return new IcyStreamDemuxer(options);
28360
- }
28361
- function selectAudioStreamDemuxer(options) {
28362
- const icyHeaders = Object.create(null);
28363
- options.headers.forEach((value2, name) => {
28364
- if (name.toLowerCase().startsWith("icy-"))
28365
- icyHeaders[name.toLowerCase()] = value2;
28366
- });
28367
- const headers = Object.freeze(icyHeaders);
28368
- const rawInterval = options.headers.get("icy-metaint");
28369
- if (rawInterval == null) {
28370
- return Object.keys(headers).length === 0 ? null : createIcyStreamDemuxer({ metadataInterval: 0, metadataEncoding: options.metadataEncoding, headers });
28371
- }
28372
- const value = rawInterval.trim();
28373
- if (!/^\d+$/.test(value))
28374
- throw new Error(`Invalid icy-metaint response header: ${rawInterval}`);
28375
- const interval = Number(value);
28376
- if (!Number.isSafeInteger(interval))
28377
- throw new Error(`Invalid icy-metaint response header: ${rawInterval}`);
28378
- return createIcyStreamDemuxer({ metadataInterval: interval, metadataEncoding: options.metadataEncoding, headers });
28379
- }
28380
-
28381
- class AudioInitializationError extends Error {
28382
- action;
28383
- status;
28384
- constructor(action, message, status, cause) {
28385
- super(message);
28386
- this.name = "AudioInitializationError";
28387
- this.action = action;
28388
- this.status = status;
28389
- if (cause !== undefined)
28390
- this.cause = cause;
28391
- }
28392
- }
28393
-
28394
27677
  class AudioCaptureStreamError extends Error {
28395
27678
  context;
28396
27679
  constructor(message, context, cause) {
@@ -28412,18 +27695,10 @@ class AudioRecorderError extends Error {
28412
27695
  this.cause = cause;
28413
27696
  }
28414
27697
  }
28415
- function statusToError(action, status) {
28416
- return new Error(`Audio ${action} failed: ${status}`);
28417
- }
28418
- function toBytes(data) {
28419
- return data instanceof Uint8Array ? data : new Uint8Array(data);
28420
- }
28421
- var DEFAULT_AUDIO_SAMPLE_RATE = 48000;
28422
27698
  var DEFAULT_STREAM_PROBE_BYTES = 1024 * 1024;
28423
27699
  var STREAM_POLL_INTERVAL_MS = 5;
28424
27700
  var MAX_TIMER_DELAY_MS = 2147483647;
28425
27701
  var MAX_U32 = 4294967295;
28426
- var DEFAULT_CAPTURE_CHUNK_FRAMES = 2048;
28427
27702
  var CAPTURE_DISCARD_BATCH_CHUNKS = 32;
28428
27703
  var WAV_HEADER_BYTES = 44;
28429
27704
  var MAX_WAV_DATA_BYTES = BigInt(MAX_U32 - 36);
@@ -28462,32 +27737,6 @@ function resolvePositiveU32(value, fallback, name) {
28462
27737
  throw new RangeError(`${name} exceeds the supported limit`);
28463
27738
  return resolved;
28464
27739
  }
28465
- function resolveAudioCaptureStreamOptions(options, sampleRate) {
28466
- const channels = resolvePositiveU32(options.channels, 1, "channels");
28467
- const capacityFrames = resolvePositiveU32(options.capacityFrames, sampleRate, "capacityFrames");
28468
- const chunkFrames = resolvePositiveU32(options.chunkFrames, DEFAULT_CAPTURE_CHUNK_FRAMES, "chunkFrames");
28469
- if (chunkFrames > capacityFrames)
28470
- throw new RangeError("chunkFrames must not exceed capacityFrames");
28471
- if (chunkFrames > Math.floor(MAX_U32 / channels)) {
28472
- throw new RangeError("chunkFrames * channels exceeds the supported limit");
28473
- }
28474
- return {
28475
- sampleRate,
28476
- channels,
28477
- capacityFrames,
28478
- chunkFrames,
28479
- startOptions: options.startOptions,
28480
- signal: options.signal
28481
- };
28482
- }
28483
- function resolveU32Index(value, name) {
28484
- if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0) {
28485
- throw new TypeError(`${name} must be a finite non-negative integer`);
28486
- }
28487
- if (value > MAX_U32)
28488
- throw new RangeError(`${name} exceeds the supported limit`);
28489
- return value;
28490
- }
28491
27740
  function resolveReconnectOptions(options) {
28492
27741
  const maxRetries = options.maxRetries ?? Number.POSITIVE_INFINITY;
28493
27742
  const initialDelayMs = options.initialDelayMs ?? 1000;
@@ -28545,12 +27794,6 @@ function resolveAudioStreamOptions(options) {
28545
27794
  reconnect: options.reconnect === undefined ? undefined : resolveReconnectOptions(options.reconnect)
28546
27795
  };
28547
27796
  }
28548
- function resolveAudioStreamConnector(connector) {
28549
- const connect = connector?.connect;
28550
- if (typeof connect !== "function")
28551
- throw new TypeError("Audio stream connector must define connect()");
28552
- return { connect: (context) => connect.call(connector, context) };
28553
- }
28554
27797
  function runBoundedCleanup(cleanup, timeoutMs = 50) {
28555
27798
  let result;
28556
27799
  try {
@@ -28597,17 +27840,6 @@ function waitForDelay(delayMs, signal) {
28597
27840
  function waitForPoll(signal) {
28598
27841
  return waitForDelay(STREAM_POLL_INTERVAL_MS, signal).then(() => true).catch(() => false);
28599
27842
  }
28600
- function parseRetryAfter(value, maxDelayMs) {
28601
- if (value == null)
28602
- return;
28603
- const seconds = Number(value.trim());
28604
- if (Number.isFinite(seconds) && seconds >= 0)
28605
- return Math.min(maxDelayMs, Math.ceil(seconds * 1000));
28606
- const date = Date.parse(value);
28607
- if (!Number.isFinite(date))
28608
- return;
28609
- return Math.min(maxDelayMs, Math.max(0, date - Date.now()));
28610
- }
28611
27843
  function resolveAudioStreamFormat(value) {
28612
27844
  const format = value ?? "mp3";
28613
27845
  if (format !== "mp3" && format !== "flac")
@@ -28622,87 +27854,6 @@ function toNativeAudioStreamFormat(format) {
28622
27854
  return NativeAudioStreamFormat.Flac;
28623
27855
  }
28624
27856
  }
28625
- function resolveContentTypePolicy(value, receiver) {
28626
- const policy = value ?? "validate";
28627
- if (policy !== "validate" && policy !== "ignore" && typeof policy !== "function") {
28628
- throw new TypeError("contentTypePolicy must be 'validate', 'ignore', or a function");
28629
- }
28630
- return typeof policy === "function" ? (context) => policy.call(receiver, context) : policy;
28631
- }
28632
- function isAllowedContentType(format, value) {
28633
- const contentType = value.split(";", 1)[0]?.trim().toLowerCase();
28634
- switch (format) {
28635
- case "mp3":
28636
- return ["audio/mpeg", "audio/mp3", "application/octet-stream", "application/mp3"].includes(contentType ?? "");
28637
- case "flac":
28638
- return ["audio/flac", "audio/x-flac", "application/octet-stream"].includes(contentType ?? "");
28639
- }
28640
- }
28641
- function createAudioStreamUrlConnector(source, request, format, contentTypePolicy) {
28642
- return {
28643
- async connect({ signal, attempt }) {
28644
- let response;
28645
- try {
28646
- const headers = new Headers(request?.headers);
28647
- if (!headers.has("icy-metadata"))
28648
- headers.set("Icy-MetaData", "1");
28649
- response = await globalThis.fetch(source, { ...request, headers, signal });
28650
- } catch (cause) {
28651
- throw new ClassifiedAudioStreamError("Audio stream fetch failed", { action: "fetch", attempt }, true, undefined, cause);
28652
- }
28653
- if (!response.ok) {
28654
- const retryAfterMs = parseRetryAfter(response.headers.get("retry-after"), Number.POSITIVE_INFINITY);
28655
- await runBoundedCleanup(() => response.body?.cancel());
28656
- const retryable = [408, 425, 429].includes(response.status) || response.status >= 500 && response.status <= 599;
28657
- throw new ClassifiedAudioStreamError(`Audio stream request failed with HTTP ${response.status}`, { action: "response", status: response.status, attempt }, retryable, retryAfterMs);
28658
- }
28659
- const contentType = response.headers.get("content-type");
28660
- let contentTypeAccepted = contentType == null || contentTypePolicy === "ignore";
28661
- if (!contentTypeAccepted && contentTypePolicy === "validate") {
28662
- contentTypeAccepted = isAllowedContentType(format, contentType);
28663
- } else if (typeof contentTypePolicy === "function") {
28664
- try {
28665
- const result = contentTypePolicy(Object.freeze({
28666
- format,
28667
- contentType,
28668
- status: response.status,
28669
- url: response.url || String(source)
28670
- }));
28671
- if (typeof result !== "boolean")
28672
- throw new TypeError("contentTypePolicy must return a boolean");
28673
- contentTypeAccepted = result;
28674
- } catch (cause) {
28675
- await runBoundedCleanup(() => response.body?.cancel());
28676
- throw new ClassifiedAudioStreamError(cause instanceof Error ? cause.message : "Audio stream content type policy failed", { action: "response", status: response.status, attempt }, false, undefined, cause);
28677
- }
28678
- }
28679
- if (!contentTypeAccepted) {
28680
- await runBoundedCleanup(() => response.body?.cancel());
28681
- throw new ClassifiedAudioStreamError(`Unsupported audio stream Content-Type: ${contentType}`, { action: "response", status: response.status, attempt }, false);
28682
- }
28683
- if (response.body == null) {
28684
- throw new ClassifiedAudioStreamError("Audio stream response has no body", { action: "response", status: response.status, attempt }, true);
28685
- }
28686
- return {
28687
- body: response.body,
28688
- info: { headers: response.headers, status: response.status }
28689
- };
28690
- }
28691
- };
28692
- }
28693
- function resolveMetadataEncoding(value) {
28694
- try {
28695
- return new TextDecoder(value ?? "iso-8859-1").encoding;
28696
- } catch {
28697
- throw new TypeError(`Unsupported metadataEncoding: ${value}`);
28698
- }
28699
- }
28700
- function resolveAudioStreamRequest(request) {
28701
- if (request === undefined)
28702
- return;
28703
- const { body: _body, signal: _signal, ...safeRequest } = request;
28704
- return safeRequest;
28705
- }
28706
27857
  function isReadableStreamSource(source) {
28707
27858
  try {
28708
27859
  return typeof source?.getReader === "function";
@@ -30480,827 +29631,6 @@ class AudioRecorder extends EventEmitter7 {
30480
29631
  }, 0);
30481
29632
  }
30482
29633
  }
30483
-
30484
- class Audio extends EventEmitter7 {
30485
- static create(options = {}) {
30486
- let lib2;
30487
- try {
30488
- lib2 = resolveRenderLib();
30489
- } catch (cause) {
30490
- throw new AudioInitializationError("resolveRenderLib", "Failed to resolve the native audio library", undefined, cause);
30491
- }
30492
- return new Audio(lib2, options);
30493
- }
30494
- sampleRate;
30495
- lib;
30496
- defaultStartOptions;
30497
- engine = null;
30498
- groups = new Map;
30499
- streams = new Set;
30500
- playbackStarted = false;
30501
- mixerStarted = false;
30502
- captureStarted = false;
30503
- captureDeviceOpen = false;
30504
- captureBufferAvailable = false;
30505
- captureChannels = 1;
30506
- captureCapacityFrames = 0;
30507
- captureOwner = null;
30508
- captureStream = null;
30509
- disposing = false;
30510
- constructor(lib2, options) {
30511
- super();
30512
- this.lib = lib2;
30513
- this.defaultStartOptions = options.startOptions;
30514
- const normalizedSampleRate = options.sampleRate == null || !Number.isFinite(options.sampleRate) ? 0 : Math.min(MAX_U32, Math.max(0, Math.trunc(options.sampleRate)));
30515
- this.sampleRate = normalizedSampleRate || DEFAULT_AUDIO_SAMPLE_RATE;
30516
- const createOptions = options.sampleRate == null && options.playbackChannels == null ? undefined : {
30517
- sampleRate: options.sampleRate == null ? undefined : normalizedSampleRate,
30518
- playbackChannels: options.playbackChannels == null ? undefined : Math.max(0, Math.trunc(options.playbackChannels))
30519
- };
30520
- this.engine = this.lib.createAudioEngine(createOptions);
30521
- if (!this.engine) {
30522
- throw new AudioInitializationError("createAudioEngine", "Audio createAudioEngine returned null");
30523
- }
30524
- if (options.autoStart ?? false) {
30525
- const status = this.lib.audioStart(this.engine, this.defaultStartOptions);
30526
- if (status !== 0) {
30527
- this.throwAfterInitializationCleanup(new AudioInitializationError("start", `Audio auto-start failed: ${status}`, status));
30528
- }
30529
- this.playbackStarted = true;
30530
- this.mixerStarted = true;
30531
- }
30532
- }
30533
- throwAfterInitializationCleanup(error) {
30534
- const engine2 = this.engine;
30535
- this.engine = null;
30536
- if (engine2)
30537
- this.lib.destroyAudioEngine(engine2);
30538
- throw error;
30539
- }
30540
- emitError(action, status, message, cause) {
30541
- const error = message ? new Error(message) : statusToError(action, status ?? -1);
30542
- if (cause)
30543
- error.cause = cause;
30544
- this.emit("error", error, { action, status });
30545
- }
30546
- start(options) {
30547
- if (this.playbackStarted)
30548
- return true;
30549
- const engine2 = this.engine;
30550
- if (!engine2) {
30551
- this.emitError("start", undefined, "Audio engine unavailable during start");
30552
- return false;
30553
- }
30554
- const startOptions = options ?? this.defaultStartOptions;
30555
- const status = this.lib.audioStart(engine2, startOptions);
30556
- if (status !== 0) {
30557
- this.emitError("start", status);
30558
- return false;
30559
- }
30560
- this.playbackStarted = true;
30561
- this.mixerStarted = true;
30562
- this.emit("started");
30563
- return true;
30564
- }
30565
- startMixer() {
30566
- if (this.mixerStarted)
30567
- return true;
30568
- const engine2 = this.engine;
30569
- if (!engine2) {
30570
- this.emitError("startMixer", undefined, "Audio engine unavailable during startMixer");
30571
- return false;
30572
- }
30573
- const status = this.lib.audioStartMixer(engine2);
30574
- if (status !== 0) {
30575
- this.emitError("startMixer", status);
30576
- return false;
30577
- }
30578
- this.mixerStarted = true;
30579
- this.emit("mixerStarted");
30580
- return true;
30581
- }
30582
- stop() {
30583
- if (!this.mixerStarted)
30584
- return true;
30585
- const engine2 = this.engine;
30586
- if (!engine2) {
30587
- this.emitError("stop", undefined, "Audio engine unavailable during stop");
30588
- return false;
30589
- }
30590
- const status = this.lib.audioStop(engine2);
30591
- if (status !== 0) {
30592
- this.emitError("stop", status);
30593
- return false;
30594
- }
30595
- this.playbackStarted = false;
30596
- this.mixerStarted = false;
30597
- this.emit("stopped");
30598
- return true;
30599
- }
30600
- isStarted() {
30601
- return this.playbackStarted;
30602
- }
30603
- isMixerStarted() {
30604
- return this.mixerStarted;
30605
- }
30606
- loadSound(data) {
30607
- const engine2 = this.engine;
30608
- if (!engine2) {
30609
- this.emitError("loadSound", undefined, "Audio engine unavailable during loadSound");
30610
- return null;
30611
- }
30612
- const result = this.lib.audioLoad(engine2, toBytes(data));
30613
- if (result.status !== 0 || result.soundId == null) {
30614
- this.emitError("loadSound", result.status);
30615
- return null;
30616
- }
30617
- return result.soundId;
30618
- }
30619
- async loadSoundFile(filePath) {
30620
- const bytes = await readFile(filePath).catch((err) => {
30621
- this.emitError("loadSoundFile", undefined, `Failed to read file '${filePath}': ${err.message}`, err);
30622
- return null;
30623
- });
30624
- if (bytes == null)
30625
- return null;
30626
- return this.loadSound(bytes);
30627
- }
30628
- unloadSound(sound) {
30629
- const engine2 = this.engine;
30630
- if (!engine2) {
30631
- this.emitError("unloadSound", undefined, "Audio engine unavailable during unloadSound");
30632
- return false;
30633
- }
30634
- const status = this.lib.audioUnload(engine2, sound);
30635
- if (status !== 0) {
30636
- this.emitError("unloadSound", status);
30637
- return false;
30638
- }
30639
- return true;
30640
- }
30641
- group(name) {
30642
- const existing = this.groups.get(name);
30643
- if (existing != null) {
30644
- return existing;
30645
- }
30646
- const engine2 = this.engine;
30647
- if (!engine2) {
30648
- this.emitError("group", undefined, "Audio engine unavailable during group");
30649
- return null;
30650
- }
30651
- const result = this.lib.audioCreateGroup(engine2, name);
30652
- if (result.status !== 0 || result.groupId == null) {
30653
- this.emitError("group", result.status);
30654
- return null;
30655
- }
30656
- this.groups.set(name, result.groupId);
30657
- return result.groupId;
30658
- }
30659
- play(sound, options) {
30660
- const rawOptions = options ? {
30661
- volume: options.volume,
30662
- pan: options.pan,
30663
- loop: options.loop,
30664
- groupId: options.groupId ?? 0
30665
- } : undefined;
30666
- const engine2 = this.engine;
30667
- if (!engine2) {
30668
- this.emitError("play", undefined, "Audio engine unavailable during play");
30669
- return null;
30670
- }
30671
- const result = this.lib.audioPlay(engine2, sound, rawOptions);
30672
- if (result.status !== 0 || result.voiceId == null) {
30673
- this.emitError("play", result.status);
30674
- return null;
30675
- }
30676
- return result.voiceId;
30677
- }
30678
- async playStream(source, options = {}) {
30679
- const urlOptions = options;
30680
- if (urlOptions.request !== undefined || urlOptions.reconnect !== undefined || urlOptions.metadataEncoding !== undefined || urlOptions.contentTypePolicy !== undefined) {
30681
- return Promise.reject(new TypeError("request, reconnect, metadataEncoding, and contentTypePolicy options are only supported by playStreamUrl()"));
30682
- }
30683
- if (!isReadableStreamSource(source) && !isAsyncIterableSource(source)) {
30684
- return Promise.reject(new TypeError("Audio stream source must be a ReadableStream or AsyncIterable"));
30685
- }
30686
- const { demuxer, ...streamOptions } = options;
30687
- const connector = {
30688
- async connect() {
30689
- return { body: source, info: undefined };
30690
- }
30691
- };
30692
- return this.openStream(connector, demuxer == null ? undefined : () => demuxer(), streamOptions, "source");
30693
- }
30694
- async playStreamUrl(source, options = {}) {
30695
- if (options.demuxer !== undefined) {
30696
- throw new TypeError("demuxer is only supported by playStream() and playStreamSource()");
30697
- }
30698
- if (typeof source !== "string" && Object.prototype.toString.call(source) !== "[object URL]") {
30699
- return Promise.reject(new TypeError("Audio stream URL source must be a string or URL"));
30700
- }
30701
- const { request, metadataEncoding, reconnect, format, contentTypePolicy, ...streamOptions } = options;
30702
- const resolvedFormat = resolveAudioStreamFormat(format);
30703
- const resolvedContentTypePolicy = resolveContentTypePolicy(contentTypePolicy, options);
30704
- const encoding = resolveMetadataEncoding(metadataEncoding);
30705
- const connector = createAudioStreamUrlConnector(source, resolveAudioStreamRequest(request), resolvedFormat, resolvedContentTypePolicy);
30706
- return this.openStream(connector, (info) => {
30707
- try {
30708
- return selectAudioStreamDemuxer({ headers: info.headers, metadataEncoding: encoding });
30709
- } catch (cause) {
30710
- throw new AudioStreamError(cause instanceof Error ? cause.message : "Invalid audio stream metadata response", { action: "response", status: info.status }, cause);
30711
- }
30712
- }, { ...streamOptions, reconnect, format: resolvedFormat }, "fetch");
30713
- }
30714
- async playStreamSource(connector, options = {}) {
30715
- const urlOptions = options;
30716
- if (urlOptions.request !== undefined || urlOptions.metadataEncoding !== undefined || urlOptions.contentTypePolicy !== undefined) {
30717
- return Promise.reject(new TypeError("request, metadataEncoding, and contentTypePolicy are only supported by playStreamUrl()"));
30718
- }
30719
- const { demuxer, ...streamOptions } = options;
30720
- return this.openStream(connector, demuxer, streamOptions, "source");
30721
- }
30722
- async openStream(connector, demuxer, options, readAction) {
30723
- const engine2 = this.engine;
30724
- if (!engine2)
30725
- throw new Error("Audio engine unavailable during stream playback");
30726
- const resolvedConnector = resolveAudioStreamConnector(connector);
30727
- let stream;
30728
- stream = createAudioStream({
30729
- lib: this.lib,
30730
- engine: engine2,
30731
- connector: resolvedConnector,
30732
- demuxer,
30733
- options,
30734
- readAction,
30735
- removeFromOwner: () => this.streams.delete(stream)
30736
- });
30737
- this.streams.add(stream);
30738
- try {
30739
- await openAudioStream(stream);
30740
- return stream;
30741
- } catch (error) {
30742
- stream.dispose();
30743
- throw error;
30744
- }
30745
- }
30746
- stopVoice(voice) {
30747
- const engine2 = this.engine;
30748
- if (!engine2) {
30749
- this.emitError("stopVoice", undefined, "Audio engine unavailable during stopVoice");
30750
- return false;
30751
- }
30752
- const status = this.lib.audioStopVoice(engine2, voice);
30753
- if (status !== 0) {
30754
- this.emitError("stopVoice", status);
30755
- return false;
30756
- }
30757
- return true;
30758
- }
30759
- setVoiceGroup(voice, group) {
30760
- const engine2 = this.engine;
30761
- if (!engine2) {
30762
- this.emitError("setVoiceGroup", undefined, "Audio engine unavailable during setVoiceGroup");
30763
- return false;
30764
- }
30765
- const status = this.lib.audioSetVoiceGroup(engine2, voice, group);
30766
- if (status !== 0) {
30767
- this.emitError("setVoiceGroup", status);
30768
- return false;
30769
- }
30770
- return true;
30771
- }
30772
- setGroupVolume(group, volume) {
30773
- const engine2 = this.engine;
30774
- if (!engine2) {
30775
- this.emitError("setGroupVolume", undefined, "Audio engine unavailable during setGroupVolume");
30776
- return false;
30777
- }
30778
- const status = this.lib.audioSetGroupVolume(engine2, group, volume);
30779
- if (status !== 0) {
30780
- this.emitError("setGroupVolume", status);
30781
- return false;
30782
- }
30783
- return true;
30784
- }
30785
- setMasterVolume(volume) {
30786
- const engine2 = this.engine;
30787
- if (!engine2) {
30788
- this.emitError("setMasterVolume", undefined, "Audio engine unavailable during setMasterVolume");
30789
- return false;
30790
- }
30791
- const status = this.lib.audioSetMasterVolume(engine2, volume);
30792
- if (status !== 0) {
30793
- this.emitError("setMasterVolume", status);
30794
- return false;
30795
- }
30796
- return true;
30797
- }
30798
- mixFrames(frameCount, channels = 2) {
30799
- const engine2 = this.engine;
30800
- if (!engine2) {
30801
- this.emitError("mixFrames", undefined, "Audio engine unavailable during mixFrames");
30802
- return null;
30803
- }
30804
- const output = new Float32Array(frameCount * channels);
30805
- const status = this.lib.audioMixToBuffer(engine2, output, frameCount, channels);
30806
- if (status !== 0) {
30807
- this.emitError("mixFrames", status);
30808
- return null;
30809
- }
30810
- return output;
30811
- }
30812
- enableTap(capacityFrames = 8192) {
30813
- const engine2 = this.engine;
30814
- if (!engine2) {
30815
- this.emitError("enableTap", undefined, "Audio engine unavailable during enableTap");
30816
- return false;
30817
- }
30818
- const status = this.lib.audioEnableTap(engine2, true, capacityFrames);
30819
- if (status !== 0) {
30820
- this.emitError("enableTap", status);
30821
- return false;
30822
- }
30823
- return true;
30824
- }
30825
- disableTap() {
30826
- const engine2 = this.engine;
30827
- if (!engine2) {
30828
- this.emitError("enableTap", undefined, "Audio engine unavailable during disableTap");
30829
- return false;
30830
- }
30831
- const status = this.lib.audioEnableTap(engine2, false, 0);
30832
- if (status !== 0) {
30833
- this.emitError("enableTap", status);
30834
- return false;
30835
- }
30836
- return true;
30837
- }
30838
- readTapFrames(frameCount, channels = 2) {
30839
- const engine2 = this.engine;
30840
- if (!engine2) {
30841
- this.emitError("readTapFrames", undefined, "Audio engine unavailable during readTapFrames");
30842
- return null;
30843
- }
30844
- const output = new Float32Array(frameCount * channels);
30845
- const result = this.lib.audioReadTap(engine2, output, frameCount, channels);
30846
- if (result.status !== 0) {
30847
- this.emitError("readTapFrames", result.status);
30848
- return null;
30849
- }
30850
- return { frames: output, framesRead: result.framesRead };
30851
- }
30852
- listPlaybackDevices() {
30853
- const engine2 = this.engine;
30854
- if (!engine2) {
30855
- this.emitError("listPlaybackDevices", undefined, "Audio engine unavailable during listPlaybackDevices");
30856
- return null;
30857
- }
30858
- const refreshStatus = this.lib.audioRefreshPlaybackDevices(engine2);
30859
- if (refreshStatus !== 0) {
30860
- this.emitError("listPlaybackDevices", refreshStatus);
30861
- return null;
30862
- }
30863
- const count = this.lib.audioGetPlaybackDeviceCount(engine2);
30864
- const devices = [];
30865
- for (let index = 0;index < count; index += 1) {
30866
- devices.push({
30867
- index,
30868
- name: this.lib.audioGetPlaybackDeviceName(engine2, index),
30869
- isDefault: this.lib.audioIsPlaybackDeviceDefault(engine2, index)
30870
- });
30871
- }
30872
- return devices;
30873
- }
30874
- selectPlaybackDevice(index) {
30875
- const engine2 = this.engine;
30876
- if (!engine2) {
30877
- this.emitError("selectPlaybackDevice", undefined, "Audio engine unavailable during selectPlaybackDevice");
30878
- return false;
30879
- }
30880
- const refreshStatus = this.lib.audioRefreshPlaybackDevices(engine2);
30881
- if (refreshStatus !== 0) {
30882
- this.emitError("selectPlaybackDevice", refreshStatus);
30883
- return false;
30884
- }
30885
- const status = this.lib.audioSelectPlaybackDevice(engine2, index);
30886
- if (status !== 0) {
30887
- this.emitError("selectPlaybackDevice", status);
30888
- return false;
30889
- }
30890
- return true;
30891
- }
30892
- clearPlaybackDeviceSelection() {
30893
- const engine2 = this.engine;
30894
- if (!engine2) {
30895
- this.emitError("clearPlaybackDeviceSelection", undefined, "Audio engine unavailable during clearPlaybackDeviceSelection");
30896
- return;
30897
- }
30898
- this.lib.audioClearPlaybackDeviceSelection(engine2);
30899
- }
30900
- async openCapture(options = {}) {
30901
- const resolved = resolveAudioCaptureStreamOptions(options, this.sampleRate);
30902
- if (resolved.signal?.aborted)
30903
- throw createAbortError();
30904
- if (!this.engine) {
30905
- throw new AudioCaptureStreamError("Audio engine unavailable during capture stream start", { action: "start" });
30906
- }
30907
- if (this.captureOwner != null || this.isCapturing()) {
30908
- throw new AudioCaptureStreamError("Audio capture ring is already in use", { action: "start" });
30909
- }
30910
- const owner = {};
30911
- this.captureOwner = owner;
30912
- let stream = null;
30913
- try {
30914
- stream = createAudioCaptureStream({
30915
- options: resolved,
30916
- start: () => this.startCaptureInternal(resolved, owner),
30917
- read: (frameCount) => this.readCaptureInternal(frameCount, owner),
30918
- stats: () => this.getCaptureStatsInternal(owner),
30919
- stop: () => this.stopCaptureInternal(owner),
30920
- isRunning: () => this.isCapturingInternal(owner),
30921
- removeFromOwner: () => {
30922
- if (this.captureOwner === owner)
30923
- this.captureOwner = null;
30924
- if (this.captureStream === stream)
30925
- this.captureStream = null;
30926
- if (stream != null)
30927
- this.streams.delete(stream);
30928
- }
30929
- });
30930
- this.captureStream = stream;
30931
- this.streams.add(stream);
30932
- await openAudioCaptureStream(stream);
30933
- return stream;
30934
- } catch (error) {
30935
- if (stream == null) {
30936
- if (this.captureOwner === owner)
30937
- this.captureOwner = null;
30938
- } else {
30939
- stream.dispose();
30940
- if (this.captureOwner !== owner)
30941
- this.streams.delete(stream);
30942
- }
30943
- throw error;
30944
- }
30945
- }
30946
- async recordToFile(filePath, options = {}) {
30947
- if (typeof filePath !== "string" || filePath.length === 0)
30948
- throw new TypeError("filePath must be a nonempty string");
30949
- if (filePath.includes("\x00"))
30950
- throw new TypeError("filePath must not contain NUL bytes");
30951
- const resolved = resolveAudioCaptureStreamOptions(options, this.sampleRate);
30952
- if (resolved.channels !== 1 && resolved.channels !== 2) {
30953
- throw new RangeError("WAV recording supports only 1 or 2 channels");
30954
- }
30955
- if (this.sampleRate * resolved.channels * 2 > MAX_U32) {
30956
- throw new RangeError("WAV byte rate exceeds the supported limit");
30957
- }
30958
- if (resolved.signal?.aborted)
30959
- throw createAbortError();
30960
- if (!this.engine)
30961
- throw new AudioRecorderError("Audio engine unavailable during recorder open", { action: "open" });
30962
- let recorder;
30963
- recorder = createAudioRecorder({
30964
- filePath,
30965
- signal: resolved.signal,
30966
- captureOptions: resolved,
30967
- openCapture: (captureOptions) => this.openCapture(captureOptions),
30968
- removeFromOwner: () => this.streams.delete(recorder)
30969
- });
30970
- this.streams.add(recorder);
30971
- try {
30972
- await openAudioRecorder(recorder);
30973
- return recorder;
30974
- } catch (error) {
30975
- throw error;
30976
- }
30977
- }
30978
- listCaptureDevices() {
30979
- const engine2 = this.engine;
30980
- if (!engine2) {
30981
- this.emitError("listCaptureDevices", undefined, "Audio engine unavailable during listCaptureDevices");
30982
- return null;
30983
- }
30984
- const refreshStatus = this.lib.audioRefreshCaptureDevices(engine2);
30985
- if (refreshStatus !== 0) {
30986
- this.emitError("listCaptureDevices", refreshStatus);
30987
- return null;
30988
- }
30989
- const count = this.lib.audioGetCaptureDeviceCount(engine2);
30990
- const devices = [];
30991
- for (let index = 0;index < count; index += 1) {
30992
- devices.push({
30993
- index,
30994
- name: this.lib.audioGetCaptureDeviceName(engine2, index),
30995
- isDefault: this.lib.audioIsCaptureDeviceDefault(engine2, index)
30996
- });
30997
- }
30998
- return devices;
30999
- }
31000
- selectCaptureDevice(index) {
31001
- const resolvedIndex = resolveU32Index(index, "index");
31002
- if (this.captureOwner != null) {
31003
- this.emitCaptureOwnershipError("selectCaptureDevice");
31004
- return false;
31005
- }
31006
- const engine2 = this.engine;
31007
- if (!engine2) {
31008
- this.emitError("selectCaptureDevice", undefined, "Audio engine unavailable during selectCaptureDevice");
31009
- return false;
31010
- }
31011
- const status = this.lib.audioSelectCaptureDevice(engine2, resolvedIndex);
31012
- if (status !== 0) {
31013
- this.emitError("selectCaptureDevice", status);
31014
- return false;
31015
- }
31016
- return true;
31017
- }
31018
- clearCaptureDeviceSelection() {
31019
- if (this.captureOwner != null) {
31020
- this.emitCaptureOwnershipError("clearCaptureDeviceSelection");
31021
- return;
31022
- }
31023
- const engine2 = this.engine;
31024
- if (!engine2) {
31025
- this.emitError("clearCaptureDeviceSelection", undefined, "Audio engine unavailable during clearCaptureDeviceSelection");
31026
- return;
31027
- }
31028
- this.lib.audioClearCaptureDeviceSelection(engine2);
31029
- }
31030
- startCapture(options = {}) {
31031
- if (this.disposing)
31032
- return false;
31033
- const channels = resolvePositiveU32(options.channels, 1, "channels");
31034
- const capacityFrames = resolvePositiveU32(options.capacityFrames, this.sampleRate, "capacityFrames");
31035
- if (this.captureOwner != null) {
31036
- this.emitCaptureOwnershipError("startCapture");
31037
- return false;
31038
- }
31039
- if (this.isCapturing()) {
31040
- const configurationMatches = (options.channels === undefined || channels === this.captureChannels) && (options.capacityFrames === undefined || capacityFrames === this.captureCapacityFrames) && options.startOptions === undefined;
31041
- if (configurationMatches)
31042
- return true;
31043
- this.emitError("startCapture", undefined, "Audio capture is already running with a different configuration");
31044
- return false;
31045
- }
31046
- const engine2 = this.engine;
31047
- if (!engine2) {
31048
- this.emitError("startCapture", undefined, "Audio engine unavailable during startCapture");
31049
- return false;
31050
- }
31051
- const result = this.startCaptureInternal({ sampleRate: this.sampleRate, channels, capacityFrames, chunkFrames: 1, startOptions: options.startOptions }, null);
31052
- if (result.status !== 0) {
31053
- this.emitError("startCapture", result.status, undefined, result.cause);
31054
- return false;
31055
- }
31056
- return true;
31057
- }
31058
- isCapturing() {
31059
- return this.isCapturingInternal(null);
31060
- }
31061
- isCapturingInternal(_owner) {
31062
- if (!this.captureStarted)
31063
- return false;
31064
- const engine2 = this.engine;
31065
- if (engine2 && this.lib.audioIsCaptureRunning(engine2))
31066
- return true;
31067
- this.captureStarted = false;
31068
- this.emit("captureStopped");
31069
- return this.captureStarted;
31070
- }
31071
- readCaptureFrames(frameCount) {
31072
- const resolvedFrameCount = resolvePositiveU32(frameCount, frameCount, "frameCount");
31073
- if (this.captureOwner != null) {
31074
- this.emitCaptureOwnershipError("readCaptureFrames");
31075
- return null;
31076
- }
31077
- if (!this.captureBufferAvailable) {
31078
- this.emitError("readCaptureFrames", -4);
31079
- return null;
31080
- }
31081
- if (resolvedFrameCount > this.captureCapacityFrames) {
31082
- throw new RangeError("frameCount exceeds the capture buffer capacity");
31083
- }
31084
- if (resolvedFrameCount > Math.floor(MAX_U32 / this.captureChannels)) {
31085
- throw new RangeError("frameCount * channels exceeds the supported limit");
31086
- }
31087
- const engine2 = this.engine;
31088
- if (!engine2) {
31089
- this.emitError("readCaptureFrames", undefined, "Audio engine unavailable during readCaptureFrames");
31090
- return null;
31091
- }
31092
- const result = this.readCaptureInternal(resolvedFrameCount, null);
31093
- if (result.status !== 0) {
31094
- this.emitError("readCaptureFrames", result.status, undefined, result.cause);
31095
- return null;
31096
- }
31097
- return { frames: result.frames, framesRead: result.framesRead };
31098
- }
31099
- getCaptureStats() {
31100
- const engine2 = this.engine;
31101
- if (!engine2) {
31102
- this.emitError("getCaptureStats", undefined, "Audio engine unavailable during getCaptureStats");
31103
- return null;
31104
- }
31105
- const result = this.getCaptureStatsInternal(null);
31106
- if (result.status !== 0 || result.stats == null) {
31107
- this.emitError("getCaptureStats", result.status, undefined, result.cause);
31108
- return null;
31109
- }
31110
- return result.stats;
31111
- }
31112
- stopCapture() {
31113
- if (this.captureOwner != null) {
31114
- this.emitCaptureOwnershipError("stopCapture");
31115
- return false;
31116
- }
31117
- if (!this.captureDeviceOpen)
31118
- return true;
31119
- const engine2 = this.engine;
31120
- if (!engine2) {
31121
- this.emitError("stopCapture", undefined, "Audio engine unavailable during stopCapture");
31122
- return false;
31123
- }
31124
- const result = this.stopCaptureInternal(null);
31125
- if (result.status !== 0) {
31126
- this.emitError("stopCapture", result.status, undefined, result.cause);
31127
- return false;
31128
- }
31129
- return true;
31130
- }
31131
- emitCaptureOwnershipError(action) {
31132
- this.emitError(action, undefined, `Audio ${action} failed: capture is owned by a stream`);
31133
- }
31134
- startCaptureInternal(options, owner) {
31135
- if (this.captureOwner != null && this.captureOwner !== owner)
31136
- return { status: -1 };
31137
- const engine2 = this.engine;
31138
- if (!engine2)
31139
- return { status: -1 };
31140
- let status;
31141
- try {
31142
- status = this.lib.audioStartCapture(engine2, options.startOptions, options.channels, options.capacityFrames);
31143
- } catch (cause) {
31144
- return { status: -1, cause };
31145
- }
31146
- if (status !== 0)
31147
- return { status };
31148
- this.captureChannels = options.channels;
31149
- this.captureCapacityFrames = options.capacityFrames;
31150
- this.captureBufferAvailable = true;
31151
- this.captureDeviceOpen = true;
31152
- this.captureStarted = true;
31153
- this.emit("captureStarted");
31154
- return { status: 0 };
31155
- }
31156
- readCaptureInternal(frameCount, owner) {
31157
- const output = new Float32Array(frameCount * this.captureChannels);
31158
- if (this.captureOwner != null && this.captureOwner !== owner)
31159
- return { status: -1, frames: output, framesRead: 0 };
31160
- const engine2 = this.engine;
31161
- if (!engine2 || !this.captureBufferAvailable)
31162
- return { status: -4, frames: output, framesRead: 0 };
31163
- try {
31164
- const result = this.lib.audioReadCapture(engine2, output, frameCount);
31165
- return { status: result.status, frames: output, framesRead: Math.min(frameCount, result.framesRead) };
31166
- } catch (cause) {
31167
- return { status: -1, frames: output, framesRead: 0, cause };
31168
- }
31169
- }
31170
- getCaptureStatsInternal(_owner) {
31171
- const engine2 = this.engine;
31172
- if (!engine2)
31173
- return { status: -1, stats: null };
31174
- try {
31175
- const result = this.lib.audioGetCaptureStats(engine2);
31176
- if (result.status !== 0 || result.stats == null)
31177
- return { status: result.status, stats: null };
31178
- return {
31179
- status: 0,
31180
- stats: {
31181
- sampleRate: result.stats.sampleRate,
31182
- channels: result.stats.channels,
31183
- capacityFrames: result.stats.capacityFrames,
31184
- bufferedFrames: result.stats.bufferedFrames,
31185
- framesReceived: result.stats.framesReceived,
31186
- framesRead: result.stats.framesRead,
31187
- framesDropped: result.stats.framesDropped
31188
- }
31189
- };
31190
- } catch (cause) {
31191
- return { status: -1, stats: null, cause };
31192
- }
31193
- }
31194
- stopCaptureInternal(owner) {
31195
- if (this.captureOwner != null && this.captureOwner !== owner)
31196
- return { status: -1 };
31197
- if (!this.captureDeviceOpen)
31198
- return { status: 0 };
31199
- const engine2 = this.engine;
31200
- if (!engine2)
31201
- return { status: -1 };
31202
- let status;
31203
- try {
31204
- status = this.lib.audioStopCapture(engine2);
31205
- } catch (cause) {
31206
- return { status: -1, cause };
31207
- }
31208
- if (status !== 0)
31209
- return { status };
31210
- const wasStarted = this.captureStarted;
31211
- this.captureDeviceOpen = false;
31212
- this.captureStarted = false;
31213
- if (wasStarted)
31214
- this.emit("captureStopped");
31215
- return { status: 0 };
31216
- }
31217
- getStats() {
31218
- const engine2 = this.engine;
31219
- if (!engine2) {
31220
- this.emitError("getStats", undefined, "Audio engine unavailable during getStats");
31221
- return null;
31222
- }
31223
- const stats = this.lib.audioGetStats(engine2);
31224
- if (stats == null) {
31225
- this.emitError("getStats", undefined, "Failed to retrieve audio stats");
31226
- }
31227
- return stats;
31228
- }
31229
- dispose() {
31230
- if (!this.engine || this.disposing)
31231
- return;
31232
- this.disposing = true;
31233
- let firstError;
31234
- let hasError = false;
31235
- let childCleanupFailed = false;
31236
- const runCleanup = (operation) => {
31237
- try {
31238
- operation();
31239
- } catch (error) {
31240
- if (!hasError) {
31241
- firstError = error;
31242
- hasError = true;
31243
- }
31244
- }
31245
- };
31246
- try {
31247
- for (const stream of [...this.streams]) {
31248
- try {
31249
- stream.dispose();
31250
- } catch (error) {
31251
- childCleanupFailed = true;
31252
- if (!hasError) {
31253
- firstError = error;
31254
- hasError = true;
31255
- }
31256
- }
31257
- }
31258
- if (this.captureDeviceOpen) {
31259
- let result;
31260
- runCleanup(() => {
31261
- result = this.stopCaptureInternal(this.captureOwner);
31262
- });
31263
- if (result && result.status !== 0) {
31264
- const wasStarted = this.captureStarted;
31265
- this.captureDeviceOpen = false;
31266
- this.captureStarted = false;
31267
- runCleanup(() => this.emitError("stopCapture", result.status, undefined, result.cause));
31268
- if (wasStarted)
31269
- runCleanup(() => void this.emit("captureStopped"));
31270
- }
31271
- }
31272
- if (this.captureStream != null) {
31273
- runCleanup(() => refreshAudioCaptureStreamFinalStats(this.captureStream));
31274
- }
31275
- if (this.mixerStarted) {
31276
- runCleanup(() => void this.stop());
31277
- }
31278
- this.groups.clear();
31279
- const engine2 = this.engine;
31280
- let engineDestroyed = false;
31281
- if (!childCleanupFailed) {
31282
- runCleanup(() => {
31283
- this.lib.destroyAudioEngine(engine2);
31284
- engineDestroyed = true;
31285
- });
31286
- }
31287
- if (engineDestroyed) {
31288
- this.engine = null;
31289
- this.captureStarted = false;
31290
- this.captureDeviceOpen = false;
31291
- this.captureBufferAvailable = false;
31292
- this.captureCapacityFrames = 0;
31293
- this.captureOwner = null;
31294
- this.captureStream = null;
31295
- runCleanup(() => void this.emit("disposed"));
31296
- }
31297
- } finally {
31298
- this.disposing = false;
31299
- }
31300
- if (hasError)
31301
- throw firstError;
31302
- }
31303
- }
31304
29634
  var MAX_ENCODED_BYTES = 64 * 1024 * 1024;
31305
29635
  var defaultTextareaKeyBindings = [
31306
29636
  { name: "left", action: "move-left" },
@@ -33055,1103 +31385,6 @@ var Gt = d.walkTokens;
33055
31385
  var Nt = d.parseInline;
33056
31386
  var Ft = b.parse;
33057
31387
  var jt = x.lex;
33058
- function comparePriority(leftGrowth, leftCapacity, rightGrowth, rightCapacity) {
33059
- const left = leftGrowth * leftGrowth * rightCapacity;
33060
- const right = rightGrowth * rightGrowth * leftCapacity;
33061
- if (Number.isSafeInteger(left) && Number.isSafeInteger(right)) {
33062
- return left < right ? -1 : left > right ? 1 : 0;
33063
- }
33064
- const exactLeft = BigInt(leftGrowth) * BigInt(leftGrowth) * BigInt(rightCapacity);
33065
- const exactRight = BigInt(rightGrowth) * BigInt(rightGrowth) * BigInt(leftCapacity);
33066
- return exactLeft < exactRight ? -1 : exactLeft > exactRight ? 1 : 0;
33067
- }
33068
- function allocateProportionalColumnWidths(widths, targetWidth, minWidth) {
33069
- const baseWidths = widths.map((width) => Math.max(minWidth, Math.floor(width)));
33070
- const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
33071
- const capacity = baseWidths.map((width) => width - minWidth);
33072
- const growth = new Array(baseWidths.length).fill(0);
33073
- const available = Math.min(Math.max(0, targetWidth - minWidth * baseWidths.length), totalBaseWidth - minWidth * baseWidths.length);
33074
- if (available === 0)
33075
- return growth.map(() => minWidth);
33076
- if (available === capacity.reduce((sum, width) => sum + width, 0))
33077
- return baseWidths;
33078
- const weights = capacity.map(Math.sqrt);
33079
- const active = capacity.map((width, idx) => ({ idx, width, weight: weights[idx] })).filter((column) => column.width > 0).sort((a, b2) => a.weight - b2.weight);
33080
- if (active.length === capacity.length && capacity.every((width) => width === capacity[0])) {
33081
- const sharedGrowth = Math.floor(available / capacity.length);
33082
- const remainder = available % capacity.length;
33083
- return growth.map((_2, idx) => minWidth + sharedGrowth + (idx < remainder ? 1 : 0));
33084
- }
33085
- let remaining = available;
33086
- let totalWeight = active.reduce((sum, column) => sum + column.weight, 0);
33087
- for (const column of active) {
33088
- if (remaining / totalWeight <= column.weight)
33089
- break;
33090
- growth[column.idx] = column.width;
33091
- remaining -= column.width;
33092
- totalWeight -= column.weight;
33093
- }
33094
- const level = remaining / totalWeight;
33095
- for (const column of active) {
33096
- if (growth[column.idx] === column.width)
33097
- continue;
33098
- growth[column.idx] = Math.min(column.width, Math.floor(level * column.weight));
33099
- }
33100
- let allocatedGrowth = growth.reduce((sum, width) => sum + width, 0);
33101
- while (allocatedGrowth > available) {
33102
- let worstIdx = -1;
33103
- for (let idx = 0;idx < baseWidths.length; idx++) {
33104
- if (growth[idx] === 0)
33105
- continue;
33106
- const comparison = worstIdx === -1 ? 1 : comparePriority(growth[idx], capacity[idx], growth[worstIdx], capacity[worstIdx]);
33107
- if (comparison > 0 || comparison === 0 && idx > worstIdx) {
33108
- worstIdx = idx;
33109
- }
33110
- }
33111
- if (worstIdx === -1)
33112
- break;
33113
- growth[worstIdx] -= 1;
33114
- allocatedGrowth -= 1;
33115
- }
33116
- while (allocatedGrowth < available) {
33117
- let bestIdx = -1;
33118
- for (let idx = 0;idx < baseWidths.length; idx++) {
33119
- if (growth[idx] >= capacity[idx])
33120
- continue;
33121
- const comparison = bestIdx === -1 ? -1 : comparePriority(growth[idx] + 1, capacity[idx], growth[bestIdx] + 1, capacity[bestIdx]);
33122
- if (comparison < 0) {
33123
- bestIdx = idx;
33124
- }
33125
- }
33126
- if (bestIdx === -1)
33127
- break;
33128
- growth[bestIdx] += 1;
33129
- allocatedGrowth += 1;
33130
- }
33131
- return growth.map((width) => width + minWidth);
33132
- }
33133
- var MEASURE_HEIGHT = 1e4;
33134
-
33135
- class TextTableRenderable extends Renderable {
33136
- _content;
33137
- _wrapMode;
33138
- _columnWidthMode;
33139
- _columnFitter;
33140
- _cellPaddingX;
33141
- _cellPaddingY;
33142
- _columnGap;
33143
- _showBorders;
33144
- _border;
33145
- _outerBorder;
33146
- _hasExplicitOuterBorder;
33147
- _borderStyle;
33148
- _borderColor;
33149
- _borderBackgroundColor;
33150
- _backgroundColor;
33151
- _defaultFg;
33152
- _defaultBg;
33153
- _defaultAttributes;
33154
- _selectionBg;
33155
- _selectionFg;
33156
- _lastLocalSelection = null;
33157
- _lastSelectionMode = null;
33158
- _cells = [];
33159
- _prevCellContent = [];
33160
- _rowCount = 0;
33161
- _columnCount = 0;
33162
- _layout = this.createEmptyLayout();
33163
- _layoutDirty = true;
33164
- _rasterDirty = true;
33165
- _cachedMeasureLayout = null;
33166
- _cachedMeasureWidth = undefined;
33167
- _defaultOptions = {
33168
- content: [],
33169
- wrapMode: "word",
33170
- columnWidthMode: "full",
33171
- columnFitter: "proportional",
33172
- cellPadding: 0,
33173
- cellPaddingX: undefined,
33174
- cellPaddingY: undefined,
33175
- columnGap: 0,
33176
- showBorders: true,
33177
- border: true,
33178
- outerBorder: true,
33179
- selectable: true,
33180
- selectionBg: undefined,
33181
- selectionFg: undefined,
33182
- borderStyle: "single",
33183
- borderColor: "#FFFFFF",
33184
- borderBackgroundColor: "transparent",
33185
- backgroundColor: "transparent",
33186
- fg: "#FFFFFF",
33187
- bg: "transparent",
33188
- attributes: 0
33189
- };
33190
- constructor(ctx, options = {}) {
33191
- super(ctx, { ...options, flexShrink: options.flexShrink ?? 0, buffered: true });
33192
- this._content = options.content ?? this._defaultOptions.content;
33193
- this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
33194
- this._columnWidthMode = options.columnWidthMode ?? this._defaultOptions.columnWidthMode;
33195
- this._columnFitter = this.resolveColumnFitter(options.columnFitter);
33196
- this._cellPaddingX = this.resolveCellPadding(options.cellPaddingX ?? options.cellPadding);
33197
- this._cellPaddingY = this.resolveCellPadding(options.cellPaddingY ?? options.cellPadding);
33198
- this._columnGap = this.resolveColumnGap(options.columnGap);
33199
- this._showBorders = options.showBorders ?? this._defaultOptions.showBorders;
33200
- this._border = options.border ?? this._defaultOptions.border;
33201
- this._hasExplicitOuterBorder = options.outerBorder !== undefined;
33202
- this._outerBorder = options.outerBorder ?? this._border;
33203
- this.selectable = options.selectable ?? this._defaultOptions.selectable;
33204
- this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : undefined;
33205
- this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : undefined;
33206
- this._borderStyle = parseBorderStyle(options.borderStyle, this._defaultOptions.borderStyle);
33207
- this._borderColor = parseColor(options.borderColor ?? this._defaultOptions.borderColor);
33208
- this._borderBackgroundColor = parseColor(options.borderBackgroundColor ?? this._defaultOptions.borderBackgroundColor);
33209
- this._backgroundColor = parseColor(options.backgroundColor ?? this._defaultOptions.backgroundColor);
33210
- this._defaultFg = parseColor(options.fg ?? this._defaultOptions.fg);
33211
- this._defaultBg = parseColor(options.bg ?? this._defaultOptions.bg);
33212
- this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
33213
- this.setupMeasureFunc();
33214
- this.rebuildCells();
33215
- }
33216
- get content() {
33217
- return this._content;
33218
- }
33219
- set content(value) {
33220
- this._content = value ?? [];
33221
- this.rebuildCells();
33222
- }
33223
- get wrapMode() {
33224
- return this._wrapMode;
33225
- }
33226
- set wrapMode(value) {
33227
- if (this._wrapMode === value)
33228
- return;
33229
- this._wrapMode = value;
33230
- for (const row of this._cells) {
33231
- for (const cell of row) {
33232
- cell.textBufferView.setWrapMode(value);
33233
- }
33234
- }
33235
- this.invalidateLayoutAndRaster();
33236
- }
33237
- get columnWidthMode() {
33238
- return this._columnWidthMode;
33239
- }
33240
- set columnWidthMode(value) {
33241
- if (this._columnWidthMode === value)
33242
- return;
33243
- this._columnWidthMode = value;
33244
- this.invalidateLayoutAndRaster();
33245
- }
33246
- get columnFitter() {
33247
- return this._columnFitter;
33248
- }
33249
- set columnFitter(value) {
33250
- const next = this.resolveColumnFitter(value);
33251
- if (this._columnFitter === next)
33252
- return;
33253
- this._columnFitter = next;
33254
- this.invalidateLayoutAndRaster();
33255
- }
33256
- get cellPadding() {
33257
- return this._cellPaddingX === this._cellPaddingY ? this._cellPaddingX : 0;
33258
- }
33259
- set cellPadding(value) {
33260
- const next = this.resolveCellPadding(value);
33261
- if (this._cellPaddingX === next && this._cellPaddingY === next)
33262
- return;
33263
- this._cellPaddingX = next;
33264
- this._cellPaddingY = next;
33265
- this.invalidateLayoutAndRaster();
33266
- }
33267
- get cellPaddingX() {
33268
- return this._cellPaddingX;
33269
- }
33270
- set cellPaddingX(value) {
33271
- const next = this.resolveCellPadding(value);
33272
- if (this._cellPaddingX === next)
33273
- return;
33274
- this._cellPaddingX = next;
33275
- this.invalidateLayoutAndRaster();
33276
- }
33277
- get cellPaddingY() {
33278
- return this._cellPaddingY;
33279
- }
33280
- set cellPaddingY(value) {
33281
- const next = this.resolveCellPadding(value);
33282
- if (this._cellPaddingY === next)
33283
- return;
33284
- this._cellPaddingY = next;
33285
- this.invalidateLayoutAndRaster();
33286
- }
33287
- get columnGap() {
33288
- return this._columnGap;
33289
- }
33290
- set columnGap(value) {
33291
- const next = this.resolveColumnGap(value);
33292
- if (this._columnGap === next)
33293
- return;
33294
- this._columnGap = next;
33295
- this.invalidateLayoutAndRaster();
33296
- }
33297
- get showBorders() {
33298
- return this._showBorders;
33299
- }
33300
- set showBorders(value) {
33301
- if (this._showBorders === value)
33302
- return;
33303
- this._showBorders = value;
33304
- this.invalidateRasterOnly();
33305
- }
33306
- get outerBorder() {
33307
- return this._outerBorder;
33308
- }
33309
- set outerBorder(value) {
33310
- if (this._outerBorder === value)
33311
- return;
33312
- this._hasExplicitOuterBorder = true;
33313
- this._outerBorder = value;
33314
- this.invalidateLayoutAndRaster();
33315
- }
33316
- get border() {
33317
- return this._border;
33318
- }
33319
- set border(value) {
33320
- if (this._border === value)
33321
- return;
33322
- this._border = value;
33323
- if (!this._hasExplicitOuterBorder) {
33324
- this._outerBorder = value;
33325
- }
33326
- this.invalidateLayoutAndRaster();
33327
- }
33328
- get borderStyle() {
33329
- return this._borderStyle;
33330
- }
33331
- set borderStyle(value) {
33332
- const next = parseBorderStyle(value, this._defaultOptions.borderStyle);
33333
- if (this._borderStyle === next)
33334
- return;
33335
- this._borderStyle = next;
33336
- this.invalidateRasterOnly();
33337
- }
33338
- get borderColor() {
33339
- return this._borderColor;
33340
- }
33341
- set borderColor(value) {
33342
- const next = parseColor(value);
33343
- if (this._borderColor === next)
33344
- return;
33345
- this._borderColor = next;
33346
- this.invalidateRasterOnly();
33347
- }
33348
- shouldStartSelection(x2, y2) {
33349
- if (!this.selectable)
33350
- return false;
33351
- this.ensureLayoutReady();
33352
- const localX = x2 - this.x;
33353
- const localY = y2 - this.y;
33354
- return this.getCellAtLocalPosition(localX, localY) !== null;
33355
- }
33356
- onSelectionChanged(selection) {
33357
- this.ensureLayoutReady();
33358
- const previousLocalSelection = this._lastLocalSelection;
33359
- const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
33360
- this._lastLocalSelection = localSelection;
33361
- const dirtyRows = this.getDirtySelectionRowRange(previousLocalSelection, localSelection);
33362
- if (!localSelection?.isActive) {
33363
- this.resetCellSelections();
33364
- this._lastSelectionMode = null;
33365
- } else {
33366
- this.applySelectionToCells(localSelection, selection?.isStart ?? false);
33367
- }
33368
- if (dirtyRows !== null) {
33369
- this.redrawSelectionRows(dirtyRows.firstRow, dirtyRows.lastRow);
33370
- }
33371
- return this.hasSelection();
33372
- }
33373
- hasSelection() {
33374
- for (const row of this._cells) {
33375
- for (const cell of row) {
33376
- if (cell.textBufferView.hasSelection()) {
33377
- return true;
33378
- }
33379
- }
33380
- }
33381
- return false;
33382
- }
33383
- getSelection() {
33384
- for (const row of this._cells) {
33385
- for (const cell of row) {
33386
- const selection = cell.textBufferView.getSelection();
33387
- if (selection) {
33388
- return selection;
33389
- }
33390
- }
33391
- }
33392
- return null;
33393
- }
33394
- getSelectedText() {
33395
- const selectedRows = [];
33396
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
33397
- const rowSelections = [];
33398
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33399
- const cell = this._cells[rowIdx]?.[colIdx];
33400
- if (!cell || !cell.textBufferView.hasSelection())
33401
- continue;
33402
- const selectedText = cell.textBufferView.getSelectedText();
33403
- if (selectedText.length > 0) {
33404
- rowSelections.push(selectedText);
33405
- }
33406
- }
33407
- if (rowSelections.length > 0) {
33408
- selectedRows.push(rowSelections.join("\t"));
33409
- }
33410
- }
33411
- return selectedRows.join(`
33412
- `);
33413
- }
33414
- onResize(width, height) {
33415
- this.invalidateLayoutAndRaster(false);
33416
- super.onResize(width, height);
33417
- }
33418
- renderSelf(buffer) {
33419
- if (!this.visible || this.isDestroyed)
33420
- return;
33421
- if (this._layoutDirty) {
33422
- this.rebuildLayoutForCurrentWidth();
33423
- }
33424
- if (!this._rasterDirty)
33425
- return;
33426
- buffer.clear(this._backgroundColor);
33427
- if (this._rowCount === 0 || this._columnCount === 0) {
33428
- this._rasterDirty = false;
33429
- return;
33430
- }
33431
- this.drawBorders(buffer);
33432
- this.drawCells(buffer);
33433
- this._rasterDirty = false;
33434
- }
33435
- destroySelf() {
33436
- this.destroyCells();
33437
- super.destroySelf();
33438
- }
33439
- setupMeasureFunc() {
33440
- const measureFunc = (width, widthMode, _height, _heightMode) => {
33441
- const hasWidthConstraint = widthMode !== 0 && Number.isFinite(width);
33442
- const rawWidthConstraint = hasWidthConstraint ? Math.max(1, Math.floor(width)) : undefined;
33443
- const widthConstraint = this.resolveLayoutWidthConstraint(rawWidthConstraint);
33444
- const measuredLayout = this.computeLayout(widthConstraint);
33445
- this._cachedMeasureLayout = measuredLayout;
33446
- this._cachedMeasureWidth = widthConstraint;
33447
- let measuredWidth = measuredLayout.tableWidth > 0 ? measuredLayout.tableWidth : 1;
33448
- let measuredHeight = measuredLayout.tableHeight > 0 ? measuredLayout.tableHeight : 1;
33449
- if (widthMode === 2 && rawWidthConstraint !== undefined && this._positionType !== "absolute") {
33450
- measuredWidth = Math.min(rawWidthConstraint, measuredWidth);
33451
- }
33452
- return {
33453
- width: measuredWidth,
33454
- height: measuredHeight
33455
- };
33456
- };
33457
- this.yogaNode.setMeasureFunc(measureFunc);
33458
- }
33459
- rebuildCells() {
33460
- const newRowCount = this._content.length;
33461
- const newColumnCount = this._content.reduce((max, row) => Math.max(max, row.length), 0);
33462
- if (this._cells.length === 0) {
33463
- this._rowCount = newRowCount;
33464
- this._columnCount = newColumnCount;
33465
- this._cells = [];
33466
- this._prevCellContent = [];
33467
- for (let rowIdx = 0;rowIdx < newRowCount; rowIdx++) {
33468
- const row = this._content[rowIdx] ?? [];
33469
- const rowCells = [];
33470
- const rowRefs = [];
33471
- for (let colIdx = 0;colIdx < newColumnCount; colIdx++) {
33472
- const cellContent = row[colIdx];
33473
- rowCells.push(this.createCell(cellContent));
33474
- rowRefs.push(cellContent);
33475
- }
33476
- this._cells.push(rowCells);
33477
- this._prevCellContent.push(rowRefs);
33478
- }
33479
- this.invalidateLayoutAndRaster();
33480
- return;
33481
- }
33482
- this.updateCellsDiff(newRowCount, newColumnCount);
33483
- this.invalidateLayoutAndRaster();
33484
- }
33485
- updateCellsDiff(newRowCount, newColumnCount) {
33486
- const oldRowCount = this._rowCount;
33487
- const oldColumnCount = this._columnCount;
33488
- const keepRows = Math.min(oldRowCount, newRowCount);
33489
- const keepCols = Math.min(oldColumnCount, newColumnCount);
33490
- for (let rowIdx = 0;rowIdx < keepRows; rowIdx++) {
33491
- const newRow = this._content[rowIdx] ?? [];
33492
- const cellRow = this._cells[rowIdx];
33493
- const refRow = this._prevCellContent[rowIdx];
33494
- for (let colIdx = 0;colIdx < keepCols; colIdx++) {
33495
- const cellContent = newRow[colIdx];
33496
- if (cellContent === refRow[colIdx])
33497
- continue;
33498
- const oldCell = cellRow[colIdx];
33499
- oldCell.textBufferView.destroy();
33500
- oldCell.textBuffer.destroy();
33501
- oldCell.syntaxStyle.destroy();
33502
- cellRow[colIdx] = this.createCell(cellContent);
33503
- refRow[colIdx] = cellContent;
33504
- }
33505
- if (newColumnCount > oldColumnCount) {
33506
- for (let colIdx = oldColumnCount;colIdx < newColumnCount; colIdx++) {
33507
- const cellContent = newRow[colIdx];
33508
- cellRow.push(this.createCell(cellContent));
33509
- refRow.push(cellContent);
33510
- }
33511
- } else if (newColumnCount < oldColumnCount) {
33512
- for (let colIdx = newColumnCount;colIdx < oldColumnCount; colIdx++) {
33513
- const cell = cellRow[colIdx];
33514
- cell.textBufferView.destroy();
33515
- cell.textBuffer.destroy();
33516
- cell.syntaxStyle.destroy();
33517
- }
33518
- cellRow.length = newColumnCount;
33519
- refRow.length = newColumnCount;
33520
- }
33521
- }
33522
- if (newRowCount > oldRowCount) {
33523
- for (let rowIdx = oldRowCount;rowIdx < newRowCount; rowIdx++) {
33524
- const newRow = this._content[rowIdx] ?? [];
33525
- const rowCells = [];
33526
- const rowRefs = [];
33527
- for (let colIdx = 0;colIdx < newColumnCount; colIdx++) {
33528
- const cellContent = newRow[colIdx];
33529
- rowCells.push(this.createCell(cellContent));
33530
- rowRefs.push(cellContent);
33531
- }
33532
- this._cells.push(rowCells);
33533
- this._prevCellContent.push(rowRefs);
33534
- }
33535
- } else if (newRowCount < oldRowCount) {
33536
- for (let rowIdx = newRowCount;rowIdx < oldRowCount; rowIdx++) {
33537
- const row = this._cells[rowIdx];
33538
- for (const cell of row) {
33539
- cell.textBufferView.destroy();
33540
- cell.textBuffer.destroy();
33541
- cell.syntaxStyle.destroy();
33542
- }
33543
- }
33544
- this._cells.length = newRowCount;
33545
- this._prevCellContent.length = newRowCount;
33546
- }
33547
- this._rowCount = newRowCount;
33548
- this._columnCount = newColumnCount;
33549
- }
33550
- createCell(content) {
33551
- const styledText = this.toStyledText(content);
33552
- const textBuffer = TextBuffer.create(this._ctx.widthMethod);
33553
- const syntaxStyle = SyntaxStyle.create();
33554
- textBuffer.setDefaultFg(this._defaultFg);
33555
- textBuffer.setDefaultBg(this._defaultBg);
33556
- textBuffer.setDefaultAttributes(this._defaultAttributes);
33557
- textBuffer.setSyntaxStyle(syntaxStyle);
33558
- textBuffer.setStyledText(styledText);
33559
- const textBufferView = TextBufferView.create(textBuffer);
33560
- textBufferView.setWrapMode(this._wrapMode);
33561
- return { textBuffer, textBufferView, syntaxStyle };
33562
- }
33563
- toStyledText(content) {
33564
- if (Array.isArray(content)) {
33565
- return new StyledText(content);
33566
- }
33567
- if (content === null || content === undefined) {
33568
- return stringToStyledText("");
33569
- }
33570
- return stringToStyledText(String(content));
33571
- }
33572
- destroyCells() {
33573
- for (const row of this._cells) {
33574
- for (const cell of row) {
33575
- cell.textBufferView.destroy();
33576
- cell.textBuffer.destroy();
33577
- cell.syntaxStyle.destroy();
33578
- }
33579
- }
33580
- this._cells = [];
33581
- this._prevCellContent = [];
33582
- this._rowCount = 0;
33583
- this._columnCount = 0;
33584
- this._layout = this.createEmptyLayout();
33585
- }
33586
- rebuildLayoutForCurrentWidth() {
33587
- const maxTableWidth = this.resolveLayoutWidthConstraint(this.width);
33588
- let layout;
33589
- if (this._cachedMeasureLayout !== null && this._cachedMeasureWidth === maxTableWidth) {
33590
- layout = this._cachedMeasureLayout;
33591
- } else {
33592
- layout = this.computeLayout(maxTableWidth);
33593
- }
33594
- this._cachedMeasureLayout = null;
33595
- this._cachedMeasureWidth = undefined;
33596
- this._layout = layout;
33597
- this.applyLayoutToViews(layout);
33598
- this._layoutDirty = false;
33599
- if (this._lastLocalSelection?.isActive) {
33600
- this.applySelectionToCells(this._lastLocalSelection, true);
33601
- }
33602
- }
33603
- computeLayout(maxTableWidth) {
33604
- if (this._rowCount === 0 || this._columnCount === 0) {
33605
- return this.createEmptyLayout();
33606
- }
33607
- const borderLayout = this.resolveBorderLayout();
33608
- const columnWidths = this.computeColumnWidths(maxTableWidth, borderLayout);
33609
- const rowHeights = this.computeRowHeights(columnWidths);
33610
- const columnOffsets = this.computeOffsets(columnWidths, borderLayout.left, borderLayout.right, borderLayout.innerVertical, this.getInterColumnGap(borderLayout));
33611
- const rowOffsets = this.computeOffsets(rowHeights, borderLayout.top, borderLayout.bottom, borderLayout.innerHorizontal);
33612
- return {
33613
- columnWidths,
33614
- rowHeights,
33615
- columnOffsets,
33616
- rowOffsets,
33617
- columnOffsetsI32: new Int32Array(columnOffsets),
33618
- rowOffsetsI32: new Int32Array(rowOffsets),
33619
- tableWidth: (columnOffsets[columnOffsets.length - 1] ?? 0) + 1,
33620
- tableHeight: (rowOffsets[rowOffsets.length - 1] ?? 0) + 1
33621
- };
33622
- }
33623
- isFullWidthMode() {
33624
- return this._columnWidthMode === "full";
33625
- }
33626
- computeColumnWidths(maxTableWidth, borderLayout) {
33627
- const horizontalPadding = this.getHorizontalCellPadding();
33628
- const intrinsicWidths = new Array(this._columnCount).fill(1 + horizontalPadding);
33629
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
33630
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33631
- const cell = this._cells[rowIdx]?.[colIdx];
33632
- if (!cell)
33633
- continue;
33634
- const measure = cell.textBufferView.measureForDimensions(0, MEASURE_HEIGHT);
33635
- const measuredWidth = Math.max(1, measure?.widthColsMax ?? 0) + horizontalPadding;
33636
- intrinsicWidths[colIdx] = Math.max(intrinsicWidths[colIdx], measuredWidth);
33637
- }
33638
- }
33639
- if (maxTableWidth === undefined || !Number.isFinite(maxTableWidth) || maxTableWidth <= 0) {
33640
- return intrinsicWidths;
33641
- }
33642
- const maxContentWidth = Math.max(1, Math.floor(maxTableWidth) - this.getVerticalBorderCount(borderLayout) - this.getTotalInterColumnGap(borderLayout));
33643
- const currentWidth = intrinsicWidths.reduce((sum, width) => sum + width, 0);
33644
- if (currentWidth === maxContentWidth) {
33645
- return intrinsicWidths;
33646
- }
33647
- if (currentWidth < maxContentWidth) {
33648
- if (this.isFullWidthMode()) {
33649
- return this.expandColumnWidths(intrinsicWidths, maxContentWidth);
33650
- }
33651
- return intrinsicWidths;
33652
- }
33653
- if (this._wrapMode === "none") {
33654
- return intrinsicWidths;
33655
- }
33656
- return this.fitColumnWidths(intrinsicWidths, maxContentWidth);
33657
- }
33658
- expandColumnWidths(widths, targetContentWidth) {
33659
- const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
33660
- const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
33661
- if (totalBaseWidth >= targetContentWidth) {
33662
- return baseWidths;
33663
- }
33664
- const expanded = [...baseWidths];
33665
- const columns = expanded.length;
33666
- const extraWidth = targetContentWidth - totalBaseWidth;
33667
- const sharedWidth = Math.floor(extraWidth / columns);
33668
- const remainder = extraWidth % columns;
33669
- for (let idx = 0;idx < columns; idx++) {
33670
- expanded[idx] += sharedWidth;
33671
- if (idx < remainder) {
33672
- expanded[idx] += 1;
33673
- }
33674
- }
33675
- return expanded;
33676
- }
33677
- fitColumnWidths(widths, targetContentWidth) {
33678
- if (this._columnFitter === "balanced") {
33679
- return this.fitColumnWidthsBalanced(widths, targetContentWidth);
33680
- }
33681
- return this.fitColumnWidthsProportional(widths, targetContentWidth);
33682
- }
33683
- fitColumnWidthsProportional(widths, targetContentWidth) {
33684
- const minWidth = 1 + this.getHorizontalCellPadding();
33685
- return allocateProportionalColumnWidths(widths, targetContentWidth, minWidth);
33686
- }
33687
- fitColumnWidthsBalanced(widths, targetContentWidth) {
33688
- const minWidth = 1 + this.getHorizontalCellPadding();
33689
- const hardMinWidths = new Array(widths.length).fill(minWidth);
33690
- const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
33691
- const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
33692
- const columns = baseWidths.length;
33693
- if (columns === 0 || totalBaseWidth <= targetContentWidth) {
33694
- return baseWidths;
33695
- }
33696
- const evenShare = Math.max(minWidth, Math.floor(targetContentWidth / columns));
33697
- const preferredMinWidths = baseWidths.map((width) => Math.min(width, evenShare));
33698
- const preferredMinTotal = preferredMinWidths.reduce((sum, width) => sum + width, 0);
33699
- const floorWidths = preferredMinTotal <= targetContentWidth ? preferredMinWidths : hardMinWidths;
33700
- const floorTotal = floorWidths.reduce((sum, width) => sum + width, 0);
33701
- const clampedTarget = Math.max(floorTotal, targetContentWidth);
33702
- if (totalBaseWidth <= clampedTarget) {
33703
- return baseWidths;
33704
- }
33705
- const shrinkable = baseWidths.map((width, idx) => width - floorWidths[idx]);
33706
- const totalShrinkable = shrinkable.reduce((sum, value) => sum + value, 0);
33707
- if (totalShrinkable <= 0) {
33708
- return [...floorWidths];
33709
- }
33710
- const targetShrink = totalBaseWidth - clampedTarget;
33711
- const shrink = this.allocateShrinkByWeight(shrinkable, targetShrink, "sqrt");
33712
- return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - shrink[idx]));
33713
- }
33714
- allocateShrinkByWeight(shrinkable, targetShrink, mode) {
33715
- const shrink = new Array(shrinkable.length).fill(0);
33716
- if (targetShrink <= 0) {
33717
- return shrink;
33718
- }
33719
- const weights = shrinkable.map((value) => {
33720
- if (value <= 0) {
33721
- return 0;
33722
- }
33723
- return mode === "sqrt" ? Math.sqrt(value) : value;
33724
- });
33725
- const totalWeight = weights.reduce((sum, value) => sum + value, 0);
33726
- if (totalWeight <= 0) {
33727
- return shrink;
33728
- }
33729
- const fractions = new Array(shrinkable.length).fill(0);
33730
- let usedShrink = 0;
33731
- for (let idx = 0;idx < shrinkable.length; idx++) {
33732
- if (shrinkable[idx] <= 0 || weights[idx] <= 0)
33733
- continue;
33734
- const exact = weights[idx] / totalWeight * targetShrink;
33735
- const whole = Math.min(shrinkable[idx], Math.floor(exact));
33736
- shrink[idx] = whole;
33737
- fractions[idx] = exact - whole;
33738
- usedShrink += whole;
33739
- }
33740
- let remainingShrink = targetShrink - usedShrink;
33741
- while (remainingShrink > 0) {
33742
- let bestIdx = -1;
33743
- let bestFraction = -1;
33744
- for (let idx = 0;idx < shrinkable.length; idx++) {
33745
- if (shrinkable[idx] - shrink[idx] <= 0)
33746
- continue;
33747
- if (bestIdx === -1 || fractions[idx] > bestFraction || fractions[idx] === bestFraction && shrinkable[idx] > shrinkable[bestIdx]) {
33748
- bestIdx = idx;
33749
- bestFraction = fractions[idx];
33750
- }
33751
- }
33752
- if (bestIdx === -1) {
33753
- break;
33754
- }
33755
- shrink[bestIdx] += 1;
33756
- fractions[bestIdx] = 0;
33757
- remainingShrink -= 1;
33758
- }
33759
- return shrink;
33760
- }
33761
- computeRowHeights(columnWidths) {
33762
- const horizontalPadding = this.getHorizontalCellPadding();
33763
- const verticalPadding = this.getVerticalCellPadding();
33764
- const rowHeights = new Array(this._rowCount).fill(1 + verticalPadding);
33765
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
33766
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33767
- const cell = this._cells[rowIdx]?.[colIdx];
33768
- if (!cell)
33769
- continue;
33770
- const width = Math.max(1, (columnWidths[colIdx] ?? 1) - horizontalPadding);
33771
- const measure = cell.textBufferView.measureForDimensions(width, MEASURE_HEIGHT);
33772
- const lineCount = Math.max(1, measure?.lineCount ?? 1);
33773
- rowHeights[rowIdx] = Math.max(rowHeights[rowIdx], lineCount + verticalPadding);
33774
- }
33775
- }
33776
- return rowHeights;
33777
- }
33778
- computeOffsets(parts, startBoundary, endBoundary, includeInnerBoundaries, innerGap = 0) {
33779
- const offsets = [startBoundary ? 0 : -1];
33780
- let cursor = offsets[0] ?? 0;
33781
- for (let idx = 0;idx < parts.length; idx++) {
33782
- const size = parts[idx] ?? 1;
33783
- const separatorAfter = idx < parts.length - 1 ? includeInnerBoundaries ? 1 : innerGap : endBoundary ? 1 : 0;
33784
- cursor += size + separatorAfter;
33785
- offsets.push(cursor);
33786
- }
33787
- return offsets;
33788
- }
33789
- getInterColumnGap(borderLayout) {
33790
- if (borderLayout.innerVertical) {
33791
- return 0;
33792
- }
33793
- return this._columnGap;
33794
- }
33795
- getTotalInterColumnGap(borderLayout) {
33796
- return Math.max(0, this._columnCount - 1) * this.getInterColumnGap(borderLayout);
33797
- }
33798
- applyLayoutToViews(layout) {
33799
- const horizontalPadding = this.getHorizontalCellPadding();
33800
- const verticalPadding = this.getVerticalCellPadding();
33801
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
33802
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33803
- const cell = this._cells[rowIdx]?.[colIdx];
33804
- if (!cell)
33805
- continue;
33806
- const colWidth = layout.columnWidths[colIdx] ?? 1;
33807
- const rowHeight = layout.rowHeights[rowIdx] ?? 1;
33808
- const contentWidth = Math.max(1, colWidth - horizontalPadding);
33809
- const contentHeight = Math.max(1, rowHeight - verticalPadding);
33810
- if (this._wrapMode === "none") {
33811
- cell.textBufferView.setWrapWidth(null);
33812
- } else {
33813
- cell.textBufferView.setWrapWidth(contentWidth);
33814
- }
33815
- cell.textBufferView.setViewport(0, 0, contentWidth, contentHeight);
33816
- }
33817
- }
33818
- }
33819
- resolveBorderLayout() {
33820
- return {
33821
- left: this._outerBorder,
33822
- right: this._outerBorder,
33823
- top: this._outerBorder,
33824
- bottom: this._outerBorder,
33825
- innerVertical: this._border && this._columnCount > 1,
33826
- innerHorizontal: this._border && this._rowCount > 1
33827
- };
33828
- }
33829
- getVerticalBorderCount(borderLayout) {
33830
- return (borderLayout.left ? 1 : 0) + (borderLayout.right ? 1 : 0) + (borderLayout.innerVertical ? Math.max(0, this._columnCount - 1) : 0);
33831
- }
33832
- getHorizontalBorderCount(borderLayout) {
33833
- return (borderLayout.top ? 1 : 0) + (borderLayout.bottom ? 1 : 0) + (borderLayout.innerHorizontal ? Math.max(0, this._rowCount - 1) : 0);
33834
- }
33835
- drawBorders(buffer) {
33836
- if (!this._showBorders) {
33837
- return;
33838
- }
33839
- const borderLayout = this.resolveBorderLayout();
33840
- if (this.getVerticalBorderCount(borderLayout) === 0 && this.getHorizontalBorderCount(borderLayout) === 0) {
33841
- return;
33842
- }
33843
- buffer.drawGrid({
33844
- borderChars: BorderCharArrays[this._borderStyle],
33845
- borderFg: this._borderColor,
33846
- borderBg: this._borderBackgroundColor,
33847
- columnOffsets: this._layout.columnOffsetsI32,
33848
- rowOffsets: this._layout.rowOffsetsI32,
33849
- drawInner: this._border,
33850
- drawOuter: this._outerBorder
33851
- });
33852
- }
33853
- drawCells(buffer) {
33854
- this.drawCellRange(buffer, 0, this._rowCount - 1);
33855
- }
33856
- drawCellRange(buffer, firstRow, lastRow) {
33857
- const colOffsets = this._layout.columnOffsets;
33858
- const rowOffsets = this._layout.rowOffsets;
33859
- const cellPaddingX = this._cellPaddingX;
33860
- const cellPaddingY = this._cellPaddingY;
33861
- for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
33862
- const cellY = (rowOffsets[rowIdx] ?? 0) + 1 + cellPaddingY;
33863
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33864
- const cell = this._cells[rowIdx]?.[colIdx];
33865
- if (!cell)
33866
- continue;
33867
- buffer.drawTextBuffer(cell.textBufferView, (colOffsets[colIdx] ?? 0) + 1 + cellPaddingX, cellY);
33868
- }
33869
- }
33870
- }
33871
- redrawSelectionRows(firstRow, lastRow) {
33872
- if (firstRow > lastRow)
33873
- return;
33874
- if (this._backgroundColor.a < 1) {
33875
- this.invalidateRasterOnly();
33876
- return;
33877
- }
33878
- const buffer = this.frameBuffer;
33879
- if (!buffer)
33880
- return;
33881
- this.clearCellRange(buffer, firstRow, lastRow);
33882
- this.drawCellRange(buffer, firstRow, lastRow);
33883
- this.requestRender();
33884
- }
33885
- clearCellRange(buffer, firstRow, lastRow) {
33886
- const colWidths = this._layout.columnWidths;
33887
- const rowHeights = this._layout.rowHeights;
33888
- const colOffsets = this._layout.columnOffsets;
33889
- const rowOffsets = this._layout.rowOffsets;
33890
- for (let rowIdx = firstRow;rowIdx <= lastRow; rowIdx++) {
33891
- const cellY = (rowOffsets[rowIdx] ?? 0) + 1;
33892
- const rowHeight = rowHeights[rowIdx] ?? 1;
33893
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33894
- const cellX = (colOffsets[colIdx] ?? 0) + 1;
33895
- const colWidth = colWidths[colIdx] ?? 1;
33896
- if (this._backgroundColor.a < 1) {
33897
- for (let y2 = cellY;y2 < cellY + rowHeight; y2++) {
33898
- for (let x2 = cellX;x2 < cellX + colWidth; x2++) {
33899
- buffer.setCell(x2, y2, " ", this._defaultFg, this._backgroundColor, this._defaultAttributes);
33900
- }
33901
- }
33902
- } else {
33903
- buffer.fillRect(cellX, cellY, colWidth, rowHeight, this._backgroundColor);
33904
- }
33905
- }
33906
- }
33907
- }
33908
- ensureLayoutReady() {
33909
- if (!this._layoutDirty)
33910
- return;
33911
- this.rebuildLayoutForCurrentWidth();
33912
- }
33913
- getCellAtLocalPosition(localX, localY) {
33914
- if (this._rowCount === 0 || this._columnCount === 0)
33915
- return null;
33916
- if (localX < 0 || localY < 0 || localX >= this._layout.tableWidth || localY >= this._layout.tableHeight) {
33917
- return null;
33918
- }
33919
- let rowIdx = -1;
33920
- for (let idx = 0;idx < this._rowCount; idx++) {
33921
- const top = (this._layout.rowOffsets[idx] ?? 0) + 1;
33922
- const bottom = top + (this._layout.rowHeights[idx] ?? 1) - 1;
33923
- if (localY >= top && localY <= bottom) {
33924
- rowIdx = idx;
33925
- break;
33926
- }
33927
- }
33928
- if (rowIdx < 0)
33929
- return null;
33930
- let colIdx = -1;
33931
- for (let idx = 0;idx < this._columnCount; idx++) {
33932
- const left = (this._layout.columnOffsets[idx] ?? 0) + 1;
33933
- const right = left + (this._layout.columnWidths[idx] ?? 1) - 1;
33934
- if (localX >= left && localX <= right) {
33935
- colIdx = idx;
33936
- break;
33937
- }
33938
- }
33939
- if (colIdx < 0)
33940
- return null;
33941
- return { rowIdx, colIdx };
33942
- }
33943
- applySelectionToCells(localSelection, isStart) {
33944
- if (localSelection.anchorX === localSelection.focusX && localSelection.anchorY === localSelection.focusY) {
33945
- this.resetCellSelections();
33946
- this._lastSelectionMode = null;
33947
- return;
33948
- }
33949
- const minSelY = Math.min(localSelection.anchorY, localSelection.focusY);
33950
- const maxSelY = Math.max(localSelection.anchorY, localSelection.focusY);
33951
- const firstRow = this.findRowForLocalY(minSelY);
33952
- const lastRow = this.findRowForLocalY(maxSelY);
33953
- const selection = this.resolveSelectionResolution(localSelection);
33954
- const modeChanged = this._lastSelectionMode !== selection.mode;
33955
- this._lastSelectionMode = selection.mode;
33956
- const lockToAnchorColumn = selection.mode === "column-locked" && selection.anchorColumn !== null;
33957
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
33958
- if (rowIdx < firstRow || rowIdx > lastRow) {
33959
- this.resetRowSelection(rowIdx);
33960
- continue;
33961
- }
33962
- const cellTop = (this._layout.rowOffsets[rowIdx] ?? 0) + 1 + this._cellPaddingY;
33963
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
33964
- const cell = this._cells[rowIdx]?.[colIdx];
33965
- if (!cell)
33966
- continue;
33967
- if (lockToAnchorColumn && colIdx !== selection.anchorColumn) {
33968
- cell.textBufferView.resetLocalSelection();
33969
- continue;
33970
- }
33971
- const cellLeft = (this._layout.columnOffsets[colIdx] ?? 0) + 1 + this._cellPaddingX;
33972
- let coords = {
33973
- anchorX: localSelection.anchorX - cellLeft,
33974
- anchorY: localSelection.anchorY - cellTop,
33975
- focusX: localSelection.focusX - cellLeft,
33976
- focusY: localSelection.focusY - cellTop
33977
- };
33978
- const isAnchorCell = selection.anchorCell !== null && selection.anchorCell.rowIdx === rowIdx && selection.anchorCell.colIdx === colIdx;
33979
- if (selection.mode === "single-cell" && !isAnchorCell) {
33980
- cell.textBufferView.resetLocalSelection();
33981
- continue;
33982
- }
33983
- const forceSet = isAnchorCell && selection.mode !== "single-cell";
33984
- if (forceSet) {
33985
- coords = this.getFullCellSelectionCoords(rowIdx, colIdx);
33986
- }
33987
- const shouldUseSet = isStart || modeChanged || forceSet;
33988
- if (shouldUseSet) {
33989
- cell.textBufferView.setLocalSelection(coords.anchorX, coords.anchorY, coords.focusX, coords.focusY, this._selectionBg, this._selectionFg);
33990
- } else {
33991
- cell.textBufferView.updateLocalSelection(coords.anchorX, coords.anchorY, coords.focusX, coords.focusY, this._selectionBg, this._selectionFg);
33992
- }
33993
- }
33994
- }
33995
- }
33996
- resolveSelectionResolution(localSelection) {
33997
- const anchorCell = this.getCellAtLocalPosition(localSelection.anchorX, localSelection.anchorY);
33998
- const focusCell = this.getCellAtLocalPosition(localSelection.focusX, localSelection.focusY);
33999
- const anchorColumn = anchorCell?.colIdx ?? this.getColumnAtLocalX(localSelection.anchorX);
34000
- if (anchorCell !== null && focusCell !== null && anchorCell.rowIdx === focusCell.rowIdx && anchorCell.colIdx === focusCell.colIdx) {
34001
- return {
34002
- mode: "single-cell",
34003
- anchorCell,
34004
- anchorColumn
34005
- };
34006
- }
34007
- const focusColumn = this.getColumnAtLocalX(localSelection.focusX);
34008
- if (anchorColumn !== null && focusColumn === anchorColumn) {
34009
- return {
34010
- mode: "column-locked",
34011
- anchorCell,
34012
- anchorColumn
34013
- };
34014
- }
34015
- return {
34016
- mode: "grid",
34017
- anchorCell,
34018
- anchorColumn
34019
- };
34020
- }
34021
- getColumnAtLocalX(localX) {
34022
- if (this._columnCount === 0)
34023
- return null;
34024
- if (localX < 0 || localX >= this._layout.tableWidth)
34025
- return null;
34026
- for (let colIdx = 0;colIdx < this._columnCount; colIdx++) {
34027
- const colStart = (this._layout.columnOffsets[colIdx] ?? 0) + 1;
34028
- const colEnd = colStart + (this._layout.columnWidths[colIdx] ?? 1) - 1;
34029
- if (localX >= colStart && localX <= colEnd) {
34030
- return colIdx;
34031
- }
34032
- }
34033
- return null;
34034
- }
34035
- getFullCellSelectionCoords(rowIdx, colIdx) {
34036
- const colWidth = this._layout.columnWidths[colIdx] ?? 1;
34037
- const rowHeight = this._layout.rowHeights[rowIdx] ?? 1;
34038
- const contentWidth = Math.max(1, colWidth - this.getHorizontalCellPadding());
34039
- const contentHeight = Math.max(1, rowHeight - this.getVerticalCellPadding());
34040
- return {
34041
- anchorX: -1,
34042
- anchorY: 0,
34043
- focusX: contentWidth,
34044
- focusY: contentHeight
34045
- };
34046
- }
34047
- findRowForLocalY(localY) {
34048
- if (this._rowCount === 0)
34049
- return 0;
34050
- if (localY < 0)
34051
- return 0;
34052
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
34053
- const rowStart = (this._layout.rowOffsets[rowIdx] ?? 0) + 1;
34054
- const rowEnd = rowStart + (this._layout.rowHeights[rowIdx] ?? 1) - 1;
34055
- if (localY <= rowEnd)
34056
- return rowIdx;
34057
- }
34058
- return this._rowCount - 1;
34059
- }
34060
- getSelectionRowRange(selection) {
34061
- if (!selection?.isActive || this._rowCount === 0)
34062
- return null;
34063
- const minSelY = Math.min(selection.anchorY, selection.focusY);
34064
- const maxSelY = Math.max(selection.anchorY, selection.focusY);
34065
- return {
34066
- firstRow: this.findRowForLocalY(minSelY),
34067
- lastRow: this.findRowForLocalY(maxSelY)
34068
- };
34069
- }
34070
- getDirtySelectionRowRange(previousSelection, currentSelection) {
34071
- const previousRange = this.getSelectionRowRange(previousSelection);
34072
- const currentRange = this.getSelectionRowRange(currentSelection);
34073
- if (previousRange === null)
34074
- return currentRange;
34075
- if (currentRange === null)
34076
- return previousRange;
34077
- return {
34078
- firstRow: Math.min(previousRange.firstRow, currentRange.firstRow),
34079
- lastRow: Math.max(previousRange.lastRow, currentRange.lastRow)
34080
- };
34081
- }
34082
- resetRowSelection(rowIdx) {
34083
- const row = this._cells[rowIdx];
34084
- if (!row)
34085
- return;
34086
- for (const cell of row) {
34087
- cell.textBufferView.resetLocalSelection();
34088
- }
34089
- }
34090
- resetCellSelections() {
34091
- for (let rowIdx = 0;rowIdx < this._rowCount; rowIdx++) {
34092
- this.resetRowSelection(rowIdx);
34093
- }
34094
- }
34095
- createEmptyLayout() {
34096
- return {
34097
- columnWidths: [],
34098
- rowHeights: [],
34099
- columnOffsets: [0],
34100
- rowOffsets: [0],
34101
- columnOffsetsI32: new Int32Array([0]),
34102
- rowOffsetsI32: new Int32Array([0]),
34103
- tableWidth: 0,
34104
- tableHeight: 0
34105
- };
34106
- }
34107
- resolveLayoutWidthConstraint(width) {
34108
- if (width === undefined || !Number.isFinite(width) || width <= 0) {
34109
- return;
34110
- }
34111
- if (this._wrapMode !== "none" || this.isFullWidthMode()) {
34112
- return Math.max(1, Math.floor(width));
34113
- }
34114
- return;
34115
- }
34116
- getHorizontalCellPadding() {
34117
- return this._cellPaddingX * 2;
34118
- }
34119
- getVerticalCellPadding() {
34120
- return this._cellPaddingY * 2;
34121
- }
34122
- resolveColumnFitter(value) {
34123
- if (value === undefined) {
34124
- return this._defaultOptions.columnFitter;
34125
- }
34126
- return value === "balanced" ? "balanced" : "proportional";
34127
- }
34128
- resolveCellPadding(value) {
34129
- if (value === undefined || !Number.isFinite(value)) {
34130
- return this._defaultOptions.cellPadding;
34131
- }
34132
- return Math.max(0, Math.floor(value));
34133
- }
34134
- resolveColumnGap(value) {
34135
- if (value === undefined || !Number.isFinite(value)) {
34136
- return this._defaultOptions.columnGap;
34137
- }
34138
- return Math.max(0, Math.floor(value));
34139
- }
34140
- invalidateLayoutAndRaster(markYogaDirty = true) {
34141
- this._layoutDirty = true;
34142
- this._rasterDirty = true;
34143
- this._cachedMeasureLayout = null;
34144
- this._cachedMeasureWidth = undefined;
34145
- if (markYogaDirty) {
34146
- this.yogaNode.markDirty();
34147
- }
34148
- this.requestRender();
34149
- }
34150
- invalidateRasterOnly() {
34151
- this._rasterDirty = true;
34152
- this.requestRender();
34153
- }
34154
- }
34155
31388
  var defaultThumbBackgroundColor = RGBA.fromHex("#9a9ea3");
34156
31389
  var defaultTrackBackgroundColor = RGBA.fromHex("#252527");
34157
31390
 
@@ -35844,6 +33077,33 @@ var OPENROUTER_MODELS = [
35844
33077
  contextLength: 256000,
35845
33078
  cost: "free"
35846
33079
  },
33080
+ {
33081
+ id: "nvidia/nemotron-3.5-lightning:free",
33082
+ name: "Nemotron 3.5 Lightning (Free)",
33083
+ description: "High-throughput open reasoning model on OpenRouter's free tier.",
33084
+ category: "fast",
33085
+ provider: "openrouter",
33086
+ contextLength: 1e6,
33087
+ cost: "free"
33088
+ },
33089
+ {
33090
+ id: "nvidia/nemotron-3-ultra-550b-a55b:free",
33091
+ name: "Nemotron 3 Ultra (Free)",
33092
+ description: "Large open reasoning model available on OpenRouter's free tier.",
33093
+ category: "reasoning",
33094
+ provider: "openrouter",
33095
+ contextLength: 1e6,
33096
+ cost: "free"
33097
+ },
33098
+ {
33099
+ id: "poolside/laguna-s-2.1:free",
33100
+ name: "Laguna S 2.1 (Free)",
33101
+ description: "Open-weight coding model for long-horizon agentic work.",
33102
+ category: "reasoning",
33103
+ provider: "openrouter",
33104
+ contextLength: 262144,
33105
+ cost: "free"
33106
+ },
35847
33107
  {
35848
33108
  id: "deepseek/deepseek-v4-flash-0731",
35849
33109
  name: "DeepSeek V4 Flash 0731",
@@ -35871,6 +33131,24 @@ var OPENROUTER_MODELS = [
35871
33131
  contextLength: 1048576,
35872
33132
  cost: "lower-cost"
35873
33133
  },
33134
+ {
33135
+ id: "z-ai/glm-5.3",
33136
+ name: "GLM 5.3",
33137
+ description: "Latest open-weight GLM model for coding, reasoning, and tool use.",
33138
+ category: "reasoning",
33139
+ provider: "openrouter",
33140
+ contextLength: 1048576,
33141
+ cost: "lower-cost"
33142
+ },
33143
+ {
33144
+ id: "z-ai/glm-5.3-flash",
33145
+ name: "GLM 5.3 Flash",
33146
+ description: "Open-weight multimodal GLM model optimized for efficient agentic coding.",
33147
+ category: "smart",
33148
+ provider: "openrouter",
33149
+ contextLength: 1310720,
33150
+ cost: "lower-cost"
33151
+ },
35874
33152
  {
35875
33153
  id: "qwen/qwen3.6-27b",
35876
33154
  name: "Qwen 3.6 27B",
@@ -35880,6 +33158,24 @@ var OPENROUTER_MODELS = [
35880
33158
  contextLength: 262144,
35881
33159
  cost: "lower-cost"
35882
33160
  },
33161
+ {
33162
+ id: "qwen/qwen3.8-2.4t-a95b",
33163
+ name: "Qwen 3.8 2.4T A95B",
33164
+ description: "Latest open-weight Qwen mixture-of-experts model for tools and reasoning.",
33165
+ category: "reasoning",
33166
+ provider: "openrouter",
33167
+ contextLength: 1048576,
33168
+ cost: "premium"
33169
+ },
33170
+ {
33171
+ id: "deepseek/deepseek-v4-pro-0813",
33172
+ name: "DeepSeek V4 Pro 0813",
33173
+ description: "GA release of DeepSeek V4 Pro for complex agentic tasks.",
33174
+ category: "reasoning",
33175
+ provider: "openrouter",
33176
+ contextLength: 1048576,
33177
+ cost: "lower-cost"
33178
+ },
35883
33179
  {
35884
33180
  id: "moonshotai/kimi-k3",
35885
33181
  name: "Kimi K3",
@@ -35952,7 +33248,52 @@ var VERCEL_AI_GATEWAY_MODELS = [
35952
33248
  "anthropic/claude-sonnet-5",
35953
33249
  "anthropic/claude-opus-5",
35954
33250
  "anthropic/claude-fable-5"
35955
- ].includes(model.id)).map((model) => ({ ...model, provider: "vercel-ai-gateway" }))
33251
+ ].includes(model.id)).map((model) => ({ ...model, provider: "vercel-ai-gateway" })),
33252
+ {
33253
+ id: "deepseek/deepseek-v4-pro-0813",
33254
+ name: "DeepSeek V4 Pro 0813",
33255
+ description: "GA release of DeepSeek V4 Pro for complex agentic tasks.",
33256
+ category: "reasoning",
33257
+ provider: "vercel-ai-gateway",
33258
+ contextLength: 1e6,
33259
+ cost: "lower-cost"
33260
+ },
33261
+ {
33262
+ id: "alibaba/qwen3.8-2.4t-a95b",
33263
+ name: "Qwen 3.8 2.4T A95B",
33264
+ description: "Latest open-weight Qwen mixture-of-experts model for tools and reasoning.",
33265
+ category: "reasoning",
33266
+ provider: "vercel-ai-gateway",
33267
+ contextLength: 262144,
33268
+ cost: "premium"
33269
+ },
33270
+ {
33271
+ id: "zai/glm-5.3",
33272
+ name: "GLM 5.3",
33273
+ description: "Latest open-weight GLM model for coding, reasoning, and tool use.",
33274
+ category: "reasoning",
33275
+ provider: "vercel-ai-gateway",
33276
+ contextLength: 1e6,
33277
+ cost: "lower-cost"
33278
+ },
33279
+ {
33280
+ id: "zai/glm-5.3-flash",
33281
+ name: "GLM 5.3 Flash",
33282
+ description: "Open-weight multimodal GLM model optimized for efficient agentic coding.",
33283
+ category: "smart",
33284
+ provider: "vercel-ai-gateway",
33285
+ contextLength: 1e6,
33286
+ cost: "lower-cost"
33287
+ },
33288
+ {
33289
+ id: "poolside/laguna-s-2.1-free",
33290
+ name: "Laguna S 2.1 (Free)",
33291
+ description: "Open-weight coding model for long-horizon agentic work.",
33292
+ category: "reasoning",
33293
+ provider: "vercel-ai-gateway",
33294
+ contextLength: 256000,
33295
+ cost: "free"
33296
+ }
35956
33297
  ];
35957
33298
  var CLOUDFLARE_AI_GATEWAY_MODELS = [
35958
33299
  {
@@ -35971,6 +33312,60 @@ var CLOUDFLARE_AI_GATEWAY_MODELS = [
35971
33312
  }))
35972
33313
  ];
35973
33314
  var WORKERS_AI_MODELS = [
33315
+ {
33316
+ id: "@cf/zai-org/glm-5.3",
33317
+ name: "GLM 5.3",
33318
+ description: "Open-weight flagship model for long-running agentic coding workflows.",
33319
+ category: "reasoning",
33320
+ provider: "workers-ai",
33321
+ contextLength: 1048576,
33322
+ cost: "lower-cost"
33323
+ },
33324
+ {
33325
+ id: "@cf/zai-org/glm-5.3-flash",
33326
+ name: "GLM 5.3 Flash",
33327
+ description: "Open-weight multimodal model for efficient reasoning and agentic coding.",
33328
+ category: "smart",
33329
+ provider: "workers-ai",
33330
+ contextLength: 1310720,
33331
+ cost: "lower-cost"
33332
+ },
33333
+ {
33334
+ id: "@cf/zai-org/glm-5.2",
33335
+ name: "GLM 5.2",
33336
+ description: "Flagship open-weight coding model with function calling and reasoning.",
33337
+ category: "reasoning",
33338
+ provider: "workers-ai",
33339
+ contextLength: 262144,
33340
+ cost: "lower-cost"
33341
+ },
33342
+ {
33343
+ id: "@cf/deepseek-ai/deepseek-v4-flash-0731",
33344
+ name: "DeepSeek V4 Flash 0731",
33345
+ description: "Fast open-weight DeepSeek model with a one-million-token context window.",
33346
+ category: "fast",
33347
+ provider: "workers-ai",
33348
+ contextLength: 1048576,
33349
+ cost: "lower-cost"
33350
+ },
33351
+ {
33352
+ id: "@cf/deepseek-ai/deepseek-v4-pro-0813",
33353
+ name: "DeepSeek V4 Pro 0813",
33354
+ description: "Open-weight DeepSeek model for complex agentic work.",
33355
+ category: "reasoning",
33356
+ provider: "workers-ai",
33357
+ contextLength: 1048576,
33358
+ cost: "lower-cost"
33359
+ },
33360
+ {
33361
+ id: "@cf/qwen/qwen3.8-27b",
33362
+ name: "Qwen 3.8 27B",
33363
+ description: "Open-weight vision-language model with reasoning and function calling.",
33364
+ category: "smart",
33365
+ provider: "workers-ai",
33366
+ contextLength: 262144,
33367
+ cost: "lower-cost"
33368
+ },
35974
33369
  {
35975
33370
  id: "@cf/zai-org/glm-4.7-flash",
35976
33371
  name: "GLM 4.7 Flash",
@@ -36029,15 +33424,35 @@ var OPENCODE_ZEN_MODELS = [
36029
33424
  cost: "free"
36030
33425
  },
36031
33426
  {
36032
- id: "ling-3.0-tiny-free",
36033
- name: "Ling 3.0 Tiny (Free)",
36034
- description: "Current free fast model on OpenCode Zen.",
33427
+ id: "nemotron-3.5-lightning-free",
33428
+ name: "Nemotron 3.5 Lightning (Free)",
33429
+ description: "Current free high-throughput reasoning model on OpenCode Zen.",
36035
33430
  category: "fast",
36036
33431
  provider: "opencode-zen",
36037
33432
  zenApiType: "openai-compatible",
36038
33433
  contextLength: 262144,
36039
33434
  cost: "free"
36040
33435
  },
33436
+ {
33437
+ id: "nemotron-3-ultra-free",
33438
+ name: "Nemotron 3 Ultra (Free)",
33439
+ description: "Large open reasoning model available free on OpenCode Zen.",
33440
+ category: "reasoning",
33441
+ provider: "opencode-zen",
33442
+ zenApiType: "openai-compatible",
33443
+ contextLength: 1e6,
33444
+ cost: "free"
33445
+ },
33446
+ {
33447
+ id: "laguna-s-2.1-free",
33448
+ name: "Laguna S 2.1 (Free)",
33449
+ description: "Open-weight coding model for long-horizon agentic work.",
33450
+ category: "reasoning",
33451
+ provider: "opencode-zen",
33452
+ zenApiType: "openai-compatible",
33453
+ contextLength: 262144,
33454
+ cost: "free"
33455
+ },
36041
33456
  {
36042
33457
  id: "minimax-m3",
36043
33458
  name: "MiniMax M3",
@@ -36058,6 +33473,16 @@ var OPENCODE_ZEN_MODELS = [
36058
33473
  contextLength: 1048576,
36059
33474
  cost: "lower-cost"
36060
33475
  },
33476
+ {
33477
+ id: "deepseek-v4-pro",
33478
+ name: "DeepSeek V4 Pro",
33479
+ description: "Current DeepSeek V4 reasoning model for complex agentic tasks.",
33480
+ category: "reasoning",
33481
+ provider: "opencode-zen",
33482
+ zenApiType: "openai-compatible",
33483
+ contextLength: 1048576,
33484
+ cost: "lower-cost"
33485
+ },
36061
33486
  {
36062
33487
  id: "kimi-k3",
36063
33488
  name: "Kimi K3",
@@ -37198,457 +34623,457 @@ var UnsupportedFunctionalityError = class extends (_b15 = AISDKError, _a15 = sym
37198
34623
  // node_modules/zod/v4/classic/external.js
37199
34624
  var exports_external = {};
37200
34625
  __export(exports_external, {
37201
- xid: () => xid2,
37202
- void: () => _void2,
37203
- uuidv7: () => uuidv7,
37204
- uuidv6: () => uuidv6,
37205
- uuidv4: () => uuidv4,
37206
- uuid: () => uuid2,
37207
- url: () => url,
37208
- uppercase: () => _uppercase,
37209
- unknown: () => unknown,
37210
- union: () => union,
37211
- undefined: () => _undefined3,
37212
- ulid: () => ulid2,
37213
- uint64: () => uint64,
37214
- uint32: () => uint32,
37215
- tuple: () => tuple,
37216
- trim: () => _trim,
37217
- treeifyError: () => treeifyError,
37218
- transform: () => transform,
37219
- toUpperCase: () => _toUpperCase,
37220
- toLowerCase: () => _toLowerCase,
37221
- toJSONSchema: () => toJSONSchema,
37222
- templateLiteral: () => templateLiteral,
37223
- symbol: () => symbol16,
37224
- superRefine: () => superRefine,
37225
- success: () => success,
37226
- stringbool: () => stringbool,
37227
- stringFormat: () => stringFormat,
37228
- string: () => string2,
37229
- strictObject: () => strictObject,
37230
- startsWith: () => _startsWith,
37231
- size: () => _size,
37232
- setErrorMap: () => setErrorMap,
37233
- set: () => set,
37234
- safeParseAsync: () => safeParseAsync2,
37235
- safeParse: () => safeParse2,
37236
- registry: () => registry,
37237
- regexes: () => exports_regexes,
37238
- regex: () => _regex,
37239
- refine: () => refine,
37240
- record: () => record,
37241
- readonly: () => readonly,
37242
- property: () => _property,
37243
- promise: () => promise,
37244
- prettifyError: () => prettifyError,
37245
- preprocess: () => preprocess,
37246
- prefault: () => prefault,
37247
- positive: () => _positive,
37248
- pipe: () => pipe,
37249
- partialRecord: () => partialRecord,
37250
- parseAsync: () => parseAsync2,
37251
- parse: () => parse4,
37252
- overwrite: () => _overwrite,
37253
- optional: () => optional,
37254
- object: () => object,
37255
- number: () => number2,
37256
- nullish: () => nullish2,
37257
- nullable: () => nullable,
37258
- null: () => _null3,
37259
- normalize: () => _normalize,
37260
- nonpositive: () => _nonpositive,
37261
- nonoptional: () => nonoptional,
37262
- nonnegative: () => _nonnegative,
37263
- never: () => never,
37264
- negative: () => _negative,
37265
- nativeEnum: () => nativeEnum,
37266
- nanoid: () => nanoid2,
37267
- nan: () => nan,
37268
- multipleOf: () => _multipleOf,
37269
- minSize: () => _minSize,
37270
- minLength: () => _minLength,
37271
- mime: () => _mime,
37272
- maxSize: () => _maxSize,
37273
- maxLength: () => _maxLength,
37274
- map: () => map,
37275
- lte: () => _lte,
37276
- lt: () => _lt,
37277
- lowercase: () => _lowercase,
37278
- looseObject: () => looseObject,
37279
- locales: () => exports_locales,
37280
- literal: () => literal,
37281
- length: () => _length,
37282
- lazy: () => lazy,
37283
- ksuid: () => ksuid2,
37284
- keyof: () => keyof,
37285
- jwt: () => jwt,
37286
- json: () => json,
37287
- iso: () => exports_iso,
37288
- ipv6: () => ipv62,
37289
- ipv4: () => ipv42,
37290
- intersection: () => intersection,
37291
- int64: () => int64,
37292
- int32: () => int32,
37293
- int: () => int,
37294
- instanceof: () => _instanceof,
37295
- includes: () => _includes,
37296
- guid: () => guid2,
37297
- gte: () => _gte,
37298
- gt: () => _gt,
37299
- globalRegistry: () => globalRegistry,
37300
- getErrorMap: () => getErrorMap,
37301
- function: () => _function,
37302
- formatError: () => formatError,
37303
- float64: () => float64,
37304
- float32: () => float32,
37305
- flattenError: () => flattenError,
37306
- file: () => file,
37307
- enum: () => _enum2,
37308
- endsWith: () => _endsWith,
37309
- emoji: () => emoji2,
37310
- email: () => email2,
37311
- e164: () => e1642,
37312
- discriminatedUnion: () => discriminatedUnion,
37313
- date: () => date3,
37314
- custom: () => custom,
37315
- cuid2: () => cuid22,
37316
- cuid: () => cuid3,
37317
- core: () => exports_core2,
37318
- config: () => config,
37319
- coerce: () => exports_coerce,
37320
- clone: () => clone,
37321
- cidrv6: () => cidrv62,
37322
- cidrv4: () => cidrv42,
37323
- check: () => check,
37324
- catch: () => _catch2,
37325
- boolean: () => boolean2,
37326
- bigint: () => bigint2,
37327
- base64url: () => base64url2,
37328
- base64: () => base642,
37329
- array: () => array,
37330
- any: () => any,
37331
- _default: () => _default2,
37332
- _ZodString: () => _ZodString,
37333
- ZodXID: () => ZodXID,
37334
- ZodVoid: () => ZodVoid,
37335
- ZodUnknown: () => ZodUnknown,
37336
- ZodUnion: () => ZodUnion,
37337
- ZodUndefined: () => ZodUndefined,
37338
- ZodUUID: () => ZodUUID,
37339
- ZodURL: () => ZodURL,
37340
- ZodULID: () => ZodULID,
37341
- ZodType: () => ZodType,
37342
- ZodTuple: () => ZodTuple,
37343
- ZodTransform: () => ZodTransform,
37344
- ZodTemplateLiteral: () => ZodTemplateLiteral,
37345
- ZodSymbol: () => ZodSymbol,
37346
- ZodSuccess: () => ZodSuccess,
37347
- ZodStringFormat: () => ZodStringFormat,
37348
- ZodString: () => ZodString,
37349
- ZodSet: () => ZodSet,
37350
- ZodRecord: () => ZodRecord,
37351
- ZodRealError: () => ZodRealError,
37352
- ZodReadonly: () => ZodReadonly,
37353
- ZodPromise: () => ZodPromise,
37354
- ZodPrefault: () => ZodPrefault,
37355
- ZodPipe: () => ZodPipe,
37356
- ZodOptional: () => ZodOptional,
37357
- ZodObject: () => ZodObject,
37358
- ZodNumberFormat: () => ZodNumberFormat,
37359
- ZodNumber: () => ZodNumber,
37360
- ZodNullable: () => ZodNullable,
37361
- ZodNull: () => ZodNull,
37362
- ZodNonOptional: () => ZodNonOptional,
37363
- ZodNever: () => ZodNever,
37364
- ZodNanoID: () => ZodNanoID,
37365
- ZodNaN: () => ZodNaN,
37366
- ZodMap: () => ZodMap,
37367
- ZodLiteral: () => ZodLiteral,
37368
- ZodLazy: () => ZodLazy,
37369
- ZodKSUID: () => ZodKSUID,
37370
- ZodJWT: () => ZodJWT,
37371
- ZodIssueCode: () => ZodIssueCode,
37372
- ZodIntersection: () => ZodIntersection,
37373
- ZodISOTime: () => ZodISOTime,
37374
- ZodISODuration: () => ZodISODuration,
37375
- ZodISODateTime: () => ZodISODateTime,
37376
- ZodISODate: () => ZodISODate,
37377
- ZodIPv6: () => ZodIPv6,
37378
- ZodIPv4: () => ZodIPv4,
37379
- ZodGUID: () => ZodGUID,
37380
- ZodFile: () => ZodFile,
37381
- ZodError: () => ZodError,
37382
- ZodEnum: () => ZodEnum,
37383
- ZodEmoji: () => ZodEmoji,
37384
- ZodEmail: () => ZodEmail,
37385
- ZodE164: () => ZodE164,
37386
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
37387
- ZodDefault: () => ZodDefault,
37388
- ZodDate: () => ZodDate,
37389
- ZodCustomStringFormat: () => ZodCustomStringFormat,
37390
- ZodCustom: () => ZodCustom,
37391
- ZodCatch: () => ZodCatch,
37392
- ZodCUID2: () => ZodCUID2,
37393
- ZodCUID: () => ZodCUID,
37394
- ZodCIDRv6: () => ZodCIDRv6,
37395
- ZodCIDRv4: () => ZodCIDRv4,
37396
- ZodBoolean: () => ZodBoolean,
37397
- ZodBigIntFormat: () => ZodBigIntFormat,
37398
- ZodBigInt: () => ZodBigInt,
37399
- ZodBase64URL: () => ZodBase64URL,
37400
- ZodBase64: () => ZodBase64,
37401
- ZodArray: () => ZodArray,
37402
- ZodAny: () => ZodAny,
37403
- TimePrecision: () => TimePrecision,
37404
- NEVER: () => NEVER,
37405
- $output: () => $output,
34626
+ $brand: () => $brand,
37406
34627
  $input: () => $input,
37407
- $brand: () => $brand
37408
- });
37409
-
37410
- // node_modules/zod/v4/core/index.js
37411
- var exports_core2 = {};
37412
- __export(exports_core2, {
37413
- version: () => version,
37414
- util: () => exports_util,
37415
- treeifyError: () => treeifyError,
37416
- toJSONSchema: () => toJSONSchema,
37417
- toDotPath: () => toDotPath,
37418
- safeParseAsync: () => safeParseAsync,
37419
- safeParse: () => safeParse,
37420
- registry: () => registry,
37421
- regexes: () => exports_regexes,
37422
- prettifyError: () => prettifyError,
37423
- parseAsync: () => parseAsync,
37424
- parse: () => parse2,
37425
- locales: () => exports_locales,
37426
- isValidJWT: () => isValidJWT,
37427
- isValidBase64URL: () => isValidBase64URL,
37428
- isValidBase64: () => isValidBase64,
37429
- globalRegistry: () => globalRegistry,
37430
- globalConfig: () => globalConfig,
37431
- function: () => _function,
37432
- formatError: () => formatError,
37433
- flattenError: () => flattenError,
37434
- config: () => config,
37435
- clone: () => clone,
37436
- _xid: () => _xid,
37437
- _void: () => _void,
37438
- _uuidv7: () => _uuidv7,
37439
- _uuidv6: () => _uuidv6,
37440
- _uuidv4: () => _uuidv4,
37441
- _uuid: () => _uuid,
37442
- _url: () => _url,
37443
- _uppercase: () => _uppercase,
37444
- _unknown: () => _unknown,
37445
- _union: () => _union,
37446
- _undefined: () => _undefined2,
37447
- _ulid: () => _ulid,
37448
- _uint64: () => _uint64,
37449
- _uint32: () => _uint32,
37450
- _tuple: () => _tuple,
37451
- _trim: () => _trim,
37452
- _transform: () => _transform,
37453
- _toUpperCase: () => _toUpperCase,
37454
- _toLowerCase: () => _toLowerCase,
37455
- _templateLiteral: () => _templateLiteral,
37456
- _symbol: () => _symbol,
37457
- _success: () => _success,
37458
- _stringbool: () => _stringbool,
37459
- _stringFormat: () => _stringFormat,
37460
- _string: () => _string,
37461
- _startsWith: () => _startsWith,
37462
- _size: () => _size,
37463
- _set: () => _set,
37464
- _safeParseAsync: () => _safeParseAsync,
37465
- _safeParse: () => _safeParse,
37466
- _regex: () => _regex,
37467
- _refine: () => _refine,
37468
- _record: () => _record,
37469
- _readonly: () => _readonly,
37470
- _property: () => _property,
37471
- _promise: () => _promise,
37472
- _positive: () => _positive,
37473
- _pipe: () => _pipe,
37474
- _parseAsync: () => _parseAsync,
37475
- _parse: () => _parse,
37476
- _overwrite: () => _overwrite,
37477
- _optional: () => _optional,
37478
- _number: () => _number,
37479
- _nullable: () => _nullable,
37480
- _null: () => _null2,
37481
- _normalize: () => _normalize,
37482
- _nonpositive: () => _nonpositive,
37483
- _nonoptional: () => _nonoptional,
37484
- _nonnegative: () => _nonnegative,
37485
- _never: () => _never,
37486
- _negative: () => _negative,
37487
- _nativeEnum: () => _nativeEnum,
37488
- _nanoid: () => _nanoid,
37489
- _nan: () => _nan,
37490
- _multipleOf: () => _multipleOf,
37491
- _minSize: () => _minSize,
37492
- _minLength: () => _minLength,
37493
- _min: () => _gte,
37494
- _mime: () => _mime,
37495
- _maxSize: () => _maxSize,
37496
- _maxLength: () => _maxLength,
37497
- _max: () => _lte,
37498
- _map: () => _map,
37499
- _lte: () => _lte,
37500
- _lt: () => _lt,
37501
- _lowercase: () => _lowercase,
37502
- _literal: () => _literal,
37503
- _length: () => _length,
37504
- _lazy: () => _lazy,
37505
- _ksuid: () => _ksuid,
37506
- _jwt: () => _jwt,
37507
- _isoTime: () => _isoTime,
37508
- _isoDuration: () => _isoDuration,
37509
- _isoDateTime: () => _isoDateTime,
37510
- _isoDate: () => _isoDate,
37511
- _ipv6: () => _ipv6,
37512
- _ipv4: () => _ipv4,
37513
- _intersection: () => _intersection,
37514
- _int64: () => _int64,
37515
- _int32: () => _int32,
37516
- _int: () => _int,
37517
- _includes: () => _includes,
37518
- _guid: () => _guid,
37519
- _gte: () => _gte,
37520
- _gt: () => _gt,
37521
- _float64: () => _float64,
37522
- _float32: () => _float32,
37523
- _file: () => _file,
37524
- _enum: () => _enum,
37525
- _endsWith: () => _endsWith,
37526
- _emoji: () => _emoji2,
37527
- _email: () => _email,
37528
- _e164: () => _e164,
37529
- _discriminatedUnion: () => _discriminatedUnion,
37530
- _default: () => _default,
37531
- _date: () => _date,
37532
- _custom: () => _custom,
37533
- _cuid2: () => _cuid2,
37534
- _cuid: () => _cuid,
37535
- _coercedString: () => _coercedString,
37536
- _coercedNumber: () => _coercedNumber,
37537
- _coercedDate: () => _coercedDate,
37538
- _coercedBoolean: () => _coercedBoolean,
37539
- _coercedBigint: () => _coercedBigint,
37540
- _cidrv6: () => _cidrv6,
37541
- _cidrv4: () => _cidrv4,
37542
- _catch: () => _catch,
37543
- _boolean: () => _boolean,
37544
- _bigint: () => _bigint,
37545
- _base64url: () => _base64url,
37546
- _base64: () => _base64,
37547
- _array: () => _array,
37548
- _any: () => _any,
37549
- TimePrecision: () => TimePrecision,
37550
- NEVER: () => NEVER,
37551
- JSONSchemaGenerator: () => JSONSchemaGenerator,
37552
- JSONSchema: () => exports_json_schema,
37553
- Doc: () => Doc,
37554
34628
  $output: () => $output,
37555
- $input: () => $input,
37556
- $constructor: () => $constructor,
37557
- $brand: () => $brand,
37558
- $ZodXID: () => $ZodXID,
37559
- $ZodVoid: () => $ZodVoid,
37560
- $ZodUnknown: () => $ZodUnknown,
37561
- $ZodUnion: () => $ZodUnion,
37562
- $ZodUndefined: () => $ZodUndefined,
37563
- $ZodUUID: () => $ZodUUID,
37564
- $ZodURL: () => $ZodURL,
37565
- $ZodULID: () => $ZodULID,
37566
- $ZodType: () => $ZodType,
37567
- $ZodTuple: () => $ZodTuple,
37568
- $ZodTransform: () => $ZodTransform,
37569
- $ZodTemplateLiteral: () => $ZodTemplateLiteral,
37570
- $ZodSymbol: () => $ZodSymbol,
37571
- $ZodSuccess: () => $ZodSuccess,
37572
- $ZodStringFormat: () => $ZodStringFormat,
37573
- $ZodString: () => $ZodString,
37574
- $ZodSet: () => $ZodSet,
37575
- $ZodRegistry: () => $ZodRegistry,
37576
- $ZodRecord: () => $ZodRecord,
37577
- $ZodRealError: () => $ZodRealError,
37578
- $ZodReadonly: () => $ZodReadonly,
37579
- $ZodPromise: () => $ZodPromise,
37580
- $ZodPrefault: () => $ZodPrefault,
37581
- $ZodPipe: () => $ZodPipe,
37582
- $ZodOptional: () => $ZodOptional,
37583
- $ZodObject: () => $ZodObject,
37584
- $ZodNumberFormat: () => $ZodNumberFormat,
37585
- $ZodNumber: () => $ZodNumber,
37586
- $ZodNullable: () => $ZodNullable,
37587
- $ZodNull: () => $ZodNull,
37588
- $ZodNonOptional: () => $ZodNonOptional,
37589
- $ZodNever: () => $ZodNever,
37590
- $ZodNanoID: () => $ZodNanoID,
37591
- $ZodNaN: () => $ZodNaN,
37592
- $ZodMap: () => $ZodMap,
37593
- $ZodLiteral: () => $ZodLiteral,
37594
- $ZodLazy: () => $ZodLazy,
37595
- $ZodKSUID: () => $ZodKSUID,
37596
- $ZodJWT: () => $ZodJWT,
37597
- $ZodIntersection: () => $ZodIntersection,
37598
- $ZodISOTime: () => $ZodISOTime,
37599
- $ZodISODuration: () => $ZodISODuration,
37600
- $ZodISODateTime: () => $ZodISODateTime,
37601
- $ZodISODate: () => $ZodISODate,
37602
- $ZodIPv6: () => $ZodIPv6,
37603
- $ZodIPv4: () => $ZodIPv4,
37604
- $ZodGUID: () => $ZodGUID,
37605
- $ZodFunction: () => $ZodFunction,
37606
- $ZodFile: () => $ZodFile,
37607
- $ZodError: () => $ZodError,
37608
- $ZodEnum: () => $ZodEnum,
37609
- $ZodEmoji: () => $ZodEmoji,
37610
- $ZodEmail: () => $ZodEmail,
37611
- $ZodE164: () => $ZodE164,
37612
- $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
37613
- $ZodDefault: () => $ZodDefault,
37614
- $ZodDate: () => $ZodDate,
37615
- $ZodCustomStringFormat: () => $ZodCustomStringFormat,
37616
- $ZodCustom: () => $ZodCustom,
37617
- $ZodCheckUpperCase: () => $ZodCheckUpperCase,
37618
- $ZodCheckStringFormat: () => $ZodCheckStringFormat,
37619
- $ZodCheckStartsWith: () => $ZodCheckStartsWith,
37620
- $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
37621
- $ZodCheckRegex: () => $ZodCheckRegex,
37622
- $ZodCheckProperty: () => $ZodCheckProperty,
37623
- $ZodCheckOverwrite: () => $ZodCheckOverwrite,
37624
- $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
37625
- $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
37626
- $ZodCheckMinSize: () => $ZodCheckMinSize,
37627
- $ZodCheckMinLength: () => $ZodCheckMinLength,
37628
- $ZodCheckMimeType: () => $ZodCheckMimeType,
37629
- $ZodCheckMaxSize: () => $ZodCheckMaxSize,
37630
- $ZodCheckMaxLength: () => $ZodCheckMaxLength,
37631
- $ZodCheckLowerCase: () => $ZodCheckLowerCase,
37632
- $ZodCheckLessThan: () => $ZodCheckLessThan,
37633
- $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
37634
- $ZodCheckIncludes: () => $ZodCheckIncludes,
37635
- $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
37636
- $ZodCheckEndsWith: () => $ZodCheckEndsWith,
37637
- $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
37638
- $ZodCheck: () => $ZodCheck,
37639
- $ZodCatch: () => $ZodCatch,
37640
- $ZodCUID2: () => $ZodCUID2,
37641
- $ZodCUID: () => $ZodCUID,
37642
- $ZodCIDRv6: () => $ZodCIDRv6,
37643
- $ZodCIDRv4: () => $ZodCIDRv4,
37644
- $ZodBoolean: () => $ZodBoolean,
37645
- $ZodBigIntFormat: () => $ZodBigIntFormat,
37646
- $ZodBigInt: () => $ZodBigInt,
37647
- $ZodBase64URL: () => $ZodBase64URL,
37648
- $ZodBase64: () => $ZodBase64,
37649
- $ZodAsyncError: () => $ZodAsyncError,
34629
+ NEVER: () => NEVER,
34630
+ TimePrecision: () => TimePrecision,
34631
+ ZodAny: () => ZodAny,
34632
+ ZodArray: () => ZodArray,
34633
+ ZodBase64: () => ZodBase64,
34634
+ ZodBase64URL: () => ZodBase64URL,
34635
+ ZodBigInt: () => ZodBigInt,
34636
+ ZodBigIntFormat: () => ZodBigIntFormat,
34637
+ ZodBoolean: () => ZodBoolean,
34638
+ ZodCIDRv4: () => ZodCIDRv4,
34639
+ ZodCIDRv6: () => ZodCIDRv6,
34640
+ ZodCUID: () => ZodCUID,
34641
+ ZodCUID2: () => ZodCUID2,
34642
+ ZodCatch: () => ZodCatch,
34643
+ ZodCustom: () => ZodCustom,
34644
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
34645
+ ZodDate: () => ZodDate,
34646
+ ZodDefault: () => ZodDefault,
34647
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
34648
+ ZodE164: () => ZodE164,
34649
+ ZodEmail: () => ZodEmail,
34650
+ ZodEmoji: () => ZodEmoji,
34651
+ ZodEnum: () => ZodEnum,
34652
+ ZodError: () => ZodError,
34653
+ ZodFile: () => ZodFile,
34654
+ ZodGUID: () => ZodGUID,
34655
+ ZodIPv4: () => ZodIPv4,
34656
+ ZodIPv6: () => ZodIPv6,
34657
+ ZodISODate: () => ZodISODate,
34658
+ ZodISODateTime: () => ZodISODateTime,
34659
+ ZodISODuration: () => ZodISODuration,
34660
+ ZodISOTime: () => ZodISOTime,
34661
+ ZodIntersection: () => ZodIntersection,
34662
+ ZodIssueCode: () => ZodIssueCode,
34663
+ ZodJWT: () => ZodJWT,
34664
+ ZodKSUID: () => ZodKSUID,
34665
+ ZodLazy: () => ZodLazy,
34666
+ ZodLiteral: () => ZodLiteral,
34667
+ ZodMap: () => ZodMap,
34668
+ ZodNaN: () => ZodNaN,
34669
+ ZodNanoID: () => ZodNanoID,
34670
+ ZodNever: () => ZodNever,
34671
+ ZodNonOptional: () => ZodNonOptional,
34672
+ ZodNull: () => ZodNull,
34673
+ ZodNullable: () => ZodNullable,
34674
+ ZodNumber: () => ZodNumber,
34675
+ ZodNumberFormat: () => ZodNumberFormat,
34676
+ ZodObject: () => ZodObject,
34677
+ ZodOptional: () => ZodOptional,
34678
+ ZodPipe: () => ZodPipe,
34679
+ ZodPrefault: () => ZodPrefault,
34680
+ ZodPromise: () => ZodPromise,
34681
+ ZodReadonly: () => ZodReadonly,
34682
+ ZodRealError: () => ZodRealError,
34683
+ ZodRecord: () => ZodRecord,
34684
+ ZodSet: () => ZodSet,
34685
+ ZodString: () => ZodString,
34686
+ ZodStringFormat: () => ZodStringFormat,
34687
+ ZodSuccess: () => ZodSuccess,
34688
+ ZodSymbol: () => ZodSymbol,
34689
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
34690
+ ZodTransform: () => ZodTransform,
34691
+ ZodTuple: () => ZodTuple,
34692
+ ZodType: () => ZodType,
34693
+ ZodULID: () => ZodULID,
34694
+ ZodURL: () => ZodURL,
34695
+ ZodUUID: () => ZodUUID,
34696
+ ZodUndefined: () => ZodUndefined,
34697
+ ZodUnion: () => ZodUnion,
34698
+ ZodUnknown: () => ZodUnknown,
34699
+ ZodVoid: () => ZodVoid,
34700
+ ZodXID: () => ZodXID,
34701
+ _ZodString: () => _ZodString,
34702
+ _default: () => _default2,
34703
+ any: () => any,
34704
+ array: () => array,
34705
+ base64: () => base642,
34706
+ base64url: () => base64url2,
34707
+ bigint: () => bigint2,
34708
+ boolean: () => boolean2,
34709
+ catch: () => _catch2,
34710
+ check: () => check,
34711
+ cidrv4: () => cidrv42,
34712
+ cidrv6: () => cidrv62,
34713
+ clone: () => clone,
34714
+ coerce: () => exports_coerce,
34715
+ config: () => config,
34716
+ core: () => exports_core2,
34717
+ cuid: () => cuid3,
34718
+ cuid2: () => cuid22,
34719
+ custom: () => custom,
34720
+ date: () => date3,
34721
+ discriminatedUnion: () => discriminatedUnion,
34722
+ e164: () => e1642,
34723
+ email: () => email2,
34724
+ emoji: () => emoji2,
34725
+ endsWith: () => _endsWith,
34726
+ enum: () => _enum2,
34727
+ file: () => file,
34728
+ flattenError: () => flattenError,
34729
+ float32: () => float32,
34730
+ float64: () => float64,
34731
+ formatError: () => formatError,
34732
+ function: () => _function,
34733
+ getErrorMap: () => getErrorMap,
34734
+ globalRegistry: () => globalRegistry,
34735
+ gt: () => _gt,
34736
+ gte: () => _gte,
34737
+ guid: () => guid2,
34738
+ includes: () => _includes,
34739
+ instanceof: () => _instanceof,
34740
+ int: () => int,
34741
+ int32: () => int32,
34742
+ int64: () => int64,
34743
+ intersection: () => intersection,
34744
+ ipv4: () => ipv42,
34745
+ ipv6: () => ipv62,
34746
+ iso: () => exports_iso,
34747
+ json: () => json,
34748
+ jwt: () => jwt,
34749
+ keyof: () => keyof,
34750
+ ksuid: () => ksuid2,
34751
+ lazy: () => lazy,
34752
+ length: () => _length,
34753
+ literal: () => literal,
34754
+ locales: () => exports_locales,
34755
+ looseObject: () => looseObject,
34756
+ lowercase: () => _lowercase,
34757
+ lt: () => _lt,
34758
+ lte: () => _lte,
34759
+ map: () => map,
34760
+ maxLength: () => _maxLength,
34761
+ maxSize: () => _maxSize,
34762
+ mime: () => _mime,
34763
+ minLength: () => _minLength,
34764
+ minSize: () => _minSize,
34765
+ multipleOf: () => _multipleOf,
34766
+ nan: () => nan,
34767
+ nanoid: () => nanoid2,
34768
+ nativeEnum: () => nativeEnum,
34769
+ negative: () => _negative,
34770
+ never: () => never,
34771
+ nonnegative: () => _nonnegative,
34772
+ nonoptional: () => nonoptional,
34773
+ nonpositive: () => _nonpositive,
34774
+ normalize: () => _normalize,
34775
+ null: () => _null3,
34776
+ nullable: () => nullable,
34777
+ nullish: () => nullish2,
34778
+ number: () => number2,
34779
+ object: () => object,
34780
+ optional: () => optional,
34781
+ overwrite: () => _overwrite,
34782
+ parse: () => parse4,
34783
+ parseAsync: () => parseAsync2,
34784
+ partialRecord: () => partialRecord,
34785
+ pipe: () => pipe,
34786
+ positive: () => _positive,
34787
+ prefault: () => prefault,
34788
+ preprocess: () => preprocess,
34789
+ prettifyError: () => prettifyError,
34790
+ promise: () => promise,
34791
+ property: () => _property,
34792
+ readonly: () => readonly,
34793
+ record: () => record,
34794
+ refine: () => refine,
34795
+ regex: () => _regex,
34796
+ regexes: () => exports_regexes,
34797
+ registry: () => registry,
34798
+ safeParse: () => safeParse2,
34799
+ safeParseAsync: () => safeParseAsync2,
34800
+ set: () => set,
34801
+ setErrorMap: () => setErrorMap,
34802
+ size: () => _size,
34803
+ startsWith: () => _startsWith,
34804
+ strictObject: () => strictObject,
34805
+ string: () => string2,
34806
+ stringFormat: () => stringFormat,
34807
+ stringbool: () => stringbool,
34808
+ success: () => success,
34809
+ superRefine: () => superRefine,
34810
+ symbol: () => symbol16,
34811
+ templateLiteral: () => templateLiteral,
34812
+ toJSONSchema: () => toJSONSchema,
34813
+ toLowerCase: () => _toLowerCase,
34814
+ toUpperCase: () => _toUpperCase,
34815
+ transform: () => transform,
34816
+ treeifyError: () => treeifyError,
34817
+ trim: () => _trim,
34818
+ tuple: () => tuple,
34819
+ uint32: () => uint32,
34820
+ uint64: () => uint64,
34821
+ ulid: () => ulid2,
34822
+ undefined: () => _undefined3,
34823
+ union: () => union,
34824
+ unknown: () => unknown,
34825
+ uppercase: () => _uppercase,
34826
+ url: () => url,
34827
+ uuid: () => uuid2,
34828
+ uuidv4: () => uuidv4,
34829
+ uuidv6: () => uuidv6,
34830
+ uuidv7: () => uuidv7,
34831
+ void: () => _void2,
34832
+ xid: () => xid2
34833
+ });
34834
+
34835
+ // node_modules/zod/v4/core/index.js
34836
+ var exports_core2 = {};
34837
+ __export(exports_core2, {
34838
+ $ZodAny: () => $ZodAny,
37650
34839
  $ZodArray: () => $ZodArray,
37651
- $ZodAny: () => $ZodAny
34840
+ $ZodAsyncError: () => $ZodAsyncError,
34841
+ $ZodBase64: () => $ZodBase64,
34842
+ $ZodBase64URL: () => $ZodBase64URL,
34843
+ $ZodBigInt: () => $ZodBigInt,
34844
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
34845
+ $ZodBoolean: () => $ZodBoolean,
34846
+ $ZodCIDRv4: () => $ZodCIDRv4,
34847
+ $ZodCIDRv6: () => $ZodCIDRv6,
34848
+ $ZodCUID: () => $ZodCUID,
34849
+ $ZodCUID2: () => $ZodCUID2,
34850
+ $ZodCatch: () => $ZodCatch,
34851
+ $ZodCheck: () => $ZodCheck,
34852
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
34853
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
34854
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
34855
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
34856
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
34857
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
34858
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
34859
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
34860
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
34861
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
34862
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
34863
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
34864
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
34865
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
34866
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
34867
+ $ZodCheckProperty: () => $ZodCheckProperty,
34868
+ $ZodCheckRegex: () => $ZodCheckRegex,
34869
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
34870
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
34871
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
34872
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
34873
+ $ZodCustom: () => $ZodCustom,
34874
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
34875
+ $ZodDate: () => $ZodDate,
34876
+ $ZodDefault: () => $ZodDefault,
34877
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
34878
+ $ZodE164: () => $ZodE164,
34879
+ $ZodEmail: () => $ZodEmail,
34880
+ $ZodEmoji: () => $ZodEmoji,
34881
+ $ZodEnum: () => $ZodEnum,
34882
+ $ZodError: () => $ZodError,
34883
+ $ZodFile: () => $ZodFile,
34884
+ $ZodFunction: () => $ZodFunction,
34885
+ $ZodGUID: () => $ZodGUID,
34886
+ $ZodIPv4: () => $ZodIPv4,
34887
+ $ZodIPv6: () => $ZodIPv6,
34888
+ $ZodISODate: () => $ZodISODate,
34889
+ $ZodISODateTime: () => $ZodISODateTime,
34890
+ $ZodISODuration: () => $ZodISODuration,
34891
+ $ZodISOTime: () => $ZodISOTime,
34892
+ $ZodIntersection: () => $ZodIntersection,
34893
+ $ZodJWT: () => $ZodJWT,
34894
+ $ZodKSUID: () => $ZodKSUID,
34895
+ $ZodLazy: () => $ZodLazy,
34896
+ $ZodLiteral: () => $ZodLiteral,
34897
+ $ZodMap: () => $ZodMap,
34898
+ $ZodNaN: () => $ZodNaN,
34899
+ $ZodNanoID: () => $ZodNanoID,
34900
+ $ZodNever: () => $ZodNever,
34901
+ $ZodNonOptional: () => $ZodNonOptional,
34902
+ $ZodNull: () => $ZodNull,
34903
+ $ZodNullable: () => $ZodNullable,
34904
+ $ZodNumber: () => $ZodNumber,
34905
+ $ZodNumberFormat: () => $ZodNumberFormat,
34906
+ $ZodObject: () => $ZodObject,
34907
+ $ZodOptional: () => $ZodOptional,
34908
+ $ZodPipe: () => $ZodPipe,
34909
+ $ZodPrefault: () => $ZodPrefault,
34910
+ $ZodPromise: () => $ZodPromise,
34911
+ $ZodReadonly: () => $ZodReadonly,
34912
+ $ZodRealError: () => $ZodRealError,
34913
+ $ZodRecord: () => $ZodRecord,
34914
+ $ZodRegistry: () => $ZodRegistry,
34915
+ $ZodSet: () => $ZodSet,
34916
+ $ZodString: () => $ZodString,
34917
+ $ZodStringFormat: () => $ZodStringFormat,
34918
+ $ZodSuccess: () => $ZodSuccess,
34919
+ $ZodSymbol: () => $ZodSymbol,
34920
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
34921
+ $ZodTransform: () => $ZodTransform,
34922
+ $ZodTuple: () => $ZodTuple,
34923
+ $ZodType: () => $ZodType,
34924
+ $ZodULID: () => $ZodULID,
34925
+ $ZodURL: () => $ZodURL,
34926
+ $ZodUUID: () => $ZodUUID,
34927
+ $ZodUndefined: () => $ZodUndefined,
34928
+ $ZodUnion: () => $ZodUnion,
34929
+ $ZodUnknown: () => $ZodUnknown,
34930
+ $ZodVoid: () => $ZodVoid,
34931
+ $ZodXID: () => $ZodXID,
34932
+ $brand: () => $brand,
34933
+ $constructor: () => $constructor,
34934
+ $input: () => $input,
34935
+ $output: () => $output,
34936
+ Doc: () => Doc,
34937
+ JSONSchema: () => exports_json_schema,
34938
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
34939
+ NEVER: () => NEVER,
34940
+ TimePrecision: () => TimePrecision,
34941
+ _any: () => _any,
34942
+ _array: () => _array,
34943
+ _base64: () => _base64,
34944
+ _base64url: () => _base64url,
34945
+ _bigint: () => _bigint,
34946
+ _boolean: () => _boolean,
34947
+ _catch: () => _catch,
34948
+ _cidrv4: () => _cidrv4,
34949
+ _cidrv6: () => _cidrv6,
34950
+ _coercedBigint: () => _coercedBigint,
34951
+ _coercedBoolean: () => _coercedBoolean,
34952
+ _coercedDate: () => _coercedDate,
34953
+ _coercedNumber: () => _coercedNumber,
34954
+ _coercedString: () => _coercedString,
34955
+ _cuid: () => _cuid,
34956
+ _cuid2: () => _cuid2,
34957
+ _custom: () => _custom,
34958
+ _date: () => _date,
34959
+ _default: () => _default,
34960
+ _discriminatedUnion: () => _discriminatedUnion,
34961
+ _e164: () => _e164,
34962
+ _email: () => _email,
34963
+ _emoji: () => _emoji2,
34964
+ _endsWith: () => _endsWith,
34965
+ _enum: () => _enum,
34966
+ _file: () => _file,
34967
+ _float32: () => _float32,
34968
+ _float64: () => _float64,
34969
+ _gt: () => _gt,
34970
+ _gte: () => _gte,
34971
+ _guid: () => _guid,
34972
+ _includes: () => _includes,
34973
+ _int: () => _int,
34974
+ _int32: () => _int32,
34975
+ _int64: () => _int64,
34976
+ _intersection: () => _intersection,
34977
+ _ipv4: () => _ipv4,
34978
+ _ipv6: () => _ipv6,
34979
+ _isoDate: () => _isoDate,
34980
+ _isoDateTime: () => _isoDateTime,
34981
+ _isoDuration: () => _isoDuration,
34982
+ _isoTime: () => _isoTime,
34983
+ _jwt: () => _jwt,
34984
+ _ksuid: () => _ksuid,
34985
+ _lazy: () => _lazy,
34986
+ _length: () => _length,
34987
+ _literal: () => _literal,
34988
+ _lowercase: () => _lowercase,
34989
+ _lt: () => _lt,
34990
+ _lte: () => _lte,
34991
+ _map: () => _map,
34992
+ _max: () => _lte,
34993
+ _maxLength: () => _maxLength,
34994
+ _maxSize: () => _maxSize,
34995
+ _mime: () => _mime,
34996
+ _min: () => _gte,
34997
+ _minLength: () => _minLength,
34998
+ _minSize: () => _minSize,
34999
+ _multipleOf: () => _multipleOf,
35000
+ _nan: () => _nan,
35001
+ _nanoid: () => _nanoid,
35002
+ _nativeEnum: () => _nativeEnum,
35003
+ _negative: () => _negative,
35004
+ _never: () => _never,
35005
+ _nonnegative: () => _nonnegative,
35006
+ _nonoptional: () => _nonoptional,
35007
+ _nonpositive: () => _nonpositive,
35008
+ _normalize: () => _normalize,
35009
+ _null: () => _null2,
35010
+ _nullable: () => _nullable,
35011
+ _number: () => _number,
35012
+ _optional: () => _optional,
35013
+ _overwrite: () => _overwrite,
35014
+ _parse: () => _parse,
35015
+ _parseAsync: () => _parseAsync,
35016
+ _pipe: () => _pipe,
35017
+ _positive: () => _positive,
35018
+ _promise: () => _promise,
35019
+ _property: () => _property,
35020
+ _readonly: () => _readonly,
35021
+ _record: () => _record,
35022
+ _refine: () => _refine,
35023
+ _regex: () => _regex,
35024
+ _safeParse: () => _safeParse,
35025
+ _safeParseAsync: () => _safeParseAsync,
35026
+ _set: () => _set,
35027
+ _size: () => _size,
35028
+ _startsWith: () => _startsWith,
35029
+ _string: () => _string,
35030
+ _stringFormat: () => _stringFormat,
35031
+ _stringbool: () => _stringbool,
35032
+ _success: () => _success,
35033
+ _symbol: () => _symbol,
35034
+ _templateLiteral: () => _templateLiteral,
35035
+ _toLowerCase: () => _toLowerCase,
35036
+ _toUpperCase: () => _toUpperCase,
35037
+ _transform: () => _transform,
35038
+ _trim: () => _trim,
35039
+ _tuple: () => _tuple,
35040
+ _uint32: () => _uint32,
35041
+ _uint64: () => _uint64,
35042
+ _ulid: () => _ulid,
35043
+ _undefined: () => _undefined2,
35044
+ _union: () => _union,
35045
+ _unknown: () => _unknown,
35046
+ _uppercase: () => _uppercase,
35047
+ _url: () => _url,
35048
+ _uuid: () => _uuid,
35049
+ _uuidv4: () => _uuidv4,
35050
+ _uuidv6: () => _uuidv6,
35051
+ _uuidv7: () => _uuidv7,
35052
+ _void: () => _void,
35053
+ _xid: () => _xid,
35054
+ clone: () => clone,
35055
+ config: () => config,
35056
+ flattenError: () => flattenError,
35057
+ formatError: () => formatError,
35058
+ function: () => _function,
35059
+ globalConfig: () => globalConfig,
35060
+ globalRegistry: () => globalRegistry,
35061
+ isValidBase64: () => isValidBase64,
35062
+ isValidBase64URL: () => isValidBase64URL,
35063
+ isValidJWT: () => isValidJWT,
35064
+ locales: () => exports_locales,
35065
+ parse: () => parse2,
35066
+ parseAsync: () => parseAsync,
35067
+ prettifyError: () => prettifyError,
35068
+ regexes: () => exports_regexes,
35069
+ registry: () => registry,
35070
+ safeParse: () => safeParse,
35071
+ safeParseAsync: () => safeParseAsync,
35072
+ toDotPath: () => toDotPath,
35073
+ toJSONSchema: () => toJSONSchema,
35074
+ treeifyError: () => treeifyError,
35075
+ util: () => exports_util,
35076
+ version: () => version
37652
35077
  });
37653
35078
 
37654
35079
  // node_modules/zod/v4/core/core.js
@@ -37714,55 +35139,55 @@ function config(newConfig) {
37714
35139
  // node_modules/zod/v4/core/util.js
37715
35140
  var exports_util = {};
37716
35141
  __export(exports_util, {
37717
- unwrapMessage: () => unwrapMessage,
37718
- stringifyPrimitive: () => stringifyPrimitive,
37719
- required: () => required,
37720
- randomString: () => randomString,
37721
- propertyKeyTypes: () => propertyKeyTypes,
37722
- promiseAllObject: () => promiseAllObject,
37723
- primitiveTypes: () => primitiveTypes,
37724
- prefixIssues: () => prefixIssues,
37725
- pick: () => pick,
37726
- partial: () => partial,
37727
- optionalKeys: () => optionalKeys,
37728
- omit: () => omit,
37729
- numKeys: () => numKeys,
37730
- nullish: () => nullish,
37731
- normalizeParams: () => normalizeParams,
37732
- merge: () => merge,
37733
- jsonStringifyReplacer: () => jsonStringifyReplacer,
37734
- joinValues: () => joinValues,
37735
- issue: () => issue,
37736
- isPlainObject: () => isPlainObject,
37737
- isObject: () => isObject,
37738
- getSizableOrigin: () => getSizableOrigin,
37739
- getParsedType: () => getParsedType,
37740
- getLengthableOrigin: () => getLengthableOrigin,
37741
- getEnumValues: () => getEnumValues,
37742
- getElementAtPath: () => getElementAtPath,
37743
- floatSafeRemainder: () => floatSafeRemainder,
37744
- finalizeIssue: () => finalizeIssue,
37745
- extend: () => extend,
37746
- escapeRegex: () => escapeRegex,
37747
- esc: () => esc,
37748
- defineLazy: () => defineLazy,
37749
- createTransparentProxy: () => createTransparentProxy,
37750
- clone: () => clone,
37751
- cleanRegex: () => cleanRegex,
37752
- cleanEnum: () => cleanEnum,
37753
- captureStackTrace: () => captureStackTrace,
37754
- cached: () => cached,
37755
- assignProp: () => assignProp,
37756
- assertNotEqual: () => assertNotEqual,
37757
- assertNever: () => assertNever,
37758
- assertIs: () => assertIs,
37759
- assertEqual: () => assertEqual,
37760
- assert: () => assert,
37761
- allowsEval: () => allowsEval,
37762
- aborted: () => aborted,
37763
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
35142
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
37764
35143
  Class: () => Class,
37765
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
35144
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
35145
+ aborted: () => aborted,
35146
+ allowsEval: () => allowsEval,
35147
+ assert: () => assert,
35148
+ assertEqual: () => assertEqual,
35149
+ assertIs: () => assertIs,
35150
+ assertNever: () => assertNever,
35151
+ assertNotEqual: () => assertNotEqual,
35152
+ assignProp: () => assignProp,
35153
+ cached: () => cached,
35154
+ captureStackTrace: () => captureStackTrace,
35155
+ cleanEnum: () => cleanEnum,
35156
+ cleanRegex: () => cleanRegex,
35157
+ clone: () => clone,
35158
+ createTransparentProxy: () => createTransparentProxy,
35159
+ defineLazy: () => defineLazy,
35160
+ esc: () => esc,
35161
+ escapeRegex: () => escapeRegex,
35162
+ extend: () => extend,
35163
+ finalizeIssue: () => finalizeIssue,
35164
+ floatSafeRemainder: () => floatSafeRemainder,
35165
+ getElementAtPath: () => getElementAtPath,
35166
+ getEnumValues: () => getEnumValues,
35167
+ getLengthableOrigin: () => getLengthableOrigin,
35168
+ getParsedType: () => getParsedType,
35169
+ getSizableOrigin: () => getSizableOrigin,
35170
+ isObject: () => isObject,
35171
+ isPlainObject: () => isPlainObject,
35172
+ issue: () => issue,
35173
+ joinValues: () => joinValues,
35174
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
35175
+ merge: () => merge,
35176
+ normalizeParams: () => normalizeParams,
35177
+ nullish: () => nullish,
35178
+ numKeys: () => numKeys,
35179
+ omit: () => omit,
35180
+ optionalKeys: () => optionalKeys,
35181
+ partial: () => partial,
35182
+ pick: () => pick,
35183
+ prefixIssues: () => prefixIssues,
35184
+ primitiveTypes: () => primitiveTypes,
35185
+ promiseAllObject: () => promiseAllObject,
35186
+ propertyKeyTypes: () => propertyKeyTypes,
35187
+ randomString: () => randomString,
35188
+ required: () => required,
35189
+ stringifyPrimitive: () => stringifyPrimitive,
35190
+ unwrapMessage: () => unwrapMessage
37766
35191
  });
37767
35192
  function assertEqual(val) {
37768
35193
  return val;
@@ -38426,47 +35851,47 @@ var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
38426
35851
  // node_modules/zod/v4/core/regexes.js
38427
35852
  var exports_regexes = {};
38428
35853
  __export(exports_regexes, {
38429
- xid: () => xid,
38430
- uuid7: () => uuid7,
38431
- uuid6: () => uuid6,
38432
- uuid4: () => uuid4,
38433
- uuid: () => uuid,
38434
- uppercase: () => uppercase,
38435
- unicodeEmail: () => unicodeEmail,
38436
- undefined: () => _undefined,
38437
- ulid: () => ulid,
38438
- time: () => time,
38439
- string: () => string,
38440
- rfc5322Email: () => rfc5322Email,
38441
- number: () => number,
38442
- null: () => _null,
38443
- nanoid: () => nanoid,
38444
- lowercase: () => lowercase,
38445
- ksuid: () => ksuid,
38446
- ipv6: () => ipv6,
38447
- ipv4: () => ipv4,
38448
- integer: () => integer,
38449
- html5Email: () => html5Email,
38450
- hostname: () => hostname,
38451
- guid: () => guid,
38452
- extendedDuration: () => extendedDuration,
38453
- emoji: () => emoji,
38454
- email: () => email,
38455
- e164: () => e164,
38456
- duration: () => duration,
38457
- domain: () => domain,
38458
- datetime: () => datetime,
38459
- date: () => date,
38460
- cuid2: () => cuid2,
38461
- cuid: () => cuid,
38462
- cidrv6: () => cidrv6,
38463
- cidrv4: () => cidrv4,
38464
- browserEmail: () => browserEmail,
38465
- boolean: () => boolean,
38466
- bigint: () => bigint,
38467
- base64url: () => base64url,
35854
+ _emoji: () => _emoji,
38468
35855
  base64: () => base64,
38469
- _emoji: () => _emoji
35856
+ base64url: () => base64url,
35857
+ bigint: () => bigint,
35858
+ boolean: () => boolean,
35859
+ browserEmail: () => browserEmail,
35860
+ cidrv4: () => cidrv4,
35861
+ cidrv6: () => cidrv6,
35862
+ cuid: () => cuid,
35863
+ cuid2: () => cuid2,
35864
+ date: () => date,
35865
+ datetime: () => datetime,
35866
+ domain: () => domain,
35867
+ duration: () => duration,
35868
+ e164: () => e164,
35869
+ email: () => email,
35870
+ emoji: () => emoji,
35871
+ extendedDuration: () => extendedDuration,
35872
+ guid: () => guid,
35873
+ hostname: () => hostname,
35874
+ html5Email: () => html5Email,
35875
+ integer: () => integer,
35876
+ ipv4: () => ipv4,
35877
+ ipv6: () => ipv6,
35878
+ ksuid: () => ksuid,
35879
+ lowercase: () => lowercase,
35880
+ nanoid: () => nanoid,
35881
+ null: () => _null,
35882
+ number: () => number,
35883
+ rfc5322Email: () => rfc5322Email,
35884
+ string: () => string,
35885
+ time: () => time,
35886
+ ulid: () => ulid,
35887
+ undefined: () => _undefined,
35888
+ unicodeEmail: () => unicodeEmail,
35889
+ uppercase: () => uppercase,
35890
+ uuid: () => uuid,
35891
+ uuid4: () => uuid4,
35892
+ uuid6: () => uuid6,
35893
+ uuid7: () => uuid7,
35894
+ xid: () => xid
38470
35895
  });
38471
35896
  var cuid = /^[cC][^\s-]{8,}$/;
38472
35897
  var cuid2 = /^[0-9a-z]+$/;
@@ -40739,45 +38164,45 @@ function handleRefineResult(result, payload, input, inst) {
40739
38164
  // node_modules/zod/v4/locales/index.js
40740
38165
  var exports_locales = {};
40741
38166
  __export(exports_locales, {
40742
- zhTW: () => zh_TW_default,
40743
- zhCN: () => zh_CN_default,
40744
- vi: () => vi_default,
40745
- ur: () => ur_default,
40746
- ua: () => ua_default,
40747
- tr: () => tr_default,
40748
- th: () => th_default,
40749
- ta: () => ta_default,
40750
- sv: () => sv_default,
40751
- sl: () => sl_default,
40752
- ru: () => ru_default,
40753
- pt: () => pt_default,
40754
- ps: () => ps_default,
40755
- pl: () => pl_default,
40756
- ota: () => ota_default,
40757
- no: () => no_default,
40758
- nl: () => nl_default,
40759
- ms: () => ms_default,
40760
- mk: () => mk_default,
40761
- ko: () => ko_default,
40762
- kh: () => kh_default,
40763
- ja: () => ja_default,
40764
- it: () => it_default,
40765
- id: () => id_default,
40766
- hu: () => hu_default,
40767
- he: () => he_default,
40768
- frCA: () => fr_CA_default,
40769
- fr: () => fr_default,
40770
- fi: () => fi_default,
40771
- fa: () => fa_default,
40772
- es: () => es_default,
40773
- eo: () => eo_default,
40774
- en: () => en_default,
40775
- de: () => de_default,
40776
- cs: () => cs_default,
40777
- ca: () => ca_default,
40778
- be: () => be_default,
38167
+ ar: () => ar_default,
40779
38168
  az: () => az_default,
40780
- ar: () => ar_default
38169
+ be: () => be_default,
38170
+ ca: () => ca_default,
38171
+ cs: () => cs_default,
38172
+ de: () => de_default,
38173
+ en: () => en_default,
38174
+ eo: () => eo_default,
38175
+ es: () => es_default,
38176
+ fa: () => fa_default,
38177
+ fi: () => fi_default,
38178
+ fr: () => fr_default,
38179
+ frCA: () => fr_CA_default,
38180
+ he: () => he_default,
38181
+ hu: () => hu_default,
38182
+ id: () => id_default,
38183
+ it: () => it_default,
38184
+ ja: () => ja_default,
38185
+ kh: () => kh_default,
38186
+ ko: () => ko_default,
38187
+ mk: () => mk_default,
38188
+ ms: () => ms_default,
38189
+ nl: () => nl_default,
38190
+ no: () => no_default,
38191
+ ota: () => ota_default,
38192
+ pl: () => pl_default,
38193
+ ps: () => ps_default,
38194
+ pt: () => pt_default,
38195
+ ru: () => ru_default,
38196
+ sl: () => sl_default,
38197
+ sv: () => sv_default,
38198
+ ta: () => ta_default,
38199
+ th: () => th_default,
38200
+ tr: () => tr_default,
38201
+ ua: () => ua_default,
38202
+ ur: () => ur_default,
38203
+ vi: () => vi_default,
38204
+ zhCN: () => zh_CN_default,
38205
+ zhTW: () => zh_TW_default
40781
38206
  });
40782
38207
 
40783
38208
  // node_modules/zod/v4/locales/ar.js
@@ -47184,14 +44609,14 @@ var exports_json_schema = {};
47184
44609
  // node_modules/zod/v4/classic/iso.js
47185
44610
  var exports_iso = {};
47186
44611
  __export(exports_iso, {
47187
- time: () => time2,
47188
- duration: () => duration2,
47189
- datetime: () => datetime2,
47190
- date: () => date2,
47191
- ZodISOTime: () => ZodISOTime,
47192
- ZodISODuration: () => ZodISODuration,
44612
+ ZodISODate: () => ZodISODate,
47193
44613
  ZodISODateTime: () => ZodISODateTime,
47194
- ZodISODate: () => ZodISODate
44614
+ ZodISODuration: () => ZodISODuration,
44615
+ ZodISOTime: () => ZodISOTime,
44616
+ date: () => date2,
44617
+ datetime: () => datetime2,
44618
+ duration: () => duration2,
44619
+ time: () => time2
47195
44620
  });
47196
44621
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
47197
44622
  $ZodISODateTime.init(inst, def);
@@ -48213,11 +45638,11 @@ function getErrorMap() {
48213
45638
  // node_modules/zod/v4/classic/coerce.js
48214
45639
  var exports_coerce = {};
48215
45640
  __export(exports_coerce, {
48216
- string: () => string3,
48217
- number: () => number3,
48218
- date: () => date4,
45641
+ bigint: () => bigint3,
48219
45642
  boolean: () => boolean3,
48220
- bigint: () => bigint3
45643
+ date: () => date4,
45644
+ number: () => number3,
45645
+ string: () => string3
48221
45646
  });
48222
45647
  function string3(params) {
48223
45648
  return _coercedString(ZodString, params);
@@ -48246,11 +45671,11 @@ class ParseError extends Error {
48246
45671
  var LF = 10;
48247
45672
  var CR = 13;
48248
45673
  var SPACE = 32;
48249
- function noop2(_arg) {}
45674
+ function noop(_arg) {}
48250
45675
  function createParser(callbacks) {
48251
45676
  if (typeof callbacks == "function")
48252
45677
  throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
48253
- const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment } = callbacks, pendingFragments = [];
45678
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
48254
45679
  let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
48255
45680
  function feed(chunk) {
48256
45681
  if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
@@ -48419,7 +45844,7 @@ var WORKFLOW_SERIALIZE = Symbol.for("workflow-serialize");
48419
45844
  var WORKFLOW_DESERIALIZE = Symbol.for("workflow-deserialize");
48420
45845
 
48421
45846
  // node_modules/@ai-sdk/provider-utils/dist/index.js
48422
- function asArray2(value) {
45847
+ function asArray(value) {
48423
45848
  return value === undefined ? [] : Array.isArray(value) ? value : [value];
48424
45849
  }
48425
45850
  function combineHeaders(...headers) {
@@ -78462,7 +75887,7 @@ async function convertToLanguageModelPrompt({
78462
75887
  }
78463
75888
  }
78464
75889
  const messages = [
78465
- ...prompt.instructions != null ? typeof prompt.instructions === "string" ? [{ role: "system", content: prompt.instructions }] : asArray2(prompt.instructions).map((message) => ({
75890
+ ...prompt.instructions != null ? typeof prompt.instructions === "string" ? [{ role: "system", content: prompt.instructions }] : asArray(prompt.instructions).map((message) => ({
78466
75891
  role: "system",
78467
75892
  content: message.content,
78468
75893
  providerOptions: message.providerOptions
@@ -79514,7 +76939,7 @@ async function standardizePrompt({
79514
76939
  message: "prompt and messages cannot be defined at the same time"
79515
76940
  });
79516
76941
  }
79517
- if (typeof instructions !== "string" && !asArray2(instructions).every((message) => message.role === "system")) {
76942
+ if (typeof instructions !== "string" && !asArray(instructions).every((message) => message.role === "system")) {
79518
76943
  throw new InvalidPromptError({
79519
76944
  prompt,
79520
76945
  message: "instructions must be a string, SystemModelMessage, or array of SystemModelMessage"
@@ -79625,7 +77050,7 @@ function now() {
79625
77050
  return (_b17 = (_a232 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a232.now()) != null ? _b17 : Date.now();
79626
77051
  }
79627
77052
  async function notify(options) {
79628
- await Promise.all(asArray2(options.callbacks).map(async (callback) => {
77053
+ await Promise.all(asArray(options.callbacks).map(async (callback) => {
79629
77054
  try {
79630
77055
  await (callback == null ? undefined : callback(options.event));
79631
77056
  } catch (e) {}
@@ -81044,7 +78469,7 @@ function createTelemetryDispatcher({
81044
78469
  return {};
81045
78470
  }
81046
78471
  const localIntegrations = telemetry == null ? undefined : telemetry.integrations;
81047
- const integrations = localIntegrations != null ? asArray2(localIntegrations) : getGlobalTelemetryIntegrations();
78472
+ const integrations = localIntegrations != null ? asArray(localIntegrations) : getGlobalTelemetryIntegrations();
81048
78473
  const telemetryMetadata = {
81049
78474
  recordInputs: telemetry == null ? undefined : telemetry.recordInputs,
81050
78475
  recordOutputs: telemetry == null ? undefined : telemetry.recordOutputs,
@@ -81916,7 +79341,7 @@ async function generateText({
81916
79341
  tools,
81917
79342
  toolCallers: experimental_toolCallers
81918
79343
  });
81919
- const stopConditions = asArray2(stopWhen);
79344
+ const stopConditions = asArray(stopWhen);
81920
79345
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
81921
79346
  const resolvedOnStepStart = onStepStart != null ? onStepStart : experimental_onStepStart;
81922
79347
  const resolvedOnLanguageModelCallStart = onLanguageModelCallStart != null ? onLanguageModelCallStart : experimental_onLanguageModelCallStart;