/* action-list-model.c generated by valac 0.56.19, the Vala compiler
 * generated from action-list-model.vala, do not modify */

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_core.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	FT_ACTION_LIST_MODEL_0_PROPERTY,
	FT_ACTION_LIST_MODEL_N_ITEMS_PROPERTY,
	FT_ACTION_LIST_MODEL_NUM_PROPERTIES
};
static GParamSpec* ft_action_list_model_properties[FT_ACTION_LIST_MODEL_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define _g_settings_schema_unref0(var) ((var == NULL) ? NULL : (var = (g_settings_schema_unref (var), NULL)))
enum  {
	FT_ACTION_LIST_MODEL_ACTION_ADDED_SIGNAL,
	FT_ACTION_LIST_MODEL_ACTION_REMOVED_SIGNAL,
	FT_ACTION_LIST_MODEL_NUM_SIGNALS
};
static guint ft_action_list_model_signals[FT_ACTION_LIST_MODEL_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtActionListModelPrivate {
	GHashTable* actions;
	gchar** uuids;
	gint uuids_length1;
	gint _uuids_size_;
	guint _n_items;
	GSettings* settings;
	gulong settings_changed_id;
	gint settings_changed_inhibit_count;
};

struct _Block1Data {
	int _ref_count_;
	FtActionListModel* self;
	gchar* uuid;
};

static gint FtActionListModel_private_offset;
static gpointer ft_action_list_model_parent_class = NULL;
static GListModelInterface * ft_action_list_model_g_list_model_parent_iface = NULL;

static void ft_action_list_model_load_uuids (FtActionListModel* self);
static void _g_free0_ (gpointer var);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void ft_action_list_model_save_uuids (FtActionListModel* self);
static GSettings* ft_action_list_model_create_action_settings (FtActionListModel* self,
                                                        const gchar* uuid);
static void ft_action_list_model_inhibit_settings_changed (FtActionListModel* self);
static void ft_action_list_model_uninhibit_settings_changed (FtActionListModel* self);
static FtAction* ft_action_list_model_load_action (FtActionListModel* self,
                                            const gchar* uuid);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda74_ (Block1Data* _data1_,
                  const gchar* key);
static void ft_action_list_model_reload_action (FtActionListModel* self,
                                         const gchar* uuid);
static void ___lambda74__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void ft_action_list_model_load (FtActionListModel* self);
static void ft_action_list_model_on_settings_changed (FtActionListModel* self,
                                               GSettings* settings,
                                               const gchar* key);
static GType ft_action_list_model_real_get_item_type (GListModel* base);
static guint ft_action_list_model_real_get_n_items (GListModel* base);
static GObject* ft_action_list_model_real_get_item (GListModel* base,
                                             guint position);
VALA_EXTERN void ft_action_set_uuid_internal (FtAction* self,
                                  const gchar* uuid);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gchar** _vala_array_dup2 (gchar** self,
                          gssize length);
static void ft_action_list_model_real_dispose (GObject* base);
static GObject * ft_action_list_model_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void _g_object_unref0_ (gpointer var);
static void _ft_action_list_model_on_settings_changed_g_settings_changed (GSettings* _sender,
                                                                   const gchar* key,
                                                                   gpointer self);
static void ft_action_list_model_finalize (GObject * obj);
static GType ft_action_list_model_get_type_once (void);
static void _vala_ft_action_list_model_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
ft_action_list_model_get_instance_private (FtActionListModel* self)
{
	return G_STRUCT_MEMBER_P (self, FtActionListModel_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_vala_array_add2 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
ft_action_list_model_load_uuids (FtActionListModel* self)
{
	gchar** uuids = NULL;
	GSettings* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint uuids_length1;
	gint _uuids_size_;
	GHashTable* unique_uuids = NULL;
	GHashFunc _tmp3_;
	GEqualFunc _tmp4_;
	GHashTable* _tmp5_;
	gint _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	_tmp2_ = _tmp1_ = g_settings_get_strv (_tmp0_, "actions");
	uuids = _tmp2_;
	uuids_length1 = _vala_array_length (_tmp1_);
	_uuids_size_ = uuids_length1;
	_tmp3_ = g_str_hash;
	_tmp4_ = g_str_equal;
	_tmp5_ = g_hash_table_new_full (_tmp3_, _tmp4_, NULL, _g_free0_);
	unique_uuids = _tmp5_;
	_tmp6_ = 0;
	self->priv->uuids = g_renew (gchar*, self->priv->uuids, 0);
	(_tmp6_ > self->priv->uuids_length1) ? memset (self->priv->uuids + self->priv->uuids_length1, 0, sizeof (gchar*) * (_tmp6_ - self->priv->uuids_length1)) : NULL;
	self->priv->uuids_length1 = _tmp6_;
	self->priv->_uuids_size_ = _tmp6_;
	self->priv->_n_items = (guint) 0;
	_tmp7_ = uuids;
	_tmp7__length1 = uuids_length1;
	{
		gchar** uuid_collection = NULL;
		gint uuid_collection_length1 = 0;
		gint _uuid_collection_size_ = 0;
		gint uuid_it = 0;
		uuid_collection = _tmp7_;
		uuid_collection_length1 = _tmp7__length1;
		for (uuid_it = 0; uuid_it < uuid_collection_length1; uuid_it = uuid_it + 1) {
			gchar* _tmp8_;
			gchar* uuid = NULL;
			_tmp8_ = g_strdup (uuid_collection[uuid_it]);
			uuid = _tmp8_;
			{
				GHashTable* _tmp9_;
				const gchar* _tmp10_;
				_tmp9_ = unique_uuids;
				_tmp10_ = uuid;
				if (!g_hash_table_contains (_tmp9_, _tmp10_)) {
					const gchar* _tmp11_;
					gchar* _tmp12_;
					guint _tmp13_;
					GHashTable* _tmp14_;
					const gchar* _tmp15_;
					gchar* _tmp16_;
					_tmp11_ = uuid;
					_tmp12_ = g_strdup (_tmp11_);
					_vala_array_add2 (&self->priv->uuids, &self->priv->uuids_length1, &self->priv->_uuids_size_, _tmp12_);
					_tmp13_ = self->priv->_n_items;
					self->priv->_n_items = _tmp13_ + 1;
					_tmp14_ = unique_uuids;
					_tmp15_ = uuid;
					_tmp16_ = g_strdup (_tmp15_);
					g_hash_table_add (_tmp14_, _tmp16_);
				}
				_g_free0 (uuid);
			}
		}
	}
	_g_hash_table_unref0 (unique_uuids);
	uuids = (_vala_array_free (uuids, uuids_length1, (GDestroyNotify) g_free), NULL);
}

static void
ft_action_list_model_save_uuids (FtActionListModel* self)
{
	GSettings* _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = self->priv->uuids;
	_tmp1__length1 = self->priv->uuids_length1;
	g_settings_set_strv (_tmp0_, "actions", _tmp1_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static GSettings*
ft_action_list_model_create_action_settings (FtActionListModel* self,
                                             const gchar* uuid)
{
	FtAction* _tmp0_ = NULL;
	GHashTable* _tmp1_;
	gconstpointer _tmp2_;
	GSettings* _tmp3_ = NULL;
	GSettings* existing_settings = NULL;
	GSettings* _tmp6_;
	GSettings* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GSettings* _tmp11_;
	GSettings* _tmp12_;
	GSettings* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uuid != NULL, NULL);
	_vala_return_val_if_fail ((uuid != NULL) && (g_strcmp0 (uuid, "") != 0), "uuid != null && uuid != \"\"", NULL);
	_tmp1_ = self->priv->actions;
	_tmp2_ = g_hash_table_lookup (_tmp1_, uuid);
	_tmp0_ = (FtAction*) _tmp2_;
	_tmp3_ = NULL;
	if (_tmp0_ != NULL) {
		GSettings* _tmp4_;
		GSettings* _tmp5_;
		_tmp4_ = ft_action_get_settings (_tmp0_);
		_tmp5_ = _tmp4_;
		_tmp3_ = _tmp5_;
	}
	_tmp6_ = _g_object_ref0 (_tmp3_);
	existing_settings = _tmp6_;
	_tmp7_ = existing_settings;
	if (_tmp7_ != NULL) {
		result = existing_settings;
		return result;
	}
	_tmp8_ = string_to_string (uuid);
	_tmp9_ = g_strconcat ("/io/github/focustimerhq/FocusTimer/actions/", _tmp8_, "/", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_settings_new_with_path ("io.github.focustimerhq.FocusTimer.actions.action", _tmp10_);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp10_);
	result = _tmp12_;
	_g_object_unref0 (existing_settings);
	return result;
}

static void
ft_action_list_model_inhibit_settings_changed (FtActionListModel* self)
{
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings_changed_inhibit_count;
	self->priv->settings_changed_inhibit_count = _tmp0_ + 1;
}

static void
ft_action_list_model_uninhibit_settings_changed (FtActionListModel* self)
{
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings_changed_inhibit_count;
	self->priv->settings_changed_inhibit_count = _tmp0_ - 1;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		FtActionListModel* self;
		self = _data1_->self;
		_g_free0 (_data1_->uuid);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda74_ (Block1Data* _data1_,
             const gchar* key)
{
	FtActionListModel* self;
	self = _data1_->self;
	g_return_if_fail (key != NULL);
	if (self->priv->settings_changed_inhibit_count > 0) {
		return;
	}
	if (g_strcmp0 (key, "trigger") == 0) {
		ft_action_list_model_reload_action (self, _data1_->uuid);
	}
}

static void
___lambda74__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda74_ (self, key);
}

static FtAction*
ft_action_list_model_load_action (FtActionListModel* self,
                                  const gchar* uuid)
{
	Block1Data* _data1_;
	gchar* _tmp0_;
	GSettings* settings = NULL;
	GSettings* _tmp1_;
	FtAction* action = NULL;
	FtAction* _tmp2_;
	GHashTable* _tmp3_;
	gchar* _tmp4_;
	FtAction* _tmp5_;
	FtAction* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uuid != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = g_strdup (uuid);
	_g_free0 (_data1_->uuid);
	_data1_->uuid = _tmp0_;
	_tmp1_ = ft_action_list_model_create_action_settings (self, _data1_->uuid);
	settings = _tmp1_;
	_tmp2_ = ft_action_list_model_create_action (self, _data1_->uuid, g_settings_get_enum (settings, "trigger"));
	action = _tmp2_;
	ft_action_load (action, settings);
	_tmp3_ = self->priv->actions;
	_tmp4_ = g_strdup (_data1_->uuid);
	_tmp5_ = _g_object_ref0 (action);
	g_hash_table_insert (_tmp3_, _tmp4_, _tmp5_);
	g_signal_connect_data (settings, "changed", (GCallback) ___lambda74__g_settings_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	result = action;
	_g_object_unref0 (settings);
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}

static void
ft_action_list_model_reload_action (FtActionListModel* self,
                                    const gchar* uuid)
{
	FtAction* action = NULL;
	FtAction* _tmp0_;
	gint position = 0;
	FtAction* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uuid != NULL);
	_tmp0_ = ft_action_list_model_load_action (self, uuid);
	action = _tmp0_;
	_tmp1_ = action;
	_tmp2_ = ft_action_get_uuid (_tmp1_);
	_tmp3_ = _tmp2_;
	position = ft_action_list_model_index (self, _tmp3_);
	if (position >= 0) {
		g_list_model_items_changed ((GListModel*) self, (guint) position, 1U, 1U);
	}
	_g_object_unref0 (action);
}

static void
ft_action_list_model_load (FtActionListModel* self)
{
	guint previous_n_items = 0U;
	gchar** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	previous_n_items = self->priv->_n_items;
	ft_action_list_model_load_uuids (self);
	_tmp0_ = self->priv->uuids;
	_tmp0__length1 = self->priv->uuids_length1;
	{
		gchar** uuid_collection = NULL;
		gint uuid_collection_length1 = 0;
		gint _uuid_collection_size_ = 0;
		gint uuid_it = 0;
		uuid_collection = _tmp0_;
		uuid_collection_length1 = _tmp0__length1;
		for (uuid_it = 0; uuid_it < uuid_collection_length1; uuid_it = uuid_it + 1) {
			gchar* _tmp1_;
			gchar* uuid = NULL;
			_tmp1_ = g_strdup (uuid_collection[uuid_it]);
			uuid = _tmp1_;
			{
				const gchar* _tmp2_;
				FtAction* _tmp3_;
				FtAction* _tmp4_;
				_tmp2_ = uuid;
				_tmp3_ = ft_action_list_model_load_action (self, _tmp2_);
				_tmp4_ = _tmp3_;
				_g_object_unref0 (_tmp4_);
				_g_free0 (uuid);
			}
		}
	}
	g_list_model_items_changed ((GListModel*) self, (guint) 0, self->priv->_n_items, previous_n_items);
}

static void
ft_action_list_model_on_settings_changed (FtActionListModel* self,
                                          GSettings* settings,
                                          const gchar* key)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (settings != NULL);
	g_return_if_fail (key != NULL);
	if (self->priv->settings_changed_inhibit_count > 0) {
		return;
	}
	_tmp0_ = key;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("actions")))) {
		switch (0) {
			default:
			{
				break;
			}
		}
	}
}

static GType
ft_action_list_model_real_get_item_type (GListModel* base)
{
	FtActionListModel * self;
	GType result;
	self = (FtActionListModel*) base;
	result = FT_TYPE_ACTION;
	return result;
}

static guint
ft_action_list_model_real_get_n_items (GListModel* base)
{
	FtActionListModel * self;
	guint result;
	self = (FtActionListModel*) base;
	result = self->priv->_n_items;
	return result;
}

static GObject*
ft_action_list_model_real_get_item (GListModel* base,
                                    guint position)
{
	FtActionListModel * self;
	gchar* uuid = NULL;
	gchar** _tmp0_;
	gint _tmp0__length1;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	FtAction* action = NULL;
	GHashTable* _tmp3_;
	const gchar* _tmp4_;
	gconstpointer _tmp5_;
	FtAction* _tmp6_;
	FtAction* _tmp7_;
	FtAction* _tmp10_;
	GObject* _tmp11_;
	GObject* result;
	self = (FtActionListModel*) base;
	if (position >= self->priv->_n_items) {
		result = NULL;
		return result;
	}
	_tmp0_ = self->priv->uuids;
	_tmp0__length1 = self->priv->uuids_length1;
	_tmp1_ = _tmp0_[position];
	_tmp2_ = g_strdup (_tmp1_);
	uuid = _tmp2_;
	_tmp3_ = self->priv->actions;
	_tmp4_ = uuid;
	_tmp5_ = g_hash_table_lookup (_tmp3_, _tmp4_);
	_tmp6_ = _g_object_ref0 ((FtAction*) _tmp5_);
	action = _tmp6_;
	_tmp7_ = action;
	if (_tmp7_ == NULL) {
		const gchar* _tmp8_;
		FtAction* _tmp9_;
		_tmp8_ = uuid;
		_tmp9_ = ft_action_list_model_load_action (self, _tmp8_);
		_g_object_unref0 (action);
		action = _tmp9_;
	}
	_tmp10_ = action;
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, G_TYPE_OBJECT, GObject));
	result = _tmp11_;
	_g_object_unref0 (action);
	_g_free0 (uuid);
	return result;
}

