@mathscan/math-exercise-engine 1.0.6 → 1.0.7

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
@@ -29,6 +29,12 @@ export declare const AST_TYPES: {
29
29
  readonly TEXT_BLOCK: "TextBlock";
30
30
  /** Line containing inline elements */
31
31
  readonly LINE_BLOCK: "LineBlock";
32
+ /** Table layout block */
33
+ readonly TABLE_BLOCK: "TableBlock";
34
+ /** Row within a table */
35
+ readonly TABLE_ROW: "TableRow";
36
+ /** Cell within a table row */
37
+ readonly TABLE_CELL: "TableCell";
32
38
  /** Drag-and-drop options tool */
33
39
  readonly DRAG_OPTIONS: "DragOptions";
34
40
  /** Numeric keypad input tool */
@@ -186,7 +192,7 @@ export declare function compileWithAST(dsl: string): {
186
192
  type: "ExpressionValidation";
187
193
  };
188
194
  type: "ExerciseDocument";
189
- lines: {
195
+ lines: ({
190
196
  type: "LineBlock";
191
197
  inlines: ({
192
198
  value: string;
@@ -219,7 +225,48 @@ export declare function compileWithAST(dsl: string): {
219
225
  digits: number;
220
226
  answer?: string | number | undefined;
221
227
  })[];
222
- }[];
228
+ } | {
229
+ type: "TableBlock";
230
+ cols: number;
231
+ rows: {
232
+ type: "TableRow";
233
+ cells: {
234
+ type: "TableCell";
235
+ inlines: ({
236
+ value: string;
237
+ type: "FreeText";
238
+ } | {
239
+ type: "Space";
240
+ } | {
241
+ value: string;
242
+ type: "HighlightedText";
243
+ highlight?: [number, number] | undefined;
244
+ } | {
245
+ value: string;
246
+ type: "ColorText";
247
+ color: string;
248
+ highlight?: [number, number] | undefined;
249
+ } | {
250
+ value: string;
251
+ type: "BoldText";
252
+ highlight?: [number, number] | undefined;
253
+ } | {
254
+ length: number;
255
+ type: "InlineInput";
256
+ inputType: "string";
257
+ name: string;
258
+ answer?: string | number | undefined;
259
+ } | {
260
+ type: "InlineInput";
261
+ inputType: "numeric";
262
+ name: string;
263
+ digits: number;
264
+ answer?: string | number | undefined;
265
+ })[];
266
+ colspan?: number | undefined;
267
+ }[];
268
+ }[];
269
+ })[];
223
270
  question?: {
224
271
  value: string;
225
272
  type: "TextBlock";
@@ -268,693 +315,1588 @@ export declare function compileWithAST(dsl: string): {
268
315
  };
269
316
  };
270
317
 
271
- /**
272
- * Create a bold text inline element
273
- */
274
- export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
275
-
276
- /**
277
- * Create a color text inline element
278
- */
279
- export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
280
-
281
- /**
282
- * Create a drag options tool
283
- */
284
- export declare function createDragOptions(options: string[]): DragOptionsTool;
285
-
286
- /**
287
- * Create an exercise document
288
- */
289
- export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: z.infer<typeof LineBlockSchema>[], validation: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
290
-
291
- /**
292
- * Create an expression validation node
293
- */
294
- export declare function createExpressionValidation(expression: string): ExpressionValidation;
295
-
296
- /**
297
- * Create a free text inline element
298
- */
299
- export declare function createFreeText(value: string): FreeTextInline;
300
-
301
- /**
302
- * Create a highlighted text inline element
303
- */
304
- export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
305
-
306
- /**
307
- * Create a line block
308
- */
309
- export declare function createLineBlock(inlines: any[]): LineBlock;
310
-
311
- /**
312
- * Create a numeric inline input widget (W_N_I)
313
- */
314
- export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
315
-
316
- /**
317
- * Create a numeric keypad tool
318
- */
319
- export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
320
-
321
- /**
322
- * Create a simple validation node
323
- */
324
- export declare function createSimpleValidation(): SimpleValidation;
325
-
326
- /**
327
- * Create a space inline element
328
- */
329
- export declare function createSpace(): SpaceInline;
330
-
331
- /**
332
- * Create a string inline input widget (W_S_I)
333
- */
334
- export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
335
-
336
- /**
337
- * Create a text block (question)
338
- */
339
- export declare function createTextBlock(value: string): TextBlock;
340
-
341
- export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
342
-
343
- export declare const DragOptionsJSONSchema: z.ZodObject<{
344
- type: z.ZodLiteral<"drag-options">;
345
- options: z.ZodArray<z.ZodString, "many">;
346
- }, "strip", z.ZodTypeAny, {
347
- type: "drag-options";
348
- options: string[];
349
- }, {
350
- type: "drag-options";
351
- options: string[];
352
- }>;
353
-
354
- export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
355
-
356
- /**
357
- * Drag options tool schema - draggable buttons/options
358
- *
359
- * Common use cases:
360
- * - Comparison symbols: ["<", ">", "="]
361
- * - Yes/No: ["نعم", "لا"]
362
- * - Multiple choice: ["A", "B", "C", "D"]
363
- *
364
- * @example
365
- * {
366
- * type: "DragOptions",
367
- * options: ["<", ">", "="]
368
- * }
369
- */
370
- export declare const DragOptionsToolSchema: z.ZodObject<{
371
- type: z.ZodLiteral<"DragOptions">;
372
- options: z.ZodArray<z.ZodString, "many">;
373
- }, "strip", z.ZodTypeAny, {
374
- type: "DragOptions";
375
- options: string[];
376
- }, {
377
- type: "DragOptions";
378
- options: string[];
379
- }>;
380
-
381
- /**
382
- * Base error class for all engine errors
383
- */
384
- export declare class EngineError extends Error {
385
- constructor(message: string);
386
- }
387
-
388
- /**
389
- * Evaluate a mathematical expression with the given variable scope
390
- *
391
- * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
392
- * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
393
- * @returns The boolean result of the expression
394
- * @throws Error if evaluation fails
395
- */
396
- export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
397
-
398
- export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
318
+ export declare type ContentBlock = z.infer<typeof ContentBlockSchema>;
399
319
 
400
- /**
401
- * Exercise document schema - the complete exercise structure
402
- *
403
- * Structure:
404
- * 1. Question: What the student should do
405
- * 2. Lines: Visual rows with inline elements
406
- * 3. Tools: Standalone interactive elements (optional)
407
- * 4. Validation: How to check answers
408
- *
409
- * @example
410
- * {
411
- * type: "ExerciseDocument",
412
- * question: {
413
- * type: "TextBlock",
414
- * value: "أقارن كل عددين باستعمال الرمر المناسب"
415
- * },
416
- * lines: [
417
- * {
418
- * type: "LineBlock",
419
- * inlines: [
420
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
421
- * { type: "InlineInput", name: "x", length: 1 },
422
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
423
- * ]
424
- * }
425
- * ],
426
- * tools: [
427
- * { type: "DragOptions", options: ["<", ">", "="] }
428
- * ],
429
- * validation: {
430
- * type: "SimpleValidation"
431
- * }
432
- * }
433
- */
434
- export declare const ExerciseDocumentSchema: z.ZodObject<{
435
- type: z.ZodLiteral<"ExerciseDocument">;
436
- question: z.ZodOptional<z.ZodObject<{
437
- type: z.ZodLiteral<"TextBlock">;
320
+ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
321
+ type: z.ZodLiteral<"LineBlock">;
322
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
323
+ type: z.ZodLiteral<"FreeText">;
438
324
  value: z.ZodString;
439
325
  }, "strip", z.ZodTypeAny, {
440
326
  value: string;
441
- type: "TextBlock";
327
+ type: "FreeText";
442
328
  }, {
443
329
  value: string;
444
- type: "TextBlock";
445
- }>>;
446
- lines: z.ZodArray<z.ZodObject<{
447
- type: z.ZodLiteral<"LineBlock">;
448
- inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
449
- type: z.ZodLiteral<"FreeText">;
450
- value: z.ZodString;
451
- }, "strip", z.ZodTypeAny, {
452
- value: string;
453
- type: "FreeText";
454
- }, {
455
- value: string;
456
- type: "FreeText";
457
- }>, z.ZodObject<{
458
- type: z.ZodLiteral<"Space">;
459
- }, "strip", z.ZodTypeAny, {
460
- type: "Space";
461
- }, {
462
- type: "Space";
463
- }>, z.ZodObject<{
464
- type: z.ZodLiteral<"HighlightedText">;
465
- value: z.ZodString;
466
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
467
- }, "strip", z.ZodTypeAny, {
468
- value: string;
469
- type: "HighlightedText";
470
- highlight?: [number, number] | undefined;
471
- }, {
472
- value: string;
473
- type: "HighlightedText";
474
- highlight?: [number, number] | undefined;
475
- }>, z.ZodObject<{
476
- type: z.ZodLiteral<"ColorText">;
477
- value: z.ZodString;
478
- color: z.ZodString;
479
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
480
- }, "strip", z.ZodTypeAny, {
481
- value: string;
482
- type: "ColorText";
483
- color: string;
484
- highlight?: [number, number] | undefined;
485
- }, {
486
- value: string;
487
- type: "ColorText";
488
- color: string;
489
- highlight?: [number, number] | undefined;
490
- }>, z.ZodObject<{
491
- type: z.ZodLiteral<"BoldText">;
492
- value: z.ZodString;
493
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
494
- }, "strip", z.ZodTypeAny, {
495
- value: string;
496
- type: "BoldText";
497
- highlight?: [number, number] | undefined;
498
- }, {
499
- value: string;
500
- type: "BoldText";
501
- highlight?: [number, number] | undefined;
502
- }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
503
- type: z.ZodLiteral<"InlineInput">;
504
- name: z.ZodString;
505
- inputType: z.ZodLiteral<"string">;
506
- length: z.ZodNumber;
507
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
508
- }, "strip", z.ZodTypeAny, {
509
- length: number;
510
- type: "InlineInput";
511
- inputType: "string";
512
- name: string;
513
- answer?: string | number | undefined;
514
- }, {
515
- length: number;
516
- type: "InlineInput";
517
- inputType: "string";
518
- name: string;
519
- answer?: string | number | undefined;
520
- }>, z.ZodObject<{
521
- type: z.ZodLiteral<"InlineInput">;
522
- name: z.ZodString;
523
- inputType: z.ZodLiteral<"numeric">;
524
- digits: z.ZodNumber;
525
- answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
526
- }, "strip", z.ZodTypeAny, {
527
- type: "InlineInput";
528
- inputType: "numeric";
529
- name: string;
530
- digits: number;
531
- answer?: string | number | undefined;
532
- }, {
533
- type: "InlineInput";
534
- inputType: "numeric";
535
- name: string;
536
- digits: number;
537
- answer?: string | number | undefined;
538
- }>]>]>, "many">;
330
+ type: "FreeText";
331
+ }>, z.ZodObject<{
332
+ type: z.ZodLiteral<"Space">;
539
333
  }, "strip", z.ZodTypeAny, {
540
- type: "LineBlock";
541
- inlines: ({
542
- value: string;
543
- type: "FreeText";
544
- } | {
545
- type: "Space";
546
- } | {
547
- value: string;
548
- type: "HighlightedText";
549
- highlight?: [number, number] | undefined;
550
- } | {
551
- value: string;
552
- type: "ColorText";
553
- color: string;
554
- highlight?: [number, number] | undefined;
555
- } | {
556
- value: string;
557
- type: "BoldText";
558
- highlight?: [number, number] | undefined;
559
- } | {
560
- length: number;
561
- type: "InlineInput";
562
- inputType: "string";
563
- name: string;
564
- answer?: string | number | undefined;
565
- } | {
566
- type: "InlineInput";
567
- inputType: "numeric";
568
- name: string;
569
- digits: number;
570
- answer?: string | number | undefined;
571
- })[];
334
+ type: "Space";
572
335
  }, {
573
- type: "LineBlock";
574
- inlines: ({
575
- value: string;
576
- type: "FreeText";
577
- } | {
578
- type: "Space";
579
- } | {
580
- value: string;
581
- type: "HighlightedText";
582
- highlight?: [number, number] | undefined;
583
- } | {
584
- value: string;
585
- type: "ColorText";
586
- color: string;
587
- highlight?: [number, number] | undefined;
588
- } | {
589
- value: string;
590
- type: "BoldText";
591
- highlight?: [number, number] | undefined;
592
- } | {
593
- length: number;
594
- type: "InlineInput";
595
- inputType: "string";
596
- name: string;
597
- answer?: string | number | undefined;
598
- } | {
599
- type: "InlineInput";
600
- inputType: "numeric";
601
- name: string;
602
- digits: number;
603
- answer?: string | number | undefined;
604
- })[];
605
- }>, "many">;
606
- tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
607
- type: z.ZodLiteral<"DragOptions">;
608
- options: z.ZodArray<z.ZodString, "many">;
336
+ type: "Space";
337
+ }>, z.ZodObject<{
338
+ type: z.ZodLiteral<"HighlightedText">;
339
+ value: z.ZodString;
340
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
609
341
  }, "strip", z.ZodTypeAny, {
610
- type: "DragOptions";
611
- options: string[];
342
+ value: string;
343
+ type: "HighlightedText";
344
+ highlight?: [number, number] | undefined;
612
345
  }, {
613
- type: "DragOptions";
614
- options: string[];
346
+ value: string;
347
+ type: "HighlightedText";
348
+ highlight?: [number, number] | undefined;
615
349
  }>, z.ZodObject<{
616
- type: z.ZodLiteral<"NumericKeypad">;
617
- includeOperators: z.ZodOptional<z.ZodBoolean>;
618
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
350
+ type: z.ZodLiteral<"ColorText">;
351
+ value: z.ZodString;
352
+ color: z.ZodString;
353
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
619
354
  }, "strip", z.ZodTypeAny, {
620
- type: "NumericKeypad";
621
- includeOperators?: boolean | undefined;
622
- includeDecimal?: boolean | undefined;
355
+ value: string;
356
+ type: "ColorText";
357
+ color: string;
358
+ highlight?: [number, number] | undefined;
623
359
  }, {
624
- type: "NumericKeypad";
625
- includeOperators?: boolean | undefined;
626
- includeDecimal?: boolean | undefined;
627
- }>]>, "many">>;
628
- validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
629
- type: z.ZodLiteral<"SimpleValidation">;
360
+ value: string;
361
+ type: "ColorText";
362
+ color: string;
363
+ highlight?: [number, number] | undefined;
364
+ }>, z.ZodObject<{
365
+ type: z.ZodLiteral<"BoldText">;
366
+ value: z.ZodString;
367
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
630
368
  }, "strip", z.ZodTypeAny, {
631
- type: "SimpleValidation";
369
+ value: string;
370
+ type: "BoldText";
371
+ highlight?: [number, number] | undefined;
632
372
  }, {
633
- type: "SimpleValidation";
373
+ value: string;
374
+ type: "BoldText";
375
+ highlight?: [number, number] | undefined;
376
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
377
+ type: z.ZodLiteral<"InlineInput">;
378
+ name: z.ZodString;
379
+ inputType: z.ZodLiteral<"string">;
380
+ length: z.ZodNumber;
381
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
382
+ }, "strip", z.ZodTypeAny, {
383
+ length: number;
384
+ type: "InlineInput";
385
+ inputType: "string";
386
+ name: string;
387
+ answer?: string | number | undefined;
388
+ }, {
389
+ length: number;
390
+ type: "InlineInput";
391
+ inputType: "string";
392
+ name: string;
393
+ answer?: string | number | undefined;
634
394
  }>, z.ZodObject<{
635
- type: z.ZodLiteral<"ExpressionValidation">;
636
- expression: z.ZodString;
395
+ type: z.ZodLiteral<"InlineInput">;
396
+ name: z.ZodString;
397
+ inputType: z.ZodLiteral<"numeric">;
398
+ digits: z.ZodNumber;
399
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
637
400
  }, "strip", z.ZodTypeAny, {
638
- expression: string;
639
- type: "ExpressionValidation";
401
+ type: "InlineInput";
402
+ inputType: "numeric";
403
+ name: string;
404
+ digits: number;
405
+ answer?: string | number | undefined;
640
406
  }, {
641
- expression: string;
642
- type: "ExpressionValidation";
643
- }>]>;
407
+ type: "InlineInput";
408
+ inputType: "numeric";
409
+ name: string;
410
+ digits: number;
411
+ answer?: string | number | undefined;
412
+ }>]>]>, "many">;
644
413
  }, "strip", z.ZodTypeAny, {
645
- validation: {
646
- type: "SimpleValidation";
414
+ type: "LineBlock";
415
+ inlines: ({
416
+ value: string;
417
+ type: "FreeText";
418
+ } | {
419
+ type: "Space";
647
420
  } | {
648
- expression: string;
649
- type: "ExpressionValidation";
650
- };
651
- type: "ExerciseDocument";
652
- lines: {
653
- type: "LineBlock";
654
- inlines: ({
655
- value: string;
656
- type: "FreeText";
657
- } | {
658
- type: "Space";
659
- } | {
660
- value: string;
661
- type: "HighlightedText";
662
- highlight?: [number, number] | undefined;
663
- } | {
664
- value: string;
665
- type: "ColorText";
666
- color: string;
667
- highlight?: [number, number] | undefined;
668
- } | {
669
- value: string;
670
- type: "BoldText";
671
- highlight?: [number, number] | undefined;
672
- } | {
673
- length: number;
674
- type: "InlineInput";
675
- inputType: "string";
676
- name: string;
677
- answer?: string | number | undefined;
678
- } | {
679
- type: "InlineInput";
680
- inputType: "numeric";
681
- name: string;
682
- digits: number;
683
- answer?: string | number | undefined;
684
- })[];
685
- }[];
686
- question?: {
687
421
  value: string;
688
- type: "TextBlock";
689
- } | undefined;
690
- tools?: ({
691
- type: "DragOptions";
692
- options: string[];
422
+ type: "HighlightedText";
423
+ highlight?: [number, number] | undefined;
693
424
  } | {
694
- type: "NumericKeypad";
695
- includeOperators?: boolean | undefined;
696
- includeDecimal?: boolean | undefined;
697
- })[] | undefined;
698
- }, {
699
- validation: {
700
- type: "SimpleValidation";
425
+ value: string;
426
+ type: "ColorText";
427
+ color: string;
428
+ highlight?: [number, number] | undefined;
701
429
  } | {
702
- expression: string;
703
- type: "ExpressionValidation";
704
- };
705
- type: "ExerciseDocument";
706
- lines: {
707
- type: "LineBlock";
708
- inlines: ({
709
- value: string;
710
- type: "FreeText";
711
- } | {
712
- type: "Space";
713
- } | {
714
- value: string;
715
- type: "HighlightedText";
716
- highlight?: [number, number] | undefined;
717
- } | {
718
- value: string;
719
- type: "ColorText";
720
- color: string;
721
- highlight?: [number, number] | undefined;
722
- } | {
723
- value: string;
724
- type: "BoldText";
725
- highlight?: [number, number] | undefined;
726
- } | {
727
- length: number;
728
- type: "InlineInput";
729
- inputType: "string";
730
- name: string;
731
- answer?: string | number | undefined;
732
- } | {
733
- type: "InlineInput";
734
- inputType: "numeric";
735
- name: string;
736
- digits: number;
737
- answer?: string | number | undefined;
738
- })[];
739
- }[];
740
- question?: {
741
430
  value: string;
742
- type: "TextBlock";
743
- } | undefined;
744
- tools?: ({
745
- type: "DragOptions";
746
- options: string[];
431
+ type: "BoldText";
432
+ highlight?: [number, number] | undefined;
747
433
  } | {
748
- type: "NumericKeypad";
749
- includeOperators?: boolean | undefined;
750
- includeDecimal?: boolean | undefined;
751
- })[] | undefined;
752
- }>;
753
-
754
- export declare type ExerciseJSON = z.infer<typeof ExerciseJSONSchema>;
755
-
756
- export declare const ExerciseJSONSchema: z.ZodObject<{
757
- version: z.ZodLiteral<"2.0">;
758
- id: z.ZodOptional<z.ZodString>;
759
- layout: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
760
- widgets: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
761
- type: z.ZodLiteral<"inline-input">;
762
- inputType: z.ZodLiteral<"string">;
763
- length: z.ZodNumber;
764
- }, "strip", z.ZodTypeAny, {
765
- length: number;
766
- type: "inline-input";
767
- inputType: "string";
768
- }, {
769
- length: number;
770
- type: "inline-input";
771
- inputType: "string";
772
- }>, z.ZodObject<{
773
- type: z.ZodLiteral<"inline-input">;
774
- inputType: z.ZodLiteral<"numeric">;
775
- digits: z.ZodNumber;
776
- }, "strip", z.ZodTypeAny, {
777
- type: "inline-input";
778
- inputType: "numeric";
779
- digits: number;
780
- }, {
781
- type: "inline-input";
782
- inputType: "numeric";
783
- digits: number;
784
- }>]>, z.ZodObject<{
785
- type: z.ZodLiteral<"drag-options">;
786
- options: z.ZodArray<z.ZodString, "many">;
787
- }, "strip", z.ZodTypeAny, {
788
- type: "drag-options";
789
- options: string[];
790
- }, {
791
- type: "drag-options";
792
- options: string[];
793
- }>, z.ZodObject<{
794
- type: z.ZodLiteral<"numeric-keypad">;
795
- includeOperators: z.ZodOptional<z.ZodBoolean>;
796
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
797
- }, "strip", z.ZodTypeAny, {
798
- type: "numeric-keypad";
799
- includeOperators?: boolean | undefined;
800
- includeDecimal?: boolean | undefined;
801
- }, {
802
- type: "numeric-keypad";
803
- includeOperators?: boolean | undefined;
804
- includeDecimal?: boolean | undefined;
805
- }>]>>;
806
- validation: z.ZodObject<{
807
- mode: z.ZodEnum<["simple", "expression"]>;
808
- answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
809
- expression: z.ZodOptional<z.ZodString>;
810
- variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
811
- }, "strip", z.ZodTypeAny, {
812
- mode: "simple" | "expression";
813
- expression?: string | undefined;
814
- answers?: Record<string, string | number> | undefined;
815
- variables?: string[] | undefined;
816
- }, {
817
- mode: "simple" | "expression";
818
- expression?: string | undefined;
819
- answers?: Record<string, string | number> | undefined;
820
- variables?: string[] | undefined;
821
- }>;
822
- meta: z.ZodOptional<z.ZodObject<{
823
- createdAt: z.ZodOptional<z.ZodString>;
824
- author: z.ZodOptional<z.ZodString>;
825
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
826
- difficulty: z.ZodOptional<z.ZodNumber>;
827
- }, "strip", z.ZodTypeAny, {
828
- createdAt?: string | undefined;
829
- author?: string | undefined;
830
- tags?: string[] | undefined;
831
- difficulty?: number | undefined;
832
- }, {
833
- createdAt?: string | undefined;
834
- author?: string | undefined;
835
- tags?: string[] | undefined;
836
- difficulty?: number | undefined;
837
- }>>;
838
- }, "strip", z.ZodTypeAny, {
839
- validation: {
840
- mode: "simple" | "expression";
841
- expression?: string | undefined;
842
- answers?: Record<string, string | number> | undefined;
843
- variables?: string[] | undefined;
844
- };
845
- version: "2.0";
846
- layout: any[];
847
- widgets: Record<string, {
848
434
  length: number;
849
- type: "inline-input";
435
+ type: "InlineInput";
850
436
  inputType: "string";
437
+ name: string;
438
+ answer?: string | number | undefined;
851
439
  } | {
852
- type: "inline-input";
440
+ type: "InlineInput";
853
441
  inputType: "numeric";
442
+ name: string;
854
443
  digits: number;
444
+ answer?: string | number | undefined;
445
+ })[];
446
+ }, {
447
+ type: "LineBlock";
448
+ inlines: ({
449
+ value: string;
450
+ type: "FreeText";
855
451
  } | {
856
- type: "drag-options";
857
- options: string[];
452
+ type: "Space";
453
+ } | {
454
+ value: string;
455
+ type: "HighlightedText";
456
+ highlight?: [number, number] | undefined;
457
+ } | {
458
+ value: string;
459
+ type: "ColorText";
460
+ color: string;
461
+ highlight?: [number, number] | undefined;
462
+ } | {
463
+ value: string;
464
+ type: "BoldText";
465
+ highlight?: [number, number] | undefined;
858
466
  } | {
859
- type: "numeric-keypad";
860
- includeOperators?: boolean | undefined;
861
- includeDecimal?: boolean | undefined;
862
- }>;
863
- id?: string | undefined;
864
- meta?: {
865
- createdAt?: string | undefined;
866
- author?: string | undefined;
867
- tags?: string[] | undefined;
868
- difficulty?: number | undefined;
869
- } | undefined;
870
- }, {
871
- validation: {
872
- mode: "simple" | "expression";
873
- expression?: string | undefined;
874
- answers?: Record<string, string | number> | undefined;
875
- variables?: string[] | undefined;
876
- };
877
- version: "2.0";
878
- layout: any[];
879
- widgets: Record<string, {
880
467
  length: number;
881
- type: "inline-input";
468
+ type: "InlineInput";
882
469
  inputType: "string";
470
+ name: string;
471
+ answer?: string | number | undefined;
883
472
  } | {
884
- type: "inline-input";
473
+ type: "InlineInput";
885
474
  inputType: "numeric";
475
+ name: string;
886
476
  digits: number;
887
- } | {
888
- type: "drag-options";
889
- options: string[];
890
- } | {
891
- type: "numeric-keypad";
892
- includeOperators?: boolean | undefined;
893
- includeDecimal?: boolean | undefined;
894
- }>;
895
- id?: string | undefined;
896
- meta?: {
897
- createdAt?: string | undefined;
898
- author?: string | undefined;
899
- tags?: string[] | undefined;
900
- difficulty?: number | undefined;
901
- } | undefined;
902
- }>;
903
-
904
- export declare type ExerciseMeta = z.infer<typeof ExerciseMetaSchema>;
905
-
906
- export declare const ExerciseMetaSchema: z.ZodObject<{
907
- createdAt: z.ZodOptional<z.ZodString>;
908
- author: z.ZodOptional<z.ZodString>;
909
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
910
- difficulty: z.ZodOptional<z.ZodNumber>;
911
- }, "strip", z.ZodTypeAny, {
912
- createdAt?: string | undefined;
913
- author?: string | undefined;
914
- tags?: string[] | undefined;
915
- difficulty?: number | undefined;
916
- }, {
917
- createdAt?: string | undefined;
918
- author?: string | undefined;
919
- tags?: string[] | undefined;
920
- difficulty?: number | undefined;
921
- }>;
922
-
923
- /**
924
- * Main renderer component - the contract for rendering exercises.
925
- *
926
- * This component is DUMB - it only collects values and passes them up.
927
- * The parent decides correctness via validation.
928
- */
929
- export declare const ExerciseRenderer: ForwardRefExoticComponent<ExerciseRendererProps & RefAttributes<ExerciseRendererRef>>;
930
-
931
- export declare interface ExerciseRendererProps {
932
- json: ExerciseJSON;
933
- onSubmit?: (values: Record<string, string>) => void;
934
- onChange?: (values: Record<string, string>) => void;
935
- showSubmitButton?: boolean;
936
- className?: string;
937
- }
938
-
939
- export declare interface ExerciseRendererRef {
940
- submit: () => ValidationResult;
941
- getValues: () => Record<string, string>;
942
- reset: () => void;
943
- focusFirstInput: () => void;
944
- }
945
-
946
- export declare type ExpressionValidation = z.infer<typeof ExpressionValidationSchema>;
947
-
948
- /**
949
- * Expression validation schema - validates using a boolean expression
950
- *
951
- * The expression can reference widget values by name.
952
- * Example: "a + b === 10"
953
- *
954
- * @example
955
- * {
956
- * type: "ExpressionValidation",
957
- * expression: "a + b === 10"
477
+ answer?: string | number | undefined;
478
+ })[];
479
+ }>, z.ZodObject<{
480
+ type: z.ZodLiteral<"TableBlock">;
481
+ cols: z.ZodNumber;
482
+ rows: z.ZodArray<z.ZodObject<{
483
+ type: z.ZodLiteral<"TableRow">;
484
+ cells: z.ZodArray<z.ZodObject<{
485
+ type: z.ZodLiteral<"TableCell">;
486
+ colspan: z.ZodOptional<z.ZodNumber>;
487
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
488
+ type: z.ZodLiteral<"FreeText">;
489
+ value: z.ZodString;
490
+ }, "strip", z.ZodTypeAny, {
491
+ value: string;
492
+ type: "FreeText";
493
+ }, {
494
+ value: string;
495
+ type: "FreeText";
496
+ }>, z.ZodObject<{
497
+ type: z.ZodLiteral<"Space">;
498
+ }, "strip", z.ZodTypeAny, {
499
+ type: "Space";
500
+ }, {
501
+ type: "Space";
502
+ }>, z.ZodObject<{
503
+ type: z.ZodLiteral<"HighlightedText">;
504
+ value: z.ZodString;
505
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
506
+ }, "strip", z.ZodTypeAny, {
507
+ value: string;
508
+ type: "HighlightedText";
509
+ highlight?: [number, number] | undefined;
510
+ }, {
511
+ value: string;
512
+ type: "HighlightedText";
513
+ highlight?: [number, number] | undefined;
514
+ }>, z.ZodObject<{
515
+ type: z.ZodLiteral<"ColorText">;
516
+ value: z.ZodString;
517
+ color: z.ZodString;
518
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
519
+ }, "strip", z.ZodTypeAny, {
520
+ value: string;
521
+ type: "ColorText";
522
+ color: string;
523
+ highlight?: [number, number] | undefined;
524
+ }, {
525
+ value: string;
526
+ type: "ColorText";
527
+ color: string;
528
+ highlight?: [number, number] | undefined;
529
+ }>, z.ZodObject<{
530
+ type: z.ZodLiteral<"BoldText">;
531
+ value: z.ZodString;
532
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
533
+ }, "strip", z.ZodTypeAny, {
534
+ value: string;
535
+ type: "BoldText";
536
+ highlight?: [number, number] | undefined;
537
+ }, {
538
+ value: string;
539
+ type: "BoldText";
540
+ highlight?: [number, number] | undefined;
541
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
542
+ type: z.ZodLiteral<"InlineInput">;
543
+ name: z.ZodString;
544
+ inputType: z.ZodLiteral<"string">;
545
+ length: z.ZodNumber;
546
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
547
+ }, "strip", z.ZodTypeAny, {
548
+ length: number;
549
+ type: "InlineInput";
550
+ inputType: "string";
551
+ name: string;
552
+ answer?: string | number | undefined;
553
+ }, {
554
+ length: number;
555
+ type: "InlineInput";
556
+ inputType: "string";
557
+ name: string;
558
+ answer?: string | number | undefined;
559
+ }>, z.ZodObject<{
560
+ type: z.ZodLiteral<"InlineInput">;
561
+ name: z.ZodString;
562
+ inputType: z.ZodLiteral<"numeric">;
563
+ digits: z.ZodNumber;
564
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
565
+ }, "strip", z.ZodTypeAny, {
566
+ type: "InlineInput";
567
+ inputType: "numeric";
568
+ name: string;
569
+ digits: number;
570
+ answer?: string | number | undefined;
571
+ }, {
572
+ type: "InlineInput";
573
+ inputType: "numeric";
574
+ name: string;
575
+ digits: number;
576
+ answer?: string | number | undefined;
577
+ }>]>]>, "many">;
578
+ }, "strip", z.ZodTypeAny, {
579
+ type: "TableCell";
580
+ inlines: ({
581
+ value: string;
582
+ type: "FreeText";
583
+ } | {
584
+ type: "Space";
585
+ } | {
586
+ value: string;
587
+ type: "HighlightedText";
588
+ highlight?: [number, number] | undefined;
589
+ } | {
590
+ value: string;
591
+ type: "ColorText";
592
+ color: string;
593
+ highlight?: [number, number] | undefined;
594
+ } | {
595
+ value: string;
596
+ type: "BoldText";
597
+ highlight?: [number, number] | undefined;
598
+ } | {
599
+ length: number;
600
+ type: "InlineInput";
601
+ inputType: "string";
602
+ name: string;
603
+ answer?: string | number | undefined;
604
+ } | {
605
+ type: "InlineInput";
606
+ inputType: "numeric";
607
+ name: string;
608
+ digits: number;
609
+ answer?: string | number | undefined;
610
+ })[];
611
+ colspan?: number | undefined;
612
+ }, {
613
+ type: "TableCell";
614
+ inlines: ({
615
+ value: string;
616
+ type: "FreeText";
617
+ } | {
618
+ type: "Space";
619
+ } | {
620
+ value: string;
621
+ type: "HighlightedText";
622
+ highlight?: [number, number] | undefined;
623
+ } | {
624
+ value: string;
625
+ type: "ColorText";
626
+ color: string;
627
+ highlight?: [number, number] | undefined;
628
+ } | {
629
+ value: string;
630
+ type: "BoldText";
631
+ highlight?: [number, number] | undefined;
632
+ } | {
633
+ length: number;
634
+ type: "InlineInput";
635
+ inputType: "string";
636
+ name: string;
637
+ answer?: string | number | undefined;
638
+ } | {
639
+ type: "InlineInput";
640
+ inputType: "numeric";
641
+ name: string;
642
+ digits: number;
643
+ answer?: string | number | undefined;
644
+ })[];
645
+ colspan?: number | undefined;
646
+ }>, "many">;
647
+ }, "strip", z.ZodTypeAny, {
648
+ type: "TableRow";
649
+ cells: {
650
+ type: "TableCell";
651
+ inlines: ({
652
+ value: string;
653
+ type: "FreeText";
654
+ } | {
655
+ type: "Space";
656
+ } | {
657
+ value: string;
658
+ type: "HighlightedText";
659
+ highlight?: [number, number] | undefined;
660
+ } | {
661
+ value: string;
662
+ type: "ColorText";
663
+ color: string;
664
+ highlight?: [number, number] | undefined;
665
+ } | {
666
+ value: string;
667
+ type: "BoldText";
668
+ highlight?: [number, number] | undefined;
669
+ } | {
670
+ length: number;
671
+ type: "InlineInput";
672
+ inputType: "string";
673
+ name: string;
674
+ answer?: string | number | undefined;
675
+ } | {
676
+ type: "InlineInput";
677
+ inputType: "numeric";
678
+ name: string;
679
+ digits: number;
680
+ answer?: string | number | undefined;
681
+ })[];
682
+ colspan?: number | undefined;
683
+ }[];
684
+ }, {
685
+ type: "TableRow";
686
+ cells: {
687
+ type: "TableCell";
688
+ inlines: ({
689
+ value: string;
690
+ type: "FreeText";
691
+ } | {
692
+ type: "Space";
693
+ } | {
694
+ value: string;
695
+ type: "HighlightedText";
696
+ highlight?: [number, number] | undefined;
697
+ } | {
698
+ value: string;
699
+ type: "ColorText";
700
+ color: string;
701
+ highlight?: [number, number] | undefined;
702
+ } | {
703
+ value: string;
704
+ type: "BoldText";
705
+ highlight?: [number, number] | undefined;
706
+ } | {
707
+ length: number;
708
+ type: "InlineInput";
709
+ inputType: "string";
710
+ name: string;
711
+ answer?: string | number | undefined;
712
+ } | {
713
+ type: "InlineInput";
714
+ inputType: "numeric";
715
+ name: string;
716
+ digits: number;
717
+ answer?: string | number | undefined;
718
+ })[];
719
+ colspan?: number | undefined;
720
+ }[];
721
+ }>, "many">;
722
+ }, "strip", z.ZodTypeAny, {
723
+ type: "TableBlock";
724
+ cols: number;
725
+ rows: {
726
+ type: "TableRow";
727
+ cells: {
728
+ type: "TableCell";
729
+ inlines: ({
730
+ value: string;
731
+ type: "FreeText";
732
+ } | {
733
+ type: "Space";
734
+ } | {
735
+ value: string;
736
+ type: "HighlightedText";
737
+ highlight?: [number, number] | undefined;
738
+ } | {
739
+ value: string;
740
+ type: "ColorText";
741
+ color: string;
742
+ highlight?: [number, number] | undefined;
743
+ } | {
744
+ value: string;
745
+ type: "BoldText";
746
+ highlight?: [number, number] | undefined;
747
+ } | {
748
+ length: number;
749
+ type: "InlineInput";
750
+ inputType: "string";
751
+ name: string;
752
+ answer?: string | number | undefined;
753
+ } | {
754
+ type: "InlineInput";
755
+ inputType: "numeric";
756
+ name: string;
757
+ digits: number;
758
+ answer?: string | number | undefined;
759
+ })[];
760
+ colspan?: number | undefined;
761
+ }[];
762
+ }[];
763
+ }, {
764
+ type: "TableBlock";
765
+ cols: number;
766
+ rows: {
767
+ type: "TableRow";
768
+ cells: {
769
+ type: "TableCell";
770
+ inlines: ({
771
+ value: string;
772
+ type: "FreeText";
773
+ } | {
774
+ type: "Space";
775
+ } | {
776
+ value: string;
777
+ type: "HighlightedText";
778
+ highlight?: [number, number] | undefined;
779
+ } | {
780
+ value: string;
781
+ type: "ColorText";
782
+ color: string;
783
+ highlight?: [number, number] | undefined;
784
+ } | {
785
+ value: string;
786
+ type: "BoldText";
787
+ highlight?: [number, number] | undefined;
788
+ } | {
789
+ length: number;
790
+ type: "InlineInput";
791
+ inputType: "string";
792
+ name: string;
793
+ answer?: string | number | undefined;
794
+ } | {
795
+ type: "InlineInput";
796
+ inputType: "numeric";
797
+ name: string;
798
+ digits: number;
799
+ answer?: string | number | undefined;
800
+ })[];
801
+ colspan?: number | undefined;
802
+ }[];
803
+ }[];
804
+ }>]>;
805
+
806
+ /**
807
+ * Create a bold text inline element
808
+ */
809
+ export declare function createBoldText(value: string, highlight?: [number, number]): BoldTextInline;
810
+
811
+ /**
812
+ * Create a color text inline element
813
+ */
814
+ export declare function createColorText(value: string, color: string, highlight?: [number, number]): ColorTextInline;
815
+
816
+ /**
817
+ * Create a drag options tool
818
+ */
819
+ export declare function createDragOptions(options: string[]): DragOptionsTool;
820
+
821
+ /**
822
+ * Create an exercise document
823
+ */
824
+ export declare function createExerciseDocument(question: z.infer<typeof TextBlockSchema> | undefined, lines: ContentBlock[], validation: z.infer<typeof ValidationNodeSchema>, tools?: z.infer<typeof ToolNodeSchema>[]): ExerciseDocument;
825
+
826
+ /**
827
+ * Create an expression validation node
828
+ */
829
+ export declare function createExpressionValidation(expression: string): ExpressionValidation;
830
+
831
+ /**
832
+ * Create a free text inline element
833
+ */
834
+ export declare function createFreeText(value: string): FreeTextInline;
835
+
836
+ /**
837
+ * Create a highlighted text inline element
838
+ */
839
+ export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
840
+
841
+ /**
842
+ * Create a line block
843
+ */
844
+ export declare function createLineBlock(inlines: InlineNode[]): LineBlock;
845
+
846
+ /**
847
+ * Create a numeric inline input widget (W_N_I)
848
+ */
849
+ export declare function createNumericInput(name: string, digits: number, answer?: string | number): InlineInputWidget;
850
+
851
+ /**
852
+ * Create a numeric keypad tool
853
+ */
854
+ export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
855
+
856
+ /**
857
+ * Create a simple validation node
858
+ */
859
+ export declare function createSimpleValidation(): SimpleValidation;
860
+
861
+ /**
862
+ * Create a space inline element
863
+ */
864
+ export declare function createSpace(): SpaceInline;
865
+
866
+ /**
867
+ * Create a string inline input widget (W_S_I)
868
+ */
869
+ export declare function createStringInput(name: string, length: number, answer?: string | number): InlineInputWidget;
870
+
871
+ /**
872
+ * Create a text block (question)
873
+ */
874
+ export declare function createTextBlock(value: string): TextBlock;
875
+
876
+ export declare type DragOptionsJSON = z.infer<typeof DragOptionsJSONSchema>;
877
+
878
+ export declare const DragOptionsJSONSchema: z.ZodObject<{
879
+ type: z.ZodLiteral<"drag-options">;
880
+ options: z.ZodArray<z.ZodString, "many">;
881
+ }, "strip", z.ZodTypeAny, {
882
+ type: "drag-options";
883
+ options: string[];
884
+ }, {
885
+ type: "drag-options";
886
+ options: string[];
887
+ }>;
888
+
889
+ export declare type DragOptionsTool = z.infer<typeof DragOptionsToolSchema>;
890
+
891
+ /**
892
+ * Drag options tool schema - draggable buttons/options
893
+ *
894
+ * Common use cases:
895
+ * - Comparison symbols: ["<", ">", "="]
896
+ * - Yes/No: ["نعم", "لا"]
897
+ * - Multiple choice: ["A", "B", "C", "D"]
898
+ *
899
+ * @example
900
+ * {
901
+ * type: "DragOptions",
902
+ * options: ["<", ">", "="]
903
+ * }
904
+ */
905
+ export declare const DragOptionsToolSchema: z.ZodObject<{
906
+ type: z.ZodLiteral<"DragOptions">;
907
+ options: z.ZodArray<z.ZodString, "many">;
908
+ }, "strip", z.ZodTypeAny, {
909
+ type: "DragOptions";
910
+ options: string[];
911
+ }, {
912
+ type: "DragOptions";
913
+ options: string[];
914
+ }>;
915
+
916
+ /**
917
+ * Base error class for all engine errors
918
+ */
919
+ export declare class EngineError extends Error {
920
+ constructor(message: string);
921
+ }
922
+
923
+ /**
924
+ * Evaluate a mathematical expression with the given variable scope
925
+ *
926
+ * @param expression - The expression to evaluate (e.g., "(a * b) + (c * d) == 1200")
927
+ * @param scope - Variable bindings (e.g., { a: 10, b: 5, c: 20, d: 30 })
928
+ * @returns The boolean result of the expression
929
+ * @throws Error if evaluation fails
930
+ */
931
+ export declare function evaluate(expression: string, scope: Record<string, number>): boolean;
932
+
933
+ export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
934
+
935
+ /**
936
+ * Exercise document schema - the complete exercise structure
937
+ *
938
+ * Structure:
939
+ * 1. Question: What the student should do
940
+ * 2. Lines: Visual rows with inline elements
941
+ * 3. Tools: Standalone interactive elements (optional)
942
+ * 4. Validation: How to check answers
943
+ *
944
+ * @example
945
+ * {
946
+ * type: "ExerciseDocument",
947
+ * question: {
948
+ * type: "TextBlock",
949
+ * value: "أقارن كل عددين باستعمال الرمر المناسب"
950
+ * },
951
+ * lines: [
952
+ * {
953
+ * type: "LineBlock",
954
+ * inlines: [
955
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
956
+ * { type: "InlineInput", name: "x", length: 1 },
957
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
958
+ * ]
959
+ * }
960
+ * ],
961
+ * tools: [
962
+ * { type: "DragOptions", options: ["<", ">", "="] }
963
+ * ],
964
+ * validation: {
965
+ * type: "SimpleValidation"
966
+ * }
967
+ * }
968
+ */
969
+ export declare const ExerciseDocumentSchema: z.ZodObject<{
970
+ type: z.ZodLiteral<"ExerciseDocument">;
971
+ question: z.ZodOptional<z.ZodObject<{
972
+ type: z.ZodLiteral<"TextBlock">;
973
+ value: z.ZodString;
974
+ }, "strip", z.ZodTypeAny, {
975
+ value: string;
976
+ type: "TextBlock";
977
+ }, {
978
+ value: string;
979
+ type: "TextBlock";
980
+ }>>;
981
+ lines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
982
+ type: z.ZodLiteral<"LineBlock">;
983
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
984
+ type: z.ZodLiteral<"FreeText">;
985
+ value: z.ZodString;
986
+ }, "strip", z.ZodTypeAny, {
987
+ value: string;
988
+ type: "FreeText";
989
+ }, {
990
+ value: string;
991
+ type: "FreeText";
992
+ }>, z.ZodObject<{
993
+ type: z.ZodLiteral<"Space">;
994
+ }, "strip", z.ZodTypeAny, {
995
+ type: "Space";
996
+ }, {
997
+ type: "Space";
998
+ }>, z.ZodObject<{
999
+ type: z.ZodLiteral<"HighlightedText">;
1000
+ value: z.ZodString;
1001
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1002
+ }, "strip", z.ZodTypeAny, {
1003
+ value: string;
1004
+ type: "HighlightedText";
1005
+ highlight?: [number, number] | undefined;
1006
+ }, {
1007
+ value: string;
1008
+ type: "HighlightedText";
1009
+ highlight?: [number, number] | undefined;
1010
+ }>, z.ZodObject<{
1011
+ type: z.ZodLiteral<"ColorText">;
1012
+ value: z.ZodString;
1013
+ color: z.ZodString;
1014
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1015
+ }, "strip", z.ZodTypeAny, {
1016
+ value: string;
1017
+ type: "ColorText";
1018
+ color: string;
1019
+ highlight?: [number, number] | undefined;
1020
+ }, {
1021
+ value: string;
1022
+ type: "ColorText";
1023
+ color: string;
1024
+ highlight?: [number, number] | undefined;
1025
+ }>, z.ZodObject<{
1026
+ type: z.ZodLiteral<"BoldText">;
1027
+ value: z.ZodString;
1028
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1029
+ }, "strip", z.ZodTypeAny, {
1030
+ value: string;
1031
+ type: "BoldText";
1032
+ highlight?: [number, number] | undefined;
1033
+ }, {
1034
+ value: string;
1035
+ type: "BoldText";
1036
+ highlight?: [number, number] | undefined;
1037
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1038
+ type: z.ZodLiteral<"InlineInput">;
1039
+ name: z.ZodString;
1040
+ inputType: z.ZodLiteral<"string">;
1041
+ length: z.ZodNumber;
1042
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1043
+ }, "strip", z.ZodTypeAny, {
1044
+ length: number;
1045
+ type: "InlineInput";
1046
+ inputType: "string";
1047
+ name: string;
1048
+ answer?: string | number | undefined;
1049
+ }, {
1050
+ length: number;
1051
+ type: "InlineInput";
1052
+ inputType: "string";
1053
+ name: string;
1054
+ answer?: string | number | undefined;
1055
+ }>, z.ZodObject<{
1056
+ type: z.ZodLiteral<"InlineInput">;
1057
+ name: z.ZodString;
1058
+ inputType: z.ZodLiteral<"numeric">;
1059
+ digits: z.ZodNumber;
1060
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1061
+ }, "strip", z.ZodTypeAny, {
1062
+ type: "InlineInput";
1063
+ inputType: "numeric";
1064
+ name: string;
1065
+ digits: number;
1066
+ answer?: string | number | undefined;
1067
+ }, {
1068
+ type: "InlineInput";
1069
+ inputType: "numeric";
1070
+ name: string;
1071
+ digits: number;
1072
+ answer?: string | number | undefined;
1073
+ }>]>]>, "many">;
1074
+ }, "strip", z.ZodTypeAny, {
1075
+ type: "LineBlock";
1076
+ inlines: ({
1077
+ value: string;
1078
+ type: "FreeText";
1079
+ } | {
1080
+ type: "Space";
1081
+ } | {
1082
+ value: string;
1083
+ type: "HighlightedText";
1084
+ highlight?: [number, number] | undefined;
1085
+ } | {
1086
+ value: string;
1087
+ type: "ColorText";
1088
+ color: string;
1089
+ highlight?: [number, number] | undefined;
1090
+ } | {
1091
+ value: string;
1092
+ type: "BoldText";
1093
+ highlight?: [number, number] | undefined;
1094
+ } | {
1095
+ length: number;
1096
+ type: "InlineInput";
1097
+ inputType: "string";
1098
+ name: string;
1099
+ answer?: string | number | undefined;
1100
+ } | {
1101
+ type: "InlineInput";
1102
+ inputType: "numeric";
1103
+ name: string;
1104
+ digits: number;
1105
+ answer?: string | number | undefined;
1106
+ })[];
1107
+ }, {
1108
+ type: "LineBlock";
1109
+ inlines: ({
1110
+ value: string;
1111
+ type: "FreeText";
1112
+ } | {
1113
+ type: "Space";
1114
+ } | {
1115
+ value: string;
1116
+ type: "HighlightedText";
1117
+ highlight?: [number, number] | undefined;
1118
+ } | {
1119
+ value: string;
1120
+ type: "ColorText";
1121
+ color: string;
1122
+ highlight?: [number, number] | undefined;
1123
+ } | {
1124
+ value: string;
1125
+ type: "BoldText";
1126
+ highlight?: [number, number] | undefined;
1127
+ } | {
1128
+ length: number;
1129
+ type: "InlineInput";
1130
+ inputType: "string";
1131
+ name: string;
1132
+ answer?: string | number | undefined;
1133
+ } | {
1134
+ type: "InlineInput";
1135
+ inputType: "numeric";
1136
+ name: string;
1137
+ digits: number;
1138
+ answer?: string | number | undefined;
1139
+ })[];
1140
+ }>, z.ZodObject<{
1141
+ type: z.ZodLiteral<"TableBlock">;
1142
+ cols: z.ZodNumber;
1143
+ rows: z.ZodArray<z.ZodObject<{
1144
+ type: z.ZodLiteral<"TableRow">;
1145
+ cells: z.ZodArray<z.ZodObject<{
1146
+ type: z.ZodLiteral<"TableCell">;
1147
+ colspan: z.ZodOptional<z.ZodNumber>;
1148
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1149
+ type: z.ZodLiteral<"FreeText">;
1150
+ value: z.ZodString;
1151
+ }, "strip", z.ZodTypeAny, {
1152
+ value: string;
1153
+ type: "FreeText";
1154
+ }, {
1155
+ value: string;
1156
+ type: "FreeText";
1157
+ }>, z.ZodObject<{
1158
+ type: z.ZodLiteral<"Space">;
1159
+ }, "strip", z.ZodTypeAny, {
1160
+ type: "Space";
1161
+ }, {
1162
+ type: "Space";
1163
+ }>, z.ZodObject<{
1164
+ type: z.ZodLiteral<"HighlightedText">;
1165
+ value: z.ZodString;
1166
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1167
+ }, "strip", z.ZodTypeAny, {
1168
+ value: string;
1169
+ type: "HighlightedText";
1170
+ highlight?: [number, number] | undefined;
1171
+ }, {
1172
+ value: string;
1173
+ type: "HighlightedText";
1174
+ highlight?: [number, number] | undefined;
1175
+ }>, z.ZodObject<{
1176
+ type: z.ZodLiteral<"ColorText">;
1177
+ value: z.ZodString;
1178
+ color: z.ZodString;
1179
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1180
+ }, "strip", z.ZodTypeAny, {
1181
+ value: string;
1182
+ type: "ColorText";
1183
+ color: string;
1184
+ highlight?: [number, number] | undefined;
1185
+ }, {
1186
+ value: string;
1187
+ type: "ColorText";
1188
+ color: string;
1189
+ highlight?: [number, number] | undefined;
1190
+ }>, z.ZodObject<{
1191
+ type: z.ZodLiteral<"BoldText">;
1192
+ value: z.ZodString;
1193
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1194
+ }, "strip", z.ZodTypeAny, {
1195
+ value: string;
1196
+ type: "BoldText";
1197
+ highlight?: [number, number] | undefined;
1198
+ }, {
1199
+ value: string;
1200
+ type: "BoldText";
1201
+ highlight?: [number, number] | undefined;
1202
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1203
+ type: z.ZodLiteral<"InlineInput">;
1204
+ name: z.ZodString;
1205
+ inputType: z.ZodLiteral<"string">;
1206
+ length: z.ZodNumber;
1207
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1208
+ }, "strip", z.ZodTypeAny, {
1209
+ length: number;
1210
+ type: "InlineInput";
1211
+ inputType: "string";
1212
+ name: string;
1213
+ answer?: string | number | undefined;
1214
+ }, {
1215
+ length: number;
1216
+ type: "InlineInput";
1217
+ inputType: "string";
1218
+ name: string;
1219
+ answer?: string | number | undefined;
1220
+ }>, z.ZodObject<{
1221
+ type: z.ZodLiteral<"InlineInput">;
1222
+ name: z.ZodString;
1223
+ inputType: z.ZodLiteral<"numeric">;
1224
+ digits: z.ZodNumber;
1225
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
1226
+ }, "strip", z.ZodTypeAny, {
1227
+ type: "InlineInput";
1228
+ inputType: "numeric";
1229
+ name: string;
1230
+ digits: number;
1231
+ answer?: string | number | undefined;
1232
+ }, {
1233
+ type: "InlineInput";
1234
+ inputType: "numeric";
1235
+ name: string;
1236
+ digits: number;
1237
+ answer?: string | number | undefined;
1238
+ }>]>]>, "many">;
1239
+ }, "strip", z.ZodTypeAny, {
1240
+ type: "TableCell";
1241
+ inlines: ({
1242
+ value: string;
1243
+ type: "FreeText";
1244
+ } | {
1245
+ type: "Space";
1246
+ } | {
1247
+ value: string;
1248
+ type: "HighlightedText";
1249
+ highlight?: [number, number] | undefined;
1250
+ } | {
1251
+ value: string;
1252
+ type: "ColorText";
1253
+ color: string;
1254
+ highlight?: [number, number] | undefined;
1255
+ } | {
1256
+ value: string;
1257
+ type: "BoldText";
1258
+ highlight?: [number, number] | undefined;
1259
+ } | {
1260
+ length: number;
1261
+ type: "InlineInput";
1262
+ inputType: "string";
1263
+ name: string;
1264
+ answer?: string | number | undefined;
1265
+ } | {
1266
+ type: "InlineInput";
1267
+ inputType: "numeric";
1268
+ name: string;
1269
+ digits: number;
1270
+ answer?: string | number | undefined;
1271
+ })[];
1272
+ colspan?: number | undefined;
1273
+ }, {
1274
+ type: "TableCell";
1275
+ inlines: ({
1276
+ value: string;
1277
+ type: "FreeText";
1278
+ } | {
1279
+ type: "Space";
1280
+ } | {
1281
+ value: string;
1282
+ type: "HighlightedText";
1283
+ highlight?: [number, number] | undefined;
1284
+ } | {
1285
+ value: string;
1286
+ type: "ColorText";
1287
+ color: string;
1288
+ highlight?: [number, number] | undefined;
1289
+ } | {
1290
+ value: string;
1291
+ type: "BoldText";
1292
+ highlight?: [number, number] | undefined;
1293
+ } | {
1294
+ length: number;
1295
+ type: "InlineInput";
1296
+ inputType: "string";
1297
+ name: string;
1298
+ answer?: string | number | undefined;
1299
+ } | {
1300
+ type: "InlineInput";
1301
+ inputType: "numeric";
1302
+ name: string;
1303
+ digits: number;
1304
+ answer?: string | number | undefined;
1305
+ })[];
1306
+ colspan?: number | undefined;
1307
+ }>, "many">;
1308
+ }, "strip", z.ZodTypeAny, {
1309
+ type: "TableRow";
1310
+ cells: {
1311
+ type: "TableCell";
1312
+ inlines: ({
1313
+ value: string;
1314
+ type: "FreeText";
1315
+ } | {
1316
+ type: "Space";
1317
+ } | {
1318
+ value: string;
1319
+ type: "HighlightedText";
1320
+ highlight?: [number, number] | undefined;
1321
+ } | {
1322
+ value: string;
1323
+ type: "ColorText";
1324
+ color: string;
1325
+ highlight?: [number, number] | undefined;
1326
+ } | {
1327
+ value: string;
1328
+ type: "BoldText";
1329
+ highlight?: [number, number] | undefined;
1330
+ } | {
1331
+ length: number;
1332
+ type: "InlineInput";
1333
+ inputType: "string";
1334
+ name: string;
1335
+ answer?: string | number | undefined;
1336
+ } | {
1337
+ type: "InlineInput";
1338
+ inputType: "numeric";
1339
+ name: string;
1340
+ digits: number;
1341
+ answer?: string | number | undefined;
1342
+ })[];
1343
+ colspan?: number | undefined;
1344
+ }[];
1345
+ }, {
1346
+ type: "TableRow";
1347
+ cells: {
1348
+ type: "TableCell";
1349
+ inlines: ({
1350
+ value: string;
1351
+ type: "FreeText";
1352
+ } | {
1353
+ type: "Space";
1354
+ } | {
1355
+ value: string;
1356
+ type: "HighlightedText";
1357
+ highlight?: [number, number] | undefined;
1358
+ } | {
1359
+ value: string;
1360
+ type: "ColorText";
1361
+ color: string;
1362
+ highlight?: [number, number] | undefined;
1363
+ } | {
1364
+ value: string;
1365
+ type: "BoldText";
1366
+ highlight?: [number, number] | undefined;
1367
+ } | {
1368
+ length: number;
1369
+ type: "InlineInput";
1370
+ inputType: "string";
1371
+ name: string;
1372
+ answer?: string | number | undefined;
1373
+ } | {
1374
+ type: "InlineInput";
1375
+ inputType: "numeric";
1376
+ name: string;
1377
+ digits: number;
1378
+ answer?: string | number | undefined;
1379
+ })[];
1380
+ colspan?: number | undefined;
1381
+ }[];
1382
+ }>, "many">;
1383
+ }, "strip", z.ZodTypeAny, {
1384
+ type: "TableBlock";
1385
+ cols: number;
1386
+ rows: {
1387
+ type: "TableRow";
1388
+ cells: {
1389
+ type: "TableCell";
1390
+ inlines: ({
1391
+ value: string;
1392
+ type: "FreeText";
1393
+ } | {
1394
+ type: "Space";
1395
+ } | {
1396
+ value: string;
1397
+ type: "HighlightedText";
1398
+ highlight?: [number, number] | undefined;
1399
+ } | {
1400
+ value: string;
1401
+ type: "ColorText";
1402
+ color: string;
1403
+ highlight?: [number, number] | undefined;
1404
+ } | {
1405
+ value: string;
1406
+ type: "BoldText";
1407
+ highlight?: [number, number] | undefined;
1408
+ } | {
1409
+ length: number;
1410
+ type: "InlineInput";
1411
+ inputType: "string";
1412
+ name: string;
1413
+ answer?: string | number | undefined;
1414
+ } | {
1415
+ type: "InlineInput";
1416
+ inputType: "numeric";
1417
+ name: string;
1418
+ digits: number;
1419
+ answer?: string | number | undefined;
1420
+ })[];
1421
+ colspan?: number | undefined;
1422
+ }[];
1423
+ }[];
1424
+ }, {
1425
+ type: "TableBlock";
1426
+ cols: number;
1427
+ rows: {
1428
+ type: "TableRow";
1429
+ cells: {
1430
+ type: "TableCell";
1431
+ inlines: ({
1432
+ value: string;
1433
+ type: "FreeText";
1434
+ } | {
1435
+ type: "Space";
1436
+ } | {
1437
+ value: string;
1438
+ type: "HighlightedText";
1439
+ highlight?: [number, number] | undefined;
1440
+ } | {
1441
+ value: string;
1442
+ type: "ColorText";
1443
+ color: string;
1444
+ highlight?: [number, number] | undefined;
1445
+ } | {
1446
+ value: string;
1447
+ type: "BoldText";
1448
+ highlight?: [number, number] | undefined;
1449
+ } | {
1450
+ length: number;
1451
+ type: "InlineInput";
1452
+ inputType: "string";
1453
+ name: string;
1454
+ answer?: string | number | undefined;
1455
+ } | {
1456
+ type: "InlineInput";
1457
+ inputType: "numeric";
1458
+ name: string;
1459
+ digits: number;
1460
+ answer?: string | number | undefined;
1461
+ })[];
1462
+ colspan?: number | undefined;
1463
+ }[];
1464
+ }[];
1465
+ }>]>, "many">;
1466
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1467
+ type: z.ZodLiteral<"DragOptions">;
1468
+ options: z.ZodArray<z.ZodString, "many">;
1469
+ }, "strip", z.ZodTypeAny, {
1470
+ type: "DragOptions";
1471
+ options: string[];
1472
+ }, {
1473
+ type: "DragOptions";
1474
+ options: string[];
1475
+ }>, z.ZodObject<{
1476
+ type: z.ZodLiteral<"NumericKeypad">;
1477
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1478
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1479
+ }, "strip", z.ZodTypeAny, {
1480
+ type: "NumericKeypad";
1481
+ includeOperators?: boolean | undefined;
1482
+ includeDecimal?: boolean | undefined;
1483
+ }, {
1484
+ type: "NumericKeypad";
1485
+ includeOperators?: boolean | undefined;
1486
+ includeDecimal?: boolean | undefined;
1487
+ }>]>, "many">>;
1488
+ validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1489
+ type: z.ZodLiteral<"SimpleValidation">;
1490
+ }, "strip", z.ZodTypeAny, {
1491
+ type: "SimpleValidation";
1492
+ }, {
1493
+ type: "SimpleValidation";
1494
+ }>, z.ZodObject<{
1495
+ type: z.ZodLiteral<"ExpressionValidation">;
1496
+ expression: z.ZodString;
1497
+ }, "strip", z.ZodTypeAny, {
1498
+ expression: string;
1499
+ type: "ExpressionValidation";
1500
+ }, {
1501
+ expression: string;
1502
+ type: "ExpressionValidation";
1503
+ }>]>;
1504
+ }, "strip", z.ZodTypeAny, {
1505
+ validation: {
1506
+ type: "SimpleValidation";
1507
+ } | {
1508
+ expression: string;
1509
+ type: "ExpressionValidation";
1510
+ };
1511
+ type: "ExerciseDocument";
1512
+ lines: ({
1513
+ type: "LineBlock";
1514
+ inlines: ({
1515
+ value: string;
1516
+ type: "FreeText";
1517
+ } | {
1518
+ type: "Space";
1519
+ } | {
1520
+ value: string;
1521
+ type: "HighlightedText";
1522
+ highlight?: [number, number] | undefined;
1523
+ } | {
1524
+ value: string;
1525
+ type: "ColorText";
1526
+ color: string;
1527
+ highlight?: [number, number] | undefined;
1528
+ } | {
1529
+ value: string;
1530
+ type: "BoldText";
1531
+ highlight?: [number, number] | undefined;
1532
+ } | {
1533
+ length: number;
1534
+ type: "InlineInput";
1535
+ inputType: "string";
1536
+ name: string;
1537
+ answer?: string | number | undefined;
1538
+ } | {
1539
+ type: "InlineInput";
1540
+ inputType: "numeric";
1541
+ name: string;
1542
+ digits: number;
1543
+ answer?: string | number | undefined;
1544
+ })[];
1545
+ } | {
1546
+ type: "TableBlock";
1547
+ cols: number;
1548
+ rows: {
1549
+ type: "TableRow";
1550
+ cells: {
1551
+ type: "TableCell";
1552
+ inlines: ({
1553
+ value: string;
1554
+ type: "FreeText";
1555
+ } | {
1556
+ type: "Space";
1557
+ } | {
1558
+ value: string;
1559
+ type: "HighlightedText";
1560
+ highlight?: [number, number] | undefined;
1561
+ } | {
1562
+ value: string;
1563
+ type: "ColorText";
1564
+ color: string;
1565
+ highlight?: [number, number] | undefined;
1566
+ } | {
1567
+ value: string;
1568
+ type: "BoldText";
1569
+ highlight?: [number, number] | undefined;
1570
+ } | {
1571
+ length: number;
1572
+ type: "InlineInput";
1573
+ inputType: "string";
1574
+ name: string;
1575
+ answer?: string | number | undefined;
1576
+ } | {
1577
+ type: "InlineInput";
1578
+ inputType: "numeric";
1579
+ name: string;
1580
+ digits: number;
1581
+ answer?: string | number | undefined;
1582
+ })[];
1583
+ colspan?: number | undefined;
1584
+ }[];
1585
+ }[];
1586
+ })[];
1587
+ question?: {
1588
+ value: string;
1589
+ type: "TextBlock";
1590
+ } | undefined;
1591
+ tools?: ({
1592
+ type: "DragOptions";
1593
+ options: string[];
1594
+ } | {
1595
+ type: "NumericKeypad";
1596
+ includeOperators?: boolean | undefined;
1597
+ includeDecimal?: boolean | undefined;
1598
+ })[] | undefined;
1599
+ }, {
1600
+ validation: {
1601
+ type: "SimpleValidation";
1602
+ } | {
1603
+ expression: string;
1604
+ type: "ExpressionValidation";
1605
+ };
1606
+ type: "ExerciseDocument";
1607
+ lines: ({
1608
+ type: "LineBlock";
1609
+ inlines: ({
1610
+ value: string;
1611
+ type: "FreeText";
1612
+ } | {
1613
+ type: "Space";
1614
+ } | {
1615
+ value: string;
1616
+ type: "HighlightedText";
1617
+ highlight?: [number, number] | undefined;
1618
+ } | {
1619
+ value: string;
1620
+ type: "ColorText";
1621
+ color: string;
1622
+ highlight?: [number, number] | undefined;
1623
+ } | {
1624
+ value: string;
1625
+ type: "BoldText";
1626
+ highlight?: [number, number] | undefined;
1627
+ } | {
1628
+ length: number;
1629
+ type: "InlineInput";
1630
+ inputType: "string";
1631
+ name: string;
1632
+ answer?: string | number | undefined;
1633
+ } | {
1634
+ type: "InlineInput";
1635
+ inputType: "numeric";
1636
+ name: string;
1637
+ digits: number;
1638
+ answer?: string | number | undefined;
1639
+ })[];
1640
+ } | {
1641
+ type: "TableBlock";
1642
+ cols: number;
1643
+ rows: {
1644
+ type: "TableRow";
1645
+ cells: {
1646
+ type: "TableCell";
1647
+ inlines: ({
1648
+ value: string;
1649
+ type: "FreeText";
1650
+ } | {
1651
+ type: "Space";
1652
+ } | {
1653
+ value: string;
1654
+ type: "HighlightedText";
1655
+ highlight?: [number, number] | undefined;
1656
+ } | {
1657
+ value: string;
1658
+ type: "ColorText";
1659
+ color: string;
1660
+ highlight?: [number, number] | undefined;
1661
+ } | {
1662
+ value: string;
1663
+ type: "BoldText";
1664
+ highlight?: [number, number] | undefined;
1665
+ } | {
1666
+ length: number;
1667
+ type: "InlineInput";
1668
+ inputType: "string";
1669
+ name: string;
1670
+ answer?: string | number | undefined;
1671
+ } | {
1672
+ type: "InlineInput";
1673
+ inputType: "numeric";
1674
+ name: string;
1675
+ digits: number;
1676
+ answer?: string | number | undefined;
1677
+ })[];
1678
+ colspan?: number | undefined;
1679
+ }[];
1680
+ }[];
1681
+ })[];
1682
+ question?: {
1683
+ value: string;
1684
+ type: "TextBlock";
1685
+ } | undefined;
1686
+ tools?: ({
1687
+ type: "DragOptions";
1688
+ options: string[];
1689
+ } | {
1690
+ type: "NumericKeypad";
1691
+ includeOperators?: boolean | undefined;
1692
+ includeDecimal?: boolean | undefined;
1693
+ })[] | undefined;
1694
+ }>;
1695
+
1696
+ export declare type ExerciseJSON = z.infer<typeof ExerciseJSONSchema>;
1697
+
1698
+ export declare const ExerciseJSONSchema: z.ZodObject<{
1699
+ version: z.ZodLiteral<"2.0">;
1700
+ id: z.ZodOptional<z.ZodString>;
1701
+ layout: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
1702
+ widgets: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1703
+ type: z.ZodLiteral<"inline-input">;
1704
+ inputType: z.ZodLiteral<"string">;
1705
+ length: z.ZodNumber;
1706
+ }, "strip", z.ZodTypeAny, {
1707
+ length: number;
1708
+ type: "inline-input";
1709
+ inputType: "string";
1710
+ }, {
1711
+ length: number;
1712
+ type: "inline-input";
1713
+ inputType: "string";
1714
+ }>, z.ZodObject<{
1715
+ type: z.ZodLiteral<"inline-input">;
1716
+ inputType: z.ZodLiteral<"numeric">;
1717
+ digits: z.ZodNumber;
1718
+ }, "strip", z.ZodTypeAny, {
1719
+ type: "inline-input";
1720
+ inputType: "numeric";
1721
+ digits: number;
1722
+ }, {
1723
+ type: "inline-input";
1724
+ inputType: "numeric";
1725
+ digits: number;
1726
+ }>]>, z.ZodObject<{
1727
+ type: z.ZodLiteral<"drag-options">;
1728
+ options: z.ZodArray<z.ZodString, "many">;
1729
+ }, "strip", z.ZodTypeAny, {
1730
+ type: "drag-options";
1731
+ options: string[];
1732
+ }, {
1733
+ type: "drag-options";
1734
+ options: string[];
1735
+ }>, z.ZodObject<{
1736
+ type: z.ZodLiteral<"numeric-keypad">;
1737
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1738
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1739
+ }, "strip", z.ZodTypeAny, {
1740
+ type: "numeric-keypad";
1741
+ includeOperators?: boolean | undefined;
1742
+ includeDecimal?: boolean | undefined;
1743
+ }, {
1744
+ type: "numeric-keypad";
1745
+ includeOperators?: boolean | undefined;
1746
+ includeDecimal?: boolean | undefined;
1747
+ }>]>>;
1748
+ validation: z.ZodObject<{
1749
+ mode: z.ZodEnum<["simple", "expression"]>;
1750
+ answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
1751
+ expression: z.ZodOptional<z.ZodString>;
1752
+ variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1753
+ }, "strip", z.ZodTypeAny, {
1754
+ mode: "simple" | "expression";
1755
+ expression?: string | undefined;
1756
+ answers?: Record<string, string | number> | undefined;
1757
+ variables?: string[] | undefined;
1758
+ }, {
1759
+ mode: "simple" | "expression";
1760
+ expression?: string | undefined;
1761
+ answers?: Record<string, string | number> | undefined;
1762
+ variables?: string[] | undefined;
1763
+ }>;
1764
+ meta: z.ZodOptional<z.ZodObject<{
1765
+ createdAt: z.ZodOptional<z.ZodString>;
1766
+ author: z.ZodOptional<z.ZodString>;
1767
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1768
+ difficulty: z.ZodOptional<z.ZodNumber>;
1769
+ }, "strip", z.ZodTypeAny, {
1770
+ createdAt?: string | undefined;
1771
+ author?: string | undefined;
1772
+ tags?: string[] | undefined;
1773
+ difficulty?: number | undefined;
1774
+ }, {
1775
+ createdAt?: string | undefined;
1776
+ author?: string | undefined;
1777
+ tags?: string[] | undefined;
1778
+ difficulty?: number | undefined;
1779
+ }>>;
1780
+ }, "strip", z.ZodTypeAny, {
1781
+ validation: {
1782
+ mode: "simple" | "expression";
1783
+ expression?: string | undefined;
1784
+ answers?: Record<string, string | number> | undefined;
1785
+ variables?: string[] | undefined;
1786
+ };
1787
+ version: "2.0";
1788
+ layout: any[];
1789
+ widgets: Record<string, {
1790
+ length: number;
1791
+ type: "inline-input";
1792
+ inputType: "string";
1793
+ } | {
1794
+ type: "inline-input";
1795
+ inputType: "numeric";
1796
+ digits: number;
1797
+ } | {
1798
+ type: "drag-options";
1799
+ options: string[];
1800
+ } | {
1801
+ type: "numeric-keypad";
1802
+ includeOperators?: boolean | undefined;
1803
+ includeDecimal?: boolean | undefined;
1804
+ }>;
1805
+ id?: string | undefined;
1806
+ meta?: {
1807
+ createdAt?: string | undefined;
1808
+ author?: string | undefined;
1809
+ tags?: string[] | undefined;
1810
+ difficulty?: number | undefined;
1811
+ } | undefined;
1812
+ }, {
1813
+ validation: {
1814
+ mode: "simple" | "expression";
1815
+ expression?: string | undefined;
1816
+ answers?: Record<string, string | number> | undefined;
1817
+ variables?: string[] | undefined;
1818
+ };
1819
+ version: "2.0";
1820
+ layout: any[];
1821
+ widgets: Record<string, {
1822
+ length: number;
1823
+ type: "inline-input";
1824
+ inputType: "string";
1825
+ } | {
1826
+ type: "inline-input";
1827
+ inputType: "numeric";
1828
+ digits: number;
1829
+ } | {
1830
+ type: "drag-options";
1831
+ options: string[];
1832
+ } | {
1833
+ type: "numeric-keypad";
1834
+ includeOperators?: boolean | undefined;
1835
+ includeDecimal?: boolean | undefined;
1836
+ }>;
1837
+ id?: string | undefined;
1838
+ meta?: {
1839
+ createdAt?: string | undefined;
1840
+ author?: string | undefined;
1841
+ tags?: string[] | undefined;
1842
+ difficulty?: number | undefined;
1843
+ } | undefined;
1844
+ }>;
1845
+
1846
+ export declare type ExerciseMeta = z.infer<typeof ExerciseMetaSchema>;
1847
+
1848
+ export declare const ExerciseMetaSchema: z.ZodObject<{
1849
+ createdAt: z.ZodOptional<z.ZodString>;
1850
+ author: z.ZodOptional<z.ZodString>;
1851
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1852
+ difficulty: z.ZodOptional<z.ZodNumber>;
1853
+ }, "strip", z.ZodTypeAny, {
1854
+ createdAt?: string | undefined;
1855
+ author?: string | undefined;
1856
+ tags?: string[] | undefined;
1857
+ difficulty?: number | undefined;
1858
+ }, {
1859
+ createdAt?: string | undefined;
1860
+ author?: string | undefined;
1861
+ tags?: string[] | undefined;
1862
+ difficulty?: number | undefined;
1863
+ }>;
1864
+
1865
+ /**
1866
+ * Main renderer component - the contract for rendering exercises.
1867
+ *
1868
+ * This component is DUMB - it only collects values and passes them up.
1869
+ * The parent decides correctness via validation.
1870
+ */
1871
+ export declare const ExerciseRenderer: ForwardRefExoticComponent<ExerciseRendererProps & RefAttributes<ExerciseRendererRef>>;
1872
+
1873
+ export declare interface ExerciseRendererProps {
1874
+ json: ExerciseJSON;
1875
+ onSubmit?: (values: Record<string, string>) => void;
1876
+ onChange?: (values: Record<string, string>) => void;
1877
+ showSubmitButton?: boolean;
1878
+ className?: string;
1879
+ }
1880
+
1881
+ export declare interface ExerciseRendererRef {
1882
+ submit: () => ValidationResult;
1883
+ getValues: () => Record<string, string>;
1884
+ reset: () => void;
1885
+ focusFirstInput: () => void;
1886
+ }
1887
+
1888
+ export declare type ExpressionValidation = z.infer<typeof ExpressionValidationSchema>;
1889
+
1890
+ /**
1891
+ * Expression validation schema - validates using a boolean expression
1892
+ *
1893
+ * The expression can reference widget values by name.
1894
+ * Example: "a + b === 10"
1895
+ *
1896
+ * @example
1897
+ * {
1898
+ * type: "ExpressionValidation",
1899
+ * expression: "a + b === 10"
958
1900
  * }
959
1901
  */
