@mathscan/math-exercise-engine 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -45,6 +45,12 @@ export declare const AST_TYPES: {
45
45
  readonly NUMBER_LINE_COUNTER: "NumberLineCounter";
46
46
  /** A highlighted range on the number line axis */
47
47
  readonly NUMBER_LINE_HIGHLIGHT: "NumberLineHighlight";
48
+ /** Matcher layout block */
49
+ readonly MATCHER_BLOCK: "MatcherBlock";
50
+ /** Row within a matcher */
51
+ readonly MATCHER_ROW: "MatcherRow";
52
+ /** Item within a matcher row */
53
+ readonly MATCHER_ITEM: "MatcherItem";
48
54
  /** Drag-and-drop options tool */
49
55
  readonly DRAG_OPTIONS: "DragOptions";
50
56
  /** Radio button options tool */
@@ -355,6 +361,44 @@ export declare function compileWithAST(dsl: string): {
355
361
  options: string[];
356
362
  name: string;
357
363
  answer: string;
364
+ } | {
365
+ type: "MatcherBlock";
366
+ name: string;
367
+ rows: {
368
+ type: "MatcherRow";
369
+ items: {
370
+ type: "MatcherItem";
371
+ inlines: ({
372
+ value: string;
373
+ type: "FreeText";
374
+ } | {
375
+ type: "Space";
376
+ } | {
377
+ value: string;
378
+ type: "HighlightedText";
379
+ highlight?: [number, number] | undefined;
380
+ } | {
381
+ value: string;
382
+ type: "ColorText";
383
+ color: string;
384
+ highlight?: [number, number] | undefined;
385
+ } | {
386
+ value: string;
387
+ type: "BoldText";
388
+ highlight?: [number, number] | undefined;
389
+ } | {
390
+ type: "Fraction";
391
+ name: string;
392
+ simplified: boolean;
393
+ answer?: string | undefined;
394
+ numerator?: number | undefined;
395
+ denominator?: number | undefined;
396
+ })[];
397
+ itemId: string;
398
+ }[];
399
+ }[];
400
+ answers: string[][];
401
+ colors?: string[] | undefined;
358
402
  })[];
359
403
  question?: {
360
404
  value: string;
@@ -401,11 +445,25 @@ export declare function compileWithAST(dsl: string): {
401
445
  numerator: number | null;
402
446
  denominator: number | null;
403
447
  simplified: boolean;
448
+ } | {
449
+ type: "matcher";
450
+ rows: {
451
+ type: "matcher-row";
452
+ items: {
453
+ type: "matcher-item";
454
+ itemId: string;
455
+ id: string;
456
+ content: any[];
457
+ }[];
458
+ id: string;
459
+ }[];
460
+ groupCount: number;
461
+ colors?: string[] | undefined;
404
462
  }>;
405
463
  validation?: {
406
464
  mode: "simple" | "expression";
407
465
  expression?: string | undefined;
408
- answers?: Record<string, string | number> | undefined;
466
+ answers?: Record<string, string | number | string[][]> | undefined;
409
467
  variables?: string[] | undefined;
410
468
  } | undefined;
411
469
  id?: string | undefined;
@@ -1669,343 +1727,818 @@ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
1669
1727
  color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
1670
1728
  label?: string | undefined;
1671
1729
  }[] | undefined;