gint
ft_action_list_model_index (FtActionListModel* self,
                            const gchar* uuid)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (uuid != NULL, -1);
	{
		gint position = 0;
		position = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gchar** _tmp2_;
				gint _tmp2__length1;
				const gchar* _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = position;
					position = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(((guint) position) < self->priv->_n_items)) {
					break;
				}
				_tmp2_ = self->priv->uuids;
				_tmp2__length1 = self->priv->uuids_length1;
				_tmp3_ = _tmp2_[position];
				if (g_strcmp0 (_tmp3_, uuid) == 0) {
					result = position;
					return result;
				}
			}
		}
	}
	result = -1;
	return result;
}

FtAction*
ft_action_list_model_lookup (FtActionListModel* self,
                             const gchar* uuid)
{
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	FtAction* _tmp2_;
	FtAction* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = self->priv->actions;
	_tmp1_ = g_hash_table_lookup (_tmp0_, uuid);
	_tmp2_ = _g_object_ref0 ((FtAction*) _tmp1_);
	result = _tmp2_;
	return result;
}

/**
         * Initialize an action instance.
         */
FtAction*
ft_action_list_model_create_action (FtActionListModel* self,
                                    const gchar* uuid,
                                    FtActionTrigger trigger)
{
	FtAction* result;
	g_return_val_if_fail (self != NULL, NULL);
	switch (trigger) {
		case FT_ACTION_TRIGGER_EVENT:
		{
			FtEventAction* _tmp0_;
			_tmp0_ = ft_event_action_new (uuid);
			result = (FtAction*) _tmp0_;
			return result;
		}
		case FT_ACTION_TRIGGER_CONDITION:
		{
			FtConditionAction* _tmp1_;
			_tmp1_ = ft_condition_action_new (uuid);
			result = (FtAction*) _tmp1_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static void
_vala_array_add3 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

void
ft_action_list_model_save_action (FtActionListModel* self,
                                  FtAction* action)
{
	gboolean creating = FALSE;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GSettings* settings = NULL;
	GSettings* _tmp2_;
	GSettings* _tmp3_;
	GSettings* _tmp4_;
	guint position = 0U;
	FtAction* previous_action = NULL;
	GSettings* _tmp14_;
	GHashTable* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	FtAction* _tmp22_;
	GSettings* _tmp23_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = ft_action_get_uuid (action);
	_tmp1_ = _tmp0_;
	creating = _tmp1_ == NULL;
	_tmp2_ = ft_action_get_settings (action);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	settings = _tmp4_;
	position = 0U;
	previous_action = NULL;
	if (creating) {
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = g_uuid_string_random ();
		_tmp6_ = _tmp5_;
		ft_action_set_uuid_internal (action, _tmp6_);
		_g_free0 (_tmp6_);
		position = self->priv->_n_items;
	} else {
		gint index = 0;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = ft_action_get_uuid (action);
		_tmp8_ = _tmp7_;
		index = ft_action_list_model_index (self, _tmp8_);
		if (index >= 0) {
			GHashTable* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gconstpointer _tmp12_;
			FtAction* _tmp13_;
			position = (guint) index;
			_tmp9_ = self->priv->actions;
			_tmp10_ = ft_action_get_uuid (action);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_hash_table_lookup (_tmp9_, _tmp11_);
			_tmp13_ = _g_object_ref0 ((FtAction*) _tmp12_);
			_g_object_unref0 (previous_action);
			previous_action = _tmp13_;
		} else {
			creating = TRUE;
			position = self->priv->_n_items;
		}
	}
	_tmp14_ = settings;
	if (_tmp14_ == NULL) {
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		GSettings* _tmp17_;
		_tmp15_ = ft_action_get_uuid (action);
		_tmp16_ = _tmp15_;
		_tmp17_ = ft_action_list_model_create_action_settings (self, _tmp16_);
		_g_object_unref0 (settings);
		settings = _tmp17_;
	}
	_tmp18_ = self->priv->actions;
	_tmp19_ = ft_action_get_uuid (action);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strdup (_tmp20_);
	_tmp22_ = _g_object_ref0 (action);
	g_hash_table_insert (_tmp18_, _tmp21_, _tmp22_);
	ft_action_list_model_inhibit_settings_changed (self);
	_tmp23_ = settings;
	ft_action_save (action, _tmp23_);
	ft_action_list_model_uninhibit_settings_changed (self);
	if (creating) {
		const gchar* _tmp24_;
		const gchar* _tmp25_;
		gchar* _tmp26_;
		guint _tmp27_;
		_tmp24_ = ft_action_get_uuid (action);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strdup (_tmp25_);
		_vala_array_add3 (&self->priv->uuids, &self->priv->uuids_length1, &self->priv->_uuids_size_, _tmp26_);
		_tmp27_ = self->priv->_n_items;
		self->priv->_n_items = _tmp27_ + 1;
		ft_action_list_model_save_uuids (self);
		g_signal_emit (self, ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_ADDED_SIGNAL], 0, action);
		g_list_model_items_changed ((GListModel*) self, position, 0U, 1U);
	} else {
		FtAction* _tmp28_;
		_tmp28_ = previous_action;
		g_signal_emit (self, ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_REMOVED_SIGNAL], 0, _tmp28_);
		g_signal_emit (self, ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_ADDED_SIGNAL], 0, action);
		g_list_model_items_changed ((GListModel*) self, position, 1U, 1U);
	}
	_g_object_unref0 (previous_action);
	_g_object_unref0 (settings);
}

