1(()=>{"use strict";const createStoreImpl=t=>{let e;const n=new Set,setState=(t,i)=>{const o="function"==typeof t?t(e):t;if(!Object.is(o,e)){const t=e;e=(null!=i?i:"object"!=typeof o||null===o)?o:Object.assign({},e,o),n.forEach(n=>n(e,t))}},getState=()=>e,i={setState,getState,getInitialState:()=>o,subscribe:t=>(n.add(t),()=>n.delete(t))},o=e=t(setState,getState,i);return i},t="vibemap_collections";class LocalStorageAdapter{read(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(t);return e?JSON.parse(e):[]}catch(t){return[]}}write(e){"undefined"!=typeof window&&localStorage.setItem(t,JSON.stringify(e))}async load(){return this.read()}async save(t){this.write(t)}async addItem(t,e){const n=this.read(),i=n.find(e=>e.id===t);i&&(i.items.push(e),i.updatedAt=(new Date).toISOString(),this.write(n))}async removeItem(t,e){const n=this.read(),i=n.find(e=>e.id===t);i&&(i.items=i.items.filter(t=>t.id!==e),i.updatedAt=(new Date).toISOString(),this.write(n))}async moveItem(t,e,n){const i=this.read(),o=i.find(e=>e.id===t),s=i.find(t=>t.id===e);if(!o||!s)return;const a=o.items.findIndex(t=>t.id===n);if(-1===a)return;const[r]=o.items.splice(a,1);r.sortOrder=s.items.length,s.items.push(r),o.updatedAt=(new Date).toISOString(),s.updatedAt=(new Date).toISOString(),this.write(i)}async createCollection(t){const e=this.read();return e.push(t),this.write(e),t}async deleteCollection(t){const e=this.read().filter(e=>e.id!==t);this.write(e)}async updateCollection(t,e){const n=this.read(),i=n.find(e=>e.id===t);i&&(Object.assign(i,e,{updatedAt:(new Date).toISOString()}),this.write(n))}async generateShareToken(t){const e=this.read().find(e=>e.id===t);if(!e)throw new Error(`Collection ${t} not found`);return function utf8ToBase64(t){const e=(new TextEncoder).encode(t);let n="";for(let t=0;t<e.length;t+=32768)n+=String.fromCharCode(...e.subarray(t,t+32768));return btoa(n)}(JSON.stringify(e))}async getSharedCollection(t){return JSON.parse(function base64ToUtf8(t){return(new TextDecoder).decode(Uint8Array.from(atob(t),t=>t.charCodeAt(0)))}(t))}}function generateId(){return crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function createCollectionsStore(t){const e=function createDefaultCollection(){const t=(new Date).toISOString();return{id:generateId(),name:"My List",isDefault:!0,items:[],createdAt:t,updatedAt:t}}(),n=(i?createStoreImpl(i):createStoreImpl)((i,o)=>({collections:[e],activeCollectionId:e.id,hydrated:!1,syncStatus:"idle",lastSyncedAt:null,isAuthenticated:!1,_adapter:t,_setAdapter:t=>{n._adapter=t},_getAdapter:()=>{var e;return null!==(e=n._adapter)&&void 0!==e?e:t},toggleItem:(t,e)=>{i(n=>{const i=null!=e?e:n.activeCollectionId,s=n.collections.map(e=>{if(e.id!==i)return e;const n=e.items.findIndex(e=>e.ref===t.ref&&e.type===t.type),o=(new Date).toISOString();if(n>=0)return Object.assign(Object.assign({},e),{items:e.items.filter((t,e)=>e!==n),updatedAt:o});const s={id:generateId(),ref:t.ref,type:t.type,addedAt:o,sortOrder:e.items.length,meta:t.meta};return Object.assign(Object.assign({},e),{items:[...e.items,s],updatedAt:o})});return o()._getAdapter().save(s),{collections:s}})},removeItemEverywhere:t=>
1{i(e=>{let n=!1;const i=(new Date).toISOString(),s=e.collections.map(e=>{const o=e.items.filter(e=>e.ref!==t);return o.length===e.items.length?e:(n=!0,Object.assign(Object.assign({},e),{items:o,updatedAt:i}))});return n?(o()._getAdapter().save(s),{collections:s}):e})},reorderItems:(t,e)=>{i(n=>{const i=n.collections.map(n=>{if(n.id!==t)return n;const i=new Map(n.items.map(t=>[t.id,t])),o=e.map((t,e)=>{const n=i.get(t);return n?Object.assign(Object.assign({},n),{sortOrder:e}):null}).filter(Boolean);return Object.assign(Object.assign({},n),{items:o,updatedAt:(new Date).toISOString()})});return o()._getAdapter().save(i),{collections:i}})},createCollection:t=>{const e=(new Date).toISOString(),n={id:generateId(),name:t,isDefault:!1,items:[],createdAt:e,updatedAt:e};return i(t=>{const e=[...t.collections,n];return o()._getAdapter().save(e),{collections:e}}),n},deleteCollection:t=>{i(e=>{const n=e.collections.find(e=>e.id===t);if(!n||n.isDefault)return e;const i=e.collections.filter(e=>e.id!==t),s=e.activeCollectionId===t?e.collections.find(t=>t.isDefault).id:e.activeCollectionId;return o()._getAdapter().save(i),{collections:i,activeCollectionId:s}})},renameCollection:(t,e)=>{i(n=>{const i=n.collections.map(n=>n.id===t?Object.assign(Object.assign({},n),{name:e,updatedAt:(new Date).toISOString()}):n);return o()._getAdapter().save(i),{collections:i}})},setActiveCollection:t=>{i({activeCollectionId:t})},moveItem:(t,e,n)=>{i(i=>{let s=null;const a=i.collections.map(e=>{if(e.id===t){const t=e.items.findIndex(t=>t.id===n);return-1===t?e:(s=e.items[t],Object.assign(Object.assign({},e),{items:e.items.filter((e,n)=>n!==t),updatedAt:(new Date).toISOString()}))}return e}).map(t=>t.id===e&&s?Object.assign(Object.assign({},t),{items:[...t.items,Object.assign(Object.assign({},s),{sortOrder:t.items.length})],updatedAt:(new Date).toISOString()}):t);return o()._getAdapter().save(a),{collections:a}})},copyItem:(t,e,n)=>{i(i=>{const s=i.collections.find(e=>e.id===t);if(!s)return i;const a=s.items.find(t=>t.id===n);if(!a)return i;const r=Object.assign(Object.assign({},a),{id:generateId(),addedAt:(new Date).toISOString()}),c=i.collections.map(t=>t.id===e?Object.assign(Object.assign({},t),{items:[...t.items,Object.assign(Object.assign({},r),{sortOrder:t.items.length})],updatedAt:(new Date).toISOString()}):t);return o()._getAdapter().save(c),{collections:c}})},setAuthenticated:t=>{i({isAuthenticated:!0})},setUnauthenticated:()=>{i({isAuthenticated:!1,syncStatus:"idle",lastSyncedAt:null})},mergeOnLogin:async()=>{},sync:async()=>{}}));var i;return t.load().then(e=>{var i;if(e.length>0){const t=e.find(t=>t.isDefault);n.setState({collections:e,activeCollectionId:null!==(i=null==t?void 0:t.id)&&void 0!==i?i:e[0].id,hydrated:!0})}else t.save(n.getState().collections),n.setState({hydrated:!0})}),n}let e=null;const n="__vibemapCollectionsStore";function getCollectionsStore(t){if("undefined"!=typeof window){const t=window[n];if(t)return e=t,e}return e||(t||(t=new LocalStorageAdapter),e=createCollectionsStore(t)),"undefined"!=typeof window&&(window[n]=e),e}!function initCollectionsGlobal(){if("undefined"==typeof window)return;const t=getCollectionsStore();window.VibemapCollections={toggleItem:e=>t.getState().toggleItem(e),removeItemEverywhere:e=>t.getState().removeItemEverywhere(e),isItemSaved:e=>t.getState().collections.some(t=>t.items.some(t=>t.ref===e)),getCollections:()=>t.getState().collections,subscribe:e=>t.subscribe(e)};try{const e=new BroadcastChannel("vibemap-collections");t.subscribe(t=>{e.postMessage({type:"collections-update",collections:t.collections})}),e.onmessage=e=>{var n;if("collections-update"===(null===(n=e.data)||void 0===n?void 0:n.type)){const n=t.getState();JSON.stringify(n.collections)!==JSON.stringify(e.data.collections)&&t.setState({collections:e.data.collections})}}}catch(t){}}();const i="undefined"!=typeof window&&window.VibemapCollectionsInit||{},o=!1!==i.toasts,s=i.label||"My List",a=i.color||"#0073aa",r=i.viewAllUrl||"",c="vibemap-collections-toast-style",l="vibemap-collections-toast";let d=null,u=null;function showToast(t,e){!function injectStyles(){if(document.getElementById(c))return;const t=document.createElement("style");t.id=c,t.textContent=`\n.${l} {\n position: fixed;\n left: 50%;\n bottom: 28px;\n transform: translateX(-50%) translateY(12px);\n z-index: 99999;\n display: flex;\n align-items: center;\n gap: 12px;\n max-width: min(92vw, 480px);\n padding: 12px 16px;\n border-radius: 10px;\n background: ${a};\n color: #fff;\n font-size: 14px;\n line-height: 1.4;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);\n opacity: 0;\n transition: opacity 0.25s ease, transform 0.25s ease;\n}\n.${l}.is-visible {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n}\n.${l} a {\n color: #fff;\n font-weight: 700;\n text-decoration: underline;\n white-space: nowrap;\n}\n.${l} button {\n appearance: none;\n border: 0;\n background: transparent;\n color: rgba(255, 255, 255, 0.85);\n font-size: 18px;\n line-height: 1;\n cursor: pointer;\n padding: 2px 4px;\n}\n@media (prefers-reduced-motion: reduce) {\n .${l} { transition: opacity 0.25s ease; transform: translateX(-50%); }\n}`,document.head.appendChild(t)}(),d&&(d.remove(),d=null),u&&clearTimeout(u);const n=document.createElement("div");n.className=l,n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const i=document.createElement("span");if(i.textContent=t,n.appendChild(i),r&&e){const t=document.createElement("a");t.href=r,t.textContent=e,n.appendChild(t)}const o=document.createElement("button");
1o.type="button",o.setAttribute("aria-label","Dismiss"),o.innerHTML="Ã",o.addEventListener("click",hideToast),n.appendChild(o),document.body.appendChild(n),d=n,requestAnimationFrame(()=>{requestAnimationFrame(()=>n.classList.add("is-visible"))}),u=setTimeout(hideToast,3500)}function hideToast(){if(u&&(clearTimeout(u),u=null),!d)return;const t=d;d=null,t.classList.remove("is-visible"),setTimeout(()=>t.remove(),300)}function refsOf(t){const e=new Set;return(t||[]).forEach(t=>{(t.items||[]).forEach(t=>{t&&t.ref&&e.add(String(t.ref))})}),e}if(o&&"undefined"!=typeof document){const t=getCollectionsStore(),e="boolean"==typeof t.getState().hydrated;let n=!!e&&!0===t.getState().hydrated,i=refsOf(t.getState().collections);e||setTimeout(()=>{i=refsOf(t.getState().collections),n=!0},50),t.subscribe(t=>{if(!n)return void(e&&t.hydrated&&(i=refsOf(t.collections),n=!0));const o=refsOf(t.collections);let a=0,r=0;o.forEach(t=>{i.has(t)||(a+=1)}),i.forEach(t=>{o.has(t)||(r+=1)}),i=o,(a||r)&&(document.hidden||(a?showToast(`Added to ${s}!`,`View ${s}`):r&&showToast(`Removed from ${s}.`,`View ${s}`)))})}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.