import{useState as n}from"react";const i="catalog-view-mode",c="table";function d(o){const[r,a]=n(o??c);return{viewMode:r,setViewMode:t=>{if(a(t),!(typeof window>"u")){try{localStorage.setItem(i,t)}catch(e){console.warn("Failed to save view mode preference to localStorage",e)}try{const e=new URL(window.location.href);e.searchParams.set("viewMode",t),window.history.replaceState({},"",e.toString())}catch(e){console.warn("Failed to update viewMode query parameter",e)}}}}}export{d as useCatalogViewMode};
