import{d as w,V as u,aq as k,$ as S,as as C,U as x,ao as R,h as T,a as t,S as O,G as V,H as g,z as K,x as M,u as I,R as U,P as b}from"./vendor.405ecf9c.js";/* empty css *//* empty css *//* empty css *//* empty css */import{C as N}from"./index.96f38933.js";import{c as z}from"./index.126c459c.js";import{c as B}from"./index.926ca9c5.js";import{S as H}from"./select-tag.7073b9d3.js";import{g as P}from"./music.a5aa04f0.js";import{S as $}from"./select-subject.abd77e32.js";function q(a){return{all:a=a||new Map,on:function(n,s){var o=a.get(n);o?o.push(s):a.set(n,[s])},off:function(n,s){var o=a.get(n);o&&(s?o.splice(o.indexOf(s)>>>0,1):a.set(n,[]))},emit:function(n,s){var o=a.get(n);o&&o.slice().map(function(c){c(s)}),(o=a.get("*"))&&o.slice().map(function(c){c(n,s)})}}}const A="_search_ngdof_1",D="_sticky_ngdof_9",F="_title_ngdof_15",G="_keywords_ngdof_21",L="_content_ngdof_28",W="_searchKeyword_ngdof_38",E="_remove_ngdof_46",J="_label_ngdof_49";var d={search:A,sticky:D,title:F,keywords:G,content:L,searchKeyword:W,remove:E,label:J};function Q(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!M(a)}const m=q(),_=u();var X=w({name:"MusicSearchHeader",setup(){const a=u();localStorage.setItem("behaviorId",P());const n=k(),s=S(),o=u(""),c=u(""),h=u(!1),r=z("music-search",[]),f=u("songe");C(()=>{var e,i;if(s.path==="/music-songbook/search"){o.value="",c.value="",f.value="songe";try{(i=(e=_.value)==null?void 0:e.resetTags)==null||i.call(e)}catch(p){console.log(p)}}return!0}),x(f,e=>{m.emit("changeTab",e)});const v=e=>{o.value=e;const i=r.value.indexOf(e);i>-1&&r.value.splice(i,1),e&&(r.value.unshift(e),r.value.length=Math.min(r.value.length,5)),m.emit("search",e)},y=(e,i="")=>{const p=Object.values(e).flat().filter(Boolean).join(",");c.value=p,m.emit("confirm",e),h.value=!1},j=e=>{l.name=e.name,l.id=e.id,m.emit("confirmSubject",l),l.show=!1};R(()=>{});const l=T({show:!1,name:"\u5168\u90E8",id:""});return()=>t("div",{class:d.search},[t(O,{class:d.sticky},{default:()=>[t(N,{modelValue:o.value,showAction:!0,ref:a,onSearch:v,onFilter:()=>h.value=!0,filterDot:!!c.value,onClick:()=>{s.path==="/music-songbook"&&n.push({path:"/music-songbook/search"})}},null),s.path==="/music-songbook/search"&&t(V,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:f.value,"onUpdate:active":e=>f.value=e,onChange:e=>f.value=e},{default:()=>[t(g,{title:"\u5355\u66F2",name:"songe"},null),t(g,{title:"\u4E13\u8F91",name:"album"},null)]})]}),r.value.length>0&&s.path==="/music-songbook/search"&&t("div",{class:B(d.keywords,"van-hairline--bottom")},[t("div",{class:d.content},[r.value.map(e=>t(K,{round:!0,class:d.searchKeyword,key:e,onClick:()=>v(e)},Q(e)?e:{default:()=>[e]}))]),t(I,{class:d.remove,name:"delete-o",onClick:()=>r.value=[]},null)]),t(U,null,null),t(b,{show:h.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>h.value=e},{default:()=>[t(H,{ref:_,onConfirm:y,onCancel:()=>{}},null)]}),t(b,{show:l.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>l.show=!1,onClosed:()=>l.show=!1},{default:()=>[t($,{isReset:!0,onComfirm:j},null)]})])}}),ie=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",mitter:m,default:X});export{ie as h,m,d as s};