import{useState as i}from"react";import{telemetry as n}from"../../telemetry/index.js";const s="catalog-view-mode",w="table";function u(o){const[r,a]=i(o??w);return{viewMode:r,setViewMode:t=>{if(a(t),!(typeof window>"u")){try{localStorage.setItem(s,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()),n.sendCatalogEntitiesViewModeChangedMessage([{mode:t,id:t,object:"view_mode",uri:window.location.href}])}catch(e){console.warn("Failed to update viewMode query parameter",e)}}}}}export{u as useCatalogViewMode};
