package com.mojang.realmsclient.gui.screens;

import java.util.Iterator;
import java.util.List;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.network.chat.Component;
import net.minecraft.client.gui.components.Button;
import net.minecraft.Util;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.realms.NarrationHelper;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.realms.RealmsScreen;

public class RealmsParentalConsentScreen extends RealmsScreen {
    private final Screen nextScreen;
    
    public RealmsParentalConsentScreen(final Screen dqs) {
        this.nextScreen = dqs;
    }
    
    public void init() {
        NarrationHelper.now(I18n.get("mco.account.privacyinfo"));
        final Component mr2 = new TranslatableComponent("mco.account.update");
        final Component mr3 = CommonComponents.GUI_BACK;
        final int integer4 = Math.max(this.font.width(mr2), this.font.width(mr3)) + 30;
        final Component mr4 = new TranslatableComponent("mco.account.privacy.info");
        final int integer5 = (int)(this.font.width(mr4) * 1.2);
        this.<Button>addButton(new Button(this.width / 2 - integer5 / 2, RealmsScreen.row(11), integer5, 20, mr4, dni -> Util.getPlatform().openUri("https://minecraft.net/privacy/gdpr/")));
        this.<Button>addButton(new Button(this.width / 2 - (integer4 + 5), RealmsScreen.row(13), integer4, 20, mr2, dni -> Util.getPlatform().openUri("https://minecraft.net/update-account")));
        this.<Button>addButton(new Button(this.width / 2 + 5, RealmsScreen.row(13), integer4, 20, mr3, dni -> this.minecraft.setScreen(this.nextScreen)));
    }
    
    @Override
    public void render(final PoseStack dhl, final int integer2, final int integer3, final float float4) {
        this.renderBackground(dhl);
        final List<FormattedText> list6 = this.minecraft.font.split(new TranslatableComponent("mco.account.privacyinfo"), (int)Math.round(this.width * 0.9));
        int integer4 = 15;
        for (final FormattedText mu9 : list6) {
            this.drawCenteredString(dhl, this.font, mu9, this.width / 2, integer4, 16777215);
            integer4 += 15;
        }
        super.render(dhl, integer2, integer3, float4);
    }
}
