@keymanapp/kmc-model 17.0.155-alpha → 17.0.156-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/build/src/build-trie.d.ts +42 -40
  2. package/build/src/build-trie.d.ts.map +1 -1
  3. package/build/src/build-trie.js +370 -366
  4. package/build/src/build-trie.js.map +1 -1
  5. package/build/src/compiler-callbacks.d.ts +6 -4
  6. package/build/src/compiler-callbacks.d.ts.map +1 -1
  7. package/build/src/compiler-callbacks.js +7 -5
  8. package/build/src/compiler-callbacks.js.map +1 -1
  9. package/build/src/join-word-breaker-decorator.d.ts +12 -10
  10. package/build/src/join-word-breaker-decorator.d.ts.map +1 -1
  11. package/build/src/join-word-breaker-decorator.js +123 -121
  12. package/build/src/join-word-breaker-decorator.js.map +1 -1
  13. package/build/src/lexical-model-compiler.d.ts +19 -16
  14. package/build/src/lexical-model-compiler.d.ts.map +1 -1
  15. package/build/src/lexical-model-compiler.js +153 -150
  16. package/build/src/lexical-model-compiler.js.map +1 -1
  17. package/build/src/lexical-model.d.ts +137 -135
  18. package/build/src/lexical-model.d.ts.map +1 -1
  19. package/build/src/lexical-model.js +8 -6
  20. package/build/src/lexical-model.js.map +1 -1
  21. package/build/src/main.d.ts +19 -17
  22. package/build/src/main.d.ts.map +1 -1
  23. package/build/src/main.js +60 -60
  24. package/build/src/main.js.map +1 -1
  25. package/build/src/model-compiler-errors.d.ts +53 -51
  26. package/build/src/model-compiler-errors.d.ts.map +1 -1
  27. package/build/src/model-compiler-errors.js +58 -56
  28. package/build/src/model-compiler-errors.js.map +1 -1
  29. package/build/src/model-defaults.d.ts +58 -56
  30. package/build/src/model-defaults.d.ts.map +1 -1
  31. package/build/src/model-defaults.js +108 -106
  32. package/build/src/model-defaults.js.map +1 -1
  33. package/build/src/model-definitions.d.ts +73 -71
  34. package/build/src/model-definitions.d.ts.map +1 -1
  35. package/build/src/model-definitions.js +191 -189
  36. package/build/src/model-definitions.js.map +1 -1
  37. package/build/src/script-overrides-decorator.d.ts +6 -4
  38. package/build/src/script-overrides-decorator.d.ts.map +1 -1
  39. package/build/src/script-overrides-decorator.js +66 -64
  40. package/build/src/script-overrides-decorator.js.map +1 -1
  41. package/package.json +7 -7
