import{d as T,s as N,O as f,M as I,L as E,bB as H,Z as M,P as V,N as x,i as o,J as y,R as A,aQ as j,V as K}from"./index.afa1b71c.js";import{S as P}from"./index.db3b0e47.js";import{T as B}from"./index.30fb9a6a.js";import"./index.7c0d35f2.js";import{T as J,a as w}from"./index.0daa711a.js";import{C as U}from"./index.09943e1e.js";import{c as z}from"./index.fce7f544.js";import{c as L}from"./index.926ca9c5.js";import{S as Q}from"./select-tag.5ef46951.js";import{g as W}from"./music.9b0ac3f4.js";import{S as Z}from"./select-subject.fb5b00b2.js";import{a as h,S as b}from"./hooks.ea9ec317.js";function $(s){return{all:s=s||new Map,on:function(r,c){var t=s.get(r);t?t.push(c):s.set(r,[c])},off:function(r,c){var t=s.get(r);t&&(c?t.splice(t.indexOf(c)>>>0,1):s.set(r,[]))},emit:function(r,c){var t=s.get(r);t&&t.slice().map(function(i){i(c)}),(t=s.get("*"))&&t.slice().map(function(i){i(r,c)})}}}const q="_search_ngdof_1",D="_sticky_ngdof_9",F="_title_ngdof_15",G="_keywords_ngdof_21",X="_content_ngdof_28",Y="_searchKeyword_ngdof_38",ee="_remove_ngdof_46",oe="_label_ngdof_49";var u={search:q,sticky:D,title:F,keywords:G,content:X,searchKeyword:Y,remove:ee,label:oe};function te(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!K(s)}const p=$(),k=f();var se=T({name:"MusicSearchHeader",setup(){if(!h(b.SEARCH).id){const e=N.user.data,n=e.subjectId?Number(e.subjectId.split(",")[0]):"",m=e.subjectName?e.subjectName.split(",")[0]:"";n&&h(b.SEARCH,JSON.stringify({id:n,name:m}),"set")}const r=f();localStorage.setItem("behaviorId",W());const c=I(),t=E(),i=f(""),v=f(""),g=f(!1),l=z("music-search",[]),d=f("songe");H(()=>{var n,m;const e=h(b.SEARCH);if(a.name=e.name||"\u5168\u90E8\u58F0\u90E8",a.id=e.id,t.path==="/music-songbook/search"){i.value="",v.value="",d.value="songe";try{(m=(n=k.value)==null?void 0:n.resetTags)==null||m.call(n)}catch(O){console.log(O)}}return!0}),M(d,e=>{p.emit("changeTab",e)});const S=e=>{i.value=e;const n=l.value.indexOf(e);n>-1&&l.value.splice(n,1),e&&(l.value.unshift(e),l.value.length=Math.min(l.value.length,5)),p.emit("search",e)},C=(e,n="")=>{const m=Object.values(e).flat().filter(Boolean).join(",");v.value=m,p.emit("confirm",e),g.value=!1},R=e=>{a.name=e.name,a.id=e.id,h(b.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set"),p.emit("confirmSubject",a),a.show=!1};V(()=>{});const _=h(b.SEARCH),a=x({show:!1,name:_.name||"\u5168\u90E8\u58F0\u90E8",id:_.id||""});return()=>o("div",{class:u.search},[o(P,{class:u.sticky},{default:()=>[o(U,{modelValue:i.value,ref:r,onSearch:S,onClick:()=>{t.path==="/music-songbook"&&c.push({path:"/music-songbook/search"})}},{left:()=>o("div",{class:u.label,onClick:()=>a.show=!0},[a.name,o(y,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t.path==="/music-songbook/search"&&o(J,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:d.value,"onUpdate:active":e=>d.value=e,onChange:e=>d.value=e},{default:()=>[o(w,{title:"\u5355\u66F2",name:"songe"},null),o(w,{title:"\u4E13\u8F91",name:"album"},null)]})]}),l.value.length>0&&t.path==="/music-songbook/search"&&o("div",{class:L(u.keywords,"van-hairline--bottom")},[o("div",{class:u.content},[l.value.map(e=>o(B,{round:!0,class:u.searchKeyword,key:e,onClick:()=>S(e)},te(e)?e:{default:()=>[e]}))]),o(y,{class:u.remove,name:"delete-o",onClick:()=>l.value=[]},null)]),o(A,null,null),o(j,{show:g.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>g.value=e},{default:()=>[o(Q,{ref:k,onConfirm:C,onCancel:()=>{}},null)]}),o(j,{show:a.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>a.show=!1,onClosed:()=>a.show=!1},{default:()=>[o(Z,{searchParams:a,onComfirm:R},null)]})])}}),pe=Object.freeze(Object.defineProperty({__proto__:null,mitter:p,default:se},Symbol.toStringTag,{value:"Module"}));export{pe as h,p as m,u as s};
