{{ header }}

<header class="background-white bottom-margin-large" id="page-product-form" data-info='{"type_marketplace": "{{ type_marketplace }}"}'>
	<div class="container-fluid">
		<div class="row no-space-xs">
			<div class="col-xs-12">
				<div class="content-box vertical-padding-large flex between-xs middle-xs js-header-notifications">
					<div>
						<span class="text-x-large text-dark vertical-middle js-product-name">{{ heading_title }}</span>
						{% if is_grid %}
							<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-info text-info vertical-middle left-margin-x-small cursor-pointer js-product-grid" data-product-key-id="{{ product_key_id }}">Grade</span>
						{% endif %}
						<div class="adm-breadcrumb">
							{% for breadcrumb in breadcrumbs %}
								<i class="fas fa-angle-right text-x-small text-gray horizontal-padding-small"></i>
								<a href="{{ breadcrumb.href }}" class="text-x-small text-gray text-decoration-none">{{ breadcrumb.text }}</a>
							{% endfor %}
						</div>
					</div>
					{% if is_grid %}
						<span class="text-primary visible-inline-block cursor-pointer text-decoration-none vertical-padding-small js-product-grid" data-product-key-id="{{ product_key_id }}">Outros itens da grade</span>
					{% endif %}
				</div>
				{% if error_message %}<div class="warning">{{ error_message }}</div>{% endif %}
				{% if success %}<div class="success">{{ success }}</div>{% endif %}
			</div>
			<div class="col-xs-12">
				<div class="flex js-tabs" id="tab-info"></div>
			</div>
		</div>
	</div>
</header>

