/* github-actions-release-source.c generated by valac 0.56.19, the Vala compiler
 * generated from github-actions-release-source.vala, do not modify */

#include "protonplus_core.h"
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <json-glib/json-glib.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  {
	PROTON_PLUS_PROVIDERS_SOURCES_GIT_HUB_ACTIONS_RELEASE_SOURCE_0_PROPERTY,
	PROTON_PLUS_PROVIDERS_SOURCES_GIT_HUB_ACTIONS_RELEASE_SOURCE_NUM_PROPERTIES
};
static GParamSpec* proton_plus_providers_sources_git_hub_actions_release_source_properties[PROTON_PLUS_PROVIDERS_SOURCES_GIT_HUB_ACTIONS_RELEASE_SOURCE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData;

struct _ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self;
	ProtonPlusModelsProvidersProviderDefinition* definition;
	gint requested_page;
	gint limit;
	ProtonPlusModelsToolsReleasePageResult* result;
	GeeLinkedList* releases;
	GeeLinkedList* _tmp0_;
	gint current_page;
	gboolean reached_end;
	gboolean _tmp1_;
	GeeLinkedList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	ProtonPlusUtilsWebResponse* response;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ProtonPlusUtilsWebResponse* _tmp7_;
	ProtonPlusUtilsWebResponse* _tmp8_;
	ProtonPlusReturnCode _tmp9_;
	ProtonPlusReturnCode _tmp10_;
	ProtonPlusUtilsWebResponse* _tmp11_;
	ProtonPlusReturnCode _tmp12_;
	ProtonPlusReturnCode _tmp13_;
	ProtonPlusModelsToolsReleasePageResult* _tmp14_;
	ProtonPlusModelsToolsReleasePageResult* page_result;
	ProtonPlusUtilsWebResponse* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	ProtonPlusModelsToolsReleasePageResult* _tmp18_;
	ProtonPlusModelsToolsReleasePageResult* _tmp19_;
	gboolean _tmp20_;
	gboolean _tmp21_;
	ProtonPlusModelsToolsReleasePage* page;
	ProtonPlusModelsToolsReleasePageResult* _tmp22_;
	ProtonPlusModelsToolsReleasePage* _tmp23_;
	GeeLinkedList* _tmp24_;
	ProtonPlusModelsToolsReleasePage* _tmp25_;
	GeeLinkedList* _tmp26_;
	GeeLinkedList* _tmp27_;
	ProtonPlusModelsToolsReleasePage* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	ProtonPlusModelsToolsReleasePage* _tmp31_;
	gint _tmp32_;
	gint _tmp33_;
	GeeLinkedList* _tmp34_;
	ProtonPlusModelsToolsReleasePage* _tmp35_;
	ProtonPlusModelsToolsReleasePage* _tmp36_;
	ProtonPlusModelsToolsReleasePageResult* _tmp37_;
	ProtonPlusModelsToolsReleasePageResult* _tmp38_;
};

struct _ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self;
	gchar* endpoint;
	gint page;
	gint limit;
	ProtonPlusUtilsWebResponse* result;
	gchar* _tmp0_;
	gchar* _tmp1_;
	ProtonPlusUtilsWebResponse* _tmp2_;
	ProtonPlusUtilsWebResponse* _tmp3_;
};

static gpointer proton_plus_providers_sources_git_hub_actions_release_source_parent_class = NULL;
static ProtonPlusProvidersSourcesReleaseSourceIface * proton_plus_providers_sources_git_hub_actions_release_source_proton_plus_providers_sources_release_source_parent_iface = NULL;

static void proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_data_free (gpointer _data);
static void proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page (ProtonPlusProvidersSourcesReleaseSource* base,
                                                                                   ProtonPlusModelsProvidersProviderDefinition* definition,
                                                                                   gint requested_page,
                                                                                   gint limit,
                                                                                   GAsyncReadyCallback _callback_,
                                                                                   gpointer _user_data_);
