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