960
1902
  export declare const ExpressionValidationSchema: z.ZodObject<{
@@ -1275,209 +2217,975 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
1275
2217
  }>]>]>;
1276
2218
 
1277
2219
  /**
1278
- * Type guard for BoldText
2220
+ * Type guard for BoldText
2221
+ */
2222
+ export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
2223
+ type: 'bold-text';
2224
+ }>;
2225
+
2226
+ /**
2227
+ * Type guard for ColorText
2228
+ */
2229
+ export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
2230
+ type: 'color-text';
2231
+ }>;
2232
+
2233
+ export declare function isDragOptions(value: unknown): value is DragOptionsTool;
2234
+
2235
+ /**
2236
+ * Type guard for DragOptionsJSON
2237
+ */
2238
+ export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2239
+ type: 'drag-options';
2240
+ }>;
2241
+
2242
+ export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
2243
+
2244
+ export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
2245
+
2246
+ export declare function isFreeText(value: unknown): value is FreeTextInline;
2247
+
2248
+ /**
2249
+ * Type guard for GroupItem
2250
+ */
2251
+ export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutItem, {
2252
+ type: 'group';
2253
+ }>;
2254
+
2255
+ /**
2256
+ * Type guard for HighlightedText
2257
+ */
2258
+ export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
2259
+ type: 'highlighted-text';
2260
+ }>;
2261
+
2262
+ export declare function isInlineInput(value: unknown): value is InlineInputWidget;
2263
+
2264
+ /**
2265
+ * Type guard for InlineInputJSON
2266
+ */
2267
+ export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2268
+ type: 'inline-input';
2269
+ }>;
2270
+
2271
+ export declare function isInlineNode(value: unknown): value is InlineNode;
2272
+
2273
+ export declare function isLineBlock(value: unknown): value is LineBlock;
2274
+
2275
+ /**
2276
+ * Type guard for Linebreak
2277
+ */
2278
+ export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
2279
+ type: 'linebreak';
2280
+ }>;
2281
+
2282
+ export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
2283
+
2284
+ /**
2285
+ * Type guard for NumericKeypadJSON
2286
+ */
2287
+ export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
2288
+ type: 'numeric-keypad';
2289
+ }>;
2290
+
2291
+ /**
2292
+ * Type guard for OperatorItem
2293
+ */
2294
+ export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
2295
+ type: 'operator';
2296
+ }>;
2297
+
2298
+ /**
2299
+ * Type guard for QuestionText
2300
+ */
2301
+ export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
2302
+ type: 'question-text';
2303
+ }>;
2304
+
2305
+ export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
2306
+
2307
+ export declare function isSpace(value: unknown): value is SpaceInline;
2308
+
2309
+ /**
2310
+ * Type guard for SpaceItem
2311
+ */
2312
+ export declare function isSpaceItem(item: LayoutItem): item is Extract<LayoutItem, {
2313
+ type: 'space';
2314
+ }>;
2315
+
2316
+ /**
2317
+ * Type guard for TableCellItem
2318
+ */
2319
+ export declare function isTableCellItem(item: LayoutItem): item is Extract<LayoutItem, {
2320
+ type: 'table-cell';
2321
+ }>;
2322
+
2323
+ /**
2324
+ * Type guard for TableItem
2325
+ */
2326
+ export declare function isTableItem(item: LayoutItem): item is Extract<LayoutItem, {
2327
+ type: 'table';
2328
+ }>;
2329
+
2330
+ /**
2331
+ * Type guard for TableRowItem
2332
+ */
2333
+ export declare function isTableRowItem(item: LayoutItem): item is Extract<LayoutItem, {
2334
+ type: 'table-row';
2335
+ }>;
2336
+
2337
+ export declare function isTextBlock(value: unknown): value is TextBlock;
2338
+
2339
+ /**
2340
+ * Type guard for TextItem
2341
+ */
2342
+ export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
2343
+ type: 'text';
2344
+ }>;
2345
+
2346
+ export declare function isToolNode(value: unknown): value is ToolNode;
2347
+
2348
+ export declare function isValidationNode(value: unknown): value is ValidationNode;
2349
+
2350
+ /**
2351
+ * Check if an expression is syntactically valid
2352
+ *
2353
+ * @param expression - The expression to check
2354
+ * @returns true if valid, false otherwise
1279
2355
  */
