/**
 * Modern Albufeira Prolog Interpreter
 *
 * Warranty & Liability
 * To the extent permitted by applicable law and unless explicitly
 * otherwise agreed upon, XLOG Technologies AG makes no warranties
 * regarding the provided information. XLOG Technologies AG assumes
 * no liability that any problems might be solved with the information
 * provided by XLOG Technologies AG.
 *
 * Rights & License
 * All industrial property rights regarding the information - copyright
 * and patent rights in particular - are the sole property of XLOG
 * Technologies AG. If the company was not the originator of some
 * excerpts, XLOG Technologies AG has at least obtained the right to
 * reproduce, change and translate the information.
 *
 * Reproduction is restricted to the whole unaltered document. Reproduction
 * of the information is only allowed for non-commercial uses. Selling,
 * giving away or letting of the execution of the library is prohibited.
 * The library can be distributed as part of your applications and libraries
 * for execution provided this comment remains unchanged.
 *
 * Restrictions
 * Only to be distributed with programs that add significant and primary
 * functionality to the library. Not to be distributed with additional
 * software intended to replace any components of the library.
 *
 * Trademarks
 * Jekejeke is a registered trademark of XLOG Technologies AG.
 */

/*********************************************************************/
/* Import Native API                                                 */
/*********************************************************************/

/* embedding native API */
import {Clause, add, Cache, make_defined, engine, set_stage,
    clear, stage, is_provable, Goal, is_cache, set_partition
} from "./store.mjs";
import {
    run, ctx, Context, VOID_ARGS, launch_async, launch,
    task_async, callback
} from "./machine.mjs";
import {check_goal, check_clause, check_provable
} from "./runtime.mjs";

/* engine native API */
import {
    is_compound, Item, is_logical, is_stick,
    stack_push, stack_peek, stack_pop, size_peek,
    Place, Skeleton, is_skeleton, Quote, check_nonvar,
} from "./store.mjs";
import {
    call, cont, unify, make_error, fs, url, gc_time,
    real_time, set_temp_display,
    register_signal, register_interrupt, gc_enter,
    gc_maxinfs, gc_major, is_frozen, Frozen, is_special
} from "./machine.mjs";
import {
    check_atom, check_number, make_arithmetic, make_check,
    check_callable,
    check_integer, check_atomic, MAX_ARITY, check_nil
} from "./special.mjs";

/* term native API */
import {Variable, is_variable, Compound, is_structure,
    VAR_MASK_SEEN, VAR_MASK_STATE, VAR_MASK_SERNO,
    copy_term, deref, variable_serno
} from "./store.mjs";
import {
    is_atom, is_number, is_integer, is_float, exec_deref,
    exec_eval, exec_unify, union_undo, is_bigint, object_hash_code,
    exec_build, bind, trail, union_find, union_add, is_pending
} from "./machine.mjs";
import {
    objects_list, list_objects, walk_vars
} from "./special.mjs";
import {equal_term, walk_uncompute, walk_compute, Triple, is_triple
} from "./eval.mjs";

/* stream native API */
import {Source, Sink, stream_close, stream_flush,
    check_source, check_sink, put_atom, codebase, MASK_DST_FEAT,
    get_encoding, MASK_SRC_AREAD, map_stream_error,
    bootbase, set_bootbase, set_codebase, file_read_promise
} from "./runtime.mjs";

/* theatre native API */
import {
    post, perform, goto_async, FFI_FUNC, register,
    instrument_document_async, perform_async,
} from "./theatre.mjs";

/* specific native API */
import {
    norm_smallint, norm_bigint, widen_bigint,
    char_count, narrow_float, norm_float, make_special,
} from "./special.mjs";

/* specific browser API */
import {
    fiddle_out, fiddle_in_promise, html_send, html_encode,
    set_cursor, set_caret_wait, set_input, fiddle_flush,
    set_to_list
} from "./theatre.mjs";

/*********************************************************************/
/* Export Native API                                                 */
/*********************************************************************/

/* embedding native API */
export {add, Clause, run, check_goal, clear, set_partition,
    Goal, Cache, make_defined, set_stage, VOID_ARGS,
    Context, is_provable, is_cache, launch_async, launch,
    task_async, callback}

/* engine native API */
export function get_cont() {
    return call;
}
export function get_mark() {
    return trail;
}
export function get_engine() {
    return engine;
}
export function get_ctx() {
    return ctx;
}
export function get_stage() {
    return stage;
}
export function get_codebase() {
    return codebase;
}
export function get_gc_enter() {
    return gc_enter;
}
export function get_gc_time() {
    return gc_time;
}
export function get_gc_maxinfs() {
    return gc_maxinfs;
}
export function get_bootbase() {
    return bootbase;
}

export {make_special, make_arithmetic, check_atomic, is_frozen,
    make_check, cont, make_error, check_clause, register_interrupt,
    check_nonvar, check_atom, fs, url, register_signal, MAX_ARITY,
    check_number, check_integer, check_callable, Item, check_nil,
    real_time, gc_major, Frozen, stack_push, stack_peek,
    call, set_temp_display, Quote,
    stack_pop, is_compound, check_provable, is_logical,
    size_peek, is_stick, Place, Skeleton, is_skeleton}

/* term native API */
export {Variable, Compound, is_variable, is_structure,
    is_atom, is_number, is_integer, is_float,
    exec_deref, is_pending, norm_float, walk_compute,
    union_find, union_add, union_undo, walk_vars,
    VAR_MASK_SEEN, VAR_MASK_SERNO, VAR_MASK_STATE,
    equal_term, bind, exec_unify, variable_serno,
    Triple, is_triple, set_to_list, unify,
    deref, copy_term, exec_eval, exec_build,
    objects_list, list_objects, walk_uncompute}

/* stream native API */
export {Source, Sink, stream_close, stream_flush,
    check_source, check_sink, put_atom, MASK_DST_FEAT,
    MASK_SRC_AREAD, get_encoding, map_stream_error,
    set_bootbase, set_codebase, file_read_promise}

/* theatre native API */
export {post, perform, goto_async, FFI_FUNC, register,
    instrument_document_async, perform_async}

/* specific native API */
export {is_bigint, norm_smallint, widen_bigint, is_special,
    norm_bigint, narrow_float, char_count, object_hash_code}

/* specific browser API */
export {fiddle_out, fiddle_in_promise, html_send, html_encode,
    set_cursor, set_caret_wait, set_input, fiddle_flush}