static void
_vala_array_add4 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar**
_vala_array_dup2 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
ft_action_list_model_delete_action (FtActionListModel* self,
                                    const gchar* uuid)
{
	FtAction* action = NULL;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	FtAction* _tmp2_;
	FtAction* _tmp3_;
	gchar** new_uuids = NULL;
	gchar** _tmp4_;
	gint new_uuids_length1;
	gint _new_uuids_size_;
	gboolean changed = FALSE;
	guint position = 0U;
	GSettings* settings = NULL;
	FtAction* _tmp5_;
	GSettings* _tmp6_;
	GSettings* _tmp7_;
	GSettings* _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	GSettings* _tmp15_;
	GHashTable* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uuid != NULL);
	_tmp0_ = self->priv->actions;
	_tmp1_ = g_hash_table_lookup (_tmp0_, uuid);
	_tmp2_ = _g_object_ref0 ((FtAction*) _tmp1_);
	action = _tmp2_;
	_tmp3_ = action;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (action);
		return;
	}
	_tmp4_ = g_new0 (gchar*, 0 + 1);
	new_uuids = _tmp4_;
	new_uuids_length1 = 0;
	_new_uuids_size_ = new_uuids_length1;
	changed = FALSE;
	position = 0U;
	_tmp5_ = action;
	_tmp6_ = ft_action_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	settings = _tmp8_;
	_tmp9_ = self->priv->uuids;
	_tmp9__length1 = self->priv->uuids_length1;
	{
		gchar** _uuid_collection = NULL;
		gint _uuid_collection_length1 = 0;
		gint __uuid_collection_size_ = 0;
		gint _uuid_it = 0;
		_uuid_collection = _tmp9_;
		_uuid_collection_length1 = _tmp9__length1;
		for (_uuid_it = 0; _uuid_it < _uuid_collection_length1; _uuid_it = _uuid_it + 1) {
			gchar* _tmp10_;
			gchar* _uuid = NULL;
			_tmp10_ = g_strdup (_uuid_collection[_uuid_it]);
			_uuid = _tmp10_;
			{
				const gchar* _tmp11_;
				_tmp11_ = _uuid;
				if (g_strcmp0 (_tmp11_, uuid) != 0) {
					const gchar* _tmp12_;
					gchar* _tmp13_;
					_tmp12_ = _uuid;
					_tmp13_ = g_strdup (_tmp12_);
					_vala_array_add4 (&new_uuids, &new_uuids_length1, &_new_uuids_size_, _tmp13_);
					if (!changed) {
						guint _tmp14_;
						_tmp14_ = position;
						position = _tmp14_ + 1;
					}
				} else {
					changed = TRUE;
				}
				_g_free0 (_uuid);
			}
		}
	}
	_tmp15_ = settings;
	if (_tmp15_ != NULL) {
		GSettings* _tmp16_;
		GSettingsSchema* _tmp17_;
		GSettingsSchema* _tmp18_;
		GSettingsSchema* _tmp19_;
		gchar** _tmp20_;
		gchar** _tmp21_;
		gchar** _tmp22_;
		gint _tmp22__length1;
		ft_action_list_model_inhibit_settings_changed (self);
		_tmp16_ = settings;
		g_object_get (_tmp16_, "settings-schema", &_tmp17_, NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp21_ = _tmp20_ = g_settings_schema_list_keys (_tmp19_);
		_tmp22_ = _tmp21_;
		_tmp22__length1 = _vala_array_length (_tmp20_);
		_g_settings_schema_unref0 (_tmp19_);
		{
			gchar** key_collection = NULL;
			gint key_collection_length1 = 0;
			gint _key_collection_size_ = 0;
			gint key_it = 0;
			key_collection = _tmp22_;
			key_collection_length1 = _tmp22__length1;
			for (key_it = 0; key_it < key_collection_length1; key_it = key_it + 1) {
				gchar* _tmp23_;
				gchar* key = NULL;
				_tmp23_ = g_strdup (key_collection[key_it]);
				key = _tmp23_;
				{
					GSettings* _tmp24_;
					const gchar* _tmp25_;
					_tmp24_ = settings;
					_tmp25_ = key;
					g_settings_reset (_tmp24_, _tmp25_);
					_g_free0 (key);
				}
			}
			key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
		}
		ft_action_list_model_uninhibit_settings_changed (self);
	}
	_tmp26_ = self->priv->actions;
	g_hash_table_remove (_tmp26_, uuid);
	if (changed) {
		gchar** _tmp27_;
		gint _tmp27__length1;
		gchar** _tmp28_;
		gint _tmp28__length1;
		gchar** _tmp29_;
		gint _tmp29__length1;
		FtAction* _tmp30_;
		_tmp27_ = new_uuids;
		_tmp27__length1 = new_uuids_length1;
		_tmp28_ = (_tmp27_ != NULL) ? _vala_array_dup2 (_tmp27_, _tmp27__length1) : _tmp27_;
		_tmp28__length1 = _tmp27__length1;
		self->priv->uuids = (_vala_array_free (self->priv->uuids, self->priv->uuids_length1, (GDestroyNotify) g_free), NULL);
		self->priv->uuids = _tmp28_;
		self->priv->uuids_length1 = _tmp28__length1;
		self->priv->_uuids_size_ = self->priv->uuids_length1;
		_tmp29_ = new_uuids;
		_tmp29__length1 = new_uuids_length1;
		self->priv->_n_items = (guint) _tmp29__length1;
		ft_action_list_model_save_uuids (self);
		_tmp30_ = action;
		g_signal_emit (self, ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_REMOVED_SIGNAL], 0, _tmp30_);
		g_list_model_items_changed ((GListModel*) self, position, 1U, 0U);
	}
	_g_object_unref0 (settings);
	new_uuids = (_vala_array_free (new_uuids, new_uuids_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (action);
}

void
ft_action_list_model_move_action (FtActionListModel* self,
                                  const gchar* uuid,
                                  guint position)
{
	gint source_position = 0;
	gint destination_position = 0;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gint n_changes = 0;
	gint _tmp1_ = 0;
	gint direction = 0;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uuid != NULL);
	source_position = ft_action_list_model_index (self, uuid);
	_tmp0_ = self->priv->uuids;
	_tmp0__length1 = self->priv->uuids_length1;
	destination_position = MIN ((gint) position, _tmp0__length1 - 1);
	n_changes = abs (source_position - destination_position);
	if (destination_position > source_position) {
		_tmp1_ = 1;
	} else {
		_tmp1_ = -1;
	}
	direction = _tmp1_;
	if (source_position < 0) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = destination_position < 0;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = n_changes == 0;
	}
	if (_tmp2_) {
		return;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gchar** _tmp6_;
				gint _tmp6__length1;
				gchar** _tmp7_;
				gint _tmp7__length1;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (!(i < n_changes)) {
					break;
				}
				_tmp6_ = self->priv->uuids;
				_tmp6__length1 = self->priv->uuids_length1;
				_tmp7_ = self->priv->uuids;
				_tmp7__length1 = self->priv->uuids_length1;
				_tmp8_ = _tmp7_[source_position + ((i + 1) * direction)];
				_tmp9_ = g_strdup (_tmp8_);
				_g_free0 (_tmp6_[source_position + (i * direction)]);
				_tmp6_[source_position + (i * direction)] = _tmp9_;
			}
		}
	}
	_tmp10_ = self->priv->uuids;
	_tmp10__length1 = self->priv->uuids_length1;
	_tmp11_ = g_strdup (uuid);
	_g_free0 (_tmp10_[destination_position]);
	_tmp10_[destination_position] = _tmp11_;
	ft_action_list_model_save_uuids (self);
	g_list_model_items_changed ((GListModel*) self, MIN ((guint) source_position, (guint) destination_position), (guint) n_changes, (guint) n_changes);
}