1280
- export declare function isBoldText(item: LayoutItem): item is Extract<LayoutItem, {
1281
- type: 'bold-text';
2356
+ export declare function isValidExpression(expression: string): boolean;
2357
+
2358
+ /**
2359
+ * Type guard for WidgetRef
2360
+ */
2361
+ export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
2362
+ type: 'widget-ref';
1282
2363
  }>;
1283
2364
 
1284
2365
  /**
1285
- * Type guard for ColorText
2366
+ * JSON Layout Item Types
2367
+ *
2368
+ * These are the types used in the JSON output format.
1286
2369
  */
1287
- export declare function isColorText(item: LayoutItem): item is Extract<LayoutItem, {
1288
- type: 'color-text';
2370
+ export declare const JSON_TYPES: {
2371
+ /** Question/instruction text */
2372
+ readonly QUESTION_TEXT: "question-text";
2373
+ /** Regular text element */
2374
+ readonly TEXT: "text";
2375
+ /** Spacing element */
2376
+ readonly SPACE: "space";
2377
+ /** Text with optional highlighting */
2378
+ readonly HIGHLIGHTED_TEXT: "highlighted-text";
2379
+ /** Text with color styling */
2380
+ readonly COLOR_TEXT: "color-text";
2381
+ /** Bold text */
2382
+ readonly BOLD_TEXT: "bold-text";
2383
+ /** Reference to a widget */
2384
+ readonly WIDGET_REF: "widget-ref";
2385
+ /** Line break element */
2386
+ readonly LINEBREAK: "linebreak";
2387
+ /** Grouped layout items */
2388
+ readonly GROUP: "group";
2389
+ /** Operator symbol */
2390
+ readonly OPERATOR: "operator";
2391
+ /** Table layout block */
2392
+ readonly TABLE: "table";
2393
+ /** Row within a table */
2394
+ readonly TABLE_ROW: "table-row";
2395
+ /** Cell within a table */
2396
+ readonly TABLE_CELL: "table-cell";
2397
+ /** Inline input widget (string or numeric) */
2398
+ readonly INLINE_INPUT: "inline-input";
2399
+ /** Drag-and-drop options widget */
2400
+ readonly DRAG_OPTIONS: "drag-options";
2401
+ /** Numeric keypad widget */
2402
+ readonly NUMERIC_KEYPAD: "numeric-keypad";
2403
+ };
2404
+
2405
+ /**
2406
+ * Type helper to get all JSON type values as a union type
2407
+ */
2408
+ export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
2409
+
2410
+ export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
2411
+
2412
+ export declare const LayoutItemSchema: z.ZodType<any>;
2413
+
2414
+ /**
2415
+ * DUMB layout renderer - no opinions about spacing or layout.
2416
+ */
2417
+ export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
2418
+
2419
+ export declare interface LayoutRendererProps {
2420
+ item: LayoutItem;
2421
+ widgets: Record<string, WidgetJSON>;
2422
+ values: Record<string, string>;
2423
+ droppedInputs: Set<string>;
2424
+ onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
2425
+ onInputFocus?: (widgetId: string) => void;
2426
+ }
2427
+
2428
+ /**
2429
+ * Error thrown when lexer fails to tokenize input
2430
+ */
2431
+ export declare class LexerError extends EngineError {
2432
+ readonly lexerErrors: ILexingError[];
2433
+ readonly positions: SourcePosition[];
2434
+ constructor(errors: ILexingError[]);
2435
+ }
2436
+
2437
+ export declare type LineBlock = z.infer<typeof LineBlockSchema>;
2438
+
2439
+ /**
2440
+ * Line block schema - represents a visual row of inline elements
2441
+ *
2442
+ * One line = one visual row in the UI
2443
+ * Contains an ordered sequence of inline elements
2444
+ *
2445
+ * @example
2446
+ * {
2447
+ * type: "LineBlock",
2448
+ * inlines: [
2449
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
2450
+ * { type: "InlineInput", name: "x", length: 1 },
2451
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
2452
+ * ]
2453
+ * }
2454
+ */
2455
+ export declare const LineBlockSchema: z.ZodObject<{
2456
+ type: z.ZodLiteral<"LineBlock">;
2457
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2458
+ type: z.ZodLiteral<"FreeText">;
2459
+ value: z.ZodString;
2460
+ }, "strip", z.ZodTypeAny, {
2461
+ value: string;
2462
+ type: "FreeText";
2463
+ }, {
2464
+ value: string;
2465
+ type: "FreeText";
2466
+ }>, z.ZodObject<{
2467
+ type: z.ZodLiteral<"Space">;
2468
+ }, "strip", z.ZodTypeAny, {
2469
+ type: "Space";
2470
+ }, {
2471
+ type: "Space";
2472
+ }>, z.ZodObject<{
2473
+ type: z.ZodLiteral<"HighlightedText">;
2474
+ value: z.ZodString;
2475
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2476
+ }, "strip", z.ZodTypeAny, {
2477
+ value: string;
2478
+ type: "HighlightedText";
2479
+ highlight?: [number, number] | undefined;
2480
+ }, {
2481
+ value: string;
2482
+ type: "HighlightedText";
2483
+ highlight?: [number, number] | undefined;
2484
+ }>, z.ZodObject<{
2485
+ type: z.ZodLiteral<"ColorText">;
2486
+ value: z.ZodString;
2487
+ color: z.ZodString;
2488
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2489
+ }, "strip", z.ZodTypeAny, {
2490
+ value: string;
2491
+ type: "ColorText";
2492
+ color: string;
2493
+ highlight?: [number, number] | undefined;
2494
+ }, {
2495
+ value: string;
2496
+ type: "ColorText";
2497
+ color: string;
2498
+ highlight?: [number, number] | undefined;
2499
+ }>, z.ZodObject<{
2500
+ type: z.ZodLiteral<"BoldText">;
2501
+ value: z.ZodString;
2502
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2503
+ }, "strip", z.ZodTypeAny, {
2504
+ value: string;
2505
+ type: "BoldText";
2506
+ highlight?: [number, number] | undefined;
2507
+ }, {
2508
+ value: string;
2509
+ type: "BoldText";
2510
+ highlight?: [number, number] | undefined;
2511
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
2512
+ type: z.ZodLiteral<"InlineInput">;
2513
+ name: z.ZodString;
2514
+ inputType: z.ZodLiteral<"string">;
2515
+ length: z.ZodNumber;
2516
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2517
+ }, "strip", z.ZodTypeAny, {
2518
+ length: number;
2519
+ type: "InlineInput";
2520
+ inputType: "string";
2521
+ name: string;
2522
+ answer?: string | number | undefined;
2523
+ }, {
2524
+ length: number;
2525
+ type: "InlineInput";
2526
+ inputType: "string";
2527
+ name: string;
2528
+ answer?: string | number | undefined;
2529
+ }>, z.ZodObject<{
2530
+ type: z.ZodLiteral<"InlineInput">;
2531
+ name: z.ZodString;
2532
+ inputType: z.ZodLiteral<"numeric">;
2533
+ digits: z.ZodNumber;
2534
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2535
+ }, "strip", z.ZodTypeAny, {
2536
+ type: "InlineInput";
2537
+ inputType: "numeric";
2538
+ name: string;
2539
+ digits: number;
2540
+ answer?: string | number | undefined;
2541
+ }, {
2542
+ type: "InlineInput";
2543
+ inputType: "numeric";
2544
+ name: string;
2545
+ digits: number;
2546
+ answer?: string | number | undefined;
2547
+ }>]>]>, "many">;
2548
+ }, "strip", z.ZodTypeAny, {
2549
+ type: "LineBlock";
2550
+ inlines: ({
2551
+ value: string;
2552
+ type: "FreeText";
2553
+ } | {
2554
+ type: "Space";
2555
+ } | {
2556
+ value: string;
2557
+ type: "HighlightedText";
2558
+ highlight?: [number, number] | undefined;
2559
+ } | {
2560
+ value: string;
2561
+ type: "ColorText";
2562
+ color: string;
2563
+ highlight?: [number, number] | undefined;
2564
+ } | {
2565
+ value: string;
2566
+ type: "BoldText";
2567
+ highlight?: [number, number] | undefined;
2568
+ } | {
2569
+ length: number;
2570
+ type: "InlineInput";
2571
+ inputType: "string";
2572
+ name: string;
2573
+ answer?: string | number | undefined;
2574
+ } | {
2575
+ type: "InlineInput";
2576
+ inputType: "numeric";
2577
+ name: string;
2578
+ digits: number;
2579
+ answer?: string | number | undefined;
2580
+ })[];
2581
+ }, {
2582
+ type: "LineBlock";
2583
+ inlines: ({
2584
+ value: string;
2585
+ type: "FreeText";
2586
+ } | {
2587
+ type: "Space";
2588
+ } | {
2589
+ value: string;
2590
+ type: "HighlightedText";
2591
+ highlight?: [number, number] | undefined;
2592
+ } | {
2593
+ value: string;
2594
+ type: "ColorText";
2595
+ color: string;
2596
+ highlight?: [number, number] | undefined;
2597
+ } | {
2598
+ value: string;
2599
+ type: "BoldText";
2600
+ highlight?: [number, number] | undefined;
2601
+ } | {
2602
+ length: number;
2603
+ type: "InlineInput";
2604
+ inputType: "string";
2605
+ name: string;
2606
+ answer?: string | number | undefined;
2607
+ } | {
2608
+ type: "InlineInput";
2609
+ inputType: "numeric";
2610
+ name: string;
2611
+ digits: number;
2612
+ answer?: string | number | undefined;
2613
+ })[];
1289
2614
  }>;
