"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    extractInsightParam: ()=>extractInsightParam,
    locateParamStr: ()=>locateParamStr,
    paramStr: ()=>paramStr,
    pullParamStr: ()=>pullParamStr,
    scrollParamStr: ()=>scrollParamStr,
    taskTitleStr: ()=>taskTitleStr,
    typeStr: ()=>typeStr
});
function typeStr(task) {
    return task.subType || task.type;
}
function locateParamStr(locate) {
    if (!locate) return '';
    if ('string' == typeof locate) return locate;
    if ('object' == typeof locate) {
        if ('object' == typeof locate.prompt && null !== locate.prompt && locate.prompt.prompt) {
            const prompt = locate.prompt.prompt;
            return prompt;
        }
        if ('string' == typeof locate.prompt) return locate.prompt;
        if ('string' == typeof locate.description) return locate.description;
    }
    return '';
}
function scrollParamStr(scrollParam) {
    if (!scrollParam) return '';
    return `${scrollParam.direction || 'down'}, ${scrollParam.scrollType || 'singleAction'}, ${scrollParam.distance || 'distance-not-set'}`;
}
function pullParamStr(pullParam) {
    if (!pullParam) return '';
    const parts = [];
    parts.push(`direction: ${pullParam.direction || 'down'}`);
    if (pullParam.distance) parts.push(`distance: ${pullParam.distance}`);
    if (pullParam.duration) parts.push(`duration: ${pullParam.duration}ms`);
    return parts.join(', ');
}
function extractInsightParam(taskParam) {
    if (!taskParam) return {
        content: ''
    };
    const extractImages = (source)=>source?.multimodalPrompt?.images && Array.isArray(source.multimodalPrompt.images) ? source.multimodalPrompt.images : void 0;
    const toContent = (value)=>'string' == typeof value ? value : JSON.stringify(value);
    if (taskParam.demand) return {
        content: toContent(taskParam.demand),
        images: extractImages(taskParam)
    };
    if (taskParam.assertion) return {
        content: toContent(taskParam.assertion),
        images: extractImages(taskParam)
    };
    if (taskParam.dataDemand) {
        const { dataDemand } = taskParam;
        if ('string' == typeof dataDemand) return {
            content: dataDemand
        };
        if ('object' == typeof dataDemand) return {
            content: toContent(dataDemand.demand || dataDemand),
            images: extractImages(dataDemand)
        };
    }
    return {
        content: ''
    };
}
function taskTitleStr(type, prompt) {
    if (prompt) return `${type} - ${prompt}`;
    return type;
}
function paramStr(task) {
    let value;
    if ('Planning' === task.type) if ('Locate' === task.subType) value = locateParamStr(task?.param);
    else {
        const planTask = task;
        value = planTask.output?.log || planTask.param?.userInstruction;
    }
    if ('Insight' === task.type) value = extractInsightParam(task?.param).content;
    if ('Action Space' === task.type) {
        const locate = task?.param?.locate;
        const locateStr = locate ? locateParamStr(locate) : '';
        value = task.thought || '';
        if ('number' == typeof task?.param?.timeMs) value = `${task?.param?.timeMs}ms`;
        else if ('string' == typeof task?.param?.scrollType) value = scrollParamStr(task?.param);
        else if ('string' == typeof task?.param?.direction && task?.subType === 'PullGesture') value = pullParamStr(task?.param);
        else if (void 0 !== task?.param?.value) value = task?.param?.value;
        else if (task?.param && 'object' == typeof task?.param && Object.keys(task?.param || {}).length > 0) value = task?.param;
        if (locateStr) value = value && 'object' != typeof value ? `${locateStr} - ${value}` : locateStr;
    }
    if (void 0 === value) return '';
    if ('string' == typeof value) return value;
    if ('object' == typeof value) {
        const locateStr = locateParamStr(value);
        if (locateStr) return locateStr;
        return JSON.stringify(value, void 0, 2);
    }
    return String(value);
}
exports.extractInsightParam = __webpack_exports__.extractInsightParam;
exports.locateParamStr = __webpack_exports__.locateParamStr;
exports.paramStr = __webpack_exports__.paramStr;
exports.pullParamStr = __webpack_exports__.pullParamStr;
exports.scrollParamStr = __webpack_exports__.scrollParamStr;
exports.taskTitleStr = __webpack_exports__.taskTitleStr;
exports.typeStr = __webpack_exports__.typeStr;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "extractInsightParam",
    "locateParamStr",
    "paramStr",
    "pullParamStr",
    "scrollParamStr",
    "taskTitleStr",
    "typeStr"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});

//# sourceMappingURL=ui-utils.js.map