static void
ft_action_list_model_real_dispose (GObject* base)
{
	FtActionListModel * self;
	self = (FtActionListModel*) base;
	if (self->priv->settings_changed_id != ((gulong) 0)) {
		GSettings* _tmp0_;
		_tmp0_ = self->priv->settings;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->settings_changed_id);
		self->priv->settings_changed_id = (gulong) 0;
	}
	self->priv->uuids = (_vala_array_free (self->priv->uuids, self->priv->uuids_length1, (GDestroyNotify) g_free), NULL);
	self->priv->uuids = NULL;
	self->priv->uuids_length1 = 0;
	self->priv->_uuids_size_ = self->priv->uuids_length1;
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = NULL;
	G_OBJECT_CLASS (ft_action_list_model_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}

FtActionListModel*
ft_action_list_model_construct (GType object_type)
{
	FtActionListModel * self = NULL;
	self = (FtActionListModel*) g_object_new (object_type, NULL);
	return self;
}

FtActionListModel*
ft_action_list_model_new (void)
{
	return ft_action_list_model_construct (FT_TYPE_ACTION_LIST_MODEL);
}

guint
ft_action_list_model_get_n_items (FtActionListModel* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_n_items;
	return result;
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_ft_action_list_model_on_settings_changed_g_settings_changed (GSettings* _sender,
                                                              const gchar* key,
                                                              gpointer self)
{
	ft_action_list_model_on_settings_changed ((FtActionListModel*) self, _sender, key);
}

static GObject *
ft_action_list_model_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtActionListModel * self;
	gchar** _tmp0_;
	GHashFunc _tmp1_;
	GEqualFunc _tmp2_;
	GHashTable* _tmp3_;
	GSettings* _tmp4_;
	GSettings* _tmp5_;
	gulong _tmp6_;
	parent_class = G_OBJECT_CLASS (ft_action_list_model_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_ACTION_LIST_MODEL, FtActionListModel);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	self->priv->uuids = (_vala_array_free (self->priv->uuids, self->priv->uuids_length1, (GDestroyNotify) g_free), NULL);
	self->priv->uuids = _tmp0_;
	self->priv->uuids_length1 = 0;
	self->priv->_uuids_size_ = self->priv->uuids_length1;
	_tmp1_ = g_str_hash;
	_tmp2_ = g_str_equal;
	_tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->actions);
	self->priv->actions = _tmp3_;
	_tmp4_ = g_settings_new ("io.github.focustimerhq.FocusTimer.actions");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp4_;
	_tmp5_ = self->priv->settings;
	_tmp6_ = g_signal_connect_object (_tmp5_, "changed", (GCallback) _ft_action_list_model_on_settings_changed_g_settings_changed, self, 0);
	self->priv->settings_changed_id = _tmp6_;
	ft_action_list_model_load (self);
	return obj;
}