1290
2615
 
1291
- export declare function isDragOptions(value: unknown): value is DragOptionsTool;
2616
+ export declare type Linebreak = z.infer<typeof LinebreakSchema>;
1292
2617
 
1293
- /**
1294
- * Type guard for DragOptionsJSON
1295
- */
1296
- export declare function isDragOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1297
- type: 'drag-options';
2618
+ export declare const LinebreakSchema: z.ZodObject<{
2619
+ id: z.ZodString;
2620
+ type: z.ZodLiteral<"linebreak">;
2621
+ }, "strip", z.ZodTypeAny, {
2622
+ type: "linebreak";
2623
+ id: string;
2624
+ }, {
2625
+ type: "linebreak";
2626
+ id: string;
1298
2627
  }>;
1299
2628
 
1300
- export declare function isExerciseDocument(value: unknown): value is ExerciseDocument;
1301
-
1302
- export declare function isExpressionValidation(value: unknown): value is ExpressionValidation;
1303
-
1304
- export declare function isFreeText(value: unknown): value is FreeTextInline;
1305
-
1306
- /**
1307
- * Type guard for GroupItem
1308
- */
1309
- export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutItem, {
1310
- type: 'group';
1311
- }>;
2629
+ export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
1312
2630
 
1313
- /**
1314
- * Type guard for HighlightedText
1315
- */
1316
- export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
1317
- type: 'highlighted-text';
2631
+ export declare const NumericKeypadJSONSchema: z.ZodObject<{
2632
+ type: z.ZodLiteral<"numeric-keypad">;
2633
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2634
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
2635
+ }, "strip", z.ZodTypeAny, {
2636
+ type: "numeric-keypad";
2637
+ includeOperators?: boolean | undefined;
2638
+ includeDecimal?: boolean | undefined;
2639
+ }, {
2640
+ type: "numeric-keypad";
2641
+ includeOperators?: boolean | undefined;
2642
+ includeDecimal?: boolean | undefined;
1318
2643
  }>;
