| 198 | }); |
| 199 | } |
| 200 | function formOk(form: string, text: string) { |
| 201 | if (form === 'polynomial') return !/sqrt|√|abs|\|/i.test(text) && !/\^\s*\(?-?\d*\s*\/\s*\d/.test(text) && !/\^-?0?\.\d/.test(text); |
| 202 | // "expanded" = no remaining grouped factor. CE's plain-text form |
| 203 | // parenthesizes multi-digit exponents (x^(31)) — those are not groups. |
| 204 | if (form === 'expanded') return !text.replace(/\^\(-?\d+\)/g, '^#').includes('('); |
| 205 | return true; |
| 206 | } |
| 207 | function classify(c: any, res: any) { |
| 208 | if (!res || res.status === 'error') return { v: 'error', note: res?.error }; |
| 209 | if (res.status === 'timeout') return { v: 'error', note: 'timeout' }; |