static void
ft_action_list_model_class_init (FtActionListModelClass * klass,
                                 gpointer klass_data)
{
	ft_action_list_model_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtActionListModel_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_action_list_model_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_action_list_model_get_property;
	G_OBJECT_CLASS (klass)->constructor = ft_action_list_model_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_action_list_model_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_ACTION_LIST_MODEL_N_ITEMS_PROPERTY, ft_action_list_model_properties[FT_ACTION_LIST_MODEL_N_ITEMS_PROPERTY] = g_param_spec_uint ("n-items", "n-items", "n-items", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_ADDED_SIGNAL] = g_signal_new ("action-added", FT_TYPE_ACTION_LIST_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, FT_TYPE_ACTION);
	ft_action_list_model_signals[FT_ACTION_LIST_MODEL_ACTION_REMOVED_SIGNAL] = g_signal_new ("action-removed", FT_TYPE_ACTION_LIST_MODEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, FT_TYPE_ACTION);
}

static void
ft_action_list_model_g_list_model_interface_init (GListModelInterface * iface,
                                                  gpointer iface_data)
{
	ft_action_list_model_g_list_model_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_item_type = (GType (*) (GListModel*)) ft_action_list_model_real_get_item_type;
	iface->get_n_items = (guint (*) (GListModel*)) ft_action_list_model_real_get_n_items;
	iface->get_item = (GObject* (*) (GListModel*, guint)) ft_action_list_model_real_get_item;
}