<div class="container-fluid" data-tabs-id="tab-info">
	<div class="row hidden" data-tab="{{ tab_general }}">
		<div class="col-xs-12 bottom-padding-small">
			<div class="content-box">
				<span class="text-x-large text-dark">{{ t_information }}</span>
			</div>
		</div>
		<div class="col-xs-12 col-md-8">
			<div class="content-box">
				<div class="row">
					<div class="col-xs-12 bottom-padding-x-large">
						<div class="content-box background-white padding-large shadow-small">
							{% for language in languages %}
								<div class="row">
									<div class="col-xs-12">
										<div class="content-box flex between-xs middle-xs">
											<div>
												{% if status %}
													<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-success text-success right-margin-small">{{ text_enabled }}</span>
												{% else %}
													<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-error text-error right-margin-small">{{ text_disabled }}</span>
												{% endif %}
												{% if quantity == 0 %}
													<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-error text-error">{{ t_sold_out }}</span>
												{% endif %}
											</div>
											<div class="text-right">
												<span class="text-small text-gray visible-block">{{ t_registered_in }}
													{{ date_available }}</span>
												{% if data_replicacao_ecommerce %}
													<span class="text-small text-gray visible-block">{{ t_repliqued_in }}
														{{ data_replicacao_ecommerce }}</span>
												{% endif %}
											</div>
										</div>
									</div>
									<div class="col-xs-12">
										<div class="content-box flex between-xs middle-xs">
											<div>
												<span class="text-small text-gray visible-block">{{ entry_name }}</span>
												{% if product_description[language.language_id] is defined and product_description[language.language_id] is not empty %}
													<span class="text-medium text-dark visible-block top-margin-small text-break-word">{{ product_description[language.language_id].name }}</span>
												{% endif %}
											</div>
											{% if status %}
												<div>
													<a href="{{ href }}" target="_blank" class="btn-default btn-medium btn-outline">
														<span>{{ text_see_store }}</span>
													</a>
												</div>
											{% endif %}

										</div>
									</div>

									{% if itens_kit %}
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block bottom-margin-small">Produtos do kit</span>
												{% for itemKitKey, itemKit in itens_kit %}
													<span class="text-medium text-dark visible-block">
														<b>{{itemKit.quantidade}}</b>
														-
														{{itemKit.descricao}}</span>
												{% endfor %}
											</div>
										</div>
									{% endif %}

									{% if cor %}
										<div class="col-xs-4">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ color_template_description }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ cor }}</span>
											</div>
										</div>
									{% endif %}
									{% if especificacao %}
										<div class="col-xs-4">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ specification_template_description }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ especificacao }}</span>
											</div>
										</div>
									{% endif %}
									{% if tamanho %}
										<div class="col-xs-4">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ size_template_description }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ tamanho }}</span>
											</div>
										</div>
									{% endif %}

									<div class="col-xs-12">
										<div class="row">
											<div class="content-box col-xs-4">
												<span class="text-small text-gray visible-block">{{ entry_price }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ price }}</span>
											</div>
											{% if mktplace_price is defined %}
												<div class="content-box col-xs-8">
													<span class="text-small text-gray visible-block">{{ entry_mktplace_price_description }}</span>
													<span class="text-medium text-dark visible-block top-margin-small">{{ mktplace_price }}</span>
												</div>
											{% endif %}
										</div>
									</div>
									<div class="col-xs-12">
										<div class="content-box">
											<span class="text-small text-gray visible-block">{{ entry_classification }}</span>
											<span class="text-medium text-dark visible-block top-margin-small">{{ product_classification }}</span>
										</div>
									</div>
									<div class="col-xs-12">
										<div class="content-box">
											<span class="text-small text-gray visible-block">{{ entry_category }}</span>
										</span>
										<span class="text-medium text-dark visible-block top-margin-small">
											{% if product_category.name %}
												{{ product_category.name }}
											{% endif %}
										</span>
									</div>
								</div>
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_description }}</span>
										{% if product_description[language.language_id] is defined and product_description[language.language_id] is not empty %}
											<div class="text-medium text-dark top-margin-small reset-product-description">{{ product_description[language.language_id].description }}</div>
										{% endif %}
									</div>
								</div>
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_manufacturer }}</span>
										<span class="text-medium text-dark visible-block top-margin-small">{{ manufacturer }}</span>
									</div>
								</div>
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_tag }}</span>
										{% if product_description[language.language_id] is defined %}
											<span class="text-medium text-dark visible-block top-margin-small">{{ product_description[language.language_id].tag }}</span>
										{% endif %}
									</div>
								</div>
							</div>
						{% endfor %}
					</div>
				</div>
				{% if produto_brinde %}
					<div class="col-xs-12 bottom-padding-small">
						<span class="text-x-large text-dark">{{ 'Brinde' }}</span>
					</div>
					<div class="col-xs-12 bottom-padding-x-large">
						<div class="content-box background-white padding-large shadow-small">
							<a href="{{ produto_brinde.href }}" class="flex nowrap-xs middle-xs text-decoration-none">
								<div class="right-margin-medium">
									<img src="{{produto_brinde.thumb }}" class="load-image visible-block" height="80" data-src="{{ produto_brinde.thumb }}">
								</div>
								<div>
									<span class="text-medium text-dark visible-block">{{ produto_brinde.product_name }}</span>
									{% if produto_brinde.quantity > 0 %}
										<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block text-success background-success">{{ text_in_stock }}</span>
									{% else %}
										<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block text-error background-error">{{ text_out_of_stock }}</span>
									{% endif %}
								</div>
							</a>
						</div>
					</div>
				{% endif %}
				<div class="col-xs-12 bottom-padding-small">
					<span class="text-x-large text-dark">{{ t_stock }}</span>
				</div>
				<div class="col-xs-12 bottom-padding-x-large">
					<div class="content-box background-white padding-large shadow-small">
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_stock_status }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">
									{% for stock_status in stock_statuses %}
										{% if stock_status.stock_status_id == stock_status_id %}
											{{ stock_status.name }}
										{% endif %}
									{% endfor %}
								</span>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_shipping }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">
									{{ shipping ? text_yes : text_no }}
								</span>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_quantity }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ quantity }}</span>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_minimum }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ minimum }}</span>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_location }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ location }}</span>
							</div>
						</div>
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">
									{{ entry_weight }}
									{% for weight_class in weight_classes %}
										{% if weight_class.weight_class_id == weight_class_id %}
											({{ weight_class.title }})
										{% endif %}
									{% endfor %}
								</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ weight }}</span>
							</div>
						</div>

						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">
									{{ entry_net_weight }}
									{% for weight_class in weight_classes %}
										{% if weight_class.weight_class_id == weight_class_id %}
											({{ weight_class.title }})
										{% endif %}
									{% endfor %}
								</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ net_weight }}</span>
							</div>
						</div>

						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">
									{{ entry_dimension }}
									{% for length_class in length_classes %}
										{% if length_class.length_class_id == length_class_id %}
											({{ length_class.title }})
										{% endif %}
									{% endfor %}
								</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ t_length }}:
									{{ length }}</span>
								<span class="text-medium text-dark visible-block">{{ t_width }}:
									{{ width }}</span>
								<span class="text-medium text-dark visible-block">{{ t_height }}:
									{{ height }}</span>
							</div>
						</div>

						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">
									{{ entry_dimension_prog }}
									{% for length_class in length_classes %}
										{% if length_class.length_class_id == length_class_id %}
											({{ length_class.title }})
										{% endif %}
									{% endfor %}
								</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ t_length }}:
									{{ comp_progressiva }}</span>
								<span class="text-medium text-dark visible-block">{{ t_width }}:
									{{ larg_progressiva }}</span>
								<span class="text-medium text-dark visible-block">{{ t_height }}:
									{{ alt_progressiva }}</span>
							</div>
						</div>

						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_quantity_unit }}</span>
								<span class="text-medium text-dark visible-block top-margin-small">{{ quantity_unit }}</span>
							</div>
						</div>
					</div>
				</div>
				<div class="col-xs-12 bottom-padding-small">
					<span class="text-x-large text-dark">{{ t_additional_images }}</span>
				</div>
				<div class="col-xs-12">
					<div class="row">
						{% if product_images %}
							{% for product_image in product_images %}
								<div class="col-xs-6 col-md-3">
									<div class="content-box text-center background-white padding-medium shadow-small">
										<img src="{{ product_image.thumb }}" alt=""/>
										<div class="content-box flex between-xs top-margin-medium">
											<span class="text-small text-gray text-start visible-block">{{ entry_sort_order }}
												{{ product_image.sort_order }}</span>
											<!-- {{ product_image.id_futura }} -->
											{% if product_image.maximumImageWeight %}
												<div class="cursor-pointer tooltip-region-rule left-margin-large" data-tooltip="{{ maximum_weight }}">
													<span class="field-label">
														<i class="text-warning fa-exclamation-triangle fas"></i>
													</span>
												</div>
											{% endif %}
											<a class="fa-solid fa-download text-primary visible-inline-block cursor-pointer text-decoration-none" href="{{ product_image.downloadImage }}" style="font-size: 15px;" title="Download da imagem"></a>
										</div>
									</div>
								</div>
							{% endfor %}
						{% else %}
							<div class="col-xs-12">
								<div class="content-box background-white shadow-small vertical-padding-x-large horizontal-padding-large text-center">
									<span class="text-medium text-gray">{{ t_no_additional_images }}</span>
								</div>
							</div>
						{% endif %}
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="col-xs-12 col-md-4">
		<div class="content-box">
			<div class="row">
				<div class="col-xs-12 bottom-padding-x-large">
					<div class="content-box background-white padding-x-large shadow-small">
						<div class="content-box flex end-xs">
							<a class="fa-solid fa-download text-primary visible-inline-block cursor-pointer text-decoration-none bottom-padding-large text-x-large" href="{{ mainProductImage }}" title="Download da imagem"></a>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<div class="content-box">
									<img src="{{ thumb }}" class="full-width">
								</div>
							</div>
							{% if maximumWeight %}
								<div class="col-xs-12" id="image-resize-section">
									{# <div class="content-box padding-medium rounded-small">
										<a href="{{ hreffix }}" id="button-fix-image" class="btn-default btn-medium btn-outline">
											<span>{{ text_fix_image }}</span>
										</a>
									</div> #}
									<div class="content-box background-warning border-info padding-medium rounded-small">
										<div class="row no-space-xs">
											<div class="col-xs-width-auto">
												<div class="content-box right-padding-small top-padding-x-small">
													<i class="fa-exclamation-triangle fas text-medium text-warning"></i>
												</div>
											</div>
											<div class="col-xs">
												<div class="content-box">
													<span class="text-small" style="color:#000">{{ maximum_weightMainImage }}</span>
												</div>
											</div>
										</div>
									</div>
								</div>
							{% endif %}
						</div>
					</div>
				</div>
				<div class="col-xs-12 bottom-padding-small">
					<span class="text-x-large text-dark">{{ t_codes }}</span>
				</div>
				<div class="col-xs-12 bottom-padding-x-large">
					<div class="content-box background-white padding-x-large shadow-small">
						<div class="row">
							<div class="col-xs-12">
								<div class="content-box">
									<div class="row">
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ entry_bar_code }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ codigo_barra }}</span>
											</div>
										</div>
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ entry_model }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ model }}</span>
											</div>
										</div>
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ entry_cod_ecommerce }}</span>
												<span class="text-medium text-dark visible-block top-margin-small js-product-id">{{ product_id_ecommerce }}</span>
											</div>
										</div>
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ entry_cod_futura }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ product_id_futura }}</span>
											</div>
										</div>
										<div class="col-xs-12">
											<div class="content-box">
												<span class="text-small text-gray visible-block">{{ entry_sku }}</span>
												<span class="text-medium text-dark visible-block top-margin-small">{{ sku }}</span>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="col-xs-12 bottom-padding-small">
					<span class="text-x-large text-dark">{{ t_information_google }}</span>
				</div>
				<div class="col-xs-12">
					<div class="content-box background-white padding-large shadow-small">
						{% for language in languages %}
							<div class="row">
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_meta_description }}</span>
										{% if product_description[language.language_id] is defined and product_description[language.language_id] is not empty %}
											<span class="text-medium text-dark visible-block top-margin-small text-break-word">{{ product_description[language.language_id].meta_description }}</span>
										{% endif %}
									</div>
								</div>
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_meta_keyword }}</span>
										{% if product_description[language.language_id] is defined and product_description[language.language_id] is not empty %}
											<span class="text-medium text-dark visible-block top-margin-small text-break-word">{{ product_description[language.language_id].meta_keyword }}</span>
										{% endif %}
									</div>
								</div>
								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_keyword }}</span>
										<span class="text-medium text-dark visible-block top-margin-small text-break-word">{{ keyword }}</span>
									</div>
								</div>

								<div class="col-xs-12">
									<div class="content-box">
										<span class="text-small text-gray visible-block">{{ entry_list_in_feeds }}</span>
										<span class="text-medium text-dark visible-block top-margin-small">{{ list_in_feeds }}</span>
									</div>
								</div>

							</div>
						{% endfor %}
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