1672
- }>]>;
1673
-
1674
- /**
1675
- * Create a bold text inline element
1676
- */
1677
- export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
1678
-
1679
- /**
1680
- * Create a color text inline element
1681
- */
1682
- export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
1683
-
1684
- /**
1685
- * Create a drag options tool
1686
- */
1687
- export declare function createDragOptions(options: string[]): DragOptionsTool;
1688
-
1689
- /**
1690
- * Create an exercise document
1691
- */
1692
- export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: ContentBlock[], validation?: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
1693
-
1694
- /**
1695
- * Create an expression validation node
1696
- */
1697
- export declare function createExpressionValidation(expression: string): ExpressionValidation;
1698
-
1699
- /**
1700
- * Create a fraction inline widget
1701
- */
1702
- export declare function createFraction(name: string, options?: {
1703
- numerator?: number;
1704
- denominator?: number;
1705
- answer?: string;
1706
- simplified?: boolean;
1707
- }): FractionInline;
1708
-
1709
- /**
1710
- * Create a free text inline element
1711
- */
1712
- export declare function createFreeText(value: string): FreeTextInline;
1713
-
1714
- /**
1715
- * Create a highlighted text inline element
1716
- */
1717
- export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
1718
-
1719
- /**
1720
- * Create a line block
1721
- */
1722
- export declare function createLineBlock(inlines: InlineNode[]): LineBlock;
1723
-
1724
- /**
1725
- * Create a numeric inline input widget (W_N_I)
1726
- */
1727
- export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
1728
-
1729
- /**
1730
- * Create a numeric keypad tool
1731
- */
1732
- export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
1733
-
1734
- /**
1735
- * Create a simple validation node
1736
- */
1737
- export declare function createSimpleValidation(): SimpleValidation;
1738
-
1739
- /**
1740
- * Create a space inline element
1741
- */
1742
- export declare function createSpace(): SpaceInline;
1743
-
1744
- /**
1745
- * Create a string inline input widget (W_S_I)
1746
- */
1747
- export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
1748
-
1749
- /**
1750
- * Create a text block (question)
1751
- */
1752
- export declare function createTextBlock(value: string): TextBlock;
1753
-
1754
- export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
1755
-
1756
- export declare const DragOptionsJSONSchema: z.ZodObject<{
1757
- type: z.ZodLiteral<"drag-options">;
1758
- options: z.ZodArray<z.ZodString, "many">;
1759
- }, "strip", z.ZodTypeAny, {
1760
- type: "drag-options";
1761
- options: string[];
1762
- }, {
1763
- type: "drag-options";
1764
- options: string[];
1765
- }>;
1766
-
1767
- export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
1768
-
1769
- /**
1770
- * Drag options tool schema - draggable buttons/options
1771
- *
1772
- * Common use cases:
1773
- * - Comparison symbols: ["<", ">", "="]
1774
- * - Yes/No: ["نعم", "لا"]
1775
- * - Multiple choice: ["A", "B", "C", "D"]
1776
- *
1777
- * @example
1778
- * {
1779
- * type: "DragOptions",
1780
- * options: ["<", ">", "="]
1781
- * }
1782
- */
1783
- export declare const DragOptionsToolSchema: z.ZodObject<{
1784
- type: z.ZodLiteral<"DragOptions">;
1785
- options: z.ZodArray<z.ZodString, "many">;
1786
- }, "strip", z.ZodTypeAny, {
1787
- type: "DragOptions";
1788
- options: string[];
1789
- }, {
1790
- type: "DragOptions";
1791
- options: string[];
1792
- }>;
1793
-
1794
- /**
1795
- * Base error class for all engine errors
1796
- */
1797
- export declare class EngineError extends Error {
1798
- constructor(message: string);
1799
- }
1800
-
1801
- /**
1802
- * Evaluate a mathematical expression with the given variable scope
1803
- *
1804
- * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
1805
- * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
1806
- * @returns The boolean result of the expression
1807
- * @throws Error if evaluation fails
1808
- */
1809
- export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
1810
-
1811
- export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
1812
-
1813
- /**
1814
- * Exercise document schema - the complete exercise structure
1815
- *
1816
- * Structure:
1817
- * 1. Question: What the student should do
1818
- * 2. Lines: Visual rows with inline elements
1819
- * 3. Tools: Standalone interactive elements (optional)
1820
- * 4. Validation: How to check answers
1821
- *
1822
- * @example
1823
- * {
1824
- * type: "ExerciseDocument",
1825
- * question: {
1826
- * type: "TextBlock",
1827
- * value: "أقارن كل عددين باستعمال الرمر المناسب"
1828
- * },
1829
- * lines: [
1830
- * {
1831
- * type: "LineBlock",
1832
- * inlines: [
1833
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
1834
- * { type: "InlineInput", name: "x", length: 1 },
1835
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
1836
- * ]
1837
- * }
1838
- * ],
1839
- * tools: [
1840
- * { type: "DragOptions", options: ["<", ">", "="] }
1841
- * ],
1842
- * validation: {
1843
- * type: "SimpleValidation"
1844
- * }
1845
- * }
1846
- */
1847
- export declare const ExerciseDocumentSchema: z.ZodObject<{
1848
- type: z.ZodLiteral<"ExerciseDocument">;
1849
- question: z.ZodOptional<z.ZodObject<{
1850
- type: z.ZodLiteral<"TextBlock">;
1851
- value: z.ZodString;
1852
- }, "strip", z.ZodTypeAny, {
1853
- value: string;
1854
- type: "TextBlock";
1855
- }, {
1856
- value: string;
1857
- type: "TextBlock";
1858
- }>>;
1859
- lines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1860
- type: z.ZodLiteral<"LineBlock">;
1861
- inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1862
- type: z.ZodLiteral<"FreeText">;
1863
- value: z.ZodString;
1864
- }, "strip", z.ZodTypeAny, {
1865
- value: string;
1866
- type: "FreeText";
1867
- }, {
1868
- value: string;
1869
- type: "FreeText";
1870
- }>, z.ZodObject<{
1871
- type: z.ZodLiteral<"Space">;
1872
- }, "strip", z.ZodTypeAny, {
1873
- type: "Space";
1874
- }, {
1875
- type: "Space";
1876
- }>, z.ZodObject<{
1877
- type: z.ZodLiteral<"HighlightedText">;
1878
- value: z.ZodString;
1879
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1880
- }, "strip", z.ZodTypeAny, {
1881
- value: string;
1882
- type: "HighlightedText";
1883
- highlight?: [number, number] | undefined;
1884
- }, {
1885
- value: string;
1886
- type: "HighlightedText";
1887
- highlight?: [number, number] | undefined;
1888
- }>, z.ZodObject<{
1889
- type: z.ZodLiteral<"ColorText">;
1890
- value: z.ZodString;
1891
- color: z.ZodString;
1892
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1893
- }, "strip", z.ZodTypeAny, {
1894
- value: string;
1895
- type: "ColorText";
1896
- color: string;
1897
- highlight?: [number, number] | undefined;
1898
- }, {
1899
- value: string;
1900
- type: "ColorText";
1901
- color: string;
1902
- highlight?: [number, number] | undefined;
1903
- }>, z.ZodObject<{
1904
- type: z.ZodLiteral<"BoldText">;
1905
- value: z.ZodString;
1906
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1907
- }, "strip", z.ZodTypeAny, {
1908
- value: string;
1909
- type: "BoldText";
1910
- highlight?: [number, number] | undefined;
1911
- }, {
1912
- value: string;
1913
- type: "BoldText";
1914
- highlight?: [number, number] | undefined;
1915
- }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1916
- type: z.ZodLiteral<"InlineInput">;
1917
- name: z.ZodString;
1918
- inputType: z.ZodLiteral<"string">;
1919
- length: z.ZodNumber;
1920
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1921
- }, "strip", z.ZodTypeAny, {
1922
- length: number;
1923
- type: "InlineInput";
1924
- inputType: "string";
1925
- name: string;
1926
- answer?: string | number | undefined;
1927
- }, {
1928
- length: number;
1929
- type: "InlineInput";
1930
- inputType: "string";
1931
- name: string;
1932
- answer?: string | number | undefined;
1933
- }>, z.ZodObject<{
1934
- type: z.ZodLiteral<"InlineInput">;
1935
- name: z.ZodString;
1936
- inputType: z.ZodLiteral<"numeric">;
1937
- digits: z.ZodNumber;
1938
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1939
- }, "strip", z.ZodTypeAny, {
1940
- type: "InlineInput";
1941
- inputType: "numeric";
1942
- name: string;
1943
- digits: number;
1944
- answer?: string | number | undefined;
1945
- }, {
1946
- type: "InlineInput";
1947
- inputType: "numeric";
1948
- name: string;
1949
- digits: number;
1950
- answer?: string | number | undefined;
1951
- }>]>, z.ZodObject<{
1952
- type: z.ZodLiteral<"Fraction">;
1953
- name: z.ZodString;
1954
- numerator: z.ZodOptional<z.ZodNumber>;
1955
- denominator: z.ZodOptional<z.ZodNumber>;
1956
- answer: z.ZodOptional<z.ZodString>;
1957
- simplified: z.ZodDefault<z.ZodBoolean>;
1730
+ }>, z.ZodEffects<z.ZodObject<{
1731
+ type: z.ZodLiteral<"MatcherBlock">;
1732
+ name: z.ZodString;
1733
+ colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1734
+ rows: z.ZodArray<z.ZodObject<{
1735
+ type: z.ZodLiteral<"MatcherRow">;
1736
+ items: z.ZodArray<z.ZodObject<{
1737
+ type: z.ZodLiteral<"MatcherItem">;
1738
+ itemId: z.ZodString;
1739
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1740
+ type: z.ZodLiteral<"FreeText">;
1741
+ value: z.ZodString;
1742
+ }, "strip", z.ZodTypeAny, {
1743
+ value: string;
1744
+ type: "FreeText";
1745
+ }, {
1746
+ value: string;
1747
+ type: "FreeText";
1748
+ }>, z.ZodObject<{
1749
+ type: z.ZodLiteral<"Space">;
1750
+ }, "strip", z.ZodTypeAny, {
1751
+ type: "Space";
1752
+ }, {
1753
+ type: "Space";
1754
+ }>, z.ZodObject<{
1755
+ type: z.ZodLiteral<"HighlightedText">;
1756
+ value: z.ZodString;
1757
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1758
+ }, "strip", z.ZodTypeAny, {
1759
+ value: string;
1760
+ type: "HighlightedText";
1761
+ highlight?: [number, number] | undefined;
1762
+ }, {
1763
+ value: string;
1764
+ type: "HighlightedText";
1765
+ highlight?: [number, number] | undefined;
1766
+ }>, z.ZodObject<{
1767
+ type: z.ZodLiteral<"ColorText">;
1768
+ value: z.ZodString;
1769
+ color: z.ZodString;
1770
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1771
+ }, "strip", z.ZodTypeAny, {
1772
+ value: string;
1773
+ type: "ColorText";
1774
+ color: string;
1775
+ highlight?: [number, number] | undefined;
1776
+ }, {
1777
+ value: string;
1778
+ type: "ColorText";
1779
+ color: string;
1780
+ highlight?: [number, number] | undefined;
1781
+ }>, z.ZodObject<{
1782
+ type: z.ZodLiteral<"BoldText">;
1783
+ value: z.ZodString;
1784
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1785
+ }, "strip", z.ZodTypeAny, {
1786
+ value: string;
1787
+ type: "BoldText";
1788
+ highlight?: [number, number] | undefined;
1789
+ }, {
1790
+ value: string;
1791
+ type: "BoldText";
1792
+ highlight?: [number, number] | undefined;
1793
+ }>, z.ZodEffects<z.ZodObject<{
1794
+ type: z.ZodLiteral<"Fraction">;
1795
+ name: z.ZodString;
1796
+ numerator: z.ZodOptional<z.ZodNumber>;
1797
+ denominator: z.ZodOptional<z.ZodNumber>;
1798
+ answer: z.ZodOptional<z.ZodString>;
1799
+ simplified: z.ZodDefault<z.ZodBoolean>;
1800
+ }, "strip", z.ZodTypeAny, {
1801
+ type: "Fraction";
1802
+ name: string;
1803
+ simplified: boolean;
1804
+ answer?: string | undefined;
1805
+ numerator?: number | undefined;
1806
+ denominator?: number | undefined;
1807
+ }, {
1808
+ type: "Fraction";
1809
+ name: string;
1810
+ answer?: string | undefined;
1811
+ numerator?: number | undefined;
1812
+ denominator?: number | undefined;
1813
+ simplified?: boolean | undefined;
1814
+ }>, {
1815
+ type: "Fraction";
1816
+ name: string;
1817
+ simplified: boolean;
1818
+ answer?: string | undefined;
1819
+ numerator?: number | undefined;
1820
+ denominator?: number | undefined;
1821
+ }, {
1822
+ type: "Fraction";
1823
+ name: string;
1824
+ answer?: string | undefined;
1825
+ numerator?: number | undefined;
1826
+ denominator?: number | undefined;
1827
+ simplified?: boolean | undefined;
1828
+ }>]>, "many">;
1958
1829
  }, "strip", z.ZodTypeAny, {
1959
- type: "Fraction";
1960
- name: string;
1961
- simplified: boolean;
1962
- answer?: string | undefined;
1963
- numerator?: number | undefined;
1964
- denominator?: number | undefined;
1830
+ type: "MatcherItem";
1831
+ inlines: ({
1832
+ value: string;
1833
+ type: "FreeText";
1834
+ } | {
1835
+ type: "Space";
1836
+ } | {
1837
+ value: string;
1838
+ type: "HighlightedText";
1839
+ highlight?: [number, number] | undefined;
1840
+ } | {
1841
+ value: string;
1842
+ type: "ColorText";
1843
+ color: string;
1844
+ highlight?: [number, number] | undefined;
1845
+ } | {
1846
+ value: string;
1847
+ type: "BoldText";
1848
+ highlight?: [number, number] | undefined;
1849
+ } | {
1850
+ type: "Fraction";
1851
+ name: string;
1852
+ simplified: boolean;
1853
+ answer?: string | undefined;
1854
+ numerator?: number | undefined;
1855
+ denominator?: number | undefined;
1856
+ })[];
1857
+ itemId: string;
1965
1858
  }, {
1966
- type: "Fraction";
1967
- name: string;
1968
- answer?: string | undefined;
1969
- numerator?: number | undefined;
1970
- denominator?: number | undefined;
1971
- simplified?: boolean | undefined;
1972
- }>]>, "many">;
1859
+ type: "MatcherItem";
1860
+ inlines: ({
1861
+ value: string;
1862
+ type: "FreeText";
1863
+ } | {
1864
+ type: "Space";
1865
+ } | {
1866
+ value: string;
1867
+ type: "HighlightedText";
1868
+ highlight?: [number, number] | undefined;
1869
+ } | {
1870
+ value: string;
1871
+ type: "ColorText";
1872
+ color: string;
1873
+ highlight?: [number, number] | undefined;
1874
+ } | {
1875
+ value: string;
1876
+ type: "BoldText";
1877
+ highlight?: [number, number] | undefined;
1878
+ } | {
1879
+ type: "Fraction";
1880
+ name: string;
1881
+ answer?: string | undefined;
1882
+ numerator?: number | undefined;
1883
+ denominator?: number | undefined;
1884
+ simplified?: boolean | undefined;
1885
+ })[];
1886
+ itemId: string;
1887
+ }>, "many">;
1973
1888
  }, "strip", z.ZodTypeAny, {
1974
- type: "LineBlock";
1975
- inlines: ({
1976
- value: string;
1977
- type: "FreeText";
1978
- } | {
1979
- type: "Space";
1980
- } | {
1981
- value: string;
1982
- type: "HighlightedText";
1983
- highlight?: [number, number] | undefined;
1984
- } | {
1985
- value: string;
1986
- type: "ColorText";
1987
- color: string;
1988
- highlight?: [number, number] | undefined;
1989
- } | {
1990
- value: string;
1991
- type: "BoldText";
1992
- highlight?: [number, number] | undefined;
1993
- } | {
1994
- length: number;
1995
- type: "InlineInput";
1996
- inputType: "string";
1997
- name: string;
1998
- answer?: string | number | undefined;
1999
- } | {
2000
- type: "InlineInput";
2001
- inputType: "numeric";
2002
- name: string;
2003
- digits: number;
2004
- answer?: string | number | undefined;
2005
- } | {
2006
- type: "Fraction";
2007
- name: string;
2008
- simplified: boolean;
1889
+ type: "MatcherRow";
1890
+ items: {
1891
+ type: "MatcherItem";
1892
+ inlines: ({
1893
+ value: string;
1894
+ type: "FreeText";
1895
+ } | {
1896
+ type: "Space";
1897
+ } | {
1898
+ value: string;
1899
+ type: "HighlightedText";
1900
+ highlight?: [number, number] | undefined;
1901
+ } | {
1902
+ value: string;
1903
+ type: "ColorText";
1904
+ color: string;
1905
+ highlight?: [number, number] | undefined;
1906
+ } | {
1907
+ value: string;
1908
+ type: "BoldText";
1909
+ highlight?: [number, number] | undefined;
1910
+ } | {
1911
+ type: "Fraction";
1912
+ name: string;
1913
+ simplified: boolean;
1914
+ answer?: string | undefined;
1915
+ numerator?: number | undefined;
1916
+ denominator?: number | undefined;
1917
+ })[];
1918
+ itemId: string;
1919
+ }[];
1920
+ }, {
1921
+ type: "MatcherRow";
1922
+ items: {
1923
+ type: "MatcherItem";
1924
+ inlines: ({
1925
+ value: string;
1926
+ type: "FreeText";
1927
+ } | {
1928
+ type: "Space";
1929
+ } | {
1930
+ value: string;
1931
+ type: "HighlightedText";
1932
+ highlight?: [number, number] | undefined;
1933
+ } | {
1934
+ value: string;
1935
+ type: "ColorText";
1936
+ color: string;
1937
+ highlight?: [number, number] | undefined;
1938
+ } | {
1939
+ value: string;
1940
+ type: "BoldText";
1941
+ highlight?: [number, number] | undefined;
1942
+ } | {
1943
+ type: "Fraction";
1944
+ name: string;
1945
+ answer?: string | undefined;
1946
+ numerator?: number | undefined;
1947
+ denominator?: number | undefined;
1948
+ simplified?: boolean | undefined;
1949
+ })[];
1950
+ itemId: string;
1951
+ }[];
1952
+ }>, "many">;
1953
+ answers: z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">;
1954
+ }, "strip", z.ZodTypeAny, {
1955
+ type: "MatcherBlock";
1956
+ name: string;
1957
+ rows: {
1958
+ type: "MatcherRow";
1959
+ items: {
1960
+ type: "MatcherItem";
1961
+ inlines: ({
1962
+ value: string;
1963
+ type: "FreeText";
1964
+ } | {
1965
+ type: "Space";
1966
+ } | {
1967
+ value: string;
1968
+ type: "HighlightedText";
1969
+ highlight?: [number, number] | undefined;
1970
+ } | {
1971
+ value: string;
1972
+ type: "ColorText";
1973
+ color: string;
1974
+ highlight?: [number, number] | undefined;
1975
+ } | {
1976
+ value: string;
1977
+ type: "BoldText";
1978
+ highlight?: [number, number] | undefined;
1979
+ } | {
1980
+ type: "Fraction";
1981
+ name: string;
1982
+ simplified: boolean;
1983
+ answer?: string | undefined;
1984
+ numerator?: number | undefined;
1985
+ denominator?: number | undefined;
1986
+ })[];
1987
+ itemId: string;
1988
+ }[];
1989
+ }[];
1990
+ answers: string[][];
1991
+ colors?: string[] | undefined;
1992
+ }, {
1993
+ type: "MatcherBlock";
1994
+ name: string;
1995
+ rows: {
1996
+ type: "MatcherRow";
1997
+ items: {
1998
+ type: "MatcherItem";
1999
+ inlines: ({
2000
+ value: string;
2001
+ type: "FreeText";
2002
+ } | {
2003
+ type: "Space";
2004
+ } | {
2005
+ value: string;
2006
+ type: "HighlightedText";
2007
+ highlight?: [number, number] | undefined;
2008
+ } | {
2009
+ value: string;
2010
+ type: "ColorText";
2011
+ color: string;
2012
+ highlight?: [number, number] | undefined;
2013
+ } | {
2014
+ value: string;
2015
+ type: "BoldText";
2016
+ highlight?: [number, number] | undefined;
2017
+ } | {
2018
+ type: "Fraction";
2019
+ name: string;
2020
+ answer?: string | undefined;
2021
+ numerator?: number | undefined;
2022
+ denominator?: number | undefined;
2023
+ simplified?: boolean | undefined;
2024
+ })[];
2025
+ itemId: string;
2026
+ }[];
2027
+ }[];
2028
+ answers: string[][];
2029
+ colors?: string[] | undefined;
2030
+ }>, {
2031
+ type: "MatcherBlock";
2032
+ name: string;
2033
+ rows: {
2034
+ type: "MatcherRow";
2035
+ items: {
2036
+ type: "MatcherItem";
2037
+ inlines: ({
2038
+ value: string;
2039
+ type: "FreeText";
2040
+ } | {
2041
+ type: "Space";
2042
+ } | {
2043
+ value: string;
2044
+ type: "HighlightedText";
2045
+ highlight?: [number, number] | undefined;
2046
+ } | {
2047
+ value: string;
2048
+ type: "ColorText";
2049
+ color: string;
2050
+ highlight?: [number, number] | undefined;
2051
+ } | {
2052
+ value: string;
2053
+ type: "BoldText";
2054
+ highlight?: [number, number] | undefined;
2055
+ } | {
2056
+ type: "Fraction";
2057
+ name: string;
2058
+ simplified: boolean;
2059
+ answer?: string | undefined;
2060
+ numerator?: number | undefined;
2061
+ denominator?: number | undefined;
2062
+ })[];
2063
+ itemId: string;
2064
+ }[];
2065
+ }[];
2066
+ answers: string[][];
2067
+ colors?: string[] | undefined;
2068
+ }, {
2069
+ type: "MatcherBlock";
2070
+ name: string;
2071
+ rows: {
2072
+ type: "MatcherRow";
2073
+ items: {
2074
+ type: "MatcherItem";
2075
+ inlines: ({
2076
+ value: string;
2077
+ type: "FreeText";
2078
+ } | {
2079
+ type: "Space";
2080
+ } | {
2081
+ value: string;
2082
+ type: "HighlightedText";
2083
+ highlight?: [number, number] | undefined;
2084
+ } | {
2085
+ value: string;
2086
+ type: "ColorText";
2087
+ color: string;
2088
+ highlight?: [number, number] | undefined;
2089
+ } | {
2090
+ value: string;
2091
+ type: "BoldText";
2092
+ highlight?: [number, number] | undefined;
2093
+ } | {
2094
+ type: "Fraction";
2095
+ name: string;
2096
+ answer?: string | undefined;
2097
+ numerator?: number | undefined;
2098
+ denominator?: number | undefined;
2099
+ simplified?: boolean | undefined;
2100
+ })[];
2101
+ itemId: string;
2102
+ }[];
2103
+ }[];
2104
+ answers: string[][];
2105
+ colors?: string[] | undefined;
2106
+ }>]>;
2107
+
2108
+ /**
2109
+ * Create a bold text inline element
2110
+ */
2111
+ export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
2112
+
2113
+ /**
2114
+ * Create a color text inline element
2115
+ */
2116
+ export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
2117
+
2118
+ /**
2119
+ * Create a drag options tool
2120
+ */
2121
+ export declare function createDragOptions(options: string[]): DragOptionsTool;
2122
+
2123
+ /**
2124
+ * Create an exercise document
2125
+ */
2126
+ export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: ContentBlock[], validation?: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
2127
+
2128
+ /**
2129
+ * Create an expression validation node
2130
+ */
2131
+ export declare function createExpressionValidation(expression: string): ExpressionValidation;
2132
+
2133
+ /**
2134
+ * Create a fraction inline widget
2135
+ */
2136
+ export declare function createFraction(name: string, options?: {
2137
+ numerator?: number;
2138
+ denominator?: number;
2139
+ answer?: string;
2140
+ simplified?: boolean;
2141
+ }): FractionInline;
2142
+
2143
+ /**
2144
+ * Create a free text inline element
2145
+ */
2146
+ export declare function createFreeText(value: string): FreeTextInline;
2147
+
2148
+ /**
2149
+ * Create a highlighted text inline element
2150
+ */
2151
+ export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
2152
+
2153
+ /**
2154
+ * Create a line block
2155
+ */
2156
+ export declare function createLineBlock(inlines: InlineNode[]): LineBlock;
2157
+
2158
+ export declare function createMatcherBlock(name: string, rows: MatcherRow[], answers: string[][], colors?: string[]): MatcherBlock;
2159
+
2160
+ export declare function createMatcherItem(itemId: string, inlines: DisplayInlineNode[]): MatcherItem;
2161
+
2162
+ export declare function createMatcherRow(items: MatcherItem[]): MatcherRow;
2163
+
2164
+ /**
2165
+ * Create a numeric inline input widget (W_N_I)
2166
+ */
2167
+ export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
2168
+
2169
+ /**
2170
+ * Create a numeric keypad tool
2171
+ */
2172
+ export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
2173
+
2174
+ /**
2175
+ * Create a simple validation node
2176
+ */
2177
+ export declare function createSimpleValidation(): SimpleValidation;
2178
+
2179
+ /**
2180
+ * Create a space inline element
2181
+ */
2182
+ export declare function createSpace(): SpaceInline;
2183
+
2184
+ /**
2185
+ * Create a string inline input widget (W_S_I)
2186
+ */
2187
+ export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
2188
+
2189
+ /**
2190
+ * Create a text block (question)
2191
+ */
2192
+ export declare function createTextBlock(value: string): TextBlock;
2193
+
2194
+ export declare type DisplayInlineNode = z.infer<typeof DisplayInlineNodeSchema>;
2195
+
2196
+ export declare const DisplayInlineNodeSchema: z.ZodUnion<[z.ZodObject<{
2197
+ type: z.ZodLiteral<"FreeText">;
2198
+ value: z.ZodString;
2199
+ }, "strip", z.ZodTypeAny, {
2200
+ value: string;
2201
+ type: "FreeText";
2202
+ }, {
2203
+ value: string;
2204
+ type: "FreeText";
2205
+ }>, z.ZodObject<{
2206
+ type: z.ZodLiteral<"Space">;
2207
+ }, "strip", z.ZodTypeAny, {
2208
+ type: "Space";
2209
+ }, {
2210
+ type: "Space";
2211
+ }>, z.ZodObject<{
2212
+ type: z.ZodLiteral<"HighlightedText">;
2213
+ value: z.ZodString;
2214
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2215
+ }, "strip", z.ZodTypeAny, {
2216
+ value: string;
2217
+ type: "HighlightedText";
2218
+ highlight?: [number, number] | undefined;
2219
+ }, {
2220
+ value: string;
2221
+ type: "HighlightedText";
2222
+ highlight?: [number, number] | undefined;
2223
+ }>, z.ZodObject<{
2224
+ type: z.ZodLiteral<"ColorText">;
2225
+ value: z.ZodString;
2226
+ color: z.ZodString;
2227
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2228
+ }, "strip", z.ZodTypeAny, {
2229
+ value: string;
2230
+ type: "ColorText";
2231
+ color: string;
2232
+ highlight?: [number, number] | undefined;
2233
+ }, {
2234
+ value: string;
2235
+ type: "ColorText";
2236
+ color: string;
2237
+ highlight?: [number, number] | undefined;
2238
+ }>, z.ZodObject<{
2239
+ type: z.ZodLiteral<"BoldText">;
2240
+ value: z.ZodString;
2241
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2242
+ }, "strip", z.ZodTypeAny, {
2243
+ value: string;
2244
+ type: "BoldText";
2245
+ highlight?: [number, number] | undefined;
2246
+ }, {
2247
+ value: string;
2248
+ type: "BoldText";
2249
+ highlight?: [number, number] | undefined;
2250
+ }>, z.ZodEffects<z.ZodObject<{
2251
+ type: z.ZodLiteral<"Fraction">;
2252
+ name: z.ZodString;
2253
+ numerator: z.ZodOptional<z.ZodNumber>;
2254
+ denominator: z.ZodOptional<z.ZodNumber>;
2255
+ answer: z.ZodOptional<z.ZodString>;
2256
+ simplified: z.ZodDefault<z.ZodBoolean>;
2257
+ }, "strip", z.ZodTypeAny, {
2258
+ type: "Fraction";
2259
+ name: string;
2260
+ simplified: boolean;
2261
+ answer?: string | undefined;
2262
+ numerator?: number | undefined;
2263
+ denominator?: number | undefined;
2264
+ }, {
2265
+ type: "Fraction";
2266
+ name: string;
2267
+ answer?: string | undefined;
2268
+ numerator?: number | undefined;
2269
+ denominator?: number | undefined;
2270
+ simplified?: boolean | undefined;
2271
+ }>, {
2272
+ type: "Fraction";
2273
+ name: string;
2274
+ simplified: boolean;
2275
+ answer?: string | undefined;
2276
+ numerator?: number | undefined;
2277
+ denominator?: number | undefined;
2278
+ }, {
2279
+ type: "Fraction";
2280
+ name: string;
2281
+ answer?: string | undefined;
2282
+ numerator?: number | undefined;
2283
+ denominator?: number | undefined;
2284
+ simplified?: boolean | undefined;
2285
+ }>]>;
2286
+
2287
+ export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
2288
+
2289
+ export declare const DragOptionsJSONSchema: z.ZodObject<{
2290
+ type: z.ZodLiteral<"drag-options">;
2291
+ options: z.ZodArray<z.ZodString, "many">;
2292
+ }, "strip", z.ZodTypeAny, {
2293
+ type: "drag-options";
2294
+ options: string[];
2295
+ }, {
2296
+ type: "drag-options";
2297
+ options: string[];
2298
+ }>;
2299
+
2300
+ export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
2301
+
2302
+ /**
2303
+ * Drag options tool schema - draggable buttons/options
2304
+ *
2305
+ * Common use cases:
2306
+ * - Comparison symbols: ["<", ">", "="]
2307
+ * - Yes/No: ["نعم", "لا"]
2308
+ * - Multiple choice: ["A", "B", "C", "D"]
2309
+ *
2310
+ * @example
2311
+ * {
2312
+ * type: "DragOptions",
2313
+ * options: ["<", ">", "="]
2314
+ * }
2315
+ */
2316
+ export declare const DragOptionsToolSchema: z.ZodObject<{
2317
+ type: z.ZodLiteral<"DragOptions">;
2318
+ options: z.ZodArray<z.ZodString, "many">;
2319
+ }, "strip", z.ZodTypeAny, {
2320
+ type: "DragOptions";
2321
+ options: string[];
2322
+ }, {
2323
+ type: "DragOptions";
2324
+ options: string[];
2325
+ }>;
2326
+
2327
+ /**
2328
+ * Base error class for all engine errors
2329
+ */
2330
+ export declare class EngineError extends Error {
2331
+ constructor(message: string);
2332
+ }
2333
+
2334
+ /**
2335
+ * Evaluate a mathematical expression with the given variable scope
2336
+ *
2337
+ * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
2338
+ * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
2339
+ * @returns The boolean result of the expression
2340
+ * @throws Error if evaluation fails
2341
+ */
2342
+ export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
2343
+
2344
+ export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
2345
+
2346
+ /**
2347
+ * Exercise document schema - the complete exercise structure
2348
+ *
2349
+ * Structure:
2350
+ * 1. Question: What the student should do
2351
+ * 2. Lines: Visual rows with inline elements
2352
+ * 3. Tools: Standalone interactive elements (optional)
2353
+ * 4. Validation: How to check answers
2354
+ *
2355
+ * @example
2356
+ * {
2357
+ * type: "ExerciseDocument",
2358
+ * question: {
2359
+ * type: "TextBlock",
2360
+ * value: "أقارن كل عددين باستعمال الرمر المناسب"
2361
+ * },
2362
+ * lines: [
2363
+ * {
2364
+ * type: "LineBlock",
2365
+ * inlines: [
2366
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
2367
+ * { type: "InlineInput", name: "x", length: 1 },
2368
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
2369
+ * ]
2370
+ * }
2371
+ * ],
2372
+ * tools: [
2373
+ * { type: "DragOptions", options: ["<", ">", "="] }
2374
+ * ],
2375
+ * validation: {
2376
+ * type: "SimpleValidation"
2377
+ * }
2378
+ * }
2379
+ */
2380
+ export declare const ExerciseDocumentSchema: z.ZodObject<{
2381
+ type: z.ZodLiteral<"ExerciseDocument">;
2382
+ question: z.ZodOptional<z.ZodObject<{
2383
+ type: z.ZodLiteral<"TextBlock">;
2384
+ value: z.ZodString;
2385
+ }, "strip", z.ZodTypeAny, {
2386
+ value: string;
2387
+ type: "TextBlock";
2388
+ }, {
2389
+ value: string;
2390
+ type: "TextBlock";
2391
+ }>>;
2392
+ lines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2393
+ type: z.ZodLiteral<"LineBlock">;
2394
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2395
+ type: z.ZodLiteral<"FreeText">;
2396
+ value: z.ZodString;
2397
+ }, "strip", z.ZodTypeAny, {
2398
+ value: string;
2399
+ type: "FreeText";
2400
+ }, {
2401
+ value: string;
2402
+ type: "FreeText";
2403
+ }>, z.ZodObject<{
2404
+ type: z.ZodLiteral<"Space">;
2405
+ }, "strip", z.ZodTypeAny, {
2406
+ type: "Space";
2407
+ }, {
2408
+ type: "Space";
2409
+ }>, z.ZodObject<{
2410
+ type: z.ZodLiteral<"HighlightedText">;
2411
+ value: z.ZodString;
2412
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2413
+ }, "strip", z.ZodTypeAny, {
2414
+ value: string;
2415
+ type: "HighlightedText";
2416
+ highlight?: [number, number] | undefined;
2417
+ }, {
2418
+ value: string;
2419
+ type: "HighlightedText";
2420
+ highlight?: [number, number] | undefined;
2421
+ }>, z.ZodObject<{
2422
+ type: z.ZodLiteral<"ColorText">;
2423
+ value: z.ZodString;
2424
+ color: z.ZodString;
2425
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2426
+ }, "strip", z.ZodTypeAny, {
2427
+ value: string;
2428
+ type: "ColorText";
2429
+ color: string;
2430
+ highlight?: [number, number] | undefined;
2431
+ }, {
2432
+ value: string;
2433
+ type: "ColorText";
2434
+ color: string;
2435
+ highlight?: [number, number] | undefined;
2436
+ }>, z.ZodObject<{
2437
+ type: z.ZodLiteral<"BoldText">;
2438
+ value: z.ZodString;
2439
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2440
+ }, "strip", z.ZodTypeAny, {
2441
+ value: string;
2442
+ type: "BoldText";
2443
+ highlight?: [number, number] | undefined;
2444
+ }, {
2445
+ value: string;
2446
+ type: "BoldText";
2447
+ highlight?: [number, number] | undefined;
2448
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
2449
+ type: z.ZodLiteral<"InlineInput">;
2450
+ name: z.ZodString;
2451
+ inputType: z.ZodLiteral<"string">;
2452
+ length: z.ZodNumber;
2453
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2454
+ }, "strip", z.ZodTypeAny, {
2455
+ length: number;
2456
+ type: "InlineInput";
2457
+ inputType: "string";
2458
+ name: string;
2459
+ answer?: string | number | undefined;
2460
+ }, {
2461
+ length: number;
2462
+ type: "InlineInput";
2463
+ inputType: "string";
2464
+ name: string;
2465
+ answer?: string | number | undefined;
2466
+ }>, z.ZodObject<{
2467
+ type: z.ZodLiteral<"InlineInput">;
2468
+ name: z.ZodString;
2469
+ inputType: z.ZodLiteral<"numeric">;
2470
+ digits: z.ZodNumber;
2471
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2472
+ }, "strip", z.ZodTypeAny, {
2473
+ type: "InlineInput";
2474
+ inputType: "numeric";
2475
+ name: string;
2476
+ digits: number;
2477
+ answer?: string | number | undefined;
2478
+ }, {
2479
+ type: "InlineInput";
2480
+ inputType: "numeric";
2481
+ name: string;
2482
+ digits: number;
2483
+ answer?: string | number | undefined;
2484
+ }>]>, z.ZodObject<{
2485
+ type: z.ZodLiteral<"Fraction">;
2486
+ name: z.ZodString;
2487
+ numerator: z.ZodOptional<z.ZodNumber>;
2488
+ denominator: z.ZodOptional<z.ZodNumber>;
2489
+ answer: z.ZodOptional<z.ZodString>;
2490
+ simplified: z.ZodDefault<z.ZodBoolean>;
2491
+ }, "strip", z.ZodTypeAny, {
2492
+ type: "Fraction";
2493
+ name: string;
2494
+ simplified: boolean;
2495
+ answer?: string | undefined;
2496
+ numerator?: number | undefined;
2497
+ denominator?: number | undefined;
2498
+ }, {
2499
+ type: "Fraction";
2500
+ name: string;
2501
+ answer?: string | undefined;
2502
+ numerator?: number | undefined;
2503
+ denominator?: number | undefined;
2504
+ simplified?: boolean | undefined;
2505
+ }>]>, "many">;
2506
+ }, "strip", z.ZodTypeAny, {
2507
+ type: "LineBlock";
2508
+ inlines: ({
2509
+ value: string;
2510
+ type: "FreeText";
2511
+ } | {
2512
+ type: "Space";
2513
+ } | {
2514
+ value: string;
2515
+ type: "HighlightedText";
2516
+ highlight?: [number, number] | undefined;
2517
+ } | {
2518
+ value: string;
2519
+ type: "ColorText";
2520
+ color: string;
2521
+ highlight?: [number, number] | undefined;
2522
+ } | {
2523
+ value: string;
2524
+ type: "BoldText";
2525
+ highlight?: [number, number] | undefined;
2526
+ } | {
2527
+ length: number;
2528
+ type: "InlineInput";
2529
+ inputType: "string";
2530
+ name: string;
2531
+ answer?: string | number | undefined;
2532
+ } | {
2533
+ type: "InlineInput";
2534
+ inputType: "numeric";
2535
+ name: string;
2536
+ digits: number;
2537
+ answer?: string | number | undefined;
2538
+ } | {
2539
+ type: "Fraction";
2540
+ name: string;
2541
+ simplified: boolean;
2009
2542
  answer?: string | undefined;
2010
2543
  numerator?: number | undefined;
2011
2544
  denominator?: number | undefined;
@@ -2626,19 +3159,107 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
2626
3159
  }, "strip", z.ZodTypeAny, {
2627
3160
  type: "Fraction";
2628
3161
  name: string;
2629
- simplified: boolean;
2630
- answer?: string | undefined;
2631
- numerator?: number | undefined;
2632
- denominator?: number | undefined;
2633
- }, {
3162
+ simplified: boolean;
3163
+ answer?: string | undefined;
3164
+ numerator?: number | undefined;
3165
+ denominator?: number | undefined;
3166
+ }, {
3167
+ type: "Fraction";
3168
+ name: string;
3169
+ answer?: string | undefined;
3170
+ numerator?: number | undefined;
3171
+ denominator?: number | undefined;
3172
+ simplified?: boolean | undefined;
3173
+ }>]>, "many">;
3174
+ }, "strip", z.ZodTypeAny, {
3175
+ value: number;
3176
+ type: "NumberLinePosition";
3177
+ inlines: ({
3178
+ value: string;
3179
+ type: "FreeText";
3180
+ } | {
3181
+ type: "Space";
3182
+ } | {
3183
+ value: string;
3184
+ type: "HighlightedText";
3185
+ highlight?: [number, number] | undefined;
3186
+ } | {
3187
+ value: string;
3188
+ type: "ColorText";
3189
+ color: string;
3190
+ highlight?: [number, number] | undefined;
3191
+ } | {
3192
+ value: string;
3193
+ type: "BoldText";
3194
+ highlight?: [number, number] | undefined;
3195
+ } | {
3196
+ length: number;
3197
+ type: "InlineInput";
3198
+ inputType: "string";
3199
+ name: string;
3200
+ answer?: string | number | undefined;
3201
+ } | {
3202
+ type: "InlineInput";
3203
+ inputType: "numeric";
3204
+ name: string;
3205
+ digits: number;
3206
+ answer?: string | number | undefined;
3207
+ } | {
3208
+ type: "Fraction";
3209
+ name: string;
3210
+ simplified: boolean;
3211
+ answer?: string | undefined;
3212
+ numerator?: number | undefined;
3213
+ denominator?: number | undefined;
3214
+ })[];
3215
+ }, {
3216
+ value: number;
3217
+ type: "NumberLinePosition";
3218
+ inlines: ({
3219
+ value: string;
3220
+ type: "FreeText";
3221
+ } | {
3222
+ type: "Space";
3223
+ } | {
3224
+ value: string;
3225
+ type: "HighlightedText";
3226
+ highlight?: [number, number] | undefined;
3227
+ } | {
3228
+ value: string;
3229
+ type: "ColorText";
3230
+ color: string;
3231
+ highlight?: [number, number] | undefined;
3232
+ } | {
3233
+ value: string;
3234
+ type: "BoldText";
3235
+ highlight?: [number, number] | undefined;
3236
+ } | {
3237
+ length: number;
3238
+ type: "InlineInput";
3239
+ inputType: "string";
3240
+ name: string;
3241
+ answer?: string | number | undefined;
3242
+ } | {
3243
+ type: "InlineInput";
3244
+ inputType: "numeric";
3245
+ name: string;
3246
+ digits: number;
3247
+ answer?: string | number | undefined;
3248
+ } | {
2634
3249
  type: "Fraction";
2635
3250
  name: string;
2636
3251
  answer?: string | undefined;
2637
3252
  numerator?: number | undefined;
2638
3253
  denominator?: number | undefined;
2639
3254
  simplified?: boolean | undefined;
2640
- }>]>, "many">;
2641
- }, "strip", z.ZodTypeAny, {
3255
+ })[];
3256
+ }>, "many">;
3257
+ }, "strip", z.ZodTypeAny, {
3258
+ type: "NumberLineBlock";
3259
+ min: number;
3260
+ max: number;
3261
+ step: number;
3262
+ positions: {
2642
3263
  value: number;
2643
3264
  type: "NumberLinePosition";
2644
3265
  inlines: ({
@@ -2679,7 +3300,29 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
2679
3300
  numerator?: number | undefined;
2680
3301
  denominator?: number | undefined;
2681
3302
  })[];
2682
- }, {
3303
+ }[];
3304
+ counter?: {
3305
+ type: "NumberLineCounter";
3306
+ min: number;
3307
+ max: number;
3308
+ name?: string | undefined;
3309
+ default?: number | undefined;
3310
+ } | undefined;
3311
+ minorTicks?: number | undefined;
3312
+ style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3313
+ labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3314
+ highlights?: {
3315
+ type: "NumberLineHighlight";
3316
+ from: number;
3317
+ to: number;
3318
+ color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3319
+ label?: string | undefined;
3320
+ }[] | undefined;
3321
+ }, {
3322
+ type: "NumberLineBlock";
3323
+ min: number;
3324
+ max: number;
3325
+ positions: {
2683
3326
  value: number;
2684
3327
  type: "NumberLinePosition";
2685
3328
  inlines: ({
@@ -2720,8 +3363,26 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
2720
3363
  denominator?: number | undefined;
2721
3364
  simplified?: boolean | undefined;
2722
3365
  })[];
2723
- }>, "many">;
2724
- }, "strip", z.ZodTypeAny, {
3366
+ }[];
3367
+ counter?: {
3368
+ type: "NumberLineCounter";
3369
+ min: number;
3370
+ max: number;
3371
+ name?: string | undefined;
3372
+ default?: number | undefined;
3373
+ } | undefined;
3374
+ step?: number | undefined;
3375
+ minorTicks?: number | undefined;
3376
+ style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3377
+ labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3378
+ highlights?: {
3379
+ type: "NumberLineHighlight";
3380
+ from: number;
3381
+ to: number;
3382
+ color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3383
+ label?: string | undefined;
3384
+ }[] | undefined;
3385
+ }>, {
2725
3386
  type: "NumberLineBlock";
2726
3387
  min: number;
2727
3388
  max: number;
@@ -2896,215 +3557,463 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
2896
3557
  denominator?: number | undefined;
2897
3558
  })[];