static void
ft_action_list_model_instance_init (FtActionListModel * self,
                                    gpointer klass)
{
	self->priv = ft_action_list_model_get_instance_private (self);
	self->priv->_n_items = (guint) 0;
	self->priv->settings = NULL;
	self->priv->settings_changed_id = (gulong) 0;
	self->priv->settings_changed_inhibit_count = 0;
}

static void
ft_action_list_model_finalize (GObject * obj)
{
	FtActionListModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_ACTION_LIST_MODEL, FtActionListModel);
	_g_hash_table_unref0 (self->priv->actions);
	self->priv->uuids = (_vala_array_free (self->priv->uuids, self->priv->uuids_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (ft_action_list_model_parent_class)->finalize (obj);
}

/**
     * A list model for storing actions in settings.
     *
     * Each action is stored using an relocatable schema. There is no API to list relocatable
     * schemas or their subfolders, so we need to keep subfolders as `actions` key. `actions`
     * also stores the actions order.
     */
static GType
ft_action_list_model_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtActionListModelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_action_list_model_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtActionListModel), 0, (GInstanceInitFunc) ft_action_list_model_instance_init, NULL };
	static const GInterfaceInfo g_list_model_info = { (GInterfaceInitFunc) ft_action_list_model_g_list_model_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_action_list_model_type_id;
	ft_action_list_model_type_id = g_type_register_static (G_TYPE_OBJECT, "FtActionListModel", &g_define_type_info, 0);
	g_type_add_interface_static (ft_action_list_model_type_id, g_list_model_get_type (), &g_list_model_info);
	FtActionListModel_private_offset = g_type_add_instance_private (ft_action_list_model_type_id, sizeof (FtActionListModelPrivate));
	return ft_action_list_model_type_id;
}

GType
ft_action_list_model_get_type (void)
{
	static volatile gsize ft_action_list_model_type_id__once = 0;
	if (g_once_init_enter (&ft_action_list_model_type_id__once)) {
		GType ft_action_list_model_type_id;
		ft_action_list_model_type_id = ft_action_list_model_get_type_once ();
		g_once_init_leave (&ft_action_list_model_type_id__once, ft_action_list_model_type_id);
	}
	return ft_action_list_model_type_id__once;
}

static void
_vala_ft_action_list_model_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	FtActionListModel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_ACTION_LIST_MODEL, FtActionListModel);
	switch (property_id) {
		case FT_ACTION_LIST_MODEL_N_ITEMS_PROPERTY:
		g_value_set_uint (value, ft_action_list_model_get_n_items (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

