import{Dt as e,kt as t}from"./BA99CCI5.js";import"./D7pSEO6W.js";import{n,t as r}from"./Da9e11Mg.js";function i(e){let{storageKey:n,defaultView:r=`cards`,mobileBreakpoint:i=768}=e,a=r;try{let e=localStorage.getItem(n);e===`cards`||e===`table`?a=e:window.innerWidth<i&&(a=`cards`)}catch{window.innerWidth<i&&(a=`cards`)}let o=t(a);return o.subscribe(e=>{try{localStorage.setItem(n,e)}catch{}}),o}function a(a,o){let{storageKey:s,searchKeys:c,defaultView:l=`cards`,debounceMs:u=300}=o,d=t(a),f=o.searchStore??(o.searchKey?n(o.searchKey,{debounceMs:u}):r({debounceMs:u})),p=i({storageKey:s,defaultView:l}),m=e([d,f.debouncedQuery],([e,t])=>{if(!t)return e;let n=t.toLowerCase();return e.filter(e=>c.some(t=>{let r=e[t];return r!=null&&String(r).toLowerCase().includes(n)}))});return{search:f,view:{subscribe:p.subscribe,set:p.set},filtered:{subscribe:m.subscribe},setItems:e=>d.set(e)}}export{i as n,a as t};