{% if product_discounts %}
	<div class="row hidden" data-tab="{{ tab_discount }}">
		<div class="col-xs-12">
			{% for product_discount in product_discounts %}
				<a href="{{ product_discount.href }}" target="_blank" class="content-box visible-block text-decoration-none background-white padding-medium bottom-margin-small shadow-small hover:shadow-large">
					<div class="row no-space-xs">
						<div class="col-xs">
							<div class="content-box">
								<span class="text-small text-dark">
									{% for customer_group in customer_groups %}
										{% if customer_group.customer_group_id == product_discount.customer_group_id %}
											{{ customer_group.name }}
										{% endif %}
									{% endfor %}
								</span>
							</div>
						</div>
						<div class="col-xs">
							<div class="content-box">
								<span class="text-small text-gray">{{ product_discount.price }}</span>
							</div>
						</div>
						<div class="col-xs">
							<div class="content-box">
								{% if product_discount.quantity == 'Habilitado' %}
									<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-success text-success">{{ product_discount.quantity }}</span>
								{% else %}
									<span class="text-x-small horizontal-padding-small vertical-padding-x-small rounded-large visible-inline-block background-error text-error">{{ text_disabled }}</span>
								{% endif %}
							</div>
						</div>
					</div>
				</a>
			{% endfor %}
		</div>
	</div>
{% endif %}
{% if product_translations %}
	<div class="row hidden" data-tab="{{ tab_translation }}">
		<div class="col-xs-12">
			<div class="content-box">
				<div class="row">
					{% for product_translation in product_translations %}
						<div class="col-xs-12 bottom-padding-x-small">
							<div class="content-box">
								<span class="text-x-large text-dark">{{ product_translation.linguagem }}</span>
							</div>
						</div>
						<div class="col-xs-12 bottom-padding-x-medium">
							<div class="content-box background-white padding-medium shadow-small">
								<div class="row">
									<div class="col-xs-12">
										<span class="text-small text-gray visible-block">{{ entry_name }}</span>
										{{ product_translation.descricao_ecommerce }}
									</div>
								</div>
								<div class="row">
									<div class="col-xs-12">
										<span class="text-small text-gray visible-block">{{ entry_description }}</span>
										{{ product_translation.descricao_completa }}
									</div>
								</div>
							</div>
						</div>
					{% endfor %}
				</div>
			</div>
		</div>
	</div>
{% endif %}
{% if mercadolivre_able %}
	<div class="row hidden" data-tab="{{ tab_mercadolivre }}">
		<div class="col-xs-12">
			<div class="content-box background-white padding-large shadow-small">
				<div class="row">
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_id }}</span>
							{% if product_mercaId is defined and product_mercaId is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">{{ product_mercaId }}</span>
							{% endif %}
						</div>
					</div>
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_category }}</span>
							{% if mercaTree is defined and mercaTree is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">{{ mercaTree }}</span>
							{% endif %}
						</div>
					</div>

					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_buying_mode }}</span>
							{% if mercadolivre_modes is defined and mercadolivre_modes is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">
									{% for key, value in mercadolivre_modes %}
										{% if mercaBuyMode == key %}
											{{ value }}
										{% endif %}
									{% endfor %}
								</span>
							{% endif %}
						</div>
					</div>
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_listing_type }}</span>
							{% if mercadolivre_types is defined and mercadolivre_types is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">
									{% for mercadolivre_type in mercadolivre_types %}
										{% if mercaListType == mercadolivre_type.value %}
											{{ mercadolivre_type.name }}
										{% endif %}
									{% endfor %}
								</span>
							{% endif %}
						</div>
					</div>
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_condition }}</span>
							{% if mercadolivre_conditions is defined and mercadolivre_conditions is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">
									{% for key, value in mercadolivre_conditions %}
										{% if mercaCondition == key %}
											{{ value }}
										{% endif %}
									{% endfor %}
								</span>
							{% endif %}
						</div>
					</div>
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_warranty }}</span>
							{% if mercaWarranty is defined and mercaWarranty is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">{{ mercaWarranty }}</span>
							{% endif %}
						</div>
					</div>
					<div class="col-xs-12">
						<div class="content-box">
							<span class="text-small text-gray visible-block">{{ entry_mercadolivre_video }}</span>
							{% if mercaVideoId is defined and mercaVideoId is not empty %}
								<span class="text-medium text-dark visible-block top-margin-small">{{ mercaVideoId }}</span>
							{% endif %}
						</div>
					</div>
					{% for language in languages %}
						<div class="col-xs-12">
							<div class="content-box">
								<span class="text-small text-gray visible-block">{{ entry_description_no_format }}</span>
								{% if product_description[language.language_id] is defined and product_description[language.language_id] is not empty %}
									<span class="text-medium text-dark visible-block top-margin-small">{{ product_description[language.language_id].description_complete_s_format }}</span>
								{% endif %}
							</div>
						</div>
					{% endfor %}
				</div>
			</div>
		</div>
	</div>
{% endif %}
</div>
<script type="text/javascript">

document.addEventListener('DOMContentLoaded', function() {
    const fixImageButton = document.getElementById('button-fix-image');
    // Referência ao div de mensagem local, estilizado como um alerta do sistema
    // const imageResizeMessageBox = document.getElementById('image-resize-message-box');
    const imageResizeSection = document.getElementById('image-resize-section');
    const mainProductImage = document.getElementById('image-thumb'); // VERIFIQUE/AJUSTE O ID DA SUA IMAGEM PRINCIPAL

    // Função para exibir mensagens com estilos do tema (similar aos alertas do sistema)

    if (fixImageButton) {
        fixImageButton.addEventListener('click', function(e) {
            e.preventDefault();

            const url = this.href;
            const originalButtonText = this.querySelector('span').textContent;
            const buttonSpan = this.querySelector('span');

            this.classList.add('disabled');
            buttonSpan.textContent = 'Processando...';
            // imageResizeMessageBox.style.display = 'none'; // Esconde qualquer mensagem anterior

            fetch(url, {
                method: 'POST'
            })
            .then(response => {
                // Se o backend retorna JSON, ele pode conter uma mensagem ou status para depuração,
                // mas a mensagem principal será via reload e Twig.
                const contentType = response.headers.get('content-type');
                if (contentType && contentType.indexOf('application/json') !== -1) {
                    return response.json(); // Consome o JSON se houver para evitar erro de leitura
                } else {
                    // Se não for JSON, apenas retorna o texto ou lança erro
                    return response.text().then(text => {
                        console.error('Resposta não é JSON:', text); // Log para depuração
                        // Não precisamos mais exibir a mensagem na div personalizada aqui.
                        // O reload cuidará disso.
                    });
                }
            })
            .then(data => {
                // Não precisamos mais exibir a mensagem via JS. O backend fará isso.
                // Apenas forçamos o reload.
                setTimeout(() => { // Pequeno atraso para garantir que a resposta do servidor seja processada antes do reload
                    location.reload();
                }, 500); // Recarrega após 0.5 segundos
            })
            .catch(error => {
                console.error('Erro na requisição de redimensionamento:', error);
                // Em caso de erro de comunicação, ainda é bom recarregar para exibir a mensagem do backend.
                setTimeout(() => {
                    location.reload();
                }, 500); // Recarrega após 0.5 segundos
            })
            .finally(() => {
                // Os botões serão reativados pelo reload da página, mas é bom ter o finally.
                // this.classList.remove('disabled');
                // buttonSpan.textContent = originalButtonText;
            });
        });
    }
});


// function getCategoryTree() {
//    var tree='';
//    $('select.mercadolivre_cat_selection option:selected').each(function(){
// 	  if($(this).val()!=''){
// 		  if(tree=='')tree+=$(this).text();
// 		  else tree+=' &raquo; '+$(this).text();
// 	  }
//    });
//
//    $('#mercaTree').val(tree);
//    $('#category_tree_span').html(tree);
// }
//
// function getCatAttr(catId) {
// 	     var product_id = '<?php echo isset($this->request->get['product_id'])?$this->request->get['product_id']:0; ?>';
// 		 $.ajax({
// 		 url: 'index.php?route=module/mercadolivre/mercadolivre/attribute&token=<?php echo $token; ?>',
// 		 dataType: 'json',
// 		 data:{catId:catId,product_id:product_id},
// 		 beforeSend:function()
// 			{
// 				$('body').css('cursor','wait');
// 			},
// 		success: function(result) {
// 			$('body').css('cursor','default');
// 			ml_attr_row=result.row;
// 			$('#ml_attr_row_wrapper td').html(result.html);
// 			if(result.html==''){
// 			  $('#ml_attr_row_wrapper').hide();
// 			}
// 			else {
// 			 $('#ml_attr_row_wrapper').show();
// 		   }
// 	}
//   });
// }
//
// if ($('#mercaId').length>0) {
//   if($('#mercaId').val()!='') getCatAttr($('#mercaId').val());
// }
//
// function addMLAttribute(){
//    var no_of_ml_attr=$('tr.ml_attr_row').length;
//       no_of_ml_attr=parseInt(no_of_ml_attr)+1;
//
//       while($('#ml_attr_row'+no_of_ml_attr).length!=0)
//        {
//          no_of_ml_attr++;
//        }
//        ml_attr_row_html=ml_attr_row;
//        ml_attr_row_html=ml_attr_row_html.replace(/__AINDEX__/g, no_of_ml_attr);
//        $('#ml_attribute tbody').append(ml_attr_row_html);
// }
//
// function removeMLAttribute(id){
//   $('#ml_attr_row'+id).remove();
// }
//
// 
</script>

{{ footer }}