static gboolean proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_co (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_);
static void proton_plus_providers_sources_git_hub_actions_release_source_fetch_page_ready (GObject* source_object,
                                                                                    GAsyncResult* _res_,
                                                                                    gpointer _user_data_);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN gchar* proton_plus_providers_sources_release_source_support_get_iso8601_date (JsonObject* object,
                                                                              const gchar* member);
VALA_EXTERN void proton_plus_providers_sources_release_source_support_add_variants (ProtonPlusModelsRelease* release,
                                                                        GeeIterable* variants);
static void proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_data_free (gpointer _data);
static void proton_plus_providers_sources_git_hub_actions_release_source_real_request_page (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                                     const gchar* endpoint,
                                                                                     gint page,
                                                                                     gint limit,
                                                                                     GAsyncReadyCallback _callback_,
                                                                                     gpointer _user_data_);
static gboolean proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_co (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_);
static void proton_plus_providers_sources_git_hub_actions_release_source_request_page_ready (GObject* source_object,
                                                                                      GAsyncResult* _res_,
                                                                                      gpointer _user_data_);
static GType proton_plus_providers_sources_git_hub_actions_release_source_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_data_free (gpointer _data)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->definition);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData, _data_);
}

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

static void
proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page (ProtonPlusProvidersSourcesReleaseSource* base,
                                                                              ProtonPlusModelsProvidersProviderDefinition* definition,
                                                                              gint requested_page,
                                                                              gint limit,
                                                                              GAsyncReadyCallback _callback_,
                                                                              gpointer _user_data_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource * self;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource* _tmp0_;
	ProtonPlusModelsProvidersProviderDefinition* _tmp1_;
	g_return_if_fail (definition != NULL);
	self = (ProtonPlusProvidersSourcesGitHubActionsReleaseSource*) base;
	_data_ = g_slice_new0 (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (definition);
	_g_object_unref0 (_data_->definition);
	_data_->definition = _tmp1_;
	_data_->requested_page = requested_page;
	_data_->limit = limit;
	proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_co (_data_);
}

static ProtonPlusModelsToolsReleasePageResult*
proton_plus_providers_sources_git_hub_actions_release_source_fetch_page_finish (ProtonPlusProvidersSourcesReleaseSource* base,
                                                                                GAsyncResult* _res_)
{
	ProtonPlusModelsToolsReleasePageResult* result;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_fetch_page_ready (GObject* source_object,
                                                                               GAsyncResult* _res_,
                                                                               gpointer _user_data_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_co (_data_);
}

static gboolean
proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page_co (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceFetchPageData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gee_linked_list_new (PROTON_PLUS_MODELS_TYPE_RELEASE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->releases = _data_->_tmp0_;
	_data_->current_page = _data_->requested_page;
	_data_->reached_end = FALSE;
	while (TRUE) {
		_data_->_tmp2_ = _data_->releases;
		_data_->_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		if (_data_->_tmp4_ == 0) {
			_data_->_tmp1_ = !_data_->reached_end;
		} else {
			_data_->_tmp1_ = FALSE;
		}
		if (!_data_->_tmp1_) {
			break;
		}
		_data_->_tmp5_ = proton_plus_models_providers_provider_definition_get_endpoint (_data_->definition);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_state_ = 1;
		proton_plus_providers_sources_git_hub_actions_release_source_request_page (_data_->self, _data_->_tmp6_, _data_->current_page, _data_->limit, proton_plus_providers_sources_git_hub_actions_release_source_fetch_page_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp7_ = proton_plus_providers_sources_git_hub_actions_release_source_request_page_finish (_data_->self, _data_->_res_);
		_data_->response = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->response;
		_data_->_tmp9_ = proton_plus_utils_web_response_get_code (_data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		if (_data_->_tmp10_ != PROTON_PLUS_RETURN_CODE_VALID_REQUEST) {
			_data_->_tmp11_ = _data_->response;
			_data_->_tmp12_ = proton_plus_utils_web_response_get_code (_data_->_tmp11_);
			_data_->_tmp13_ = _data_->_tmp12_;
			_data_->_tmp14_ = proton_plus_models_tools_release_page_result_failure (_data_->_tmp13_);
			_data_->result = _data_->_tmp14_;
			_g_object_unref0 (_data_->response);
			_g_object_unref0 (_data_->releases);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp15_ = _data_->response;
		_data_->_tmp16_ = proton_plus_utils_web_response_get_body (_data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = proton_plus_providers_sources_git_hub_actions_release_source_parse_response (_data_->self, _data_->definition, _data_->_tmp17_, _data_->current_page, _data_->limit);
		_data_->page_result = _data_->_tmp18_;
		_data_->_tmp19_ = _data_->page_result;
		_data_->_tmp20_ = proton_plus_models_tools_release_page_result_get_succeeded (_data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		if (!_data_->_tmp21_) {
			_data_->result = _data_->page_result;
			_g_object_unref0 (_data_->response);
			_g_object_unref0 (_data_->releases);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp22_ = _data_->page_result;
		_data_->_tmp23_ = proton_plus_models_tools_release_page_result_require_page (_data_->_tmp22_);
		_data_->page = _data_->_tmp23_;
		_data_->_tmp24_ = _data_->releases;
		_data_->_tmp25_ = _data_->page;
		_data_->_tmp26_ = proton_plus_models_tools_release_page_get_releases (_data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		gee_collection_add_all ((GeeCollection*) _data_->_tmp24_, (GeeCollection*) _data_->_tmp27_);
		_data_->_tmp28_ = _data_->page;
		_data_->_tmp29_ = proton_plus_models_tools_release_page_get_has_more (_data_->_tmp28_);
		_data_->_tmp30_ = _data_->_tmp29_;
		_data_->reached_end = !_data_->_tmp30_;
		_data_->_tmp31_ = _data_->page;
		_data_->_tmp32_ = proton_plus_models_tools_release_page_get_next_page (_data_->_tmp31_);
		_data_->_tmp33_ = _data_->_tmp32_;
		_data_->current_page = _data_->_tmp33_;
		_g_object_unref0 (_data_->page);
		_g_object_unref0 (_data_->page_result);
		_g_object_unref0 (_data_->response);
	}
	_data_->_tmp34_ = _data_->releases;
	_data_->_tmp35_ = proton_plus_models_tools_release_page_new (_data_->_tmp34_, _data_->current_page, !_data_->reached_end);
	_data_->_tmp36_ = _data_->_tmp35_;
	_data_->_tmp37_ = proton_plus_models_tools_release_page_result_success (_data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	_g_object_unref0 (_data_->_tmp36_);
	_data_->result = _data_->_tmp38_;
	_g_object_unref0 (_data_->releases);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

static gpointer
_json_array_ref0 (gpointer self)
{
	return self ? json_array_ref (self) : NULL;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		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_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			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_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 NULL;
}

ProtonPlusModelsToolsReleasePageResult*
proton_plus_providers_sources_git_hub_actions_release_source_parse_response (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                             ProtonPlusModelsProvidersProviderDefinition* definition,
                                                                             const gchar* response_body,
                                                                             gint requested_page,
                                                                             gint limit)
{
	JsonNode* root_node = NULL;
	gboolean _tmp4_ = FALSE;
	JsonNode* _tmp5_;
	JsonObject* root = NULL;
	JsonNode* _tmp8_;
	JsonObject* _tmp9_;
	JsonObject* _tmp10_;
	JsonArray* _tmp11_ = NULL;
	JsonObject* _tmp12_;
	JsonArray* runs = NULL;
	JsonArray* _tmp15_;
	JsonArray* _tmp16_;
	GeeLinkedList* releases = NULL;
	GeeLinkedList* _tmp18_;
	GeeLinkedList* _tmp82_;
	JsonArray* _tmp83_;
	ProtonPlusModelsToolsReleasePage* _tmp84_;
	ProtonPlusModelsToolsReleasePage* _tmp85_;
	ProtonPlusModelsToolsReleasePageResult* _tmp86_;
	ProtonPlusModelsToolsReleasePageResult* _tmp87_;
	GError* _inner_error0_ = NULL;
	ProtonPlusModelsToolsReleasePageResult* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (definition != NULL, NULL);
	g_return_val_if_fail (response_body != NULL, NULL);
	{
		JsonNode* _tmp0_ = NULL;
		JsonNode* _tmp1_;
		JsonNode* _tmp2_;
		_tmp1_ = json_from_string (response_body, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		__vala_JsonNode_free0 (root_node);
		root_node = _tmp2_;
		__vala_JsonNode_free0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		ProtonPlusModelsToolsReleasePageResult* _tmp3_;
		g_clear_error (&_inner_error0_);
		_tmp3_ = proton_plus_models_tools_release_page_result_failure (PROTON_PLUS_RETURN_CODE_INVALID_DATA);
		result = _tmp3_;
		__vala_JsonNode_free0 (root_node);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		__vala_JsonNode_free0 (root_node);
		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 NULL;
	}
	_tmp5_ = root_node;
	if (_tmp5_ == NULL) {
		_tmp4_ = TRUE;
	} else {
		JsonNode* _tmp6_;
		_tmp6_ = root_node;
		_tmp4_ = json_node_get_node_type (_tmp6_) != JSON_NODE_OBJECT;
	}
	if (_tmp4_) {
		ProtonPlusModelsToolsReleasePageResult* _tmp7_;
		_tmp7_ = proton_plus_models_tools_release_page_result_failure (PROTON_PLUS_RETURN_CODE_INVALID_DATA);
		result = _tmp7_;
		__vala_JsonNode_free0 (root_node);
		return result;
	}
	_tmp8_ = root_node;
	_tmp9_ = json_node_get_object (_tmp8_);
	_tmp10_ = _json_object_ref0 (_tmp9_);
	root = _tmp10_;
	_tmp12_ = root;
	if (_tmp12_ != NULL) {
		JsonObject* _tmp13_;
		JsonArray* _tmp14_;
		_tmp13_ = root;
		_tmp14_ = json_object_get_array_member (_tmp13_, "workflow_runs");
		_tmp11_ = _tmp14_;
	} else {
		_tmp11_ = NULL;
	}
	_tmp15_ = _json_array_ref0 (_tmp11_);
	runs = _tmp15_;
	_tmp16_ = runs;
	if (_tmp16_ == NULL) {
		ProtonPlusModelsToolsReleasePageResult* _tmp17_;
		_tmp17_ = proton_plus_models_tools_release_page_result_failure (PROTON_PLUS_RETURN_CODE_INVALID_DATA);
		result = _tmp17_;
		_json_array_unref0 (runs);
		_json_object_unref0 (root);
		__vala_JsonNode_free0 (root_node);
		return result;
	}
	_tmp18_ = gee_linked_list_new (PROTON_PLUS_MODELS_TYPE_RELEASE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	releases = _tmp18_;
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp19_ = FALSE;
			_tmp19_ = TRUE;
			while (TRUE) {
				JsonArray* _tmp21_;
				JsonObject* run = NULL;
				JsonArray* _tmp22_;
				JsonObject* _tmp23_;
				JsonObject* _tmp24_;
				gboolean _tmp25_ = FALSE;
				gboolean _tmp26_ = FALSE;
				JsonObject* _tmp27_;
				gchar* _tmp32_ = NULL;
				JsonObject* _tmp33_;
				gchar* release_name = NULL;
				gchar* _tmp37_;
				const gchar* _tmp38_;
				gint64 _tmp39_ = 0LL;
				JsonObject* _tmp40_;
				gint64 id = 0LL;
				gchar* download_url = NULL;
				const gchar* _tmp42_;
				const gchar* _tmp43_;
				gchar* _tmp44_;
				gchar* _tmp45_;
				gchar* _tmp46_;
				gchar* _tmp47_;
				ProtonPlusModelsAssetsAsset* asset = NULL;
				const gchar* _tmp48_;
				ProtonPlusModelsAssetsAsset* _tmp49_;
				GeeLinkedList* assets = NULL;
				GeeLinkedList* _tmp50_;
				GeeLinkedList* _tmp51_;
				ProtonPlusModelsAssetsAsset* _tmp52_;
				GeeLinkedList* variants = NULL;
				const gchar* _tmp53_;
				const gchar* _tmp54_;
				GeeLinkedList* _tmp55_;
				GeeLinkedList* _tmp56_;
				ProtonPlusModelsAssetsAsset* primary_asset = NULL;
				GeeLinkedList* _tmp57_;
				GeeLinkedList* _tmp58_;
				ProtonPlusModelsAssetsAsset* _tmp59_;
				ProtonPlusModelsAssetsAsset* _tmp60_;
				gchar* _tmp61_ = NULL;
				ProtonPlusModelsRelease* release = NULL;
				const gchar* _tmp64_;
				JsonObject* _tmp65_;
				gchar* _tmp66_;
				gchar* _tmp67_;
				ProtonPlusModelsAssetsAsset* _tmp68_;
				JsonObject* _tmp69_;
				const gchar* _tmp70_;
				ProtonPlusModelsAssetsAsset* _tmp71_;
				gint64 _tmp72_;
				gint64 _tmp73_;
				JsonObject* _tmp74_;
				const gchar* _tmp75_;
				ProtonPlusModelsRelease* _tmp76_;
				ProtonPlusModelsRelease* _tmp77_;
				ProtonPlusModelsRelease* _tmp78_;
				GeeLinkedList* _tmp79_;
				GeeLinkedList* _tmp80_;
				ProtonPlusModelsRelease* _tmp81_;
				if (!_tmp19_) {
					gint _tmp20_;
					_tmp20_ = index;
					index = _tmp20_ + 1;
				}
				_tmp19_ = FALSE;
				_tmp21_ = runs;
				if (!(((guint) index) < json_array_get_length (_tmp21_))) {
					break;
				}
				_tmp22_ = runs;
				_tmp23_ = json_array_get_object_element (_tmp22_, (guint) index);
				_tmp24_ = _json_object_ref0 (_tmp23_);
				run = _tmp24_;
				_tmp27_ = run;
				if (_tmp27_ == NULL) {
					_tmp26_ = TRUE;
				} else {
					JsonObject* _tmp28_;
					const gchar* _tmp29_;
					_tmp28_ = run;
					_tmp29_ = json_object_get_string_member_with_default (_tmp28_, "status", "");
					_tmp26_ = g_strcmp0 (_tmp29_, "completed") != 0;
				}
				if (_tmp26_) {
					_tmp25_ = TRUE;
				} else {
					JsonObject* _tmp30_;
					const gchar* _tmp31_;
					_tmp30_ = run;
					_tmp31_ = json_object_get_string_member_with_default (_tmp30_, "conclusion", "");
					_tmp25_ = g_strcmp0 (_tmp31_, "success") != 0;
				}
				if (_tmp25_) {
					_json_object_unref0 (run);
					continue;
				}
				_tmp33_ = run;
				if (json_object_has_member (_tmp33_, "run_number")) {
					JsonObject* _tmp34_;
					gchar* _tmp35_;
					_tmp34_ = run;
					_tmp35_ = g_strdup_printf ("%" G_GINT64_FORMAT, json_object_get_int_member (_tmp34_, "run_number"));
					_g_free0 (_tmp32_);
					_tmp32_ = _tmp35_;
				} else {
					gchar* _tmp36_;
					_tmp36_ = g_strdup ("");
					_g_free0 (_tmp32_);
					_tmp32_ = _tmp36_;
				}
				_tmp37_ = _tmp32_;
				_tmp32_ = NULL;
				release_name = _tmp37_;
				_tmp38_ = release_name;
				if (!proton_plus_providers_sources_catalog_release_builder_is_eligible (definition, _tmp38_)) {
					_g_free0 (release_name);
					_g_free0 (_tmp32_);
					_json_object_unref0 (run);
					continue;
				}
				_tmp40_ = run;
				if (json_object_has_member (_tmp40_, "id")) {
					JsonObject* _tmp41_;
					_tmp41_ = run;
					_tmp39_ = json_object_get_int_member (_tmp41_, "id");
				} else {
					_tmp39_ = (gint64) 0;
				}
				id = _tmp39_;
				_tmp42_ = proton_plus_models_providers_provider_definition_get_url_template (definition);
				_tmp43_ = _tmp42_;
				_tmp44_ = g_strdup_printf ("%" G_GINT64_FORMAT, id);
				_tmp45_ = _tmp44_;
				_tmp46_ = string_replace (_tmp43_, "{id}", _tmp45_);
				_tmp47_ = _tmp46_;
				_g_free0 (_tmp45_);
				download_url = _tmp47_;
				_tmp48_ = download_url;
				_tmp49_ = proton_plus_models_assets_asset_from_download_url (_tmp48_, (gint64) 0, "");
				asset = _tmp49_;
				_tmp50_ = gee_linked_list_new (PROTON_PLUS_MODELS_ASSETS_TYPE_ASSET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
				assets = _tmp50_;
				_tmp51_ = assets;
				_tmp52_ = asset;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp51_, _tmp52_);
				_tmp53_ = release_name;
				_tmp54_ = release_name;
				_tmp55_ = assets;
				_tmp56_ = proton_plus_providers_sources_catalog_release_builder_create_variants (definition, _tmp53_, _tmp54_, _tmp55_);
				variants = _tmp56_;
				_tmp57_ = assets;
				_tmp58_ = variants;
				_tmp59_ = proton_plus_providers_sources_catalog_release_builder_select_default_asset (_tmp57_, _tmp58_);
				primary_asset = _tmp59_;
				_tmp60_ = primary_asset;
				if (_tmp60_ == NULL) {
					_g_object_unref0 (primary_asset);
					_g_object_unref0 (variants);
					_g_object_unref0 (assets);
					_g_object_unref0 (asset);
					_g_free0 (download_url);
					_g_free0 (release_name);
					_g_free0 (_tmp32_);
					_json_object_unref0 (run);
					continue;
				}
				if (id > ((gint64) 0)) {
					gchar* _tmp62_;
					_tmp62_ = g_strdup_printf ("%" G_GINT64_FORMAT, id);
					_g_free0 (_tmp61_);
					_tmp61_ = _tmp62_;
				} else {
					gchar* _tmp63_;
					_tmp63_ = g_strdup ("");
					_g_free0 (_tmp61_);
					_tmp61_ = _tmp63_;
				}
				_tmp64_ = release_name;
				_tmp65_ = run;
				_tmp66_ = proton_plus_providers_sources_release_source_support_get_iso8601_date (_tmp65_, "created_at");
				_tmp67_ = _tmp66_;
				_tmp68_ = primary_asset;
				_tmp69_ = run;
				_tmp70_ = json_object_get_string_member_with_default (_tmp69_, "html_url", "");
				_tmp71_ = primary_asset;
				_tmp72_ = proton_plus_models_assets_asset_get_download_size (_tmp71_);
				_tmp73_ = _tmp72_;
				_tmp74_ = run;
				_tmp75_ = json_object_get_string_member_with_default (_tmp74_, "artifacts_url", "");
				_tmp76_ = proton_plus_models_release_new (_tmp64_, "", _tmp67_, _tmp68_, _tmp70_, &_tmp73_, _tmp61_, "", PROTON_PLUS_MODELS_RELEASE_KIND_GITHUB_ACTION, _tmp75_);
				_tmp77_ = _tmp76_;
				_g_free0 (_tmp67_);
				release = _tmp77_;
				_tmp78_ = release;
				_tmp79_ = variants;
				proton_plus_providers_sources_release_source_support_add_variants (_tmp78_, (GeeIterable*) _tmp79_);
				_tmp80_ = releases;
				_tmp81_ = release;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp80_, _tmp81_);
				_g_object_unref0 (release);
				_g_free0 (_tmp61_);
				_g_object_unref0 (primary_asset);
				_g_object_unref0 (variants);
				_g_object_unref0 (assets);
				_g_object_unref0 (asset);
				_g_free0 (download_url);
				_g_free0 (release_name);
				_g_free0 (_tmp32_);
				_json_object_unref0 (run);
			}
		}
	}
	_tmp82_ = releases;
	_tmp83_ = runs;
	_tmp84_ = proton_plus_models_tools_release_page_new (_tmp82_, requested_page + 1, json_array_get_length (_tmp83_) == ((guint) limit));
	_tmp85_ = _tmp84_;
	_tmp86_ = proton_plus_models_tools_release_page_result_success (_tmp85_);
	_tmp87_ = _tmp86_;
	_g_object_unref0 (_tmp85_);
	result = _tmp87_;
	_g_object_unref0 (releases);
	_json_array_unref0 (runs);
	_json_object_unref0 (root);
	__vala_JsonNode_free0 (root_node);
	return result;
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_data_free (gpointer _data)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_;
	_data_ = _data;
	_g_free0 (_data_->endpoint);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData, _data_);
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_real_request_page (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                                const gchar* endpoint,
                                                                                gint page,
                                                                                gint limit,
                                                                                GAsyncReadyCallback _callback_,
                                                                                gpointer _user_data_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (endpoint != NULL);
	_data_ = g_slice_new0 (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (endpoint);
	_g_free0 (_data_->endpoint);
	_data_->endpoint = _tmp1_;
	_data_->page = page;
	_data_->limit = limit;
	proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_co (_data_);
}

static ProtonPlusUtilsWebResponse*
proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_finish (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                                       GAsyncResult* _res_)
{
	ProtonPlusUtilsWebResponse* result;
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_request_page_ready (GObject* source_object,
                                                                                 GAsyncResult* _res_,
                                                                                 gpointer _user_data_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_co (_data_);
}

static gboolean
proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_co (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceRequestPageData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_strdup_printf ("%s?per_page=%i&page=%i", _data_->endpoint, _data_->limit, _data_->page);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_state_ = 1;
	proton_plus_utils_web_get_request (_data_->_tmp1_, PROTON_PLUS_UTILS_WEB_GET_REQUEST_TYPE_GITHUB, NULL, proton_plus_providers_sources_git_hub_actions_release_source_request_page_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = proton_plus_utils_web_get_request_finish (_data_->_res_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_g_free0 (_data_->_tmp1_);
	_data_->result = _data_->_tmp3_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
proton_plus_providers_sources_git_hub_actions_release_source_request_page (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                           const gchar* endpoint,
                                                                           gint page,
                                                                           gint limit,
                                                                           GAsyncReadyCallback _callback_,
                                                                           gpointer _user_data_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass* _klass_;
	_klass_ = PROTON_PLUS_PROVIDERS_SOURCES_GIT_HUB_ACTIONS_RELEASE_SOURCE_GET_CLASS (self);
	if (_klass_->request_page) {
		_klass_->request_page (self, endpoint, page, limit, _callback_, _user_data_);
	}
}

ProtonPlusUtilsWebResponse*
proton_plus_providers_sources_git_hub_actions_release_source_request_page_finish (ProtonPlusProvidersSourcesGitHubActionsReleaseSource* self,
                                                                                  GAsyncResult* _res_)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass* _klass_;
	_klass_ = PROTON_PLUS_PROVIDERS_SOURCES_GIT_HUB_ACTIONS_RELEASE_SOURCE_GET_CLASS (self);
	if (_klass_->request_page_finish) {
		return _klass_->request_page_finish (self, _res_);
	}
	return NULL;
}

ProtonPlusProvidersSourcesGitHubActionsReleaseSource*
proton_plus_providers_sources_git_hub_actions_release_source_construct (GType object_type)
{
	ProtonPlusProvidersSourcesGitHubActionsReleaseSource * self = NULL;
	self = (ProtonPlusProvidersSourcesGitHubActionsReleaseSource*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusProvidersSourcesGitHubActionsReleaseSource*
proton_plus_providers_sources_git_hub_actions_release_source_new (void)
{
	return proton_plus_providers_sources_git_hub_actions_release_source_construct (PROTON_PLUS_PROVIDERS_SOURCES_TYPE_GIT_HUB_ACTIONS_RELEASE_SOURCE);
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_class_init (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass * klass,
                                                                         gpointer klass_data)
{
	proton_plus_providers_sources_git_hub_actions_release_source_parent_class = g_type_class_peek_parent (klass);
	((ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass *) klass)->request_page = (void (*) (ProtonPlusProvidersSourcesGitHubActionsReleaseSource*, const gchar*, gint, gint, GAsyncReadyCallback, gpointer)) proton_plus_providers_sources_git_hub_actions_release_source_real_request_page;
	((ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass *) klass)->request_page_finish = (ProtonPlusUtilsWebResponse* (*) (ProtonPlusProvidersSourcesGitHubActionsReleaseSource*, GAsyncResult*)) proton_plus_providers_sources_git_hub_actions_release_source_real_request_page_finish;
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_proton_plus_providers_sources_release_source_interface_init (ProtonPlusProvidersSourcesReleaseSourceIface * iface,
                                                                                                                          gpointer iface_data)
{
	proton_plus_providers_sources_git_hub_actions_release_source_proton_plus_providers_sources_release_source_parent_iface = g_type_interface_peek_parent (iface);
	iface->fetch_page = (void (*) (ProtonPlusProvidersSourcesReleaseSource*, ProtonPlusModelsProvidersProviderDefinition*, gint, gint, GAsyncReadyCallback, gpointer)) proton_plus_providers_sources_git_hub_actions_release_source_real_fetch_page;
	iface->fetch_page_finish = (ProtonPlusModelsToolsReleasePageResult* (*) (ProtonPlusProvidersSourcesReleaseSource*, GAsyncResult*)) proton_plus_providers_sources_git_hub_actions_release_source_fetch_page_finish;
}

static void
proton_plus_providers_sources_git_hub_actions_release_source_instance_init (ProtonPlusProvidersSourcesGitHubActionsReleaseSource * self,
                                                                            gpointer klass)
{
}

static GType
proton_plus_providers_sources_git_hub_actions_release_source_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusProvidersSourcesGitHubActionsReleaseSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_providers_sources_git_hub_actions_release_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusProvidersSourcesGitHubActionsReleaseSource), 0, (GInstanceInitFunc) proton_plus_providers_sources_git_hub_actions_release_source_instance_init, NULL };
	static const GInterfaceInfo proton_plus_providers_sources_release_source_info = { (GInterfaceInitFunc) proton_plus_providers_sources_git_hub_actions_release_source_proton_plus_providers_sources_release_source_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType proton_plus_providers_sources_git_hub_actions_release_source_type_id;
	proton_plus_providers_sources_git_hub_actions_release_source_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusProvidersSourcesGitHubActionsReleaseSource", &g_define_type_info, 0);
	g_type_add_interface_static (proton_plus_providers_sources_git_hub_actions_release_source_type_id, PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE, &proton_plus_providers_sources_release_source_info);
	return proton_plus_providers_sources_git_hub_actions_release_source_type_id;
}

GType
proton_plus_providers_sources_git_hub_actions_release_source_get_type (void)
{
	static volatile gsize proton_plus_providers_sources_git_hub_actions_release_source_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_providers_sources_git_hub_actions_release_source_type_id__once)) {
		GType proton_plus_providers_sources_git_hub_actions_release_source_type_id;
		proton_plus_providers_sources_git_hub_actions_release_source_type_id = proton_plus_providers_sources_git_hub_actions_release_source_get_type_once ();
		g_once_init_leave (&proton_plus_providers_sources_git_hub_actions_release_source_type_id__once, proton_plus_providers_sources_git_hub_actions_release_source_type_id);
	}
	return proton_plus_providers_sources_git_hub_actions_release_source_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

