@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-earth"></i>
                    </span>
                    {{ __('auto.虚拟分区配置') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.渠道管理') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.虚拟分区配置') }}</li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.分区列表') }}</h4>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>RegionID</th>
                                    <th>DomainUrl</th>
                                    <th>Logo</th>
                                    <th>Icon</th>
                                    <th>GroupID</th>
                                    <th>BindChannels</th>
                                    <th>ThemeKey</th>
                                    <th>{{ __('auto.操作') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $v)
                                    <tr>
                                        <td>{{$v->id}}</td>
                                        <td>{{$v->RegionID}}</td>
                                        <td>{{$v->DomainUrl}}</td>
                                        <td>
                                            @if($v->LogoUrl)
                                                @php
                                                    $logoUrl = $v->DomainUrl . $v->LogoUrl;
                                                    $isSvg = strtolower(pathinfo($v->LogoUrl, PATHINFO_EXTENSION)) === 'svg';
                                                @endphp
                                                <div style="background-color: #000; display: inline-block; padding: 5px; width: 100%; text-align: center;">
                                                    @if($isSvg)
                                                        <object data="{{$logoUrl}}" type="image/svg+xml" style="max-width: 150px; width: 100%; height: auto; pointer-events: none;">
                                                            <img src="{{$logoUrl}}" style="max-width: 150px; height: auto;" alt="Logo">
                                                        </object>
                                                    @else
                                                        <img src="{{$logoUrl}}" style="max-width: 150px; height: auto; border-radius: 0;" alt="Logo">
                                                    @endif
                                                </div>
                                            @endif
                                        </td>
                                        <td>
                                            @if($v->IconUrl)
                                                @php
                                                    $iconUrl = $v->DomainUrl . $v->IconUrl;
                                                    $isIconSvg = strtolower(pathinfo($v->IconUrl, PATHINFO_EXTENSION)) === 'svg';
                                                @endphp
                                                @if($isIconSvg)
                                                    <div style="width: 192px; height: 192px; display: flex; align-items: center; justify-content: center;">
                                                        <object data="{{$iconUrl}}" type="image/svg+xml" style="width: 100%; height: 100%; pointer-events: none;">
                                                            <img src="{{$iconUrl}}" style="width: 192px; height: 192px;" alt="Icon">
                                                        </object>
                                                    </div>
                                                @else
                                                    <img src="{{$iconUrl}}" style="width: 192px; height: 192px; border-radius: 0;" alt="Icon">
                                                @endif
                                            @endif
                                        </td>
                                        <td>{{$v->GroupID}}</td>
                                        <td style="word-break: break-all; max-width: 300px;">
                                            @if($v->BindChannels)
                                                {{ is_array($v->BindChannels) ? implode(',', $v->BindChannels) : $v->BindChannels }}
                                            @endif
                                        </td>
                                        <td>{{$v->ThemeKey}}</td>
                                        <td>
                                            <a href="{{ url('admin/web_region_config/edit/'.$v->id) }}" class="btn btn-sm btn-gradient-info">{{ __('auto.编辑') }}</a>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
