| 304 | } |
| 305 | |
| 306 | func normalizeInt(value any) (int64, error) { |
| 307 | switch current := value.(type) { |
| 308 | case int: |
| 309 | return int64(current), nil |
| 310 | case int32: |
| 311 | return int64(current), nil |
| 312 | case int64: |
| 313 | return current, nil |
| 314 | case float64: |
| 315 | return int64(current), nil |
| 316 | case string: |
| 317 | parsed, err := strconv.ParseInt(current, 10, 64) |
| 318 | if err != nil { |
| 319 | return 0, fmt.Errorf("parse int %q: %w", current, err) |
| 320 | } |
| 321 | return parsed, nil |
| 322 | default: |
| 323 | return 0, fmt.Errorf("unsupported integer result type %T", value) |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | func wrapQJSScript(script string) string { |
| 328 | return script |