2898
3559
  }[];
2899
- counter?: {
2900
- type: "NumberLineCounter";
2901
- min: number;
2902
- max: number;
2903
- name?: string | undefined;
2904
- default?: number | undefined;
2905
- } | undefined;
2906
- minorTicks?: number | undefined;
2907
- style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
2908
- labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
2909
- highlights?: {
2910
- type: "NumberLineHighlight";
2911
- from: number;
2912
- to: number;
2913
- color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
2914
- label?: string | undefined;
2915
- }[] | undefined;
3560
+ counter?: {
3561
+ type: "NumberLineCounter";
3562
+ min: number;
3563
+ max: number;
3564
+ name?: string | undefined;
3565
+ default?: number | undefined;
3566
+ } | undefined;
3567
+ minorTicks?: number | undefined;
3568
+ style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3569
+ labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3570
+ highlights?: {
3571
+ type: "NumberLineHighlight";
3572
+ from: number;
3573
+ to: number;
3574
+ color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3575
+ label?: string | undefined;
3576
+ }[] | undefined;
3577
+ }, {
3578
+ type: "NumberLineBlock";
3579
+ min: number;
3580
+ max: number;
3581
+ positions: {
3582
+ value: number;
3583
+ type: "NumberLinePosition";
3584
+ inlines: ({
3585
+ value: string;
3586
+ type: "FreeText";
3587
+ } | {
3588
+ type: "Space";
3589
+ } | {
3590
+ value: string;
3591
+ type: "HighlightedText";
3592
+ highlight?: [number, number] | undefined;
3593
+ } | {
3594
+ value: string;
3595
+ type: "ColorText";
3596
+ color: string;
3597
+ highlight?: [number, number] | undefined;
3598
+ } | {
3599
+ value: string;
3600
+ type: "BoldText";
3601
+ highlight?: [number, number] | undefined;
3602
+ } | {
3603
+ length: number;
3604
+ type: "InlineInput";
3605
+ inputType: "string";
3606
+ name: string;
3607
+ answer?: string | number | undefined;
3608
+ } | {
3609
+ type: "InlineInput";
3610
+ inputType: "numeric";
3611
+ name: string;
3612
+ digits: number;
3613
+ answer?: string | number | undefined;
3614
+ } | {
3615
+ type: "Fraction";
3616
+ name: string;
3617
+ answer?: string | undefined;
3618
+ numerator?: number | undefined;
3619
+ denominator?: number | undefined;
3620
+ simplified?: boolean | undefined;
3621
+ })[];
3622
+ }[];
3623
+ counter?: {
3624
+ type: "NumberLineCounter";
3625
+ min: number;
3626
+ max: number;
3627
+ name?: string | undefined;
3628
+ default?: number | undefined;
3629
+ } | undefined;
3630
+ step?: number | undefined;
3631
+ minorTicks?: number | undefined;
3632
+ style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3633
+ labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3634
+ highlights?: {
3635
+ type: "NumberLineHighlight";
3636
+ from: number;
3637
+ to: number;
3638
+ color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3639
+ label?: string | undefined;
3640
+ }[] | undefined;
3641
+ }>, z.ZodEffects<z.ZodObject<{
3642
+ type: z.ZodLiteral<"MatcherBlock">;
3643
+ name: z.ZodString;
3644
+ colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3645
+ rows: z.ZodArray<z.ZodObject<{
3646
+ type: z.ZodLiteral<"MatcherRow">;
3647
+ items: z.ZodArray<z.ZodObject<{
3648
+ type: z.ZodLiteral<"MatcherItem">;
3649
+ itemId: z.ZodString;
3650
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
3651
+ type: z.ZodLiteral<"FreeText">;
3652
+ value: z.ZodString;
3653
+ }, "strip", z.ZodTypeAny, {
3654
+ value: string;
3655
+ type: "FreeText";
3656
+ }, {
3657
+ value: string;
3658
+ type: "FreeText";
3659
+ }>, z.ZodObject<{
3660
+ type: z.ZodLiteral<"Space">;
3661
+ }, "strip", z.ZodTypeAny, {
3662
+ type: "Space";
3663
+ }, {
3664
+ type: "Space";
3665
+ }>, z.ZodObject<{
3666
+ type: z.ZodLiteral<"HighlightedText">;
3667
+ value: z.ZodString;
3668
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3669
+ }, "strip", z.ZodTypeAny, {
3670
+ value: string;
3671
+ type: "HighlightedText";
3672
+ highlight?: [number, number] | undefined;
3673
+ }, {
3674
+ value: string;
3675
+ type: "HighlightedText";
3676
+ highlight?: [number, number] | undefined;
3677
+ }>, z.ZodObject<{
3678
+ type: z.ZodLiteral<"ColorText">;
3679
+ value: z.ZodString;
3680
+ color: z.ZodString;
3681
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3682
+ }, "strip", z.ZodTypeAny, {
3683
+ value: string;
3684
+ type: "ColorText";
3685
+ color: string;
3686
+ highlight?: [number, number] | undefined;
3687
+ }, {
3688
+ value: string;
3689
+ type: "ColorText";
3690
+ color: string;
3691
+ highlight?: [number, number] | undefined;
3692
+ }>, z.ZodObject<{
3693
+ type: z.ZodLiteral<"BoldText">;
3694
+ value: z.ZodString;
3695
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3696
+ }, "strip", z.ZodTypeAny, {
3697
+ value: string;
3698
+ type: "BoldText";
3699
+ highlight?: [number, number] | undefined;
3700
+ }, {
3701
+ value: string;
3702
+ type: "BoldText";
3703
+ highlight?: [number, number] | undefined;
3704
+ }>, z.ZodEffects<z.ZodObject<{
3705
+ type: z.ZodLiteral<"Fraction">;
3706
+ name: z.ZodString;
3707
+ numerator: z.ZodOptional<z.ZodNumber>;
3708
+ denominator: z.ZodOptional<z.ZodNumber>;
3709
+ answer: z.ZodOptional<z.ZodString>;
3710
+ simplified: z.ZodDefault<z.ZodBoolean>;
3711
+ }, "strip", z.ZodTypeAny, {
3712
+ type: "Fraction";
3713
+ name: string;
3714
+ simplified: boolean;
3715
+ answer?: string | undefined;
3716
+ numerator?: number | undefined;
3717
+ denominator?: number | undefined;
3718
+ }, {
3719
+ type: "Fraction";
3720
+ name: string;
3721
+ answer?: string | undefined;
3722
+ numerator?: number | undefined;
3723
+ denominator?: number | undefined;
3724
+ simplified?: boolean | undefined;
3725
+ }>, {
3726
+ type: "Fraction";
3727
+ name: string;
3728
+ simplified: boolean;
3729
+ answer?: string | undefined;
3730
+ numerator?: number | undefined;
3731
+ denominator?: number | undefined;
3732
+ }, {
3733
+ type: "Fraction";
3734
+ name: string;
3735
+ answer?: string | undefined;
3736
+ numerator?: number | undefined;
3737
+ denominator?: number | undefined;
3738
+ simplified?: boolean | undefined;
3739
+ }>]>, "many">;
3740
+ }, "strip", z.ZodTypeAny, {
3741
+ type: "MatcherItem";
3742
+ inlines: ({
3743
+ value: string;
3744
+ type: "FreeText";
3745
+ } | {
3746
+ type: "Space";
3747
+ } | {
3748
+ value: string;
3749
+ type: "HighlightedText";
3750
+ highlight?: [number, number] | undefined;
3751
+ } | {
3752
+ value: string;
3753
+ type: "ColorText";
3754
+ color: string;
3755
+ highlight?: [number, number] | undefined;
3756
+ } | {
3757
+ value: string;
3758
+ type: "BoldText";
3759
+ highlight?: [number, number] | undefined;
3760
+ } | {
3761
+ type: "Fraction";
3762
+ name: string;
3763
+ simplified: boolean;
3764
+ answer?: string | undefined;
3765
+ numerator?: number | undefined;
3766
+ denominator?: number | undefined;
3767
+ })[];
3768
+ itemId: string;
3769
+ }, {
3770
+ type: "MatcherItem";
3771
+ inlines: ({
3772
+ value: string;
3773
+ type: "FreeText";
3774
+ } | {
3775
+ type: "Space";
3776
+ } | {
3777
+ value: string;
3778
+ type: "HighlightedText";
3779
+ highlight?: [number, number] | undefined;
3780
+ } | {
3781
+ value: string;
3782
+ type: "ColorText";
3783
+ color: string;
3784
+ highlight?: [number, number] | undefined;
3785
+ } | {
3786
+ value: string;
3787
+ type: "BoldText";
3788
+ highlight?: [number, number] | undefined;
3789
+ } | {
3790
+ type: "Fraction";
3791
+ name: string;
3792
+ answer?: string | undefined;
3793
+ numerator?: number | undefined;
3794
+ denominator?: number | undefined;
3795
+ simplified?: boolean | undefined;
3796
+ })[];
3797
+ itemId: string;
3798
+ }>, "many">;
3799
+ }, "strip", z.ZodTypeAny, {
3800
+ type: "MatcherRow";
3801
+ items: {
3802
+ type: "MatcherItem";
3803
+ inlines: ({
3804
+ value: string;
3805
+ type: "FreeText";
3806
+ } | {
3807
+ type: "Space";
3808
+ } | {
3809
+ value: string;
3810
+ type: "HighlightedText";
3811
+ highlight?: [number, number] | undefined;
3812
+ } | {
3813
+ value: string;
3814
+ type: "ColorText";
3815
+ color: string;
3816
+ highlight?: [number, number] | undefined;
3817
+ } | {
3818
+ value: string;
3819
+ type: "BoldText";
3820
+ highlight?: [number, number] | undefined;
3821
+ } | {
3822
+ type: "Fraction";
3823
+ name: string;
3824
+ simplified: boolean;
3825
+ answer?: string | undefined;
3826
+ numerator?: number | undefined;
3827
+ denominator?: number | undefined;
3828
+ })[];
3829
+ itemId: string;
3830
+ }[];
3831
+ }, {
3832
+ type: "MatcherRow";
3833
+ items: {
3834
+ type: "MatcherItem";
3835
+ inlines: ({
3836
+ value: string;
3837
+ type: "FreeText";
3838
+ } | {
3839
+ type: "Space";
3840
+ } | {
3841
+ value: string;
3842
+ type: "HighlightedText";
3843
+ highlight?: [number, number] | undefined;
3844
+ } | {
3845
+ value: string;
3846
+ type: "ColorText";
3847
+ color: string;
3848
+ highlight?: [number, number] | undefined;
3849
+ } | {
3850
+ value: string;
3851
+ type: "BoldText";
3852
+ highlight?: [number, number] | undefined;
3853
+ } | {
3854
+ type: "Fraction";
3855
+ name: string;
3856
+ answer?: string | undefined;
3857
+ numerator?: number | undefined;
3858
+ denominator?: number | undefined;
3859
+ simplified?: boolean | undefined;
3860
+ })[];
3861
+ itemId: string;
3862
+ }[];
3863
+ }>, "many">;
3864
+ answers: z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">;
3865
+ }, "strip", z.ZodTypeAny, {
3866
+ type: "MatcherBlock";
3867
+ name: string;
3868
+ rows: {
3869
+ type: "MatcherRow";
3870
+ items: {
3871
+ type: "MatcherItem";
3872
+ inlines: ({
3873
+ value: string;
3874
+ type: "FreeText";
3875
+ } | {
3876
+ type: "Space";
3877
+ } | {
3878
+ value: string;
3879
+ type: "HighlightedText";
3880
+ highlight?: [number, number] | undefined;
3881
+ } | {
3882
+ value: string;
3883
+ type: "ColorText";
3884
+ color: string;
3885
+ highlight?: [number, number] | undefined;
3886
+ } | {
3887
+ value: string;
3888
+ type: "BoldText";
3889
+ highlight?: [number, number] | undefined;
3890
+ } | {
3891
+ type: "Fraction";
3892
+ name: string;
3893
+ simplified: boolean;
3894
+ answer?: string | undefined;
3895
+ numerator?: number | undefined;
3896
+ denominator?: number | undefined;
3897
+ })[];
3898
+ itemId: string;
3899
+ }[];
3900
+ }[];
3901
+ answers: string[][];
3902
+ colors?: string[] | undefined;
2916
3903
  }, {
2917
- type: "NumberLineBlock";
2918
- min: number;
2919
- max: number;
2920
- positions: {
2921
- value: number;
2922
- type: "NumberLinePosition";
2923
- inlines: ({
2924
- value: string;
2925
- type: "FreeText";
2926
- } | {
2927
- type: "Space";
2928
- } | {
2929
- value: string;
2930
- type: "HighlightedText";
2931
- highlight?: [number, number] | undefined;
2932
- } | {
2933
- value: string;
2934
- type: "ColorText";
2935
- color: string;
2936
- highlight?: [number, number] | undefined;
2937
- } | {
2938
- value: string;
2939
- type: "BoldText";
2940
- highlight?: [number, number] | undefined;
2941
- } | {
2942
- length: number;
2943
- type: "InlineInput";
2944
- inputType: "string";
2945
- name: string;
2946
- answer?: string | number | undefined;
2947
- } | {
2948
- type: "InlineInput";
2949
- inputType: "numeric";
2950
- name: string;
2951
- digits: number;
2952
- answer?: string | number | undefined;
2953
- } | {
2954
- type: "Fraction";
2955
- name: string;
2956
- answer?: string | undefined;
2957
- numerator?: number | undefined;
2958
- denominator?: number | undefined;
2959
- simplified?: boolean | undefined;
2960
- })[];
2961
- }[];
2962
- counter?: {
2963
- type: "NumberLineCounter";
2964
- min: number;
2965
- max: number;
2966
- name?: string | undefined;
2967
- default?: number | undefined;
2968
- } | undefined;
2969
- step?: number | undefined;
2970
- minorTicks?: number | undefined;
2971
- style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
2972
- labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
2973
- highlights?: {
2974
- type: "NumberLineHighlight";
2975
- from: number;
2976
- to: number;
2977
- color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
2978
- label?: string | undefined;
2979
- }[] | undefined;
2980
- }>, {
2981
- type: "NumberLineBlock";
2982
- min: number;
2983
- max: number;
2984
- step: number;
2985
- positions: {
2986
- value: number;
2987
- type: "NumberLinePosition";
2988
- inlines: ({
2989
- value: string;
2990
- type: "FreeText";
2991
- } | {
2992
- type: "Space";
2993
- } | {
2994
- value: string;
2995
- type: "HighlightedText";
2996
- highlight?: [number, number] | undefined;
2997
- } | {
2998
- value: string;
2999
- type: "ColorText";
3000
- color: string;
3001
- highlight?: [number, number] | undefined;
3002
- } | {
3003
- value: string;
3004
- type: "BoldText";
3005
- highlight?: [number, number] | undefined;
3006
- } | {
3007
- length: number;
3008
- type: "InlineInput";
3009
- inputType: "string";
3010
- name: string;
3011
- answer?: string | number | undefined;
3012
- } | {
3013
- type: "InlineInput";
3014
- inputType: "numeric";
3015
- name: string;
3016
- digits: number;
3017
- answer?: string | number | undefined;
3018
- } | {
3019
- type: "Fraction";
3020
- name: string;
3021
- simplified: boolean;
3022
- answer?: string | undefined;
3023
- numerator?: number | undefined;
3024
- denominator?: number | undefined;
3025
- })[];
3904
+ type: "MatcherBlock";
3905
+ name: string;
3906
+ rows: {
3907
+ type: "MatcherRow";
3908
+ items: {
3909
+ type: "MatcherItem";
3910
+ inlines: ({
3911
+ value: string;
3912
+ type: "FreeText";
3913
+ } | {
3914
+ type: "Space";
3915
+ } | {
3916
+ value: string;
3917
+ type: "HighlightedText";
3918
+ highlight?: [number, number] | undefined;
3919
+ } | {
3920
+ value: string;
3921
+ type: "ColorText";
3922
+ color: string;
3923
+ highlight?: [number, number] | undefined;
3924
+ } | {
3925
+ value: string;
3926
+ type: "BoldText";
3927
+ highlight?: [number, number] | undefined;
3928
+ } | {
3929
+ type: "Fraction";
3930
+ name: string;
3931
+ answer?: string | undefined;
3932
+ numerator?: number | undefined;
3933
+ denominator?: number | undefined;
3934
+ simplified?: boolean | undefined;
3935
+ })[];
3936
+ itemId: string;
3937
+ }[];
3026
3938
  }[];
3027
- counter?: {
3028
- type: "NumberLineCounter";
3029
- min: number;
3030
- max: number;
3031
- name?: string | undefined;
3032
- default?: number | undefined;
3033
- } | undefined;
3034
- minorTicks?: number | undefined;
3035
- style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3036
- labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3037
- highlights?: {
3038
- type: "NumberLineHighlight";
3039
- from: number;
3040
- to: number;
3041
- color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3042
- label?: string | undefined;
3043
- }[] | undefined;
3939
+ answers: string[][];
3940
+ colors?: string[] | undefined;
3941
+ }>, {
3942
+ type: "MatcherBlock";
3943
+ name: string;
3944
+ rows: {
3945
+ type: "MatcherRow";
3946
+ items: {
3947
+ type: "MatcherItem";
3948
+ inlines: ({
3949
+ value: string;
3950
+ type: "FreeText";
3951
+ } | {
3952
+ type: "Space";
3953
+ } | {
3954
+ value: string;
3955
+ type: "HighlightedText";
3956
+ highlight?: [number, number] | undefined;
3957
+ } | {
3958
+ value: string;
3959
+ type: "ColorText";
3960
+ color: string;
3961
+ highlight?: [number, number] | undefined;
3962
+ } | {
3963
+ value: string;
3964
+ type: "BoldText";
3965
+ highlight?: [number, number] | undefined;
3966
+ } | {
3967
+ type: "Fraction";
3968
+ name: string;
3969
+ simplified: boolean;
3970
+ answer?: string | undefined;
3971
+ numerator?: number | undefined;
3972
+ denominator?: number | undefined;
3973
+ })[];
3974
+ itemId: string;
3975
+ }[];
3976
+ }[];
3977
+ answers: string[][];
3978
+ colors?: string[] | undefined;
3044
3979
  }, {
3045
- type: "NumberLineBlock";
3046
- min: number;
3047
- max: number;
3048
- positions: {
3049
- value: number;
3050
- type: "NumberLinePosition";
3051
- inlines: ({
3052
- value: string;
3053
- type: "FreeText";
3054
- } | {
3055
- type: "Space";
3056
- } | {
3057
- value: string;
3058
- type: "HighlightedText";
3059
- highlight?: [number, number] | undefined;
3060
- } | {
3061
- value: string;
3062
- type: "ColorText";
3063
- color: string;
3064
- highlight?: [number, number] | undefined;
3065
- } | {
3066
- value: string;
3067
- type: "BoldText";
3068
- highlight?: [number, number] | undefined;
3069
- } | {
3070
- length: number;
3071
- type: "InlineInput";
3072
- inputType: "string";
3073
- name: string;
3074
- answer?: string | number | undefined;
3075
- } | {
3076
- type: "InlineInput";
3077
- inputType: "numeric";
3078
- name: string;
3079
- digits: number;
3080
- answer?: string | number | undefined;
3081
- } | {
3082
- type: "Fraction";
3083
- name: string;
3084
- answer?: string | undefined;
3085
- numerator?: number | undefined;
3086
- denominator?: number | undefined;
3087
- simplified?: boolean | undefined;
3088
- })[];
3980
+ type: "MatcherBlock";
3981
+ name: string;
3982
+ rows: {
3983
+ type: "MatcherRow";
3984
+ items: {
3985
+ type: "MatcherItem";
3986
+ inlines: ({
3987
+ value: string;
3988
+ type: "FreeText";
3989
+ } | {
3990
+ type: "Space";
3991
+ } | {
3992
+ value: string;
3993
+ type: "HighlightedText";
3994
+ highlight?: [number, number] | undefined;
3995
+ } | {
3996
+ value: string;
3997
+ type: "ColorText";
3998
+ color: string;
3999
+ highlight?: [number, number] | undefined;
4000
+ } | {
4001
+ value: string;
4002
+ type: "BoldText";
4003
+ highlight?: [number, number] | undefined;
4004
+ } | {
4005
+ type: "Fraction";
4006
+ name: string;
4007
+ answer?: string | undefined;
4008
+ numerator?: number | undefined;
4009
+ denominator?: number | undefined;
4010
+ simplified?: boolean | undefined;
4011
+ })[];
4012
+ itemId: string;
4013
+ }[];
3089
4014
  }[];
3090
- counter?: {
3091
- type: "NumberLineCounter";
3092
- min: number;
3093
- max: number;
3094
- name?: string | undefined;
3095
- default?: number | undefined;
3096
- } | undefined;
3097
- step?: number | undefined;
3098
- minorTicks?: number | undefined;
3099
- style?: "arrow-right" | "arrow-left" | "arrow-both" | "line" | undefined;
3100
- labelVisibility?: "all" | "extremes" | "min-only" | "max-only" | "none" | undefined;
3101
- highlights?: {
3102
- type: "NumberLineHighlight";
3103
- from: number;
3104
- to: number;
3105
- color?: "blue" | "red" | "green" | "orange" | "purple" | "yellow" | undefined;
3106
- label?: string | undefined;
3107
- }[] | undefined;
4015
+ answers: string[][];
4016
+ colors?: string[] | undefined;
3108
4017
  }>]>, "many">;
3109
4018
  tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3110
4019
  type: z.ZodLiteral<"DragOptions">;
@@ -3303,6 +4212,44 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
3303
4212
  options: string[];
3304
4213
  name: string;
3305
4214
  answer: string;
4215
+ } | {
4216
+ type: "MatcherBlock";
4217
+ name: string;
4218
+ rows: {
4219
+ type: "MatcherRow";
4220
+ items: {
4221
+ type: "MatcherItem";
4222
+ inlines: ({
4223
+ value: string;
4224
+ type: "FreeText";
4225
+ } | {
4226
+ type: "Space";
4227
+ } | {
4228
+ value: string;
4229
+ type: "HighlightedText";
4230
+ highlight?: [number, number] | undefined;
4231
+ } | {
4232
+ value: string;
4233
+ type: "ColorText";
4234
+ color: string;
4235
+ highlight?: [number, number] | undefined;
4236
+ } | {
4237
+ value: string;
4238
+ type: "BoldText";
4239
+ highlight?: [number, number] | undefined;
4240
+ } | {
4241
+ type: "Fraction";
4242
+ name: string;
4243
+ simplified: boolean;
4244
+ answer?: string | undefined;
4245
+ numerator?: number | undefined;
4246
+ denominator?: number | undefined;
4247
+ })[];
4248
+ itemId: string;
4249
+ }[];
4250
+ }[];
4251
+ answers: string[][];
4252
+ colors?: string[] | undefined;
3306
4253
  })[];
