<?php $_shouldextend[1]=1; ?>

<?php 
 $fields = [
 [
 'name' => 'country',
 'brackets' => true,
 'label' => 'order.country',
 ],

 [
 'name' => 'city',
 'brackets' => true,
 'label' => 'order.city',
 ],

 [
 'name' => 'street',
 'brackets' => true,
 'label' => 'order.street',
 ],

 [
 'name' => 'building',
 'brackets' => true,
 'label' => 'order.building',
 ],
 
 [
 'name' => 'flat',
 'brackets' => true,
 'label' => 'order.flat',
 ],
 ];
 ?>

<?php $this->startSection('accountContent'); ?>
 <div x-data="{ action: 'account/address' }">
 <form class="form" x-data="form" x-bind="form">
 <div x-data='<?php echo json_encode($data, 15, 512); ?>'>
 <template x-for="index in count">
 <div>
 <div class="flex">
 <?php $__currentLoopData = $fields; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $index => $field): $loop = $this->incrementLoopIndices();  ?>
 <?php if($index == 3): ?>
 <div class="field flex">
 <?php endif; ?>
 
 <div class="field">
 <label>
 <?php echo \htmlentities(__($field['label'])??'', ENT_QUOTES, 'UTF-8', false); ?>


 <?php if( isset($field['require']) ): ?>
 <span class="form__star">*</span>
 <?php endif; ?>
 </label>

 <?php ($name = $field['name']); ?>
 
 <input type="text" 
 name="<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?>[]" 
 class="form__input"
 :class="errors.<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?> && errors.<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?>[index] ? 'error' : ''"
 :value="items[index-1] ? items[index-1]['<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?>'] : ''">
 
 <div x-text="errors.<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?>" 
 :class="errors.<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?> && errors.<?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?>[index] ? 'form__error' : ''"></div>
 </div>

 <?php if($index == 4): ?>
 </div>
 <?php endif; ?>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 </div>
 
 <div class="line"></div>
 </div>
 </template>
 
 <div x-text="errors.message" :class="errors.message ? 'form__error form__error_bottom' : ''"></div>

 <div class="flex">
 <div class="button">
 <button type="submit">
 <?php echo \htmlentities(__('form.save')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </button>
 </div>
 
 <a class="add" @click="count++">
 <?php echo \htmlentities(__('account.add_address')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </a>
 </div>
 </div>
 </form>
 </div>
<?php $this->stopSection(); ?>

<?php if (isset($_shouldextend[1])) { echo $this->runChild('account.layout'); } ?>