/* TagExtractor.c generated by valac 0.56.19, the Vala compiler
 * generated from TagExtractor.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>

#define TUBA_UTILS_TAG_EXTRACTOR_MAX_TAGS_ALLOWED 20
#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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TUBA_UTILS_TYPE_TAG_EXTRACTOR (tuba_utils_tag_extractor_get_type ())
#define TUBA_UTILS_TAG_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_UTILS_TYPE_TAG_EXTRACTOR, TubaUtilsTagExtractor))
#define TUBA_UTILS_TAG_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_UTILS_TYPE_TAG_EXTRACTOR, TubaUtilsTagExtractorClass))
#define TUBA_UTILS_IS_TAG_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_UTILS_TYPE_TAG_EXTRACTOR))
#define TUBA_UTILS_IS_TAG_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_UTILS_TYPE_TAG_EXTRACTOR))
#define TUBA_UTILS_TAG_EXTRACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_UTILS_TYPE_TAG_EXTRACTOR, TubaUtilsTagExtractorClass))

typedef struct _TubaUtilsTagExtractor TubaUtilsTagExtractor;
typedef struct _TubaUtilsTagExtractorClass TubaUtilsTagExtractorClass;
typedef struct _TubaUtilsTagExtractorPrivate TubaUtilsTagExtractorPrivate;

#define TUBA_UTILS_TAG_EXTRACTOR_TYPE_RESULT (tuba_utils_tag_extractor_result_get_type ())
typedef struct _TubaUtilsTagExtractorResult TubaUtilsTagExtractorResult;

#define TUBA_UTILS_TAG_EXTRACTOR_TYPE_TAG (tuba_utils_tag_extractor_tag_get_type ())
typedef struct _TubaUtilsTagExtractorTag TubaUtilsTagExtractorTag;
#define _tuba_utils_tag_extractor_unref0(var) ((var == NULL) ? NULL : (var = (tuba_utils_tag_extractor_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block62Data Block62Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _TubaUtilsParamSpecTagExtractor TubaUtilsParamSpecTagExtractor;

struct _TubaUtilsTagExtractor {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TubaUtilsTagExtractorPrivate * priv;
};

struct _TubaUtilsTagExtractorClass {
	GTypeClass parent_class;
	void (*finalize) (TubaUtilsTagExtractor *self);
};

struct _TubaUtilsTagExtractorTag {
	gchar* tag;
	gchar* link;
};

struct _TubaUtilsTagExtractorResult {
	gchar* input_without_tags;
	TubaUtilsTagExtractorTag* extracted_tags;
	gint extracted_tags_length1;
};

struct _Block62Data {
	int _ref_count_;
	TubaUtilsTagExtractorTag* extracted_tags;
	gint extracted_tags_length1;
	gint _extracted_tags_size_;
};

struct _TubaUtilsParamSpecTagExtractor {
	GParamSpec parent_instance;
};

static gpointer tuba_utils_tag_extractor_parent_class = NULL;
static GRegex* tuba_utils_tag_extractor_pango_uri_regex;
static GRegex* tuba_utils_tag_extractor_pango_uri_regex = NULL;

VALA_EXTERN gpointer tuba_utils_tag_extractor_ref (gpointer instance);
VALA_EXTERN void tuba_utils_tag_extractor_unref (gpointer instance);
VALA_EXTERN GParamSpec* tuba_utils_param_spec_tag_extractor (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void tuba_utils_value_set_tag_extractor (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void tuba_utils_value_take_tag_extractor (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer tuba_utils_value_get_tag_extractor (const GValue* value);
VALA_EXTERN GType tuba_utils_tag_extractor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaUtilsTagExtractor, tuba_utils_tag_extractor_unref)
VALA_EXTERN GType tuba_utils_tag_extractor_result_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType tuba_utils_tag_extractor_tag_get_type (void) G_GNUC_CONST ;
VALA_EXTERN TubaUtilsTagExtractorTag* tuba_utils_tag_extractor_tag_dup (const TubaUtilsTagExtractorTag* self);
VALA_EXTERN void tuba_utils_tag_extractor_tag_free (TubaUtilsTagExtractorTag* self);
VALA_EXTERN void tuba_utils_tag_extractor_tag_copy (const TubaUtilsTagExtractorTag* self,
                                        TubaUtilsTagExtractorTag* dest);
VALA_EXTERN void tuba_utils_tag_extractor_tag_destroy (TubaUtilsTagExtractorTag* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (TubaUtilsTagExtractorTag, tuba_utils_tag_extractor_tag_destroy)
VALA_EXTERN TubaUtilsTagExtractorResult* tuba_utils_tag_extractor_result_dup (const TubaUtilsTagExtractorResult* self);
VALA_EXTERN void tuba_utils_tag_extractor_result_free (TubaUtilsTagExtractorResult* self);
VALA_EXTERN void tuba_utils_tag_extractor_result_copy (const TubaUtilsTagExtractorResult* self,
                                           TubaUtilsTagExtractorResult* dest);
VALA_EXTERN void tuba_utils_tag_extractor_result_destroy (TubaUtilsTagExtractorResult* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (TubaUtilsTagExtractorResult, tuba_utils_tag_extractor_result_destroy)
VALA_EXTERN void tuba_utils_tag_extractor_from_string (const gchar* input,
                                           TubaUtilsTagExtractorResult* result);
VALA_EXTERN TubaUtilsTagExtractor* tuba_utils_tag_extractor_new (void);
VALA_EXTERN TubaUtilsTagExtractor* tuba_utils_tag_extractor_construct (GType object_type);
static void _vala_TubaUtilsTagExtractorTag_array_free (TubaUtilsTagExtractorTag * array,
                                                gssize array_length);
static Block62Data* block62_data_ref (Block62Data* _data62_);
static void block62_data_unref (void * _userdata_);
static gboolean ___lambda43_ (Block62Data* _data62_,
                       GMatchInfo* match_info,
                       GString* data);
static void _vala_array_add58 (TubaUtilsTagExtractorTag* * array,
                        gint* length,
                        gint* size,
                        const TubaUtilsTagExtractorTag* value);
static gboolean ____lambda43__gregex_eval_callback (GMatchInfo* match_info,
                                             GString* _result_,
                                             gpointer self);
static TubaUtilsTagExtractorTag* _vala_array_dup39 (TubaUtilsTagExtractorTag* self,
                                             gssize length);
static TubaUtilsTagExtractorTag* _vala_array_dup40 (TubaUtilsTagExtractorTag* self,
                                             gssize length);
static void tuba_utils_tag_extractor_finalize (TubaUtilsTagExtractor * obj);
static GType tuba_utils_tag_extractor_get_type_once (void);

static void
_vala_TubaUtilsTagExtractorTag_array_free (TubaUtilsTagExtractorTag * array,
                                           gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			tuba_utils_tag_extractor_tag_destroy (&array[i]);
		}
	}
	g_free (array);
}

static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gint
string_last_index_of_char (const gchar* self,
                           gunichar c,
                           gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strrchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static Block62Data*
block62_data_ref (Block62Data* _data62_)
{
	g_atomic_int_inc (&_data62_->_ref_count_);
	return _data62_;
}

static void
block62_data_unref (void * _userdata_)
{
	Block62Data* _data62_;
	_data62_ = (Block62Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data62_->_ref_count_)) {
		_data62_->extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free (_data62_->extracted_tags, _data62_->extracted_tags_length1), NULL);
		g_slice_free (Block62Data, _data62_);
	}
}

static void
_vala_array_add58 (TubaUtilsTagExtractorTag* * array,
                   gint* length,
                   gint* size,
                   const TubaUtilsTagExtractorTag* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (TubaUtilsTagExtractorTag, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static gboolean
___lambda43_ (Block62Data* _data62_,
              GMatchInfo* match_info,
              GString* data)
{
	TubaUtilsTagExtractorTag* _tmp0_;
	gint _tmp0__length1;
	gchar* _tmp2_;
	gchar* _tmp3_;
	TubaUtilsTagExtractorTag _tmp4_ = {0};
	gboolean result;
	g_return_val_if_fail (match_info != NULL, FALSE);
	g_return_val_if_fail (data != NULL, FALSE);
	g_string_append (data, "");
	_tmp0_ = _data62_->extracted_tags;
	_tmp0__length1 = _data62_->extracted_tags_length1;
	if (_tmp0_ == NULL) {
		TubaUtilsTagExtractorTag* _tmp1_;
		_tmp1_ = g_new0 (TubaUtilsTagExtractorTag, 0);
		_data62_->extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free (_data62_->extracted_tags, _data62_->extracted_tags_length1), NULL);
		_data62_->extracted_tags = _tmp1_;
		_data62_->extracted_tags_length1 = 0;
		_data62_->_extracted_tags_size_ = _data62_->extracted_tags_length1;
	}
	_tmp2_ = g_match_info_fetch_named (match_info, "tag");
	_tmp3_ = g_match_info_fetch_named (match_info, "href");
	memset (&_tmp4_, 0, sizeof (TubaUtilsTagExtractorTag));
	_g_free0 (_tmp4_.tag);
	_tmp4_.tag = _tmp2_;
	_g_free0 (_tmp4_.link);
	_tmp4_.link = _tmp3_;
	_vala_array_add58 (&_data62_->extracted_tags, &_data62_->extracted_tags_length1, &_data62_->_extracted_tags_size_, &_tmp4_);
	result = FALSE;
	return result;
}

static gboolean
____lambda43__gregex_eval_callback (GMatchInfo* match_info,
                                    GString* _result_,
                                    gpointer self)
{
	gboolean result;
	result = ___lambda43_ (self, match_info, _result_);
	return result;
}

static TubaUtilsTagExtractorTag*
_vala_array_dup39 (TubaUtilsTagExtractorTag* self,
                   gssize length)
{
	if (length > 0) {
		TubaUtilsTagExtractorTag* result;
		gssize i;
		result = g_new0 (TubaUtilsTagExtractorTag, length);
		for (i = 0; i < length; i++) {
			TubaUtilsTagExtractorTag _tmp0_;
			TubaUtilsTagExtractorTag _tmp1_ = {0};
			_tmp0_ = self[i];
			tuba_utils_tag_extractor_tag_copy (&_tmp0_, &_tmp1_);
			result[i] = _tmp1_;
		}
		return result;
	}
	return NULL;
}

void
tuba_utils_tag_extractor_from_string (const gchar* input,
                                      TubaUtilsTagExtractorResult* result)
{
	TubaUtilsTagExtractor* _tmp0_;
	TubaUtilsTagExtractor* _tmp1_;
	TubaUtilsTagExtractorResult res = {0};
	TubaUtilsTagExtractorResult _tmp2_ = {0};
	gint last_paragraph_begin = 0;
	gchar* last_paragraph = NULL;
	gint _tmp3_;
	gint _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gboolean _tmp9_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (input != NULL);
	_tmp0_ = tuba_utils_tag_extractor_new ();
	_tmp1_ = _tmp0_;
	_tuba_utils_tag_extractor_unref0 (_tmp1_);
	_g_free0 (_tmp2_.input_without_tags);
	_tmp2_.input_without_tags = NULL;
	_tmp2_.extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free (_tmp2_.extracted_tags, _tmp2_.extracted_tags_length1), NULL);
	_tmp2_.extracted_tags = NULL;
	_tmp2_.extracted_tags_length1 = 0;
	res = _tmp2_;
	last_paragraph_begin = string_last_index_of (input, "\n\n", 0);
	if (last_paragraph_begin == -1) {
		*result = res;
		return;
	}
	_tmp3_ = strlen (input);
	_tmp4_ = _tmp3_;
	_tmp5_ = string_slice (input, (glong) last_paragraph_begin, (glong) _tmp4_);
	last_paragraph = _tmp5_;
	_tmp6_ = last_paragraph;
	_tmp7_ = string_strip (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = string_last_index_of_char (_tmp8_, (gunichar) '\n', 0) > -1;
	_g_free0 (_tmp8_);
	if (_tmp9_) {
		*result = res;
		_g_free0 (last_paragraph);
		return;
	}
	{
		Block62Data* _data62_;
		gchar* _tmp10_ = NULL;
		GRegex* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		gchar* _tmp16_;
		gchar* cleaned_up_paragraph = NULL;
		gchar* _tmp17_;
		gboolean _tmp18_ = FALSE;
		const gchar* _tmp19_;
		TubaUtilsTagExtractorTag* _tmp21_;
		gint _tmp21__length1;
		TubaUtilsTagExtractorTag* _tmp22_;
		gint _tmp22__length1;
		gchar* _tmp23_;
		_data62_ = g_slice_new0 (Block62Data);
		_data62_->_ref_count_ = 1;
		_data62_->extracted_tags = NULL;
		_data62_->extracted_tags_length1 = 0;
		_data62_->_extracted_tags_size_ = _data62_->extracted_tags_length1;
		_tmp11_ = tuba_utils_tag_extractor_pango_uri_regex;
		_tmp12_ = last_paragraph;
		_tmp13_ = last_paragraph;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_regex_replace_eval (_tmp11_, _tmp12_, (gssize) _tmp15_, 0, 0, ____lambda43__gregex_eval_callback, _data62_, &_inner_error0_);
		_tmp10_ = _tmp16_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			block62_data_unref (_data62_);
			_data62_ = NULL;
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_free0 (last_paragraph);
			tuba_utils_tag_extractor_result_destroy (&res);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_tmp17_ = string_strip (_tmp10_);
		cleaned_up_paragraph = _tmp17_;
		_tmp19_ = cleaned_up_paragraph;
		if (g_strcmp0 (_tmp19_, "") != 0) {
			_tmp18_ = TRUE;
		} else {
			TubaUtilsTagExtractorTag* _tmp20_;
			gint _tmp20__length1;
			_tmp20_ = _data62_->extracted_tags;
			_tmp20__length1 = _data62_->extracted_tags_length1;
			_tmp18_ = _tmp20__length1 > TUBA_UTILS_TAG_EXTRACTOR_MAX_TAGS_ALLOWED;
		}
		if (_tmp18_) {
			*result = res;
			_g_free0 (cleaned_up_paragraph);
			_g_free0 (_tmp10_);
			block62_data_unref (_data62_);
			_data62_ = NULL;
			_g_free0 (last_paragraph);
			return;
		}
		_tmp21_ = _data62_->extracted_tags;
		_tmp21__length1 = _data62_->extracted_tags_length1;
		_tmp22_ = (_tmp21_ != NULL) ? _vala_array_dup39 (_tmp21_, _tmp21__length1) : _tmp21_;
		_tmp22__length1 = _tmp21__length1;
		res.extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free (res.extracted_tags, res.extracted_tags_length1), NULL);
		res.extracted_tags = _tmp22_;
		res.extracted_tags_length1 = _tmp22__length1;
		_tmp23_ = string_slice (input, (glong) 0, (glong) last_paragraph_begin);
		_g_free0 (res.input_without_tags);
		res.input_without_tags = _tmp23_;
		_g_free0 (cleaned_up_paragraph);
		_g_free0 (_tmp10_);
		block62_data_unref (_data62_);
		_data62_ = NULL;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* e = NULL;
		GError* _tmp24_;
		const gchar* _tmp25_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp24_ = e;
		_tmp25_ = _tmp24_->message;
		g_critical ("TagExtractor.vala:51: %s", _tmp25_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (last_paragraph);
		tuba_utils_tag_extractor_result_destroy (&res);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	*result = res;
	_g_free0 (last_paragraph);
	return;
}

TubaUtilsTagExtractor*
tuba_utils_tag_extractor_construct (GType object_type)
{
	TubaUtilsTagExtractor* self = NULL;
	self = (TubaUtilsTagExtractor*) g_type_create_instance (object_type);
	return self;
}

TubaUtilsTagExtractor*
tuba_utils_tag_extractor_new (void)
{
	return tuba_utils_tag_extractor_construct (TUBA_UTILS_TYPE_TAG_EXTRACTOR);
}

void
tuba_utils_tag_extractor_tag_copy (const TubaUtilsTagExtractorTag* self,
                                   TubaUtilsTagExtractorTag* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = (*self).tag;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).tag);
	(*dest).tag = _tmp1_;
	_tmp2_ = (*self).link;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).link);
	(*dest).link = _tmp3_;
}

void
tuba_utils_tag_extractor_tag_destroy (TubaUtilsTagExtractorTag* self)
{
	_g_free0 ((*self).tag);
	_g_free0 ((*self).link);
}

TubaUtilsTagExtractorTag*
tuba_utils_tag_extractor_tag_dup (const TubaUtilsTagExtractorTag* self)
{
	TubaUtilsTagExtractorTag* dup;
	dup = g_new0 (TubaUtilsTagExtractorTag, 1);
	tuba_utils_tag_extractor_tag_copy (self, dup);
	return dup;
}

void
tuba_utils_tag_extractor_tag_free (TubaUtilsTagExtractorTag* self)
{
	tuba_utils_tag_extractor_tag_destroy (self);
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_tag_extractor_tag_get_type_once (void)
{
	GType tuba_utils_tag_extractor_tag_type_id;
	tuba_utils_tag_extractor_tag_type_id = g_boxed_type_register_static ("TubaUtilsTagExtractorTag", (GBoxedCopyFunc) tuba_utils_tag_extractor_tag_dup, (GBoxedFreeFunc) tuba_utils_tag_extractor_tag_free);
	return tuba_utils_tag_extractor_tag_type_id;
}

GType
tuba_utils_tag_extractor_tag_get_type (void)
{
	static GType tuba_utils_tag_extractor_tag_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_tag_extractor_tag_type_id__once)) {
		GType tuba_utils_tag_extractor_tag_type_id;
		tuba_utils_tag_extractor_tag_type_id = tuba_utils_tag_extractor_tag_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_tag_extractor_tag_type_id__once, tuba_utils_tag_extractor_tag_type_id);
	}
	return tuba_utils_tag_extractor_tag_type_id__once;
}

static TubaUtilsTagExtractorTag*
_vala_array_dup40 (TubaUtilsTagExtractorTag* self,
                   gssize length)
{
	if (length > 0) {
		TubaUtilsTagExtractorTag* result;
		gssize i;
		result = g_new0 (TubaUtilsTagExtractorTag, length);
		for (i = 0; i < length; i++) {
			TubaUtilsTagExtractorTag _tmp0_;
			TubaUtilsTagExtractorTag _tmp1_ = {0};
			_tmp0_ = self[i];
			tuba_utils_tag_extractor_tag_copy (&_tmp0_, &_tmp1_);
			result[i] = _tmp1_;
		}
		return result;
	}
	return NULL;
}

void
tuba_utils_tag_extractor_result_copy (const TubaUtilsTagExtractorResult* self,
                                      TubaUtilsTagExtractorResult* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	TubaUtilsTagExtractorTag* _tmp2_;
	gint _tmp2__length1;
	TubaUtilsTagExtractorTag* _tmp3_;
	gint _tmp3__length1;
	_tmp0_ = (*self).input_without_tags;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).input_without_tags);
	(*dest).input_without_tags = _tmp1_;
	_tmp2_ = (*self).extracted_tags;
	_tmp2__length1 = (*self).extracted_tags_length1;
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup40 (_tmp2_, _tmp2__length1) : _tmp2_;
	_tmp3__length1 = _tmp2__length1;
	(*dest).extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free ((*dest).extracted_tags, (*dest).extracted_tags_length1), NULL);
	(*dest).extracted_tags = _tmp3_;
	(*dest).extracted_tags_length1 = _tmp3__length1;
}

void
tuba_utils_tag_extractor_result_destroy (TubaUtilsTagExtractorResult* self)
{
	_g_free0 ((*self).input_without_tags);
	(*self).extracted_tags = (_vala_TubaUtilsTagExtractorTag_array_free ((*self).extracted_tags, (*self).extracted_tags_length1), NULL);
}

TubaUtilsTagExtractorResult*
tuba_utils_tag_extractor_result_dup (const TubaUtilsTagExtractorResult* self)
{
	TubaUtilsTagExtractorResult* dup;
	dup = g_new0 (TubaUtilsTagExtractorResult, 1);
	tuba_utils_tag_extractor_result_copy (self, dup);
	return dup;
}

void
tuba_utils_tag_extractor_result_free (TubaUtilsTagExtractorResult* self)
{
	tuba_utils_tag_extractor_result_destroy (self);
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_tag_extractor_result_get_type_once (void)
{
	GType tuba_utils_tag_extractor_result_type_id;
	tuba_utils_tag_extractor_result_type_id = g_boxed_type_register_static ("TubaUtilsTagExtractorResult", (GBoxedCopyFunc) tuba_utils_tag_extractor_result_dup, (GBoxedFreeFunc) tuba_utils_tag_extractor_result_free);
	return tuba_utils_tag_extractor_result_type_id;
}

GType
tuba_utils_tag_extractor_result_get_type (void)
{
	static GType tuba_utils_tag_extractor_result_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_tag_extractor_result_type_id__once)) {
		GType tuba_utils_tag_extractor_result_type_id;
		tuba_utils_tag_extractor_result_type_id = tuba_utils_tag_extractor_result_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_tag_extractor_result_type_id__once, tuba_utils_tag_extractor_result_type_id);
	}
	return tuba_utils_tag_extractor_result_type_id__once;
}

static void
tuba_utils_value_tag_extractor_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
tuba_utils_value_tag_extractor_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		tuba_utils_tag_extractor_unref (value->data[0].v_pointer);
	}
}

static void
tuba_utils_value_tag_extractor_copy_value (const GValue* src_value,
                                           GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = tuba_utils_tag_extractor_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
tuba_utils_value_tag_extractor_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
tuba_utils_value_tag_extractor_collect_value (GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		TubaUtilsTagExtractor * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = tuba_utils_tag_extractor_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
tuba_utils_value_tag_extractor_lcopy_value (const GValue* value,
                                            guint n_collect_values,
                                            GTypeCValue* collect_values,
                                            guint collect_flags)
{
	TubaUtilsTagExtractor ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = tuba_utils_tag_extractor_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
tuba_utils_param_spec_tag_extractor (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags)
{
	TubaUtilsParamSpecTagExtractor* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TUBA_UTILS_TYPE_TAG_EXTRACTOR), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
tuba_utils_value_get_tag_extractor (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_TAG_EXTRACTOR), NULL);
	return value->data[0].v_pointer;
}

void
tuba_utils_value_set_tag_extractor (GValue* value,
                                    gpointer v_object)
{
	TubaUtilsTagExtractor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_TAG_EXTRACTOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_TAG_EXTRACTOR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		tuba_utils_tag_extractor_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_tag_extractor_unref (old);
	}
}

void
tuba_utils_value_take_tag_extractor (GValue* value,
                                     gpointer v_object)
{
	TubaUtilsTagExtractor * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_TAG_EXTRACTOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_TAG_EXTRACTOR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_tag_extractor_unref (old);
	}
}

static void
tuba_utils_tag_extractor_class_init (TubaUtilsTagExtractorClass * klass,
                                     gpointer klass_data)
{
	GError* _inner_error0_ = NULL;
	tuba_utils_tag_extractor_parent_class = g_type_class_peek_parent (klass);
	((TubaUtilsTagExtractorClass *) klass)->finalize = tuba_utils_tag_extractor_finalize;
	{
		GRegex* _tmp0_ = NULL;
		GRegex* _tmp1_;
		GRegex* _tmp2_;
		_tmp1_ = g_regex_new ("<a href='(?<href>http[^']+)'>#(?<tag>[^<]+)<\\/a>", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_regex_unref0 (tuba_utils_tag_extractor_pango_uri_regex);
		tuba_utils_tag_extractor_pango_uri_regex = _tmp2_;
		_g_regex_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("TagExtractor.vala:19: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
	}
}

static void
tuba_utils_tag_extractor_instance_init (TubaUtilsTagExtractor * self,
                                        gpointer klass)
{
	self->ref_count = 1;
}

static void
tuba_utils_tag_extractor_finalize (TubaUtilsTagExtractor * obj)
{
	TubaUtilsTagExtractor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_UTILS_TYPE_TAG_EXTRACTOR, TubaUtilsTagExtractor);
	g_signal_handlers_destroy (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_tag_extractor_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { tuba_utils_value_tag_extractor_init, tuba_utils_value_tag_extractor_free_value, tuba_utils_value_tag_extractor_copy_value, tuba_utils_value_tag_extractor_peek_pointer, "p", tuba_utils_value_tag_extractor_collect_value, "p", tuba_utils_value_tag_extractor_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TubaUtilsTagExtractorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_utils_tag_extractor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaUtilsTagExtractor), 0, (GInstanceInitFunc) tuba_utils_tag_extractor_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType tuba_utils_tag_extractor_type_id;
	tuba_utils_tag_extractor_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TubaUtilsTagExtractor", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_NONE);
	return tuba_utils_tag_extractor_type_id;
}

GType
tuba_utils_tag_extractor_get_type (void)
{
	static GType tuba_utils_tag_extractor_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_tag_extractor_type_id__once)) {
		GType tuba_utils_tag_extractor_type_id;
		tuba_utils_tag_extractor_type_id = tuba_utils_tag_extractor_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_tag_extractor_type_id__once, tuba_utils_tag_extractor_type_id);
	}
	return tuba_utils_tag_extractor_type_id__once;
}

gpointer
tuba_utils_tag_extractor_ref (gpointer instance)
{
	TubaUtilsTagExtractor * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
tuba_utils_tag_extractor_unref (gpointer instance)
{
	TubaUtilsTagExtractor * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TUBA_UTILS_TAG_EXTRACTOR_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