3307
4254
  question?: {
3308
4255
  value: string;
@@ -3481,6 +4428,44 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
3481
4428
  options: string[];
3482
4429
  name: string;
3483
4430
  answer: string;
4431
+ } | {
4432
+ type: "MatcherBlock";
4433
+ name: string;
4434
+ rows: {
4435
+ type: "MatcherRow";
4436
+ items: {
4437
+ type: "MatcherItem";
4438
+ inlines: ({
4439
+ value: string;
4440
+ type: "FreeText";
4441
+ } | {
4442
+ type: "Space";
4443
+ } | {
4444
+ value: string;
4445
+ type: "HighlightedText";
4446
+ highlight?: [number, number] | undefined;
4447
+ } | {
4448
+ value: string;
4449
+ type: "ColorText";
4450
+ color: string;
4451
+ highlight?: [number, number] | undefined;
4452
+ } | {
4453
+ value: string;
4454
+ type: "BoldText";
4455
+ highlight?: [number, number] | undefined;
4456
+ } | {
4457
+ type: "Fraction";
4458
+ name: string;
4459
+ answer?: string | undefined;
4460
+ numerator?: number | undefined;
4461
+ denominator?: number | undefined;
4462
+ simplified?: boolean | undefined;
4463
+ })[];
4464
+ itemId: string;
4465
+ }[];
4466
+ }[];
4467
+ answers: string[][];
4468
+ colors?: string[] | undefined;
3484
4469
  })[];
3485
4470
  question?: {
3486
4471
  value: string;
@@ -3577,21 +4562,95 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
3577
4562
  numerator: number | null;
3578
4563
  denominator: number | null;
3579
4564
  simplified: boolean;
4565
+ }>, z.ZodObject<{
4566
+ type: z.ZodLiteral<"matcher">;
4567
+ rows: z.ZodArray<z.ZodObject<{
4568
+ id: z.ZodString;
4569
+ type: z.ZodLiteral<"matcher-row">;
4570
+ items: z.ZodArray<z.ZodObject<{
4571
+ id: z.ZodString;
4572
+ type: z.ZodLiteral<"matcher-item">;
4573
+ /** Item identifier (no pipe allowed) */
4574
+ itemId: z.ZodString;
4575
+ /** Display-only inline content */
4576
+ content: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
4577
+ }, "strip", z.ZodTypeAny, {
4578
+ type: "matcher-item";
4579
+ itemId: string;
4580
+ id: string;
4581
+ content: any[];
4582
+ }, {
4583
+ type: "matcher-item";
4584
+ itemId: string;
4585
+ id: string;
4586
+ content: any[];
4587
+ }>, "many">;
4588
+ }, "strip", z.ZodTypeAny, {
4589
+ type: "matcher-row";
4590
+ items: {
4591
+ type: "matcher-item";
4592
+ itemId: string;
4593
+ id: string;
4594
+ content: any[];
4595
+ }[];
4596
+ id: string;
4597
+ }, {
4598
+ type: "matcher-row";
4599
+ items: {
4600
+ type: "matcher-item";
4601
+ itemId: string;
4602
+ id: string;
4603
+ content: any[];
4604
+ }[];
4605
+ id: string;
4606
+ }>, "many">;
4607
+ /** Optional color palette for the renderer (one color per answer group) */
4608
+ colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
4609
+ /** Number of answer groups — equals answers.length, stored here to avoid prop-drilling. */
4610
+ groupCount: z.ZodNumber;
4611
+ }, "strip", z.ZodTypeAny, {
4612
+ type: "matcher";
4613
+ rows: {
4614
+ type: "matcher-row";
4615
+ items: {
4616
+ type: "matcher-item";
4617
+ itemId: string;
4618
+ id: string;
4619
+ content: any[];
4620
+ }[];
4621
+ id: string;
4622
+ }[];
4623
+ groupCount: number;
4624
+ colors?: string[] | undefined;
4625
+ }, {
4626
+ type: "matcher";
4627
+ rows: {
4628
+ type: "matcher-row";
4629
+ items: {
4630
+ type: "matcher-item";
4631
+ itemId: string;
4632
+ id: string;
4633
+ content: any[];
4634
+ }[];
4635
+ id: string;
4636
+ }[];
4637
+ groupCount: number;
4638
+ colors?: string[] | undefined;
3580
4639
  }>]>>;
3581
4640
  validation: z.ZodOptional<z.ZodObject<{
3582
4641
  mode: z.ZodEnum<["simple", "expression"]>;
3583
- answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
4642
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">]>>>;
3584
4643
  expression: z.ZodOptional<z.ZodString>;
3585
4644
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3586
4645
  }, "strip", z.ZodTypeAny, {
3587
4646
  mode: "simple" | "expression";
3588
4647
  expression?: string | undefined;
3589
- answers?: Record<string, string | number> | undefined;
4648
+ answers?: Record<string, string | number | string[][]> | undefined;
3590
4649
  variables?: string[] | undefined;
3591
4650
  }, {
3592
4651
  mode: "simple" | "expression";
3593
4652
  expression?: string | undefined;
3594
- answers?: Record<string, string | number> | undefined;
4653
+ answers?: Record<string, string | number | string[][]> | undefined;
3595
4654
  variables?: string[] | undefined;
3596
4655
  }>>;
3597
4656
  meta: z.ZodOptional<z.ZodObject<{
@@ -3636,11 +4695,25 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
3636
4695
  numerator: number | null;
3637
4696
  denominator: number | null;
3638
4697
  simplified: boolean;
4698
+ } | {
4699
+ type: "matcher";
4700
+ rows: {
4701
+ type: "matcher-row";
4702
+ items: {
4703
+ type: "matcher-item";
4704
+ itemId: string;
4705
+ id: string;
4706
+ content: any[];
4707
+ }[];
4708
+ id: string;
4709
+ }[];
4710
+ groupCount: number;
4711
+ colors?: string[] | undefined;
3639
4712
  }>;
3640
4713
  validation?: {
3641
4714
  mode: "simple" | "expression";
3642
4715
  expression?: string | undefined;
3643
- answers?: Record<string, string | number> | undefined;
4716
+ answers?: Record<string, string | number | string[][]> | undefined;
3644
4717
  variables?: string[] | undefined;
3645
4718
  } | undefined;
3646
4719
  id?: string | undefined;
@@ -3676,11 +4749,25 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
3676
4749
  numerator: number | null;
3677
4750
  denominator: number | null;
3678
4751
  simplified: boolean;
4752
+ } | {
4753
+ type: "matcher";
4754
+ rows: {
4755
+ type: "matcher-row";
4756
+ items: {
4757
+ type: "matcher-item";
4758
+ itemId: string;
4759
+ id: string;
4760
+ content: any[];
4761
+ }[];
4762
+ id: string;
4763
+ }[];
4764
+ groupCount: number;
4765
+ colors?: string[] | undefined;
3679
4766
  }>;
3680
4767
  validation?: {
3681
4768
  mode: "simple" | "expression";
3682
4769
  expression?: string | undefined;
3683
- answers?: Record<string, string | number> | undefined;
4770
+ answers?: Record<string, string | number | string[][]> | undefined;
3684
4771
  variables?: string[] | undefined;
3685
4772
  } | undefined;
3686
4773
  id?: string | undefined;
@@ -3721,15 +4808,15 @@ export declare const ExerciseRenderer: ForwardRefExoticComponent<ExerciseRendere
3721
4808
 
3722
4809
  export declare interface ExerciseRendererProps {
3723
4810
  json: ExerciseJSON;
3724
- onSubmit?: (values: Record<string, string>) => void;
3725
- onChange?: (values: Record<string, string>) => void;
4811
+ onSubmit?: (values: Record<string, UserAnswerValue>) => void;
4812
+ onChange?: (values: Record<string, UserAnswerValue>) => void;
3726
4813
  showSubmitButton?: boolean;
3727
4814
  className?: string;
3728
4815
  }
3729
4816
 
3730
4817
  export declare interface ExerciseRendererRef {
3731
4818
  submit: () => ValidationResult;
3732
- getValues: () => Record<string, string>;
4819
+ getValues: () => Record<string, UserAnswerValue>;
3733
4820
  reset: () => void;
3734
4821
  focusFirstInput: () => void;
3735
4822
  }
@@ -3782,22 +4869,356 @@ export declare function findValidCombination(expression: string, ranges: Record<
3782
4869
  step?: number;
3783
4870
  }>): Record<string, number> | null;
3784
4871
 
3785
- export declare type FractionInline = z.infer<typeof FractionInlineSchema>;
4872
+ export declare type FractionInline = z.infer<typeof FractionInlineSchema>;
4873
+
4874
+ /**
4875
+ * Fraction inline widget schema
4876
+ *
4877
+ * Modes determined by presence of numerator/denominator:
4878
+ * - both provided → readonly display
4879
+ * - only numerator → denominator input
4880
+ * - only denominator → numerator input
4881
+ * - neither → both are inputs
4882
+ *
4883
+ * @example Readonly: { type: "Fraction", name: "x", numerator: 5, denominator: 3 }
4884
+ * @example Denominator input: { type: "Fraction", name: "y", numerator: 5, answer: "5/3" }
4885
+ * @example Both inputs: { type: "Fraction", name: "z", answer: "5/3" }
4886
+ */
4887
+ export declare const FractionInlineSchema: z.ZodObject<{
4888
+ type: z.ZodLiteral<"Fraction">;
4889
+ name: z.ZodString;
4890
+ numerator: z.ZodOptional<z.ZodNumber>;
4891
+ denominator: z.ZodOptional<z.ZodNumber>;
4892
+ answer: z.ZodOptional<z.ZodString>;
4893
+ simplified: z.ZodDefault<z.ZodBoolean>;
4894
+ }, "strip", z.ZodTypeAny, {
4895
+ type: "Fraction";
4896
+ name: string;
4897
+ simplified: boolean;
4898
+ answer?: string | undefined;
4899
+ numerator?: number | undefined;
4900
+ denominator?: number | undefined;
4901
+ }, {
4902
+ type: "Fraction";
4903
+ name: string;
4904
+ answer?: string | undefined;
4905
+ numerator?: number | undefined;
4906
+ denominator?: number | undefined;
4907
+ simplified?: boolean | undefined;
4908
+ }>;
4909
+
4910
+ export declare type FractionJSON = z.infer<typeof FractionJSONSchema>;
4911
+
4912
+ export declare const FractionJSONSchema: z.ZodObject<{
4913
+ type: z.ZodLiteral<"fraction">;
4914
+ numerator: z.ZodNullable<z.ZodNumber>;
4915
+ denominator: z.ZodNullable<z.ZodNumber>;
4916
+ simplified: z.ZodBoolean;
4917
+ }, "strip", z.ZodTypeAny, {
4918
+ type: "fraction";
4919
+ numerator: number | null;
4920
+ denominator: number | null;
4921
+ simplified: boolean;
4922
+ }, {
4923
+ type: "fraction";
4924
+ numerator: number | null;
4925
+ denominator: number | null;
4926
+ simplified: boolean;
4927
+ }>;
4928
+
4929
+ /**
4930
+ * Centralized fraction compound key utilities.
4931
+ *
4932
+ * Fraction widgets use compound keys (e.g., "x__num", "x__den") in the
4933
+ * UI values map for sub-inputs. These keys are UI-only — they never appear
4934
+ * in the widgets map or validation answers.
4935
+ */
4936
+ export declare type FractionPart = 'num' | 'den';
4937
+
4938
+ export declare type FreeTextInline = z.infer<typeof FreeTextInlineSchema>;
4939
+
4940
+ /**
4941
+ * Free text inline schema - plain text/numbers WITHOUT special formatting
4942
+ *
4943
+ * Use this for normal text. Only use NUMBER_TEXT when you need highlighting!
4944
+ *
4945
+ * @example
4946
+ * { type: "FreeText", value: "25 + " }
4947
+ * { type: "FreeText", value: " = 30" }
4948
+ */
4949
+ export declare const FreeTextInlineSchema: z.ZodObject<{
4950
+ type: z.ZodLiteral<"FreeText">;
4951
+ value: z.ZodString;
4952
+ }, "strip", z.ZodTypeAny, {
4953
+ value: string;
4954
+ type: "FreeText";
4955
+ }, {
4956
+ value: string;
4957
+ type: "FreeText";
4958
+ }>;
4959
+
4960
+ export declare function getFractionKey(widgetId: string, part: FractionPart): string;
4961
+
4962
+ /**
4963
+ * Check if all required inputs are provided
4964
+ *
4965
+ * @param exercise - The exercise JSON
4966
+ * @param userInputs - User's answers
4967
+ * @returns Array of missing widget IDs
4968
+ */
4969
+ export declare function getMissingInputs(exercise: ExerciseJSON, userInputs: Record<string, string | number>): string[];
4970
+
4971
+ export declare type GroupItem = z.infer<typeof GroupItemSchema>;
4972
+
4973
+ export declare const GroupItemSchema: z.ZodObject<{
4974
+ id: z.ZodString;
4975
+ type: z.ZodLiteral<"group">;
4976
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
4977
+ }, "strip", z.ZodTypeAny, {
4978
+ type: "group";
4979
+ items: any[];
4980
+ id: string;
4981
+ }, {
4982
+ type: "group";
4983
+ items: any[];
4984
+ id: string;
4985
+ }>;
4986
+
4987
+ export declare type HighlightedText = z.infer<typeof HighlightedTextSchema>;
4988
+
4989
+ export declare type HighlightedTextInline = z.infer<typeof HighlightedTextInlineSchema>;
4990
+
4991
+ /**
4992
+ * Highlighted text inline schema - text with optional highlighting
4993
+ *
4994
+ * highlight: [start, end] character positions for visual emphasis
4995
+ *
4996
+ * @example
4997
+ * {
4998
+ * type: "HighlightedText",
4999
+ * value: "151 000",
5000
+ * highlight: [0, 3] // Highlights "151"
5001
+ * }
5002
+ */
5003
+ export declare const HighlightedTextInlineSchema: z.ZodObject<{
5004
+ type: z.ZodLiteral<"HighlightedText">;
5005
+ value: z.ZodString;
5006
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5007
+ }, "strip", z.ZodTypeAny, {
5008
+ value: string;
5009
+ type: "HighlightedText";
5010
+ highlight?: [number, number] | undefined;
5011
+ }, {
5012
+ value: string;
5013
+ type: "HighlightedText";
5014
+ highlight?: [number, number] | undefined;
5015
+ }>;
5016
+
5017
+ export declare const HighlightedTextSchema: z.ZodObject<{
5018
+ id: z.ZodString;
5019
+ type: z.ZodLiteral<"highlighted-text">;
5020
+ value: z.ZodString;
5021
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5022
+ }, "strip", z.ZodTypeAny, {
5023
+ value: string;
5024
+ type: "highlighted-text";
5025
+ id: string;
5026
+ highlight?: [number, number] | undefined;
5027
+ }, {
5028
+ value: string;
5029
+ type: "highlighted-text";
5030
+ id: string;
5031
+ highlight?: [number, number] | undefined;
5032
+ }>;
5033
+
5034
+ export declare type InlineInputJSON = z.infer<typeof InlineInputJSONSchema>;
5035
+
5036
+ export declare const InlineInputJSONSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
5037
+ type: z.ZodLiteral<"inline-input">;
5038
+ inputType: z.ZodLiteral<"string">;
5039
+ length: z.ZodNumber;
5040
+ }, "strip", z.ZodTypeAny, {
5041
+ length: number;
5042
+ type: "inline-input";
5043
+ inputType: "string";
5044
+ }, {
5045
+ length: number;
5046
+ type: "inline-input";
5047
+ inputType: "string";
5048
+ }>, z.ZodObject<{
5049
+ type: z.ZodLiteral<"inline-input">;
5050
+ inputType: z.ZodLiteral<"numeric">;
5051
+ digits: z.ZodNumber;
5052
+ }, "strip", z.ZodTypeAny, {
5053
+ type: "inline-input";
5054
+ inputType: "numeric";
5055
+ digits: number;
5056
+ }, {
5057
+ type: "inline-input";
5058
+ inputType: "numeric";
5059
+ digits: number;
5060
+ }>]>;
5061
+
5062
+ export declare type InlineInputWidget = z.infer<typeof InlineInputWidgetSchema>;
5063
+
5064
+ /**
5065
+ * Inline input widget schema - small input that appears within a line
5066
+ *
5067
+ * This is for SHORT inputs (1-5 characters) that flow with text
5068
+ * For longer inputs, consider a standalone tool
5069
+ *
5070
+ * @example String input (W_S_I):
5071
+ * {
5072
+ * type: "InlineInput",
5073
+ * name: "x",
5074
+ * inputType: "string",
5075
+ * length: 5, // Visual width in characters
5076
+ * answer: "hello"
5077
+ * }
5078
+ *
5079
+ * @example Numeric input (W_N_I):
5080
+ * {
5081
+ * type: "InlineInput",
5082
+ * name: "x",
5083
+ * inputType: "numeric",
5084
+ * digits: 2, // Maximum number of digits
5085
+ * answer: 42
5086
+ * }
5087
+ */
5088
+ export declare const InlineInputWidgetSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
5089
+ type: z.ZodLiteral<"InlineInput">;
5090
+ name: z.ZodString;
5091
+ inputType: z.ZodLiteral<"string">;
5092
+ length: z.ZodNumber;
5093
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5094
+ }, "strip", z.ZodTypeAny, {
5095
+ length: number;
5096
+ type: "InlineInput";
5097
+ inputType: "string";
5098
+ name: string;
5099
+ answer?: string | number | undefined;
5100
+ }, {
5101
+ length: number;
5102
+ type: "InlineInput";
5103
+ inputType: "string";
5104
+ name: string;
5105
+ answer?: string | number | undefined;
5106
+ }>, z.ZodObject<{
5107
+ type: z.ZodLiteral<"InlineInput">;
5108
+ name: z.ZodString;
5109
+ inputType: z.ZodLiteral<"numeric">;
5110
+ digits: z.ZodNumber;
5111
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5112
+ }, "strip", z.ZodTypeAny, {
5113
+ type: "InlineInput";
5114
+ inputType: "numeric";
5115
+ name: string;
5116
+ digits: number;
5117
+ answer?: string | number | undefined;
5118
+ }, {
5119
+ type: "InlineInput";
5120
+ inputType: "numeric";
5121
+ name: string;
5122
+ digits: number;
5123
+ answer?: string | number | undefined;
5124
+ }>]>;
5125
+
5126
+ export declare type InlineNode = z.infer<typeof InlineNodeSchema>;
3786
5127
 
