@pie-element/select-text 6.5.2 → 6.5.3-next.1016

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.
@@ -1,3242 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_lodash, _dll_pie_lib__render_ui, _dll_react_dom_server, _dll_react_dom} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- import {_dll_pie_lib__config_ui, _dll_pie_lib__editable_html, _dll_pie_framework__pie_configure_events} from "../../shared-config@^1.8.13/module/index.js";
3
- const React = _dll_react;
4
- const PropTypes = _dll_prop_types;
5
- const {Button: Button} = _dll_material_ui__core;
6
- const {Switch: Switch} = _dll_material_ui__core;
7
- const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
8
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
9
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/controls.jsx";
10
- class Controls extends React.Component {
11
- static __initStatic() {
12
- this.propTypes = {
13
- classes: PropTypes.object.isRequired,
14
- onClear: PropTypes.func.isRequired,
15
- onWords: PropTypes.func.isRequired,
16
- onSentences: PropTypes.func.isRequired,
17
- onParagraphs: PropTypes.func.isRequired,
18
- setCorrectMode: PropTypes.bool.isRequired,
19
- onToggleCorrectMode: PropTypes.func.isRequired
20
- };
21
- }
22
- static __initStatic2() {
23
- this.defaultProps = {};
24
- }
25
- render() {
26
- const {classes, onClear, onWords, onSentences, onParagraphs, setCorrectMode, onToggleCorrectMode} = this.props;
27
- return React.createElement('div', {
28
- className: classes.controls,
29
- __self: this,
30
- __source: {
31
- fileName: _jsxFileName,
32
- lineNumber: 33
33
- }
34
- }, React.createElement('div', {
35
- __self: this,
36
- __source: {
37
- fileName: _jsxFileName,
38
- lineNumber: 34
39
- }
40
- }, React.createElement(Button, {
41
- onClick: onWords,
42
- className: classes.button,
43
- size: "small",
44
- color: "primary",
45
- disabled: setCorrectMode,
46
- __self: this,
47
- __source: {
48
- fileName: _jsxFileName,
49
- lineNumber: 35
50
- }
51
- }, "Words"), React.createElement(Button, {
52
- onClick: onSentences,
53
- className: classes.button,
54
- size: "small",
55
- color: "primary",
56
- disabled: setCorrectMode,
57
- __self: this,
58
- __source: {
59
- fileName: _jsxFileName,
60
- lineNumber: 44
61
- }
62
- }, "Sentences"), React.createElement(Button, {
63
- onClick: onParagraphs,
64
- className: classes.button,
65
- size: "small",
66
- color: "primary",
67
- disabled: setCorrectMode,
68
- __self: this,
69
- __source: {
70
- fileName: _jsxFileName,
71
- lineNumber: 53
72
- }
73
- }, "Paragraphs"), React.createElement(Button, {
74
- className: classes.button,
75
- size: "small",
76
- color: "secondary",
77
- onClick: onClear,
78
- disabled: setCorrectMode,
79
- __self: this,
80
- __source: {
81
- fileName: _jsxFileName,
82
- lineNumber: 62
83
- }
84
- }, "Clear")), React.createElement(FormControlLabel, {
85
- control: React.createElement(Switch, {
86
- checked: setCorrectMode,
87
- onChange: onToggleCorrectMode,
88
- __self: this,
89
- __source: {
90
- fileName: _jsxFileName,
91
- lineNumber: 73
92
- }
93
- }),
94
- label: "Set correct answers",
95
- __self: this,
96
- __source: {
97
- fileName: _jsxFileName,
98
- lineNumber: 72
99
- }
100
- }));
101
- }
102
- }
103
- Controls.__initStatic();
104
- Controls.__initStatic2();
105
- var Controls$1 = withStyles(theme => ({
106
- button: {
107
- marginRight: theme.spacing.unit
108
- },
109
- controls: {
110
- display: 'flex',
111
- alignItems: 'center',
112
- justifyContent: 'space-between'
113
- }
114
- }))(Controls);
115
- var nlcstToString_1 = nlcstToString;
116
- function nlcstToString(node, separator) {
117
- var sep = separator || '';
118
- var values;
119
- var length;
120
- var children;
121
- if (!node || !(('length' in node)) && !node.type) {
122
- throw new Error('Expected node, not `' + node + '`');
123
- }
124
- if (typeof node.value === 'string') {
125
- return node.value;
126
- }
127
- children = ('length' in node) ? node : node.children;
128
- length = children.length;
129
- if (length === 1 && ('value' in children[0])) {
130
- return children[0].value;
131
- }
132
- values = [];
133
- while (length--) {
134
- values[length] = nlcstToString(children[length], sep);
135
- }
136
- return values.join(sep);
137
- }
138
- var unistUtilVisitChildren = visitChildren;
139
- function visitChildren(callback) {
140
- return visitor;
141
- function visitor(parent) {
142
- var index = -1;
143
- var children = parent && parent.children;
144
- if (!children) {
145
- throw new Error('Missing children in `parent` for `visitor`');
146
- }
147
- while ((++index in children)) {
148
- callback(children[index], index, parent);
149
- }
150
- }
151
- }
152
- var arrayIterate = iterate;
153
- var own = ({}).hasOwnProperty;
154
- function iterate(values, callback, context) {
155
- var index = -1;
156
- var result;
157
- if (!values) {
158
- throw new Error('Iterate requires that |this| not be ' + values);
159
- }
160
- if (!own.call(values, 'length')) {
161
- throw new Error('Iterate requires that |this| has a `length`');
162
- }
163
- if (typeof callback !== 'function') {
164
- throw new Error('`callback` must be a function');
165
- }
166
- while (++index < values.length) {
167
- if (!((index in values))) {
168
- continue;
169
- }
170
- result = callback.call(context, values[index], index, values);
171
- if (typeof result === 'number') {
172
- if (result < 0) {
173
- index = 0;
174
- }
175
- index = result - 1;
176
- }
177
- }
178
- }
179
- var unistUtilModifyChildren = modifierFactory;
180
- function modifierFactory(callback) {
181
- return iteratorFactory(wrapperFactory(callback));
182
- }
183
- function iteratorFactory(callback) {
184
- return iterator;
185
- function iterator(parent) {
186
- var children = parent && parent.children;
187
- if (!children) {
188
- throw new Error('Missing children in `parent` for `modifier`');
189
- }
190
- return arrayIterate(children, callback, parent);
191
- }
192
- }
193
- function wrapperFactory(callback) {
194
- return wrapper;
195
- function wrapper(value, index) {
196
- return callback(value, index, this);
197
- }
198
- }
199
- var tokenizer = tokenizerFactory;
200
- function tokenizerFactory(childType, expression) {
201
- return tokenizer;
202
- function tokenizer(node) {
203
- var children = [];
204
- var tokens = node.children;
205
- var type = node.type;
206
- var length = tokens.length;
207
- var index = -1;
208
- var lastIndex = length - 1;
209
- var start = 0;
210
- var first;
211
- var last;
212
- var parent;
213
- while (++index < length) {
214
- if (index === lastIndex || tokens[index].type === childType && expression.test(nlcstToString_1(tokens[index]))) {
215
- first = tokens[start];
216
- last = tokens[index];
217
- parent = {
218
- type: type,
219
- children: tokens.slice(start, index + 1)
220
- };
221
- if (first.position && last.position) {
222
- parent.position = {
223
- start: first.position.start,
224
- end: last.position.end
225
- };
226
- }
227
- children.push(parent);
228
- start = index + 1;
229
- }
230
- }
231
- return children;
232
- }
233
- }
234
- var parser = parserFactory;
235
- function parserFactory(options) {
236
- var type = options.type;
237
- var tokenizerProperty = options.tokenizer;
238
- var delimiter = options.delimiter;
239
- var tokenize = delimiter && tokenizer(options.delimiterType, delimiter);
240
- return parser;
241
- function parser(value) {
242
- var children = this[tokenizerProperty](value);
243
- return {
244
- type: type,
245
- children: tokenize ? tokenize(children) : children
246
- };
247
- }
248
- }
249
- var expressions = {
250
- affixSymbol: /^([!"').?\u0F3B\u0F3D\u169C\u2019\u201D\u2026\u203A\u203D\u2046\u207E\u208E\u2309\u230B\u232A\u2769\u276B\u276D\u276F\u2771\u2773\u2775\u27C6\u27E7\u27E9\u27EB\u27ED\u27EF\u2984\u2986\u2988\u298A\u298C\u298E\u2990\u2992\u2994\u2996\u2998\u29D9\u29DB\u29FD\u2E03\u2E05\u2E0A\u2E0D\u2E1D\u2E21\u2E23\u2E25\u2E27\u2E29\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u301E\u301F\uFD3E\uFE18\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE48\uFE5A\uFE5C\uFE5E\uFF09\uFF3D\uFF5D\uFF60\uFF63\xBB\]}])\1*$/,
251
- newLine: /^[ \t]*((\r?\n|\r)[\t ]*)+$/,
252
- newLineMulti: /^[ \t]*((\r?\n|\r)[\t ]*){2,}$/,
253
- terminalMarker: /^([!.?\u2026\u203D]+)$/,
254
- wordSymbolInner: /^([&'\-.:=?@\xAD\xB7\u2010\u2011\u2019\u2027]|_+)$/,
255
- numerical: /^(?:[\d\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])+$/,
256
- digitStart: /^\d/,
257
- lowerInitial: /^(?:[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0560-\u0588\u10D0-\u10FA\u10FD-\u10FF\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7AF\uA7B5\uA7B7\uA7B9\uA7BB\uA7BD\uA7BF\uA7C3\uA7C8\uA7CA\uA7F6\uA7FA\uAB30-\uAB5A\uAB60-\uAB68\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]|\uD801[\uDC28-\uDC4F\uDCD8-\uDCFB]|\uD803[\uDCC0-\uDCF2]|\uD806[\uDCC0-\uDCDF]|\uD81B[\uDE60-\uDE7F]|\uD835[\uDC1A-\uDC33\uDC4E-\uDC54\uDC56-\uDC67\uDC82-\uDC9B\uDCB6-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDCEA-\uDD03\uDD1E-\uDD37\uDD52-\uDD6B\uDD86-\uDD9F\uDDBA-\uDDD3\uDDEE-\uDE07\uDE22-\uDE3B\uDE56-\uDE6F\uDE8A-\uDEA5\uDEC2-\uDEDA\uDEDC-\uDEE1\uDEFC-\uDF14\uDF16-\uDF1B\uDF36-\uDF4E\uDF50-\uDF55\uDF70-\uDF88\uDF8A-\uDF8F\uDFAA-\uDFC2\uDFC4-\uDFC9\uDFCB]|\uD83A[\uDD22-\uDD43])/,
258
- surrogates: /[\uD800-\uDFFF]/,
259
- punctuation: /[!"'-),-/:;?[-\]_{}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u201F\u2022-\u2027\u2032-\u203A\u203C-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDFFF]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,
260
- word: /[\dA-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE6\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC52-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF]/,
261
- whiteSpace: /[\t-\r \x85\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
262
- };
263
- var unistUtilModifyChildren$1 = modifierFactory$1;
264
- function modifierFactory$1(callback) {
265
- return iteratorFactory$1(wrapperFactory$1(callback));
266
- }
267
- function iteratorFactory$1(callback) {
268
- return iterator;
269
- function iterator(parent) {
270
- var children = parent && parent.children;
271
- if (!children) {
272
- throw new Error('Missing children in `parent` for `modifier`');
273
- }
274
- arrayIterate(children, callback, parent);
275
- }
276
- }
277
- function wrapperFactory$1(callback) {
278
- return wrapper;
279
- function wrapper(value, index) {
280
- return callback(value, index, this);
281
- }
282
- }
283
- var mergeInitialWordSymbol_1 = unistUtilModifyChildren$1(mergeInitialWordSymbol);
284
- function mergeInitialWordSymbol(child, index, parent) {
285
- var children;
286
- var next;
287
- if (child.type !== 'SymbolNode' && child.type !== 'PunctuationNode' || nlcstToString_1(child) !== '&') {
288
- return;
289
- }
290
- children = parent.children;
291
- next = children[index + 1];
292
- if (index !== 0 && children[index - 1].type === 'WordNode' || !(next && next.type === 'WordNode')) {
293
- return;
294
- }
295
- children.splice(index, 1);
296
- next.children.unshift(child);
297
- if (next.position && child.position) {
298
- next.position.start = child.position.start;
299
- }
300
- return index - 1;
301
- }
302
- var mergeFinalWordSymbol_1 = unistUtilModifyChildren$1(mergeFinalWordSymbol);
303
- function mergeFinalWordSymbol(child, index, parent) {
304
- var children;
305
- var previous;
306
- var next;
307
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && nlcstToString_1(child) === '-') {
308
- children = parent.children;
309
- previous = children[index - 1];
310
- next = children[index + 1];
311
- if ((!next || next.type !== 'WordNode') && previous && previous.type === 'WordNode') {
312
- children.splice(index, 1);
313
- previous.children.push(child);
314
- if (previous.position && child.position) {
315
- previous.position.end = child.position.end;
316
- }
317
- return index;
318
- }
319
- }
320
- }
321
- var mergeInnerWordSymbol_1 = unistUtilModifyChildren$1(mergeInnerWordSymbol);
322
- var wordSymbolInner = expressions.wordSymbolInner;
323
- function mergeInnerWordSymbol(child, index, parent) {
324
- var siblings;
325
- var sibling;
326
- var previous;
327
- var last;
328
- var position;
329
- var tokens;
330
- var queue;
331
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode')) {
332
- siblings = parent.children;
333
- previous = siblings[index - 1];
334
- if (previous && previous.type === 'WordNode') {
335
- position = index - 1;
336
- tokens = [];
337
- queue = [];
338
- while (siblings[++position]) {
339
- sibling = siblings[position];
340
- if (sibling.type === 'WordNode') {
341
- tokens = tokens.concat(queue, sibling.children);
342
- queue = [];
343
- } else if ((sibling.type === 'SymbolNode' || sibling.type === 'PunctuationNode') && wordSymbolInner.test(nlcstToString_1(sibling))) {
344
- queue.push(sibling);
345
- } else {
346
- break;
347
- }
348
- }
349
- if (tokens.length !== 0) {
350
- if (queue.length !== 0) {
351
- position -= queue.length;
352
- }
353
- siblings.splice(index, position - index);
354
- previous.children = previous.children.concat(tokens);
355
- last = tokens[tokens.length - 1];
356
- if (previous.position && last.position) {
357
- previous.position.end = last.position.end;
358
- }
359
- return index;
360
- }
361
- }
362
- }
363
- }
364
- var mergeInnerWordSlash_1 = unistUtilModifyChildren$1(mergeInnerWordSlash);
365
- var slash = '/';
366
- function mergeInnerWordSlash(child, index, parent) {
367
- var siblings = parent.children;
368
- var previous;
369
- var next;
370
- var previousValue;
371
- var nextValue;
372
- var queue;
373
- var tail;
374
- var count;
375
- previous = siblings[index - 1];
376
- next = siblings[index + 1];
377
- if (previous && previous.type === 'WordNode' && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && nlcstToString_1(child) === slash) {
378
- previousValue = nlcstToString_1(previous);
379
- tail = child;
380
- queue = [child];
381
- count = 1;
382
- if (next && next.type === 'WordNode') {
383
- nextValue = nlcstToString_1(next);
384
- tail = next;
385
- queue = queue.concat(next.children);
386
- count++;
387
- }
388
- if (previousValue.length < 3 && (!nextValue || nextValue.length < 3)) {
389
- previous.children = previous.children.concat(queue);
390
- siblings.splice(index, count);
391
- if (previous.position && tail.position) {
392
- previous.position.end = tail.position.end;
393
- }
394
- return index;
395
- }
396
- }
397
- }
398
- var mergeInitialisms_1 = unistUtilModifyChildren$1(mergeInitialisms);
399
- var numerical = expressions.numerical;
400
- function mergeInitialisms(child, index, parent) {
401
- var siblings;
402
- var previous;
403
- var children;
404
- var length;
405
- var position;
406
- var otherChild;
407
- var isAllDigits;
408
- var value;
409
- if (index !== 0 && nlcstToString_1(child) === '.') {
410
- siblings = parent.children;
411
- previous = siblings[index - 1];
412
- children = previous.children;
413
- length = children && children.length;
414
- if (previous.type === 'WordNode' && length !== 1 && length % 2 !== 0) {
415
- position = length;
416
- isAllDigits = true;
417
- while (children[--position]) {
418
- otherChild = children[position];
419
- value = nlcstToString_1(otherChild);
420
- if (position % 2 === 0) {
421
- if (value.length > 1) {
422
- return;
423
- }
424
- if (!numerical.test(value)) {
425
- isAllDigits = false;
426
- }
427
- } else if (value !== '.') {
428
- if (position < length - 2) {
429
- break;
430
- } else {
431
- return;
432
- }
433
- }
434
- }
435
- if (!isAllDigits) {
436
- siblings.splice(index, 1);
437
- children.push(child);
438
- if (previous.position && child.position) {
439
- previous.position.end = child.position.end;
440
- }
441
- return index;
442
- }
443
- }
444
- }
445
- }
446
- var mergeWords = unistUtilModifyChildren$1(mergeFinalWordSymbol$1);
447
- function mergeFinalWordSymbol$1(child, index, parent) {
448
- var siblings = parent.children;
449
- var next;
450
- if (child.type === 'WordNode') {
451
- next = siblings[index + 1];
452
- if (next && next.type === 'WordNode') {
453
- siblings.splice(index + 1, 1);
454
- child.children = child.children.concat(next.children);
455
- if (next.position && child.position) {
456
- child.position.end = next.position.end;
457
- }
458
- return index;
459
- }
460
- }
461
- }
462
- var patchPosition_1 = unistUtilVisitChildren(patchPosition);
463
- function patchPosition(child, index, node) {
464
- var siblings = node.children;
465
- if (!child.position) {
466
- return;
467
- }
468
- if (index === 0 && (!node.position || !node.position.start)) {
469
- patch(node);
470
- node.position.start = child.position.start;
471
- }
472
- if (index === siblings.length - 1 && (!node.position || !node.position.end)) {
473
- patch(node);
474
- node.position.end = child.position.end;
475
- }
476
- }
477
- function patch(node) {
478
- if (!node.position) {
479
- node.position = {};
480
- }
481
- }
482
- var mergeNonWordSentences_1 = unistUtilModifyChildren$1(mergeNonWordSentences);
483
- function mergeNonWordSentences(child, index, parent) {
484
- var children = child.children;
485
- var position = -1;
486
- var previous;
487
- var next;
488
- while (children[++position]) {
489
- if (children[position].type === 'WordNode') {
490
- return;
491
- }
492
- }
493
- previous = parent.children[index - 1];
494
- if (previous) {
495
- previous.children = previous.children.concat(children);
496
- parent.children.splice(index, 1);
497
- if (previous.position && child.position) {
498
- previous.position.end = child.position.end;
499
- }
500
- return index;
501
- }
502
- next = parent.children[index + 1];
503
- if (next) {
504
- next.children = children.concat(next.children);
505
- if (next.position && child.position) {
506
- next.position.start = child.position.start;
507
- }
508
- parent.children.splice(index, 1);
509
- }
510
- }
511
- var mergeAffixSymbol_1 = unistUtilModifyChildren$1(mergeAffixSymbol);
512
- var affixSymbol = expressions.affixSymbol;
513
- function mergeAffixSymbol(child, index, parent) {
514
- var children = child.children;
515
- var first;
516
- var second;
517
- var previous;
518
- if (children && children.length !== 0 && index !== 0) {
519
- first = children[0];
520
- second = children[1];
521
- previous = parent.children[index - 1];
522
- if ((first.type === 'SymbolNode' || first.type === 'PunctuationNode') && affixSymbol.test(nlcstToString_1(first))) {
523
- previous.children.push(children.shift());
524
- if (first.position && previous.position) {
525
- previous.position.end = first.position.end;
526
- }
527
- if (second && second.position && child.position) {
528
- child.position.start = second.position.start;
529
- }
530
- return index - 1;
531
- }
532
- }
533
- }
534
- var mergeInitialLowerCaseLetterSentences_1 = unistUtilModifyChildren$1(mergeInitialLowerCaseLetterSentences);
535
- var lowerInitial = expressions.lowerInitial;
536
- function mergeInitialLowerCaseLetterSentences(child, index, parent) {
537
- var children = child.children;
538
- var position;
539
- var node;
540
- var siblings;
541
- var previous;
542
- if (children && children.length !== 0 && index !== 0) {
543
- position = -1;
544
- while (children[++position]) {
545
- node = children[position];
546
- if (node.type === 'WordNode') {
547
- if (!lowerInitial.test(nlcstToString_1(node))) {
548
- return;
549
- }
550
- siblings = parent.children;
551
- previous = siblings[index - 1];
552
- previous.children = previous.children.concat(children);
553
- siblings.splice(index, 1);
554
- if (previous.position && child.position) {
555
- previous.position.end = child.position.end;
556
- }
557
- return index;
558
- }
559
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
560
- return;
561
- }
562
- }
563
- }
564
- }
565
- var mergeInitialDigitSentences_1 = unistUtilModifyChildren$1(mergeInitialDigitSentences);
566
- var digit = expressions.digitStart;
567
- function mergeInitialDigitSentences(child, index, parent) {
568
- var children = child.children;
569
- var siblings = parent.children;
570
- var previous = siblings[index - 1];
571
- var head = children[0];
572
- if (previous && head && head.type === 'WordNode' && digit.test(nlcstToString_1(head))) {
573
- previous.children = previous.children.concat(children);
574
- siblings.splice(index, 1);
575
- if (previous.position && child.position) {
576
- previous.position.end = child.position.end;
577
- }
578
- return index;
579
- }
580
- }
581
- var mergePrefixExceptions_1 = unistUtilModifyChildren$1(mergePrefixExceptions);
582
- var abbreviationPrefix = new RegExp('^(' + '[0-9]{1,3}|' + '[a-z]|' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + ')$');
583
- function mergePrefixExceptions(child, index, parent) {
584
- var children = child.children;
585
- var period;
586
- var node;
587
- var next;
588
- if (children && children.length > 1) {
589
- period = children[children.length - 1];
590
- if (period && nlcstToString_1(period) === '.') {
591
- node = children[children.length - 2];
592
- if (node && node.type === 'WordNode' && abbreviationPrefix.test(nlcstToString_1(node).toLowerCase())) {
593
- node.children.push(period);
594
- children.pop();
595
- if (period.position && node.position) {
596
- node.position.end = period.position.end;
597
- }
598
- next = parent.children[index + 1];
599
- if (next) {
600
- child.children = children.concat(next.children);
601
- parent.children.splice(index + 1, 1);
602
- if (next.position && child.position) {
603
- child.position.end = next.position.end;
604
- }
605
- return index - 1;
606
- }
607
- }
608
- }
609
- }
610
- }
611
- var mergeAffixExceptions_1 = unistUtilModifyChildren$1(mergeAffixExceptions);
612
- function mergeAffixExceptions(child, index, parent) {
613
- var children = child.children;
614
- var node;
615
- var position;
616
- var value;
617
- var previousChild;
618
- if (!children || children.length === 0 || index === 0) {
619
- return;
620
- }
621
- position = -1;
622
- while (children[++position]) {
623
- node = children[position];
624
- if (node.type === 'WordNode') {
625
- return;
626
- }
627
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
628
- value = nlcstToString_1(node);
629
- if (value !== ',' && value !== ';') {
630
- return;
631
- }
632
- previousChild = parent.children[index - 1];
633
- previousChild.children = previousChild.children.concat(children);
634
- if (previousChild.position && child.position) {
635
- previousChild.position.end = child.position.end;
636
- }
637
- parent.children.splice(index, 1);
638
- return index;
639
- }
640
- }
641
- }
642
- var mergeRemainingFullStops_1 = unistUtilVisitChildren(mergeRemainingFullStops);
643
- var terminalMarker = expressions.terminalMarker;
644
- function mergeRemainingFullStops(child) {
645
- var children = child.children;
646
- var position = children.length;
647
- var hasFoundDelimiter = false;
648
- var grandchild;
649
- var previous;
650
- var next;
651
- var nextNext;
652
- while (children[--position]) {
653
- grandchild = children[position];
654
- if (grandchild.type !== 'SymbolNode' && grandchild.type !== 'PunctuationNode') {
655
- if (grandchild.type === 'WordNode') {
656
- hasFoundDelimiter = true;
657
- }
658
- continue;
659
- }
660
- if (!terminalMarker.test(nlcstToString_1(grandchild))) {
661
- continue;
662
- }
663
- if (!hasFoundDelimiter) {
664
- hasFoundDelimiter = true;
665
- continue;
666
- }
667
- if (nlcstToString_1(grandchild) !== '.') {
668
- continue;
669
- }
670
- previous = children[position - 1];
671
- next = children[position + 1];
672
- if (previous && previous.type === 'WordNode') {
673
- nextNext = children[position + 2];
674
- if (next && nextNext && next.type === 'WhiteSpaceNode' && nlcstToString_1(nextNext) === '.') {
675
- continue;
676
- }
677
- children.splice(position, 1);
678
- previous.children.push(grandchild);
679
- if (grandchild.position && previous.position) {
680
- previous.position.end = grandchild.position.end;
681
- }
682
- position--;
683
- } else if (next && next.type === 'WordNode') {
684
- children.splice(position, 1);
685
- next.children.unshift(grandchild);
686
- if (grandchild.position && next.position) {
687
- next.position.start = grandchild.position.start;
688
- }
689
- }
690
- }
691
- }
692
- var makeInitialWhiteSpaceSiblings_1 = unistUtilVisitChildren(makeInitialWhiteSpaceSiblings);
693
- function makeInitialWhiteSpaceSiblings(child, index, parent) {
694
- var children = child.children;
695
- var next;
696
- if (children && children.length !== 0 && children[0].type === 'WhiteSpaceNode') {
697
- parent.children.splice(index, 0, children.shift());
698
- next = children[0];
699
- if (next && next.position && child.position) {
700
- child.position.start = next.position.start;
701
- }
702
- }
703
- }
704
- var makeFinalWhiteSpaceSiblings_1 = unistUtilModifyChildren$1(makeFinalWhiteSpaceSiblings);
705
- function makeFinalWhiteSpaceSiblings(child, index, parent) {
706
- var children = child.children;
707
- var previous;
708
- if (children && children.length !== 0 && children[children.length - 1].type === 'WhiteSpaceNode') {
709
- parent.children.splice(index + 1, 0, child.children.pop());
710
- previous = children[children.length - 1];
711
- if (previous && previous.position && child.position) {
712
- child.position.end = previous.position.end;
713
- }
714
- return index;
715
- }
716
- }
717
- var breakImplicitSentences_1 = unistUtilModifyChildren$1(breakImplicitSentences);
718
- var multiNewLine = expressions.newLineMulti;
719
- function breakImplicitSentences(child, index, parent) {
720
- var children;
721
- var position;
722
- var length;
723
- var tail;
724
- var head;
725
- var end;
726
- var insertion;
727
- var node;
728
- if (child.type !== 'SentenceNode') {
729
- return;
730
- }
731
- children = child.children;
732
- length = children.length - 1;
733
- position = 0;
734
- while (++position < length) {
735
- node = children[position];
736
- if (node.type !== 'WhiteSpaceNode' || !multiNewLine.test(nlcstToString_1(node))) {
737
- continue;
738
- }
739
- child.children = children.slice(0, position);
740
- insertion = {
741
- type: 'SentenceNode',
742
- children: children.slice(position + 1)
743
- };
744
- tail = children[position - 1];
745
- head = children[position + 1];
746
- parent.children.splice(index + 1, 0, node, insertion);
747
- if (child.position && tail.position && head.position) {
748
- end = child.position.end;
749
- child.position.end = tail.position.end;
750
- insertion.position = {
751
- start: head.position.start,
752
- end: end
753
- };
754
- }
755
- return index + 1;
756
- }
757
- }
758
- var removeEmptyNodes_1 = unistUtilModifyChildren$1(removeEmptyNodes);
759
- function removeEmptyNodes(child, index, parent) {
760
- if (('children' in child) && child.children.length === 0) {
761
- parent.children.splice(index, 1);
762
- return index;
763
- }
764
- }
765
- var lib = ParseLatin;
766
- function ParseLatin(doc, file) {
767
- var value = file || doc;
768
- if (!(this instanceof ParseLatin)) {
769
- return new ParseLatin(doc, file);
770
- }
771
- this.doc = value ? String(value) : null;
772
- }
773
- var proto = ParseLatin.prototype;
774
- proto.position = true;
775
- proto.tokenizeSymbol = createTextFactory('Symbol');
776
- proto.tokenizeWhiteSpace = createTextFactory('WhiteSpace');
777
- proto.tokenizePunctuation = createTextFactory('Punctuation');
778
- proto.tokenizeSource = createTextFactory('Source');
779
- proto.tokenizeText = createTextFactory('Text');
780
- proto.run = run;
781
- proto.use = useFactory(function (context, key, plugins) {
782
- context[key] = context[key].concat(plugins);
783
- });
784
- proto.useFirst = useFactory(function (context, key, plugins) {
785
- context[key] = plugins.concat(context[key]);
786
- });
787
- proto.parse = function (value) {
788
- return this.tokenizeRoot(value || this.doc);
789
- };
790
- proto.tokenize = function (value) {
791
- return tokenize(this, value);
792
- };
793
- pluggable(ParseLatin, 'tokenizeWord', function (value, eat) {
794
- var add = (eat || noopEat)('');
795
- var parent = {
796
- type: 'WordNode',
797
- children: []
798
- };
799
- this.tokenizeText(value, eat, parent);
800
- return add(parent);
801
- });
802
- pluggable(ParseLatin, 'tokenizeSentence', parser({
803
- type: 'SentenceNode',
804
- tokenizer: 'tokenize'
805
- }));
806
- pluggable(ParseLatin, 'tokenizeParagraph', parser({
807
- type: 'ParagraphNode',
808
- delimiter: expressions.terminalMarker,
809
- delimiterType: 'PunctuationNode',
810
- tokenizer: 'tokenizeSentence'
811
- }));
812
- pluggable(ParseLatin, 'tokenizeRoot', parser({
813
- type: 'RootNode',
814
- delimiter: expressions.newLine,
815
- delimiterType: 'WhiteSpaceNode',
816
- tokenizer: 'tokenizeParagraph'
817
- }));
818
- proto.use('tokenizeSentence', [mergeInitialWordSymbol_1, mergeFinalWordSymbol_1, mergeInnerWordSymbol_1, mergeInnerWordSlash_1, mergeInitialisms_1, mergeWords, patchPosition_1]);
819
- proto.use('tokenizeParagraph', [mergeNonWordSentences_1, mergeAffixSymbol_1, mergeInitialLowerCaseLetterSentences_1, mergeInitialDigitSentences_1, mergePrefixExceptions_1, mergeAffixExceptions_1, mergeRemainingFullStops_1, makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, breakImplicitSentences_1, removeEmptyNodes_1, patchPosition_1]);
820
- proto.use('tokenizeRoot', [makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, removeEmptyNodes_1, patchPosition_1]);
821
- function createTextFactory(type) {
822
- type += 'Node';
823
- return createText;
824
- function createText(value, eat, parent) {
825
- if (value === null || value === undefined) {
826
- value = '';
827
- }
828
- return (eat || noopEat)(value)({
829
- type: type,
830
- value: String(value)
831
- }, parent);
832
- }
833
- }
834
- function run(key, nodes) {
835
- var wareKey = key + 'Plugins';
836
- var plugins = this[wareKey];
837
- var index = -1;
838
- if (plugins) {
839
- while (plugins[++index]) {
840
- plugins[index](nodes);
841
- }
842
- }
843
- return nodes;
844
- }
845
- function pluggable(Constructor, key, callback) {
846
- Constructor.prototype[key] = function () {
847
- return this.run(key, callback.apply(this, arguments));
848
- };
849
- }
850
- function useFactory(callback) {
851
- return use;
852
- function use(key, plugins) {
853
- var self = this;
854
- var wareKey;
855
- if (!((key in self))) {
856
- throw new Error('Illegal Invocation: Unsupported `key` for ' + '`use(key, plugins)`. Make sure `key` is a ' + 'supported function');
857
- }
858
- if (!plugins) {
859
- return;
860
- }
861
- wareKey = key + 'Plugins';
862
- if (typeof plugins === 'function') {
863
- plugins = [plugins];
864
- } else {
865
- plugins = plugins.concat();
866
- }
867
- if (!self[wareKey]) {
868
- self[wareKey] = [];
869
- }
870
- callback(self, wareKey, plugins);
871
- }
872
- }
873
- var wordRe = expressions.word;
874
- var surrogatesRe = expressions.surrogates;
875
- var punctuationRe = expressions.punctuation;
876
- var whiteSpaceRe = expressions.whiteSpace;
877
- function tokenize(parser, value) {
878
- var tokens;
879
- var offset;
880
- var line;
881
- var column;
882
- var index;
883
- var length;
884
- var character;
885
- var queue;
886
- var previous;
887
- var left;
888
- var right;
889
- var eater;
890
- if (value === null || value === undefined) {
891
- value = '';
892
- } else if (value instanceof String) {
893
- value = value.toString();
894
- }
895
- if (typeof value !== 'string') {
896
- if (('length' in value) && (!value[0] || value[0].type)) {
897
- return value;
898
- }
899
- throw new Error("Illegal invocation: '" + value + "' is not a valid argument for 'ParseLatin'");
900
- }
901
- tokens = [];
902
- if (!value) {
903
- return tokens;
904
- }
905
- index = 0;
906
- offset = 0;
907
- line = 1;
908
- column = 1;
909
- eater = parser.position ? eat : noPositionEat;
910
- length = value.length;
911
- previous = '';
912
- queue = '';
913
- while (index < length) {
914
- character = value.charAt(index);
915
- if (whiteSpaceRe.test(character)) {
916
- right = 'WhiteSpace';
917
- } else if (punctuationRe.test(character)) {
918
- right = 'Punctuation';
919
- } else if (wordRe.test(character)) {
920
- right = 'Word';
921
- } else {
922
- right = 'Symbol';
923
- }
924
- tick();
925
- previous = character;
926
- character = '';
927
- left = right;
928
- right = null;
929
- index++;
930
- }
931
- tick();
932
- return tokens;
933
- function tick() {
934
- if (left === right && (left === 'Word' || left === 'WhiteSpace' || character === previous || surrogatesRe.test(character))) {
935
- queue += character;
936
- } else {
937
- if (queue) {
938
- parser['tokenize' + left](queue, eater);
939
- }
940
- queue = character;
941
- }
942
- }
943
- function eat(subvalue) {
944
- var pos = position();
945
- update(subvalue);
946
- return apply;
947
- function apply() {
948
- return pos(add.apply(null, arguments));
949
- }
950
- }
951
- function noPositionEat() {
952
- return apply;
953
- function apply() {
954
- return add.apply(null, arguments);
955
- }
956
- }
957
- function add(node, parent) {
958
- if (parent) {
959
- parent.children.push(node);
960
- } else {
961
- tokens.push(node);
962
- }
963
- return node;
964
- }
965
- function position() {
966
- var before = now();
967
- function patch(node) {
968
- node.position = new Position(before);
969
- return node;
970
- }
971
- return patch;
972
- }
973
- function update(subvalue) {
974
- var subvalueLength = subvalue.length;
975
- var character = -1;
976
- var lastIndex = -1;
977
- offset += subvalueLength;
978
- while (++character < subvalueLength) {
979
- if (subvalue.charAt(character) === '\n') {
980
- lastIndex = character;
981
- line++;
982
- }
983
- }
984
- if (lastIndex === -1) {
985
- column += subvalueLength;
986
- } else {
987
- column = subvalueLength - lastIndex;
988
- }
989
- }
990
- function Position(start) {
991
- this.start = start;
992
- this.end = now();
993
- }
994
- function now() {
995
- return {
996
- line: line,
997
- column: column,
998
- offset: offset
999
- };
1000
- }
1001
- }
1002
- function noopAdd(node, parent) {
1003
- if (parent) {
1004
- parent.children.push(node);
1005
- }
1006
- return node;
1007
- }
1008
- function noopEat() {
1009
- return noopAdd;
1010
- }
1011
- var parseLatin = lib;
1012
- var parseEnglish = ParseEnglish;
1013
- ParserPrototype.prototype = parseLatin.prototype;
1014
- var proto$1 = new ParserPrototype();
1015
- ParseEnglish.prototype = proto$1;
1016
- proto$1.tokenizeSentencePlugins = [unistUtilVisitChildren(mergeEnglishElisionExceptions)].concat(proto$1.tokenizeSentencePlugins);
1017
- proto$1.tokenizeParagraphPlugins = [unistUtilModifyChildren(mergeEnglishPrefixExceptions)].concat([mergeNonWordSentences_1, mergeAffixSymbol_1, mergeInitialLowerCaseLetterSentences_1, mergeInitialDigitSentences_1, mergeAffixExceptions_1, mergeRemainingFullStops_1, makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, breakImplicitSentences_1, removeEmptyNodes_1, patchPosition_1]);
1018
- function ParseEnglish(doc, file) {
1019
- if (!(this instanceof ParseEnglish)) {
1020
- return new ParseEnglish(doc, file);
1021
- }
1022
- parseLatin.apply(this, arguments);
1023
- }
1024
- function ParserPrototype() {}
1025
- var abbreviations = new RegExp('^(' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + 'inc|ltd|' + 'bbls?|cu|doz|fl|ft|gal|gr|gro|in|kt|lbs?|mi|oz|pt|qt|sq|tbsp|' + 'tsp|yds?|' + 'sec|min|hr|mon|tue|tues|wed|thu|thurs|fri|sat|sun|jan|feb|mar|' + 'apr|jun|jul|aug|sep|sept|oct|nov|dec' + ')$');
1026
- var abbreviationsSensitive = new RegExp('^(' + 'Mr|Mrs|Miss|Ms|Mss|Mses|Mlle|Mme|M|Messrs|Mmes|Jr|Sr|Snr|' + 'Dr|Mgr|Atty|Prof|Hon|Rev|Fr|Msgr|Sr|Br|St|Pres|Supt|Rep|Sen|' + 'Gov|Amb|Treas|Sec|Amd|Brig|Gen|Cdr|Col|Capt|Lt|Maj|Sgt|Po|Wo|Ph|' + 'Ave|Blvd|Mt|Rd|Bldgs?|Nat|Natl|Rt|Rte|Co|Pk|Sq|Dr|Pt|St|' + 'Ft|Pen|Terr|Hwy|Fwy|Pkwy|' + 'Ala|Ariz|Ark|Cal|Calif|Col|Colo|Conn|Del|Fla|Ga|Ida|Id|Ill|Ind|' + 'Ia|Kan|Kans|Ken|Ky|La|Me|Md|Mass|Mich|Minn|Miss|Mo|Mont|Neb|' + 'Nebr|Nev|Mex|Dak|Okla|Ok|Ore|Penna|Penn|Pa|Tenn|Tex|Ut|Vt|Va|' + 'Wash|Wis|Wisc|Wyo|' + 'Alta|Man|Ont|Qu\u00E9|Que|Sask|Yuk|' + 'Beds|Berks|Bucks|Cambs|Ches|Corn|Cumb|Derbys|Derbs|Dev|Dor|Dur|' + 'Glos|Hants|Here|Heref|Herts|Hunts|Lancs|Leics|Lincs|Mx|Middx|Mddx|' + 'Norf|Northants|Northumb|Northd|Notts|Oxon|Rut|Shrops|Salop|Som|' + 'Staffs|Staf|Suff|Sy|Sx|Ssx|Warks|War|Warw|Westm|Wilts|Worcs|Yorks' + ')$');
1027
- var elisionPrefix = new RegExp('^(' + 'o|ol' + ')$');
1028
- var elisionAffix = new RegExp('^(' + 'im|er|em|cause|' + 'twas|tis|twere|' + '\\d\\ds?' + ')$');
1029
- var apostrophe = /^['\u2019]$/;
1030
- function mergeEnglishPrefixExceptions(sentence, index, paragraph) {
1031
- var children = sentence.children;
1032
- var period = children[children.length - 1];
1033
- var word = children[children.length - 2];
1034
- var value;
1035
- var next;
1036
- if (period && nlcstToString_1(period) === '.' && word && word.type === 'WordNode') {
1037
- value = nlcstToString_1(word);
1038
- if (abbreviations.test(lower(value)) || abbreviationsSensitive.test(value)) {
1039
- word.children.push(period);
1040
- children.pop();
1041
- if (period.position && word.position) {
1042
- word.position.end = period.position.end;
1043
- }
1044
- next = paragraph.children[index + 1];
1045
- if (next) {
1046
- sentence.children = children.concat(next.children);
1047
- paragraph.children.splice(index + 1, 1);
1048
- if (next.position && sentence.position) {
1049
- sentence.position.end = next.position.end;
1050
- }
1051
- return index - 1;
1052
- }
1053
- }
1054
- }
1055
- }
1056
- function mergeEnglishElisionExceptions(child, index, sentence) {
1057
- var siblings;
1058
- var sibling;
1059
- var other;
1060
- var length;
1061
- var value;
1062
- if (child.type !== 'PunctuationNode' && child.type !== 'SymbolNode') {
1063
- return;
1064
- }
1065
- siblings = sentence.children;
1066
- length = siblings.length;
1067
- value = nlcstToString_1(child);
1068
- if (value === '/') {
1069
- sibling = siblings[index - 1];
1070
- if (sibling && lower(nlcstToString_1(sibling)) === 'w') {
1071
- siblings.splice(index, 1);
1072
- sibling.children.push(child);
1073
- if (sibling.position && child.position) {
1074
- sibling.position.end = child.position.end;
1075
- }
1076
- }
1077
- } else if (apostrophe.test(value)) {
1078
- sibling = siblings[index - 1];
1079
- if (index > 2 && index < length - 1 && sibling.type === 'WordNode' && siblings[index - 2].type === 'WhiteSpaceNode' && siblings[index + 1].type === 'WhiteSpaceNode' && elisionPrefix.test(lower(nlcstToString_1(sibling)))) {
1080
- siblings.splice(index, 1);
1081
- sibling.children.push(child);
1082
- if (sibling.position && child.position) {
1083
- sibling.position.end = child.position.end;
1084
- }
1085
- return;
1086
- }
1087
- if (index !== length - 1 && siblings[index + 1].type === 'WordNode' && (index === 0 || siblings[index - 1].type !== 'WordNode')) {
1088
- sibling = siblings[index + 1];
1089
- value = lower(nlcstToString_1(sibling));
1090
- if (elisionAffix.test(value)) {
1091
- siblings.splice(index, 1);
1092
- sibling.children = [child].concat(sibling.children);
1093
- if (sibling.position && child.position) {
1094
- sibling.position.start = child.position.start;
1095
- }
1096
- } else if (value === 'n' && index < length - 2 && apostrophe.test(nlcstToString_1(siblings[index + 2]))) {
1097
- other = siblings[index + 2];
1098
- siblings.splice(index, 1);
1099
- siblings.splice(index + 1, 1);
1100
- sibling.children = [child].concat(sibling.children, other);
1101
- if (sibling.position) {
1102
- if (child.position) {
1103
- sibling.position.start = child.position.start;
1104
- }
1105
- if (other.position) {
1106
- sibling.position.end = other.position.end;
1107
- }
1108
- }
1109
- }
1110
- }
1111
- }
1112
- }
1113
- function lower(value) {
1114
- return value.toLowerCase();
1115
- }
1116
- const {compact: compact} = _dll_lodash;
1117
- const {clone: clone} = _dll_lodash;
1118
- const g = (str, node) => {
1119
- if (node.children) {
1120
- return node.children.reduce(g, str);
1121
- } else if (node.value) {
1122
- return str + node.value;
1123
- } else {
1124
- return str;
1125
- }
1126
- };
1127
- const getParagraph = p => g('', p);
1128
- const getSentence = s => g('', s);
1129
- const getWord = w => g('', w);
1130
- const paragraphs = text => {
1131
- const tree = new parseEnglish().parse(text);
1132
- const out = tree.children.reduce((acc, child) => {
1133
- if (child.type === 'ParagraphNode') {
1134
- const paragraph = {
1135
- text: getParagraph(child),
1136
- start: child.position.start.offset,
1137
- end: child.position.end.offset
1138
- };
1139
- return acc.concat([paragraph]);
1140
- } else {
1141
- return acc;
1142
- }
1143
- }, []);
1144
- return out;
1145
- };
1146
- const handleSentence = (child, acc) => {
1147
- const sentenceChilds = [];
1148
- let newAcc = child.children.reduce(function (acc, child) {
1149
- if (child.type === 'WhiteSpaceNode' && child.value === '\n') {
1150
- if (sentenceChilds.length) {
1151
- const firstWord = sentenceChilds[0];
1152
- const sentence = {
1153
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1154
- start: firstWord.position.start.offset,
1155
- end: child.position.start.offset
1156
- };
1157
- sentenceChilds.splice(0, sentenceChilds.length);
1158
- return acc.concat([sentence]);
1159
- }
1160
- } else {
1161
- sentenceChilds.push(child);
1162
- }
1163
- return acc;
1164
- }, acc);
1165
- if (sentenceChilds.length) {
1166
- const firstWord = sentenceChilds[0];
1167
- const lastWord = sentenceChilds[sentenceChilds.length - 1];
1168
- const sentence = {
1169
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1170
- start: firstWord.position.start.offset,
1171
- end: lastWord.position.end.offset
1172
- };
1173
- newAcc = newAcc.concat([sentence]);
1174
- sentenceChilds.splice(0, sentenceChilds.length);
1175
- }
1176
- return newAcc;
1177
- };
1178
- const sentences = text => {
1179
- const tree = new parseEnglish().parse(text);
1180
- const out = tree.children.reduce((acc, child) => {
1181
- if (child.type === 'ParagraphNode') {
1182
- return child.children.reduce((acc, child) => {
1183
- if (child.type === 'SentenceNode') {
1184
- const newAcc = handleSentence(child, acc);
1185
- return newAcc || acc;
1186
- } else {
1187
- return acc;
1188
- }
1189
- }, acc);
1190
- } else {
1191
- return acc;
1192
- }
1193
- }, []);
1194
- return out;
1195
- };
1196
- const words = text => {
1197
- const tree = new parseEnglish().parse(text);
1198
- const out = tree.children.reduce((acc, child) => {
1199
- if (child.type === 'ParagraphNode') {
1200
- return child.children.reduce((acc, child) => {
1201
- if (child.type === 'SentenceNode') {
1202
- return child.children.reduce((acc, child) => {
1203
- if (child.type === 'WordNode') {
1204
- const node = {
1205
- text: getWord(child),
1206
- start: child.position.start.offset,
1207
- end: child.position.end.offset
1208
- };
1209
- return acc.concat([node]);
1210
- } else {
1211
- return acc;
1212
- }
1213
- }, acc);
1214
- } else {
1215
- return acc;
1216
- }
1217
- }, acc);
1218
- } else {
1219
- return acc;
1220
- }
1221
- }, []);
1222
- return out;
1223
- };
1224
- class Intersection {
1225
- constructor(results) {
1226
- this.results = results;
1227
- }
1228
- get hasOverlap() {
1229
- return this.results.filter(r => r.type === 'overlap').length > 0;
1230
- }
1231
- get surroundedTokens() {
1232
- return this.results.filter(r => r.type === 'within-selection').map(t => t.token);
1233
- }
1234
- }
1235
- const intersection = (selection, tokens) => {
1236
- const {start, end} = selection;
1237
- const startsWithin = t => start >= t.start && start < t.end;
1238
- const endsWithin = t => end > t.start && end <= t.end;
1239
- const mapped = tokens.map(t => {
1240
- if (start === t.start && end === t.end) {
1241
- return {
1242
- token: t,
1243
- type: 'exact-fit'
1244
- };
1245
- } else if (start <= t.start && end >= t.end) {
1246
- return {
1247
- token: t,
1248
- type: 'within-selection'
1249
- };
1250
- } else if (startsWithin(t) || endsWithin(t)) {
1251
- return {
1252
- token: t,
1253
- type: 'overlap'
1254
- };
1255
- }
1256
- });
1257
- return new Intersection(compact(mapped));
1258
- };
1259
- const sort = tokens => {
1260
- if (!Array.isArray(tokens)) {
1261
- return tokens;
1262
- } else {
1263
- const out = clone(tokens);
1264
- out.sort((a, b) => {
1265
- const s = a.start < b.start ? -1 : a.start > b.start ? 1 : 0;
1266
- const e = a.end < b.end ? -1 : a.end > b.end ? 1 : 0;
1267
- if (s === -1 && e !== -1) {
1268
- throw new Error(`sort does not support intersecting tokens. a: ${a.start}-${a.end}, b: ${b.start}-${b.end}`);
1269
- }
1270
- return s;
1271
- });
1272
- return out;
1273
- }
1274
- };
1275
- const normalize = (textToNormalize, tokens) => {
1276
- const text = textToNormalize || '';
1277
- if (!Array.isArray(tokens) || tokens.length === 0) {
1278
- return [{
1279
- text,
1280
- start: 0,
1281
- end: text.length
1282
- }];
1283
- }
1284
- const out = sort(tokens).reduce((acc, t, index, outer) => {
1285
- let tokens = [];
1286
- const lastIndex = acc.lastIndex;
1287
- if (t.start === lastIndex) {
1288
- tokens = [{
1289
- text: text.substring(lastIndex, t.end),
1290
- start: lastIndex,
1291
- end: t.end,
1292
- predefined: true,
1293
- correct: t.correct
1294
- }];
1295
- } else if (lastIndex < t.start) {
1296
- tokens = [{
1297
- text: text.substring(lastIndex, t.start),
1298
- start: lastIndex,
1299
- end: t.start
1300
- }, {
1301
- text: text.substring(t.start, t.end),
1302
- start: t.start,
1303
- end: t.end,
1304
- predefined: true,
1305
- correct: t.correct
1306
- }];
1307
- }
1308
- if (index === outer.length - 1 && t.end < text.length) {
1309
- const last = {
1310
- text: text.substring(t.end),
1311
- start: t.end,
1312
- end: text.length
1313
- };
1314
- tokens.push(last);
1315
- }
1316
- return {
1317
- lastIndex: tokens.length ? tokens[tokens.length - 1].end : lastIndex,
1318
- result: acc.result.concat(tokens)
1319
- };
1320
- }, {
1321
- result: [],
1322
- lastIndex: 0
1323
- });
1324
- return out.result;
1325
- };
1326
- function createCommonjsModule(fn, module) {
1327
- return (module = {
1328
- exports: {}
1329
- }, fn(module, module.exports), module.exports);
1330
- }
1331
- var classnames = createCommonjsModule(function (module) {
1332
- (function () {
1333
- var hasOwn = ({}).hasOwnProperty;
1334
- function classNames() {
1335
- var classes = [];
1336
- for (var i = 0; i < arguments.length; i++) {
1337
- var arg = arguments[i];
1338
- if (!arg) continue;
1339
- var argType = typeof arg;
1340
- if (argType === 'string' || argType === 'number') {
1341
- classes.push(arg);
1342
- } else if (Array.isArray(arg) && arg.length) {
1343
- var inner = classNames.apply(null, arg);
1344
- if (inner) {
1345
- classes.push(inner);
1346
- }
1347
- } else if (argType === 'object') {
1348
- for (var key in arg) {
1349
- if (hasOwn.call(arg, key) && arg[key]) {
1350
- classes.push(key);
1351
- }
1352
- }
1353
- }
1354
- }
1355
- return classes.join(' ');
1356
- }
1357
- if (module.exports) {
1358
- classNames.default = classNames;
1359
- module.exports = classNames;
1360
- } else {
1361
- window.classNames = classNames;
1362
- }
1363
- })();
1364
- });
1365
- const noSelect = () => ({
1366
- cursor: 'default',
1367
- '-webkit-user-select': 'none',
1368
- '-moz-user-select': 'none',
1369
- '-ms-user-select': 'none',
1370
- 'user-select': 'none'
1371
- });
1372
- var s = 1000;
1373
- var m = s * 60;
1374
- var h = m * 60;
1375
- var d = h * 24;
1376
- var w = d * 7;
1377
- var y = d * 365.25;
1378
- var ms = function (val, options) {
1379
- options = options || ({});
1380
- var type = typeof val;
1381
- if (type === 'string' && val.length > 0) {
1382
- return parse(val);
1383
- } else if (type === 'number' && isFinite(val)) {
1384
- return options.long ? fmtLong(val) : fmtShort(val);
1385
- }
1386
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
1387
- };
1388
- function parse(str) {
1389
- str = String(str);
1390
- if (str.length > 100) {
1391
- return;
1392
- }
1393
- var match = (/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i).exec(str);
1394
- if (!match) {
1395
- return;
1396
- }
1397
- var n = parseFloat(match[1]);
1398
- var type = (match[2] || 'ms').toLowerCase();
1399
- switch (type) {
1400
- case 'years':
1401
- case 'year':
1402
- case 'yrs':
1403
- case 'yr':
1404
- case 'y':
1405
- return n * y;
1406
- case 'weeks':
1407
- case 'week':
1408
- case 'w':
1409
- return n * w;
1410
- case 'days':
1411
- case 'day':
1412
- case 'd':
1413
- return n * d;
1414
- case 'hours':
1415
- case 'hour':
1416
- case 'hrs':
1417
- case 'hr':
1418
- case 'h':
1419
- return n * h;
1420
- case 'minutes':
1421
- case 'minute':
1422
- case 'mins':
1423
- case 'min':
1424
- case 'm':
1425
- return n * m;
1426
- case 'seconds':
1427
- case 'second':
1428
- case 'secs':
1429
- case 'sec':
1430
- case 's':
1431
- return n * s;
1432
- case 'milliseconds':
1433
- case 'millisecond':
1434
- case 'msecs':
1435
- case 'msec':
1436
- case 'ms':
1437
- return n;
1438
- default:
1439
- return undefined;
1440
- }
1441
- }
1442
- function fmtShort(ms) {
1443
- var msAbs = Math.abs(ms);
1444
- if (msAbs >= d) {
1445
- return Math.round(ms / d) + 'd';
1446
- }
1447
- if (msAbs >= h) {
1448
- return Math.round(ms / h) + 'h';
1449
- }
1450
- if (msAbs >= m) {
1451
- return Math.round(ms / m) + 'm';
1452
- }
1453
- if (msAbs >= s) {
1454
- return Math.round(ms / s) + 's';
1455
- }
1456
- return ms + 'ms';
1457
- }
1458
- function fmtLong(ms) {
1459
- var msAbs = Math.abs(ms);
1460
- if (msAbs >= d) {
1461
- return plural(ms, msAbs, d, 'day');
1462
- }
1463
- if (msAbs >= h) {
1464
- return plural(ms, msAbs, h, 'hour');
1465
- }
1466
- if (msAbs >= m) {
1467
- return plural(ms, msAbs, m, 'minute');
1468
- }
1469
- if (msAbs >= s) {
1470
- return plural(ms, msAbs, s, 'second');
1471
- }
1472
- return ms + ' ms';
1473
- }
1474
- function plural(ms, msAbs, n, name) {
1475
- var isPlural = msAbs >= n * 1.5;
1476
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1477
- }
1478
- function setup(env) {
1479
- createDebug.debug = createDebug;
1480
- createDebug.default = createDebug;
1481
- createDebug.coerce = coerce;
1482
- createDebug.disable = disable;
1483
- createDebug.enable = enable;
1484
- createDebug.enabled = enabled;
1485
- createDebug.humanize = ms;
1486
- createDebug.destroy = destroy;
1487
- Object.keys(env).forEach(key => {
1488
- createDebug[key] = env[key];
1489
- });
1490
- createDebug.names = [];
1491
- createDebug.skips = [];
1492
- createDebug.formatters = {};
1493
- function selectColor(namespace) {
1494
- let hash = 0;
1495
- for (let i = 0; i < namespace.length; i++) {
1496
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
1497
- hash |= 0;
1498
- }
1499
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1500
- }
1501
- createDebug.selectColor = selectColor;
1502
- function createDebug(namespace) {
1503
- let prevTime;
1504
- let enableOverride = null;
1505
- function debug(...args) {
1506
- if (!debug.enabled) {
1507
- return;
1508
- }
1509
- const self = debug;
1510
- const curr = Number(new Date());
1511
- const ms = curr - (prevTime || curr);
1512
- self.diff = ms;
1513
- self.prev = prevTime;
1514
- self.curr = curr;
1515
- prevTime = curr;
1516
- args[0] = createDebug.coerce(args[0]);
1517
- if (typeof args[0] !== 'string') {
1518
- args.unshift('%O');
1519
- }
1520
- let index = 0;
1521
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1522
- if (match === '%%') {
1523
- return '%';
1524
- }
1525
- index++;
1526
- const formatter = createDebug.formatters[format];
1527
- if (typeof formatter === 'function') {
1528
- const val = args[index];
1529
- match = formatter.call(self, val);
1530
- args.splice(index, 1);
1531
- index--;
1532
- }
1533
- return match;
1534
- });
1535
- createDebug.formatArgs.call(self, args);
1536
- const logFn = self.log || createDebug.log;
1537
- logFn.apply(self, args);
1538
- }
1539
- debug.namespace = namespace;
1540
- debug.useColors = createDebug.useColors();
1541
- debug.color = createDebug.selectColor(namespace);
1542
- debug.extend = extend;
1543
- debug.destroy = createDebug.destroy;
1544
- Object.defineProperty(debug, 'enabled', {
1545
- enumerable: true,
1546
- configurable: false,
1547
- get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
1548
- set: v => {
1549
- enableOverride = v;
1550
- }
1551
- });
1552
- if (typeof createDebug.init === 'function') {
1553
- createDebug.init(debug);
1554
- }
1555
- return debug;
1556
- }
1557
- function extend(namespace, delimiter) {
1558
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1559
- newDebug.log = this.log;
1560
- return newDebug;
1561
- }
1562
- function enable(namespaces) {
1563
- createDebug.save(namespaces);
1564
- createDebug.names = [];
1565
- createDebug.skips = [];
1566
- let i;
1567
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1568
- const len = split.length;
1569
- for (i = 0; i < len; i++) {
1570
- if (!split[i]) {
1571
- continue;
1572
- }
1573
- namespaces = split[i].replace(/\*/g, '.*?');
1574
- if (namespaces[0] === '-') {
1575
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
1576
- } else {
1577
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
1578
- }
1579
- }
1580
- }
1581
- function disable() {
1582
- const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
1583
- createDebug.enable('');
1584
- return namespaces;
1585
- }
1586
- function enabled(name) {
1587
- if (name[name.length - 1] === '*') {
1588
- return true;
1589
- }
1590
- let i;
1591
- let len;
1592
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
1593
- if (createDebug.skips[i].test(name)) {
1594
- return false;
1595
- }
1596
- }
1597
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
1598
- if (createDebug.names[i].test(name)) {
1599
- return true;
1600
- }
1601
- }
1602
- return false;
1603
- }
1604
- function toNamespace(regexp) {
1605
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
1606
- }
1607
- function coerce(val) {
1608
- if (val instanceof Error) {
1609
- return val.stack || val.message;
1610
- }
1611
- return val;
1612
- }
1613
- function destroy() {
1614
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1615
- }
1616
- createDebug.enable(createDebug.load());
1617
- return createDebug;
1618
- }
1619
- var common = setup;
1620
- var browser = createCommonjsModule(function (module, exports) {
1621
- exports.formatArgs = formatArgs;
1622
- exports.save = save;
1623
- exports.load = load;
1624
- exports.useColors = useColors;
1625
- exports.storage = localstorage();
1626
- exports.destroy = (() => {
1627
- let warned = false;
1628
- return () => {
1629
- if (!warned) {
1630
- warned = true;
1631
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1632
- }
1633
- };
1634
- })();
1635
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
1636
- function useColors() {
1637
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1638
- return true;
1639
- }
1640
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1641
- return false;
1642
- }
1643
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1644
- }
1645
- function formatArgs(args) {
1646
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
1647
- if (!this.useColors) {
1648
- return;
1649
- }
1650
- const c = 'color: ' + this.color;
1651
- args.splice(1, 0, c, 'color: inherit');
1652
- let index = 0;
1653
- let lastC = 0;
1654
- args[0].replace(/%[a-zA-Z%]/g, match => {
1655
- if (match === '%%') {
1656
- return;
1657
- }
1658
- index++;
1659
- if (match === '%c') {
1660
- lastC = index;
1661
- }
1662
- });
1663
- args.splice(lastC, 0, c);
1664
- }
1665
- exports.log = console.debug || console.log || (() => {});
1666
- function save(namespaces) {
1667
- try {
1668
- if (namespaces) {
1669
- exports.storage.setItem('debug', namespaces);
1670
- } else {
1671
- exports.storage.removeItem('debug');
1672
- }
1673
- } catch (error) {}
1674
- }
1675
- function load() {
1676
- let r;
1677
- try {
1678
- r = exports.storage.getItem('debug');
1679
- } catch (error) {}
1680
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
1681
- r = process.env.DEBUG;
1682
- }
1683
- return r;
1684
- }
1685
- function localstorage() {
1686
- try {
1687
- return localStorage;
1688
- } catch (error) {}
1689
- }
1690
- module.exports = common(exports);
1691
- const {formatters} = module.exports;
1692
- formatters.j = function (v) {
1693
- try {
1694
- return JSON.stringify(v);
1695
- } catch (error) {
1696
- return '[UnexpectedJSONParseError]: ' + error.message;
1697
- }
1698
- };
1699
- });
1700
- browser.formatArgs;
1701
- browser.save;
1702
- browser.load;
1703
- browser.useColors;
1704
- browser.storage;
1705
- browser.destroy;
1706
- browser.colors;
1707
- browser.log;
1708
- const clearSelection = () => {
1709
- if (document.getSelection) {
1710
- document.getSelection().removeAllRanges();
1711
- document.getSelection().addRange(document.createRange());
1712
- } else if (window.getSelection) {
1713
- if (window.getSelection().removeAllRanges) {
1714
- window.getSelection().removeAllRanges();
1715
- window.getSelection().addRange(document.createRange());
1716
- } else if (window.getSelection().empty) {
1717
- window.getSelection().empty();
1718
- }
1719
- } else if (document.selection) {
1720
- document.selection.empty();
1721
- }
1722
- };
1723
- const getCaretCharacterOffsetWithin = element => {
1724
- var caretOffset = 0;
1725
- var doc = element.ownerDocument || element.document;
1726
- var win = doc.defaultView || doc.parentWindow;
1727
- var sel;
1728
- if (typeof win.getSelection !== 'undefined') {
1729
- sel = win.getSelection();
1730
- if (sel.rangeCount > 0) {
1731
- var range = win.getSelection().getRangeAt(0);
1732
- var selected = range.toString().length;
1733
- var preCaretRange = range.cloneRange();
1734
- preCaretRange.selectNodeContents(element);
1735
- preCaretRange.setEnd(range.endContainer, range.endOffset);
1736
- if (selected) {
1737
- caretOffset = preCaretRange.toString().length - selected;
1738
- } else {
1739
- caretOffset = preCaretRange.toString().length;
1740
- }
1741
- }
1742
- } else if ((sel = doc.selection) && sel.type != 'Control') {
1743
- var textRange = sel.createRange();
1744
- var preCaretTextRange = doc.body.createTextRange();
1745
- preCaretTextRange.moveToElementText(element);
1746
- preCaretTextRange.setEndPoint('EndToEnd', textRange);
1747
- caretOffset = preCaretTextRange.text.length;
1748
- }
1749
- return caretOffset;
1750
- };
1751
- const React$1 = _dll_react;
1752
- const PropTypes$1 = _dll_prop_types;
1753
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
1754
- const {colors: {yellow: yellow}} = _dll_material_ui__core;
1755
- const {colors: {green: green}} = _dll_material_ui__core;
1756
- const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/token-text.jsx";
1757
- const log = browser('@pie-lib:text-select:token-text');
1758
- const Text = withStyles$1(() => ({
1759
- predefined: {
1760
- cursor: 'pointer',
1761
- backgroundColor: yellow[100],
1762
- border: `dashed 0px ${yellow[700]}`
1763
- },
1764
- correct: {
1765
- backgroundColor: green[500]
1766
- }
1767
- }))(({text, predefined, classes, onClick, correct}) => {
1768
- const formattedText = (text || '').replace(/\n/g, '<br>');
1769
- if (predefined) {
1770
- const className = classnames(classes.predefined, correct && classes.correct);
1771
- return React$1.createElement('span', {
1772
- onClick: onClick,
1773
- className: className,
1774
- dangerouslySetInnerHTML: {
1775
- __html: formattedText
1776
- },
1777
- __self: undefined,
1778
- __source: {
1779
- fileName: _jsxFileName$1,
1780
- lineNumber: 30
1781
- }
1782
- });
1783
- } else {
1784
- return React$1.createElement('span', {
1785
- dangerouslySetInnerHTML: {
1786
- __html: formattedText
1787
- },
1788
- __self: undefined,
1789
- __source: {
1790
- fileName: _jsxFileName$1,
1791
- lineNumber: 37
1792
- }
1793
- });
1794
- }
1795
- });
1796
- class TokenText extends React$1.Component {
1797
- constructor(...args) {
1798
- super(...args);
1799
- TokenText.prototype.__init.call(this);
1800
- }
1801
- static __initStatic() {
1802
- this.propTypes = {
1803
- text: PropTypes$1.string.isRequired,
1804
- tokens: PropTypes$1.array.isRequired,
1805
- onTokenClick: PropTypes$1.func.isRequired,
1806
- onSelectToken: PropTypes$1.func.isRequired,
1807
- className: PropTypes$1.string
1808
- };
1809
- }
1810
- __init() {
1811
- this.mouseUp = event => {
1812
- event.preventDefault();
1813
- const {onSelectToken, text, tokens} = this.props;
1814
- if (typeof window === 'undefined') {
1815
- return;
1816
- }
1817
- const selection = window.getSelection();
1818
- const textSelected = selection.toString();
1819
- if (textSelected.length > 0) {
1820
- if (this.root) {
1821
- const offset = getCaretCharacterOffsetWithin(this.root);
1822
- if (offset !== undefined) {
1823
- const endIndex = offset + textSelected.length;
1824
- if (endIndex <= text.length) {
1825
- const i = intersection({
1826
- start: offset,
1827
- end: endIndex
1828
- }, tokens);
1829
- if (i.hasOverlap) {
1830
- log('hasOverlap - do nothing');
1831
- clearSelection();
1832
- } else {
1833
- const tokensToRemove = i.surroundedTokens;
1834
- const token = {
1835
- text: textSelected,
1836
- start: offset,
1837
- end: endIndex
1838
- };
1839
- onSelectToken(token, tokensToRemove);
1840
- clearSelection();
1841
- }
1842
- }
1843
- }
1844
- }
1845
- }
1846
- };
1847
- }
1848
- render() {
1849
- const {text, tokens, className, onTokenClick} = this.props;
1850
- const normalized = normalize(text, tokens);
1851
- return React$1.createElement('div', {
1852
- className: className,
1853
- ref: r => this.root = r,
1854
- onMouseUp: this.mouseUp,
1855
- __self: this,
1856
- __source: {
1857
- fileName: _jsxFileName$1,
1858
- lineNumber: 95
1859
- }
1860
- }, normalized.map((t, index) => {
1861
- return React$1.createElement(Text, {
1862
- key: index,
1863
- ...t,
1864
- onClick: () => onTokenClick(t),
1865
- __self: this,
1866
- __source: {
1867
- fileName: _jsxFileName$1,
1868
- lineNumber: 97
1869
- }
1870
- });
1871
- }));
1872
- }
1873
- }
1874
- TokenText.__initStatic();
1875
- const React$2 = _dll_react;
1876
- const PropTypes$2 = _dll_prop_types;
1877
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
1878
- const {clone: clone$1} = _dll_lodash;
1879
- const {isEqual: isEqual} = _dll_lodash;
1880
- const {differenceWith: differenceWith} = _dll_lodash;
1881
- const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/index.jsx";
1882
- class Tokenizer extends React$2.Component {
1883
- static __initStatic() {
1884
- this.propTypes = {
1885
- text: PropTypes$2.string.isRequired,
1886
- tokens: PropTypes$2.arrayOf(PropTypes$2.shape({
1887
- text: PropTypes$2.string,
1888
- correct: PropTypes$2.bool,
1889
- start: PropTypes$2.number,
1890
- end: PropTypes$2.number
1891
- })),
1892
- classes: PropTypes$2.object.isRequired,
1893
- className: PropTypes$2.string,
1894
- onChange: PropTypes$2.func.isRequired
1895
- };
1896
- }
1897
- static __initStatic2() {
1898
- this.defaultProps = {};
1899
- }
1900
- constructor(props) {
1901
- super(props);
1902
- Tokenizer.prototype.__init.call(this);
1903
- Tokenizer.prototype.__init2.call(this);
1904
- Tokenizer.prototype.__init3.call(this);
1905
- Tokenizer.prototype.__init4.call(this);
1906
- Tokenizer.prototype.__init5.call(this);
1907
- Tokenizer.prototype.__init6.call(this);
1908
- Tokenizer.prototype.__init7.call(this);
1909
- Tokenizer.prototype.__init8.call(this);
1910
- Tokenizer.prototype.__init9.call(this);
1911
- this.state = {
1912
- setCorrectMode: false,
1913
- mode: ''
1914
- };
1915
- }
1916
- __init() {
1917
- this.onChangeHandler = (token, mode) => {
1918
- this.props.onChange(token, mode);
1919
- this.setState({
1920
- mode
1921
- });
1922
- };
1923
- }
1924
- __init2() {
1925
- this.toggleCorrectMode = () => this.setState({
1926
- setCorrectMode: !this.state.setCorrectMode
1927
- });
1928
- }
1929
- __init3() {
1930
- this.clear = () => {
1931
- this.onChangeHandler([], '');
1932
- };
1933
- }
1934
- __init4() {
1935
- this.buildTokens = (type, fn) => {
1936
- const {text} = this.props;
1937
- const tokens = fn(text);
1938
- this.onChangeHandler(tokens, type);
1939
- };
1940
- }
1941
- __init5() {
1942
- this.selectToken = (newToken, tokensToRemove) => {
1943
- const {tokens} = this.props;
1944
- const update = differenceWith(clone$1(tokens), tokensToRemove, isEqual);
1945
- update.push(newToken);
1946
- this.onChangeHandler(update, this.state.mode);
1947
- };
1948
- }
1949
- __init6() {
1950
- this.tokenClick = token => {
1951
- const {setCorrectMode} = this.state;
1952
- if (setCorrectMode) {
1953
- this.setCorrect(token);
1954
- } else {
1955
- this.removeToken(token);
1956
- }
1957
- };
1958
- }
1959
- __init7() {
1960
- this.tokenIndex = token => {
1961
- const {tokens} = this.props;
1962
- return tokens.findIndex(t => {
1963
- return t.text == token.text && t.start == token.start && t.end == token.end;
1964
- });
1965
- };
1966
- }
1967
- __init8() {
1968
- this.setCorrect = token => {
1969
- const {tokens} = this.props;
1970
- const index = this.tokenIndex(token);
1971
- if (index !== -1) {
1972
- const t = tokens[index];
1973
- t.correct = !t.correct;
1974
- const update = clone$1(tokens);
1975
- update.splice(index, 1, t);
1976
- this.onChangeHandler(update, this.state.mode);
1977
- }
1978
- };
1979
- }
1980
- __init9() {
1981
- this.removeToken = token => {
1982
- const {tokens} = this.props;
1983
- const index = this.tokenIndex(token);
1984
- if (index !== -1) {
1985
- const update = clone$1(tokens);
1986
- update.splice(index, 1);
1987
- this.onChangeHandler(update, this.state.mode);
1988
- }
1989
- };
1990
- }
1991
- render() {
1992
- const {text, tokens, classes, className} = this.props;
1993
- const {setCorrectMode} = this.state;
1994
- const tokenClassName = classnames(classes.text, setCorrectMode && classes.noselect);
1995
- const rootName = classnames(classes.tokenizer, className);
1996
- return React$2.createElement('div', {
1997
- className: rootName,
1998
- __self: this,
1999
- __source: {
2000
- fileName: _jsxFileName$2,
2001
- lineNumber: 123
2002
- }
2003
- }, React$2.createElement(Controls$1, {
2004
- onClear: this.clear,
2005
- onWords: () => this.buildTokens('words', words),
2006
- onSentences: () => this.buildTokens('sentence', sentences),
2007
- onParagraphs: () => this.buildTokens('paragraphs', paragraphs),
2008
- setCorrectMode: setCorrectMode,
2009
- onToggleCorrectMode: this.toggleCorrectMode,
2010
- __self: this,
2011
- __source: {
2012
- fileName: _jsxFileName$2,
2013
- lineNumber: 124
2014
- }
2015
- }), React$2.createElement(TokenText, {
2016
- className: tokenClassName,
2017
- text: text,
2018
- tokens: tokens,
2019
- onTokenClick: this.tokenClick,
2020
- onSelectToken: this.selectToken,
2021
- __self: this,
2022
- __source: {
2023
- fileName: _jsxFileName$2,
2024
- lineNumber: 132
2025
- }
2026
- }));
2027
- }
2028
- }
2029
- Tokenizer.__initStatic();
2030
- Tokenizer.__initStatic2();
2031
- var Tokenizer$1 = withStyles$2(theme => ({
2032
- text: {
2033
- marginTop: theme.spacing.unit,
2034
- paddingTop: theme.spacing.unit,
2035
- paddingBottom: theme.spacing.unit
2036
- },
2037
- noselect: {
2038
- ...noSelect()
2039
- }
2040
- }))(Tokenizer);
2041
- const React$3 = _dll_react;
2042
- const PropTypes$3 = _dll_prop_types;
2043
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
2044
- const {color: color} = _dll_pie_lib__render_ui;
2045
- const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/token-select/token.jsx";
2046
- const TokenTypes = {
2047
- text: PropTypes$3.string,
2048
- selectable: PropTypes$3.bool
2049
- };
2050
- class Token extends React$3.Component {
2051
- static __initStatic() {
2052
- this.rootClassName = 'tokenRootClass';
2053
- }
2054
- static __initStatic2() {
2055
- this.propTypes = {
2056
- ...TokenTypes,
2057
- classes: PropTypes$3.object.isRequired,
2058
- className: PropTypes$3.string,
2059
- disabled: PropTypes$3.bool,
2060
- highlight: PropTypes$3.bool,
2061
- correct: PropTypes$3.bool,
2062
- text: PropTypes$3.string.isRequired
2063
- };
2064
- }
2065
- static __initStatic3() {
2066
- this.defaultProps = {
2067
- selectable: false,
2068
- text: ''
2069
- };
2070
- }
2071
- render() {
2072
- const {text, selectable, selected, classes, className: classNameProp, disabled, index, highlight, correct} = this.props;
2073
- let className;
2074
- if (correct === undefined && selected && disabled) {
2075
- className = classnames(classes.token, classes.selected, classes.disabled);
2076
- } else if (correct !== undefined) {
2077
- className = classnames(Token.rootClassName, classes.custom, correct === true && classes.correct, correct === false && classes.incorrect);
2078
- } else {
2079
- className = classnames(Token.rootClassName, classes.token, disabled && classes.disabled, selectable && !disabled && classes.selectable, selected && !disabled && classes.selected, selected && disabled && classes.disabledAndSelected, highlight && selectable && !disabled && !selected && classes.highlight, classNameProp);
2080
- }
2081
- return React$3.createElement('span', {
2082
- className: className,
2083
- dangerouslySetInnerHTML: {
2084
- __html: (text || '').replace(/\n/g, '<br>')
2085
- },
2086
- 'data-indexkey': index,
2087
- __self: this,
2088
- __source: {
2089
- fileName: _jsxFileName$3,
2090
- lineNumber: 68
2091
- }
2092
- });
2093
- }
2094
- }
2095
- Token.__initStatic();
2096
- Token.__initStatic2();
2097
- Token.__initStatic3();
2098
- var Token$1 = withStyles$3(theme => {
2099
- return {
2100
- token: {
2101
- cursor: 'pointer',
2102
- textIndent: 0,
2103
- padding: theme.spacing.unit / 2,
2104
- paddingRight: 0,
2105
- paddingLeft: 0,
2106
- transition: 'background-color 100ms ease-in'
2107
- },
2108
- disabled: {
2109
- cursor: 'inherit',
2110
- color: 'grey'
2111
- },
2112
- disabledAndSelected: {
2113
- backgroundColor: 'pink'
2114
- },
2115
- selectable: {
2116
- '&:hover': {
2117
- backgroundColor: color.primaryLight(),
2118
- '& > *': {
2119
- backgroundColor: color.primaryLight()
2120
- }
2121
- }
2122
- },
2123
- selected: {
2124
- lineHeight: 2,
2125
- marginTop: theme.spacing.unit / 2,
2126
- '&:hover': {
2127
- backgroundColor: color.primaryLight()
2128
- },
2129
- backgroundColor: color.primaryLight(),
2130
- '& > *': {
2131
- backgroundColor: color.primaryLight()
2132
- }
2133
- },
2134
- highlight: {
2135
- border: 'dashed 2px gray',
2136
- lineHeight: 2,
2137
- boxSizing: 'border-box',
2138
- marginTop: theme.spacing.unit / 2,
2139
- display: 'inline-block',
2140
- padding: theme.spacing.unit
2141
- },
2142
- custom: {
2143
- display: 'initial'
2144
- },
2145
- correct: {
2146
- backgroundColor: color.correct()
2147
- },
2148
- incorrect: {
2149
- backgroundColor: color.incorrect()
2150
- }
2151
- };
2152
- })(Token);
2153
- const React$4 = _dll_react;
2154
- const PropTypes$4 = _dll_prop_types;
2155
- const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
2156
- const {clone: clone$2} = _dll_lodash;
2157
- const {renderToString: renderToString} = _dll_react_dom_server;
2158
- const _jsxFileName$4 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/token-select/index.jsx";
2159
- const log$1 = browser('@pie-lib:text-select:token-select');
2160
- class TokenSelect extends React$4.Component {
2161
- constructor(...args) {
2162
- super(...args);
2163
- TokenSelect.prototype.__init.call(this);
2164
- TokenSelect.prototype.__init2.call(this);
2165
- TokenSelect.prototype.__init3.call(this);
2166
- TokenSelect.prototype.__init4.call(this);
2167
- }
2168
- static __initStatic() {
2169
- this.propTypes = {
2170
- tokens: PropTypes$4.arrayOf(PropTypes$4.shape(TokenTypes)).isRequired,
2171
- className: PropTypes$4.string,
2172
- classes: PropTypes$4.object.isRequired,
2173
- onChange: PropTypes$4.func.isRequired,
2174
- disabled: PropTypes$4.bool,
2175
- highlightChoices: PropTypes$4.bool,
2176
- maxNoOfSelections: PropTypes$4.number
2177
- };
2178
- }
2179
- static __initStatic2() {
2180
- this.defaultProps = {
2181
- highlightChoices: false,
2182
- maxNoOfSelections: 0,
2183
- tokens: []
2184
- };
2185
- }
2186
- __init() {
2187
- this.selectedCount = () => this.props.tokens.filter(t => t.selected).length;
2188
- }
2189
- __init2() {
2190
- this.canSelectMore = selectedCount => {
2191
- const {maxNoOfSelections} = this.props;
2192
- log$1('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);
2193
- return maxNoOfSelections <= 0 || isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections;
2194
- };
2195
- }
2196
- __init3() {
2197
- this.toggleToken = event => {
2198
- const {target} = event;
2199
- const tokens = clone$2(this.props.tokens);
2200
- const targetSpanWrapper = target.closest(`.${Token$1.rootClassName}`);
2201
- const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
2202
- const t = targetedTokenIndex && tokens[targetedTokenIndex];
2203
- if (t && t.correct === undefined) {
2204
- const {onChange, maxNoOfSelections} = this.props;
2205
- const selected = !t.selected;
2206
- if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {
2207
- log$1('skip toggle max reached');
2208
- return;
2209
- }
2210
- const update = {
2211
- ...t,
2212
- selected: !t.selected
2213
- };
2214
- tokens.splice(targetedTokenIndex, 1, update);
2215
- onChange(tokens);
2216
- }
2217
- };
2218
- }
2219
- __init4() {
2220
- this.generateTokensInHtml = () => {
2221
- const {tokens, disabled, highlightChoices} = this.props;
2222
- const selectedCount = this.selectedCount();
2223
- const isLineBreak = text => text === '\n';
2224
- const isNewParagraph = text => text === '\n\n';
2225
- const reducer = (accumulator, t, index) => {
2226
- const selectable = t.selected || t.selectable && this.canSelectMore(selectedCount);
2227
- const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);
2228
- let finalAcc = accumulator;
2229
- if (isNewParagraph(t.text)) {
2230
- return finalAcc + '</p><p>';
2231
- }
2232
- if (isLineBreak(t.text)) {
2233
- return finalAcc + '<br>';
2234
- }
2235
- if (!disabled || showCorrectAnswer || t.selected) {
2236
- return finalAcc + renderToString(React$4.createElement(Token$1, {
2237
- key: index,
2238
- disabled: disabled,
2239
- index: index,
2240
- ...t,
2241
- selectable: selectable,
2242
- highlight: highlightChoices,
2243
- __self: this,
2244
- __source: {
2245
- fileName: _jsxFileName$4,
2246
- lineNumber: 97
2247
- }
2248
- }));
2249
- } else {
2250
- return accumulator + t.text;
2251
- }
2252
- };
2253
- const reduceResult = (tokens || []).reduce(reducer, '<p>');
2254
- return reduceResult + '</p>';
2255
- };
2256
- }
2257
- render() {
2258
- const {classes, className: classNameProp} = this.props;
2259
- const className = classnames(classes.tokenSelect, classNameProp);
2260
- const html = this.generateTokensInHtml();
2261
- return React$4.createElement('div', {
2262
- className: className,
2263
- dangerouslySetInnerHTML: {
2264
- __html: html
2265
- },
2266
- onClick: this.toggleToken,
2267
- __self: this,
2268
- __source: {
2269
- fileName: _jsxFileName$4,
2270
- lineNumber: 123
2271
- }
2272
- });
2273
- }
2274
- }
2275
- TokenSelect.__initStatic();
2276
- TokenSelect.__initStatic2();
2277
- var TokenSelect$1 = withStyles$4(() => ({
2278
- tokenSelect: {
2279
- backgroundColor: 'none',
2280
- whiteSpace: 'pre',
2281
- ...noSelect()
2282
- }
2283
- }))(TokenSelect);
2284
- const React$5 = _dll_react;
2285
- const PropTypes$5 = _dll_prop_types;
2286
- const _jsxFileName$5 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/text-select.jsx";
2287
- const log$2 = browser('@pie-lib:text-select');
2288
- class TextSelect extends React$5.Component {
2289
- constructor(...args) {
2290
- super(...args);
2291
- TextSelect.prototype.__init.call(this);
2292
- }
2293
- static __initStatic() {
2294
- this.propTypes = {
2295
- onChange: PropTypes$5.func,
2296
- disabled: PropTypes$5.bool,
2297
- tokens: PropTypes$5.arrayOf(PropTypes$5.shape(TokenTypes)).isRequired,
2298
- selectedTokens: PropTypes$5.arrayOf(PropTypes$5.shape(TokenTypes)).isRequired,
2299
- text: PropTypes$5.string.isRequired,
2300
- className: PropTypes$5.string,
2301
- highlightChoices: PropTypes$5.bool,
2302
- maxNoOfSelections: PropTypes$5.number
2303
- };
2304
- }
2305
- __init() {
2306
- this.change = tokens => {
2307
- const {onChange} = this.props;
2308
- if (!onChange) {
2309
- return;
2310
- }
2311
- const out = tokens.filter(t => t.selected).map(t => ({
2312
- start: t.start,
2313
- end: t.end
2314
- }));
2315
- onChange(out);
2316
- };
2317
- }
2318
- render() {
2319
- const {text, disabled, tokens, selectedTokens, className, highlightChoices, maxNoOfSelections} = this.props;
2320
- const normalized = normalize(text, tokens);
2321
- log$2('normalized: ', normalized);
2322
- const prepped = normalized.map(t => {
2323
- const selectedIndex = selectedTokens.findIndex(s => {
2324
- return s.start === t.start && s.end === t.end;
2325
- });
2326
- const selected = selectedIndex !== -1;
2327
- const correct = selected ? t.correct : undefined;
2328
- return {
2329
- ...t,
2330
- selectable: !disabled && t.predefined,
2331
- selected,
2332
- correct
2333
- };
2334
- });
2335
- return React$5.createElement(TokenSelect$1, {
2336
- highlightChoices: !disabled && highlightChoices,
2337
- className: className,
2338
- tokens: prepped,
2339
- disabled: disabled,
2340
- onChange: this.change,
2341
- maxNoOfSelections: maxNoOfSelections,
2342
- __self: this,
2343
- __source: {
2344
- fileName: _jsxFileName$5,
2345
- lineNumber: 63
2346
- }
2347
- });
2348
- }
2349
- }
2350
- TextSelect.__initStatic();
2351
- var s$1 = 1000;
2352
- var m$1 = s$1 * 60;
2353
- var h$1 = m$1 * 60;
2354
- var d$1 = h$1 * 24;
2355
- var w$1 = d$1 * 7;
2356
- var y$1 = d$1 * 365.25;
2357
- var ms$1 = function (val, options) {
2358
- options = options || ({});
2359
- var type = typeof val;
2360
- if (type === 'string' && val.length > 0) {
2361
- return parse$1(val);
2362
- } else if (type === 'number' && isFinite(val)) {
2363
- return options.long ? fmtLong$1(val) : fmtShort$1(val);
2364
- }
2365
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
2366
- };
2367
- function parse$1(str) {
2368
- str = String(str);
2369
- if (str.length > 100) {
2370
- return;
2371
- }
2372
- var match = (/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i).exec(str);
2373
- if (!match) {
2374
- return;
2375
- }
2376
- var n = parseFloat(match[1]);
2377
- var type = (match[2] || 'ms').toLowerCase();
2378
- switch (type) {
2379
- case 'years':
2380
- case 'year':
2381
- case 'yrs':
2382
- case 'yr':
2383
- case 'y':
2384
- return n * y$1;
2385
- case 'weeks':
2386
- case 'week':
2387
- case 'w':
2388
- return n * w$1;
2389
- case 'days':
2390
- case 'day':
2391
- case 'd':
2392
- return n * d$1;
2393
- case 'hours':
2394
- case 'hour':
2395
- case 'hrs':
2396
- case 'hr':
2397
- case 'h':
2398
- return n * h$1;
2399
- case 'minutes':
2400
- case 'minute':
2401
- case 'mins':
2402
- case 'min':
2403
- case 'm':
2404
- return n * m$1;
2405
- case 'seconds':
2406
- case 'second':
2407
- case 'secs':
2408
- case 'sec':
2409
- case 's':
2410
- return n * s$1;
2411
- case 'milliseconds':
2412
- case 'millisecond':
2413
- case 'msecs':
2414
- case 'msec':
2415
- case 'ms':
2416
- return n;
2417
- default:
2418
- return undefined;
2419
- }
2420
- }
2421
- function fmtShort$1(ms) {
2422
- var msAbs = Math.abs(ms);
2423
- if (msAbs >= d$1) {
2424
- return Math.round(ms / d$1) + 'd';
2425
- }
2426
- if (msAbs >= h$1) {
2427
- return Math.round(ms / h$1) + 'h';
2428
- }
2429
- if (msAbs >= m$1) {
2430
- return Math.round(ms / m$1) + 'm';
2431
- }
2432
- if (msAbs >= s$1) {
2433
- return Math.round(ms / s$1) + 's';
2434
- }
2435
- return ms + 'ms';
2436
- }
2437
- function fmtLong$1(ms) {
2438
- var msAbs = Math.abs(ms);
2439
- if (msAbs >= d$1) {
2440
- return plural$1(ms, msAbs, d$1, 'day');
2441
- }
2442
- if (msAbs >= h$1) {
2443
- return plural$1(ms, msAbs, h$1, 'hour');
2444
- }
2445
- if (msAbs >= m$1) {
2446
- return plural$1(ms, msAbs, m$1, 'minute');
2447
- }
2448
- if (msAbs >= s$1) {
2449
- return plural$1(ms, msAbs, s$1, 'second');
2450
- }
2451
- return ms + ' ms';
2452
- }
2453
- function plural$1(ms, msAbs, n, name) {
2454
- var isPlural = msAbs >= n * 1.5;
2455
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
2456
- }
2457
- function setup$1(env) {
2458
- createDebug.debug = createDebug;
2459
- createDebug.default = createDebug;
2460
- createDebug.coerce = coerce;
2461
- createDebug.disable = disable;
2462
- createDebug.enable = enable;
2463
- createDebug.enabled = enabled;
2464
- createDebug.humanize = ms$1;
2465
- Object.keys(env).forEach(function (key) {
2466
- createDebug[key] = env[key];
2467
- });
2468
- createDebug.instances = [];
2469
- createDebug.names = [];
2470
- createDebug.skips = [];
2471
- createDebug.formatters = {};
2472
- function selectColor(namespace) {
2473
- var hash = 0;
2474
- for (var i = 0; i < namespace.length; i++) {
2475
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
2476
- hash |= 0;
2477
- }
2478
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
2479
- }
2480
- createDebug.selectColor = selectColor;
2481
- function createDebug(namespace) {
2482
- var prevTime;
2483
- function debug() {
2484
- if (!debug.enabled) {
2485
- return;
2486
- }
2487
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2488
- args[_key] = arguments[_key];
2489
- }
2490
- var self = debug;
2491
- var curr = Number(new Date());
2492
- var ms = curr - (prevTime || curr);
2493
- self.diff = ms;
2494
- self.prev = prevTime;
2495
- self.curr = curr;
2496
- prevTime = curr;
2497
- args[0] = createDebug.coerce(args[0]);
2498
- if (typeof args[0] !== 'string') {
2499
- args.unshift('%O');
2500
- }
2501
- var index = 0;
2502
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
2503
- if (match === '%%') {
2504
- return match;
2505
- }
2506
- index++;
2507
- var formatter = createDebug.formatters[format];
2508
- if (typeof formatter === 'function') {
2509
- var val = args[index];
2510
- match = formatter.call(self, val);
2511
- args.splice(index, 1);
2512
- index--;
2513
- }
2514
- return match;
2515
- });
2516
- createDebug.formatArgs.call(self, args);
2517
- var logFn = self.log || createDebug.log;
2518
- logFn.apply(self, args);
2519
- }
2520
- debug.namespace = namespace;
2521
- debug.enabled = createDebug.enabled(namespace);
2522
- debug.useColors = createDebug.useColors();
2523
- debug.color = selectColor(namespace);
2524
- debug.destroy = destroy;
2525
- debug.extend = extend;
2526
- if (typeof createDebug.init === 'function') {
2527
- createDebug.init(debug);
2528
- }
2529
- createDebug.instances.push(debug);
2530
- return debug;
2531
- }
2532
- function destroy() {
2533
- var index = createDebug.instances.indexOf(this);
2534
- if (index !== -1) {
2535
- createDebug.instances.splice(index, 1);
2536
- return true;
2537
- }
2538
- return false;
2539
- }
2540
- function extend(namespace, delimiter) {
2541
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
2542
- }
2543
- function enable(namespaces) {
2544
- createDebug.save(namespaces);
2545
- createDebug.names = [];
2546
- createDebug.skips = [];
2547
- var i;
2548
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
2549
- var len = split.length;
2550
- for (i = 0; i < len; i++) {
2551
- if (!split[i]) {
2552
- continue;
2553
- }
2554
- namespaces = split[i].replace(/\*/g, '.*?');
2555
- if (namespaces[0] === '-') {
2556
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
2557
- } else {
2558
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
2559
- }
2560
- }
2561
- for (i = 0; i < createDebug.instances.length; i++) {
2562
- var instance = createDebug.instances[i];
2563
- instance.enabled = createDebug.enabled(instance.namespace);
2564
- }
2565
- }
2566
- function disable() {
2567
- createDebug.enable('');
2568
- }
2569
- function enabled(name) {
2570
- if (name[name.length - 1] === '*') {
2571
- return true;
2572
- }
2573
- var i;
2574
- var len;
2575
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
2576
- if (createDebug.skips[i].test(name)) {
2577
- return false;
2578
- }
2579
- }
2580
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
2581
- if (createDebug.names[i].test(name)) {
2582
- return true;
2583
- }
2584
- }
2585
- return false;
2586
- }
2587
- function coerce(val) {
2588
- if (val instanceof Error) {
2589
- return val.stack || val.message;
2590
- }
2591
- return val;
2592
- }
2593
- createDebug.enable(createDebug.load());
2594
- return createDebug;
2595
- }
2596
- var common$1 = setup$1;
2597
- var browser$1 = createCommonjsModule(function (module, exports) {
2598
- function _typeof(obj) {
2599
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
2600
- _typeof = function _typeof(obj) {
2601
- return typeof obj;
2602
- };
2603
- } else {
2604
- _typeof = function _typeof(obj) {
2605
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2606
- };
2607
- }
2608
- return _typeof(obj);
2609
- }
2610
- exports.log = log;
2611
- exports.formatArgs = formatArgs;
2612
- exports.save = save;
2613
- exports.load = load;
2614
- exports.useColors = useColors;
2615
- exports.storage = localstorage();
2616
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
2617
- function useColors() {
2618
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
2619
- return true;
2620
- }
2621
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
2622
- return false;
2623
- }
2624
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
2625
- }
2626
- function formatArgs(args) {
2627
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
2628
- if (!this.useColors) {
2629
- return;
2630
- }
2631
- var c = 'color: ' + this.color;
2632
- args.splice(1, 0, c, 'color: inherit');
2633
- var index = 0;
2634
- var lastC = 0;
2635
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
2636
- if (match === '%%') {
2637
- return;
2638
- }
2639
- index++;
2640
- if (match === '%c') {
2641
- lastC = index;
2642
- }
2643
- });
2644
- args.splice(lastC, 0, c);
2645
- }
2646
- function log() {
2647
- var _console;
2648
- return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
2649
- }
2650
- function save(namespaces) {
2651
- try {
2652
- if (namespaces) {
2653
- exports.storage.setItem('debug', namespaces);
2654
- } else {
2655
- exports.storage.removeItem('debug');
2656
- }
2657
- } catch (error) {}
2658
- }
2659
- function load() {
2660
- var r;
2661
- try {
2662
- r = exports.storage.getItem('debug');
2663
- } catch (error) {}
2664
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
2665
- r = process.env.DEBUG;
2666
- }
2667
- return r;
2668
- }
2669
- function localstorage() {
2670
- try {
2671
- return localStorage;
2672
- } catch (error) {}
2673
- }
2674
- module.exports = common$1(exports);
2675
- var formatters = module.exports.formatters;
2676
- formatters.j = function (v) {
2677
- try {
2678
- return JSON.stringify(v);
2679
- } catch (error) {
2680
- return '[UnexpectedJSONParseError]: ' + error.message;
2681
- }
2682
- };
2683
- });
2684
- browser$1.log;
2685
- browser$1.formatArgs;
2686
- browser$1.save;
2687
- browser$1.load;
2688
- browser$1.useColors;
2689
- browser$1.storage;
2690
- browser$1.colors;
2691
- const React$6 = _dll_react;
2692
- const PropTypes$6 = _dll_prop_types;
2693
- const {TextField: TextField} = _dll_material_ui__core;
2694
- const {Chip: Chip} = _dll_material_ui__core;
2695
- const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
2696
- const {cloneDeep: cloneDeep} = _dll_lodash;
2697
- const {debounce: debounce} = _dll_lodash;
2698
- const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
2699
- const {NumberTextField: NumberTextField} = _dll_pie_lib__config_ui;
2700
- const {FeedbackConfig: FeedbackConfig} = _dll_pie_lib__config_ui;
2701
- const {settings: settings} = _dll_pie_lib__config_ui;
2702
- const {layout: layout} = _dll_pie_lib__config_ui;
2703
- const EditableHtml = _dll_pie_lib__editable_html;
2704
- const _jsxFileName$6 = "/home/ede/dev/github/pie-framework/pie-elements/packages/select-text/configure/src/design.jsx";
2705
- const {Panel, toggle, radio} = settings;
2706
- const log$3 = browser$1('@pie-element:select-text:configure');
2707
- class Design extends React$6.Component {
2708
- static __initStatic() {
2709
- this.propTypes = {
2710
- model: PropTypes$6.object.isRequired,
2711
- configuration: PropTypes$6.object.isRequired,
2712
- classes: PropTypes$6.object.isRequired,
2713
- onModelChanged: PropTypes$6.func.isRequired,
2714
- onConfigurationChanged: PropTypes$6.func.isRequired,
2715
- imageSupport: PropTypes$6.shape({
2716
- add: PropTypes$6.func.isRequired,
2717
- delete: PropTypes$6.func.isRequired
2718
- })
2719
- };
2720
- }
2721
- static __initStatic2() {
2722
- this.defaultProps = {};
2723
- }
2724
- constructor(props) {
2725
- super(props);
2726
- Design.prototype.__init.call(this);
2727
- Design.prototype.__init2.call(this);
2728
- Design.prototype.__init3.call(this);
2729
- Design.prototype.__init4.call(this);
2730
- Design.prototype.__init5.call(this);
2731
- Design.prototype.__init6.call(this);
2732
- Design.prototype.__init7.call(this);
2733
- Design.prototype.__init8.call(this);
2734
- Design.prototype.__init9.call(this);
2735
- Design.prototype.__init10.call(this);
2736
- const {model} = this.props;
2737
- this.state = {
2738
- text: model && model.text || ''
2739
- };
2740
- }
2741
- UNSAFE_componentWillReceiveProps(nProps) {
2742
- const {model} = nProps;
2743
- if (model && model.text) {
2744
- this.setState({
2745
- text: model.text
2746
- });
2747
- }
2748
- }
2749
- __init() {
2750
- this.updateText = debounce(val => {
2751
- this.apply(u => {
2752
- u.text = val;
2753
- u.tokens = [];
2754
- });
2755
- }, 200);
2756
- }
2757
- __init2() {
2758
- this.changeText = event => {
2759
- const value = event.target.value;
2760
- const preparedText = value;
2761
- this.setState({
2762
- text: value
2763
- });
2764
- this.updateText(preparedText);
2765
- };
2766
- }
2767
- __init3() {
2768
- this.changeTokens = (tokens, mode) => {
2769
- this.apply(u => {
2770
- u.tokens = tokens;
2771
- u.mode = mode;
2772
- const correctTokenCount = tokens.filter(t => t.correct).length;
2773
- const max = isFinite(u.maxSelections) ? u.maxSelections : 0;
2774
- u.maxSelections = Math.max(max, correctTokenCount);
2775
- });
2776
- };
2777
- }
2778
- __init4() {
2779
- this.changeMaxSelections = (event, max) => {
2780
- this.apply(u => u.maxSelections = max);
2781
- };
2782
- }
2783
- __init5() {
2784
- this.apply = fn => {
2785
- const {onModelChanged, model} = this.props;
2786
- const update = cloneDeep(model);
2787
- fn(update);
2788
- onModelChanged(update);
2789
- };
2790
- }
2791
- __init6() {
2792
- this.changeFeedback = feedback => {
2793
- this.apply(u => u.feedback = feedback);
2794
- };
2795
- }
2796
- __init7() {
2797
- this.changePartialScoring = partialScoring => {
2798
- const {onModelChanged, model} = this.props;
2799
- const update = cloneDeep(model);
2800
- update.partialScoring = partialScoring;
2801
- onModelChanged(update);
2802
- };
2803
- }
2804
- __init8() {
2805
- this.onPromptChanged = prompt => {
2806
- const {onModelChanged, model} = this.props;
2807
- const update = cloneDeep(model);
2808
- update.prompt = prompt;
2809
- onModelChanged(update);
2810
- };
2811
- }
2812
- __init9() {
2813
- this.onTeacherInstructionsChanged = teacherInstructions => {
2814
- const {onModelChanged, model} = this.props;
2815
- const update = cloneDeep(model);
2816
- update.teacherInstructions = teacherInstructions;
2817
- onModelChanged(update);
2818
- };
2819
- }
2820
- __init10() {
2821
- this.onRationaleChanged = rationale => {
2822
- const {onModelChanged, model} = this.props;
2823
- onModelChanged({
2824
- ...model,
2825
- rationale
2826
- });
2827
- };
2828
- }
2829
- render() {
2830
- const {text: textValue} = this.state;
2831
- const {model, classes, imageSupport, onModelChanged, configuration, onConfigurationChanged} = this.props;
2832
- const {prompt = {}, text = {}, tokens = {}, mode = {}, feedback = {}, partialScoring = {}, selections = {}, selectionCount = {}, correctAnswer = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, scoringType = {}, highlightChoices = {}} = configuration || ({});
2833
- const {teacherInstructionsEnabled, promptEnabled, rationaleEnabled, feedbackEnabled} = model || ({});
2834
- log$3('[render] maxSelections:', model.maxSelections);
2835
- return React$6.createElement(layout.ConfigLayout, {
2836
- settings: React$6.createElement(Panel, {
2837
- model: model,
2838
- configuration: configuration,
2839
- onChangeModel: model => onModelChanged(model),
2840
- onChangeConfiguration: onConfigurationChanged,
2841
- groups: {
2842
- Settings: {
2843
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
2844
- highlightChoices: highlightChoices.settings && toggle(highlightChoices.label),
2845
- feedbackEnabled: feedback.settings && toggle(feedback.label)
2846
- },
2847
- Properties: {
2848
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
2849
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
2850
- promptEnabled: prompt.settings && toggle(prompt.label),
2851
- rationaleEnabled: rationale.settings && toggle(rationale.label),
2852
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
2853
- }
2854
- },
2855
- __self: this,
2856
- __source: {
2857
- fileName: _jsxFileName$6,
2858
- lineNumber: 169
2859
- }
2860
- }),
2861
- __self: this,
2862
- __source: {
2863
- fileName: _jsxFileName$6,
2864
- lineNumber: 167
2865
- }
2866
- }, React$6.createElement('div', {
2867
- className: classes.container,
2868
- __self: this,
2869
- __source: {
2870
- fileName: _jsxFileName$6,
2871
- lineNumber: 200
2872
- }
2873
- }, teacherInstructionsEnabled && React$6.createElement(InputContainer, {
2874
- label: teacherInstructions.label,
2875
- className: classes.promptHolder,
2876
- __self: this,
2877
- __source: {
2878
- fileName: _jsxFileName$6,
2879
- lineNumber: 202
2880
- }
2881
- }, React$6.createElement(EditableHtml, {
2882
- className: classes.prompt,
2883
- markup: model.teacherInstructions || '',
2884
- onChange: this.onTeacherInstructionsChanged,
2885
- imageSupport: imageSupport,
2886
- nonEmpty: false,
2887
- __self: this,
2888
- __source: {
2889
- fileName: _jsxFileName$6,
2890
- lineNumber: 206
2891
- }
2892
- })), promptEnabled && React$6.createElement(InputContainer, {
2893
- label: prompt.label || '',
2894
- className: classes.promptHolder,
2895
- __self: this,
2896
- __source: {
2897
- fileName: _jsxFileName$6,
2898
- lineNumber: 217
2899
- }
2900
- }, React$6.createElement(EditableHtml, {
2901
- className: classes.prompt,
2902
- markup: model.prompt,
2903
- onChange: this.onPromptChanged,
2904
- imageSupport: imageSupport,
2905
- __self: this,
2906
- __source: {
2907
- fileName: _jsxFileName$6,
2908
- lineNumber: 221
2909
- }
2910
- })), rationaleEnabled && React$6.createElement(InputContainer, {
2911
- label: rationale.label || '',
2912
- className: classes.promptHolder,
2913
- __self: this,
2914
- __source: {
2915
- fileName: _jsxFileName$6,
2916
- lineNumber: 231
2917
- }
2918
- }, React$6.createElement(EditableHtml, {
2919
- className: classes.prompt,
2920
- markup: model.rationale || '',
2921
- onChange: this.onRationaleChanged,
2922
- imageSupport: imageSupport,
2923
- __self: this,
2924
- __source: {
2925
- fileName: _jsxFileName$6,
2926
- lineNumber: 235
2927
- }
2928
- })), text.settings && React$6.createElement(TextField, {
2929
- label: text.label,
2930
- className: classes.input,
2931
- multiline: true,
2932
- value: textValue,
2933
- onChange: this.changeText,
2934
- __self: this,
2935
- __source: {
2936
- fileName: _jsxFileName$6,
2937
- lineNumber: 245
2938
- }
2939
- }), tokens.settings && React$6.createElement(InputContainer, {
2940
- label: tokens.label || '',
2941
- className: classes.tokenizerContainer,
2942
- __self: this,
2943
- __source: {
2944
- fileName: _jsxFileName$6,
2945
- lineNumber: 255
2946
- }
2947
- }, React$6.createElement(Tokenizer$1, {
2948
- className: classes.tokenizer,
2949
- text: model.text,
2950
- tokens: model.tokens,
2951
- onChange: this.changeTokens,
2952
- __self: this,
2953
- __source: {
2954
- fileName: _jsxFileName$6,
2955
- lineNumber: 259
2956
- }
2957
- })), mode.settings && React$6.createElement(Chip, {
2958
- label: `${mode.label}: ${model.mode ? model.mode : 'None'}`,
2959
- className: classes.chip,
2960
- __self: this,
2961
- __source: {
2962
- fileName: _jsxFileName$6,
2963
- lineNumber: 269
2964
- }
2965
- }), selections.settings && React$6.createElement(Chip, {
2966
- label: `${selections.label}: ${model.tokens.length}`,
2967
- className: classes.chip,
2968
- __self: this,
2969
- __source: {
2970
- fileName: _jsxFileName$6,
2971
- lineNumber: 276
2972
- }
2973
- }), correctAnswer.settings && React$6.createElement(Chip, {
2974
- label: `${correctAnswer.label}: ${model.tokens.filter(t => t.correct).length}`,
2975
- className: classes.chip,
2976
- __self: this,
2977
- __source: {
2978
- fileName: _jsxFileName$6,
2979
- lineNumber: 283
2980
- }
2981
- }), selectionCount.settings && React$6.createElement(NumberTextField, {
2982
- min: 0,
2983
- label: `${selectionCount.label} (0:any)`,
2984
- max: model.tokens.length,
2985
- value: model.maxSelections,
2986
- onChange: this.changeMaxSelections,
2987
- className: classes.numberField,
2988
- __self: this,
2989
- __source: {
2990
- fileName: _jsxFileName$6,
2991
- lineNumber: 292
2992
- }
2993
- }), feedbackEnabled && React$6.createElement(FeedbackConfig, {
2994
- feedback: model.feedback,
2995
- onChange: this.changeFeedback,
2996
- __self: this,
2997
- __source: {
2998
- fileName: _jsxFileName$6,
2999
- lineNumber: 303
3000
- }
3001
- })));
3002
- }
3003
- }
3004
- Design.__initStatic();
3005
- Design.__initStatic2();
3006
- var Main = withStyles$5(theme => ({
3007
- container: {
3008
- paddingTop: theme.spacing.unit
3009
- },
3010
- tokenizerContainer: {
3011
- paddingRight: 0,
3012
- marginRight: 0,
3013
- '&:after': {
3014
- position: 'absolute',
3015
- bottom: 0,
3016
- left: 0,
3017
- right: 0,
3018
- height: '1px',
3019
- content: '""',
3020
- backgroundColor: theme.palette.primary.main
3021
- },
3022
- marginBottom: theme.spacing.unit
3023
- },
3024
- chip: {
3025
- marginRight: theme.spacing.unit * 2
3026
- },
3027
- input: {
3028
- width: '100%',
3029
- paddingBottom: theme.spacing.unit * 3
3030
- },
3031
- tokenizer: {
3032
- marginTop: theme.spacing.unit * 2
3033
- },
3034
- mainOpts: {
3035
- width: '100%',
3036
- justifyContent: 'space-between',
3037
- display: 'flex',
3038
- alignItems: 'baseline'
3039
- },
3040
- promptHolder: {
3041
- width: '100%',
3042
- paddingBottom: theme.spacing.unit * 2,
3043
- marginBottom: theme.spacing.unit * 2
3044
- },
3045
- prompt: {
3046
- paddingTop: theme.spacing.unit * 2,
3047
- width: '100%'
3048
- },
3049
- numberField: {
3050
- width: '180px'
3051
- }
3052
- }))(Design);
3053
- const tokens = () => [{
3054
- text: '',
3055
- start: 0,
3056
- end: 0
3057
- }];
3058
- var defaultValues = {
3059
- model: {
3060
- highlightChoices: false,
3061
- partialScoring: false,
3062
- maxSelections: 2,
3063
- mode: 'sentence',
3064
- prompt: 'Question Prompt goes here',
3065
- text: '',
3066
- tokens: tokens(),
3067
- scoringType: 'auto',
3068
- feedbackEnabled: true,
3069
- rationaleEnabled: true,
3070
- promptEnabled: true,
3071
- teacherInstructionsEnabled: true,
3072
- studentInstructionsEnabled: true
3073
- },
3074
- configuration: {
3075
- selectionCount: {
3076
- settings: true,
3077
- label: 'Selection count'
3078
- },
3079
- correctAnswer: {
3080
- settings: true,
3081
- label: 'Correct Answers'
3082
- },
3083
- selections: {
3084
- settings: true,
3085
- label: 'Selections Available'
3086
- },
3087
- highlightChoices: {
3088
- settings: true,
3089
- label: 'Highlight choices'
3090
- },
3091
- rationale: {
3092
- settings: true,
3093
- label: 'Rationale'
3094
- },
3095
- scoringType: {
3096
- settings: false,
3097
- label: 'Scoring Type'
3098
- },
3099
- studentInstructions: {
3100
- settings: false,
3101
- label: 'Student Instructions'
3102
- },
3103
- teacherInstructions: {
3104
- settings: true,
3105
- label: 'Teacher Instructions'
3106
- },
3107
- prompt: {
3108
- label: 'Prompt',
3109
- settings: true
3110
- },
3111
- text: {
3112
- settings: true,
3113
- label: 'Content'
3114
- },
3115
- tokens: {
3116
- settings: true,
3117
- label: 'Tokens'
3118
- },
3119
- feedback: {
3120
- settings: true,
3121
- label: 'Feedback'
3122
- },
3123
- partialScoring: {
3124
- settings: false,
3125
- label: 'Allow Partial Scoring'
3126
- },
3127
- mode: {
3128
- settings: true,
3129
- label: 'Mode'
3130
- }
3131
- }
3132
- };
3133
- const createElementFromHTML = (htmlString = '') => {
3134
- const div = document.createElement('div');
3135
- div.innerHTML = htmlString.trim();
3136
- return div;
3137
- };
3138
- const parseBrs = dom => {
3139
- const brs = dom.querySelectorAll('br');
3140
- brs.forEach(br => br.replaceWith('\n'));
3141
- dom.innerHTML = dom.innerHTML.replace(/\n\n/g, '\n');
3142
- };
3143
- const parseParagraph = (paragraph, end) => {
3144
- if (end) {
3145
- return paragraph.innerHTML;
3146
- }
3147
- return `${paragraph.innerHTML}\n\n`;
3148
- };
3149
- const parseParagraphs = dom => {
3150
- const paragraphs = dom.querySelectorAll('p');
3151
- let str = '';
3152
- paragraphs.forEach((par, index) => {
3153
- str += parseParagraph(par, index === paragraphs.length - 1);
3154
- });
3155
- return str || null;
3156
- };
3157
- const prepareText = text => {
3158
- let txtDom = createElementFromHTML(text);
3159
- const allDomElements = Array.from(txtDom.querySelectorAll('*'));
3160
- if (txtDom.querySelectorAll('p').length === 0) {
3161
- const div = document.createElement('div');
3162
- div.innerHTML = `<p>${txtDom.innerHTML}</p>`;
3163
- txtDom = div;
3164
- }
3165
- if (allDomElements.length === 0) {
3166
- return text;
3167
- }
3168
- parseBrs(txtDom);
3169
- return parseParagraphs(txtDom);
3170
- };
3171
- const React$7 = _dll_react;
3172
- const ReactDOM = _dll_react_dom;
3173
- const {DeleteImageEvent: DeleteImageEvent} = _dll_pie_framework__pie_configure_events;
3174
- const {InsertImageEvent: InsertImageEvent} = _dll_pie_framework__pie_configure_events;
3175
- const {ModelUpdatedEvent: ModelUpdatedEvent} = _dll_pie_framework__pie_configure_events;
3176
- class SelectTextConfigure extends HTMLElement {
3177
- static __initStatic() {
3178
- this.createDefaultModel = (model = {}) => {
3179
- const newModel = {
3180
- ...defaultValues.model,
3181
- ...model
3182
- };
3183
- const newText = prepareText(newModel.text);
3184
- return {
3185
- ...newModel,
3186
- unpreparedText: newModel.text,
3187
- text: newText
3188
- };
3189
- };
3190
- }
3191
- constructor() {
3192
- super();
3193
- this._model = SelectTextConfigure.createDefaultModel();
3194
- this._configuration = defaultValues.configuration;
3195
- }
3196
- set model(m) {
3197
- this._model = SelectTextConfigure.createDefaultModel(m);
3198
- this.render();
3199
- }
3200
- set configuration(c) {
3201
- this._configuration = c;
3202
- this.render();
3203
- }
3204
- connectedCallback() {
3205
- this.render();
3206
- }
3207
- modelChanged(m) {
3208
- this._model = m;
3209
- this.dispatchEvent(new ModelUpdatedEvent(this._model), true);
3210
- this.render();
3211
- }
3212
- onConfigurationChanged(c) {
3213
- this._configuration = c;
3214
- if (this._model) {
3215
- this.dispatchEvent(new ModelUpdatedEvent(this._model), false);
3216
- }
3217
- this.render();
3218
- }
3219
- insertImage(handler) {
3220
- this.dispatchEvent(new InsertImageEvent(handler));
3221
- }
3222
- onDeleteImage(src, done) {
3223
- this.dispatchEvent(new DeleteImageEvent(src, done));
3224
- }
3225
- render() {
3226
- if (this._model) {
3227
- const el = React$7.createElement(Main, {
3228
- model: this._model,
3229
- configuration: this._configuration,
3230
- onModelChanged: this.modelChanged.bind(this),
3231
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
3232
- imageSupport: {
3233
- add: this.insertImage.bind(this),
3234
- delete: this.onDeleteImage.bind(this)
3235
- }
3236
- });
3237
- ReactDOM.render(el, this);
3238
- }
3239
- }
3240
- }
3241
- SelectTextConfigure.__initStatic();
3242
- export default SelectTextConfigure;