1319
2644
 
1320
- export declare function isInlineInput(value: unknown): value is InlineInputWidget;
2645
+ export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1321
2646
 
1322
2647
  /**
1323
- * Type guard for InlineInputJSON
2648
+ * Numeric keypad tool schema - on-screen number pad
2649
+ *
2650
+ * Use cases:
2651
+ * - Touch-friendly number entry
2652
+ * - Restricting input to numbers only
2653
+ * - Consistent cross-device experience
2654
+ *
2655
+ * @example
2656
+ * {
2657
+ * type: "NumericKeypad",
2658
+ * includeOperators: true
2659
+ * }
1324
2660
  */
1325
- export declare function isInlineInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1326
- type: 'inline-input';
2661
+ export declare const NumericKeypadToolSchema: z.ZodObject<{
2662
+ type: z.ZodLiteral<"NumericKeypad">;
2663
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2664
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
2665
+ }, "strip", z.ZodTypeAny, {
2666
+ type: "NumericKeypad";
2667
+ includeOperators?: boolean | undefined;
2668
+ includeDecimal?: boolean | undefined;
2669
+ }, {
2670
+ type: "NumericKeypad";
2671
+ includeOperators?: boolean | undefined;
2672
+ includeDecimal?: boolean | undefined;
1327
2673
  }>;