3787
5128
  /**
3788
- * Fraction inline widget schema
3789
- *
3790
- * Modes determined by presence of numerator/denominator:
3791
- * - both provided → readonly display
3792
- * - only numerator → denominator input
3793
- * - only denominator → numerator input
3794
- * - neither → both are inputs
3795
- *
3796
- * @example Readonly: { type: "Fraction", name: "x", numerator: 5, denominator: 3 }
3797
- * @example Denominator input: { type: "Fraction", name: "y", numerator: 5, answer: "5/3" }
3798
- * @example Both inputs: { type: "Fraction", name: "z", answer: "5/3" }
5129
+ * Union of all inline element types
3799
5130
  */
3800
- export declare const FractionInlineSchema: z.ZodObject<{
5131
+ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
5132
+ type: z.ZodLiteral<"FreeText">;
5133
+ value: z.ZodString;
5134
+ }, "strip", z.ZodTypeAny, {
5135
+ value: string;
5136
+ type: "FreeText";
5137
+ }, {
5138
+ value: string;
5139
+ type: "FreeText";
5140
+ }>, z.ZodObject<{
5141
+ type: z.ZodLiteral<"Space">;
5142
+ }, "strip", z.ZodTypeAny, {
5143
+ type: "Space";
5144
+ }, {
5145
+ type: "Space";
5146
+ }>, z.ZodObject<{
5147
+ type: z.ZodLiteral<"HighlightedText">;
5148
+ value: z.ZodString;
5149
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5150
+ }, "strip", z.ZodTypeAny, {
5151
+ value: string;
5152
+ type: "HighlightedText";
5153
+ highlight?: [number, number] | undefined;
5154
+ }, {
5155
+ value: string;
5156
+ type: "HighlightedText";
5157
+ highlight?: [number, number] | undefined;
5158
+ }>, z.ZodObject<{
5159
+ type: z.ZodLiteral<"ColorText">;
5160
+ value: z.ZodString;
5161
+ color: z.ZodString;
5162
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5163
+ }, "strip", z.ZodTypeAny, {
5164
+ value: string;
5165
+ type: "ColorText";
5166
+ color: string;
5167
+ highlight?: [number, number] | undefined;
5168
+ }, {
5169
+ value: string;
5170
+ type: "ColorText";
5171
+ color: string;
5172
+ highlight?: [number, number] | undefined;
5173
+ }>, z.ZodObject<{
5174
+ type: z.ZodLiteral<"BoldText">;
5175
+ value: z.ZodString;
5176
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5177
+ }, "strip", z.ZodTypeAny, {
5178
+ value: string;
5179
+ type: "BoldText";
5180
+ highlight?: [number, number] | undefined;
5181
+ }, {
5182
+ value: string;
5183
+ type: "BoldText";
5184
+ highlight?: [number, number] | undefined;
5185
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
5186
+ type: z.ZodLiteral<"InlineInput">;
5187
+ name: z.ZodString;
5188
+ inputType: z.ZodLiteral<"string">;
5189
+ length: z.ZodNumber;
5190
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5191
+ }, "strip", z.ZodTypeAny, {
5192
+ length: number;
5193
+ type: "InlineInput";
5194
+ inputType: "string";
5195
+ name: string;
5196
+ answer?: string | number | undefined;
5197
+ }, {
5198
+ length: number;
5199
+ type: "InlineInput";
5200
+ inputType: "string";
5201
+ name: string;
5202
+ answer?: string | number | undefined;
5203
+ }>, z.ZodObject<{
5204
+ type: z.ZodLiteral<"InlineInput">;
5205
+ name: z.ZodString;
5206
+ inputType: z.ZodLiteral<"numeric">;
5207
+ digits: z.ZodNumber;
5208
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5209
+ }, "strip", z.ZodTypeAny, {
5210
+ type: "InlineInput";
5211
+ inputType: "numeric";
5212
+ name: string;
5213
+ digits: number;
5214
+ answer?: string | number | undefined;
5215
+ }, {
5216
+ type: "InlineInput";
5217
+ inputType: "numeric";
5218
+ name: string;
5219
+ digits: number;
5220
+ answer?: string | number | undefined;
5221
+ }>]>, z.ZodObject<{
3801
5222
  type: z.ZodLiteral<"Fraction">;
3802
5223
  name: z.ZodString;
3803
5224
  numerator: z.ZodOptional<z.ZodNumber>;
@@ -3818,609 +5239,884 @@ export declare const FractionInlineSchema: z.ZodObject<{
3818
5239
  numerator?: number | undefined;
3819
5240
  denominator?: number | undefined;
3820
5241
  simplified?: boolean | undefined;
5242
+ }>]>;
5243
+
5244
+ /**
5245
+ * Type guard for BoldText
5246
+ */
5247
+ export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
5248
+ type: 'bold-text';
3821
5249
  }>;
3822
5250
 
3823
- export declare type FractionJSON = z.infer<typeof FractionJSONSchema>;
5251
+ /**
5252
+ * Type guard for ColorText
5253
+ */
5254
+ export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
5255
+ type: 'color-text';
5256
+ }>;
3824
5257
 
3825
- export declare const FractionJSONSchema: z.ZodObject<{
3826
- type: z.ZodLiteral<"fraction">;
3827
- numerator: z.ZodNullable<z.ZodNumber>;
3828
- denominator: z.ZodNullable<z.ZodNumber>;
3829
- simplified: z.ZodBoolean;
3830
- }, "strip", z.ZodTypeAny, {
3831
- type: "fraction";
3832
- numerator: number | null;
3833
- denominator: number | null;
3834
- simplified: boolean;
3835
- }, {
3836
- type: "fraction";
3837
- numerator: number | null;
3838
- denominator: number | null;
3839
- simplified: boolean;
5258
+ export declare function isDragOptions(value: unknown): value is DragOptionsTool;
5259
+
5260
+ /**
5261
+ * Type guard for DragOptionsJSON
5262
+ */
5263
+ export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
5264
+ type: 'drag-options';
3840
5265
  }>;
3841
5266
 
5267
+ export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
5268
+
5269
+ export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
5270
+
5271
+ export declare function isFraction(value: unknown): value is FractionInline;
5272
+
3842
5273
  /**
3843
- * Centralized fraction compound key utilities.
3844
- *
3845
- * Fraction widgets use compound keys (e.g., "x__num", "x__den") in the
3846
- * UI values map for sub-inputs. These keys are UI-only — they never appear
3847
- * in the widgets map or validation answers.
5274
+ * Type guard for FractionJSON
3848
5275
  */
3849
- export declare type FractionPart = 'num' | 'den';
5276
+ export declare function isFractionJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
5277
+ type: 'fraction';
5278
+ }>;
3850
5279
 
3851
- export declare type FreeTextInline = z.infer<typeof FreeTextInlineSchema>;
5280
+ export declare function isFractionKey(key: string): boolean;
5281
+
5282
+ export declare function isFreeText(value: unknown): value is FreeTextInline;
3852
5283
 
3853
5284
  /**
3854
- * Free text inline schema - plain text/numbers WITHOUT special formatting
3855
- *
3856
- * Use this for normal text. Only use NUMBER_TEXT when you need highlighting!
3857
- *
3858
- * @example
3859
- * { type: "FreeText", value: "25 + " }
3860
- * { type: "FreeText", value: " = 30" }
5285
+ * Type guard for GroupItem
3861
5286
  */
3862
- export declare const FreeTextInlineSchema: z.ZodObject<{
3863
- type: z.ZodLiteral<"FreeText">;
3864
- value: z.ZodString;
3865
- }, "strip", z.ZodTypeAny, {
3866
- value: string;
3867
- type: "FreeText";
3868
- }, {
3869
- value: string;
3870
- type: "FreeText";
5287
+ export declare function isGroupItem(item: LayoutItem): item is GroupItem;
5288
+
5289
+ /**
5290
+ * Type guard for HighlightedText
5291
+ */
5292
+ export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
5293
+ type: 'highlighted-text';
5294
+ }>;
5295
+
5296
+ export declare function isInlineInput(value: unknown): value is InlineInputWidget;
5297
+
5298
+ /**
5299
+ * Type guard for InlineInputJSON
5300
+ */
5301
+ export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
5302
+ type: 'inline-input';
5303
+ }>;
5304
+
5305
+ export declare function isInlineNode(value: unknown): value is InlineNode;
5306
+
5307
+ export declare function isLineBlock(value: unknown): value is LineBlock;
5308
+
5309
+ /**
5310
+ * Type guard for Linebreak
5311
+ */
5312
+ export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
5313
+ type: 'linebreak';
5314
+ }>;
5315
+
5316
+ export declare function isMatcherBlock(value: unknown): value is MatcherBlock;
5317
+
5318
+ export declare function isMatcherItem(value: unknown): value is MatcherItem;
5319
+
5320
+ export declare function isMatcherRow(value: unknown): value is MatcherRow;
5321
+
5322
+ export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
5323
+
5324
+ /**
5325
+ * Type guard for NumericKeypadJSON
5326
+ */
5327
+ export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
5328
+ type: 'numeric-keypad';
5329
+ }>;
5330
+
5331
+ /**
5332
+ * Type guard for OperatorItem
5333
+ */
5334
+ export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
5335
+ type: 'operator';
5336
+ }>;
5337
+
5338
+ /**
5339
+ * Type guard for QuestionText
5340
+ */
5341
+ export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
5342
+ type: 'question-text';
5343
+ }>;
5344
+
5345
+ /**
5346
+ * Type guard for RadioOptionsJSON
5347
+ */
5348
+ export declare function isRadioOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
5349
+ type: 'radio-options';
5350
+ }>;
5351
+
5352
+ export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
5353
+
5354
+ export declare function isSpace(value: unknown): value is SpaceInline;
5355
+
5356
+ /**
5357
+ * Type guard for SpaceItem
5358
+ */
5359
+ export declare function isSpaceItem(item: LayoutItem): item is Extract<LayoutItem, {
5360
+ type: 'space';
5361
+ }>;
5362
+
5363
+ /**
5364
+ * Type guard for TableCellItem
5365
+ */
5366
+ export declare function isTableCellItem(item: LayoutItem): item is Extract<LayoutItem, {
5367
+ type: 'table-cell';
3871
5368
  }>;
3872
5369
 
3873
- export declare function getFractionKey(widgetId: string, part: FractionPart): string;
5370
+ /**
5371
+ * Type guard for TableItem
5372
+ */
5373
+ export declare function isTableItem(item: LayoutItem): item is Extract<LayoutItem, {
5374
+ type: 'table';
5375
+ }>;
3874
5376
 
3875
5377
  /**
3876
- * Check if all required inputs are provided
3877
- *
3878
- * @param exercise - The exercise JSON
3879
- * @param userInputs - User's answers
3880
- * @returns Array of missing widget IDs
5378
+ * Type guard for TableRowItem
3881
5379
  */
3882
- export declare function getMissingInputs(exercise: ExerciseJSON, userInputs: Record<string, string | number>): string[];
5380
+ export declare function isTableRowItem(item: LayoutItem): item is Extract<LayoutItem, {
5381
+ type: 'table-row';
5382
+ }>;
3883
5383
 
3884
- export declare type GroupItem = z.infer<typeof GroupItemSchema>;
5384
+ export declare function isTextBlock(value: unknown): value is TextBlock;
3885
5385
 
3886
- export declare const GroupItemSchema: z.ZodObject<{
3887
- id: z.ZodString;
3888
- type: z.ZodLiteral<"group">;
3889
- items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3890
- }, "strip", z.ZodTypeAny, {
3891
- type: "group";
3892
- id: string;
3893
- items: any[];
3894
- }, {
3895
- type: "group";
3896
- id: string;
3897
- items: any[];
5386
+ /**
5387
+ * Type guard for TextItem
5388
+ */
5389
+ export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
5390
+ type: 'text';
3898
5391
  }>;
3899
5392
 
3900
- export declare type HighlightedText = z.infer<typeof HighlightedTextSchema>;
5393
+ export declare function isToolNode(value: unknown): value is ToolNode;
3901
5394
 
3902
- export declare type HighlightedTextInline = z.infer<typeof HighlightedTextInlineSchema>;
5395
+ export declare function isValidationNode(value: unknown): value is ValidationNode;
3903
5396
 
3904
5397
  /**
3905
- * Highlighted text inline schema - text with optional highlighting
3906
- *
3907
- * highlight: [start, end] character positions for visual emphasis
5398
+ * Check if an expression is syntactically valid
3908
5399
  *
3909
- * @example
3910
- * {
3911
- * type: "HighlightedText",
3912
- * value: "151 000",
3913
- * highlight: [0, 3] // Highlights "151"
3914
- * }
5400
+ * @param expression - The expression to check
5401
+ * @returns true if valid, false otherwise
3915
5402
  */
3916
- export declare const HighlightedTextInlineSchema: z.ZodObject<{
3917
- type: z.ZodLiteral<"HighlightedText">;
3918
- value: z.ZodString;
3919
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3920
- }, "strip", z.ZodTypeAny, {
3921
- value: string;
3922
- type: "HighlightedText";
3923
- highlight?: [number, number] | undefined;
3924
- }, {
3925
- value: string;
3926
- type: "HighlightedText";
3927
- highlight?: [number, number] | undefined;
3928
- }>;
5403
+ export declare function isValidExpression(expression: string): boolean;
3929
5404
 
3930
- export declare const HighlightedTextSchema: z.ZodObject<{
3931
- id: z.ZodString;
3932
- type: z.ZodLiteral<"highlighted-text">;
3933
- value: z.ZodString;
3934
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3935
- }, "strip", z.ZodTypeAny, {
3936
- value: string;
3937
- type: "highlighted-text";
3938
- id: string;
3939
- highlight?: [number, number] | undefined;
3940
- }, {
3941
- value: string;
3942
- type: "highlighted-text";
3943
- id: string;
3944
- highlight?: [number, number] | undefined;
5405
+ /**
5406
+ * Type guard for WidgetRef
5407
+ */
5408
+ export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
5409
+ type: 'widget-ref';
3945
5410
  }>;
3946
5411
 
3947
- export declare type InlineInputJSON = z.infer<typeof InlineInputJSONSchema>;
5412
+ /**
5413
+ * JSON Layout Item Types
5414
+ *
5415
+ * These are the types used in the JSON output format.
5416
+ */
5417
+ export declare const JSON_TYPES: {
5418
+ /** Question/instruction text */
5419
+ readonly QUESTION_TEXT: "question-text";
5420
+ /** Regular text element */
5421
+ readonly TEXT: "text";
5422
+ /** Spacing element */
5423
+ readonly SPACE: "space";
5424
+ /** Text with optional highlighting */
5425
+ readonly HIGHLIGHTED_TEXT: "highlighted-text";
5426
+ /** Text with color styling */
5427
+ readonly COLOR_TEXT: "color-text";
5428
+ /** Bold text */
5429
+ readonly BOLD_TEXT: "bold-text";
5430
+ /** Reference to a widget */
5431
+ readonly WIDGET_REF: "widget-ref";
5432
+ /** Line break element */
5433
+ readonly LINEBREAK: "linebreak";
5434
+ /** Grouped layout items */
5435
+ readonly GROUP: "group";
5436
+ /** Operator symbol */
5437
+ readonly OPERATOR: "operator";
5438
+ /** Table layout block */
5439
+ readonly TABLE: "table";
5440
+ /** Row within a table */
5441
+ readonly TABLE_ROW: "table-row";
5442
+ /** Cell within a table */
5443
+ readonly TABLE_CELL: "table-cell";
5444
+ /** Number line layout block */
5445
+ readonly NUMBER_LINE: "number-line";
5446
+ /** Position marker within a number line */
5447
+ readonly NUMBER_LINE_POSITION: "number-line-position";
5448
+ /** Dynamic subdivision counter embedded in a number line */
5449
+ readonly NUMBER_LINE_COUNTER: "number-line-counter";
5450
+ /** Highlighted range within a number line */
5451
+ readonly NUMBER_LINE_HIGHLIGHT: "number-line-highlight";
5452
+ /** Matcher layout block */
5453
+ readonly MATCHER: "matcher";
5454
+ /** Row within a matcher */
5455
+ readonly MATCHER_ROW: "matcher-row";
5456
+ /** Item within a matcher row */
5457
+ readonly MATCHER_ITEM: "matcher-item";
5458
+ /** Inline input widget (string or numeric) */
5459
+ readonly INLINE_INPUT: "inline-input";
5460
+ /** Drag-and-drop options widget */
5461
+ readonly DRAG_OPTIONS: "drag-options";
5462
+ /** Radio button options widget */
5463
+ readonly RADIO_OPTIONS: "radio-options";
5464
+ /** Numeric keypad widget */
5465
+ readonly NUMERIC_KEYPAD: "numeric-keypad";
5466
+ /** Inline fraction widget */
5467
+ readonly FRACTION: "fraction";
5468
+ };
3948
5469
 
3949
- export declare const InlineInputJSONSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
3950
- type: z.ZodLiteral<"inline-input">;
3951
- inputType: z.ZodLiteral<"string">;
3952
- length: z.ZodNumber;
3953
- }, "strip", z.ZodTypeAny, {
3954
- length: number;
3955
- type: "inline-input";
3956
- inputType: "string";
3957
- }, {
3958
- length: number;
3959
- type: "inline-input";
3960
- inputType: "string";
3961
- }>, z.ZodObject<{
3962
- type: z.ZodLiteral<"inline-input">;
3963
- inputType: z.ZodLiteral<"numeric">;
3964
- digits: z.ZodNumber;
3965
- }, "strip", z.ZodTypeAny, {
3966
- type: "inline-input";
3967
- inputType: "numeric";
3968
- digits: number;
3969
- }, {
3970
- type: "inline-input";
3971
- inputType: "numeric";
3972
- digits: number;
3973
- }>]>;
5470
+ /**
5471
+ * Type helper to get all JSON type values as a union type
5472
+ */
5473
+ export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
3974
5474
 
3975
- export declare type InlineInputWidget = z.infer<typeof InlineInputWidgetSchema>;
5475
+ export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
5476
+
5477
+ export declare const LayoutItemSchema: z.ZodType<any>;
3976
5478
 
3977
5479
  /**
3978
- * Inline input widget schema - small input that appears within a line
3979
- *
3980
- * This is for SHORT inputs (1-5 characters) that flow with text
3981
- * For longer inputs, consider a standalone tool
3982
- *
3983
- * @example String input (W_S_I):
3984
- * {
3985
- * type: "InlineInput",
3986
- * name: "x",
3987
- * inputType: "string",
3988
- * length: 5, // Visual width in characters
3989
- * answer: "hello"
3990
- * }
3991
- *
3992
- * @example Numeric input (W_N_I):
3993
- * {
3994
- * type: "InlineInput",
3995
- * name: "x",
3996
- * inputType: "numeric",
3997
- * digits: 2, // Maximum number of digits
3998
- * answer: 42
3999
- * }
5480
+ * DUMB layout renderer - no opinions about spacing or layout.
4000
5481
  */
4001
- export declare const InlineInputWidgetSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
4002
- type: z.ZodLiteral<"InlineInput">;
4003
- name: z.ZodString;
4004
- inputType: z.ZodLiteral<"string">;
4005
- length: z.ZodNumber;
4006
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
4007
- }, "strip", z.ZodTypeAny, {
4008
- length: number;
4009
- type: "InlineInput";
4010
- inputType: "string";
4011
- name: string;
4012
- answer?: string | number | undefined;
4013
- }, {
4014
- length: number;
4015
- type: "InlineInput";
4016
- inputType: "string";
4017
- name: string;
4018
- answer?: string | number | undefined;
4019
- }>, z.ZodObject<{
4020
- type: z.ZodLiteral<"InlineInput">;
4021
- name: z.ZodString;
4022
- inputType: z.ZodLiteral<"numeric">;
4023
- digits: z.ZodNumber;
4024
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
4025
- }, "strip", z.ZodTypeAny, {
4026
- type: "InlineInput";
4027
- inputType: "numeric";
4028
- name: string;
4029
- digits: number;
4030
- answer?: string | number | undefined;
4031
- }, {
4032
- type: "InlineInput";
4033
- inputType: "numeric";
4034
- name: string;
4035
- digits: number;
4036
- answer?: string | number | undefined;
4037
- }>]>;
5482
+ export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
4038
5483
 
