import {J}from'./main-WUGO6e7n.js';var f,o=J(()=>{f=(()=>{class a{static{this.storageKey="dvls.table.columnVisibility";}static{this.version=1;}static getVisibleFields(i,e){let l=this.readRegistry()?.tables[i]??null;return this.normalizeVisibleFields(e,l)}static setVisibleFields(i,e,s){let l=this.normalizeVisibleFields(e,{version:1,visibleFields:s,knownFields:e.map(t=>t.field)}),r=this.readRegistry()??{version:1,tables:{}};return r.tables[i]={version:1,visibleFields:l,knownFields:e.map(t=>t.field)},this.writeRegistry(r),l}static normalizeVisibleFields(i,e){let s=new Set(e?.knownFields??[]),l=new Set(i.map(t=>t.field)),r=new Set((e?.visibleFields??this.getDefaultVisibleFields(i)).filter(t=>l.has(t)));for(let t of i){if(t.alwaysVisible){r.add(t.field);continue}!s.has(t.field)&&!t.hiddenByDefault&&r.add(t.field);}return i.some(t=>t.alwaysVisible||r.has(t.field))?i.filter(t=>t.alwaysVisible||r.has(t.field)).map(t=>t.field):this.getDefaultVisibleFields(i)}static getDefaultVisibleFields(i){return i.filter(e=>e.alwaysVisible||!e.hiddenByDefault).map(e=>e.field)}static readRegistry(){if(!this.canUseLocalStorage())return null;try{let i=window.localStorage.getItem(this.storageKey);if(!i)return null;let e=JSON.parse(i);return e.version!==this.version||!e.tables||typeof e.tables!="object"?null:{version:1,tables:Object.fromEntries(Object.entries(e.tables).map(([s,l])=>[s,this.normalizeState(l)]).filter(s=>!!s[1]))}}catch(i){return null}}static writeRegistry(i){this.canUseLocalStorage()&&window.localStorage.setItem(this.storageKey,JSON.stringify(i));}static normalizeState(i){if(!i||typeof i!="object")return null;let e=i;return e.version!==this.version||!Array.isArray(e.visibleFields)?null:{version:1,visibleFields:e.visibleFields.filter(s=>typeof s=="string"),knownFields:Array.isArray(e.knownFields)?e.knownFields.filter(s=>typeof s=="string"):[]}}static canUseLocalStorage(){try{return typeof window<"u"&&!!window.localStorage}catch(i){return !1}}}return a})();});export{f,o};