import { BuilderNode, NodeController } from "@ohos:arkui.node";
import type { FrameNode } from "@ohos:arkui.node";
import type { UIContext } from "@ohos:arkui.UIContext";
import type { WebHostModel } from './WebHostModel';
import { RenderRecovery } from "@normalized:N&&&tencentqianwebview/src/main/ets/internal/RenderRecovery&1.0.0";
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 bjccovms8pf60p = new BjcCov({ version: "bjc v1.0.0", versionCode: 10000, path: "tencentqianwebview/src/main/ets/internal/prewarm/TencentQianWebNode.ets", hash: "1b40aeba7ffb4f9e88712855246ab66e0e9e216daa6228f169d4a80a69e8b285", lineCnt: 207, count: 0, projectPath: "", functions: { 0: { name: "tencentQianWebBuilder", count: 0, regions: { 0: { startLoc: { line: 26, col: 1 }, endLoc: { line: 167, col: 2 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 52, col: 7 }, endLoc: { line: 54, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 97, col: 7 }, endLoc: { line: 98, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 72, col: 9 }, endLoc: { line: 77, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 113, col: 7 }, endLoc: { line: 114, col: 6 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 105, col: 9 }, endLoc: { line: 106, col: 8 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 151, col: 7 }, endLoc: { line: 164, col: 6 }, count: 0, ignored: 0 }, 7: { startLoc: { line: 134, col: 9 }, endLoc: { line: 135, col: 8 }, count: 0, ignored: 0 }, 8: { startLoc: { line: 149, col: 9 }, endLoc: { line: 150, col: 8 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 0 }, 1: { name: "anonymous_0", count: 0, regions: { 0: { startLoc: { line: 27, col: 32 }, endLoc: { line: 166, col: 19 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 39, col: 16 }, endLoc: { line: 39, col: 84 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 1 }, 2: { name: "anonymous_1", count: 0, regions: { 0: { startLoc: { line: 41, col: 27 }, endLoc: { line: 43, col: 6 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 42, col: 7 }, endLoc: { line: 43, col: 6 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 2 }, 3: { name: "anonymous_2", count: 0, regions: { 0: { startLoc: { line: 44, col: 22 }, endLoc: { line: 44, col: 81 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 3 }, 4: { name: "anonymous_3", count: 0, regions: { 0: { startLoc: { line: 45, col: 18 }, endLoc: { line: 54, col: 6 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 49, col: 45 }, endLoc: { line: 51, col: 8 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 49, col: 11 }, endLoc: { line: 49, col: 43 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 4 }, 5: { name: "anonymous_4", count: 0, regions: { 0: { startLoc: { line: 55, col: 16 }, endLoc: { line: 98, col: 6 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 64, col: 86 }, endLoc: { line: 66, col: 8 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 69, col: 45 }, endLoc: { line: 77, col: 8 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 78, col: 11 }, endLoc: { line: 94, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 94, col: 9 }, endLoc: { line: 96, col: 8 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 81, col: 37 }, endLoc: { line: 88, col: 10 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 83, col: 15 }, endLoc: { line: 85, col: 12 }, count: 0, ignored: 0 }, 7: { startLoc: { line: 85, col: 13 }, endLoc: { line: 87, col: 12 }, count: 0, ignored: 0 }, 8: { startLoc: { line: 91, col: 44 }, endLoc: { line: 93, col: 10 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 64, col: 11 }, endLoc: { line: 64, col: 84 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 69, col: 11 }, endLoc: { line: 69, col: 43 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 81, col: 13 }, endLoc: { line: 81, col: 35 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 3: { startLoc: { line: 91, col: 13 }, endLoc: { line: 91, col: 42 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 5 }, 6: { name: "anonymous_5", count: 0, regions: { 0: { startLoc: { line: 72, col: 20 }, endLoc: { line: 76, col: 10 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 73, col: 49 }, endLoc: { line: 75, col: 12 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 73, col: 15 }, endLoc: { line: 73, col: 47 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 6 }, 7: { name: "anonymous_6", count: 0, regions: { 0: { startLoc: { line: 99, col: 23 }, endLoc: { line: 114, col: 6 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 103, col: 33 }, endLoc: { line: 106, col: 8 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 110, col: 45 }, endLoc: { line: 112, col: 8 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 103, col: 11 }, endLoc: { line: 103, col: 31 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 110, col: 11 }, endLoc: { line: 110, col: 43 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 7 }, 8: { name: "anonymous_7", count: 0, regions: { 0: { startLoc: { line: 115, col: 26 }, endLoc: { line: 115, col: 89 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 8 }, 9: { name: "anonymous_8", count: 0, regions: { 0: { startLoc: { line: 116, col: 25 }, endLoc: { line: 116, col: 87 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 9 }, 10: { name: "anonymous_9", count: 0, regions: { 0: { startLoc: { line: 117, col: 14 }, endLoc: { line: 117, col: 65 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 10 }, 11: { name: "anonymous_10", count: 0, regions: { 0: { startLoc: { line: 118, col: 16 }, endLoc: { line: 118, col: 69 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 11 }, 12: { name: "anonymous_11", count: 0, regions: { 0: { startLoc: { line: 119, col: 15 }, endLoc: { line: 119, col: 67 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 12 }, 13: { name: "anonymous_12", count: 0, regions: { 0: { startLoc: { line: 120, col: 22 }, endLoc: { line: 120, col: 81 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 13 }, 14: { name: "anonymous_13", count: 0, regions: { 0: { startLoc: { line: 121, col: 21 }, endLoc: { line: 121, col: 79 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 14 }, 15: { name: "anonymous_14", count: 0, regions: { 0: { startLoc: { line: 122, col: 25 }, endLoc: { line: 122, col: 87 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 15 }, 16: { name: "anonymous_15", count: 0, regions: { 0: { startLoc: { line: 123, col: 29 }, endLoc: { line: 123, col: 95 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 16 }, 17: { name: "anonymous_16", count: 0, regions: { 0: { startLoc: { line: 124, col: 21 }, endLoc: { line: 164, col: 6 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 128, col: 69 }, endLoc: { line: 135, col: 8 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 129, col: 13 }, endLoc: { line: 131, col: 10 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 131, col: 11 }, endLoc: { line: 133, col: 10 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 139, col: 81 }, endLoc: { line: 141, col: 8 }, count: 0, ignored: 0 }, 5: { startLoc: { line: 145, col: 60 }, endLoc: { line: 150, col: 8 }, count: 0, ignored: 0 }, 6: { startLoc: { line: 146, col: 51 }, endLoc: { line: 148, col: 10 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 128, col: 11 }, endLoc: { line: 128, col: 67 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 1: { startLoc: { line: 139, col: 11 }, endLoc: { line: 139, col: 79 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 2: { startLoc: { line: 145, col: 11 }, endLoc: { line: 145, col: 58 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 3: { startLoc: { line: 146, col: 13 }, endLoc: { line: 146, col: 49 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 }, 4: { startLoc: { line: 151, col: 32 }, endLoc: { line: 151, col: 98 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 17 }, 18: { name: "anonymous_17", count: 0, regions: { 0: { startLoc: { line: 158, col: 88 }, endLoc: { line: 163, col: 8 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 160, col: 51 }, endLoc: { line: 162, col: 10 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 160, col: 13 }, endLoc: { line: 160, col: 49 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 18 }, 19: { name: "WebNodeController.init", count: 0, regions: { 0: { startLoc: { line: 179, col: 3 }, endLoc: { line: 184, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 180, col: 5 }, endLoc: { line: 184, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 19 }, 20: { name: "WebNodeController.makeNode", count: 0, regions: { 0: { startLoc: { line: 186, col: 3 }, endLoc: { line: 188, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 187, col: 5 }, endLoc: { line: 188, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 187, col: 12 }, endLoc: { line: 187, col: 78 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 20 }, 21: { name: "WebNodeController.getModel", count: 0, regions: { 0: { startLoc: { line: 190, col: 3 }, endLoc: { line: 192, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 191, col: 5 }, endLoc: { line: 192, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 21 }, 22: { name: "WebNodeController.disposeNode", count: 0, regions: { 0: { startLoc: { line: 195, col: 3 }, endLoc: { line: 205, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 196, col: 9 }, endLoc: { line: 200, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 200, col: 7 }, endLoc: { line: 202, col: 6 }, count: 0, ignored: 0 }, 3: { startLoc: { line: 197, col: 38 }, endLoc: { line: 199, col: 8 }, count: 0, ignored: 0 }, 4: { startLoc: { line: 203, col: 5 }, endLoc: { line: 205, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 197, col: 11 }, endLoc: { line: 197, col: 36 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 22 } }, exeLine: { 0: 1, 1: 2, 2: 3, 3: 4, 4: 7, 5: 14, 6: 27, 7: 28, 8: 29, 9: 30, 10: 31, 11: 32, 12: 33, 13: 34, 14: 35, 15: 36, 16: 37, 17: 38, 18: 39, 19: 40, 20: 41, 21: 42, 22: 44, 23: 45, 24: 46, 25: 47, 26: 48, 27: 49, 28: 50, 29: 52, 30: 53, 31: 55, 32: 56, 33: 57, 34: 64, 35: 65, 36: 68, 37: 69, 38: 70, 39: 72, 40: 73, 41: 74, 42: 76, 43: 78, 44: 81, 45: 82, 46: 83, 47: 84, 48: 85, 49: 89, 50: 90, 51: 91, 52: 92, 53: 94, 54: 97, 55: 99, 56: 103, 57: 104, 58: 105, 59: 107, 60: 108, 61: 109, 62: 110, 63: 111, 64: 113, 65: 115, 66: 116, 67: 117, 68: 118, 69: 119, 70: 120, 71: 121, 72: 122, 73: 123, 74: 124, 75: 125, 76: 128, 77: 129, 78: 130, 79: 131, 80: 134, 81: 138, 82: 139, 83: 140, 84: 142, 85: 144, 86: 145, 87: 146, 88: 147, 89: 149, 90: 151, 91: 153, 92: 158, 93: 159, 94: 160, 95: 161, 96: 165, 97: 166, 98: 169, 99: 174, 100: 175, 101: 176, 102: 179, 103: 180, 104: 181, 105: 182, 106: 183, 107: 186, 108: 187, 109: 190, 110: 191, 111: 195, 112: 196, 113: 197, 114: 198, 115: 200, 116: 203, 117: 204 } });
/** 渲染进程连续崩溃恢复次数上限，超过则判定不可恢复并关闭容器（对齐 Android）。 */
const MAX_RENDER_RECOVERY: number = 3;
/**
 * 崩溃恢复计数的冷却窗口（毫秒）。距上次崩溃超过此窗口视为页面已稳定运行过，
 * 本次崩溃按全新问题处理并重置连续计数，避免长时间运行中的偶发（非连续）崩溃
 * 累计触顶被误判为"不可恢复"。对齐 iOS renderRecoveryResetWindow。
 */
const RENDER_RECOVERY_RESET_WINDOW: number = 30000;
/**
 * 承载 SDK Web 组件的**统一命令式 Builder + NodeController**（离线 Web 组件）。
 *
 * Page（open 模式）、Component（嵌入模式）、以及预热池都用这同一套 `@Builder` 构建，
 * 从而保证「池预热态」的组件能被真实页 `NodeContainer` 绑定复用（事件绑定同构）。
 *
 * 所有 Web 事件回调转发到 `model.handlers`，联动状态写回 `model`（`@Observed`，容器响应式读取）。
 */
/** 统一 Web 组件 Builder：所有链式属性/事件与原 Page/Component 声明等价。 */
function tencentQianWebBuilder(model: WebHostModel, parent = null): void {
    bjccovms8pf60p.instrumentFunction(0);
    const __model__ = model;
    (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, model = __model__) => {
        bjccovms8pf60p.instrumentFunction(1);
        Web.create({ src: model.url, controller: model.controller });
        Web.javaScriptAccess(model.handlers!.webSettings.javaScriptAccess);
        Web.domStorageAccess(model.handlers!.webSettings.domStorageAccess);
        Web.mediaPlayGestureAccess(model.handlers!.webSettings.mediaPlaybackRequiresUserGesture);
        Web.fileAccess(model.handlers!.webSettings.fileAccess);
        Web.databaseAccess(model.handlers!.webSettings.databaseAccess);
        Web.textZoomRatio(model.handlers!.webSettings.textZoomAtio);
        Web.zoomAccess(model.handlers!.webSettings.zoomAccess);
        Web.multiWindowAccess(model.handlers!.webSettings.multiWindowAccess);
        Web.wideViewModeAccess(model.handlers!.webSettings.wideViewModeAccess);
        Web.overviewModeAccess(model.handlers!.webSettings.overviewModeAccess);
        Web.mixedMode(model.handlers!.mixedMode === 'All' ? (bjccovms8pf60p.instrumentBranch(1, 0, true), MixedMode.All) : (bjccovms8pf60p.instrumentBranch(1, 0, false), MixedMode.None));
        Web.javaScriptOnDocumentStart(model.handlers!.documentStartScripts as Array<ScriptItem>);
        Web.onControllerAttached(() => {
            bjccovms8pf60p.instrumentFunction(2);
            bjccovms8pf60p.instrumentRegion(2, 1);
            model.handlers!.onControllerAttached();
        });
        Web.onLoadIntercept((event: any) => { bjccovms8pf60p.instrumentFunction(3); return model.handlers!.onLoadIntercept(event); });
        Web.onPageBegin((event: any) => {
            bjccovms8pf60p.instrumentFunction(4);
            model.isPageLoading = true;
            model.progressVisible = true;
            model.progress = 0;
            if (model.onProgressChanged !== null) {
                bjccovms8pf60p.instrumentBranch(4, 0, true);
                bjccovms8pf60p.instrumentRegion(4, 1);
                model.onProgressChanged(0, true);
            }
            else {
                bjccovms8pf60p.instrumentBranch(4, 0, false);
            }
            bjccovms8pf60p.instrumentRegion(0, 1);
            model.lastVisitedUrl = RenderRecovery.captureLastUrl(event, model.lastVisitedUrl);
            model.handlers!.onPageBegin(event);
        });
        Web.onPageEnd((event: any) => {
            bjccovms8pf60p.instrumentFunction(5);
            model.isPageLoading = false;
            model.progress = 100;
            // 页面成功加载完成 → 崩溃恢复计数清零，但**必须门控稳定运行窗口**：
            // OOM 型必崩页面每次都是"加载完成 → 运行几秒 → 再崩"，若无条件清零，则 onPageEnd
            // 会把刚累加的计数抹掉，renderRecoveryCount 永远停在 1，MAX_RENDER_RECOVERY 上限形同
            // 虚设、陷入无限 reload。仅当距上次崩溃超过 RENDER_RECOVERY_RESET_WINDOW（真正稳定运行过）
            // 才清零；否则保留计数，让连续崩溃能累加到上限触发 onRenderUnrecoverable。
            // 从未崩溃过的正常页面：lastRenderTerminateAtMs 初始 0，差值远超窗口，照常清零（本就是 0，no-op）。
            if (Date.now() - model.lastRenderTerminateAtMs > RENDER_RECOVERY_RESET_WINDOW) {
                bjccovms8pf60p.instrumentBranch(5, 0, true);
                bjccovms8pf60p.instrumentRegion(5, 1);
                model.renderRecoveryCount = 0;
            }
            // 恢复成功后 timer 已执行完毕，复位 id 保持状态干净（clearTimeout 已触发 id 为 no-op）。
            else {
                bjccovms8pf60p.instrumentBranch(5, 0, false);
            }
            // 恢复成功后 timer 已执行完毕，复位 id 保持状态干净（clearTimeout 已触发 id 为 no-op）。
            model.pendingRecoverTimerId = -1;
            if (model.onProgressChanged !== null) {
                bjccovms8pf60p.instrumentBranch(5, 1, true);
                bjccovms8pf60p.instrumentRegion(5, 2);
                model.onProgressChanged(100, true);
                bjccovms8pf60p.instrumentRegion(0, 3);
                // 短暂保留 100% 后淡出
                setTimeout(() => {
                    bjccovms8pf60p.instrumentFunction(6);
                    if (model.onProgressChanged !== null) {
                        bjccovms8pf60p.instrumentBranch(6, 0, true);
                        bjccovms8pf60p.instrumentRegion(6, 1);
                        model.onProgressChanged(100, false);
                    }
                    else {
                        bjccovms8pf60p.instrumentBranch(6, 0, false);
                    }
                }, 200);
            }
            else {
                bjccovms8pf60p.instrumentBranch(5, 1, false);
            }
            try {
                bjccovms8pf60p.instrumentRegion(5, 3);
                // 池复用（HEAVY 预热）后的首个页面加载完成：清掉预热残留历史（warmupUrl / about:blank），
                // 使 signingUrl 成为唯一历史项，避免第一次点返回退回预热页。仅执行一次，不影响页内导航。
                if (model.clearHistoryOnce) {
                    bjccovms8pf60p.instrumentBranch(5, 2, true);
                    bjccovms8pf60p.instrumentRegion(5, 5);
                    model.clearHistoryOnce = false;
                    try {
                        bjccovms8pf60p.instrumentRegion(5, 6);
                        model.controller.clearHistory();
                    }
                    catch (_e) {
                        bjccovms8pf60p.instrumentRegion(5, 7);
                    }
                }
                else {
                    bjccovms8pf60p.instrumentBranch(5, 2, false);
                }
                model.canGoBack = model.controller.accessBackward();
                model.title = model.controller.getTitle();
                if (model.onTitleChanged !== null) {
                    bjccovms8pf60p.instrumentBranch(5, 3, true);
                    bjccovms8pf60p.instrumentRegion(5, 8);
                    model.onTitleChanged(model.title, model.canGoBack);
                }
                else {
                    bjccovms8pf60p.instrumentBranch(5, 3, false);
                }
            }
            catch (_e) {
                bjccovms8pf60p.instrumentRegion(5, 4);
            }
            bjccovms8pf60p.instrumentRegion(0, 2);
            model.handlers!.onPageEnd(event);
        });
        Web.onProgressChange((event: any) => {
            bjccovms8pf60p.instrumentFunction(7);
            // 对齐 Android animateProgressTo：仅在整页加载周期（onPageBegin 后、onPageEnd 前）
            // 驱动进度条。SPA 软导航（pushState/hashchange）不触发 onPageBegin，isPageLoading=false，
            // 其加载子资源触发的 onProgressChange 一律不显示，避免切路由时进度条重现。
            if (!model.isPageLoading) {
                bjccovms8pf60p.instrumentBranch(7, 0, true);
                bjccovms8pf60p.instrumentRegion(7, 1);
                model.handlers!.onProgressChange(event);
                bjccovms8pf60p.instrumentRegion(0, 5);
                return;
            }
            else {
                bjccovms8pf60p.instrumentBranch(7, 0, false);
            }
            const np: number = (event as any).newProgress as number;
            model.progress = np;
            model.progressVisible = np < 100;
            if (model.onProgressChanged !== null) {
                bjccovms8pf60p.instrumentBranch(7, 1, true);
                bjccovms8pf60p.instrumentRegion(7, 2);
                model.onProgressChanged(np, model.progressVisible);
            }
            else {
                bjccovms8pf60p.instrumentBranch(7, 1, false);
            }
            bjccovms8pf60p.instrumentRegion(0, 4);
            model.handlers!.onProgressChange(event);
        });
        Web.onPermissionRequest((event: any) => { bjccovms8pf60p.instrumentFunction(8); return model.handlers!.onPermissionRequest(event); });
        Web.onShowFileSelector((event: any) => { bjccovms8pf60p.instrumentFunction(9); return model.handlers!.onShowFileSelector(event); });
        Web.onAlert((event: any) => { bjccovms8pf60p.instrumentFunction(10); return model.handlers!.onAlert(event); });
        Web.onConfirm((event: any) => { bjccovms8pf60p.instrumentFunction(11); return model.handlers!.onConfirm(event); });
        Web.onPrompt((event: any) => { bjccovms8pf60p.instrumentFunction(12); return model.handlers!.onPrompt(event); });
        Web.onDownloadStart((event: any) => { bjccovms8pf60p.instrumentFunction(13); return model.handlers!.onDownloadStart(event); });
        Web.onErrorReceive((event: any) => { bjccovms8pf60p.instrumentFunction(14); return model.handlers!.onErrorReceive(event); });
        Web.onHttpErrorReceive((event: any) => { bjccovms8pf60p.instrumentFunction(15); return model.handlers!.onHttpErrorReceive(event); });
        Web.onSslErrorEventReceive((event: any) => { bjccovms8pf60p.instrumentFunction(16); return model.handlers!.onSslErrorEventReceive(event); });
        Web.onRenderExited((event: any) => {
            bjccovms8pf60p.instrumentFunction(17);
            model.handlers!.onRenderExited(event);
            // 借出态实例崩溃：即便 reload 成功也已是"渲染进程死过的"僵尸，作废池避免归还后污染复用。
            // 对齐 Android 借出态 invalidatePooledWebView（自建实例 fromPool=false，不触发）。
            if (model.fromPool && model.onPoolInvalidateRequest !== null) {
                bjccovms8pf60p.instrumentBranch(17, 0, true);
                bjccovms8pf60p.instrumentRegion(17, 1);
                try {
                    bjccovms8pf60p.instrumentRegion(17, 2);
                    model.onPoolInvalidateRequest();
                }
                catch (_e) {
                    bjccovms8pf60p.instrumentRegion(17, 3);
                }
                bjccovms8pf60p.instrumentRegion(0, 7);
                model.fromPool = false;
            }
            // 冷却重置：距上次崩溃超过 RENDER_RECOVERY_RESET_WINDOW 视为页面已稳定运行过，
            // 本次按全新问题处理，重置连续计数，避免偶发崩溃被误判为"不可恢复"。
            else {
                bjccovms8pf60p.instrumentBranch(17, 0, false);
            }
            // 冷却重置：距上次崩溃超过 RENDER_RECOVERY_RESET_WINDOW 视为页面已稳定运行过，
            // 本次按全新问题处理，重置连续计数，避免偶发崩溃被误判为"不可恢复"。
            const nowMs: number = Date.now();
            if (nowMs - model.lastRenderTerminateAtMs > RENDER_RECOVERY_RESET_WINDOW) {
                bjccovms8pf60p.instrumentBranch(17, 1, true);
                bjccovms8pf60p.instrumentRegion(17, 4);
                model.renderRecoveryCount = 0;
            }
            else {
                bjccovms8pf60p.instrumentBranch(17, 1, false);
            }
            model.lastRenderTerminateAtMs = nowMs;
            // 连续崩溃达上限 → 判定不可恢复，停止 reload 并关闭容器，避免死循环 reload 风暴。
            model.renderRecoveryCount++;
            if (model.renderRecoveryCount > MAX_RENDER_RECOVERY) {
                bjccovms8pf60p.instrumentBranch(17, 2, true);
                bjccovms8pf60p.instrumentRegion(17, 5);
                if (model.onRenderUnrecoverable !== null) {
                    bjccovms8pf60p.instrumentBranch(17, 3, true);
                    bjccovms8pf60p.instrumentRegion(17, 6);
                    model.onRenderUnrecoverable();
                }
                else {
                    bjccovms8pf60p.instrumentBranch(17, 3, false);
                }
                bjccovms8pf60p.instrumentRegion(0, 8);
                return;
            }
            else {
                bjccovms8pf60p.instrumentBranch(17, 2, false);
            }
            bjccovms8pf60p.instrumentRegion(0, 6);
            const fallback: string = model.lastVisitedUrl.length > 0 ? (bjccovms8pf60p.instrumentBranch(17, 4, true), model.lastVisitedUrl) : (bjccovms8pf60p.instrumentBranch(17, 4, false), model.url);
            // 取消上一次未执行的延迟恢复（连续崩溃场景），避免累积多个 timer。
            model.cancelPendingRecover();
            // 恢复链 refresh → loadUrl 均失败（崩溃后 controller 常已失效）时，通知容器关闭，
            // 消除持久白屏兜底缺口。对齐 Android 恢复失败 finish()。
            // 保存 timer id：用户在 1s 延迟窗口内关闭页面时，容器 aboutToDisappear 会 clearTimeout 取消，
            // 避免回调访问已销毁/已归还的 controller（野指针）。
            model.pendingRecoverTimerId = RenderRecovery.recover(model.controller, fallback, () => {
                bjccovms8pf60p.instrumentFunction(18);
                model.pendingRecoverTimerId = -1;
                if (model.onRenderUnrecoverable !== null) {
                    bjccovms8pf60p.instrumentBranch(18, 0, true);
                    bjccovms8pf60p.instrumentRegion(18, 1);
                    model.onRenderUnrecoverable();
                }
                else {
                    bjccovms8pf60p.instrumentBranch(18, 0, false);
                }
            });
        });
        Web.width('100%');
        Web.height('100%');
    }, Web);
}
const TENCENT_QIAN_WEB_WRAP: WrappedBuilder<[
    WebHostModel
]> = wrapBuilder<[
    WebHostModel
]>(tencentQianWebBuilder);
/**
 * 承载离线 Web 组件的 NodeController。容器把它交给 `NodeContainer(...)` 绑定即上树渲染。
 */
export class WebNodeController extends NodeController {
    private builderNode: BuilderNode<[
        WebHostModel
    ]> | null = null;
    private model: WebHostModel | null = null;
    /** 命令式创建离线 Web 组件（触发渲染进程；未挂载时 Hidden/Inactive）。 */
    public init(uiContext: UIContext, model: WebHostModel): void {
        bjccovms8pf60p.instrumentFunction(19);
        bjccovms8pf60p.instrumentRegion(19, 1);
        this.model = model;
        const node: BuilderNode<[
            WebHostModel
        ]> = new BuilderNode<[
            WebHostModel
        ]>(uiContext);
        node.build(TENCENT_QIAN_WEB_WRAP, model);
        this.builderNode = node;
    }
    makeNode(_uiContext: UIContext): FrameNode | null {
        bjccovms8pf60p.instrumentFunction(20);
        bjccovms8pf60p.instrumentRegion(20, 1);
        return this.builderNode !== null ? (bjccovms8pf60p.instrumentBranch(20, 0, true), this.builderNode.getFrameNode()) : (bjccovms8pf60p.instrumentBranch(20, 0, false), null);
    }
    public getModel(): WebHostModel | null {
        bjccovms8pf60p.instrumentFunction(21);
        bjccovms8pf60p.instrumentRegion(21, 1);
        return this.model;
    }
    /** 销毁离线节点（调用前须确保已从 NodeContainer 解绑，避免白屏）。 */
    public disposeNode(): void {
        bjccovms8pf60p.instrumentFunction(22);
        try {
            bjccovms8pf60p.instrumentRegion(22, 1);
            if (this.builderNode !== null) {
                bjccovms8pf60p.instrumentBranch(22, 0, true);
                bjccovms8pf60p.instrumentRegion(22, 3);
                this.builderNode.dispose();
            }
            else {
                bjccovms8pf60p.instrumentBranch(22, 0, false);
            }
        }
        catch (_e) {
            bjccovms8pf60p.instrumentRegion(22, 2);
        }
        bjccovms8pf60p.instrumentRegion(22, 4);
        this.builderNode = null;
        this.model = null;
    }
}