1328
2674
 
1329
- export declare function isInlineNode(value: unknown): value is InlineNode;
1330
-
1331
- export declare function isLineBlock(value: unknown): value is LineBlock;
2675
+ export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
1332
2676
 
1333
- /**
1334
- * Type guard for Linebreak
1335
- */
1336
- export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutItem, {
1337
- type: 'linebreak';
2677
+ export declare const OperatorItemSchema: z.ZodObject<{
2678
+ id: z.ZodString;
2679
+ type: z.ZodLiteral<"operator">;
2680
+ operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
2681
+ }, "strip", z.ZodTypeAny, {
2682
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
2683
+ type: "operator";
2684
+ id: string;
2685
+ }, {
2686
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
2687
+ type: "operator";
2688
+ id: string;
1338
2689
  }>;
1339
2690
 
1340
- export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
2691
+ export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1341
2692
 
1342
2693
  /**
1343
- * Type guard for NumericKeypadJSON
2694
+ * Parse DSL tokens into CST
1344
2695
  */
1345
- export declare function isNumericKeypadJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1346
- type: 'numeric-keypad';
1347
- }>;
2696
+ export declare function parse(tokens: IToken[]): CstNode;
1348
2697
 
1349
2698
  /**
1350
- * Type guard for OperatorItem
2699
+ * Error thrown when parser fails to parse tokens
1351
2700
  */
1352
- export declare function isOperatorItem(item: LayoutItem): item is Extract<LayoutItem, {
1353
- type: 'operator';
1354
- }>;
2701
+ export declare class ParseError extends EngineError {
2702
+ readonly parseErrors: IRecognitionException[];
2703
+ readonly positions: SourcePosition[];
2704
+ constructor(errors: IRecognitionException[]);
2705
+ }
1355
2706
 
1356
2707
  /**
1357
- * Type guard for QuestionText
2708
+ * Parse DSL tokens into CST (safe version - returns errors instead of throwing)
1358
2709
  */
1359
- export declare function isQuestionText(item: LayoutItem): item is Extract<LayoutItem, {
1360
- type: 'question-text';
1361
- }>;
1362
-
1363
- export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
1364
-
1365
- export declare function isSpace(value: unknown): value is SpaceInline;
2710
+ export declare function parseSafe(tokens: IToken[]): {
2711
+ success: true;
2712
+ cst: CstNode;
2713
+ error?: undefined;
2714
+ } | {
2715
+ success: false;
2716
+ error: unknown;
2717
+ cst?: undefined;
2718
+ };
1366
2719
 
1367
- export declare function isTextBlock(value: unknown): value is TextBlock;
2720
+ export declare type QuestionText = z.infer<typeof QuestionTextSchema>;
1368
2721
 
1369
- /**
1370
- * Type guard for TextItem
1371
- */
1372
- export declare function isTextItem(item: LayoutItem): item is Extract<LayoutItem, {
1373
- type: 'text';
2722
+ export declare const QuestionTextSchema: z.ZodObject<{
2723
+ id: z.ZodString;
2724
+ type: z.ZodLiteral<"question-text">;
2725
+ value: z.ZodString;
2726
+ }, "strip", z.ZodTypeAny, {
2727
+ value: string;
2728
+ type: "question-text";
2729
+ id: string;
2730
+ }, {
2731
+ value: string;
2732
+ type: "question-text";
2733
+ id: string;
1374
2734
  }>;
1375
2735
 
1376
- export declare function isToolNode(value: unknown): value is ToolNode;
1377
-
1378
- export declare function isValidationNode(value: unknown): value is ValidationNode;
1379
-
1380
2736
  /**
1381
- * Check if an expression is syntactically valid
2737
+ * DOM helper for quick usage / demos.
1382
2738
  *
1383
- * @param expression - The expression to check
1384
- * @returns true if valid, false otherwise
2739
+ * This couples the engine to DOM + React root creation.
2740
+ * For production use, prefer <ExerciseRenderer /> directly in your React tree.
2741
+ *
2742
+ * @example
2743
+ * ```typescript
2744
+ * import { compile, renderExercise } from 'math-exercise-engine';
2745
+ *
2746
+ * const json = compile(dsl);
2747
+ * const unmount = renderExercise({
2748
+ * container: '#app',
2749
+ * json,
2750
+ * onSubmit: (values) => {
2751
+ * // Parent decides correctness
2752
+ * const result = validate(json, values);
2753
+ * console.log(result.isCorrect);
2754
+ * }
2755
+ * });
2756
+ *
2757
+ * // Later: unmount()
2758
+ * ```
1385
2759
  */
1386
- export declare function isValidExpression(expression: string): boolean;
2760
+ export declare function renderExercise(options: RenderOptions): () => void;
1387
2761
 
1388
- /**
1389
- * Type guard for WidgetRef
1390
- */
1391
- export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
1392
- type: 'widget-ref';
1393
- }>;
2762
+ export declare interface RenderOptions {
2763
+ container: HTMLElement | string;
2764
+ json: ExerciseJSON;
2765
+ onSubmit?: (values: Record<string, string>) => void;
2766
+ onChange?: (values: Record<string, string>) => void;
2767
+ showSubmitButton?: boolean;
2768
+ className?: string;
2769
+ }
2770
+
2771
+ export declare type SimpleValidation = z.infer<typeof SimpleValidationSchema>;
1394
2772
 
1395
2773
  /**
1396
- * JSON Layout Item Types
2774
+ * Simple validation schema - direct answer matching
1397
2775
  *
1398
- * These are the types used in the JSON output format.
2776
+ * Each input has a predetermined correct answer.
2777
+ * No complex expressions or calculations.
2778
+ *
2779
+ * @example
2780
+ * {
2781
+ * type: "SimpleValidation"
2782
+ * }
2783
+ *
2784
+ * Note: Actual answer values are stored separately (in widget definitions)
1399
2785
  */
1400
- export declare const JSON_TYPES: {
1401
- /** Question/instruction text */
1402
- readonly QUESTION_TEXT: "question-text";
1403
- /** Regular text element */
1404
- readonly TEXT: "text";
1405
- /** Spacing element */
1406
- readonly SPACE: "space";
1407
- /** Text with optional highlighting */
1408
- readonly HIGHLIGHTED_TEXT: "highlighted-text";
1409
- /** Text with color styling */
1410
- readonly COLOR_TEXT: "color-text";
1411
- /** Bold text */
1412
- readonly BOLD_TEXT: "bold-text";
1413
- /** Reference to a widget */
1414
- readonly WIDGET_REF: "widget-ref";
1415
- /** Line break element */
1416
- readonly LINEBREAK: "linebreak";
1417
- /** Grouped layout items */
1418
- readonly GROUP: "group";
1419
- /** Operator symbol */
1420
- readonly OPERATOR: "operator";
1421
- /** Inline input widget (string or numeric) */
1422
- readonly INLINE_INPUT: "inline-input";
1423
- /** Drag-and-drop options widget */
1424
- readonly DRAG_OPTIONS: "drag-options";
1425
- /** Numeric keypad widget */
1426
- readonly NUMERIC_KEYPAD: "numeric-keypad";
1427
- };
2786
+ export declare const SimpleValidationSchema: z.ZodObject<{
2787
+ type: z.ZodLiteral<"SimpleValidation">;
2788
+ }, "strip", z.ZodTypeAny, {
2789
+ type: "SimpleValidation";
2790
+ }, {
2791
+ type: "SimpleValidation";
2792
+ }>;
1428
2793
 
1429
2794
  /**
1430
- * Type helper to get all JSON type values as a union type
2795
+ * Source position information for error reporting
1431
2796
  */
1432
- export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
1433
-
1434
- export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
2797
+ export declare interface SourcePosition {
2798
+ startLine: number;
2799
+ startColumn: number;
2800
+ endLine: number;
2801
+ endColumn: number;
2802
+ }
1435
2803
 
1436
- export declare const LayoutItemSchema: z.ZodType<any>;
2804
+ export declare type SpaceInline = z.infer<typeof SpaceInlineSchema>;
1437
2805
 
1438
2806
  /**
1439
- * DUMB layout renderer - no opinions about spacing or layout.
2807
+ * Space inline schema - explicit spacing element
2808
+ *
2809
+ * Represents one or more consecutive spaces as a single space element.
2810
+ * This allows for deterministic and explicit control over spacing in the layout.
2811
+ *
2812
+ * @example
2813
+ * { type: "Space" }
1440
2814
  */