4039
- export declare type InlineNode = z.infer<typeof InlineNodeSchema>;
5484
+ export declare interface LayoutRendererProps {
5485
+ item: LayoutItem;
5486
+ widgets: Record<string, WidgetJSON>;
5487
+ values: Record<string, UserAnswerValue>;
5488
+ droppedInputs: Set<string>;
5489
+ validationDetails?: Record<string, boolean> | null;
5490
+ onChange: (widgetId: string, value: UserAnswerValue, fromDrop?: boolean, sourceOptionId?: string) => void;
5491
+ onInputFocus?: (widgetId: string) => void;
5492
+ /** Incremented on reset. Drives remount of stateful items: NumberLine and MatcherWidget. */
5493
+ resetKey?: number;
5494
+ }
4040
5495
 
4041
5496
  /**
4042
- * Union of all inline element types
5497
+ * Error thrown when lexer fails to tokenize input
5498
+ */
5499
+ export declare class LexerError extends EngineError {
5500
+ readonly lexerErrors: ILexingError[];
5501
+ readonly positions: SourcePosition[];
5502
+ constructor(errors: ILexingError[]);
5503
+ }
5504
+
5505
+ export declare type LineBlock = z.infer<typeof LineBlockSchema>;
5506
+
5507
+ /**
5508
+ * Line block schema - represents a visual row of inline elements
5509
+ *
5510
+ * One line = one visual row in the UI
5511
+ * Contains an ordered sequence of inline elements
5512
+ *
5513
+ * @example
5514
+ * {
5515
+ * type: "LineBlock",
5516
+ * inlines: [
5517
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
5518
+ * { type: "InlineInput", name: "x", length: 1 },
5519
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
5520
+ * ]
5521
+ * }
4043
5522
  */
4044
- export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
4045
- type: z.ZodLiteral<"FreeText">;
4046
- value: z.ZodString;
4047
- }, "strip", z.ZodTypeAny, {
4048
- value: string;
4049
- type: "FreeText";
4050
- }, {
4051
- value: string;
4052
- type: "FreeText";
4053
- }>, z.ZodObject<{
4054
- type: z.ZodLiteral<"Space">;
4055
- }, "strip", z.ZodTypeAny, {
4056
- type: "Space";
4057
- }, {
4058
- type: "Space";
4059
- }>, z.ZodObject<{
4060
- type: z.ZodLiteral<"HighlightedText">;
4061
- value: z.ZodString;
4062
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
4063
- }, "strip", z.ZodTypeAny, {
4064
- value: string;
4065
- type: "HighlightedText";
4066
- highlight?: [number, number] | undefined;
4067
- }, {
4068
- value: string;
4069
- type: "HighlightedText";
4070
- highlight?: [number, number] | undefined;
4071
- }>, z.ZodObject<{
4072
- type: z.ZodLiteral<"ColorText">;
4073
- value: z.ZodString;
4074
- color: z.ZodString;
4075
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
4076
- }, "strip", z.ZodTypeAny, {
4077
- value: string;
4078
- type: "ColorText";
4079
- color: string;
4080
- highlight?: [number, number] | undefined;
4081
- }, {
4082
- value: string;
4083
- type: "ColorText";
4084
- color: string;
4085
- highlight?: [number, number] | undefined;
4086
- }>, z.ZodObject<{
4087
- type: z.ZodLiteral<"BoldText">;
4088
- value: z.ZodString;
4089
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5523
+ export declare const LineBlockSchema: z.ZodObject<{
5524
+ type: z.ZodLiteral<"LineBlock">;
5525
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
5526
+ type: z.ZodLiteral<"FreeText">;
5527
+ value: z.ZodString;
5528
+ }, "strip", z.ZodTypeAny, {
5529
+ value: string;
5530
+ type: "FreeText";
5531
+ }, {
5532
+ value: string;
5533
+ type: "FreeText";
5534
+ }>, z.ZodObject<{
5535
+ type: z.ZodLiteral<"Space">;
5536
+ }, "strip", z.ZodTypeAny, {
5537
+ type: "Space";
5538
+ }, {
5539
+ type: "Space";
5540
+ }>, z.ZodObject<{
5541
+ type: z.ZodLiteral<"HighlightedText">;
5542
+ value: z.ZodString;
5543
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5544
+ }, "strip", z.ZodTypeAny, {
5545
+ value: string;
5546
+ type: "HighlightedText";
5547
+ highlight?: [number, number] | undefined;
5548
+ }, {
5549
+ value: string;
5550
+ type: "HighlightedText";
5551
+ highlight?: [number, number] | undefined;
5552
+ }>, z.ZodObject<{
5553
+ type: z.ZodLiteral<"ColorText">;
5554
+ value: z.ZodString;
5555
+ color: z.ZodString;
5556
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5557
+ }, "strip", z.ZodTypeAny, {
5558
+ value: string;
5559
+ type: "ColorText";
5560
+ color: string;
5561
+ highlight?: [number, number] | undefined;
5562
+ }, {
5563
+ value: string;
5564
+ type: "ColorText";
5565
+ color: string;
5566
+ highlight?: [number, number] | undefined;
5567
+ }>, z.ZodObject<{
5568
+ type: z.ZodLiteral<"BoldText">;
5569
+ value: z.ZodString;
5570
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5571
+ }, "strip", z.ZodTypeAny, {
5572
+ value: string;
5573
+ type: "BoldText";
5574
+ highlight?: [number, number] | undefined;
5575
+ }, {
5576
+ value: string;
5577
+ type: "BoldText";
5578
+ highlight?: [number, number] | undefined;
5579
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
5580
+ type: z.ZodLiteral<"InlineInput">;
5581
+ name: z.ZodString;
5582
+ inputType: z.ZodLiteral<"string">;
5583
+ length: z.ZodNumber;
5584
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5585
+ }, "strip", z.ZodTypeAny, {
5586
+ length: number;
5587
+ type: "InlineInput";
5588
+ inputType: "string";
5589
+ name: string;
5590
+ answer?: string | number | undefined;
5591
+ }, {
5592
+ length: number;
5593
+ type: "InlineInput";
5594
+ inputType: "string";
5595
+ name: string;
5596
+ answer?: string | number | undefined;
5597
+ }>, z.ZodObject<{
5598
+ type: z.ZodLiteral<"InlineInput">;
5599
+ name: z.ZodString;
5600
+ inputType: z.ZodLiteral<"numeric">;
5601
+ digits: z.ZodNumber;
5602
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5603
+ }, "strip", z.ZodTypeAny, {
5604
+ type: "InlineInput";
5605
+ inputType: "numeric";
5606
+ name: string;
5607
+ digits: number;
5608
+ answer?: string | number | undefined;
5609
+ }, {
5610
+ type: "InlineInput";
5611
+ inputType: "numeric";
5612
+ name: string;
5613
+ digits: number;
5614
+ answer?: string | number | undefined;
5615
+ }>]>, z.ZodObject<{
5616
+ type: z.ZodLiteral<"Fraction">;
5617
+ name: z.ZodString;
5618
+ numerator: z.ZodOptional<z.ZodNumber>;
5619
+ denominator: z.ZodOptional<z.ZodNumber>;
5620
+ answer: z.ZodOptional<z.ZodString>;
5621
+ simplified: z.ZodDefault<z.ZodBoolean>;
5622
+ }, "strip", z.ZodTypeAny, {
5623
+ type: "Fraction";
5624
+ name: string;
5625
+ simplified: boolean;
5626
+ answer?: string | undefined;
5627
+ numerator?: number | undefined;
5628
+ denominator?: number | undefined;
5629
+ }, {
5630
+ type: "Fraction";
5631
+ name: string;
5632
+ answer?: string | undefined;
5633
+ numerator?: number | undefined;
5634
+ denominator?: number | undefined;
5635
+ simplified?: boolean | undefined;
5636
+ }>]>, "many">;
4090
5637
  }, "strip", z.ZodTypeAny, {
4091
- value: string;
4092
- type: "BoldText";
4093
- highlight?: [number, number] | undefined;
5638
+ type: "LineBlock";
5639
+ inlines: ({
5640
+ value: string;
5641
+ type: "FreeText";
5642
+ } | {
5643
+ type: "Space";
5644
+ } | {
5645
+ value: string;
5646
+ type: "HighlightedText";
5647
+ highlight?: [number, number] | undefined;
5648
+ } | {
5649
+ value: string;
5650
+ type: "ColorText";
5651
+ color: string;
5652
+ highlight?: [number, number] | undefined;
5653
+ } | {
5654
+ value: string;
5655
+ type: "BoldText";
5656
+ highlight?: [number, number] | undefined;
5657
+ } | {
5658
+ length: number;
5659
+ type: "InlineInput";
5660
+ inputType: "string";
5661
+ name: string;
5662
+ answer?: string | number | undefined;
5663
+ } | {
5664
+ type: "InlineInput";
5665
+ inputType: "numeric";
5666
+ name: string;
5667
+ digits: number;
5668
+ answer?: string | number | undefined;
5669
+ } | {
5670
+ type: "Fraction";
5671
+ name: string;
5672
+ simplified: boolean;
5673
+ answer?: string | undefined;
5674
+ numerator?: number | undefined;
5675
+ denominator?: number | undefined;
5676
+ })[];
4094
5677
  }, {
4095
- value: string;
4096
- type: "BoldText";
4097
- highlight?: [number, number] | undefined;
4098
- }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
4099
- type: z.ZodLiteral<"InlineInput">;
4100
- name: z.ZodString;
4101
- inputType: z.ZodLiteral<"string">;
4102
- length: z.ZodNumber;
4103
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5678
+ type: "LineBlock";
5679
+ inlines: ({
5680
+ value: string;
5681
+ type: "FreeText";
5682
+ } | {
5683
+ type: "Space";
5684
+ } | {
5685
+ value: string;
5686
+ type: "HighlightedText";
5687
+ highlight?: [number, number] | undefined;
5688
+ } | {
5689
+ value: string;
5690
+ type: "ColorText";
5691
+ color: string;
5692
+ highlight?: [number, number] | undefined;
5693
+ } | {
5694
+ value: string;
5695
+ type: "BoldText";
5696
+ highlight?: [number, number] | undefined;
5697
+ } | {
5698
+ length: number;
5699
+ type: "InlineInput";
5700
+ inputType: "string";
5701
+ name: string;
5702
+ answer?: string | number | undefined;
5703
+ } | {
5704
+ type: "InlineInput";
5705
+ inputType: "numeric";
5706
+ name: string;
5707
+ digits: number;
5708
+ answer?: string | number | undefined;
5709
+ } | {
5710
+ type: "Fraction";
5711
+ name: string;
5712
+ answer?: string | undefined;
5713
+ numerator?: number | undefined;
5714
+ denominator?: number | undefined;
5715
+ simplified?: boolean | undefined;
5716
+ })[];
5717
+ }>;
5718
+
5719
+ export declare type Linebreak = z.infer<typeof LinebreakSchema>;
5720
+
5721
+ export declare const LinebreakSchema: z.ZodObject<{
5722
+ id: z.ZodString;
5723
+ type: z.ZodLiteral<"linebreak">;
4104
5724
  }, "strip", z.ZodTypeAny, {
4105
- length: number;
4106
- type: "InlineInput";
4107
- inputType: "string";
4108
- name: string;
4109
- answer?: string | number | undefined;
5725
+ type: "linebreak";
5726
+ id: string;
4110
5727
  }, {
4111
- length: number;
4112
- type: "InlineInput";
4113
- inputType: "string";
4114
- name: string;
4115
- answer?: string | number | undefined;
4116
- }>, z.ZodObject<{
4117
- type: z.ZodLiteral<"InlineInput">;
5728
+ type: "linebreak";
5729
+ id: string;
5730
+ }>;
5731
+
5732
+ export declare type MatcherBlock = z.infer<typeof MatcherBlockSchema>;
5733
+
5734
+ export declare const MatcherBlockSchema: z.ZodEffects<z.ZodObject<{
5735
+ type: z.ZodLiteral<"MatcherBlock">;
4118
5736
  name: z.ZodString;
4119
- inputType: z.ZodLiteral<"numeric">;
4120
- digits: z.ZodNumber;
4121
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
5737
+ /** Optional palette of colors for the renderer (one per answer group) */
5738
+ colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5739
+ /** At least one row required */
5740
+ rows: z.ZodArray<z.ZodObject<{
5741
+ type: z.ZodLiteral<"MatcherRow">;
5742
+ /** At least one item per row */
5743
+ items: z.ZodArray<z.ZodObject<{
5744
+ type: z.ZodLiteral<"MatcherItem">;
5745
+ itemId: z.ZodString;
5746
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
5747
+ type: z.ZodLiteral<"FreeText">;
5748
+ value: z.ZodString;
5749
+ }, "strip", z.ZodTypeAny, {
5750
+ value: string;
5751
+ type: "FreeText";
5752
+ }, {
5753
+ value: string;
5754
+ type: "FreeText";
5755
+ }>, z.ZodObject<{
5756
+ type: z.ZodLiteral<"Space">;
5757
+ }, "strip", z.ZodTypeAny, {
5758
+ type: "Space";
5759
+ }, {
5760
+ type: "Space";
5761
+ }>, z.ZodObject<{
5762
+ type: z.ZodLiteral<"HighlightedText">;
5763
+ value: z.ZodString;
5764
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5765
+ }, "strip", z.ZodTypeAny, {
5766
+ value: string;
5767
+ type: "HighlightedText";
5768
+ highlight?: [number, number] | undefined;
5769
+ }, {
5770
+ value: string;
5771
+ type: "HighlightedText";
5772
+ highlight?: [number, number] | undefined;
5773
+ }>, z.ZodObject<{
5774
+ type: z.ZodLiteral<"ColorText">;
5775
+ value: z.ZodString;
5776
+ color: z.ZodString;
5777
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5778
+ }, "strip", z.ZodTypeAny, {
5779
+ value: string;
5780
+ type: "ColorText";
5781
+ color: string;
5782
+ highlight?: [number, number] | undefined;
5783
+ }, {
5784
+ value: string;
5785
+ type: "ColorText";
5786
+ color: string;
5787
+ highlight?: [number, number] | undefined;
5788
+ }>, z.ZodObject<{
5789
+ type: z.ZodLiteral<"BoldText">;
5790
+ value: z.ZodString;
5791
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
5792
+ }, "strip", z.ZodTypeAny, {
5793
+ value: string;
5794
+ type: "BoldText";
5795
+ highlight?: [number, number] | undefined;
5796
+ }, {
5797
+ value: string;
5798
+ type: "BoldText";
5799
+ highlight?: [number, number] | undefined;
5800
+ }>, z.ZodEffects<z.ZodObject<{
5801
+ type: z.ZodLiteral<"Fraction">;
5802
+ name: z.ZodString;
5803
+ numerator: z.ZodOptional<z.ZodNumber>;
5804
+ denominator: z.ZodOptional<z.ZodNumber>;
5805
+ answer: z.ZodOptional<z.ZodString>;
5806
+ simplified: z.ZodDefault<z.ZodBoolean>;
5807
+ }, "strip", z.ZodTypeAny, {
5808
+ type: "Fraction";
5809
+ name: string;
5810
+ simplified: boolean;
5811
+ answer?: string | undefined;
5812
+ numerator?: number | undefined;
5813
+ denominator?: number | undefined;
5814
+ }, {
5815
+ type: "Fraction";
5816
+ name: string;
5817
+ answer?: string | undefined;
5818
+ numerator?: number | undefined;
5819
+ denominator?: number | undefined;
5820
+ simplified?: boolean | undefined;
5821
+ }>, {
5822
+ type: "Fraction";
5823
+ name: string;
5824
+ simplified: boolean;
5825
+ answer?: string | undefined;
5826
+ numerator?: number | undefined;
5827
+ denominator?: number | undefined;
5828
+ }, {
5829
+ type: "Fraction";
5830
+ name: string;
5831
+ answer?: string | undefined;
5832
+ numerator?: number | undefined;
5833
+ denominator?: number | undefined;
5834
+ simplified?: boolean | undefined;
5835
+ }>]>, "many">;
5836
+ }, "strip", z.ZodTypeAny, {
5837
+ type: "MatcherItem";
5838
+ inlines: ({
5839
+ value: string;
5840
+ type: "FreeText";
5841
+ } | {
5842
+ type: "Space";
5843
+ } | {
5844
+ value: string;
5845
+ type: "HighlightedText";
5846
+ highlight?: [number, number] | undefined;
5847
+ } | {
5848
+ value: string;
5849
+ type: "ColorText";
5850
+ color: string;
5851
+ highlight?: [number, number] | undefined;
5852
+ } | {
5853
+ value: string;
5854
+ type: "BoldText";
5855
+ highlight?: [number, number] | undefined;
5856
+ } | {
5857
+ type: "Fraction";
5858
+ name: string;
5859
+ simplified: boolean;
5860
+ answer?: string | undefined;
5861
+ numerator?: number | undefined;
5862
+ denominator?: number | undefined;
5863
+ })[];
5864
+ itemId: string;
5865
+ }, {
5866
+ type: "MatcherItem";
5867
+ inlines: ({
5868
+ value: string;
5869
+ type: "FreeText";
5870
+ } | {
5871
+ type: "Space";
5872
+ } | {
5873
+ value: string;
5874
+ type: "HighlightedText";
5875
+ highlight?: [number, number] | undefined;
5876
+ } | {
5877
+ value: string;
5878
+ type: "ColorText";
5879
+ color: string;
5880
+ highlight?: [number, number] | undefined;
5881
+ } | {
5882
+ value: string;
5883
+ type: "BoldText";
5884
+ highlight?: [number, number] | undefined;
5885
+ } | {
5886
+ type: "Fraction";
5887
+ name: string;
5888
+ answer?: string | undefined;
5889
+ numerator?: number | undefined;
5890
+ denominator?: number | undefined;
5891
+ simplified?: boolean | undefined;
5892
+ })[];
5893
+ itemId: string;
5894
+ }>, "many">;
5895
+ }, "strip", z.ZodTypeAny, {
5896
+ type: "MatcherRow";
5897
+ items: {
5898
+ type: "MatcherItem";
5899
+ inlines: ({
5900
+ value: string;
5901
+ type: "FreeText";
5902
+ } | {
5903
+ type: "Space";
5904
+ } | {
5905
+ value: string;
5906
+ type: "HighlightedText";
5907
+ highlight?: [number, number] | undefined;
5908
+ } | {
5909
+ value: string;
5910
+ type: "ColorText";
5911
+ color: string;
5912
+ highlight?: [number, number] | undefined;
5913
+ } | {
5914
+ value: string;
5915
+ type: "BoldText";
5916
+ highlight?: [number, number] | undefined;
5917
+ } | {
5918
+ type: "Fraction";
5919
+ name: string;
5920
+ simplified: boolean;
5921
+ answer?: string | undefined;
5922
+ numerator?: number | undefined;
5923
+ denominator?: number | undefined;
5924
+ })[];
5925
+ itemId: string;
5926
+ }[];
5927
+ }, {
5928
+ type: "MatcherRow";
5929
+ items: {
5930
+ type: "MatcherItem";
5931
+ inlines: ({
5932
+ value: string;
5933
+ type: "FreeText";
5934
+ } | {
5935
+ type: "Space";
5936
+ } | {
5937
+ value: string;
5938
+ type: "HighlightedText";
5939
+ highlight?: [number, number] | undefined;
5940
+ } | {
5941
+ value: string;
5942
+ type: "ColorText";
5943
+ color: string;
5944
+ highlight?: [number, number] | undefined;
5945
+ } | {
5946
+ value: string;
5947
+ type: "BoldText";
5948
+ highlight?: [number, number] | undefined;
5949
+ } | {
5950
+ type: "Fraction";
5951
+ name: string;
5952
+ answer?: string | undefined;
5953
+ numerator?: number | undefined;
5954
+ denominator?: number | undefined;
5955
+ simplified?: boolean | undefined;
5956
+ })[];
5957
+ itemId: string;
5958
+ }[];
5959
+ }>, "many">;
5960
+ answers: z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">;
4122
5961
  }, "strip", z.ZodTypeAny, {
4123
- type: "InlineInput";
4124
- inputType: "numeric";
5962
+ type: "MatcherBlock";
4125
5963
  name: string;
4126
- digits: number;
4127
- answer?: string | number | undefined;
5964
+ rows: {
5965
+ type: "MatcherRow";
5966
+ items: {
5967
+ type: "MatcherItem";
5968
+ inlines: ({
5969
+ value: string;
5970
+ type: "FreeText";
5971
+ } | {
5972
+ type: "Space";
5973
+ } | {
5974
+ value: string;
5975
+ type: "HighlightedText";
5976
+ highlight?: [number, number] | undefined;
5977
+ } | {
5978
+ value: string;
5979
+ type: "ColorText";
5980
+ color: string;
5981
+ highlight?: [number, number] | undefined;
5982
+ } | {
5983
+ value: string;
5984
+ type: "BoldText";
5985
+ highlight?: [number, number] | undefined;
5986
+ } | {
5987
+ type: "Fraction";
5988
+ name: string;
5989
+ simplified: boolean;
5990
+ answer?: string | undefined;
5991
+ numerator?: number | undefined;
5992
+ denominator?: number | undefined;
5993
+ })[];
5994
+ itemId: string;
5995
+ }[];
5996
+ }[];
5997
+ answers: string[][];
5998
+ colors?: string[] | undefined;
4128
5999
  }, {
4129
- type: "InlineInput";
4130
- inputType: "numeric";
6000
+ type: "MatcherBlock";
4131
6001
  name: string;
4132
- digits: number;
4133
- answer?: string | number | undefined;
4134
- }>]>, z.ZodObject<{
4135
- type: z.ZodLiteral<"Fraction">;
4136
- name: z.ZodString;
4137
- numerator: z.ZodOptional<z.ZodNumber>;
4138
- denominator: z.ZodOptional<z.ZodNumber>;
4139
- answer: z.ZodOptional<z.ZodString>;
4140
- simplified: z.ZodDefault<z.ZodBoolean>;
4141
- }, "strip", z.ZodTypeAny, {
4142
- type: "Fraction";
4143
- name: string;
4144
- simplified: boolean;
4145
- answer?: string | undefined;
4146
- numerator?: number | undefined;
4147
- denominator?: number | undefined;
4148
- }, {
4149
- type: "Fraction";
6002
+ rows: {
6003
+ type: "MatcherRow";
6004
+ items: {
6005
+ type: "MatcherItem";
6006
+ inlines: ({
6007
+ value: string;
6008
+ type: "FreeText";
6009
+ } | {
6010
+ type: "Space";
6011
+ } | {
6012
+ value: string;
6013
+ type: "HighlightedText";
6014
+ highlight?: [number, number] | undefined;
6015
+ } | {
6016
+ value: string;
6017
+ type: "ColorText";
6018
+ color: string;
6019
+ highlight?: [number, number] | undefined;
6020
+ } | {
6021
+ value: string;
6022
+ type: "BoldText";
6023
+ highlight?: [number, number] | undefined;
6024
+ } | {
6025
+ type: "Fraction";
6026
+ name: string;
6027
+ answer?: string | undefined;
6028
+ numerator?: number | undefined;
6029
+ denominator?: number | undefined;
6030
+ simplified?: boolean | undefined;
6031
+ })[];
6032
+ itemId: string;
6033
+ }[];
6034
+ }[];
6035
+ answers: string[][];
6036
+ colors?: string[] | undefined;
6037
+ }>, {
6038
+ type: "MatcherBlock";
4150
6039
  name: string;
4151
- answer?: string | undefined;
4152
- numerator?: number | undefined;
4153
- denominator?: number | undefined;
4154
- simplified?: boolean | undefined;
4155
- }>]>;
4156
-
4157
- /**
4158
- * Type guard for BoldText
4159
- */
4160
- export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
4161
- type: 'bold-text';
4162
- }>;
4163
-
4164
- /**
4165
- * Type guard for ColorText
4166
- */
4167
- export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
4168
- type: 'color-text';
4169
- }>;
4170
-
4171
- export declare function isDragOptions(value: unknown): value is DragOptionsTool;
4172
-
4173
- /**
4174
- * Type guard for DragOptionsJSON
4175
- */
4176
- export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
4177
- type: 'drag-options';
4178
- }>;
4179
-
4180
- export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
4181
-
4182
- export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
4183
-
4184
- export declare function isFraction(value: unknown): value is FractionInline;
4185
-
4186
- /**
4187
- * Type guard for FractionJSON
4188
- */
4189
- export declare function isFractionJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
4190
- type: 'fraction';
4191
- }>;
4192
-
4193
- export declare function isFractionKey(key: string): boolean;
4194
-
4195
- export declare function isFreeText(value: unknown): value is FreeTextInline;
4196
-
4197
- /**
4198
- * Type guard for GroupItem
4199
- */
4200
- export declare function isGroupItem(item: LayoutItem): item is GroupItem;
4201
-
4202
- /**
4203
- * Type guard for HighlightedText
4204
- */
4205
- export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
4206
- type: 'highlighted-text';
4207
- }>;
4208
-
4209
- export declare function isInlineInput(value: unknown): value is InlineInputWidget;
4210
-
4211
- /**
4212
- * Type guard for InlineInputJSON
4213
- */
4214
- export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
4215
- type: 'inline-input';
4216
- }>;
4217
-
4218
- export declare function isInlineNode(value: unknown): value is InlineNode;
4219
-
4220
- export declare function isLineBlock(value: unknown): value is LineBlock;
4221
-
4222
- /**
4223
- * Type guard for Linebreak
4224
- */
4225
- export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
4226
- type: 'linebreak';
4227
- }>;
4228
-
4229
- export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
4230
-
4231
- /**
4232
- * Type guard for NumericKeypadJSON
4233
- */
4234
- export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
4235
- type: 'numeric-keypad';
4236
- }>;
4237
-
4238
- /**
4239
- * Type guard for OperatorItem
4240
- */
4241
- export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
4242
- type: 'operator';
4243
- }>;
4244
-
4245
- /**
4246
- * Type guard for QuestionText
4247
- */
4248
- export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
4249
- type: 'question-text';
4250
- }>;
4251
-
4252
- /**
4253
- * Type guard for RadioOptionsJSON
4254
- */
4255
- export declare function isRadioOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
4256
- type: 'radio-options';
4257
- }>;
4258
-
4259
- export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
4260
-
4261
- export declare function isSpace(value: unknown): value is SpaceInline;
4262
-
4263
- /**
4264
- * Type guard for SpaceItem
4265
- */
4266
- export declare function isSpaceItem(item: LayoutItem): item is Extract<LayoutItem, {
4267
- type: 'space';
4268
- }>;
4269
-
4270
- /**
4271
- * Type guard for TableCellItem
4272
- */
4273
- export declare function isTableCellItem(item: LayoutItem): item is Extract<LayoutItem, {
4274
- type: 'table-cell';
4275
- }>;
4276
-
4277
- /**
4278
- * Type guard for TableItem
4279
- */
4280
- export declare function isTableItem(item: LayoutItem): item is Extract<LayoutItem, {
4281
- type: 'table';
4282
- }>;
4283
-
4284
- /**
4285
- * Type guard for TableRowItem
4286
- */
4287
- export declare function isTableRowItem(item: LayoutItem): item is Extract<LayoutItem, {
4288
- type: 'table-row';
4289
- }>;
4290
-
4291
- export declare function isTextBlock(value: unknown): value is TextBlock;
4292
-
4293
- /**
4294
- * Type guard for TextItem
4295
- */
4296
- export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
4297
- type: 'text';
4298
- }>;
4299
-
4300
- export declare function isToolNode(value: unknown): value is ToolNode;
4301
-
4302
- export declare function isValidationNode(value: unknown): value is ValidationNode;
4303
-
4304
- /**
4305
- * Check if an expression is syntactically valid
4306
- *
4307
- * @param expression - The expression to check
4308
- * @returns true if valid, false otherwise
4309
- */
4310
- export declare function isValidExpression(expression: string): boolean;
4311
-
4312
- /**
4313
- * Type guard for WidgetRef
4314
- */
4315
- export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
4316
- type: 'widget-ref';
6040
+ rows: {
6041
+ type: "MatcherRow";
6042
+ items: {
6043
+ type: "MatcherItem";
6044
+ inlines: ({
6045
+ value: string;
6046
+ type: "FreeText";
6047
+ } | {
6048
+ type: "Space";
6049
+ } | {
6050
+ value: string;
6051
+ type: "HighlightedText";
6052
+ highlight?: [number, number] | undefined;
6053
+ } | {
6054
+ value: string;
6055
+ type: "ColorText";
6056
+ color: string;
6057
+ highlight?: [number, number] | undefined;
6058
+ } | {
6059
+ value: string;
6060
+ type: "BoldText";
6061
+ highlight?: [number, number] | undefined;
6062
+ } | {
6063
+ type: "Fraction";
6064
+ name: string;
6065
+ simplified: boolean;
6066
+ answer?: string | undefined;
6067
+ numerator?: number | undefined;
6068
+ denominator?: number | undefined;
6069
+ })[];
6070
+ itemId: string;
6071
+ }[];
6072
+ }[];
6073
+ answers: string[][];
6074
+ colors?: string[] | undefined;
6075
+ }, {
6076
+ type: "MatcherBlock";
6077
+ name: string;
6078
+ rows: {
6079
+ type: "MatcherRow";
6080
+ items: {
6081
+ type: "MatcherItem";
6082
+ inlines: ({
6083
+ value: string;
6084
+ type: "FreeText";
6085
+ } | {
6086
+ type: "Space";
6087
+ } | {
6088
+ value: string;
6089
+ type: "HighlightedText";
6090
+ highlight?: [number, number] | undefined;
6091
+ } | {
6092
+ value: string;
6093
+ type: "ColorText";
6094
+ color: string;
6095
+ highlight?: [number, number] | undefined;
6096
+ } | {
6097
+ value: string;
6098
+ type: "BoldText";
6099
+ highlight?: [number, number] | undefined;
6100
+ } | {
6101
+ type: "Fraction";
6102
+ name: string;
6103
+ answer?: string | undefined;
6104
+ numerator?: number | undefined;
6105
+ denominator?: number | undefined;
6106
+ simplified?: boolean | undefined;
6107
+ })[];
6108
+ itemId: string;
6109
+ }[];
6110
+ }[];
6111
+ answers: string[][];
6112
+ colors?: string[] | undefined;
4317
6113
  }>;
