import '../../globals';
import { setActivityCallbacks } from '.';
import { Application } from '../../application';
import { isEmbedded } from '../embedding';
import { enableEdgeToEdge } from '../../utils/native-helper-for-android';
const EMPTY_FN = () => { };
if (!isEmbedded()) {
    /**
     * NOTE: We cannot use NativeClass here because this is used in appComponents in webpack.config
     * Whereby it bypasses the decorator transformation, hence pure es5 style written here
     */
    const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
    androidx.appcompat.app.AppCompatActivity.extend('com.tns.NativeScriptActivity', {
        init() {
            // init must at least be defined
        },
        onCreate(savedInstanceState) {
            Application.android.init(this.getApplication());
            // Set isNativeScriptActivity in onCreate.
            // The JS constructor might not be called because the activity is created from Android.
            this.isNativeScriptActivity = true;
            enableEdgeToEdge(this);
            if (!this._callbacks) {
                setActivityCallbacks(this);
            }
            this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
        },
        onNewIntent(intent) {
            this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent);
        },
        onSaveInstanceState(outState) {
            this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState);
        },
        onStart() {
            this._callbacks.onStart(this, superProto.onStart);
        },
        onStop() {
            this._callbacks.onStop(this, superProto.onStop);
        },
        onDestroy() {
            this._callbacks.onDestroy(this, superProto.onDestroy);
        },
        onPostResume() {
            this._callbacks.onPostResume(this, superProto.onPostResume);
        },
        onBackPressed() {
            this._callbacks.onBackPressed(this, superProto.onBackPressed);
        },
        onRequestPermissionsResult(requestCode, permissions, grantResults) {
            this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
        },
        onActivityResult(requestCode, resultCode, data) {
            this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult);
        },
    });
}
else {
    const Callbacks = com.tns.embedding.EmbeddableActivityCallbacks.extend({
        init() {
            // init must at least be defined
        },
        onCreate(savedInstanceState) {
            const activity = this.getActivity();
            Application.android.init(activity.getApplication());
            // Set isNativeScriptActivity in onCreate.
            // The JS constructor might not be called because the activity is created from Android.
            activity.isNativeScriptActivity = true;
            enableEdgeToEdge(this);
            if (!activity._callbacks) {
                setActivityCallbacks(activity);
            }
            activity._callbacks.onCreate(activity, savedInstanceState, activity.getIntent(), EMPTY_FN);
        },
        onNewIntent(intent) {
            const activity = this.getActivity();
            activity._callbacks.onNewIntent(activity, intent, EMPTY_FN, EMPTY_FN);
        },
        onSaveInstanceState(outState) {
            const activity = this.getActivity();
            activity._callbacks.onSaveInstanceState(activity, outState, EMPTY_FN);
        },
        onStart() {
            const activity = this.getActivity();
            activity._callbacks.onStart(activity, EMPTY_FN);
        },
        onStop() {
            const activity = this.getActivity();
            activity._callbacks.onStop(activity, EMPTY_FN);
        },
        onDestroy() {
            const activity = this.getActivity();
            activity._callbacks.onDestroy(activity, EMPTY_FN);
        },
        onPostResume() {
            const activity = this.getActivity();
            activity._callbacks.onPostResume(activity, EMPTY_FN);
        },
        onBackPressed() {
            const activity = this.getActivity();
            activity._callbacks.onBackPressed(activity, EMPTY_FN);
        },
        onRequestPermissionsResult(requestCode, permissions, grantResults) {
            const activity = this.getActivity();
            activity._callbacks.onRequestPermissionsResult(activity, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
        },
        onActivityResult(requestCode, resultCode, data) {
            const activity = this.getActivity();
            activity._callbacks.onActivityResult(activity, requestCode, resultCode, data, EMPTY_FN);
        },
    });
    com.tns.embedding.CallbacksStore.setActivityCallbacks(new Callbacks());
}
//# sourceMappingURL=activity.android.js.map