@@ -1,106 +1,108 @@
1
- /**
2
- * Converts wordforms into an indexable form. It does this by
3
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
4
- * context-sensitive case transformations), normalizing to NFKD form,
5
- * and removing common diacritical marks.
6
- *
7
- * This is a very speculative implementation, that might work with
8
- * your language. We don't guarantee that this will be perfect for your
9
- * language, but it's a start.
10
- *
11
- * This uses String.prototype.normalize() to convert normalize into NFKD.
12
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
13
- * same character; plus, it's an easy way to separate a Latin character from
14
- * its diacritics; Even then, orthographies regularly use code points
15
- * that, under NFKD normalization, do NOT decompose appropriately for your
16
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
17
- *
18
- * Use this in early iterations of the model. For a production lexical model,
19
- * you will probably write/generate your own key function, tailored to your
20
- * language. There is a chance the default will work properly out of the box.
21
- */
22
- export function defaultSearchTermToKey(wordform) {
23
- return wordform
24
- .normalize('NFKD')
25
- // Remove any combining diacritics (if input is in NFKD)
26
- .replace(/[\u0300-\u036F]/g, '')
27
- // Replace directional quotation marks with plain apostrophes
28
- .replace(/‘/, "'")
29
- .replace(/’/, "'")
30
- // Also double-quote marks.
31
- .replace(/“/, '"')
32
- .replace(/”/, '"');
33
- }
34
- /**
35
- * Converts wordforms into an indexable form. It does this by
36
- * normalizing the letter case of characters INDIVIDUALLY (to disregard
37
- * context-sensitive case transformations), normalizing to NFKD form,
38
- * and removing common diacritical marks.
39
- *
40
- * This is a very speculative implementation, that might work with
41
- * your language. We don't guarantee that this will be perfect for your
42
- * language, but it's a start.
43
- *
44
- * This uses String.prototype.normalize() to convert normalize into NFKD.
45
- * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
46
- * same character; plus, it's an easy way to separate a Latin character from
47
- * its diacritics; Even then, orthographies regularly use code points
48
- * that, under NFKD normalization, do NOT decompose appropriately for your
49
- * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
50
- *
51
- * Use this in early iterations of the model. For a production lexical model,
52
- * you will probably write/generate your own key function, tailored to your
53
- * language. There is a chance the default will work properly out of the box.
54
- */
55
- export function defaultCasedSearchTermToKey(wordform, applyCasing) {
56
- // While this is a bit WET, as the basic `defaultSearchTermToKey` exists and performs some of
57
- // the same functions, repetition is the easiest way to allow the function to be safely compiled
58
- // with ease by use of `.toString()`.
59
- return Array.from(wordform
60
- .normalize('NFKD')
61
- // Remove any combining diacritics (if input is in NFKD)
62
- .replace(/[\u0300-\u036F]/g, '')) // end of `Array.from`
63
- .map(function (c) { return applyCasing('lower', c); })
64
- .join('')
65
- // Replace directional quotation marks with plain apostrophes
66
- .replace(/‘/, "'")
67
- .replace(/’/, "'")
68
- // Also double-quote marks.
69
- .replace(/“/, '"')
70
- .replace(/”/, '"');
71
- }
72
- /**
73
- * Specifies default casing behavior for lexical models when `languageUsesCasing` is
74
- * set to true.
75
- * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
76
- *
77
- * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
78
- * This may be overwritten as appropriate in model-specific implementations.
79
- * @param text The text to be modified.
80
- */
81
- export function defaultApplyCasing(casing, text) {
82
- switch (casing) {
83
- case 'lower':
84
- return text.toLowerCase();
85
- case 'upper':
86
- return text.toUpperCase();
87
- case 'initial':
88
- var headCode = text.charCodeAt(0);
89
- // The length of the first code unit, as measured in code points.
90
- var headUnitLength = 1;
91
- // Is the first character a high surrogate, indicating possible use of UTF-16
92
- // surrogate pairs? Also, is the string long enough for there to BE a pair?
93
- if (text.length > 1 && headCode >= 0xD800 && headCode <= 0xDBFF) {
94
- // It's possible, so now we check for low surrogates.
95
- var lowSurrogateCode = text.charCodeAt(1);
96
- if (lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF) {
97
- // We have a surrogate pair; this pair is the 'first' character.
98
- headUnitLength++;
99
- }
100
- }
101
- // Capitalizes the first code unit of the string, leaving the rest intact.
102
- return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
103
- .concat(text.substring(headUnitLength)); // tail - lowercased
104
- }
105
- }
106
- //# sourceMappingURL=model-defaults.js.map
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="61ea4f9f-b0d0-5f4c-b7bb-b818146e82c1")}catch(e){}}();
2
+ /**
3
+ * Converts wordforms into an indexable form. It does this by
4
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
5
+ * context-sensitive case transformations), normalizing to NFKD form,
6
+ * and removing common diacritical marks.
7
+ *
8
+ * This is a very speculative implementation, that might work with
9
+ * your language. We don't guarantee that this will be perfect for your
10
+ * language, but it's a start.
11
+ *
12
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
13
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
14
+ * same character; plus, it's an easy way to separate a Latin character from
15
+ * its diacritics; Even then, orthographies regularly use code points
16
+ * that, under NFKD normalization, do NOT decompose appropriately for your
17
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
18
+ *
19
+ * Use this in early iterations of the model. For a production lexical model,
20
+ * you will probably write/generate your own key function, tailored to your
21
+ * language. There is a chance the default will work properly out of the box.
22
+ */
23
+ export function defaultSearchTermToKey(wordform) {
24
+ return wordform
25
+ .normalize('NFKD')
26
+ // Remove any combining diacritics (if input is in NFKD)
27
+ .replace(/[\u0300-\u036F]/g, '')
28
+ // Replace directional quotation marks with plain apostrophes
29
+ .replace(/‘/, "'")
30
+ .replace(/’/, "'")
31
+ // Also double-quote marks.
32
+ .replace(/“/, '"')
33
+ .replace(/”/, '"');
34
+ }
35
+ /**
36
+ * Converts wordforms into an indexable form. It does this by
37
+ * normalizing the letter case of characters INDIVIDUALLY (to disregard
38
+ * context-sensitive case transformations), normalizing to NFKD form,
39
+ * and removing common diacritical marks.
40
+ *
41
+ * This is a very speculative implementation, that might work with
42
+ * your language. We don't guarantee that this will be perfect for your
43
+ * language, but it's a start.
44
+ *
45
+ * This uses String.prototype.normalize() to convert normalize into NFKD.
46
+ * NFKD neutralizes some funky distinctions, e.g., ꬲ, e, e should all be the
47
+ * same character; plus, it's an easy way to separate a Latin character from
48
+ * its diacritics; Even then, orthographies regularly use code points
49
+ * that, under NFKD normalization, do NOT decompose appropriately for your
50
+ * language (e.g., SENĆOŦEN, Plains Cree in syllabics).
51
+ *
52
+ * Use this in early iterations of the model. For a production lexical model,
53
+ * you will probably write/generate your own key function, tailored to your
54
+ * language. There is a chance the default will work properly out of the box.
55
+ */
56
+ export function defaultCasedSearchTermToKey(wordform, applyCasing) {
57
+ // While this is a bit WET, as the basic `defaultSearchTermToKey` exists and performs some of
58
+ // the same functions, repetition is the easiest way to allow the function to be safely compiled
59
+ // with ease by use of `.toString()`.
60
+ return Array.from(wordform
61
+ .normalize('NFKD')
62
+ // Remove any combining diacritics (if input is in NFKD)
63
+ .replace(/[\u0300-\u036F]/g, '')) // end of `Array.from`
64
+ .map(function (c) { return applyCasing('lower', c); })
65
+ .join('')
66
+ // Replace directional quotation marks with plain apostrophes
67
+ .replace(/‘/, "'")
68
+ .replace(/’/, "'")
69
+ // Also double-quote marks.
70
+ .replace(/“/, '"')
71
+ .replace(/”/, '"');
72
+ }
73
+ /**
74
+ * Specifies default casing behavior for lexical models when `languageUsesCasing` is
75
+ * set to true.
76
+ * @param casing One of 'lower' (lowercased), 'upper' (uppercased), or 'initial'.
77
+ *
78
+ * 'initial' is designed to cover cases like sentence-initial & proper noun capitalization in English.
79
+ * This may be overwritten as appropriate in model-specific implementations.
80
+ * @param text The text to be modified.
81
+ */
82
+ export function defaultApplyCasing(casing, text) {
83
+ switch (casing) {
84
+ case 'lower':
85
+ return text.toLowerCase();
86
+ case 'upper':
87
+ return text.toUpperCase();
88
+ case 'initial':
89
+ var headCode = text.charCodeAt(0);
90
+ // The length of the first code unit, as measured in code points.
91
+ var headUnitLength = 1;
92
+ // Is the first character a high surrogate, indicating possible use of UTF-16
93
+ // surrogate pairs? Also, is the string long enough for there to BE a pair?
94
+ if (text.length > 1 && headCode >= 0xD800 && headCode <= 0xDBFF) {
95
+ // It's possible, so now we check for low surrogates.
96
+ var lowSurrogateCode = text.charCodeAt(1);
97
+ if (lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF) {
98
+ // We have a surrogate pair; this pair is the 'first' character.
99
+ headUnitLength++;
100
+ }
101
+ }
102
+ // Capitalizes the first code unit of the string, leaving the rest intact.
103
+ return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
104
+ .concat(text.substring(headUnitLength)); // tail - lowercased
105
+ }
106
+ }
107
+ //# debugId=61ea4f9f-b0d0-5f4c-b7bb-b818146e82c1
108
+ //# sourceMappingURL=model-defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-defaults.js","sourceRoot":"","sources":["../../src/model-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,QAAQ;SACV,SAAS,CAAC,MAAM,CAAC;QAClB,wDAAwD;SACvD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChC,6DAA6D;SAC5D,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;QAClB,2BAA2B;SAC1B,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB,EAAE,WAA2B;IACv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G,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAkB,EAAE,IAAY;IACjE,QAAO,MAAM,EAAE;QACb,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5B,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5B,KAAK,SAAS;YACZ,IAAI,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAClC,iEAAiE;YACjE,IAAI,cAAc,GAAG,CAAC,CAAC;YAEvB,6EAA6E;YAC7E,4EAA4E;YAC5E,IAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE;gBAC9D,qDAAqD;gBACrD,IAAI,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBAE1C,IAAG,gBAAgB,IAAI,MAAM,IAAI,gBAAgB,IAAI,MAAM,EAAE;oBAC3D,gEAAgE;oBAChE,cAAc,EAAE,CAAC;iBAClB;aACF;YAED,0EAA0E;YAC1E,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC,oBAAoB;iBACnE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAQ,oBAAoB;KAC9E;AACH,CAAC","names":[],"sourceRoot":"","sources":["../../src/model-defaults.ts"],"version":3}
@@ -1,71 +1,73 @@
1
- /// <reference types="@keymanapp/models-types" />
2
- import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js";
3
- /**
4
- * Processes certain defined model behaviors in such a way that the needed closures
5
- * may be safely compiled to a JS file and loaded within the LMLayer.
6
- *
7
- * This is accomplished by writing out a 'pseudoclosure' within the model's IIFE,
8
- * then used to build _actual_ closures at LMLayer load time. This 'pseudoclosure'
9
- * will very closely match the organizational patterns of this class in order to
10
- * facilitate the maintenance of this approach.
11
- */
12
- export declare class ModelDefinitions {
13
- static readonly COMPILED_NAME = "definitions";
14
- /**
15
- * A closure fully implementing the model's defined `applyCasing` behavior with
16
- * the function parameter preset to the version-appropriate default.
17
- * `defaults.applyCasing` is captured as part of the closure.
18
- *
19
- * During compilation of some models (such as Trie-based wordlist templated models),
20
- * this closure will be directly used as part of searchTermToKey.
21
- *
22
- * In compiled code, this will instead be defined in-line as an autogenerated closure
23
- * using the other properties of the pseudoclosure.
24
- */
25
- applyCasing?: CasingFunction;
26
- /**
27
- * A closure fully implementing the model's defined `searchTermToKey` behavior
28
- * based upon the model's specified casing rules. The `applyCasing` closure is
29
- * itself captured within this closure.
30
- *
31
- * During compilation of some models (such as Trie-based wordlist templated models),
32
- * this closure will be directly utilized when compiling the lexicon.
33
- *
34
- * In compiled code, this will instead be defined in-line as an autogenerated closure
35
- * using the other properties of the pseudoclosure.
36
- */
37
- searchTermToKey?: WordformToKeySpec;
38
- /**
39
- * Contains embedded 'default' implementations that may be needed for
40
- * closures in the compiled version, annotated with the current version
41
- * of Developer.
42
- */
43
- private defaults;
44
- /**
45
- * Contains the model-specific definitions specified in the model's source.
46
- *
47
- * These definitions may expect `defaults.applyCasing` as a parameter in
48
- * their final closures.
49
- */
50
- private model;
51
- constructor(modelSource: LexicalModelSource);
52
- /**
53
- * Writes out a compiled JS version of the pseudoclosure, preserving all function
54
- * implementations.
55
- *
56
- * This should be written to the file within the same IIFE as the model but BEFORE
57
- * the model itself, as the model will need to refer to the definitions herein.
58
- */
59
- compileDefinitions(): string;
60
- /**
61
- * Compiles the model-options entry for `searchTermToKey` in reference to the
62
- * compiled pseudoclosure.
63
- */
64
- compileSearchTermToKey(): string;
65
- /**
66
- * Compiles the model-options entry for `applyCasing` in reference to the
67
- * compiled pseudoclosure.
68
- */
69
- compileApplyCasing(): string;
70
- }
71
- //# sourceMappingURL=model-definitions.d.ts.map
1
+ /// <reference types="@keymanapp/models-types" />
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="da50a2a7-71d5-57a0-9a0c-c905d304ad11")}catch(e){}}();
3
+ import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js";
4
+ /**
5
+ * Processes certain defined model behaviors in such a way that the needed closures
6
+ * may be safely compiled to a JS file and loaded within the LMLayer.
7
+ *
8
+ * This is accomplished by writing out a 'pseudoclosure' within the model's IIFE,
9
+ * then used to build _actual_ closures at LMLayer load time. This 'pseudoclosure'
10
+ * will very closely match the organizational patterns of this class in order to
11
+ * facilitate the maintenance of this approach.
12
+ */
13
+ export declare class ModelDefinitions {
14
+ static readonly COMPILED_NAME = "definitions";
15
+ /**
16
+ * A closure fully implementing the model's defined `applyCasing` behavior with
17
+ * the function parameter preset to the version-appropriate default.
18
+ * `defaults.applyCasing` is captured as part of the closure.
19
+ *
20
+ * During compilation of some models (such as Trie-based wordlist templated models),
21
+ * this closure will be directly used as part of searchTermToKey.
22
+ *
23
+ * In compiled code, this will instead be defined in-line as an autogenerated closure
24
+ * using the other properties of the pseudoclosure.
25
+ */
26
+ applyCasing?: CasingFunction;
27
+ /**
28
+ * A closure fully implementing the model's defined `searchTermToKey` behavior
29
+ * based upon the model's specified casing rules. The `applyCasing` closure is
30
+ * itself captured within this closure.
31
+ *
32
+ * During compilation of some models (such as Trie-based wordlist templated models),
33
+ * this closure will be directly utilized when compiling the lexicon.
34
+ *
35
+ * In compiled code, this will instead be defined in-line as an autogenerated closure
36
+ * using the other properties of the pseudoclosure.
37
+ */
38
+ searchTermToKey?: WordformToKeySpec;
39
+ /**
40
+ * Contains embedded 'default' implementations that may be needed for
41
+ * closures in the compiled version, annotated with the current version
42
+ * of Developer.
43
+ */
44
+ private defaults;
45
+ /**
46
+ * Contains the model-specific definitions specified in the model's source.
47
+ *
48
+ * These definitions may expect `defaults.applyCasing` as a parameter in
49
+ * their final closures.
50
+ */
51
+ private model;
52
+ constructor(modelSource: LexicalModelSource);
53
+ /**
54
+ * Writes out a compiled JS version of the pseudoclosure, preserving all function
55
+ * implementations.
56
+ *
57
+ * This should be written to the file within the same IIFE as the model but BEFORE
58
+ * the model itself, as the model will need to refer to the definitions herein.
59
+ */
60
+ compileDefinitions(): string;
61
+ /**
62
+ * Compiles the model-options entry for `searchTermToKey` in reference to the
63
+ * compiled pseudoclosure.
64
+ */
65
+ compileSearchTermToKey(): string;
66
+ /**
67
+ * Compiles the model-options entry for `applyCasing` in reference to the
68
+ * compiled pseudoclosure.
69
+ */
70
+ compileApplyCasing(): string;
71
+ }
72
+ //# debugId=da50a2a7-71d5-57a0-9a0c-c905d304ad11
73
+ //# sourceMappingURL=model-definitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-definitions.d.ts","sourceRoot":"","sources":["../../src/model-definitions.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,aAAa,iBAAiB;IAC9C;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;IAEpC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAKd;IAEF;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAGN;gBAEK,WAAW,EAAE,kBAAkB;IAsD3C;;;;;;OAMG;IACH,kBAAkB,IAAI,MAAM;IAuE5B;;;OAGG;IACH,sBAAsB,IAAI,MAAM;IAMhC;;;OAGG;IACH,kBAAkB,IAAI,MAAM;CAI7B"}
1
+ {"debug_id":"da50a2a7-71d5-57a0-9a0c-c905d304ad11","file":"model-definitions.d.ts","mappings":";;AAMA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,aAAa,iBAAiB;IAC9C;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;IAEpC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAKd;IAEF;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAGN;gBAEK,WAAW,EAAE,kBAAkB;IAsD3C;;;;;;OAMG;IACH,kBAAkB,IAAI,MAAM;IAuE5B;;;OAGG;IACH,sBAAsB,IAAI,MAAM;IAMhC;;;OAGG;IACH,kBAAkB,IAAI,MAAM;CAI7B","names":[],"sourceRoot":"","sources":["../../src/model-definitions.ts"],"version":3}