import{l as s,h as t,z as e,x as a,bg as l,bh as i}from"./utils-lib.js?v=20260328163632";import{B as o}from"./naive-ui.js?v=20260328163632";import{k as n,O as r,j as c}from"./base-lib.js?v=20260328163632";const p=n({name:"BtSearchHistory",props:{name:{type:String,default:""},keys:{type:String,default:""},list:{type:Object,default:()=>({historyList:[],recommendList:[]})},showHistory:{type:Boolean,default:!0},showRecommend:{type:Boolean,default:!0}},emits:["search","trigger","updateList"],setup(n,{emit:p}){const{name:d,keys:m}=n;return()=>{var u;return r("div",{class:"box w-[400px]",onMousedown:s=>s.preventDefault()},[r("div",{class:"".concat(n.showHistory?"":"hidden")},[r("span",{class:"history-title"},[r("span",{class:"text-[var(--text-color-3)] text-[12px]"},[c(" "),s("搜索历史")]),r(o,{size:"small",onClick:t=>{t.stopPropagation(),(async()=>{await e({icon:"warning-filled",title:s("清空搜索历史"),content:s("清空所有搜索历史记录，是否继续？")});const t={model_name:d,key:m};a({loading:s("正在清空搜索历史记录，请稍后..."),request:l(t),message:!0,success:s=>{(null==s?void 0:s.status)&&(n.list.historyList.length=0,p("updateList",[])),p("trigger",!0)}})})()}},{default:()=>[r("span",{class:"flex items-center"},[r("i",{class:"svgtofont-el-delete mr-[4px]"},null),r("span",null,[s("清空")])])]})]),r("div",{class:"list-box"},[r("div",{class:"list-box-body max-h-[240px] !overflow-y-auto"},[null==(u=n.list.historyList)?void 0:u.map(((t,l)=>r("div",{key:l,class:"body-item",onClick:s=>{var e;e=t.val,p("search",e),p("trigger",!1),s.stopPropagation()}},[r("span",{title:t.val,class:"truncate max-w-[160px]"},[t.val]),r("i",{class:"svgtofont-el-close",onClick:o=>{(async(t,l)=>{await e({icon:"warning-filled",title:s("删除搜索历史记录"),content:s("删除该条搜索历史【{0}】，是否继续？",[t])}),a({loading:s("正在删除指定搜索历史记录，请稍后..."),request:i({model_name:d,key:m,val:t}),message:!0,success:s=>{if(null==s?void 0:s.status){let s=n.list.historyList;s.splice(l,1),s=[...s],p("updateList",s)}p("trigger",!0)}})})(t.val,l),o.stopPropagation()}},null)])))]),!n.list.historyList.length&&r("div",{class:"w-full flex items-center justify-center h-[60px]"},[r("span",null,[s("暂无搜索历史")])])])]),r("div",{class:"".concat(n.showRecommend?"":"hidden")},[r("span",{class:"history-title !justify-start"},[r("span",{class:"text-[var(--text-color-3)] text-[12px]"},[s("您可能感兴趣")]),r(t,{class:"w-[14px] h-[14px] ml-[5px]",src:"/soft_ico/hots.png"},null)]),r("div",{class:"recommend-list"},[n.list.recommendList.filter((s=>!0!==s.hide)).map(((s,t)=>r("div",{key:t,class:"recommend-item",onClick:t=>{t.stopPropagation(),(s=>{s.callback&&s.callback(),p("trigger",!1)})(s)}},[r("span",null,[s.name])])))])])])}}});export{p as B};