1441
- export declare const LayoutRenderer: default_2.FC<LayoutRendererProps>;
2815
+ export declare const SpaceInlineSchema: z.ZodObject<{
2816
+ type: z.ZodLiteral<"Space">;
2817
+ }, "strip", z.ZodTypeAny, {
2818
+ type: "Space";
2819
+ }, {
2820
+ type: "Space";
2821
+ }>;
2822
+
2823
+ export declare type SpaceItem = z.infer<typeof SpaceItemSchema>;
2824
+
2825
+ export declare const SpaceItemSchema: z.ZodObject<{
2826
+ id: z.ZodString;
2827
+ type: z.ZodLiteral<"space">;
2828
+ }, "strip", z.ZodTypeAny, {
2829
+ type: "space";
2830
+ id: string;
2831
+ }, {
2832
+ type: "space";
2833
+ id: string;
2834
+ }>;
2835
+
2836
+ export declare type TableBlock = z.infer<typeof TableBlockSchema>;
2837
+
2838
+ declare const TableBlockSchema: z.ZodObject<{
2839
+ type: z.ZodLiteral<"TableBlock">;
2840
+ cols: z.ZodNumber;
2841
+ rows: z.ZodArray<z.ZodObject<{
2842
+ type: z.ZodLiteral<"TableRow">;
2843
+ cells: z.ZodArray<z.ZodObject<{
2844
+ type: z.ZodLiteral<"TableCell">;
2845
+ colspan: z.ZodOptional<z.ZodNumber>;
2846
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
2847
+ type: z.ZodLiteral<"FreeText">;
2848
+ value: z.ZodString;
2849
+ }, "strip", z.ZodTypeAny, {
2850
+ value: string;
2851
+ type: "FreeText";
2852
+ }, {
2853
+ value: string;
2854
+ type: "FreeText";
2855
+ }>, z.ZodObject<{
2856
+ type: z.ZodLiteral<"Space">;
2857
+ }, "strip", z.ZodTypeAny, {
2858
+ type: "Space";
2859
+ }, {
2860
+ type: "Space";
2861
+ }>, z.ZodObject<{
2862
+ type: z.ZodLiteral<"HighlightedText">;
2863
+ value: z.ZodString;
2864
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2865
+ }, "strip", z.ZodTypeAny, {
2866
+ value: string;
2867
+ type: "HighlightedText";
2868
+ highlight?: [number, number] | undefined;
2869
+ }, {
2870
+ value: string;
2871
+ type: "HighlightedText";
2872
+ highlight?: [number, number] | undefined;
2873
+ }>, z.ZodObject<{
2874
+ type: z.ZodLiteral<"ColorText">;
2875
+ value: z.ZodString;
2876
+ color: z.ZodString;
2877
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2878
+ }, "strip", z.ZodTypeAny, {
2879
+ value: string;
2880
+ type: "ColorText";
2881
+ color: string;
2882
+ highlight?: [number, number] | undefined;
2883
+ }, {
2884
+ value: string;
2885
+ type: "ColorText";
2886
+ color: string;
2887
+ highlight?: [number, number] | undefined;
2888
+ }>, z.ZodObject<{
2889
+ type: z.ZodLiteral<"BoldText">;
2890
+ value: z.ZodString;
2891
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
2892
+ }, "strip", z.ZodTypeAny, {
2893
+ value: string;
2894
+ type: "BoldText";
2895
+ highlight?: [number, number] | undefined;
2896
+ }, {
2897
+ value: string;
2898
+ type: "BoldText";
2899
+ highlight?: [number, number] | undefined;
2900
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
2901
+ type: z.ZodLiteral<"InlineInput">;
2902
+ name: z.ZodString;
2903
+ inputType: z.ZodLiteral<"string">;
2904
+ length: z.ZodNumber;
2905
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2906
+ }, "strip", z.ZodTypeAny, {
2907
+ length: number;
2908
+ type: "InlineInput";
2909
+ inputType: "string";
2910
+ name: string;
2911
+ answer?: string | number | undefined;
2912
+ }, {
2913
+ length: number;
2914
+ type: "InlineInput";
2915
+ inputType: "string";
2916
+ name: string;
2917
+ answer?: string | number | undefined;
2918
+ }>, z.ZodObject<{
2919
+ type: z.ZodLiteral<"InlineInput">;
2920
+ name: z.ZodString;
2921
+ inputType: z.ZodLiteral<"numeric">;
2922
+ digits: z.ZodNumber;
2923
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
2924
+ }, "strip", z.ZodTypeAny, {
2925
+ type: "InlineInput";
2926
+ inputType: "numeric";
2927
+ name: string;
2928
+ digits: number;
2929
+ answer?: string | number | undefined;
2930
+ }, {
2931
+ type: "InlineInput";
2932
+ inputType: "numeric";
2933
+ name: string;
2934
+ digits: number;
2935
+ answer?: string | number | undefined;
2936
+ }>]>]>, "many">;
2937
+ }, "strip", z.ZodTypeAny, {
2938
+ type: "TableCell";
2939
+ inlines: ({
2940
+ value: string;
2941
+ type: "FreeText";
2942
+ } | {
2943
+ type: "Space";
2944
+ } | {
2945
+ value: string;
2946
+ type: "HighlightedText";
2947
+ highlight?: [number, number] | undefined;
2948
+ } | {
2949
+ value: string;
2950
+ type: "ColorText";
2951
+ color: string;
2952
+ highlight?: [number, number] | undefined;
2953
+ } | {
2954
+ value: string;
2955
+ type: "BoldText";
2956
+ highlight?: [number, number] | undefined;
2957
+ } | {
2958
+ length: number;
2959
+ type: "InlineInput";
2960
+ inputType: "string";
2961
+ name: string;
2962
+ answer?: string | number | undefined;
2963
+ } | {
2964
+ type: "InlineInput";
2965
+ inputType: "numeric";
2966
+ name: string;
2967
+ digits: number;
2968
+ answer?: string | number | undefined;
2969
+ })[];
2970
+ colspan?: number | undefined;
2971
+ }, {
2972
+ type: "TableCell";
2973
+ inlines: ({
2974
+ value: string;
2975
+ type: "FreeText";
2976
+ } | {
2977
+ type: "Space";
2978
+ } | {
2979
+ value: string;
2980
+ type: "HighlightedText";
2981
+ highlight?: [number, number] | undefined;
2982
+ } | {
2983
+ value: string;
2984
+ type: "ColorText";
2985
+ color: string;
2986
+ highlight?: [number, number] | undefined;
2987
+ } | {
2988
+ value: string;
2989
+ type: "BoldText";
2990
+ highlight?: [number, number] | undefined;
2991
+ } | {
2992
+ length: number;
2993
+ type: "InlineInput";
2994
+ inputType: "string";
2995
+ name: string;
2996
+ answer?: string | number | undefined;
2997
+ } | {
2998
+ type: "InlineInput";
2999
+ inputType: "numeric";
3000
+ name: string;
3001
+ digits: number;
3002
+ answer?: string | number | undefined;
3003
+ })[];
3004
+ colspan?: number | undefined;
3005
+ }>, "many">;
3006
+ }, "strip", z.ZodTypeAny, {
3007
+ type: "TableRow";
3008
+ cells: {
3009
+ type: "TableCell";
3010
+ inlines: ({
3011
+ value: string;
3012
+ type: "FreeText";
3013
+ } | {
3014
+ type: "Space";
3015
+ } | {
3016
+ value: string;
3017
+ type: "HighlightedText";
3018
+ highlight?: [number, number] | undefined;
3019
+ } | {
3020
+ value: string;
3021
+ type: "ColorText";
3022
+ color: string;
3023
+ highlight?: [number, number] | undefined;
3024
+ } | {
3025
+ value: string;
3026
+ type: "BoldText";
3027
+ highlight?: [number, number] | undefined;
3028
+ } | {
3029
+ length: number;
3030
+ type: "InlineInput";
3031
+ inputType: "string";
3032
+ name: string;
3033
+ answer?: string | number | undefined;
3034
+ } | {
3035
+ type: "InlineInput";
3036
+ inputType: "numeric";
3037
+ name: string;
3038
+ digits: number;
3039
+ answer?: string | number | undefined;
3040
+ })[];
3041
+ colspan?: number | undefined;
3042
+ }[];
3043
+ }, {
3044
+ type: "TableRow";
3045
+ cells: {
3046
+ type: "TableCell";
3047
+ inlines: ({
3048
+ value: string;
3049
+ type: "FreeText";
3050
+ } | {
3051
+ type: "Space";
3052
+ } | {
3053
+ value: string;
3054
+ type: "HighlightedText";
3055
+ highlight?: [number, number] | undefined;
3056
+ } | {
3057
+ value: string;
3058
+ type: "ColorText";
3059
+ color: string;
3060
+ highlight?: [number, number] | undefined;
3061
+ } | {
3062
+ value: string;
3063
+ type: "BoldText";
3064
+ highlight?: [number, number] | undefined;
3065
+ } | {
3066
+ length: number;
3067
+ type: "InlineInput";
3068
+ inputType: "string";
3069
+ name: string;
3070
+ answer?: string | number | undefined;
3071
+ } | {
3072
+ type: "InlineInput";
3073
+ inputType: "numeric";
3074
+ name: string;
3075
+ digits: number;
3076
+ answer?: string | number | undefined;
3077
+ })[];
3078
+ colspan?: number | undefined;
3079
+ }[];
3080
+ }>, "many">;
3081
+ }, "strip", z.ZodTypeAny, {
3082
+ type: "TableBlock";
3083
+ cols: number;
3084
+ rows: {
3085
+ type: "TableRow";
3086
+ cells: {
3087
+ type: "TableCell";
3088
+ inlines: ({
3089
+ value: string;
3090
+ type: "FreeText";
3091
+ } | {
3092
+ type: "Space";
3093
+ } | {
3094
+ value: string;
3095
+ type: "HighlightedText";
3096
+ highlight?: [number, number] | undefined;
3097
+ } | {
3098
+ value: string;
3099
+ type: "ColorText";
3100
+ color: string;
3101
+ highlight?: [number, number] | undefined;
3102
+ } | {
3103
+ value: string;
3104
+ type: "BoldText";
3105
+ highlight?: [number, number] | undefined;
3106
+ } | {
3107
+ length: number;
3108
+ type: "InlineInput";
3109
+ inputType: "string";
3110
+ name: string;
3111
+ answer?: string | number | undefined;
3112
+ } | {
3113
+ type: "InlineInput";
3114
+ inputType: "numeric";
3115
+ name: string;
3116
+ digits: number;
3117
+ answer?: string | number | undefined;
3118
+ })[];
3119
+ colspan?: number | undefined;
3120
+ }[];
3121
+ }[];
3122
+ }, {
3123
+ type: "TableBlock";
3124
+ cols: number;
3125
+ rows: {
3126
+ type: "TableRow";
3127
+ cells: {
3128
+ type: "TableCell";
3129
+ inlines: ({
3130
+ value: string;
3131
+ type: "FreeText";
3132
+ } | {
3133
+ type: "Space";
3134
+ } | {
3135
+ value: string;
3136
+ type: "HighlightedText";
3137
+ highlight?: [number, number] | undefined;
3138
+ } | {
3139
+ value: string;
3140
+ type: "ColorText";
3141
+ color: string;
3142
+ highlight?: [number, number] | undefined;
3143
+ } | {
3144
+ value: string;
3145
+ type: "BoldText";
3146
+ highlight?: [number, number] | undefined;
3147
+ } | {
3148
+ length: number;
3149
+ type: "InlineInput";
3150
+ inputType: "string";
3151
+ name: string;
3152
+ answer?: string | number | undefined;
3153
+ } | {
3154
+ type: "InlineInput";
3155
+ inputType: "numeric";
3156
+ name: string;
3157
+ digits: number;
3158
+ answer?: string | number | undefined;
3159
+ })[];
3160
+ colspan?: number | undefined;
3161
+ }[];
3162
+ }[];
3163
+ }>;
1442
3164
 
1443
- export declare interface LayoutRendererProps {
1444
- item: LayoutItem;
1445
- widgets: Record<string, WidgetJSON>;
1446
- values: Record<string, string>;
1447
- droppedInputs: Set<string>;
1448
- onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
1449
- onInputFocus?: (widgetId: string) => void;
1450
- }
3165
+ export declare type TableCell = z.infer<typeof TableCellSchema>;
1451
3166
 
1452
- /**
1453
- * Error thrown when lexer fails to tokenize input
1454
- */
1455
- export declare class LexerError extends EngineError {
1456
- readonly lexerErrors: ILexingError[];
1457
- readonly positions: SourcePosition[];
1458
- constructor(errors: ILexingError[]);
1459
- }
3167
+ export declare type TableCellItem = z.infer<typeof TableCellItemSchema>;
1460
3168
 
1461
- export declare type LineBlock = z.infer<typeof LineBlockSchema>;
3169
+ export declare const TableCellItemSchema: z.ZodObject<{
3170
+ id: z.ZodString;
3171
+ type: z.ZodLiteral<"table-cell">;
3172
+ colspan: z.ZodOptional<z.ZodNumber>;
3173
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3174
+ }, "strip", z.ZodTypeAny, {
3175
+ type: "table-cell";
3176
+ id: string;
3177
+ items: any[];
3178
+ colspan?: number | undefined;
3179
+ }, {
3180
+ type: "table-cell";
3181
+ id: string;
3182
+ items: any[];
3183
+ colspan?: number | undefined;
3184
+ }>;
1462
3185
 
1463
- /**
1464
- * Line block schema - represents a visual row of inline elements
1465
- *
1466
- * One line = one visual row in the UI
1467
- * Contains an ordered sequence of inline elements
1468
- *
1469
- * @example
1470
- * {
1471
- * type: "LineBlock",
1472
- * inlines: [
1473
- * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
1474
- * { type: "InlineInput", name: "x", length: 1 },
1475
- * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
1476
- * ]
1477
- * }
1478
- */
1479
- export declare const LineBlockSchema: z.ZodObject<{
1480
- type: z.ZodLiteral<"LineBlock">;
3186
+ declare const TableCellSchema: z.ZodObject<{
3187
+ type: z.ZodLiteral<"TableCell">;
3188
+ colspan: z.ZodOptional<z.ZodNumber>;
1481
3189
  inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
1482
3190
  type: z.ZodLiteral<"FreeText">;
1483
3191
  value: z.ZodString;
@@ -1570,7 +3278,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1570
3278
  answer?: string | number | undefined;
1571
3279
  }>]>]>, "many">;
