/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.quarkus.component.azure.storage.blob.it;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import com.azure.storage.blob.models.BlockListType;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.common.mapper.TypeRef;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import org.apache.camel.quarkus.component.azure.storage.blob.it.AzureStorageHelper.ClientCertificateAuthEnabled;
import org.apache.camel.quarkus.component.azure.storage.blob.it.AzureStorageHelper.ClientSecretAuthEnabled;
import org.apache.camel.quarkus.test.EnabledIf;
import org.apache.camel.quarkus.test.mock.backend.MockBackendDisabled;
import org.apache.camel.quarkus.test.support.azure.AzureStorageTestResource;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringEndsWith.endsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

@QuarkusTest
@QuarkusTestResource(AzureStorageTestResource.class)
class AzureStorageBlobTest {

    private static final String BLOB_CONTENT = "Hello Camel Quarkus Azure Blob";

    @BeforeAll
    static void beforeAll(Config config) {
        String containerName = config.getValue("azure.blob.container.name", String.class);
        RestAssured.port = config.getValue("quarkus.http.test-port", int.class);
        RestAssured.given()
                .queryParam("containerName", containerName)
                .post("/azure-storage-blob/blob/container")
                .then()
                .statusCode(201);
    }

    @AfterAll
    static void afterAll(Config config) {
        String containerName = config.getValue("azure.blob.container.name", String.class);
        RestAssured.given()
                .queryParam("containerName", containerName)
                .delete("/azure-storage-blob/blob/container")
                .then()
                .statusCode(204);
    }