4318
6114
 
4319
- /**
4320
- * JSON Layout Item Types
4321
- *
4322
- * These are the types used in the JSON output format.
4323
- */
4324
- export declare const JSON_TYPES: {
4325
- /** Question/instruction text */
4326
- readonly QUESTION_TEXT: "question-text";
4327
- /** Regular text element */
4328
- readonly TEXT: "text";
4329
- /** Spacing element */
4330
- readonly SPACE: "space";
4331
- /** Text with optional highlighting */
4332
- readonly HIGHLIGHTED_TEXT: "highlighted-text";
4333
- /** Text with color styling */
4334
- readonly COLOR_TEXT: "color-text";
4335
- /** Bold text */
4336
- readonly BOLD_TEXT: "bold-text";
4337
- /** Reference to a widget */
4338
- readonly WIDGET_REF: "widget-ref";
4339
- /** Line break element */
4340
- readonly LINEBREAK: "linebreak";
4341
- /** Grouped layout items */
4342
- readonly GROUP: "group";
4343
- /** Operator symbol */
4344
- readonly OPERATOR: "operator";
4345
- /** Table layout block */
4346
- readonly TABLE: "table";
4347
- /** Row within a table */
4348
- readonly TABLE_ROW: "table-row";
4349
- /** Cell within a table */
4350
- readonly TABLE_CELL: "table-cell";
4351
- /** Number line layout block */
4352
- readonly NUMBER_LINE: "number-line";
4353
- /** Position marker within a number line */
4354
- readonly NUMBER_LINE_POSITION: "number-line-position";
4355
- /** Dynamic subdivision counter embedded in a number line */
4356
- readonly NUMBER_LINE_COUNTER: "number-line-counter";
4357
- /** Highlighted range within a number line */
4358
- readonly NUMBER_LINE_HIGHLIGHT: "number-line-highlight";
4359
- /** Inline input widget (string or numeric) */
4360
- readonly INLINE_INPUT: "inline-input";
4361
- /** Drag-and-drop options widget */
4362
- readonly DRAG_OPTIONS: "drag-options";
4363
- /** Radio button options widget */
4364
- readonly RADIO_OPTIONS: "radio-options";
4365
- /** Numeric keypad widget */
4366
- readonly NUMERIC_KEYPAD: "numeric-keypad";
4367
- /** Inline fraction widget */
4368
- readonly FRACTION: "fraction";
4369
- };
4370
-
4371
- /**
4372
- * Type helper to get all JSON type values as a union type
4373
- */
4374
- export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
4375
-
4376
- export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
4377
-
4378
- export declare const LayoutItemSchema: z.ZodType<any>;
4379
-
4380
- /**
4381
- * DUMB layout renderer - no opinions about spacing or layout.
4382
- */
4383
- export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
4384
-
4385
- export declare interface LayoutRendererProps {
4386
- item: LayoutItem;
4387
- widgets: Record<string, WidgetJSON>;
4388
- values: Record<string, string>;
4389
- droppedInputs: Set<string>;
4390
- validationDetails?: Record<string, boolean> | null;
4391
- onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
4392
- onInputFocus?: (widgetId: string) => void;
4393
- }
4394
-
4395
- /**
4396
- * Error thrown when lexer fails to tokenize input
4397
- */
4398
- export declare class LexerError extends EngineError {
4399
- readonly lexerErrors: ILexingError[];
4400
- readonly positions: SourcePosition[];
4401
- constructor(errors: ILexingError[]);
4402
- }
4403
-
4404
- export declare type LineBlock = z.infer<typeof LineBlockSchema>;
6115
+ export declare type MatcherItem = z.infer<typeof MatcherItemSchema>;
4405
6116
 
4406
- /**
4407
- * Line block schema - represents a visual row of inline elements
4408
- *
4409
- * One line = one visual row in the UI
4410
- * Contains an ordered sequence of inline elements
4411
- *
4412
- * @example
4413
- * {
4414
- * type: "LineBlock",
4415
- * inlines: [
4416
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
4417
- * { type: "InlineInput", name: "x", length: 1 },
4418
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
4419
- * ]
4420
- * }
4421
- */
4422
- export declare const LineBlockSchema: z.ZodObject<{
4423
- type: z.ZodLiteral<"LineBlock">;
6117
+ export declare const MatcherItemSchema: z.ZodObject<{
6118
+ type: z.ZodLiteral<"MatcherItem">;
6119
+ itemId: z.ZodString;
4424
6120
  inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
4425
6121
  type: z.ZodLiteral<"FreeText">;
4426
6122
  value: z.ZodString;
@@ -4475,43 +6171,7 @@ export declare const LineBlockSchema: z.ZodObject<{
4475
6171
  value: string;
4476
6172
  type: "BoldText";
4477
6173
  highlight?: [number, number] | undefined;
4478
- }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
4479
- type: z.ZodLiteral<"InlineInput">;
4480
- name: z.ZodString;
4481
- inputType: z.ZodLiteral<"string">;
4482
- length: z.ZodNumber;
4483
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
4484
- }, "strip", z.ZodTypeAny, {
4485
- length: number;
4486
- type: "InlineInput";
4487
- inputType: "string";
4488
- name: string;
4489
- answer?: string | number | undefined;
4490
- }, {
4491
- length: number;
4492
- type: "InlineInput";
4493
- inputType: "string";
4494
- name: string;
4495
- answer?: string | number | undefined;
4496
- }>, z.ZodObject<{
4497
- type: z.ZodLiteral<"InlineInput">;
4498
- name: z.ZodString;
4499
- inputType: z.ZodLiteral<"numeric">;
4500
- digits: z.ZodNumber;
4501
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
4502
- }, "strip", z.ZodTypeAny, {
4503
- type: "InlineInput";
4504
- inputType: "numeric";
4505
- name: string;
4506
- digits: number;
4507
- answer?: string | number | undefined;
4508
- }, {
4509
- type: "InlineInput";
4510
- inputType: "numeric";
4511
- name: string;
4512
- digits: number;
4513
- answer?: string | number | undefined;
4514
- }>]>, z.ZodObject<{
6174
+ }>, z.ZodEffects<z.ZodObject<{
4515
6175
  type: z.ZodLiteral<"Fraction">;
4516
6176
  name: z.ZodString;
4517
6177
  numerator: z.ZodOptional<z.ZodNumber>;
@@ -4532,9 +6192,23 @@ export declare const LineBlockSchema: z.ZodObject<{
4532
6192
  numerator?: number | undefined;
4533
6193
  denominator?: number | undefined;
4534
6194
  simplified?: boolean | undefined;
6195
+ }>, {
6196
+ type: "Fraction";
6197
+ name: string;
6198
+ simplified: boolean;
6199
+ answer?: string | undefined;
6200
+ numerator?: number | undefined;
6201
+ denominator?: number | undefined;
6202
+ }, {
6203
+ type: "Fraction";
6204
+ name: string;
6205
+ answer?: string | undefined;
6206
+ numerator?: number | undefined;
6207
+ denominator?: number | undefined;
6208
+ simplified?: boolean | undefined;
4535
6209
  }>]>, "many">;