1572
3280
  }, "strip", z.ZodTypeAny, {
1573
- type: "LineBlock";
3281
+ type: "TableCell";
1574
3282
  inlines: ({
1575
3283
  value: string;
1576
3284
  type: "FreeText";
@@ -1602,8 +3310,9 @@ export declare const LineBlockSchema: z.ZodObject<{
1602
3310
  digits: number;
1603
3311
  answer?: string | number | undefined;
1604
3312
  })[];
3313
+ colspan?: number | undefined;
1605
3314
  }, {
1606
- type: "LineBlock";
3315
+ type: "TableCell";
1607
3316
  inlines: ({
1608
3317
  value: string;
1609
3318
  type: "FreeText";
@@ -1635,213 +3344,365 @@ export declare const LineBlockSchema: z.ZodObject<{
1635
3344
  digits: number;
1636
3345
  answer?: string | number | undefined;
1637
3346
  })[];
3347
+ colspan?: number | undefined;
1638
3348
  }>;
1639
3349
 
1640
- export declare type Linebreak = z.infer<typeof LinebreakSchema>;
1641
-
1642
- export declare const LinebreakSchema: z.ZodObject<{
1643
- id: z.ZodString;
1644
- type: z.ZodLiteral<"linebreak">;
1645
- }, "strip", z.ZodTypeAny, {
1646
- type: "linebreak";
1647
- id: string;
1648
- }, {
1649
- type: "linebreak";
1650
- id: string;
1651
- }>;
1652
-
1653
- export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
1654
-
1655
- export declare const NumericKeypadJSONSchema: z.ZodObject<{
1656
- type: z.ZodLiteral<"numeric-keypad">;
1657
- includeOperators: z.ZodOptional<z.ZodBoolean>;
1658
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
1659
- }, "strip", z.ZodTypeAny, {
1660
- type: "numeric-keypad";
1661
- includeOperators?: boolean | undefined;
1662
- includeDecimal?: boolean | undefined;
1663
- }, {
1664
- type: "numeric-keypad";
1665
- includeOperators?: boolean | undefined;
1666
- includeDecimal?: boolean | undefined;
1667
- }>;
1668
-
1669
- export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1670
-
1671
- /**
1672
- * Numeric keypad tool schema - on-screen number pad
1673
- *
1674
- * Use cases:
1675
- * - Touch-friendly number entry
1676
- * - Restricting input to numbers only
1677
- * - Consistent cross-device experience
1678
- *
1679
- * @example
1680
- * {
1681
- * type: "NumericKeypad",
1682
- * includeOperators: true
1683
- * }
1684
- */
1685
- export declare const NumericKeypadToolSchema: z.ZodObject<{
1686
- type: z.ZodLiteral<"NumericKeypad">;
1687
- includeOperators: z.ZodOptional<z.ZodBoolean>;
1688
- includeDecimal: z.ZodOptional<z.ZodBoolean>;
1689
- }, "strip", z.ZodTypeAny, {
1690
- type: "NumericKeypad";
1691
- includeOperators?: boolean | undefined;
1692
- includeDecimal?: boolean | undefined;
1693
- }, {
1694
- type: "NumericKeypad";
1695
- includeOperators?: boolean | undefined;
1696
- includeDecimal?: boolean | undefined;
1697
- }>;
1698
-
1699
- export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
1700
-
1701
- export declare const OperatorItemSchema: z.ZodObject<{
1702
- id: z.ZodString;
1703
- type: z.ZodLiteral<"operator">;
1704
- operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1705
- }, "strip", z.ZodTypeAny, {
1706
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1707
- type: "operator";
1708
- id: string;
1709
- }, {
1710
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1711
- type: "operator";
1712
- id: string;
1713
- }>;
1714
-
1715
- export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1716
-
1717
- /**
1718
- * Parse DSL tokens into CST
1719
- */
1720
- export declare function parse(tokens: IToken[]): CstNode;
1721
-
1722
- /**
1723
- * Error thrown when parser fails to parse tokens
1724
- */
1725
- export declare class ParseError extends EngineError {
1726
- readonly parseErrors: IRecognitionException[];
1727
- readonly positions: SourcePosition[];
1728
- constructor(errors: IRecognitionException[]);
1729
- }
1730
-
1731
- /**
1732
- * Parse DSL tokens into CST (safe version - returns errors instead of throwing)
1733
- */
1734
- export declare function parseSafe(tokens: IToken[]): {
1735
- success: true;
1736
- cst: CstNode;
1737
- error?: undefined;
1738
- } | {
1739
- success: false;
1740
- error: unknown;
1741
- cst?: undefined;
1742
- };
1743
-
1744
- export declare type QuestionText = z.infer<typeof QuestionTextSchema>;
3350
+ export declare type TableItem = z.infer<typeof TableItemSchema>;
1745
3351
 
1746
- export declare const QuestionTextSchema: z.ZodObject<{
3352
+ export declare const TableItemSchema: z.ZodObject<{
1747
3353
  id: z.ZodString;
1748
- type: z.ZodLiteral<"question-text">;
1749
- value: z.ZodString;
3354
+ type: z.ZodLiteral<"table">;
3355
+ cols: z.ZodNumber;
3356
+ rows: z.ZodArray<z.ZodObject<{
3357
+ id: z.ZodString;
3358
+ type: z.ZodLiteral<"table-row">;
3359
+ cells: z.ZodArray<z.ZodObject<{
3360
+ id: z.ZodString;
3361
+ type: z.ZodLiteral<"table-cell">;
3362
+ colspan: z.ZodOptional<z.ZodNumber>;
3363
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3364
+ }, "strip", z.ZodTypeAny, {
3365
+ type: "table-cell";
3366
+ id: string;
3367
+ items: any[];
3368
+ colspan?: number | undefined;
3369
+ }, {
3370
+ type: "table-cell";
3371
+ id: string;
3372
+ items: any[];
3373
+ colspan?: number | undefined;
3374
+ }>, "many">;
3375
+ }, "strip", z.ZodTypeAny, {
3376
+ type: "table-row";
3377
+ cells: {
3378
+ type: "table-cell";
3379
+ id: string;
3380
+ items: any[];
3381
+ colspan?: number | undefined;
3382
+ }[];
3383
+ id: string;
3384
+ }, {
3385
+ type: "table-row";
3386
+ cells: {
3387
+ type: "table-cell";
3388
+ id: string;
3389
+ items: any[];
3390
+ colspan?: number | undefined;
3391
+ }[];
3392
+ id: string;
3393
+ }>, "many">;
1750
3394
  }, "strip", z.ZodTypeAny, {
1751
- value: string;
1752
- type: "question-text";
1753
- id: string;
1754
- }, {
1755
- value: string;
1756
- type: "question-text";
3395
+ type: "table";
3396
+ cols: number;
3397
+ rows: {
3398
+ type: "table-row";
3399
+ cells: {
3400
+ type: "table-cell";
3401
+ id: string;
3402
+ items: any[];
3403
+ colspan?: number | undefined;
3404
+ }[];
3405
+ id: string;
3406
+ }[];
1757
3407
  id: string;
1758
- }>;
1759
-
1760
- /**
1761
- * DOM helper for quick usage / demos.
1762
- *
1763
- * This couples the engine to DOM + React root creation.
1764
- * For production use, prefer <ExerciseRenderer /> directly in your React tree.
1765
- *
1766
- * @example
1767
- * ```typescript
1768
- * import { compile, renderExercise } from 'math-exercise-engine';
1769
- *
1770
- * const json = compile(dsl);
1771
- * const unmount = renderExercise({
1772
- * container: '#app',
1773
- * json,
1774
- * onSubmit: (values) => {
1775
- * // Parent decides correctness
1776
- * const result = validate(json, values);
1777
- * console.log(result.isCorrect);
1778
- * }
1779
- * });
1780
- *
1781
- * // Later: unmount()
1782
- * ```
1783
- */
1784
- export declare function renderExercise(options: RenderOptions): () => void;
1785
-
1786
- export declare interface RenderOptions {
1787
- container: HTMLElement | string;
1788
- json: ExerciseJSON;
1789
- onSubmit?: (values: Record<string, string>) => void;
1790
- onChange?: (values: Record<string, string>) => void;
1791
- showSubmitButton?: boolean;
1792
- className?: string;
1793
- }
1794
-
1795
- export declare type SimpleValidation = z.infer<typeof SimpleValidationSchema>;
1796
-
1797
- /**
1798
- * Simple validation schema - direct answer matching
1799
- *
1800
- * Each input has a predetermined correct answer.
1801
- * No complex expressions or calculations.
1802
- *
1803
- * @example
1804
- * {
1805
- * type: "SimpleValidation"
1806
- * }
1807
- *
1808
- * Note: Actual answer values are stored separately (in widget definitions)
1809
- */
1810
- export declare const SimpleValidationSchema: z.ZodObject<{
1811
- type: z.ZodLiteral<"SimpleValidation">;
1812
- }, "strip", z.ZodTypeAny, {
1813
- type: "SimpleValidation";
1814
3408
  }, {
1815
- type: "SimpleValidation";
3409
+ type: "table";
3410
+ cols: number;
3411
+ rows: {
3412
+ type: "table-row";
3413
+ cells: {
3414
+ type: "table-cell";
3415
+ id: string;
3416
+ items: any[];
3417
+ colspan?: number | undefined;
3418
+ }[];
3419
+ id: string;
3420
+ }[];
3421
+ id: string;
1816
3422
  }>;
1817
3423
 
1818
- /**
1819
- * Source position information for error reporting
1820
- */
1821
- export declare interface SourcePosition {
1822
- startLine: number;
1823
- startColumn: number;
1824
- endLine: number;
1825
- endColumn: number;
1826
- }
3424
+ export declare type TableRow = z.infer<typeof TableRowSchema>;
1827
3425
 
1828
- export declare type SpaceInline = z.infer<typeof SpaceInlineSchema>;
3426
+ export declare type TableRowItem = z.infer<typeof TableRowItemSchema>;
1829
3427
 
1830
- /**
1831
- * Space inline schema - explicit spacing element
1832
- *
1833
- * Represents one or more consecutive spaces as a single space element.
1834
- * This allows for deterministic and explicit control over spacing in the layout.
1835
- *
1836
- * @example
1837
- * { type: "Space" }
1838
- */
1839
- export declare const SpaceInlineSchema: z.ZodObject<{
1840
- type: z.ZodLiteral<"Space">;
3428
+ export declare const TableRowItemSchema: z.ZodObject<{
3429
+ id: z.ZodString;
3430
+ type: z.ZodLiteral<"table-row">;
3431
+ cells: z.ZodArray<z.ZodObject<{
3432
+ id: z.ZodString;
3433
+ type: z.ZodLiteral<"table-cell">;
3434
+ colspan: z.ZodOptional<z.ZodNumber>;
3435
+ items: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
3436
+ }, "strip", z.ZodTypeAny, {
3437
+ type: "table-cell";
3438
+ id: string;
3439
+ items: any[];
3440
+ colspan?: number | undefined;
3441
+ }, {
3442
+ type: "table-cell";
3443
+ id: string;
3444
+ items: any[];
3445
+ colspan?: number | undefined;
3446
+ }>, "many">;
1841
3447
  }, "strip", z.ZodTypeAny, {
1842
- type: "Space";
3448
+ type: "table-row";
3449
+ cells: {
3450
+ type: "table-cell";
3451
+ id: string;
3452
+ items: any[];
3453
+ colspan?: number | undefined;
3454
+ }[];
3455
+ id: string;
1843
3456
  }, {
1844
- type: "Space";
3457
+ type: "table-row";
3458
+ cells: {
3459
+ type: "table-cell";
3460
+ id: string;
3461
+ items: any[];
3462
+ colspan?: number | undefined;
3463
+ }[];
3464
+ id: string;
3465
+ }>;
3466
+
3467
+ declare const TableRowSchema: z.ZodObject<{
3468
+ type: z.ZodLiteral<"TableRow">;
3469
+ cells: z.ZodArray<z.ZodObject<{
3470
+ type: z.ZodLiteral<"TableCell">;
3471
+ colspan: z.ZodOptional<z.ZodNumber>;
3472
+ inlines: z.ZodArray<z.ZodUnion<[z.ZodObject<{
3473
+ type: z.ZodLiteral<"FreeText">;
3474
+ value: z.ZodString;
3475
+ }, "strip", z.ZodTypeAny, {
3476
+ value: string;
3477
+ type: "FreeText";
3478
+ }, {
3479
+ value: string;
3480
+ type: "FreeText";
3481
+ }>, z.ZodObject<{
3482
+ type: z.ZodLiteral<"Space">;
3483
+ }, "strip", z.ZodTypeAny, {
3484
+ type: "Space";
3485
+ }, {
3486
+ type: "Space";
3487
+ }>, z.ZodObject<{
3488
+ type: z.ZodLiteral<"HighlightedText">;
3489
+ value: z.ZodString;
3490
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3491
+ }, "strip", z.ZodTypeAny, {
3492
+ value: string;
3493
+ type: "HighlightedText";
3494
+ highlight?: [number, number] | undefined;
3495
+ }, {
3496
+ value: string;
3497
+ type: "HighlightedText";
3498
+ highlight?: [number, number] | undefined;
3499
+ }>, z.ZodObject<{
3500
+ type: z.ZodLiteral<"ColorText">;
3501
+ value: z.ZodString;
3502
+ color: z.ZodString;
3503
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3504
+ }, "strip", z.ZodTypeAny, {
3505
+ value: string;
3506
+ type: "ColorText";
3507
+ color: string;
3508
+ highlight?: [number, number] | undefined;
3509
+ }, {
3510
+ value: string;
3511
+ type: "ColorText";
3512
+ color: string;
3513
+ highlight?: [number, number] | undefined;
3514
+ }>, z.ZodObject<{
3515
+ type: z.ZodLiteral<"BoldText">;
3516
+ value: z.ZodString;
3517
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
3518
+ }, "strip", z.ZodTypeAny, {
3519
+ value: string;
3520
+ type: "BoldText";
3521
+ highlight?: [number, number] | undefined;
3522
+ }, {
3523
+ value: string;
3524
+ type: "BoldText";
3525
+ highlight?: [number, number] | undefined;
3526
+ }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
3527
+ type: z.ZodLiteral<"InlineInput">;
3528
+ name: z.ZodString;
3529
+ inputType: z.ZodLiteral<"string">;
3530
+ length: z.ZodNumber;
3531
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3532
+ }, "strip", z.ZodTypeAny, {
3533
+ length: number;
3534
+ type: "InlineInput";
3535
+ inputType: "string";
3536
+ name: string;
3537
+ answer?: string | number | undefined;
3538
+ }, {
3539
+ length: number;
3540
+ type: "InlineInput";
3541
+ inputType: "string";
3542
+ name: string;
3543
+ answer?: string | number | undefined;
3544
+ }>, z.ZodObject<{
3545
+ type: z.ZodLiteral<"InlineInput">;
3546
+ name: z.ZodString;
3547
+ inputType: z.ZodLiteral<"numeric">;
3548
+ digits: z.ZodNumber;
3549
+ answer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
3550
+ }, "strip", z.ZodTypeAny, {
3551
+ type: "InlineInput";
3552
+ inputType: "numeric";
3553
+ name: string;
3554
+ digits: number;
3555
+ answer?: string | number | undefined;
3556
+ }, {
3557
+ type: "InlineInput";
3558
+ inputType: "numeric";
3559
+ name: string;
3560
+ digits: number;
3561
+ answer?: string | number | undefined;
3562
+ }>]>]>, "many">;
3563
+ }, "strip", z.ZodTypeAny, {
3564
+ type: "TableCell";
3565
+ inlines: ({
3566
+ value: string;
3567
+ type: "FreeText";
3568
+ } | {
3569
+ type: "Space";
3570
+ } | {
3571
+ value: string;
3572
+ type: "HighlightedText";
3573
+ highlight?: [number, number] | undefined;
3574
+ } | {
3575
+ value: string;
3576
+ type: "ColorText";
3577
+ color: string;
3578
+ highlight?: [number, number] | undefined;
3579
+ } | {
3580
+ value: string;
3581
+ type: "BoldText";
3582
+ highlight?: [number, number] | undefined;
3583
+ } | {
3584
+ length: number;
3585
+ type: "InlineInput";
3586
+ inputType: "string";
3587
+ name: string;
3588
+ answer?: string | number | undefined;
3589
+ } | {
3590
+ type: "InlineInput";
3591
+ inputType: "numeric";
3592
+ name: string;
3593
+ digits: number;
3594
+ answer?: string | number | undefined;
3595
+ })[];
3596
+ colspan?: number | undefined;
3597
+ }, {
3598
+ type: "TableCell";
3599
+ inlines: ({
3600
+ value: string;
3601
+ type: "FreeText";
3602
+ } | {
3603
+ type: "Space";
3604
+ } | {
3605
+ value: string;
3606
+ type: "HighlightedText";
3607
+ highlight?: [number, number] | undefined;
3608
+ } | {
3609
+ value: string;
3610
+ type: "ColorText";
3611
+ color: string;
3612
+ highlight?: [number, number] | undefined;
3613
+ } | {
3614
+ value: string;
3615
+ type: "BoldText";
3616
+ highlight?: [number, number] | undefined;
3617
+ } | {
3618
+ length: number;
3619
+ type: "InlineInput";
3620
+ inputType: "string";
3621
+ name: string;
3622
+ answer?: string | number | undefined;
3623
+ } | {
3624
+ type: "InlineInput";
3625
+ inputType: "numeric";
3626
+ name: string;
3627
+ digits: number;
3628
+ answer?: string | number | undefined;
3629
+ })[];
3630
+ colspan?: number | undefined;
3631
+ }>, "many">;
3632
+ }, "strip", z.ZodTypeAny, {
3633
+ type: "TableRow";
3634
+ cells: {
3635
+ type: "TableCell";
3636
+ inlines: ({
3637
+ value: string;
3638
+ type: "FreeText";
3639
+ } | {
3640
+ type: "Space";
3641
+ } | {
3642
+ value: string;
3643
+ type: "HighlightedText";
3644
+ highlight?: [number, number] | undefined;
3645
+ } | {
3646
+ value: string;
3647
+ type: "ColorText";
3648
+ color: string;
3649
+ highlight?: [number, number] | undefined;
3650
+ } | {
3651
+ value: string;
3652
+ type: "BoldText";
3653
+ highlight?: [number, number] | undefined;
3654
+ } | {
3655
+ length: number;
3656
+ type: "InlineInput";
3657
+ inputType: "string";
3658
+ name: string;
3659
+ answer?: string | number | undefined;
3660
+ } | {
3661
+ type: "InlineInput";
3662
+ inputType: "numeric";
3663
+ name: string;
3664
+ digits: number;
3665
+ answer?: string | number | undefined;
3666
+ })[];
3667
+ colspan?: number | undefined;
3668
+ }[];
3669
+ }, {
3670
+ type: "TableRow";
3671
+ cells: {
3672
+ type: "TableCell";
3673
+ inlines: ({
3674
+ value: string;
3675
+ type: "FreeText";
3676
+ } | {
3677
+ type: "Space";
3678
+ } | {
3679
+ value: string;
3680
+ type: "HighlightedText";
3681
+ highlight?: [number, number] | undefined;
3682
+ } | {
3683
+ value: string;
3684
+ type: "ColorText";
3685
+ color: string;
3686
+ highlight?: [number, number] | undefined;
3687
+ } | {
3688
+ value: string;
3689
+ type: "BoldText";
3690
+ highlight?: [number, number] | undefined;
3691
+ } | {
3692
+ length: number;
3693
+ type: "InlineInput";
3694
+ inputType: "string";
3695
+ name: string;
3696
+ answer?: string | number | undefined;
3697
+ } | {
3698
+ type: "InlineInput";
3699
+ inputType: "numeric";
3700
+ name: string;
3701
+ digits: number;
3702
+ answer?: string | number | undefined;
3703
+ })[];
3704
+ colspan?: number | undefined;
3705
+ }[];
1845
3706
  }>;
1846
3707
 
1847
3708
  export declare type TextBlock = z.infer<typeof TextBlockSchema>;
@@ -1885,7 +3746,7 @@ export declare const TextItemSchema: z.ZodObject<{
1885
3746
  /**
1886
3747
  * Transform CST to AST
1887
3748
  */
1888
- export declare function toAST(cst: any): ExerciseDocument;
3749
+ export declare function toAST(cst: CstNode): ExerciseDocument;
1889
3750
 
1890
3751
  /**
1891
3752
  * Transform AST to JSON