import picker from "@ohos:file.picker";
import photoAccessHelper from "@ohos:file.photoAccessHelper";
import camera from "@ohos:multimedia.cameraPicker";
import type common from "@ohos:app.ability.common";
import fileIo from "@ohos:file.fs";
import fileUri from "@ohos:file.fileuri";
class BjcCov {
    coverage: {
        [key: string]: string | number;
    };
    constructor(covData: object) {
        const gcv = "__coverage__";
        let coverage = globalThis[gcv] || (globalThis[gcv] = {});
        if (!coverage[covData.path] && true) {
            coverage[covData.path] = covData;
        }
        this.coverage = coverage[covData.path];
    }
    instrumentFunction(func: number) {
        this.coverage.functions[func].count++;
        this.coverage.functions[func].regions[0].count++;
    }
    instrumentRegion(func: number, region: number) {
        this.coverage.functions[func].regions[region].count++;
    }
    instrumentReturn(func: number, retIdx: number) {
        this.coverage.functions[func].returnes[retIdx].count++;
    }
    instrumentBranch(func: number, branch: number, trueOrFalse: boolean) {
        if (trueOrFalse) {
            this.coverage.functions[func].branches[branch].trueCount++;
            for (let r of Object.values(this.coverage.functions[func].branches[branch].group)) {
                if (r !== branch) {
                    this.coverage.functions[func].branches[r as number].falseCount++;
                }
            }
        }
        else {
            this.coverage.functions[func].branches[branch].falseCount++;
        }
    }
}
let bjccovms5u83nu = new BjcCov({ version: "bjc v1.0.0", versionCode: 10000, path: "tencentqianwebview/src/main/ets/filechooser/FileChooserHandler.ets", hash: "d39f78ffdcdc50057f2f1b4e8a8f7d11111c89baba51bae8d91b4e0099e7efd7", lineCnt: 288, count: 0, projectPath: "", functions: { 0: { name: "FileChooserHandler.pick", count: 0, regions: { 0: { startLoc: { line: 39, col: 3 }, endLoc: { line: 55, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 48, col: 20 }, endLoc: { line: 50, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 51, col: 31 }, endLoc: { line: 53, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 54, col: 5 }, endLoc: { line: 55, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 48, col: 9 }, endLoc: { line: 48, col: 18 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 51, col: 9 }, endLoc: { line: 51, col: 29 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 0 }, 1: { name: "captureFromCamera", count: 0, regions: { 0: { startLoc: { line: 63, col: 3 }, endLoc: { line: 104, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 68, col: 9 }, endLoc: { line: 101, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 101, col: 7 }, endLoc: { line: 103, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 86, col: 24 }, endLoc: { line: 89, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 96, col: 79 }, endLoc: { line: 98, col: 8 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 99, col: 7 }, endLoc: { line: 101, col: 6 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 71, col: 52 }, endLoc: { line: 75, col: 73 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 73, col: 11 }, endLoc: { line: 75, col: 73 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 77, col: 27 }, endLoc: { line: 77, col: 56 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 3: { startLoc: { line: 86, col: 11 }, endLoc: { line: 86, col: 22 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 4: { startLoc: { line: 96, col: 11 }, endLoc: { line: 96, col: 77 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 5: { startLoc: { line: 100, col: 14 }, endLoc: { line: 100, col: 78 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 1 }, 2: { name: "FileChooserHandler.pickPhoto", count: 0, regions: { 0: { startLoc: { line: 107, col: 3 }, endLoc: { line: 123, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 112, col: 9 }, endLoc: { line: 120, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 120, col: 7 }, endLoc: { line: 122, col: 6 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 116, col: 33 }, endLoc: { line: 116, col: 60 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 119, col: 14 }, endLoc: { line: 119, col: 61 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 2 }, 3: { name: "FileChooserHandler.resolvePhotoMimeType", count: 0, regions: { 0: { startLoc: { line: 126, col: 3 }, endLoc: { line: 136, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 130, col: 31 }, endLoc: { line: 132, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 133, col: 5 }, endLoc: { line: 136, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 130, col: 9 }, endLoc: { line: 130, col: 29 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 133, col: 12 }, endLoc: { line: 135, col: 56 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 3 }, 4: { name: "pickDocument", count: 0, regions: { 0: { startLoc: { line: 139, col: 3 }, endLoc: { line: 156, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 143, col: 9 }, endLoc: { line: 153, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 153, col: 7 }, endLoc: { line: 155, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 148, col: 31 }, endLoc: { line: 150, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 151, col: 7 }, endLoc: { line: 153, col: 6 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 146, col: 33 }, endLoc: { line: 146, col: 60 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 148, col: 11 }, endLoc: { line: 148, col: 29 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 152, col: 14 }, endLoc: { line: 152, col: 61 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 4 }, 5: { name: "FileChooserHandler.hasCategory", count: 0, regions: { 0: { startLoc: { line: 164, col: 3 }, endLoc: { line: 180, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 171, col: 5 }, endLoc: { line: 178, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 172, col: 66 }, endLoc: { line: 174, col: 8 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 175, col: 56 }, endLoc: { line: 177, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 179, col: 5 }, endLoc: { line: 180, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 168, col: 44 }, endLoc: { line: 170, col: 38 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 172, col: 11 }, endLoc: { line: 172, col: 64 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 175, col: 11 }, endLoc: { line: 175, col: 54 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 5 }, 6: { name: "FileChooserHandler.flatten", count: 0, regions: { 0: { startLoc: { line: 183, col: 3 }, endLoc: { line: 201, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 184, col: 73 }, endLoc: { line: 186, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 188, col: 5 }, endLoc: { line: 199, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 189, col: 46 }, endLoc: { line: 191, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 193, col: 7 }, endLoc: { line: 198, col: 8 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 195, col: 27 }, endLoc: { line: 197, col: 10 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 200, col: 5 }, endLoc: { line: 201, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 184, col: 9 }, endLoc: { line: 184, col: 71 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 189, col: 11 }, endLoc: { line: 189, col: 44 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 195, col: 13 }, endLoc: { line: 195, col: 25 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 6 }, 7: { name: "FileChooserHandler.acceptTypesToSuffixFilters", count: 0, regions: { 0: { startLoc: { line: 207, col: 3 }, endLoc: { line: 240, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 208, col: 88 }, endLoc: { line: 210, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 213, col: 5 }, endLoc: { line: 238, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 215, col: 27 }, endLoc: { line: 217, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 218, col: 61 }, endLoc: { line: 220, col: 8 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 221, col: 32 }, endLoc: { line: 228, col: 8 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 223, col: 35 }, endLoc: { line: 226, col: 10 }, count: 0, ignored: 0 }, 7: { startLoc: { line: 230, col: 29 }, endLoc: { line: 232, col: 8 }, count: 0, ignored: 0 }, 8: { startLoc: { line: 234, col: 33 }, endLoc: { line: 237, col: 8 }, count: 0, ignored: 0 }, 9: { startLoc: { line: 239, col: 5 }, endLoc: { line: 240, col: 4 }, count: 0, ignored: 0 }, 10: { startLoc: { line: 227, col: 9 }, endLoc: { line: 228, col: 8 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 208, col: 9 }, endLoc: { line: 208, col: 86 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 215, col: 11 }, endLoc: { line: 215, col: 25 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 218, col: 11 }, endLoc: { line: 218, col: 59 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 3: { startLoc: { line: 221, col: 11 }, endLoc: { line: 221, col: 30 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 4: { startLoc: { line: 223, col: 13 }, endLoc: { line: 223, col: 33 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 5: { startLoc: { line: 230, col: 11 }, endLoc: { line: 230, col: 27 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 6: { startLoc: { line: 234, col: 11 }, endLoc: { line: 234, col: 31 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 7 }, 8: { name: "FileChooserHandler.suffixToFilter", count: 0, regions: { 0: { startLoc: { line: 243, col: 3 }, endLoc: { line: 247, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 244, col: 5 }, endLoc: { line: 247, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 244, col: 25 }, endLoc: { line: 244, col: 75 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 8 }, 9: { name: "FileChooserHandler.mimeToSuffix", count: 0, regions: { 0: { startLoc: { line: 250, col: 3 }, endLoc: { line: 284, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 252, col: 7 }, endLoc: { line: 253, col: 23 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 254, col: 7 }, endLoc: { line: 255, col: 23 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 256, col: 7 }, endLoc: { line: 256, col: 25 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 257, col: 7 }, endLoc: { line: 258, col: 23 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 259, col: 7 }, endLoc: { line: 260, col: 23 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 261, col: 7 }, endLoc: { line: 262, col: 23 }, count: 0, ignored: 0 }, 7: { startLoc: { line: 263, col: 7 }, endLoc: { line: 264, col: 24 }, count: 0, ignored: 0 }, 8: { startLoc: { line: 265, col: 7 }, endLoc: { line: 266, col: 23 }, count: 0, ignored: 0 }, 9: { startLoc: { line: 267, col: 7 }, endLoc: { line: 268, col: 24 }, count: 0, ignored: 0 }, 10: { startLoc: { line: 269, col: 7 }, endLoc: { line: 270, col: 23 }, count: 0, ignored: 0 }, 11: { startLoc: { line: 271, col: 7 }, endLoc: { line: 272, col: 24 }, count: 0, ignored: 0 }, 12: { startLoc: { line: 273, col: 7 }, endLoc: { line: 274, col: 23 }, count: 0, ignored: 0 }, 13: { startLoc: { line: 275, col: 7 }, endLoc: { line: 276, col: 24 }, count: 0, ignored: 0 }, 14: { startLoc: { line: 277, col: 7 }, endLoc: { line: 278, col: 23 }, count: 0, ignored: 0 }, 15: { startLoc: { line: 279, col: 7 }, endLoc: { line: 280, col: 23 }, count: 0, ignored: 0 }, 16: { startLoc: { line: 281, col: 7 }, endLoc: { line: 282, col: 19 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 252, col: 12 }, endLoc: { line: 252, col: 29 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 1: { startLoc: { line: 254, col: 12 }, endLoc: { line: 254, col: 23 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 2: { startLoc: { line: 256, col: 12 }, endLoc: { line: 256, col: 24 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 3: { startLoc: { line: 257, col: 12 }, endLoc: { line: 257, col: 23 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 4: { startLoc: { line: 259, col: 12 }, endLoc: { line: 259, col: 23 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 5: { startLoc: { line: 261, col: 12 }, endLoc: { line: 261, col: 23 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 6: { startLoc: { line: 263, col: 12 }, endLoc: { line: 263, col: 24 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 7: { startLoc: { line: 265, col: 12 }, endLoc: { line: 265, col: 32 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 8: { startLoc: { line: 267, col: 12 }, endLoc: { line: 267, col: 85 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 9: { startLoc: { line: 269, col: 12 }, endLoc: { line: 269, col: 38 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 10: { startLoc: { line: 271, col: 12 }, endLoc: { line: 271, col: 79 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 11: { startLoc: { line: 273, col: 12 }, endLoc: { line: 273, col: 43 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 12: { startLoc: { line: 275, col: 12 }, endLoc: { line: 275, col: 87 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 13: { startLoc: { line: 277, col: 12 }, endLoc: { line: 277, col: 24 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 14: { startLoc: { line: 279, col: 12 }, endLoc: { line: 279, col: 29 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 }, 15: { startLoc: { line: 281, col: 7 }, endLoc: { line: 281, col: 7 }, trueCount: 0, falseCount: 0, group: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15 }, ignored: 0 } }, ignored: 0, index: 9 }, 10: { name: "FileChooserHandler.constructor", count: 0, regions: { 0: { startLoc: { line: 286, col: 3 }, endLoc: { line: 286, col: 27 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 10 } }, exeLine: { 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 14, 7: 19, 8: 20, 9: 21, 10: 26, 11: 27, 12: 39, 13: 40, 14: 41, 15: 42, 16: 43, 17: 44, 18: 45, 19: 46, 20: 48, 21: 49, 22: 51, 23: 52, 24: 54, 25: 63, 26: 64, 27: 65, 28: 66, 29: 67, 30: 68, 31: 69, 32: 70, 33: 71, 34: 72, 35: 73, 36: 74, 37: 75, 38: 77, 39: 78, 40: 79, 41: 80, 42: 82, 43: 83, 44: 84, 45: 86, 46: 88, 47: 91, 48: 92, 49: 93, 50: 94, 51: 96, 52: 97, 53: 99, 54: 100, 55: 101, 56: 102, 57: 107, 58: 108, 59: 109, 60: 110, 61: 111, 62: 112, 63: 113, 64: 114, 65: 115, 66: 116, 67: 117, 68: 118, 69: 119, 70: 120, 71: 121, 72: 126, 73: 127, 74: 128, 75: 129, 76: 130, 77: 131, 78: 133, 79: 134, 80: 135, 81: 139, 82: 140, 83: 141, 84: 142, 85: 143, 86: 144, 87: 145, 88: 146, 89: 147, 90: 148, 91: 149, 92: 151, 93: 152, 94: 153, 95: 154, 96: 164, 97: 165, 98: 166, 99: 167, 100: 168, 101: 169, 102: 170, 103: 171, 104: 172, 105: 173, 106: 175, 107: 176, 108: 179, 109: 183, 110: 184, 111: 185, 112: 187, 113: 188, 114: 189, 115: 190, 116: 192, 117: 193, 118: 194, 119: 195, 120: 196, 121: 200, 122: 207, 123: 208, 124: 209, 125: 211, 126: 212, 127: 213, 128: 214, 129: 215, 130: 216, 131: 218, 132: 219, 133: 221, 134: 222, 135: 223, 136: 224, 137: 225, 138: 227, 139: 229, 140: 230, 141: 231, 142: 233, 143: 234, 144: 235, 145: 236, 146: 239, 147: 243, 148: 244, 149: 245, 150: 246, 151: 250, 152: 251, 153: 252, 154: 253, 155: 254, 156: 255, 157: 256, 158: 257, 159: 258, 160: 259, 161: 260, 162: 261, 163: 262, 164: 263, 165: 264, 166: 265, 167: 266, 168: 267, 169: 268, 170: 269, 171: 270, 172: 271, 173: 272, 174: 273, 175: 274, 176: 275, 177: 276, 178: 277, 179: 278, 180: 279, 181: 280, 182: 281, 183: 282, 184: 286 } });
/**
 * 处理 `<input type=file>` 触发的文件选择请求。
 *
 * 根据 H5 `accept` / `capture` / `multiple` 属性,自动选择系统相机、图库、
 * 或文档选择器,并返回选中文件的 URI 列表交还 ArkWeb。
 */
export class FileChooserHandler {
    /**
     * ArkWeb 把 H5 `accept="image/*"` 在原生层展开后的扩展名清单。
     * 用于在仅拿到扩展名(如 `.jpg`)时反查媒体大类。
     */
    private static readonly IMAGE_EXTS: ReadonlySet<string> = new Set<string>([
        '.tif', '.xbm', '.tiff', '.pjp', '.jfif', '.bmp', '.avif', '.apng', '.ico',
        '.webp', '.svg', '.gif', '.svgz', '.jpg', '.jpeg', '.png', '.pjpeg'
    ]);
    /**
     * ArkWeb 把 H5 `accept="video/*"` 在原生层展开后的扩展名清单。
     */
    private static readonly VIDEO_EXTS: ReadonlySet<string> = new Set<string>([
        '.mp4', '.mpg', '.mpeg', '.m4v', '.ogm', '.ogv', '.webm'
    ]);
    /**
     * 入口:根据 ArkWeb 传入的文件选择参数选择合适的系统选择器。
     *
     * @param context UIAbilityContext,用于拉起系统应用
     * @param acceptTypes `getAcceptType()` 返回的扩展名/MIME 数组
     * @param isCapture 是否要求即时拍摄(对应 H5 `capture` 属性)
     * @param mode 单选 / 多选(对应 H5 `multiple` 属性)
     * @returns 选中文件的 URI 列表;用户取消或失败均返回 `[]`
     */
    public static async pick(context: common.UIAbilityContext, acceptTypes: string[], isCapture: boolean, mode: 'single' | 'multiple'): Promise<string[]> {
        bjccovms5u83nu.instrumentFunction(0);
        const hasImage: boolean = FileChooserHandler.hasCategory(acceptTypes, 'image');
        const hasVideo: boolean = FileChooserHandler.hasCategory(acceptTypes, 'video');
        if (isCapture) {
            bjccovms5u83nu.instrumentBranch(0, 0, true);
            bjccovms5u83nu.instrumentRegion(0, 1);
            return await FileChooserHandler.captureFromCamera(context, hasImage, hasVideo);
        }
        else {
            bjccovms5u83nu.instrumentBranch(0, 0, false);
        }
        if (hasImage || hasVideo) {
            bjccovms5u83nu.instrumentBranch(0, 1, true);
            bjccovms5u83nu.instrumentRegion(0, 2);
            return await FileChooserHandler.pickPhoto(mode, hasImage, hasVideo);
        }
        else {
            bjccovms5u83nu.instrumentBranch(0, 1, false);
        }
        bjccovms5u83nu.instrumentRegion(0, 3);
        return await FileChooserHandler.pickDocument(mode, acceptTypes);
    }
    /**
     * 拉起系统相机进行拍照或录像。
     *
     * `accept` 仅含 image → 拍照;仅含 video → 录像;两者皆有/皆无 → 由系统 picker 让用户选择。
     * 录像需预先在沙箱内创建 saveUri 文件,否则 5.0.x 上 cameraPicker 会回退到拍照模式。
     */
    private static async captureFromCamera(context: common.UIAbilityContext, hasImage: boolean, hasVideo: boolean): Promise<string[]> {
        bjccovms5u83nu.instrumentFunction(1);
        try {
            bjccovms5u83nu.instrumentRegion(1, 1);
            const isVideoOnly: boolean = hasVideo && !hasImage;
            const isPhotoOnly: boolean = hasImage && !hasVideo;
            const mediaTypes: camera.PickerMediaType[] = isVideoOnly
                ? (bjccovms5u83nu.instrumentBranch(1, 0, true), [camera.PickerMediaType.VIDEO]) : (bjccovms5u83nu.instrumentBranch(1, 0, false), isPhotoOnly
                ? (bjccovms5u83nu.instrumentBranch(1, 1, true), [camera.PickerMediaType.PHOTO]) : (bjccovms5u83nu.instrumentBranch(1, 1, false), [camera.PickerMediaType.PHOTO, camera.PickerMediaType.VIDEO]));
            const ext: string = isVideoOnly ? (bjccovms5u83nu.instrumentBranch(1, 2, true), '.mp4') : (bjccovms5u83nu.instrumentBranch(1, 2, false), '.jpg');
            const filePath: string = context.filesDir + '/qian_' + Date.now() + ext;
            fileIo.createRandomAccessFileSync(filePath, fileIo.OpenMode.CREATE);
            const saveUri: string = fileUri.getUriFromPath(filePath);
            const profile: any = {
                cameraPosition: 1,
                saveUri: saveUri
            };
            if (isVideoOnly) {
                bjccovms5u83nu.instrumentBranch(1, 3, true);
                bjccovms5u83nu.instrumentRegion(1, 3);
                // videoDuration 单位秒,0 表示不限时长
                profile.videoDuration = 0;
            }
            else {
                bjccovms5u83nu.instrumentBranch(1, 3, false);
            }
            const result: camera.PickerResult = await camera.pick(context, mediaTypes, profile as camera.PickerProfile);
            if (result === null || result === undefined || result.resultCode !== 0) {
                bjccovms5u83nu.instrumentBranch(1, 4, true);
                bjccovms5u83nu.instrumentRegion(1, 4);
                return [];
            }
            else {
                bjccovms5u83nu.instrumentBranch(1, 4, false);
            }
            bjccovms5u83nu.instrumentRegion(1, 5);
            const uri: string = result.resultUri;
            return uri !== null && uri !== undefined && uri.length > 0 ? (bjccovms5u83nu.instrumentBranch(1, 5, true), [uri]) : (bjccovms5u83nu.instrumentBranch(1, 5, false), []);
        }
        catch (_e) {
            bjccovms5u83nu.instrumentRegion(1, 2);
            return [];
        }
    }
    /** 拉起系统图库选择器(图片 / 视频 / 混合)。 */
    private static async pickPhoto(mode: 'single' | 'multiple', hasImage: boolean, hasVideo: boolean): Promise<string[]> {
        bjccovms5u83nu.instrumentFunction(2);
        try {
            bjccovms5u83nu.instrumentRegion(2, 1);
            const photoPicker = new photoAccessHelper.PhotoViewPicker();
            const options: photoAccessHelper.PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
            options.MIMEType = FileChooserHandler.resolvePhotoMimeType(hasImage, hasVideo);
            options.maxSelectNumber = mode === 'multiple' ? (bjccovms5u83nu.instrumentBranch(2, 0, true), 9) : (bjccovms5u83nu.instrumentBranch(2, 0, false), 1);
            const result: photoAccessHelper.PhotoSelectResult = await photoPicker.select(options);
            const uris: string[] = result.photoUris;
            return uris !== null && uris !== undefined ? (bjccovms5u83nu.instrumentBranch(2, 1, true), uris) : (bjccovms5u83nu.instrumentBranch(2, 1, false), []);
        }
        catch (_e) {
            bjccovms5u83nu.instrumentRegion(2, 2);
            return [];
        }
    }
    /** 根据 hasImage / hasVideo 选择图库 MIMEType。 */
    private static resolvePhotoMimeType(hasImage: boolean, hasVideo: boolean): photoAccessHelper.PhotoViewMIMETypes {
        bjccovms5u83nu.instrumentFunction(3);
        if (hasImage && hasVideo) {
            bjccovms5u83nu.instrumentBranch(3, 0, true);
            bjccovms5u83nu.instrumentRegion(3, 1);
            return photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE;
        }
        else {
            bjccovms5u83nu.instrumentBranch(3, 0, false);
        }
        bjccovms5u83nu.instrumentRegion(3, 2);
        return hasVideo
            ? (bjccovms5u83nu.instrumentBranch(3, 1, true), photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE) : (bjccovms5u83nu.instrumentBranch(3, 1, false), photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE);
    }
    /** 拉起文档选择器,按 accept 限定可选后缀。 */
    private static async pickDocument(mode: 'single' | 'multiple', acceptTypes: string[]): Promise<string[]> {
        bjccovms5u83nu.instrumentFunction(4);
        try {
            bjccovms5u83nu.instrumentRegion(4, 1);
            const documentPicker = new picker.DocumentViewPicker();
            const options: picker.DocumentSelectOptions = new picker.DocumentSelectOptions();
            options.maxSelectNumber = mode === 'multiple' ? (bjccovms5u83nu.instrumentBranch(4, 0, true), 9) : (bjccovms5u83nu.instrumentBranch(4, 0, false), 1);
            const filters: string[] = FileChooserHandler.acceptTypesToSuffixFilters(acceptTypes);
            if (filters.length > 0) {
                bjccovms5u83nu.instrumentBranch(4, 1, true);
                bjccovms5u83nu.instrumentRegion(4, 3);
                (options as any).fileSuffixFilters = filters;
            }
            else {
                bjccovms5u83nu.instrumentBranch(4, 1, false);
            }
            bjccovms5u83nu.instrumentRegion(4, 4);
            const uris: string[] = await documentPicker.select(options);
            return uris !== null && uris !== undefined ? (bjccovms5u83nu.instrumentBranch(4, 2, true), uris) : (bjccovms5u83nu.instrumentBranch(4, 2, false), []);
        }
        catch (_e) {
            bjccovms5u83nu.instrumentRegion(4, 2);
            return [];
        }
    }
    /**
     * 判断 accept 是否覆盖某个媒体大类。
     *
     * `getAcceptType()` 返回的元素既可能是 MIME(`image/png`、`video/*`),也可能是
     * 扩展名(`.jpg`、`.mp4`)——ArkWeb 会把通配 MIME 展开成扩展名清单。两种格式同时识别。
     */
    private static hasCategory(acceptTypes: string[], category: 'image' | 'video'): boolean {
        bjccovms5u83nu.instrumentFunction(5);
        const whitelist: ReadonlySet<string> = category === 'image'
            ? (bjccovms5u83nu.instrumentBranch(5, 0, true), FileChooserHandler.IMAGE_EXTS) : (bjccovms5u83nu.instrumentBranch(5, 0, false), FileChooserHandler.VIDEO_EXTS);
        for (const raw of FileChooserHandler.flatten(acceptTypes)) {
            bjccovms5u83nu.instrumentRegion(5, 1);
            if (raw === category || raw.indexOf(category + '/') === 0) {
                bjccovms5u83nu.instrumentBranch(5, 1, true);
                bjccovms5u83nu.instrumentRegion(5, 2);
                return true;
            }
            else {
                bjccovms5u83nu.instrumentBranch(5, 1, false);
            }
            if (raw.charAt(0) === '.' && whitelist.has(raw)) {
                bjccovms5u83nu.instrumentBranch(5, 2, true);
                bjccovms5u83nu.instrumentRegion(5, 3);
                return true;
            }
            else {
                bjccovms5u83nu.instrumentBranch(5, 2, false);
            }
        }
        bjccovms5u83nu.instrumentRegion(5, 4);
        return false;
    }
    /** 规范化 accept 数组:拆逗号、trim、转小写、去空,得到扁平的 token 列表。 */
    private static flatten(values: string[]): string[] {
        bjccovms5u83nu.instrumentFunction(6);
        if (values === null || values === undefined || values.length === 0) {
            bjccovms5u83nu.instrumentBranch(6, 0, true);
            bjccovms5u83nu.instrumentRegion(6, 1);
            return [];
        }
        else {
            bjccovms5u83nu.instrumentBranch(6, 0, false);
        }
        const out: string[] = [];
        for (const raw of values) {
            bjccovms5u83nu.instrumentRegion(6, 2);
            if (raw === null || raw === undefined) {
                bjccovms5u83nu.instrumentBranch(6, 1, true);
                bjccovms5u83nu.instrumentRegion(6, 3);
                continue;
            }
            else {
                bjccovms5u83nu.instrumentBranch(6, 1, false);
            }
            const parts: string[] = raw.split(',');
            for (const p of parts) {
                bjccovms5u83nu.instrumentRegion(6, 4);
                const t: string = p.trim().toLowerCase();
                if (t.length > 0) {
                    bjccovms5u83nu.instrumentBranch(6, 2, true);
                    bjccovms5u83nu.instrumentRegion(6, 5);
                    out.push(t);
                }
                else {
                    bjccovms5u83nu.instrumentBranch(6, 2, false);
                }
            }
        }
        bjccovms5u83nu.instrumentRegion(6, 6);
        return out;
    }
    /**
     * 把 accept 列表转换为文档选择器的后缀过滤数组。
     * 含通配(`* / *`、`image/*`)或未识别 MIME 时返回空数组,表示不过滤。
     */
    private static acceptTypesToSuffixFilters(acceptTypes: string[]): string[] {
        bjccovms5u83nu.instrumentFunction(7);
        if (acceptTypes === null || acceptTypes === undefined || acceptTypes.length === 0) {
            bjccovms5u83nu.instrumentBranch(7, 0, true);
            bjccovms5u83nu.instrumentRegion(7, 1);
            return [];
        }
        else {
            bjccovms5u83nu.instrumentBranch(7, 0, false);
        }
        const filters: string[] = [];
        const seen: Set<string> = new Set<string>();
        for (const raw of acceptTypes) {
            bjccovms5u83nu.instrumentRegion(7, 2);
            const t: string = raw.trim().toLowerCase();
            if (t.length === 0) {
                bjccovms5u83nu.instrumentBranch(7, 1, true);
                bjccovms5u83nu.instrumentRegion(7, 3);
                continue;
            }
            else {
                bjccovms5u83nu.instrumentBranch(7, 1, false);
            }
            if (t.indexOf('/*') >= 0 || t === '*' || t === '*/*') {
                bjccovms5u83nu.instrumentBranch(7, 2, true);
                bjccovms5u83nu.instrumentRegion(7, 4);
                return [];
            }
            else {
                bjccovms5u83nu.instrumentBranch(7, 2, false);
            }
            if (t.charAt(0) === '.') {
                bjccovms5u83nu.instrumentBranch(7, 3, true);
                bjccovms5u83nu.instrumentRegion(7, 5);
                const filterStr: string = FileChooserHandler.suffixToFilter(t);
                if (!seen.has(filterStr)) {
                    bjccovms5u83nu.instrumentBranch(7, 4, true);
                    bjccovms5u83nu.instrumentRegion(7, 6);
                    seen.add(filterStr);
                    filters.push(filterStr);
                }
                else {
                    bjccovms5u83nu.instrumentBranch(7, 4, false);
                }
                bjccovms5u83nu.instrumentRegion(7, 10);
                continue;
            }
            else {
                bjccovms5u83nu.instrumentBranch(7, 3, false);
            }
            const ext: string = FileChooserHandler.mimeToSuffix(t);
            if (ext.length === 0) {
                bjccovms5u83nu.instrumentBranch(7, 5, true);
                bjccovms5u83nu.instrumentRegion(7, 7);
                return [];
            }
            else {
                bjccovms5u83nu.instrumentBranch(7, 5, false);
            }
            const filterStr: string = FileChooserHandler.suffixToFilter(ext);
            if (!seen.has(filterStr)) {
                bjccovms5u83nu.instrumentBranch(7, 6, true);
                bjccovms5u83nu.instrumentRegion(7, 8);
                seen.add(filterStr);
                filters.push(filterStr);
            }
            else {
                bjccovms5u83nu.instrumentBranch(7, 6, false);
            }
        }
        bjccovms5u83nu.instrumentRegion(7, 9);
        return filters;
    }
    /** 后缀转 picker filter 字符串。 */
    private static suffixToFilter(suffix: string): string {
        bjccovms5u83nu.instrumentFunction(8);
        bjccovms5u83nu.instrumentRegion(8, 1);
        const ext: string = suffix.charAt(0) === '.' ? (bjccovms5u83nu.instrumentBranch(8, 0, true), suffix) : (bjccovms5u83nu.instrumentBranch(8, 0, false), ('.' + suffix));
        const upper: string = ext.substring(1).toUpperCase();
        return upper + '文件|' + ext;
    }
    /** 常见 MIME 到文件后缀的映射。 */
    private static mimeToSuffix(mime: string): string {
        bjccovms5u83nu.instrumentFunction(9);
        switch (mime) {
            case 'application/pdf':
                bjccovms5u83nu.instrumentBranch(9, 0, true);
                bjccovms5u83nu.instrumentRegion(9, 1);
                return '.pdf';
            case 'image/png':
                bjccovms5u83nu.instrumentBranch(9, 1, true);
                bjccovms5u83nu.instrumentRegion(9, 2);
                return '.png';
            case 'image/jpeg':
                bjccovms5u83nu.instrumentBranch(9, 2, true);
                bjccovms5u83nu.instrumentRegion(9, 3);
            case 'image/jpg':
                bjccovms5u83nu.instrumentBranch(9, 3, true);
                bjccovms5u83nu.instrumentRegion(9, 4);
                return '.jpg';
            case 'image/gif':
                bjccovms5u83nu.instrumentBranch(9, 4, true);
                bjccovms5u83nu.instrumentRegion(9, 5);
                return '.gif';
            case 'image/bmp':
                bjccovms5u83nu.instrumentBranch(9, 5, true);
                bjccovms5u83nu.instrumentRegion(9, 6);
                return '.bmp';
            case 'image/webp':
                bjccovms5u83nu.instrumentBranch(9, 6, true);
                bjccovms5u83nu.instrumentRegion(9, 7);
                return '.webp';
            case 'application/msword':
                bjccovms5u83nu.instrumentBranch(9, 7, true);
                bjccovms5u83nu.instrumentRegion(9, 8);
                return '.doc';
            case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
                bjccovms5u83nu.instrumentBranch(9, 8, true);
                bjccovms5u83nu.instrumentRegion(9, 9);
                return '.docx';
            case 'application/vnd.ms-excel':
                bjccovms5u83nu.instrumentBranch(9, 9, true);
                bjccovms5u83nu.instrumentRegion(9, 10);
                return '.xls';
            case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
                bjccovms5u83nu.instrumentBranch(9, 10, true);
                bjccovms5u83nu.instrumentRegion(9, 11);
                return '.xlsx';
            case 'application/vnd.ms-powerpoint':
                bjccovms5u83nu.instrumentBranch(9, 11, true);
                bjccovms5u83nu.instrumentRegion(9, 12);
                return '.ppt';
            case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
                bjccovms5u83nu.instrumentBranch(9, 12, true);
                bjccovms5u83nu.instrumentRegion(9, 13);
                return '.pptx';
            case 'text/plain':
                bjccovms5u83nu.instrumentBranch(9, 13, true);
                bjccovms5u83nu.instrumentRegion(9, 14);
                return '.txt';
            case 'application/zip':
                bjccovms5u83nu.instrumentBranch(9, 14, true);
                bjccovms5u83nu.instrumentRegion(9, 15);
                return '.zip';
            default:
                bjccovms5u83nu.instrumentBranch(9, 15, true);
                bjccovms5u83nu.instrumentRegion(9, 16);
                return '';
        }
    }
    private constructor() { bjccovms5u83nu.instrumentFunction(10); }
}