    @Test
    public void crud() {
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Read
            RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));

            // List
            RestAssured.get("/azure-storage-blob/blob/list")
                    .then()
                    .statusCode(200)
                    .body("blobs[0].name", is(AzureStorageBlobRoutes.BLOB_NAME));

            // Update
            String updatedContent = BLOB_CONTENT + " updated";
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(updatedContent)
                    .patch("/azure-storage-blob/blob/update")
                    .then()
                    .statusCode(200);

            RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(updatedContent));
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void download() throws IOException {
        Path path = null;
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Download file
            String downloadPath = RestAssured.get("/azure-storage-blob/blob/download")
                    .then()
                    .statusCode(200)
                    .body(endsWith("target/test"))
                    .extract()
                    .body()
                    .asString();

            path = Paths.get(downloadPath);
            assertEquals(BLOB_CONTENT, Files.readString(path));

            // Download link
            RestAssured.get("/azure-storage-blob/blob/download/link")
                    .then()
                    .statusCode(200)
                    .body(matchesPattern("^(https?)://.*/test.*"));
        } finally {
            if (path != null) {
                try {
                    Files.deleteIfExists(path);
                } catch (IOException e) {
                    // Ignore
                }
            }

            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void blockBlobStageCommit() {
        try {
            List<String> blockContent = Arrays.asList(BLOB_CONTENT.split(" "));

            // Stage blocks
            RestAssured.given()
                    .contentType(ContentType.JSON)
                    .body(blockContent)
                    .post("/azure-storage-blob/block/blob/stage")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            // Verify blocks uncommitted
            JsonPath json = RestAssured.given()
                    .queryParam("blockListType", BlockListType.UNCOMMITTED)
                    .get("/azure-storage-blob/blob/block/list")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .jsonPath();

            List<String> uncommittedBlocks = json.getList(BlockListType.UNCOMMITTED.toString());
            assertNotNull(uncommittedBlocks);
            assertEquals(blockContent.size(), uncommittedBlocks.size());

            // Commit blocks
            RestAssured.given()
                    .contentType(ContentType.JSON)
                    .body(uncommittedBlocks)
                    .post("/azure-storage-blob/block/blob/commit")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            // Verify blocks committed
            json = RestAssured.given()
                    .queryParam("blockListType", BlockListType.COMMITTED)
                    .get("/azure-storage-blob/blob/block/list")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .jsonPath();

            List<String> committedBlocks = json.getList(BlockListType.COMMITTED.toString());
            assertNotNull(committedBlocks);
            assertEquals(blockContent.size(), committedBlocks.size());
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void appendBlob() {
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/append/blob/create")
                    .then()
                    .statusCode(201);

            // Commit
            String appendedContent = BLOB_CONTENT + " Appended";
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(appendedContent)
                    .post("/azure-storage-blob/append/blob/commit")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            // Read
            RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(appendedContent));
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void pageBlob() {
        try {
            // Create
            RestAssured.given()
                    .post("/azure-storage-blob/page/blob/create")
                    .then()
                    .statusCode(201);

            // Upload
            RestAssured.given()
                    .queryParam("pageStart", 0)
                    .queryParam("pageEnd", 511)
                    .post("/azure-storage-blob/page/blob/upload")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            byte[] pageData = RestAssured.get("/azure-storage-blob/blob/read/bytes")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asByteArray();

            assertEquals(512, pageData.length);

            // Get ranges
            RestAssured.given()
                    .queryParam("pageStart", 0)
                    .queryParam("pageEnd", 511)
                    .get("/azure-storage-blob/page/blob")
                    .then()
                    .statusCode(200)
                    .body("ranges[0].offset", is(0),
                            "ranges[0].length", is(512));

            // Resize
            RestAssured.given()
                    .queryParam("pageStart", 0)
                    .queryParam("pageEnd", 1023)
                    .post("/azure-storage-blob/page/blob/resize")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            // Read after resize
            pageData = RestAssured.get("/azure-storage-blob/blob/read/bytes")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asByteArray();

            assertEquals(1024, pageData.length);

            // Verify page data beyond the resized point is empty
            for (int i = 512; i < pageData.length; i++) {
                if (pageData[i] != 0) {
                    fail("Expected byte element at position " + i + " to be zero value");
                }
            }

            // Clear
            RestAssured.given()
                    .queryParam("pageStart", 0)
                    .queryParam("pageEnd", 1023)
                    .post("/azure-storage-blob/page/blob/clear")
                    .then()
                    .statusCode(200)
                    .body(is("true"));

            // Read after clear
            pageData = RestAssured.get("/azure-storage-blob/blob/read/bytes")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asByteArray();

            // Verify all page data is empty
            for (int i = 0; i < pageData.length; i++) {
                if (pageData[i] != 0) {
                    fail("Expected byte element at position " + i + " to be zero value");
                }
            }
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void blobContainer() {
        String alternativeContainerName = "camel-quarkus-" + UUID.randomUUID();

        try {
            // Create
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .post("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(201);

            // List
            String containerName = ConfigProvider.getConfig().getValue("azure.blob.container.name", String.class);
            RestAssured.get("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(200)
                    .body("containers.name",
                            hasItems(containerName, alternativeContainerName));
        } finally {
            // Delete
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .delete("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void copyBlob() {
        String alternativeContainerName = "camel-quarkus-" + UUID.randomUUID();

        try {
            // Create container to copy to
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .post("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(201);

            // List
            String containerName = ConfigProvider.getConfig().getValue("azure.blob.container.name", String.class);
            RestAssured.get("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(200)
                    .body("containers.name",
                            hasItems(containerName, alternativeContainerName));

            // Create blob in first container
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Read
            RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));

            // Copy blob to alternate storage container
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .post("/azure-storage-blob/blob/copy")
                    .then()
                    .statusCode(200);

            // Read blob from alternate storage container
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));
        } finally {
            // Delete
            RestAssured.given()
                    .queryParam("containerName", alternativeContainerName)
                    .delete("/azure-storage-blob/blob/container")
                    .then()
                    .statusCode(204);

            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void blobConsumer() {
        try {
            // Start blob consumer
            RestAssured.given()
                    .post("/azure-storage-blob/consumer/true")
                    .then()
                    .statusCode(204);

            // Create blob
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Fetch results
            RestAssured.get("/azure-storage-blob/consumed/blobs")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));
        } finally {
            // Stop blob consumer
            RestAssured.given()
                    .post("/azure-storage-blob/consumer/false")
                    .then()
                    .statusCode(204);
        }
    }

    // Change feed is not available in Azurite
    @EnabledIf({ MockBackendDisabled.class })
    @Test
    public void changeFeed() {
        try {
            String eTag = RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201)
                    .extract()
                    .body()
                    .asString();

            OffsetDateTime now = OffsetDateTime.now();
            OffsetDateTime startTime = now.minus(5, ChronoUnit.MINUTES);
            OffsetDateTime endTime = now.plus(5, ChronoUnit.MINUTES);

            // Poll change feed until the blob just created is present
            Awaitility.await().pollInterval(5, TimeUnit.SECONDS).timeout(5, TimeUnit.MINUTES).until(() -> RestAssured.given()
                    .queryParam("startTime", startTime.toString())
                    .queryParam("endTime", endTime.toString())
                    .queryParam("etag", eTag)
                    .get("/azure-storage-blob/changes")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asString()
                    .equals("true"));
        } finally {
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    // Can only use the Camel component managed blob client with the real Azure service
    @EnabledIf({ MockBackendDisabled.class })
    @Test
    public void readWithManagedClient() {
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Read
            RestAssured.given()
                    .queryParam("uri", "direct:readWithManagedClient")
                    .get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    // Authentication with client secrets is not possible with Azurite
    @EnabledIf({ ClientSecretAuthEnabled.class })
    @Test
    public void readWithClientSecretAuth() {
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Read
            RestAssured.given()
                    .queryParam("uri", "direct:readWithClientSecret")
                    .get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    // Authentication with client certificates is not possible with Azurite
    @EnabledIf({ ClientCertificateAuthEnabled.class })
    @Test
    public void readWithClientCertificateAuth() {
        try {
            // Create
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(BLOB_CONTENT)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Read
            RestAssured.given()
                    .queryParam("uri", "direct:readWithClientCertificate")
                    .get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(BLOB_CONTENT));
        } finally {
            // Delete
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void dynamicExceptionInstantiation() {
        RestAssured.get("/azure-storage-blob/exception/cache")
                .then()
                .statusCode(200)
                .body(is("true"));
    }

    @Test
    public void blobSnapshot() {
        try {
            String originalContent = "Original Content";
            String updatedContent = "Updated Content";

            // Create blob
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(originalContent)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Create snapshot
            String snapshotId = RestAssured.post("/azure-storage-blob/blob/snapshot/create")
                    .then()
                    .statusCode(201)
                    .extract()
                    .body()
                    .asString();

            assertNotNull(snapshotId);

            // Update blob content
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(updatedContent)
                    .patch("/azure-storage-blob/blob/update")
                    .then()
                    .statusCode(200);

            // Read current blob (should return updated content)
            RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .body(is(updatedContent));

            // Read snapshot (should return original content)
            RestAssured.given()
                    .queryParam("snapshotId", snapshotId)
                    .get("/azure-storage-blob/blob/snapshot/read")
                    .then()
                    .statusCode(200)
                    .body(is(originalContent));
        } finally {
            // Delete blob and all snapshots
            RestAssured.given()
                    .queryParam("deleteSnapshots", "include")
                    .delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void blobTags() {
        try {
            // Create blob
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body("Test content for tags")
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Set blob tags
            Map<String, String> tags = new HashMap<>();
            tags.put("environment", "test");
            tags.put("project", "camel-quarkus");
            tags.put("version", "1.0");

            RestAssured.given()
                    .contentType(ContentType.JSON)
                    .body(tags)
                    .post("/azure-storage-blob/blob/tags/set")
                    .then()
                    .statusCode(200);

            // Get blob tags
            Map<String, String> retrievedTags = RestAssured.get("/azure-storage-blob/blob/tags/get")
                    .then()
                    .statusCode(200)
                    .extract()
                    .as(new TypeRef<Map<String, String>>() {
                    });

            // Verify tags
            assertEquals("test", retrievedTags.get("environment"));
            assertEquals("camel-quarkus", retrievedTags.get("project"));
            assertEquals("1.0", retrievedTags.get("version"));
        } finally {
            // Delete blob
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    @Test
    public void findBlobsByTags() {
        String blobName1 = AzureStorageBlobRoutes.BLOB_NAME;

        try {
            // Create first blob with tags
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body("Content for blob 1")
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            Map<String, String> tags1 = new HashMap<>();
            tags1.put("environment", "production");
            tags1.put("team", "backend");

            RestAssured.given()
                    .contentType(ContentType.JSON)
                    .body(tags1)
                    .post("/azure-storage-blob/blob/tags/set")
                    .then()
                    .statusCode(200);

            // On the real Azure service, blob index tag search is eventually consistent;
            // poll until the result is available. Azurite returns results immediately.
            String filter = "\"environment\" = 'production' AND \"team\" = 'backend'";
            Awaitility.await().pollInterval(5, TimeUnit.SECONDS).timeout(2, TimeUnit.MINUTES).until(() -> {
                List<Map<String, String>> blobs = RestAssured.given()
                        .queryParam("filter", filter)
                        .get("/azure-storage-blob/blob/tags/find")
                        .then()
                        .statusCode(200)
                        .extract()
                        .jsonPath()
                        .getList("blobs");
                return blobs != null && blobs.size() == 1 && blobName1.equals(blobs.get(0).get("name"));
            });
        } finally {
            // Delete blob
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }

    // Blob versioning is not fully supported in Azurite
    @EnabledIf({ MockBackendDisabled.class })
    @Test
    public void blobVersions() {
        try {
            String originalContent = "Version 1 Content";
            String updatedContent = "Version 2 Content";

            // Create blob (version 1)
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(originalContent)
                    .post("/azure-storage-blob/blob/create")
                    .then()
                    .statusCode(201);

            // Update blob (version 2)
            RestAssured.given()
                    .contentType(ContentType.TEXT)
                    .body(updatedContent)
                    .patch("/azure-storage-blob/blob/update")
                    .then()
                    .statusCode(200);

            // List blob versions
            List<Map<String, Object>> versions = RestAssured.get("/azure-storage-blob/blob/versions/list")
                    .then()
                    .statusCode(200)
                    .extract()
                    .jsonPath()
                    .getList("versions");

            // Verify we have at least 2 versions
            assertEquals(2, versions.size(), "Should have 2 versions (original and updated)");

            // Find the current version and an older version
            Map<String, Object> currentVersion = versions.stream()
                    .filter(v -> (Boolean) v.get("isCurrentVersion"))
                    .findFirst()
                    .orElse(null);

            Map<String, Object> oldVersion = versions.stream()
                    .filter(v -> !(Boolean) v.get("isCurrentVersion"))
                    .findFirst()
                    .orElse(null);

            assertNotNull(currentVersion, "Should have a current version");
            assertNotNull(oldVersion, "Should have an old version");

            // Read current version (should return updated content)
            String current = RestAssured.get("/azure-storage-blob/blob/read")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asString();
            assertEquals(updatedContent, current);

            // Read old version (should return original content)
            String oldVersionId = (String) oldVersion.get("versionId");
            assertNotNull(oldVersionId, "Old version should have a versionId");
            String old = RestAssured.given()
                    .queryParam("versionId", oldVersionId)
                    .get("/azure-storage-blob/blob/version/read")
                    .then()
                    .statusCode(200)
                    .extract()
                    .body()
                    .asString();
            assertEquals(originalContent, old);
        } finally {
            // Delete blob
            RestAssured.delete("/azure-storage-blob/blob/delete")
                    .then()
                    .statusCode(anyOf(is(204), is(404)));
        }
    }
}