4536
6210
  }, "strip", z.ZodTypeAny, {
4537
- type: "LineBlock";
6211
+ type: "MatcherItem";
4538
6212
  inlines: ({
4539
6213
  value: string;
4540
6214
  type: "FreeText";
@@ -4553,18 +6227,6 @@ export declare const LineBlockSchema: z.ZodObject<{
4553
6227
  value: string;
4554
6228
  type: "BoldText";
4555
6229
  highlight?: [number, number] | undefined;
4556
- } | {
4557
- length: number;
4558
- type: "InlineInput";
4559
- inputType: "string";
4560
- name: string;
4561
- answer?: string | number | undefined;
4562
- } | {
4563
- type: "InlineInput";
4564
- inputType: "numeric";
4565
- name: string;
4566
- digits: number;
4567
- answer?: string | number | undefined;
4568
6230
  } | {
4569
6231
  type: "Fraction";
4570
6232
  name: string;
@@ -4573,8 +6235,9 @@ export declare const LineBlockSchema: z.ZodObject<{
4573
6235
  numerator?: number | undefined;
4574
6236
  denominator?: number | undefined;
4575
6237
  })[];
6238
+ itemId: string;
4576
6239
  }, {
4577
- type: "LineBlock";
6240
+ type: "MatcherItem";
4578
6241
  inlines: ({
4579
6242
  value: string;
4580
6243
  type: "FreeText";
@@ -4593,18 +6256,6 @@ export declare const LineBlockSchema: z.ZodObject<{
4593
6256
  value: string;
4594
6257
  type: "BoldText";
4595
6258
  highlight?: [number, number] | undefined;
4596
- } | {
4597
- length: number;
4598
- type: "InlineInput";
4599
- inputType: "string";
4600
- name: string;
4601
- answer?: string | number | undefined;
4602
- } | {
4603
- type: "InlineInput";
4604
- inputType: "numeric";
4605
- name: string;
4606
- digits: number;
4607
- answer?: string | number | undefined;
4608
6259
  } | {
4609
6260
  type: "Fraction";
4610
6261
  name: string;
@@ -4613,19 +6264,230 @@ export declare const LineBlockSchema: z.ZodObject<{
4613
6264
  denominator?: number | undefined;
4614
6265
  simplified?: boolean | undefined;
4615
6266
  })[];
6267
+ itemId: string;
4616
6268
  }>;
4617
6269
 
4618
- export declare type Linebreak = z.infer<typeof LinebreakSchema>;
6270
+ export declare type MatcherRow = z.infer<typeof MatcherRowSchema>;
4619
6271
 
4620
- export declare const LinebreakSchema: z.ZodObject<{
4621
- id: z.ZodString;
4622
- type: z.ZodLiteral<"linebreak">;
6272
+ export declare const MatcherRowSchema: z.ZodObject<{
6273
+ type: z.ZodLiteral<"MatcherRow">;
6274
+ /** At least one item per row */
6275
+ items: z.ZodArray<z.ZodObject<{
6276
+ type: z.ZodLiteral<"MatcherItem">;
6277
+ itemId: z.ZodString;
6278
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
6279
+ type: z.ZodLiteral<"FreeText">;
6280
+ value: z.ZodString;
6281
+ }, "strip", z.ZodTypeAny, {
6282
+ value: string;
6283
+ type: "FreeText";
6284
+ }, {
6285
+ value: string;
6286
+ type: "FreeText";
6287
+ }>, z.ZodObject<{
6288
+ type: z.ZodLiteral<"Space">;
6289
+ }, "strip", z.ZodTypeAny, {
6290
+ type: "Space";
6291
+ }, {
6292
+ type: "Space";
6293
+ }>, z.ZodObject<{
6294
+ type: z.ZodLiteral<"HighlightedText">;
6295
+ value: z.ZodString;
6296
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
6297
+ }, "strip", z.ZodTypeAny, {
6298
+ value: string;
6299
+ type: "HighlightedText";
6300
+ highlight?: [number, number] | undefined;
6301
+ }, {
6302
+ value: string;
6303
+ type: "HighlightedText";
6304
+ highlight?: [number, number] | undefined;
6305
+ }>, z.ZodObject<{
6306
+ type: z.ZodLiteral<"ColorText">;
6307
+ value: z.ZodString;
6308
+ color: z.ZodString;
6309
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
6310
+ }, "strip", z.ZodTypeAny, {
6311
+ value: string;
6312
+ type: "ColorText";
6313
+ color: string;
6314
+ highlight?: [number, number] | undefined;
6315
+ }, {
6316
+ value: string;
6317
+ type: "ColorText";
6318
+ color: string;
6319
+ highlight?: [number, number] | undefined;
6320
+ }>, z.ZodObject<{
6321
+ type: z.ZodLiteral<"BoldText">;
6322
+ value: z.ZodString;
6323
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
6324
+ }, "strip", z.ZodTypeAny, {
6325
+ value: string;
6326
+ type: "BoldText";
6327
+ highlight?: [number, number] | undefined;
6328
+ }, {
6329
+ value: string;
6330
+ type: "BoldText";
6331
+ highlight?: [number, number] | undefined;
6332
+ }>, z.ZodEffects<z.ZodObject<{
6333
+ type: z.ZodLiteral<"Fraction">;
6334
+ name: z.ZodString;
6335
+ numerator: z.ZodOptional<z.ZodNumber>;
6336
+ denominator: z.ZodOptional<z.ZodNumber>;
6337
+ answer: z.ZodOptional<z.ZodString>;
6338
+ simplified: z.ZodDefault<z.ZodBoolean>;
6339
+ }, "strip", z.ZodTypeAny, {
6340
+ type: "Fraction";
6341
+ name: string;
6342
+ simplified: boolean;
6343
+ answer?: string | undefined;
6344
+ numerator?: number | undefined;
6345
+ denominator?: number | undefined;
6346
+ }, {
6347
+ type: "Fraction";
6348
+ name: string;
6349
+ answer?: string | undefined;
6350
+ numerator?: number | undefined;
6351
+ denominator?: number | undefined;
6352
+ simplified?: boolean | undefined;
6353
+ }>, {
6354
+ type: "Fraction";
6355
+ name: string;
6356
+ simplified: boolean;
6357
+ answer?: string | undefined;
6358
+ numerator?: number | undefined;
6359
+ denominator?: number | undefined;
6360
+ }, {
6361
+ type: "Fraction";
6362
+ name: string;
6363
+ answer?: string | undefined;
6364
+ numerator?: number | undefined;
6365
+ denominator?: number | undefined;
6366
+ simplified?: boolean | undefined;
6367
+ }>]>, "many">;
6368
+ }, "strip", z.ZodTypeAny, {
6369
+ type: "MatcherItem";
6370
+ inlines: ({
6371
+ value: string;
6372
+ type: "FreeText";
6373
+ } | {
6374
+ type: "Space";
6375
+ } | {
6376
+ value: string;
6377
+ type: "HighlightedText";
6378
+ highlight?: [number, number] | undefined;
6379
+ } | {
6380
+ value: string;
6381
+ type: "ColorText";
6382
+ color: string;
6383
+ highlight?: [number, number] | undefined;
6384
+ } | {
6385
+ value: string;
6386
+ type: "BoldText";
6387
+ highlight?: [number, number] | undefined;
6388
+ } | {
6389
+ type: "Fraction";
6390
+ name: string;
6391
+ simplified: boolean;
6392
+ answer?: string | undefined;
6393
+ numerator?: number | undefined;
6394
+ denominator?: number | undefined;
6395
+ })[];
6396
+ itemId: string;
6397
+ }, {
6398
+ type: "MatcherItem";
6399
+ inlines: ({
6400
+ value: string;
6401
+ type: "FreeText";
6402
+ } | {
6403
+ type: "Space";
6404
+ } | {
6405
+ value: string;
6406
+ type: "HighlightedText";
6407
+ highlight?: [number, number] | undefined;
6408
+ } | {
6409
+ value: string;
6410
+ type: "ColorText";
6411
+ color: string;
6412
+ highlight?: [number, number] | undefined;
6413
+ } | {
6414
+ value: string;
6415
+ type: "BoldText";
6416
+ highlight?: [number, number] | undefined;
6417
+ } | {
6418
+ type: "Fraction";
6419
+ name: string;
6420
+ answer?: string | undefined;
6421
+ numerator?: number | undefined;
6422
+ denominator?: number | undefined;
6423
+ simplified?: boolean | undefined;
6424
+ })[];
6425
+ itemId: string;
6426
+ }>, "many">;
4623
6427
  }, "strip", z.ZodTypeAny, {
4624
- type: "linebreak";
4625
- id: string;
6428
+ type: "MatcherRow";
6429
+ items: {
6430
+ type: "MatcherItem";
6431
+ inlines: ({
6432
+ value: string;
6433
+ type: "FreeText";
6434
+ } | {
6435
+ type: "Space";
6436
+ } | {
6437
+ value: string;
6438
+ type: "HighlightedText";
6439
+ highlight?: [number, number] | undefined;
6440
+ } | {
6441
+ value: string;
6442
+ type: "ColorText";
6443
+ color: string;
6444
+ highlight?: [number, number] | undefined;
6445
+ } | {
6446
+ value: string;
6447
+ type: "BoldText";
6448
+ highlight?: [number, number] | undefined;
6449
+ } | {
6450
+ type: "Fraction";
6451
+ name: string;
6452
+ simplified: boolean;
6453
+ answer?: string | undefined;
6454
+ numerator?: number | undefined;
6455
+ denominator?: number | undefined;
6456
+ })[];
6457
+ itemId: string;
6458
+ }[];
4626
6459
  }, {
4627
- type: "linebreak";
4628
- id: string;
6460
+ type: "MatcherRow";
6461
+ items: {
6462
+ type: "MatcherItem";
6463
+ inlines: ({
6464
+ value: string;
6465
+ type: "FreeText";
6466
+ } | {
6467
+ type: "Space";
6468
+ } | {
6469
+ value: string;
6470
+ type: "HighlightedText";
6471
+ highlight?: [number, number] | undefined;
6472
+ } | {
6473
+ value: string;
6474
+ type: "ColorText";
6475
+ color: string;
6476
+ highlight?: [number, number] | undefined;
6477
+ } | {
6478
+ value: string;
6479
+ type: "BoldText";
6480
+ highlight?: [number, number] | undefined;
6481
+ } | {
6482
+ type: "Fraction";
6483
+ name: string;
6484
+ answer?: string | undefined;
6485
+ numerator?: number | undefined;
6486
+ denominator?: number | undefined;
6487
+ simplified?: boolean | undefined;
6488
+ })[];
6489
+ itemId: string;
6490
+ }[];
4629
6491
  }>;
4630
6492
 
4631
6493
  export declare type NumberLineBlock = z.infer<typeof NumberLineBlockSchema>;
@@ -5978,8 +7840,8 @@ export declare function renderExercise(options: RenderOptions): () => void;
5978
7840
  export declare interface RenderOptions {
5979
7841
  container: HTMLElement | string;
5980
7842
  json: ExerciseJSON;
5981
- onSubmit?: (values: Record<string, string>) => void;
5982
- onChange?: (values: Record<string, string>) => void;
7843
+ onSubmit?: (values: Record<string, UserAnswerValue>) => void;
7844
+ onChange?: (values: Record<string, UserAnswerValue>) => void;
5983
7845
  showSubmitButton?: boolean;
5984
7846
  className?: string;
5985
7847
  }
@@ -6452,13 +8314,13 @@ export declare const TableCellItemSchema: z.ZodObject<{
6452
8314
  items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
6453
8315
  }, "strip", z.ZodTypeAny, {
6454
8316
  type: "table-cell";
6455
- id: string;
6456
8317
  items: any[];
8318
+ id: string;
6457
8319
  colspan?: number | undefined;
6458
8320
  }, {
6459
8321
  type: "table-cell";
6460
- id: string;
6461
8322
  items: any[];
8323
+ id: string;
6462
8324
  colspan?: number | undefined;
6463
8325
  }>;
6464
8326
 
@@ -6677,21 +8539,21 @@ export declare const TableItemSchema: z.ZodObject<{
6677
8539
  items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
6678
8540
  }, "strip", z.ZodTypeAny, {
6679
8541
  type: "table-cell";
6680
- id: string;
6681
8542
  items: any[];
8543
+ id: string;
6682
8544
  colspan?: number | undefined;
6683
8545
  }, {
6684
8546
  type: "table-cell";
6685
- id: string;
6686
8547
  items: any[];
8548
+ id: string;
6687
8549
  colspan?: number | undefined;
6688
8550
  }>, "many">;
6689
8551
  }, "strip", z.ZodTypeAny, {
6690
8552
  type: "table-row";
6691
8553
  cells: {
6692
8554
  type: "table-cell";
6693
- id: string;
6694
8555
  items: any[];
8556
+ id: string;
6695
8557
  colspan?: number | undefined;
6696
8558
  }[];
6697
8559
  id: string;
@@ -6699,8 +8561,8 @@ export declare const TableItemSchema: z.ZodObject<{
6699
8561
  type: "table-row";
6700
8562
  cells: {
6701
8563
  type: "table-cell";
6702
- id: string;
6703
8564
  items: any[];
8565
+ id: string;
6704
8566
  colspan?: number | undefined;
6705
8567
  }[];
6706
8568
  id: string;
@@ -6712,8 +8574,8 @@ export declare const TableItemSchema: z.ZodObject<{
6712
8574
  type: "table-row";
6713
8575
  cells: {
6714
8576
  type: "table-cell";
6715
- id: string;
6716
8577
  items: any[];
8578
+ id: string;
6717
8579
  colspan?: number | undefined;
6718
8580
  }[];
6719
8581
  id: string;
@@ -6726,8 +8588,8 @@ export declare const TableItemSchema: z.ZodObject<{
6726
8588
  type: "table-row";
6727
8589
  cells: {
6728
8590
  type: "table-cell";
6729
- id: string;
6730
8591
  items: any[];
8592
+ id: string;
6731
8593
  colspan?: number | undefined;
6732
8594
  }[];
6733
8595
  id: string;
@@ -6749,21 +8611,21 @@ export declare const TableRowItemSchema: z.ZodObject<{
6749
8611
  items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
6750
8612
  }, "strip", z.ZodTypeAny, {
6751
8613
  type: "table-cell";
6752
- id: string;
6753
8614
  items: any[];
8615
+ id: string;
6754
8616
  colspan?: number | undefined;
6755
8617
  }, {
6756
8618
  type: "table-cell";
6757
- id: string;
6758
8619
  items: any[];
8620
+ id: string;
6759
8621
  colspan?: number | undefined;
6760
8622
  }>, "many">;
6761
8623
  }, "strip", z.ZodTypeAny, {
6762
8624
  type: "table-row";
6763
8625
  cells: {
6764
8626
  type: "table-cell";
6765
- id: string;
6766
8627
  items: any[];
8628
+ id: string;
6767
8629
  colspan?: number | undefined;
6768
8630
  }[];
6769
8631
  id: string;
@@ -6771,8 +8633,8 @@ export declare const TableRowItemSchema: z.ZodObject<{
6771
8633
  type: "table-row";
6772
8634
  cells: {
6773
8635
  type: "table-cell";
6774
- id: string;
6775
8636
  items: any[];
8637
+ id: string;
6776
8638
  colspan?: number | undefined;
6777
8639
  }[];
6778
8640
  id: string;
@@ -7182,6 +9044,18 @@ export declare class TransformError extends EngineError {
7182
9044
  constructor(message: string, position?: SourcePosition);
7183
9045
  }
7184
9046
 
9047
+ /**
9048
+ * Shared value types for the renderer layer.
9049
+ *
9050
+ * `UserAnswerValue` is the runtime type of any answer collected by the renderer:
9051
+ * - `string` — all scalar widgets (inline-input, radio-options, drag-options, number-line inputs…)
9052
+ * - `string[][]` — matcher widget (groups of item IDs, no JSON serialisation needed)
9053
+ *
9054
+ * This union matches the type accepted by `validate()` and avoids any
9055
+ * JSON.stringify / JSON.parse round-trips for structured widget values.
9056
+ */
9057
+ declare type UserAnswerValue = string | string[][];
9058
+
7185
9059
  /**
7186
9060
  * Validate user inputs against an exercise
7187
9061
  *
@@ -7202,7 +9076,7 @@ export declare class TransformError extends EngineError {
7202
9076
  * }
7203
9077
  * ```
7204
9078
  */
7205
- export declare function validate(exercise: ExerciseJSON, userInputs: Record<string, string | number>): ValidationResult;
9079
+ export declare function validate(exercise: ExerciseJSON, userInputs: Record<string, string | number | string[][]>): ValidationResult;
7206
9080
 
7207
9081
  /**
7208
9082
  * Validate that an expression will return a boolean
@@ -7259,11 +9133,25 @@ export declare function validateExerciseJSON(data: unknown): {
7259
9133
  numerator: number | null;
7260
9134
  denominator: number | null;
7261
9135
  simplified: boolean;
9136
+ } | {
9137
+ type: "matcher";
9138
+ rows: {
9139
+ type: "matcher-row";
9140
+ items: {
9141
+ type: "matcher-item";
9142
+ itemId: string;
9143
+ id: string;
9144
+ content: any[];
9145
+ }[];
9146
+ id: string;
9147
+ }[];
9148
+ groupCount: number;
9149
+ colors?: string[] | undefined;
7262
9150
  }>;
7263
9151
  validation?: {
7264
9152
  mode: "simple" | "expression";
7265
9153
  expression?: string | undefined;
7266
- answers?: Record<string, string | number> | undefined;
9154
+ answers?: Record<string, string | number | string[][]> | undefined;
7267
9155
  variables?: string[] | undefined;
7268
9156
  } | undefined;
7269
9157
  id?: string | undefined;
@@ -7317,11 +9205,25 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
7317
9205
  numerator: number | null;
7318
9206
  denominator: number | null;
7319
9207
  simplified: boolean;
9208
+ } | {
9209
+ type: "matcher";
9210
+ rows: {
9211
+ type: "matcher-row";
9212
+ items: {
9213
+ type: "matcher-item";
9214
+ itemId: string;
9215
+ id: string;
9216
+ content: any[];
9217
+ }[];
9218
+ id: string;
9219
+ }[];
9220
+ groupCount: number;
9221
+ colors?: string[] | undefined;
7320
9222
  }>;
7321
9223
  validation?: {
7322
9224
  mode: "simple" | "expression";
7323
9225
  expression?: string | undefined;
7324
- answers?: Record<string, string | number> | undefined;
9226
+ answers?: Record<string, string | number | string[][]> | undefined;
7325
9227
  variables?: string[] | undefined;
7326
9228
  } | undefined;
7327
9229
  id?: string | undefined;
@@ -7357,11 +9259,25 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
7357
9259
  numerator: number | null;
7358
9260
  denominator: number | null;
7359
9261
  simplified: boolean;
9262
+ } | {
9263
+ type: "matcher";
9264
+ rows: {
9265
+ type: "matcher-row";
9266
+ items: {
9267
+ type: "matcher-item";
9268
+ itemId: string;
9269
+ id: string;
9270
+ content: any[];
9271
+ }[];
9272
+ id: string;
9273
+ }[];
9274
+ groupCount: number;
9275
+ colors?: string[] | undefined;
7360
9276
  }>;
7361
9277
  validation?: {
7362
9278
  mode: "simple" | "expression";
7363
9279
  expression?: string | undefined;
7364
- answers?: Record<string, string | number> | undefined;
9280
+ answers?: Record<string, string | number | string[][]> | undefined;
7365
9281
  variables?: string[] | undefined;
7366
9282
  } | undefined;
7367
9283
  id?: string | undefined;
@@ -7399,7 +9315,7 @@ export declare function validateInputFormats(exercise: ExerciseJSON, userInputs:
7399
9315
  * @param userInputs - User's answers keyed by widget ID
7400
9316
  * @returns Validation result
7401
9317
  */
7402
- export declare function validateSimple(exercise: ValidatedExerciseJSON, userInputs: Record<string, string | number>): ValidationResult;
9318
+ export declare function validateSimple(exercise: ValidatedExerciseJSON, userInputs: Record<string, string | number | string[][]>): ValidationResult;
7403
9319
 
7404
9320
  /**
7405
9321
  * Validate a widget JSON object at runtime
@@ -7431,6 +9347,20 @@ export declare function validateWidgetJSON(data: unknown): {
7431
9347
  numerator: number | null;
7432
9348
  denominator: number | null;
7433
9349
  simplified: boolean;
9350
+ } | {
9351
+ type: "matcher";
9352
+ rows: {
9353
+ type: "matcher-row";
9354
+ items: {
9355
+ type: "matcher-item";
9356
+ itemId: string;
9357
+ id: string;
9358
+ content: any[];
9359
+ }[];
9360
+ id: string;
9361
+ }[];
9362
+ groupCount: number;
9363
+ colors?: string[] | undefined;
7434
9364
  };
7435
9365
 
7436
9366
  /**
@@ -7462,6 +9392,20 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
7462
9392
  numerator: number | null;
7463
9393
  denominator: number | null;
7464
9394
  simplified: boolean;
9395
+ } | {
9396
+ type: "matcher";
9397
+ rows: {
9398
+ type: "matcher-row";
9399
+ items: {
9400
+ type: "matcher-item";
9401
+ itemId: string;
9402
+ id: string;
9403
+ content: any[];
9404
+ }[];
9405
+ id: string;
9406
+ }[];
9407
+ groupCount: number;
9408
+ colors?: string[] | undefined;
7465
9409
  }, {
7466
9410
  length: number;
7467
9411
  type: "inline-input";
@@ -7485,6 +9429,20 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
7485
9429
  numerator: number | null;
7486
9430
  denominator: number | null;
7487
9431
  simplified: boolean;
9432
+ } | {
9433
+ type: "matcher";
9434
+ rows: {
9435
+ type: "matcher-row";
9436
+ items: {
9437
+ type: "matcher-item";
9438
+ itemId: string;
9439
+ id: string;
9440
+ content: any[];
9441
+ }[];
9442
+ id: string;
9443
+ }[];
9444
+ groupCount: number;
9445
+ colors?: string[] | undefined;
7488
9446
  }>;
7489
9447
 
7490
9448
  /**
@@ -7499,18 +9457,18 @@ export declare type ValidationJSON = z.infer<typeof ValidationJSONSchema>;
7499
9457
 
7500
9458
  export declare const ValidationJSONSchema: z.ZodObject<{
7501
9459
  mode: z.ZodEnum<["simple", "expression"]>;
7502
- answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
9460
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodArray<z.ZodArray<z.ZodString, "many">, "many">]>>>;
7503
9461
  expression: z.ZodOptional<z.ZodString>;
7504
9462
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7505
9463
  }, "strip", z.ZodTypeAny, {
7506
9464
  mode: "simple" | "expression";
7507
9465
  expression?: string | undefined;
7508
- answers?: Record<string, string | number> | undefined;
9466
+ answers?: Record<string, string | number | string[][]> | undefined;
7509
9467
  variables?: string[] | undefined;
7510
9468
  }, {
7511
9469
  mode: "simple" | "expression";
7512
9470
  expression?: string | undefined;
7513
- answers?: Record<string, string | number> | undefined;
9471
+ answers?: Record<string, string | number | string[][]> | undefined;
7514
9472
  variables?: string[] | undefined;
7515
9473
  }>;
7516
9474
 
@@ -7627,6 +9585,80 @@ export declare const WidgetJSONSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"inpu
7627
9585
  numerator: number | null;
7628
9586
  denominator: number | null;
7629
9587
  simplified: boolean;
9588
+ }>, z.ZodObject<{
9589
+ type: z.ZodLiteral<"matcher">;
9590
+ rows: z.ZodArray<z.ZodObject<{
9591
+ id: z.ZodString;
9592
+ type: z.ZodLiteral<"matcher-row">;
9593
+ items: z.ZodArray<z.ZodObject<{
9594
+ id: z.ZodString;
9595
+ type: z.ZodLiteral<"matcher-item">;
9596
+ /** Item identifier (no pipe allowed) */
9597
+ itemId: z.ZodString;
9598
+ /** Display-only inline content */
9599
+ content: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
9600
+ }, "strip", z.ZodTypeAny, {
9601
+ type: "matcher-item";
9602
+ itemId: string;
9603
+ id: string;
9604
+ content: any[];
9605
+ }, {
9606
+ type: "matcher-item";
9607
+ itemId: string;
9608
+ id: string;
9609
+ content: any[];
9610
+ }>, "many">;
9611
+ }, "strip", z.ZodTypeAny, {
9612
+ type: "matcher-row";
9613
+ items: {
9614
+ type: "matcher-item";
9615
+ itemId: string;
9616
+ id: string;
9617
+ content: any[];
9618
+ }[];
9619
+ id: string;
9620
+ }, {
9621
+ type: "matcher-row";
9622
+ items: {
9623
+ type: "matcher-item";
9624
+ itemId: string;
9625
+ id: string;
9626
+ content: any[];
9627
+ }[];
9628
+ id: string;
9629
+ }>, "many">;
9630
+ /** Optional color palette for the renderer (one color per answer group) */
9631
+ colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9632
+ /** Number of answer groups — equals answers.length, stored here to avoid prop-drilling. */
9633
+ groupCount: z.ZodNumber;
9634
+ }, "strip", z.ZodTypeAny, {
9635
+ type: "matcher";
9636
+ rows: {
9637
+ type: "matcher-row";
9638
+ items: {
9639
+ type: "matcher-item";
9640
+ itemId: string;
9641
+ id: string;
9642
+ content: any[];
9643
+ }[];
9644
+ id: string;
9645
+ }[];
9646
+ groupCount: number;
9647
+ colors?: string[] | undefined;
9648
+ }, {
9649
+ type: "matcher";
9650
+ rows: {
9651
+ type: "matcher-row";
9652
+ items: {
9653
+ type: "matcher-item";
9654
+ itemId: string;
9655
+ id: string;
9656
+ content: any[];
9657
+ }[];
9658
+ id: string;
9659
+ }[];
9660
+ groupCount: number;
9661
+ colors?: string[] | undefined;
7630
9662
  }>]>;
7631
9663
 
7632
9664
  export declare type WidgetRef = z.infer<typeof WidgetRefSchema>;
@@ -7655,12 +9687,14 @@ export declare const WidgetRenderer: default_2.FC<WidgetRendererProps>;
7655
9687
  export declare interface WidgetRendererProps {
7656
9688
  widget: WidgetJSON;
7657
9689
  widgetId: string;
7658
- value: string;
9690
+ value: UserAnswerValue | undefined;
7659
9691
  values?: Record<string, string>;
7660
9692
  isDropped?: boolean;
7661
9693
  validationStatus?: ValidationStatus;
7662
9694
  droppedInputs?: Set<string>;
7663
- onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
9695
+ /** All widgets in the exercise — needed so MatcherWidget can resolve refs in its items. */
9696
+ widgets?: Record<string, WidgetJSON>;
9697
+ onChange: (widgetId: string, value: UserAnswerValue, fromDrop?: boolean, sourceOptionId?: string) => void;
7664
9698
  onInputFocus?: (widgetId: string) => void;
7665
9699
  onKeypadChange?: (value: string) => void;
7666
9700
  }
@@ -7677,7 +9711,7 @@ export declare interface WidgetValidation {
7677
9711
  /** The widget ID */
7678
9712
  widgetId: string;
7679
9713
  /** The user's input value */
7680
- userValue: string | number | undefined;
9714
+ userValue: string | number | string[][] | undefined;
7681
9715
  /** Whether the input is correct */
7682
9716
  isCorrect: boolean;
7683
9717
  /** Optional error message (for debugging) */