@robthepcguy/rag-vault 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +76 -43
  2. package/dist/hyde/index.d.ts +47 -0
  3. package/dist/hyde/index.d.ts.map +1 -0
  4. package/dist/hyde/index.js +203 -0
  5. package/dist/hyde/index.js.map +1 -0
  6. package/dist/reranker/index.d.ts +76 -0
  7. package/dist/reranker/index.d.ts.map +1 -0
  8. package/dist/reranker/index.js +199 -0
  9. package/dist/reranker/index.js.map +1 -0
  10. package/dist/server/index.d.ts +25 -0
  11. package/dist/server/index.d.ts.map +1 -1
  12. package/dist/server/index.js +103 -14
  13. package/dist/server/index.js.map +1 -1
  14. package/dist/server/schemas.d.ts +21 -100
  15. package/dist/server/schemas.d.ts.map +1 -1
  16. package/dist/server/schemas.js +3 -3
  17. package/dist/server/schemas.js.map +1 -1
  18. package/dist/utils/config-parsers.d.ts +14 -0
  19. package/dist/utils/config-parsers.d.ts.map +1 -1
  20. package/dist/utils/config-parsers.js +26 -0
  21. package/dist/utils/config-parsers.js.map +1 -1
  22. package/dist/utils/config.d.ts +23 -0
  23. package/dist/utils/config.d.ts.map +1 -1
  24. package/dist/utils/config.js +39 -1
  25. package/dist/utils/config.js.map +1 -1
  26. package/dist/utils/file-utils.d.ts.map +1 -1
  27. package/dist/utils/file-utils.js +17 -1
  28. package/dist/utils/file-utils.js.map +1 -1
  29. package/dist/vectordb/index.d.ts +33 -7
  30. package/dist/vectordb/index.d.ts.map +1 -1
  31. package/dist/vectordb/index.js +161 -47
  32. package/dist/vectordb/index.js.map +1 -1
  33. package/package.json +8 -7
  34. package/skills/rag-vault/SKILL.md +3 -3
  35. package/skills/rag-vault/references/html-ingestion.md +1 -1
  36. package/web-ui/dist/assets/{CollectionsPage-CjLs8_5j.js → CollectionsPage-wbfgYFTw.js} +1 -1
  37. package/web-ui/dist/assets/{FilesPage-Bw9x9aMr.js → FilesPage-D6TlldaR.js} +1 -1
  38. package/web-ui/dist/assets/{ReaderPage-JPNiOF-x.js → ReaderPage-Sgy0vMZ6.js} +1 -1
  39. package/web-ui/dist/assets/{ReaderSettingsContext-BLFJnEne.js → ReaderSettingsContext-DsvLXuaf.js} +1 -1
  40. package/web-ui/dist/assets/{SearchPage-D3_Vtbdw.js → SearchPage-mPKXZEyq.js} +1 -1
  41. package/web-ui/dist/assets/{SettingsPage-BAxB2264.js → SettingsPage-DXeWwfvd.js} +1 -1
  42. package/web-ui/dist/assets/{StatusPage-CzJZW8Gs.js → StatusPage-AirpfsGF.js} +1 -1
  43. package/web-ui/dist/assets/{UploadPage-DW8OujeJ.js → UploadPage-Cob25kDa.js} +1 -1
  44. package/web-ui/dist/assets/index-BZMzEssr.js +6 -0
  45. package/web-ui/dist/assets/motion-DdHBXDWx.js +9 -0
  46. package/web-ui/dist/assets/query-DbAD_nLW.js +1 -0
  47. package/web-ui/dist/assets/{vendor-DSXQOR6A.js → vendor-DNJ-hWNb.js} +1 -1
  48. package/web-ui/dist/index.html +3 -3
  49. package/web-ui/dist/assets/index-ANt8Xo4z.js +0 -6
  50. package/web-ui/dist/assets/motion-Brxs0UET.js +0 -9
  51. package/web-ui/dist/assets/query-DPt-uCb6.js +0 -1
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ReaderPage-JPNiOF-x.js","assets/query-DPt-uCb6.js","assets/ReaderSettingsContext-BLFJnEne.js","assets/vendor-DSXQOR6A.js","assets/motion-Brxs0UET.js","assets/SearchPage-D3_Vtbdw.js","assets/UploadPage-DW8OujeJ.js","assets/FilesPage-Bw9x9aMr.js","assets/CollectionsPage-CjLs8_5j.js","assets/StatusPage-CzJZW8Gs.js","assets/format-DOJ3IkRX.js","assets/SettingsPage-BAxB2264.js"])))=>i.map(i=>d[i]);
2
- import{a,j as i,u as q,b as H,c as _,Q as Ye,d as Ze}from"./query-DPt-uCb6.js";import{r as et,u as tt,R as nt,a as J,N as st,b as ot,B as rt}from"./vendor-DSXQOR6A.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const c of r.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&e(c)}).observe(document,{childList:!0,subtree:!0});function s(t){const r={};return t.integrity&&(r.integrity=t.integrity),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?r.credentials="include":t.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function e(t){if(t.ep)return;t.ep=!0;const r=s(t);fetch(t.href,r)}})();var ee={},ce;function at(){if(ce)return ee;ce=1;var n=et();return ee.createRoot=n.createRoot,ee.hydrateRoot=n.hydrateRoot,ee}var it=at();class ct extends a.Component{constructor(o){super(o),this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,s){console.error("ErrorBoundary caught an error:",o,s)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:i.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"var(--ws-surface-1)"},children:i.jsxs("div",{className:"max-w-md w-full rounded-lg shadow-lg p-6 text-center",style:{background:"var(--ws-surface-raised)"},children:[i.jsx("div",{className:"text-red-500 mb-4",children:i.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),i.jsx("h1",{className:"text-xl font-semibold mb-2",style:{color:"var(--ws-text)"},children:"Something went wrong"}),i.jsx("p",{className:"mb-4",style:{color:"var(--ws-text-secondary)"},children:"An unexpected error occurred. Please try again."}),this.state.error&&i.jsx("pre",{className:"text-left text-sm p-3 rounded mb-4 overflow-auto max-h-32",style:{background:"var(--ws-surface-1)",color:"var(--ws-text-secondary)"},children:this.state.error.message}),i.jsxs("div",{className:"flex gap-3 justify-center",children:[i.jsx("button",{type:"button",onClick:this.handleRetry,className:"px-4 py-2 text-white rounded-lg transition-colors",style:{background:"var(--ws-accent)"},children:"Try Again"}),i.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"px-4 py-2 rounded-lg transition-colors",style:{background:"var(--ws-surface-2)",color:"var(--ws-text-secondary)"},children:"Reload Page"})]})]})}):this.props.children}}const le={docId:null,chunkIndex:null,chunkRef:null,source:null},Ne=a.createContext(null);function lt({children:n}){const[o,s]=a.useState(le),e=a.useCallback(r=>{s({docId:r.docId,chunkIndex:r.chunkIndex??null,chunkRef:r.chunkRef??null,source:r.source})},[]),t=a.useCallback(()=>{s(le)},[]);return i.jsx(Ne.Provider,{value:{selection:o,select:e,clearSelection:t},children:n})}function V(){const n=a.useContext(Ne);if(!n)throw new Error("useSelection must be used within a SelectionProvider");return n}const de=100;function dt(){const[n,o]=a.useState([]),[s,e]=a.useState(-1),t=a.useRef(s);t.current=s;const r=a.useRef(n);r.current=n;const c=a.useMemo(()=>s>=0&&s<n.length?n[s]??null:null,[n,s]),l=s>0,h=s<n.length-1,g=a.useCallback((y,u)=>{o(v=>{const w=t.current,k=w>=0&&w<v.length?v[w]:null;if(k&&k.docId===y&&k.chunkIndex===u)return v;const x={docId:y,chunkIndex:u??null,timestamp:Date.now()},d=[...v.slice(0,w+1),x];if(d.length>de){const p=d.slice(d.length-de);return e(p.length-1),p}return e(d.length-1),d})},[]),f=a.useCallback(()=>{const y=t.current;if(y<=0)return null;const u=y-1;return e(u),r.current[u]??null},[]),m=a.useCallback(()=>{const y=t.current,u=r.current;if(y>=u.length-1)return null;const v=y+1;return e(v),u[v]??null},[]);return{push:g,goBack:f,goForward:m,canGoBack:l,canGoForward:h,current:c,history:n,currentIndex:s}}function F(n,o){const[s,e]=a.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):o}catch{return o}}),t=a.useCallback(r=>{e(c=>{const l=r instanceof Function?r(c):r;try{window.localStorage.setItem(n,JSON.stringify(l))}catch(h){console.warn(`Failed to persist "${n}" to localStorage:`,h)}return l})},[n]);return a.useEffect(()=>{const r=c=>{if(c.key===n&&c.newValue!==null)try{e(JSON.parse(c.newValue))}catch{}};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[n]),[s,t]}function ue(n){const{storageKey:o,defaultWidth:s,min:e,max:t}=n,[r,c]=F(`ws-panel-${o}`,{width:s,collapsed:!1}),l=a.useCallback(f=>{const m=Math.max(e,Math.min(t,f));c(y=>({...y,width:m}))},[e,t,c]),h=a.useCallback(()=>{c(f=>({...f,collapsed:!f.collapsed}))},[c]),g=a.useCallback(f=>{c(m=>({...m,collapsed:f}))},[c]);return{width:r.width,collapsed:r.collapsed,setWidth:l,toggleCollapsed:h,setCollapsed:g}}function ut(n){const o=a.useRef(n);o.current=n,a.useEffect(()=>{function s(e){if(e.metaKey||e.ctrlKey)switch(e.key){case"[":e.preventDefault(),o.current.onToggleLeftRail?.();break;case"]":e.preventDefault(),o.current.onToggleRightRail?.();break;case"ArrowLeft":e.preventDefault(),o.current.onNavigateBack?.();break;case"ArrowRight":e.preventDefault(),o.current.onNavigateForward?.();break}}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[])}const Re="/api/v1",ht=3e4,ft=3e5;async function B(n,o,s=ht){const e=new AbortController,t=setTimeout(()=>e.abort(),s);try{const r=await fetch(`${Re}${n}`,{headers:{"Content-Type":"application/json",...o?.headers},...o,signal:e.signal}),c=await r.json();if(!r.ok)throw new Error(c.error||"Request failed");return c}catch(r){throw r instanceof Error&&r.name==="AbortError"?new Error("Request timed out"):r}finally{clearTimeout(t)}}async function Ns(n,o){return(await B("/search",{method:"POST",body:JSON.stringify({query:n,limit:o})})).results}async function Rs(n){const o=new AbortController,s=setTimeout(()=>o.abort(),ft);try{const e=new FormData;e.append("file",n);const t=await fetch(`${Re}/files/upload`,{method:"POST",body:e,signal:o.signal}),r=await t.json();if(!t.ok)throw new Error(r.error||"Upload failed");return r}catch(e){throw e instanceof Error&&e.name==="AbortError"?new Error("Upload timed out"):e}finally{clearTimeout(s)}}async function Ps(n,o,s){return B("/data",{method:"POST",body:JSON.stringify({content:n,metadata:{source:o,format:s}})})}async function Pe(){return(await B("/files")).files}async function gt(n){await B("/files",{method:"DELETE",body:JSON.stringify(n)})}async function Ms(){return B("/status")}async function Me(n){const o=encodeURIComponent(n);return(await B(`/documents/chunks?filePath=${o}`)).chunks}async function mt(n,o,s){const e=new URLSearchParams({filePath:n,chunkIndex:String(o)});return(await B(`/chunks/related?${e.toString()}`)).related.map(r=>({...r,connectionReason:r.explanation?pt(r.explanation):De(r.score,r.filePath===n)}))}function pt(n){switch(n.reasonLabel){case"same_doc":return"Same document";case"very_similar":return"Very similar";case"related_topic":return"Related topic";case"loosely_related":return"Loosely related";default:return"Related"}}async function Ds(n,o){const s=await B("/chunks/batch-related",{method:"POST",body:JSON.stringify({chunks:n,limit:o})}),e={};for(const[t,r]of Object.entries(s.results)){const[c]=t.split(":");e[t]=r.map(l=>({...l,connectionReason:De(l.score,l.filePath===c)}))}return e}function De(n,o){return o?"Same document":n<.3?"Very similar":n<.5?"Related topic":"Loosely related"}async function he(n,o,s){await B("/feedback",{method:"POST",body:JSON.stringify({type:n,source:o,target:s})})}const bt={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-8 w-8"};function xt({size:n="md",className:o="",style:s}){return i.jsxs("svg",{className:`animate-spin ${bt[n]} text-current ${o}`,style:s,fill:"none",viewBox:"0 0 24 24",role:"status","aria-label":"Loading",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}const yt={success:{container:"ws-toast--success",icon:"ws-toast-icon--success"},error:{container:"ws-toast--error",icon:"ws-toast-icon--error"},info:{container:"ws-toast--info",icon:"ws-toast-icon--info"}};function wt({toast:n,onDismiss:o}){const s=yt[n.type],[e,t]=a.useState(!1),r=a.useRef(o);r.current=o,a.useEffect(()=>{const l=setTimeout(()=>{t(!0),setTimeout(()=>r.current(n.id),200)},5e3);return()=>clearTimeout(l)},[n.id]);const c=()=>{t(!0),setTimeout(()=>o(n.id),200)};return i.jsxs("div",{className:`ws-toast ${s.container} ${e?"ws-toast--exiting":""}`,role:"alert","aria-live":"polite",children:[i.jsxs("div",{className:`ws-toast-icon ${s.icon}`,children:[n.type==="success"&&i.jsx(kt,{}),n.type==="error"&&i.jsx(vt,{}),n.type==="info"&&i.jsx(St,{})]}),i.jsxs("div",{className:"ws-toast-content",children:[i.jsx("p",{className:"ws-toast-title",children:n.title}),n.message&&i.jsx("p",{className:"ws-toast-message",children:n.message})]}),i.jsx("button",{type:"button",onClick:c,className:"ws-toast-close","aria-label":"Dismiss",children:i.jsx(Ct,{})})]})}function kt(){return i.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function vt(){return i.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function St(){return i.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Ct(){return i.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function It({toasts:n,onDismiss:o}){return i.jsx("div",{className:"ws-toast-container",children:n.map(s=>i.jsx(wt,{toast:s,onDismiss:o},s.id))})}const Oe=a.createContext(null);function jt({children:n}){const[o,s]=a.useState([]),e=a.useCallback(r=>{const c=`${Date.now()}-${Math.random().toString(36).slice(2,9)}`;s(l=>[...l,{...r,id:c}])},[]),t=a.useCallback(r=>{s(c=>c.filter(l=>l.id!==r))},[]);return i.jsxs(Oe.Provider,{value:{addToast:e,removeToast:t},children:[n,i.jsx(It,{toasts:o,onDismiss:t})]})}function K(){const n=a.useContext(Oe);if(!n)throw new Error("useToast must be used within a ToastProvider");return n}function Et(){const n=q(),{addToast:o}=K(),{data:s=[],isLoading:e,error:t}=H({queryKey:["files"],queryFn:Pe}),r=_({mutationFn:gt,onSuccess:()=>{n.invalidateQueries({queryKey:["files"]}),o({type:"success",title:"File deleted",message:"The file has been removed from the knowledge base."})},onError:c=>{o({type:"error",title:"Failed to delete file",message:c.message})}});return{files:s,isLoading:e,error:t,deleteFile:r.mutate,isDeleting:r.isPending}}function fe(n,o){if(!o)return!0;const s=n.toLowerCase(),e=o.toLowerCase();return s.includes(e)}function Tt(){const[n,o]=a.useState(!1),[s,e]=a.useState(""),[t,r]=a.useState(0),{files:c}=Et(),{select:l}=V(),h=tt(),g=a.useCallback(()=>{o(!0),e(""),r(0)},[]),f=a.useCallback(()=>{o(!1)},[]),m=a.useCallback(()=>{o(w=>(w||(e(""),r(0)),!w))},[]),y=a.useMemo(()=>{const w=c.map(b=>{const d=b.filePath.split("/").pop()||b.filePath;return{id:`doc:${b.filePath}`,label:d,description:b.filePath,icon:"D",category:"document",onSelect:()=>{l({docId:b.filePath,source:"command-palette"}),h(`/reader?doc=${encodeURIComponent(b.filePath)}`)}}}),k=[{id:"nav:search",label:"Search",description:"Go to search page",icon:"S",category:"navigation",onSelect:()=>h("/")},{id:"nav:upload",label:"Upload",description:"Go to upload page",icon:"U",category:"navigation",onSelect:()=>h("/upload")},{id:"nav:files",label:"Files",description:"Go to files page",icon:"F",category:"navigation",onSelect:()=>h("/files")},{id:"nav:collections",label:"Collections",description:"Go to collections page",icon:"C",category:"navigation",onSelect:()=>h("/collections")},{id:"nav:status",label:"Status",description:"Go to status page",icon:"T",category:"navigation",onSelect:()=>h("/status")},{id:"nav:settings",label:"Settings",description:"Go to settings page",icon:"G",category:"navigation",onSelect:()=>h("/settings")}],x=[{id:"action:toggle-left-rail",label:"Toggle left rail",description:"Show or hide the left sidebar",icon:"L",category:"action",onSelect:()=>{window.dispatchEvent(new CustomEvent("ws:toggle-left-rail"))}},{id:"action:toggle-right-rail",label:"Toggle right rail",description:"Show or hide the right sidebar",icon:"R",category:"action",onSelect:()=>{window.dispatchEvent(new CustomEvent("ws:toggle-right-rail"))}}];return[...w,...k,...x]},[c,l,h]),u=a.useMemo(()=>s?y.filter(w=>fe(w.label,s)||w.description&&fe(w.description,s)):y,[y,s]);a.useEffect(()=>{r(w=>u.length===0?0:Math.min(w,u.length-1))},[u.length]);const v=a.useCallback(()=>{const w=u[t];w&&(w.onSelect(),f())},[u,t,f]);return a.useEffect(()=>{function w(k){(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),m())}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[m]),{isOpen:n,open:g,close:f,toggle:m,query:s,setQuery:e,results:u,selectedIndex:t,setSelectedIndex:r,executeSelected:v}}function At(n){switch(n){case"document":return"Documents";case"navigation":return"Navigation";case"action":return"Actions"}}function Nt(){const{isOpen:n,close:o,query:s,setQuery:e,results:t,selectedIndex:r,setSelectedIndex:c,executeSelected:l}=Tt(),h=a.useRef(null),g=a.useRef(null);a.useEffect(()=>{if(n){const u=requestAnimationFrame(()=>{h.current?.focus()});return()=>cancelAnimationFrame(u)}},[n]),a.useEffect(()=>{if(!n||!g.current)return;const u=g.current.querySelector('[data-selected="true"]');u&&u.scrollIntoView({block:"nearest"})},[r,n]);function f(u){switch(u.key){case"ArrowDown":u.preventDefault(),c(Math.min(r+1,t.length-1));break;case"ArrowUp":u.preventDefault(),c(Math.max(r-1,0));break;case"Enter":u.preventDefault(),l();break;case"Escape":u.preventDefault(),o();break}}if(!n)return null;const m=[],y=new Set;for(let u=0;u<t.length;u++){const v=t[u];y.has(v.category)||(y.add(v.category),m.push({category:v.category,items:[]})),m.find(k=>k.category===v.category)?.items.push({action:v,globalIndex:u})}return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"ws-command-palette-backdrop",onClick:o,onKeyDown:u=>{u.key==="Escape"&&o()}}),i.jsxs("div",{className:"ws-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command palette",onKeyDown:f,children:[i.jsx("input",{ref:h,className:"ws-command-palette-input ws-input",type:"text",placeholder:"Search documents, pages, actions...",value:s,onChange:u=>e(u.target.value),"aria-label":"Command palette search","aria-controls":"command-palette-results","aria-activedescendant":t[r]?`command-palette-item-${t[r].id}`:void 0,role:"combobox","aria-expanded":"true","aria-autocomplete":"list"}),i.jsxs("div",{ref:g,id:"command-palette-results",className:"ws-command-palette-results",role:"listbox","aria-label":"Command palette results",children:[t.length===0&&i.jsx("div",{className:"ws-command-palette-empty",children:"No results found"}),m.map(u=>i.jsxs("div",{className:"ws-command-palette-group",children:[i.jsx("div",{className:"ws-command-palette-category",children:At(u.category)}),u.items.map(({action:v,globalIndex:w})=>i.jsxs("button",{id:`command-palette-item-${v.id}`,className:`ws-command-palette-item ${w===r?"ws-command-palette-item--selected":""}`,role:"option","aria-selected":w===r,"data-selected":w===r,onClick:()=>{c(w),v.onSelect(),o()},onMouseEnter:()=>c(w),type:"button",children:[i.jsx("span",{className:"ws-command-palette-item-icon",children:v.icon}),i.jsxs("span",{className:"ws-command-palette-item-content",children:[i.jsx("span",{className:"ws-command-palette-item-label",children:v.label}),v.description&&i.jsx("span",{className:"ws-command-palette-item-description",children:v.description})]})]},v.id))]},u.category))]}),i.jsxs("div",{className:"ws-command-palette-footer",children:[i.jsxs("span",{className:"ws-command-palette-hint",children:[i.jsx("kbd",{children:"↑↓"})," navigate"]}),i.jsxs("span",{className:"ws-command-palette-hint",children:[i.jsx("kbd",{children:"Enter"})," select"]}),i.jsxs("span",{className:"ws-command-palette-hint",children:[i.jsx("kbd",{children:"Esc"})," close"]})]})]})]})}const Rt="modulepreload",Pt=function(n){return"/"+n},ge={},G=function(o,s,e){let t=Promise.resolve();if(s&&s.length>0){let h=function(g){return Promise.all(g.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");t=h(s.map(g=>{if(g=Pt(g),g in ge)return;ge[g]=!0;const f=g.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${m}`))return;const y=document.createElement("link");if(y.rel=f?"stylesheet":Rt,f||(y.as="script"),y.crossOrigin="",y.href=g,l&&y.setAttribute("nonce",l),document.head.appendChild(y),f)return new Promise((u,v)=>{y.addEventListener("load",u),y.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${g}`)))})}))}function r(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return t.then(c=>{for(const l of c||[])l.status==="rejected"&&r(l.reason);return o().catch(r)})},me=8;function pe(){const n=crypto.randomUUID();return{tabs:[{tabId:n,kind:"search",title:"Search",scrollTop:0,lastActiveAt:Date.now(),pinned:!0}],activeTabId:n}}function be(n,o){const s=n.filter(t=>!t.pinned&&t.tabId!==o);if(s.length===0)return n;let e=s[0];for(const t of s)t.lastActiveAt<e.lastActiveAt&&(e=t);return n.filter(t=>t.tabId!==e.tabId)}const Le=a.createContext(null);function Mt({dbId:n,children:o}){const s=`rag-vault-tabs-v1-${n}`,[e,t]=F(s,pe()),r=a.useCallback((u,v,w)=>{t(k=>{const x=k.tabs.find(p=>p.kind==="doc"&&p.docId===u);if(x)return{...k,activeTabId:x.tabId,tabs:k.tabs.map(p=>p.tabId===x.tabId?{...p,lastActiveAt:Date.now()}:p)};const b={tabId:crypto.randomUUID(),kind:"doc",docId:u,chunkRef:w,title:v,scrollTop:0,lastActiveAt:Date.now(),pinned:!1};let d=[...k.tabs,b];return d.length>me&&(d=be(d,b.tabId)),{tabs:d,activeTabId:b.tabId}})},[t]),c=a.useCallback((u,v)=>{t(w=>{const k=w.tabs.find(d=>d.kind===u);if(k)return{...w,activeTabId:k.tabId,tabs:w.tabs.map(d=>d.tabId===k.tabId?{...d,lastActiveAt:Date.now()}:d)};const x={tabId:crypto.randomUUID(),kind:u,title:v,scrollTop:0,lastActiveAt:Date.now(),pinned:!1};let b=[...w.tabs,x];return b.length>me&&(b=be(b,x.tabId)),{tabs:b,activeTabId:x.tabId}})},[t]),l=a.useCallback(u=>{t(v=>{const w=v.tabs.findIndex(b=>b.tabId===u);if(w===-1)return v;const k=v.tabs.filter(b=>b.tabId!==u);if(k.length===0)return pe();let x=v.activeTabId;if(v.activeTabId===u){const b=Math.min(w,k.length-1);x=k[b].tabId}return{tabs:k,activeTabId:x}})},[t]),h=a.useCallback(u=>{t(v=>({...v,activeTabId:u,tabs:v.tabs.map(w=>w.tabId===u?{...w,lastActiveAt:Date.now()}:w)}))},[t]),g=a.useCallback((u,v)=>{t(w=>({...w,tabs:w.tabs.map(k=>k.tabId===u?{...k,scrollTop:v}:k)}))},[t]),f=a.useCallback((u,v)=>{t(w=>({...w,tabs:w.tabs.map(k=>k.tabId===u?{...k,pinned:v}:k)}))},[t]),m=a.useMemo(()=>e.tabs.find(u=>u.tabId===e.activeTabId),[e.tabs,e.activeTabId]),y=a.useMemo(()=>({tabs:e.tabs,activeTabId:e.activeTabId,activeTab:m,openDoc:r,openPage:c,closeTab:l,setActiveTab:h,updateTabScroll:g,pinTab:f}),[e.tabs,e.activeTabId,m,r,c,l,h,g,f]);return i.jsx(Le.Provider,{value:y,children:o})}function Dt(){const n=a.useContext(Le);if(!n)throw new Error("useTabs must be used within a TabsProvider");return n}const Ot=a.forwardRef(({variant:n="default",size:o="md",className:s="",children:e,...t},r)=>i.jsx("button",{ref:r,"data-variant":n,"data-size":o,className:`ws-button ${s}`,...t,children:e}));Ot.displayName="WsButton";const Lt=a.forwardRef(({error:n,className:o="",...s},e)=>i.jsx("input",{ref:e,"data-error":n||void 0,className:`ws-input ${o}`,...s}));Lt.displayName="WsInput";const Ft=a.forwardRef(({error:n,className:o="",children:s,...e},t)=>i.jsx("select",{ref:t,"data-error":n||void 0,className:`ws-select ${o}`,...e,children:s}));Ft.displayName="WsSelect";function Fe({tabs:n,activeId:o,onSelect:s,onClose:e,variant:t="underline",className:r=""}){const c=a.useRef(null),l=h=>{const g=c.current?.querySelectorAll('[role="tab"]');if(!g?.length)return;const f=Array.from(g).indexOf(document.activeElement);let m=f;if(h.key==="ArrowRight"?(h.preventDefault(),m=f+1>=g.length?0:f+1):h.key==="ArrowLeft"&&(h.preventDefault(),m=f-1<0?g.length-1:f-1),m!==f){const y=g[m];if(y){y.focus();const u=y.dataset.tabId;u&&s(u)}}};return i.jsx("div",{ref:c,role:"tablist",className:`ws-tabs ws-tabs--${t} ${r}`,onKeyDown:l,children:n.map(h=>{const g=h.id===o;return i.jsxs("button",{role:"tab",type:"button","aria-selected":g,tabIndex:g?0:-1,"data-tab-id":h.id,className:"ws-tab",onClick:()=>s(h.id),children:[h.icon&&i.jsx("span",{className:"ws-tab-icon",children:h.icon}),h.label,h.badge!==void 0&&i.jsx("span",{className:"ws-tab-badge",children:h.badge}),h.closeable&&!h.pinned&&i.jsx("span",{role:"button",tabIndex:-1,className:"ws-tab-close",onClick:f=>{f.stopPropagation(),e?.(h.id)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.stopPropagation(),e?.(h.id))},children:"x"})]},h.id)})})}function oe({variant:n="default",count:o,children:s,className:e="",...t}){return i.jsxs("span",{"data-variant":n,className:`ws-badge ${e}`,...t,children:[s,o!==void 0&&i.jsx("span",{className:"ws-badge-count",children:o})]})}function $t({content:n,side:o="top",delay:s=300,children:e}){const[t,r]=a.useState(!1),c=a.useRef(null),l=a.useCallback(()=>{c.current=setTimeout(()=>r(!0),s)},[s]),h=a.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null),r(!1)},[]);return a.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),i.jsxs("span",{className:"ws-tooltip-anchor",onMouseEnter:l,onMouseLeave:h,onFocus:l,onBlur:h,children:[e,t&&i.jsx("span",{className:`ws-tooltip ws-tooltip--${o}`,role:"tooltip",children:n})]})}function _t(){const{tabs:n,activeTabId:o,setActiveTab:s,closeTab:e}=Dt(),t=n.map(r=>({id:r.tabId,label:r.title,closeable:!r.pinned,pinned:r.pinned}));return i.jsx("div",{className:"ws-tab-bar",children:i.jsx(Fe,{tabs:t,activeId:o,onSelect:s,onClose:e,variant:"pill"})})}const Kt=a.lazy(()=>G(()=>import("./ReaderPage-JPNiOF-x.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.ReaderPage}))),zt=a.lazy(()=>G(()=>import("./SearchPage-D3_Vtbdw.js"),__vite__mapDeps([5,1,3])).then(n=>({default:n.SearchPage}))),Wt=a.lazy(()=>G(()=>import("./UploadPage-DW8OujeJ.js"),__vite__mapDeps([6,1,3])).then(n=>({default:n.UploadPage}))),qt=a.lazy(()=>G(()=>import("./FilesPage-Bw9x9aMr.js"),__vite__mapDeps([7,1,3])).then(n=>({default:n.FilesPage}))),Bt=a.lazy(()=>G(()=>import("./CollectionsPage-CjLs8_5j.js"),__vite__mapDeps([8,1,4,3])).then(n=>({default:n.CollectionsPage}))),Ut=a.lazy(()=>G(()=>import("./StatusPage-CzJZW8Gs.js"),__vite__mapDeps([9,1,10,3])).then(n=>({default:n.StatusPage}))),Ht=a.lazy(()=>G(()=>import("./SettingsPage-BAxB2264.js"),__vite__mapDeps([11,1,10,4,3])).then(n=>({default:n.SettingsPage}))),Vt=a.lazy(()=>G(()=>import("./ReaderSettingsContext-BLFJnEne.js"),__vite__mapDeps([2,1,3])).then(n=>({default:n.ReaderSettingsProvider})));function xe(){return i.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:i.jsx(xt,{})})}function Gt(){return i.jsxs("div",{className:"ws-center-pane",children:[i.jsx(_t,{}),i.jsx("div",{className:"ws-center-content",children:i.jsx(a.Suspense,{fallback:i.jsx(xe,{}),children:i.jsxs(nt,{children:[i.jsx(J,{path:"/",element:i.jsx(zt,{})}),i.jsx(J,{path:"/read",element:i.jsx(a.Suspense,{fallback:i.jsx(xe,{}),children:i.jsx(Vt,{children:i.jsx(Kt,{})})})}),i.jsx(J,{path:"/upload",element:i.jsx(Wt,{})}),i.jsx(J,{path:"/files",element:i.jsx(qt,{})}),i.jsx(J,{path:"/collections",element:i.jsx(Bt,{})}),i.jsx(J,{path:"/status",element:i.jsx(Ut,{})}),i.jsx(J,{path:"/settings",element:i.jsx(Ht,{})})]})})})]})}const Jt={theme:"system",lastBrowsedPath:"/",showHiddenFiles:!1,statsRefreshInterval:0},$e=a.createContext(null);function Qt(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Xt({children:n}){const[o,s]=F("rag-vault-preferences",Jt),e=o.theme==="system"?Qt():o.theme;a.useEffect(()=>{const h=document.documentElement;e==="dark"?h.classList.add("dark"):h.classList.remove("dark")},[e]),a.useEffect(()=>{if(o.theme!=="system")return;const h=window.matchMedia("(prefers-color-scheme: dark)"),g=()=>{const f=document.documentElement;h.matches?f.classList.add("dark"):f.classList.remove("dark")};return h.addEventListener("change",g),()=>h.removeEventListener("change",g)},[o.theme]);const t=a.useCallback(h=>{s(g=>({...g,theme:h}))},[s]),r=a.useCallback(h=>{s(g=>({...g,lastBrowsedPath:h}))},[s]),c=a.useCallback(h=>{s(g=>({...g,showHiddenFiles:h}))},[s]),l=a.useCallback(h=>{s(g=>({...g,statsRefreshInterval:h}))},[s]);return i.jsx($e.Provider,{value:{preferences:o,setTheme:t,setLastBrowsedPath:r,setShowHiddenFiles:c,setStatsRefreshInterval:l,effectiveTheme:e},children:n})}function Os(){const n=a.useContext($e);if(!n)throw new Error("usePreferences must be used within a PreferencesProvider");return n}const Yt="/api/v1/config",Zt=3e4;async function O(n,o,s=Zt){const e=new AbortController,t=setTimeout(()=>e.abort(),s);try{const r=await fetch(`${Yt}${n}`,{headers:{"Content-Type":"application/json",...o?.headers},...o,signal:e.signal}),c=await r.json();if(!r.ok)throw new Error(c.error||"Request failed");return c}catch(r){throw r instanceof Error&&r.name==="AbortError"?new Error("Request timed out"):r}finally{clearTimeout(t)}}async function en(){return O("/current")}async function tn(){return(await O("/databases")).databases}async function nn(n){return(await O("/databases/switch",{method:"POST",body:JSON.stringify({dbPath:n})})).config}async function sn(n,o,s){return(await O("/databases/create",{method:"POST",body:JSON.stringify({dbPath:n,name:o,modelName:s})})).config}async function on(n){return(await O("/databases/scan",{method:"POST",body:JSON.stringify({scanPath:n})})).databases}async function rn(n,o=!1){return(await O("/databases",{method:"DELETE",body:JSON.stringify({dbPath:n,deleteFiles:o})})).databases}async function an(){return O("/allowed-roots")}async function cn(n){return O("/allowed-roots",{method:"POST",body:JSON.stringify({path:n})})}async function ln(n){return O("/allowed-roots",{method:"DELETE",body:JSON.stringify({path:n})})}async function dn(n,o=!1){const s=new URLSearchParams({path:n});return o&&s.set("showHidden","true"),O(`/browse?${s.toString()}`)}async function un(){return(await O("/models")).models}async function hn(){return O("/export")}async function fn(n){return O("/import",{method:"POST",body:JSON.stringify({config:n})})}async function gn(){return(await O("/hybrid-weight")).weight}async function mn(n){await O("/hybrid-weight",{method:"PUT",body:JSON.stringify({weight:n})})}function pn(n=0){const{data:o,isLoading:s,error:e,refetch:t,isFetching:r}=H({queryKey:["config","current"],queryFn:en,refetchInterval:n>0?n:!1});return{config:o,isLoading:s,error:e,refetch:t,isFetching:r}}function Ls(){const{data:n,isLoading:o,error:s,refetch:e}=H({queryKey:["config","databases"],queryFn:tn});return{databases:n||[],isLoading:o,error:s,refetch:e}}function Fs(){const n=q(),{addToast:o}=K(),s=_({mutationFn:e=>nn(e),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:["config"]}),n.invalidateQueries({queryKey:["files"]}),n.invalidateQueries({queryKey:["status"]}),o({type:"success",title:"Database switched",message:`Now using ${t.split("/").pop()||t}`})},onError:e=>{o({type:"error",title:"Failed to switch database",message:e.message})}});return{switchDatabase:s.mutate,switchDatabaseAsync:s.mutateAsync,isLoading:s.isPending,error:s.error,isSuccess:s.isSuccess}}function $s(){const n=q(),{addToast:o}=K(),s=_({mutationFn:({dbPath:e,name:t,modelName:r})=>sn(e,t,r),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:["config"]}),n.invalidateQueries({queryKey:["files"]}),n.invalidateQueries({queryKey:["status"]}),o({type:"success",title:"Database created",message:`Created and switched to ${t.dbPath.split("/").pop()||t.dbPath}`})},onError:e=>{o({type:"error",title:"Failed to create database",message:e.message})}});return{createDatabase:s.mutate,createDatabaseAsync:s.mutateAsync,isLoading:s.isPending,error:s.error,isSuccess:s.isSuccess}}function _s(){const{addToast:n}=K(),o=_({mutationFn:s=>on(s),onError:s=>{n({type:"error",title:"Scan failed",message:s.message})}});return{scan:o.mutate,scanAsync:o.mutateAsync,isLoading:o.isPending,error:o.error,data:o.data,reset:o.reset}}function Ks(){const n=q(),{addToast:o}=K(),s=_({mutationFn:({dbPath:e,deleteFiles:t})=>rn(e,t),onSuccess:(e,t)=>{n.invalidateQueries({queryKey:["config","databases"]});const r=t.dbPath.split("/").pop()||t.dbPath;o({type:"success",title:"Database removed",message:t.deleteFiles?`Deleted ${r} and its files`:`Removed ${r} from list`})},onError:e=>{o({type:"error",title:"Failed to delete database",message:e.message})}});return{deleteDatabase:s.mutate,deleteDatabaseAsync:s.mutateAsync,isLoading:s.isPending,error:s.error}}function zs(){const{data:n,isLoading:o,error:s,refetch:e}=H({queryKey:["config","allowed-roots"],queryFn:an});return{data:n,isLoading:o,error:s,refetch:e}}function Ws(){const n=q(),{addToast:o}=K(),s=_({mutationFn:e=>cn(e),onSuccess:()=>{n.invalidateQueries({queryKey:["config","allowed-roots"]}),o({type:"success",title:"Root added",message:"Allowed root added successfully"})},onError:e=>{o({type:"error",title:"Failed to add root",message:e.message})}});return{addRoot:s.mutate,addRootAsync:s.mutateAsync,isLoading:s.isPending,error:s.error}}function qs(){const n=q(),{addToast:o}=K(),s=_({mutationFn:e=>ln(e),onSuccess:()=>{n.invalidateQueries({queryKey:["config","allowed-roots"]}),o({type:"success",title:"Root removed",message:"Allowed root removed successfully"})},onError:e=>{o({type:"error",title:"Failed to remove root",message:e.message})}});return{removeRoot:s.mutate,removeRootAsync:s.mutateAsync,isLoading:s.isPending,error:s.error}}function Bs(){const{addToast:n}=K(),o=_({mutationFn:({path:t,showHidden:r=!1})=>dn(t,r),onError:t=>{n({type:"error",title:"Failed to browse directory",message:t.message})}}),s=a.useCallback((t,r=!1)=>o.mutate({path:t,showHidden:r}),[o.mutate]),e=a.useCallback((t,r=!1)=>o.mutateAsync({path:t,showHidden:r}),[o.mutateAsync]);return{browse:s,browseAsync:e,isLoading:o.isPending,error:o.error,data:o.data,reset:o.reset}}function Us(){const{data:n,isLoading:o,error:s}=H({queryKey:["config","models"],queryFn:un});return{models:n||[],isLoading:o,error:s}}function Hs(){const{addToast:n}=K(),o=_({mutationFn:hn,onSuccess:()=>{n({type:"success",title:"Configuration exported",message:"Download should begin automatically"})},onError:s=>{n({type:"error",title:"Failed to export configuration",message:s.message})}});return{exportConfig:o.mutate,exportConfigAsync:o.mutateAsync,isLoading:o.isPending,error:o.error,data:o.data}}function Vs(){const n=q(),{addToast:o}=K(),s=_({mutationFn:e=>fn(e),onSuccess:()=>{n.invalidateQueries({queryKey:["config","allowed-roots"]}),o({type:"success",title:"Configuration imported",message:"Settings have been restored"})},onError:e=>{o({type:"error",title:"Failed to import configuration",message:e.message})}});return{importConfig:s.mutate,importConfigAsync:s.mutateAsync,isLoading:s.isPending,error:s.error}}function Gs(){const{data:n,isLoading:o,error:s,refetch:e}=H({queryKey:["config","hybrid-weight"],queryFn:gn});return{weight:n??.6,isLoading:o,error:s,refetch:e}}function Js(){const n=q(),{addToast:o}=K(),s=_({mutationFn:e=>mn(e),onSuccess:()=>{n.invalidateQueries({queryKey:["config","hybrid-weight"]}),o({type:"success",title:"Search weight updated",message:"Hybrid search weight has been adjusted"})},onError:e=>{o({type:"error",title:"Failed to update search weight",message:e.message})}});return{setWeight:s.mutate,setWeightAsync:s.mutateAsync,isLoading:s.isPending,error:s.error}}function bn(n){const{data:o=[],isLoading:s,error:e,refetch:t}=H({queryKey:["documentChunks",n],queryFn:()=>n?Me(n):Promise.resolve([]),enabled:!!n,staleTime:3e5});return{chunks:o,isLoading:s,error:e,refetch:t}}function _e(n,o,s){const{data:e=[],isLoading:t,error:r,refetch:c}=H({queryKey:["relatedChunks",n,o,s],queryFn:()=>n&&o!==null?mt(n,o):Promise.resolve([]),enabled:!!n&&o!==null,staleTime:3e5});return{related:e,isLoading:t,error:r,refetch:c}}function te(){return crypto.randomUUID()}async function ye(n){const s=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Q(n,o){return n.fingerprint&&o.fingerprint?n.fingerprint===o.fingerprint:n.filePath===o.filePath&&n.chunkIndex===o.chunkIndex}const xn={version:1,vaultId:"",pins:[],trails:[],bookmarks:[]},Ke=a.createContext(null);function yn({children:n,vaultId:o="default"}){const s=`rag-vault-links-v1-${o}`,[e,t]=F(s,{...xn,vaultId:o}),r=a.useCallback((R,T,C,I,N)=>{const E={id:te(),createdAt:new Date().toISOString(),sourceKey:R,sourceText:C.slice(0,200),sourceFingerprint:"",targetKey:T,targetText:I.slice(0,200),targetFingerprint:"",label:N?.label,autoGenerated:N?.autoGenerated??!1,originalScore:N?.originalScore};return Promise.all([ye(C),ye(I)]).then(([P,D])=>{t($=>({...$,pins:$.pins.map(Y=>Y.id===E.id?{...Y,sourceFingerprint:P,targetFingerprint:D}:Y)})),he("pin",{...R,fingerprint:P},{...T,fingerprint:D}).catch(()=>{})}).catch(P=>{console.warn("Failed to hash text for pin fingerprints, removing incomplete pin:",P),t(D=>({...D,pins:D.pins.filter($=>$.id!==E.id)}))}),t(P=>({...P,pins:[...P.pins,E]})),E},[t]),c=a.useCallback(R=>{const T=e.pins.find(C=>C.id===R);t(C=>({...C,pins:C.pins.filter(I=>I.id!==R)})),T&&he("unpin",{...T.sourceKey,fingerprint:T.sourceFingerprint},{...T.targetKey,fingerprint:T.targetFingerprint}).catch(()=>{})},[t,e.pins]),l=a.useCallback((R,T)=>{t(C=>({...C,pins:C.pins.map(I=>I.id===R?{...I,label:T}:I)}))},[t]),h=a.useCallback(R=>e.pins.filter(T=>Q(T.sourceKey,R)),[e.pins]),g=a.useCallback(R=>e.pins.filter(T=>Q(T.targetKey,R)),[e.pins]),f=a.useCallback((R,T)=>e.pins.some(C=>Q(C.sourceKey,R)&&Q(C.targetKey,T)),[e.pins]),[m,y]=F(`rag-vault-current-trail-${o}`,null),u=a.useCallback(()=>{const R={id:te(),name:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),steps:[]};y(R)},[y]),v=a.useCallback((R,T)=>{y(C=>{if(!C)return{id:te(),name:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),steps:[{chunkKey:R,visitedAt:new Date().toISOString(),connectionReason:T}]};const I=C.steps[C.steps.length-1];return I&&Q(I.chunkKey,R)?C:{...C,updatedAt:new Date().toISOString(),steps:[...C.steps,{chunkKey:R,visitedAt:new Date().toISOString(),connectionReason:T}]}})},[y]),w=a.useCallback(R=>{if(!m)throw new Error("No current trail to save");const T={...m,name:R,updatedAt:new Date().toISOString()};return t(C=>({...C,trails:[...C.trails,T]})),y(null),T},[m,t,y]),k=a.useCallback(R=>{const T=e.trails.find(C=>C.id===R);return T&&y({...T}),T||null},[e.trails,y]),x=a.useCallback(R=>{t(T=>({...T,trails:T.trails.filter(C=>C.id!==R)}))},[t]),b=a.useCallback(()=>{y(null)},[y]),d=a.useCallback((R,T)=>{const C={id:te(),chunkKey:R,note:T,createdAt:new Date().toISOString()};return t(I=>({...I,bookmarks:[...I.bookmarks||[],C]})),C},[t]),p=a.useCallback(R=>{t(T=>({...T,bookmarks:(T.bookmarks||[]).filter(C=>C.id!==R)}))},[t]),S=a.useCallback((R,T)=>{t(C=>({...C,bookmarks:(C.bookmarks||[]).map(I=>I.id===R?{...I,note:T}:I)}))},[t]),j=a.useCallback(R=>(e.bookmarks||[]).filter(T=>T.chunkKey.filePath===R).sort((T,C)=>T.chunkKey.chunkIndex-C.chunkKey.chunkIndex),[e.bookmarks]),A=a.useCallback(R=>(e.bookmarks||[]).some(T=>Q(T.chunkKey,R)),[e.bookmarks]),M=a.useCallback(R=>{const T=(e.bookmarks||[]).find(C=>Q(C.chunkKey,R));return T?(p(T.id),!1):(d(R),!0)},[e.bookmarks,d,p]),z=a.useCallback(()=>JSON.stringify(e,null,2),[e]),W=a.useCallback(R=>{const T=[];let C=0;try{const I=JSON.parse(R);if(I.version!==1)return T.push(`Unsupported version: ${I.version}`),{imported:C,errors:T};if(Array.isArray(I.pins))for(const N of I.pins)N.id&&N.sourceKey&&N.targetKey&&!e.pins.some(E=>E.id===N.id)&&(t(E=>({...E,pins:[...E.pins,N]})),C++);if(Array.isArray(I.trails))for(const N of I.trails)N.id&&N.name&&Array.isArray(N.steps)&&!e.trails.some(E=>E.id===N.id)&&(t(E=>({...E,trails:[...E.trails,N]})),C++);if(Array.isArray(I.bookmarks))for(const N of I.bookmarks)N.id&&N.chunkKey&&!(e.bookmarks||[]).some(E=>E.id===N.id)&&(t(E=>({...E,bookmarks:[...E.bookmarks||[],N]})),C++)}catch(I){T.push(`Invalid JSON: ${I.message}`)}return{imported:C,errors:T}},[e,t]),U=a.useMemo(()=>({pins:e.pins,createPin:r,deletePin:c,updatePinLabel:l,getPinsFromChunk:h,getBacklinks:g,isPinned:f,trails:e.trails,currentTrail:m,startNewTrail:u,addToTrail:v,saveTrail:w,loadTrail:k,deleteTrail:x,clearCurrentTrail:b,bookmarks:e.bookmarks||[],createBookmark:d,deleteBookmark:p,updateBookmarkNote:S,getBookmarksForDocument:j,isBookmarked:A,toggleBookmark:M,exportLinks:z,importLinks:W}),[e.pins,e.trails,e.bookmarks,r,c,l,h,g,f,m,u,v,w,k,x,b,d,p,S,j,A,M,z,W]);return i.jsx(Ke.Provider,{value:U,children:n})}function ze(){const n=a.useContext(Ke);if(!n)throw new Error("useLinks must be used within a LinksProvider");return n}function wn(){const n=ze(),o=a.useMemo(()=>{const e=new Set;for(const t of n.pins)e.add(`${t.targetKey.filePath}:${t.targetKey.chunkIndex}`);return e},[n.pins]),s=a.useCallback((e,t,r,c,l)=>{const h=n.pins.find(g=>g.sourceKey.filePath===e.filePath&&g.sourceKey.chunkIndex===e.chunkIndex&&g.targetKey.filePath===t.filePath&&g.targetKey.chunkIndex===t.chunkIndex);h?n.deletePin(h.id):n.createPin(e,t,r,c,{autoGenerated:!1,originalScore:l})},[n]);return{pins:n.pins,pinnedChunkKeys:o,createPin:n.createPin,deletePin:n.deletePin,updatePinLabel:n.updatePinLabel,isPinned:n.isPinned,togglePin:s,getPinsFromChunk:n.getPinsFromChunk}}function kn(n,o){const s=ze(),e=a.useMemo(()=>!n||o===null?[]:s.getBacklinks({filePath:n,chunkIndex:o}),[s,n,o]);return{backlinks:e,hasBacklinks:e.length>0,backlinkCount:e.length}}const vn=/^(#{1,6})\s+(.+)$/m,Sn=/^([A-Z][A-Z0-9\s]{4,79})$/m,Cn=/^(\d+(?:\.\d+)*)\s+(.+)$/m;function In(n){const o=n.match(vn);if(o){const[,t,r]=o;if(t&&r)return{text:r.trim(),level:t.length,type:"markdown"}}const s=n.match(Cn);if(s){const[,t,r]=s;if(t&&r){const c=t.split(".").length;return{text:`${t} ${r.trim()}`,level:c,type:"numbered"}}}const e=n.trim();if(e.length>=5&&e.length<=80){const t=e.match(Sn);if(t?.[1]){const r=t[1].match(/[A-Z]/g);if(r&&r.length>=3)return{text:t[1].trim(),level:1,type:"allcaps"}}}return null}function jn(n,o){const s=[],e=n.split(`
3
- `);for(const t of e){const r=In(t);r&&s.push({...r,chunkIndex:o,text:r.text.length>80?`${r.text.slice(0,77)}...`:r.text})}return s}function En(n){const o=Math.max(1,Math.floor(n.length/10));return n.filter((s,e)=>e%o===0).map((s,e)=>({id:`fallback-${s.chunkIndex}`,text:`Section ${e+1}`,level:1,chunkIndex:s.chunkIndex,type:"fallback"}))}function Tn({chunks:n,minHeadings:o=2}){return a.useMemo(()=>{if(n.length===0)return{entries:[],hasHeadings:!1,isFallback:!1};const e=[];for(const c of n){const l=jn(c.text,c.chunkIndex);e.push(...l)}const t=[];for(const c of e){const l=t[t.length-1];(!l||l.text!==c.text||l.chunkIndex!==c.chunkIndex)&&t.push(c)}return t.length<o?{entries:En(n),hasHeadings:!1,isFallback:!0}:{entries:t.map((c,l)=>({...c,id:`toc-${l}-${c.chunkIndex}`})),hasHeadings:!0,isFallback:!1}},[n,o])}function we(){return crypto.randomUUID()}function An(n,o){return n.filePath===o.filePath&&n.chunkIndex===o.chunkIndex}const Nn={version:1,vaultId:"",highlights:[],annotations:[]},We=a.createContext(null);function Rn({children:n,vaultId:o="default"}){const s=`rag-vault-annotations-v1-${o}`,[e,t]=F(s,{...Nn,vaultId:o}),r=a.useCallback((k,x,b,d,p,S)=>{const j={id:we(),chunkKey:k,range:x,text:b,contextBefore:d.slice(-30),contextAfter:p.slice(0,30),color:S,createdAt:new Date().toISOString()};return t(A=>({...A,highlights:[...A.highlights,j]})),j},[t]),c=a.useCallback(k=>{t(x=>({...x,highlights:x.highlights.filter(b=>b.id!==k),annotations:x.annotations.filter(b=>b.highlightId!==k)}))},[t]),l=a.useCallback((k,x)=>{t(b=>({...b,highlights:b.highlights.map(d=>d.id===k?{...d,color:x}:d)}))},[t]),h=a.useCallback(k=>e.highlights.filter(x=>An(x.chunkKey,k)).sort((x,b)=>x.range.startOffset-b.range.startOffset),[e.highlights]),g=a.useCallback((k,x)=>{const b={id:we(),highlightId:k,note:x,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return t(d=>({...d,annotations:[...d.annotations,b]})),b},[t]),f=a.useCallback((k,x)=>{t(b=>({...b,annotations:b.annotations.map(d=>d.id===k?{...d,note:x,updatedAt:new Date().toISOString()}:d)}))},[t]),m=a.useCallback(k=>{t(x=>({...x,annotations:x.annotations.filter(b=>b.id!==k)}))},[t]),y=a.useCallback(k=>e.annotations.find(x=>x.highlightId===k),[e.annotations]),u=a.useCallback(()=>JSON.stringify(e,null,2),[e]),v=a.useCallback(k=>{const x=[];let b=0;try{const d=JSON.parse(k);if(d.version!==1)return x.push(`Unsupported version: ${d.version}`),{imported:b,errors:x};if(Array.isArray(d.highlights))for(const p of d.highlights)p.id&&p.chunkKey&&p.range&&!e.highlights.some(S=>S.id===p.id)&&(t(S=>({...S,highlights:[...S.highlights,p]})),b++);if(Array.isArray(d.annotations))for(const p of d.annotations)p.id&&p.highlightId&&!e.annotations.some(S=>S.id===p.id)&&(t(S=>({...S,annotations:[...S.annotations,p]})),b++)}catch(d){x.push(`Invalid JSON: ${d.message}`)}return{imported:b,errors:x}},[e,t]),w=a.useMemo(()=>({highlights:e.highlights,createHighlight:r,deleteHighlight:c,updateHighlightColor:l,getHighlightsForChunk:h,annotations:e.annotations,createAnnotation:g,updateAnnotation:f,deleteAnnotation:m,getAnnotationForHighlight:y,exportAnnotations:u,importAnnotations:v}),[e.highlights,e.annotations,r,c,l,h,g,f,m,y,u,v]);return i.jsx(We.Provider,{value:w,children:n})}function Qs(){const n=a.useContext(We);if(!n)throw new Error("useAnnotations must be used within an AnnotationsProvider");return n}function Pn({filePath:n,activeChunkIndex:o,relatedChunks:s,pins:e,maxNodes:t=150}){const r=a.useMemo(()=>{const l=new Map,h=[],g=o!==null?`${n}:${o}`:null;g&&l.set(g,{id:g,filePath:n,chunkIndex:o,text:"(current chunk)"});for(const u of s){const v=`${u.filePath}:${u.chunkIndex}`;l.has(v)||l.set(v,{id:v,filePath:u.filePath,chunkIndex:u.chunkIndex,text:u.text.slice(0,100)+(u.text.length>100?"...":"")}),g&&g!==v&&h.push({source:g,target:v,score:u.score,type:"semantic",label:u.connectionReason})}for(const u of e){const v=`${u.sourceKey.filePath}:${u.sourceKey.chunkIndex}`,w=`${u.targetKey.filePath}:${u.targetKey.chunkIndex}`;l.has(v)||l.set(v,{id:v,filePath:u.sourceKey.filePath,chunkIndex:u.sourceKey.chunkIndex,text:u.sourceText.slice(0,100)+(u.sourceText.length>100?"...":"")}),l.has(w)||l.set(w,{id:w,filePath:u.targetKey.filePath,chunkIndex:u.targetKey.chunkIndex,text:u.targetText.slice(0,100)+(u.targetText.length>100?"...":"")});const k=h.findIndex(x=>x.source===v&&x.target===w);if(k>=0){const x=h[k];x&&(h[k]={...x,type:"pinned",label:u.label||x.label})}else h.push({source:v,target:w,score:u.originalScore??.5,type:"pinned",label:u.label})}let f=Array.from(l.values());if(f.length>t){const u=new Set(e.flatMap(x=>[`${x.sourceKey.filePath}:${x.sourceKey.chunkIndex}`,`${x.targetKey.filePath}:${x.targetKey.chunkIndex}`])),v=f.filter(x=>x.id===g||u.has(x.id)),w=Math.max(0,t-v.length),k=f.filter(x=>x.id!==g&&!u.has(x.id)).slice(0,w);f=v.concat(k)}const m=new Set(f.map(u=>u.id)),y=h.filter(u=>m.has(u.source)&&m.has(u.target));return{nodes:f,edges:y}},[n,o,s,e,t]),c=o!==null?`${n}:${o}`:null;return{graphData:r,currentNodeId:c}}function ke(){return crypto.randomUUID()}const Mn={version:1,vaultId:"",updatedAt:new Date().toISOString(),tags:[],taggedItems:[]},Xs={red:{bg:"bg-red-100 dark:bg-red-900/40",text:"text-red-700 dark:text-red-300",border:"border-red-200 dark:border-red-800"},orange:{bg:"bg-orange-100 dark:bg-orange-900/40",text:"text-orange-700 dark:text-orange-300",border:"border-orange-200 dark:border-orange-800"},yellow:{bg:"bg-yellow-100 dark:bg-yellow-900/40",text:"text-yellow-700 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"},green:{bg:"bg-green-100 dark:bg-green-900/40",text:"text-green-700 dark:text-green-300",border:"border-green-200 dark:border-green-800"},blue:{bg:"bg-blue-100 dark:bg-blue-900/40",text:"text-blue-700 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"},purple:{bg:"bg-purple-100 dark:bg-purple-900/40",text:"text-purple-700 dark:text-purple-300",border:"border-purple-200 dark:border-purple-800"},pink:{bg:"bg-pink-100 dark:bg-pink-900/40",text:"text-pink-700 dark:text-pink-300",border:"border-pink-200 dark:border-pink-800"},gray:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-700 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}},qe=a.createContext(null);function Dn({children:n,vaultId:o="default"}){const s=`rag-vault-tags-v1-${o}`,[e,t]=F(s,{...Mn,vaultId:o}),r=a.useCallback((d,p)=>{const S={id:ke(),name:d.trim(),color:p,usageCount:0,lastUsedAt:new Date().toISOString(),createdAt:new Date().toISOString()};return t(j=>({...j,updatedAt:new Date().toISOString(),tags:[...j.tags,S]})),S},[t]),c=a.useCallback((d,p)=>{t(S=>({...S,updatedAt:new Date().toISOString(),tags:S.tags.map(j=>{if(j.id!==d)return j;const A={...p};return A.name!==void 0&&(A.name=A.name.trim()),{...j,...A}})}))},[t]),l=a.useCallback(d=>{t(p=>({...p,updatedAt:new Date().toISOString(),tags:p.tags.filter(S=>S.id!==d),taggedItems:p.taggedItems.filter(S=>S.tagId!==d)}))},[t]),h=a.useCallback(d=>e.tags.find(p=>p.id===d),[e.tags]),g=a.useCallback((d,p,S)=>{const j={id:ke(),tagId:d,targetType:p,targetKey:S,createdAt:new Date().toISOString()};return t(A=>({...A,updatedAt:new Date().toISOString(),taggedItems:[...A.taggedItems,j],tags:A.tags.map(M=>M.id===d?{...M,usageCount:M.usageCount+1,lastUsedAt:new Date().toISOString()}:M)})),j},[t]),f=a.useCallback(d=>{t(p=>({...p,updatedAt:new Date().toISOString(),taggedItems:p.taggedItems.filter(S=>S.id!==d)}))},[t]),m=a.useCallback((d,p,S)=>{t(j=>({...j,updatedAt:new Date().toISOString(),taggedItems:j.taggedItems.filter(A=>!(A.tagId===d&&A.targetType===p&&A.targetKey===S))}))},[t]),y=a.useCallback((d,p)=>{const S=e.taggedItems.filter(j=>j.targetType===d&&j.targetKey===p).map(j=>j.tagId);return e.tags.filter(j=>S.includes(j.id))},[e.tags,e.taggedItems]),u=a.useCallback(d=>e.taggedItems.filter(p=>p.tagId===d),[e.taggedItems]),v=a.useCallback((d,p,S)=>e.taggedItems.some(j=>j.tagId===d&&j.targetType===p&&j.targetKey===S),[e.taggedItems]),w=a.useCallback((d=10)=>[...e.tags].sort((p,S)=>S.usageCount!==p.usageCount?S.usageCount-p.usageCount:new Date(S.lastUsedAt).getTime()-new Date(p.lastUsedAt).getTime()).slice(0,d),[e.tags]),k=a.useCallback(()=>JSON.stringify(e,null,2),[e]),x=a.useCallback(d=>{const p=[];let S=0;try{const j=JSON.parse(d);if(j.version!==1)return p.push(`Unsupported version: ${j.version}`),{imported:S,errors:p};if(Array.isArray(j.tags))for(const A of j.tags)A.id&&A.name&&!e.tags.some(M=>M.id===A.id)&&(t(M=>({...M,updatedAt:new Date().toISOString(),tags:[...M.tags,A]})),S++);if(Array.isArray(j.taggedItems))for(const A of j.taggedItems)A.id&&A.tagId&&A.targetKey&&!e.taggedItems.some(M=>M.id===A.id)&&(t(M=>({...M,updatedAt:new Date().toISOString(),taggedItems:[...M.taggedItems,A]})),S++)}catch(j){p.push(`Invalid JSON: ${j.message}`)}return{imported:S,errors:p}},[e,t]),b=a.useMemo(()=>({tags:e.tags,createTag:r,updateTag:c,deleteTag:l,getTag:h,taggedItems:e.taggedItems,addTag:g,removeTag:f,removeTagFromTarget:m,getTagsForTarget:y,getTargetsForTag:u,isTagged:v,getTagSuggestions:w,exportTags:k,importTags:x}),[e.tags,e.taggedItems,r,c,l,h,g,f,m,y,u,v,w,k,x]);return i.jsx(qe.Provider,{value:b,children:n})}function Ys(){const n=a.useContext(qe);if(!n)throw new Error("useTags must be used within a TagsProvider");return n}function On(){return crypto.randomUUID()}const Ln={version:1,vaultId:"",updatedAt:new Date().toISOString(),collections:[]},Zs=["red","orange","yellow","green","blue","purple","pink","gray"],eo={red:{bg:"bg-red-100 dark:bg-red-900/40",text:"text-red-700 dark:text-red-300",border:"border-red-200 dark:border-red-800"},orange:{bg:"bg-orange-100 dark:bg-orange-900/40",text:"text-orange-700 dark:text-orange-300",border:"border-orange-200 dark:border-orange-800"},yellow:{bg:"bg-yellow-100 dark:bg-yellow-900/40",text:"text-yellow-700 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"},green:{bg:"bg-green-100 dark:bg-green-900/40",text:"text-green-700 dark:text-green-300",border:"border-green-200 dark:border-green-800"},blue:{bg:"bg-blue-100 dark:bg-blue-900/40",text:"text-blue-700 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"},purple:{bg:"bg-purple-100 dark:bg-purple-900/40",text:"text-purple-700 dark:text-purple-300",border:"border-purple-200 dark:border-purple-800"},pink:{bg:"bg-pink-100 dark:bg-pink-900/40",text:"text-pink-700 dark:text-pink-300",border:"border-pink-200 dark:border-pink-800"},gray:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-700 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}},Be=a.createContext(null);function Fn({children:n,vaultId:o="default"}){const s=`rag-vault-collections-v1-${o}`,[e,t]=F(s,{...Ln,vaultId:o}),r=a.useCallback((x,b,d)=>{const p={id:On(),name:x.trim(),description:d?.trim(),color:b,documents:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return t(S=>({...S,updatedAt:new Date().toISOString(),collections:[...S.collections,p]})),p},[t]),c=a.useCallback((x,b)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(p=>p.id===x?{...p,...b,updatedAt:new Date().toISOString()}:p)}))},[t]),l=a.useCallback(x=>{t(b=>({...b,updatedAt:new Date().toISOString(),collections:b.collections.filter(d=>d.id!==x)}))},[t]),h=a.useCallback(x=>e.collections.find(b=>b.id===x),[e.collections]),g=a.useCallback((x,b)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(p=>p.id!==x||p.documents.includes(b)?p:{...p,documents:[...p.documents,b],updatedAt:new Date().toISOString()})}))},[t]),f=a.useCallback((x,b)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(p=>p.id!==x?p:{...p,documents:p.documents.filter(S=>S!==b),updatedAt:new Date().toISOString()})}))},[t]),m=a.useCallback(x=>e.collections.filter(b=>b.documents.includes(x)),[e.collections]),y=a.useCallback(x=>e.collections.find(d=>d.id===x)?.documents??[],[e.collections]),u=a.useCallback((x,b)=>e.collections.find(p=>p.id===x)?.documents.includes(b)??!1,[e.collections]),v=a.useCallback(()=>JSON.stringify(e,null,2),[e]),w=a.useCallback(x=>{const b=[];let d=0;try{const p=JSON.parse(x);if(p.version!==1)return b.push(`Unsupported version: ${p.version}`),{imported:d,errors:b};if(Array.isArray(p.collections))for(const S of p.collections)S.id&&S.name&&!e.collections.some(j=>j.id===S.id)&&(t(j=>({...j,updatedAt:new Date().toISOString(),collections:[...j.collections,S]})),d++)}catch(p){b.push(`Invalid JSON: ${p.message}`)}return{imported:d,errors:b}},[e,t]),k=a.useMemo(()=>({collections:e.collections,createCollection:r,updateCollection:c,deleteCollection:l,getCollection:h,addDocumentToCollection:g,removeDocumentFromCollection:f,getCollectionsForDocument:m,getDocumentsInCollection:y,isDocumentInCollection:u,exportCollections:v,importCollections:w}),[e.collections,r,c,l,h,g,f,m,y,u,v,w]);return i.jsx(Be.Provider,{value:k,children:n})}function to(){const n=a.useContext(Be);if(!n)throw new Error("useCollections must be used within a CollectionsProvider");return n}const re={pan:{x:0,y:0},zoom:1},ve={version:1,vaultId:"",nodePositions:{},viewState:re},$n=a.createContext(null);function _n({children:n,vaultId:o="default"}){const s=`rag-vault-graph-state-v1-${o}`,[e,t]=F(s,{...ve,vaultId:o}),r=a.useCallback(k=>e.nodePositions[k],[e.nodePositions]),c=a.useCallback((k,x)=>{t(b=>({...b,nodePositions:{...b.nodePositions,[k]:{x:x.x,y:x.y,fixedAt:new Date().toISOString()}}}))},[t]),l=a.useCallback(()=>{t(k=>({...k,nodePositions:{}}))},[t]),h=a.useCallback(k=>{t(x=>({...x,viewState:{...x.viewState,pan:k}}))},[t]),g=a.useCallback(k=>{t(x=>({...x,viewState:{...x.viewState,zoom:k}}))},[t]),f=a.useCallback(k=>{t(x=>({...x,viewState:k}))},[t]),m=a.useCallback(()=>{t(k=>({...k,viewState:re}))},[t]),y=a.useCallback(()=>{t(k=>({...ve,vaultId:k.vaultId}))},[t]),u=a.useCallback(()=>JSON.stringify(e,null,2),[e]),v=a.useCallback(k=>{try{const x=JSON.parse(k);return x.version!==1?{success:!1,error:`Unsupported version: ${x.version}`}:(t(b=>({...b,nodePositions:x.nodePositions||{},viewState:x.viewState||re})),{success:!0})}catch(x){return{success:!1,error:`Invalid JSON: ${x.message}`}}},[t]),w=a.useMemo(()=>({nodePositions:e.nodePositions,getNodePosition:r,setNodePosition:c,clearNodePositions:l,viewState:e.viewState,setPan:h,setZoom:g,setViewState:f,resetViewState:m,resetAll:y,exportGraphState:u,importGraphState:v}),[e.nodePositions,e.viewState,r,c,l,h,g,f,m,y,u,v]);return i.jsx($n.Provider,{value:w,children:n})}const Kn={version:1,vaultId:"",documents:{}},zn=a.createContext(null);function Wn({children:n,vaultId:o="default"}){const s=`rag-vault-reading-stats-v1-${o}`,[e,t]=F(s,{...Kn,vaultId:o}),r=a.useCallback(b=>e.documents[b],[e.documents]),c=a.useCallback((b,d)=>{const p=e.documents[b];if(p)return p.chunkStats[d]},[e.documents]),l=a.useCallback((b,d)=>{const p=e.documents[b];return p?p.totalChunks!==d?{...p,totalChunks:d}:p:{filePath:b,totalChunks:d,chunksRead:0,totalTimeMs:0,sessions:[],chunkStats:{}}},[e.documents]),h=a.useCallback((b,d,p)=>{t(S=>{const j=l(b,p),A=j.chunkStats[d]||{totalTimeMs:0,readCount:0,lastReadAt:""},M=A.readCount===0,z={...A,readCount:A.readCount+1,lastReadAt:new Date().toISOString()},W={...j,chunksRead:M?j.chunksRead+1:j.chunksRead,chunkStats:{...j.chunkStats,[d]:z}};return{...S,documents:{...S.documents,[b]:W}}})},[t,l]),g=a.useCallback((b,d,p)=>{p<=0||t(S=>{const j=S.documents[b];if(!j)return S;const A=j.chunkStats[d]||{totalTimeMs:0,readCount:0,lastReadAt:new Date().toISOString()},M={...A,totalTimeMs:A.totalTimeMs+p},z=!j.chunkStats[d],W={...j,totalTimeMs:j.totalTimeMs+p,chunksRead:z?j.chunksRead+1:j.chunksRead,chunkStats:{...j.chunkStats,[d]:M}};return{...S,documents:{...S.documents,[b]:W}}})},[t]),f=a.useCallback(b=>{t(d=>{const p=d.documents[b];if(!p)return d;const S=p.sessions[p.sessions.length-1];if(S&&!S.endedAt)return d;const j={startedAt:new Date().toISOString(),endedAt:"",durationMs:0},A=[...p.sessions,j].slice(-10);return{...d,documents:{...d.documents,[b]:{...p,sessions:A}}}})},[t]),m=a.useCallback(b=>{t(d=>{const p=d.documents[b];if(!p)return d;const S=[...p.sessions],j=S[S.length-1];if(!j||j.endedAt)return d;const A=new Date().toISOString(),M=new Date(A).getTime()-new Date(j.startedAt).getTime();return S[S.length-1]={...j,endedAt:A,durationMs:M},{...d,documents:{...d.documents,[b]:{...p,sessions:S}}}})},[t]),y=a.useCallback(b=>{const d=e.documents[b];return!d||d.totalChunks===0?0:Math.round(d.chunksRead/d.totalChunks*100)},[e.documents]),u=a.useCallback(b=>e.documents[b]?.totalTimeMs??0,[e.documents]),v=a.useCallback(b=>{const d=e.documents[b];return!d||d.chunksRead===0?0:Math.round(d.totalTimeMs/d.chunksRead)},[e.documents]),w=a.useCallback(()=>JSON.stringify(e,null,2),[e]),k=a.useCallback(b=>{t(b?d=>{const{[b]:p,...S}=d.documents;return{...d,documents:S}}:d=>({...d,documents:{}}))},[t]),x=a.useMemo(()=>({getDocumentStats:r,getChunkStats:c,recordChunkView:h,recordTimeSpent:g,startSession:f,endSession:m,getCompletionPercent:y,getTotalReadingTime:u,getAverageTimePerChunk:v,exportStats:w,clearStats:k}),[r,c,h,g,f,m,y,u,v,w,k]);return i.jsx(zn.Provider,{value:x,children:n})}const qn=[{to:"/",label:"Search",shortcut:""},{to:"/upload",label:"Upload",shortcut:""},{to:"/files",label:"Files",shortcut:""},{to:"/collections",label:"Collections",shortcut:""},{to:"/status",label:"Status",shortcut:""},{to:"/settings",label:"Settings",shortcut:""}];function Bn({collapsed:n,onToggle:o,width:s}){const{config:e}=pn();return i.jsxs("aside",{className:"ws-left-rail",style:{width:n?"var(--ws-left-rail-collapsed)":s},children:[i.jsx("nav",{className:"ws-left-rail-nav",children:qn.map(t=>i.jsx($t,{content:t.label,side:"right",delay:n?100:1e3,children:i.jsxs(st,{to:t.to,className:({isActive:r})=>`ws-nav-item ${r?"ws-nav-item--active":""} ${n?"ws-nav-item--collapsed":""}`,end:t.to==="/",children:[i.jsx("span",{className:"ws-nav-icon",children:t.label.charAt(0)}),!n&&i.jsx("span",{className:"ws-nav-label",children:t.label})]})},t.to))}),i.jsx("div",{style:{flex:1}}),e&&!n&&i.jsx("div",{className:"ws-left-rail-footer",children:i.jsxs("div",{className:"ws-db-indicator",title:e.dbPath,children:[i.jsx("span",{className:"ws-db-dot"}),i.jsx("span",{className:"ws-db-name",children:e.name}),i.jsxs("span",{className:"ws-db-count",children:[e.documentCount," docs"]})]})}),i.jsx("button",{type:"button",className:"ws-rail-toggle",onClick:o,"aria-label":"Toggle left rail",children:n?"›":"‹"})]})}function Se({onResize:n,direction:o}){const s=a.useRef(0),e=a.useRef(null);a.useEffect(()=>()=>{e.current?.()},[]);const t=a.useCallback(r=>{r.preventDefault(),s.current=r.clientX;const c=h=>{const g=h.clientX-s.current;s.current=h.clientX,n(o==="right"?-g:g)},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l),document.body.style.cursor="",document.body.style.userSelect="",e.current=null};document.addEventListener("mousemove",c),document.addEventListener("mouseup",l),document.body.style.cursor="col-resize",document.body.style.userSelect="none",e.current=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l),document.body.style.cursor="",document.body.style.userSelect=""}},[n,o]);return i.jsx("div",{className:"ws-resize-handle",onMouseDown:t,role:"separator","aria-orientation":"vertical","aria-valuenow":50,tabIndex:0})}const Ce=12;function ae(n={}){const{delay:o=300,hideDelay:s=150}=n,[e,t]=a.useState({isVisible:!1,position:{x:0,y:0},targetRef:null}),r=a.useRef(null),c=a.useRef(null),l=a.useCallback(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),h=a.useCallback(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null)},[]),g=a.useCallback(()=>{l(),h()},[l,h]),f=a.useCallback((w,k)=>{h();const x=k.left+k.width/2,b=k.bottom+8,d=Math.max(Ce,Math.min(x,window.innerWidth-Ce)),S=window.innerHeight-k.bottom<200?k.top-8:b;l(),r.current=setTimeout(()=>{t({isVisible:!0,position:{x:d,y:S},targetRef:w})},o)},[o,h,l]),m=a.useCallback(()=>{l(),c.current=setTimeout(()=>{t(w=>({...w,isVisible:!1,targetRef:null}))},s)},[s,l]),y=a.useCallback(()=>{h()},[h]),u=a.useCallback(()=>{c.current=setTimeout(()=>{t(w=>({...w,isVisible:!1,targetRef:null}))},s)},[s]),v=a.useCallback(()=>{g(),t({isVisible:!1,position:{x:0,y:0},targetRef:null})},[g]);return a.useEffect(()=>()=>g(),[g]),{state:e,onHoverStart:f,onHoverEnd:m,onPreviewEnter:y,onPreviewLeave:u,hide:v}}const se=150,X=12;function Un(n){if(n.length<=se)return n;const o=n.slice(0,se),s=o.lastIndexOf(" ");return s>se*.6?`${o.slice(0,s)}...`:`${o}...`}function Hn(n){return`${Math.round(n*100)}%`}function ie({docTitle:n,excerpt:o,backlinkCount:s,score:e,position:t,onNavigate:r,onOpenInNewTab:c,onPinAsLink:l,onMouseEnter:h,onMouseLeave:g}){const f=a.useRef(null),[m,y]=a.useState(t),[u,v]=a.useState(!0),w=s!==void 0&&s>0||e!==void 0,k=c!==void 0||l!==void 0;return a.useEffect(()=>{const x=f.current;if(!x)return;const b=x.getBoundingClientRect();let{x:d,y:p}=t;d=d-b.width/2,d+b.width>window.innerWidth-X&&(d=window.innerWidth-X-b.width),d<X&&(d=X),p+b.height>window.innerHeight-X&&(p=t.y-b.height-16),p<X&&(p=X),y({x:d,y:p})},[t]),a.useEffect(()=>{const x=requestAnimationFrame(()=>{v(!1)});return()=>cancelAnimationFrame(x)},[]),i.jsxs("div",{ref:f,className:`ws-hover-preview ${u?"ws-hover-preview--entering":""}`,style:{left:m.x,top:m.y},onMouseEnter:h,onMouseLeave:g,children:[i.jsx("div",{className:"ws-hover-preview-title",children:n}),o&&i.jsx("p",{className:"ws-hover-preview-excerpt",children:Un(o)}),w&&i.jsxs("div",{className:"ws-hover-preview-meta",children:[s!==void 0&&s>0&&i.jsxs("span",{className:"ws-badge","data-variant":"link-backlink",children:[s," ",s===1?"backlink":"backlinks"]}),e!==void 0&&i.jsxs("span",{className:"ws-badge","data-variant":"link-semantic",children:[Hn(e)," match"]})]}),i.jsxs("div",{className:"ws-hover-preview-actions",children:[i.jsx("button",{type:"button",className:"ws-button","data-variant":"primary","data-size":"sm",onClick:r,children:"Open"}),k&&i.jsxs("div",{className:"ws-hover-preview-secondary-actions",children:[c&&i.jsx("button",{type:"button",className:"ws-button","data-variant":"ghost","data-size":"sm",onClick:c,children:"New Tab"}),l&&i.jsx("button",{type:"button",className:"ws-button","data-variant":"ghost","data-size":"sm",onClick:l,children:"Pin as Link"})]})]})]})}function L({message:n}){return i.jsx("div",{className:"ws-rail-empty-state",children:i.jsx("p",{children:n})})}function Z(n,o,s){let e=s.initialDeps??[],t,r=!0;function c(){var l,h,g;let f;s.key&&((l=s.debug)!=null&&l.call(s))&&(f=Date.now());const m=n();if(!(m.length!==e.length||m.some((v,w)=>e[w]!==v)))return t;e=m;let u;if(s.key&&((h=s.debug)!=null&&h.call(s))&&(u=Date.now()),t=o(...m),s.key&&((g=s.debug)!=null&&g.call(s))){const v=Math.round((Date.now()-f)*100)/100,w=Math.round((Date.now()-u)*100)/100,k=w/16,x=(b,d)=>{for(b=String(b);b.length<d;)b=" "+b;return b};console.info(`%c⏱ ${x(w,5)} /${x(v,5)} ms`,`
4
- font-size: .6rem;
5
- font-weight: bold;
6
- color: hsl(${Math.max(0,Math.min(120-120*k,120))}deg 100% 31%);`,s?.key)}return s?.onChange&&!(r&&s.skipInitialOnChange)&&s.onChange(t),r=!1,t}return c.updateDeps=l=>{e=l},c}function Ie(n,o){if(n===void 0)throw new Error("Unexpected undefined");return n}const Vn=(n,o)=>Math.abs(n-o)<1.01,Gn=(n,o,s)=>{let e;return function(...t){n.clearTimeout(e),e=n.setTimeout(()=>o.apply(this,t),s)}},je=n=>{const{offsetWidth:o,offsetHeight:s}=n;return{width:o,height:s}},Jn=n=>n,Qn=n=>{const o=Math.max(n.startIndex-n.overscan,0),s=Math.min(n.endIndex+n.overscan,n.count-1),e=[];for(let t=o;t<=s;t++)e.push(t);return e},Xn=(n,o)=>{const s=n.scrollElement;if(!s)return;const e=n.targetWindow;if(!e)return;const t=c=>{const{width:l,height:h}=c;o({width:Math.round(l),height:Math.round(h)})};if(t(je(s)),!e.ResizeObserver)return()=>{};const r=new e.ResizeObserver(c=>{const l=()=>{const h=c[0];if(h?.borderBoxSize){const g=h.borderBoxSize[0];if(g){t({width:g.inlineSize,height:g.blockSize});return}}t(je(s))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return r.observe(s,{box:"border-box"}),()=>{r.unobserve(s)}},Ee={passive:!0},Te=typeof window>"u"?!0:"onscrollend"in window,Yn=(n,o)=>{const s=n.scrollElement;if(!s)return;const e=n.targetWindow;if(!e)return;let t=0;const r=n.options.useScrollendEvent&&Te?()=>{}:Gn(e,()=>{o(t,!1)},n.options.isScrollingResetDelay),c=f=>()=>{const{horizontal:m,isRtl:y}=n.options;t=m?s.scrollLeft*(y&&-1||1):s.scrollTop,r(),o(t,f)},l=c(!0),h=c(!1);s.addEventListener("scroll",l,Ee);const g=n.options.useScrollendEvent&&Te;return g&&s.addEventListener("scrollend",h,Ee),()=>{s.removeEventListener("scroll",l),g&&s.removeEventListener("scrollend",h)}},Zn=(n,o,s)=>{if(o?.borderBoxSize){const e=o.borderBoxSize[0];if(e)return Math.round(e[s.options.horizontal?"inlineSize":"blockSize"])}return n[s.options.horizontal?"offsetWidth":"offsetHeight"]},es=(n,{adjustments:o=0,behavior:s},e)=>{var t,r;const c=n+o;(r=(t=e.scrollElement)==null?void 0:t.scrollTo)==null||r.call(t,{[e.options.horizontal?"left":"top"]:c,behavior:s})};class ts{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const e=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(t=>{t.forEach(r=>{const c=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var t;(t=e())==null||t.disconnect(),s=null},observe:t=>{var r;return(r=e())==null?void 0:r.observe(t,{box:"border-box"})},unobserve:t=>{var r;return(r=e())==null?void 0:r.unobserve(t)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([e,t])=>{typeof t>"u"&&delete s[e]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Jn,rangeExtractor:Qn,onChange:()=>{},measureElement:Zn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var e,t;(t=(e=this.options).onChange)==null||t.call(e,this,s)},this.maybeNotify=Z(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(t=>{this.observer.observe(t)}),this.unsubs.push(this.options.observeElementRect(this,t=>{this.scrollRect=t,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(t,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<t?"forward":"backward":null,this.scrollOffset=t,this.isScrolling=r,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,e)=>{const t=new Map,r=new Map;for(let c=e-1;c>=0;c--){const l=s[c];if(t.has(l.lane))continue;const h=r.get(l.lane);if(h==null||l.end>h.end?r.set(l.lane,l):l.end<h.end&&t.set(l.lane,!0),t.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((c,l)=>c.end===l.end?c.index-l.index:c.end-l.end)[0]:void 0},this.getMeasurementOptions=Z(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,e,t,r,c,l)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:e,scrollMargin:t,getItemKey:r,enabled:c,lanes:l}),{key:!1}),this.getMeasurements=Z(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:e,scrollMargin:t,getItemKey:r,enabled:c,lanes:l},h)=>{if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const y of this.laneAssignments.keys())y>=s&&this.laneAssignments.delete(y);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(y=>{this.itemSizeCache.set(y.key,y.size)}));const g=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const f=this.measurementsCache.slice(0,g),m=new Array(l).fill(void 0);for(let y=0;y<g;y++){const u=f[y];u&&(m[u.lane]=y)}for(let y=g;y<s;y++){const u=r(y),v=this.laneAssignments.get(y);let w,k;if(v!==void 0&&this.options.lanes>1){w=v;const p=m[w],S=p!==void 0?f[p]:void 0;k=S?S.end+this.options.gap:e+t}else{const p=this.options.lanes===1?f[y-1]:this.getFurthestMeasurement(f,y);k=p?p.end+this.options.gap:e+t,w=p?p.lane:y%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(y,w)}const x=h.get(u),b=typeof x=="number"?x:this.options.estimateSize(y),d=k+b;f[y]={index:y,start:k,size:b,end:d,key:u,lane:w},m[w]=y}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Z(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,e,t,r)=>this.range=s.length>0&&e>0?ns({measurements:s,outerSize:e,scrollOffset:t,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Z(()=>{let s=null,e=null;const t=this.calculateRange();return t&&(s=t.startIndex,e=t.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,e]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,e]},(s,e,t,r,c)=>r===null||c===null?[]:s({startIndex:r,endIndex:c,overscan:e,count:t}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const e=this.options.indexAttribute,t=s.getAttribute(e);return t?parseInt(t,10):(console.warn(`Missing attribute name '${e}={index}' on measured element.`),-1)},this._measureElement=(s,e)=>{const t=this.indexFromElement(s),r=this.measurementsCache[t];if(!r)return;const c=r.key,l=this.elementsCache.get(c);l!==s&&(l&&this.observer.unobserve(l),this.observer.observe(s),this.elementsCache.set(c,s)),s.isConnected&&this.resizeItem(t,this.options.measureElement(s,e,this))},this.resizeItem=(s,e)=>{const t=this.measurementsCache[s];if(!t)return;const r=this.itemSizeCache.get(t.key)??t.size,c=e-r;c!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(t,c,this):t.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(t.index),this.itemSizeCache=new Map(this.itemSizeCache.set(t.key,e)),this.notify(!1))},this.measureElement=s=>{if(!s){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}this._measureElement(s,void 0)},this.getVirtualItems=Z(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,e)=>{const t=[];for(let r=0,c=s.length;r<c;r++){const l=s[r],h=e[l];t.push(h)}return t},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const e=this.getMeasurements();if(e.length!==0)return Ie(e[Ue(0,e.length-1,t=>Ie(e[t]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,e,t=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),c=this.getScrollOffset();e==="auto"&&(e=s>=c+r?"end":"start"),e==="center"?s+=(t-r)/2:e==="end"&&(s-=r);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,s),0)},this.getOffsetForIndex=(s,e="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const t=this.measurementsCache[s];if(!t)return;const r=this.getSize(),c=this.getScrollOffset();if(e==="auto")if(t.end>=c+r-this.options.scrollPaddingEnd)e="end";else if(t.start<=c+this.options.scrollPaddingStart)e="start";else return[c,e];if(e==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),e];const l=e==="end"?t.end+this.options.scrollPaddingEnd:t.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,e,t.size),e]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:e="start",behavior:t}={})=>{t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,e),{adjustments:void 0,behavior:t})},this.scrollToIndex=(s,{align:e="auto",behavior:t}={})=>{t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let r=0;const c=10,l=g=>{if(!this.targetWindow)return;const f=this.getOffsetForIndex(s,g);if(!f){console.warn("Failed to get offset for index:",s);return}const[m,y]=f;this._scrollToOffset(m,{adjustments:void 0,behavior:t}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;const u=()=>{if(this.currentScrollToIndex!==s)return;const v=this.getScrollOffset(),w=this.getOffsetForIndex(s,y);if(!w){console.warn("Failed to get offset for index:",s);return}Vn(w[0],v)||h(y)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(u):u()})},h=g=>{this.targetWindow&&this.currentScrollToIndex===s&&(r++,r<c?this.targetWindow.requestAnimationFrame(()=>l(g)):console.warn(`Failed to scroll to index ${s} after ${c} attempts.`))};l(e)},this.scrollBy=(s,{behavior:e}={})=>{e==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:e})},this.getTotalSize=()=>{var s;const e=this.getMeasurements();let t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=((s=e[e.length-1])==null?void 0:s.end)??0;else{const r=Array(this.options.lanes).fill(null);let c=e.length-1;for(;c>=0&&r.some(l=>l===null);){const l=e[c];r[l.lane]===null&&(r[l.lane]=l.end),c--}t=Math.max(...r.filter(l=>l!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:e,behavior:t})=>{this.options.scrollToFn(s,{behavior:t,adjustments:e},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(o)}}const Ue=(n,o,s,e)=>{for(;n<=o;){const t=(n+o)/2|0,r=s(t);if(r<e)n=t+1;else if(r>e)o=t-1;else return t}return n>0?n-1:0};function ns({measurements:n,outerSize:o,scrollOffset:s,lanes:e}){const t=n.length-1,r=h=>n[h].start;if(n.length<=e)return{startIndex:0,endIndex:t};let c=Ue(0,t,r,s),l=c;if(e===1)for(;l<t&&n[l].end<s+o;)l++;else if(e>1){const h=Array(e).fill(0);for(;l<t&&h.some(f=>f<s+o);){const f=n[l];h[f.lane]=f.end,l++}const g=Array(e).fill(s+o);for(;c>=0&&g.some(f=>f>=s);){const f=n[c];g[f.lane]=f.start,c--}c=Math.max(0,c-c%e),l=Math.min(t,l+(e-1-l%e))}return{startIndex:c,endIndex:l}}const Ae=typeof document<"u"?a.useLayoutEffect:a.useEffect;function ss({useFlushSync:n=!0,...o}){const s=a.useReducer(()=>({}),{})[1],e={...o,onChange:(r,c)=>{var l;n&&c?ot.flushSync(s):s(),(l=o.onChange)==null||l.call(o,r,c)}},[t]=a.useState(()=>new ts(e));return t.setOptions(e),Ae(()=>t._didMount(),[]),Ae(()=>t._willUpdate()),t}function os(n){return ss({observeElementRect:Xn,observeElementOffset:Yn,scrollToFn:es,...n})}const rs=50,as=72;function ne({items:n,renderItem:o,getKey:s}){const e=a.useRef(null),t=os({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>as,overscan:5});return n.length<=rs?i.jsx("div",{className:"ws-rail-list",children:n.map((r,c)=>i.jsx("div",{children:o(r,c)},s(r,c)))}):i.jsx("div",{ref:e,className:"ws-rail-list",style:{height:"100%",overflow:"auto"},children:i.jsx("div",{style:{height:t.getTotalSize(),width:"100%",position:"relative"},children:t.getVirtualItems().map(r=>{const c=n[r.index];return i.jsx("div",{"data-index":r.index,ref:t.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${r.start}px)`},children:o(c,r.index)},s(c,r.index))})})})}function He(){const{selection:n,select:o}=V(),{backlinks:s,backlinkCount:e}=kn(n.docId??null,n.chunkIndex??null),{state:t,onHoverStart:r,onHoverEnd:c,onPreviewEnter:l,onPreviewLeave:h,hide:g}=ae();if(!n.docId)return i.jsx(L,{message:"Select a document to see backlinks"});if(e===0)return i.jsx(L,{message:"No backlinks found for this document"});const f=t.isVisible?s.find(m=>m.id===t.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:s,getKey:m=>m.id,renderItem:m=>{const y=m.sourceKey.filePath.split("/").pop()??m.sourceKey.filePath;return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{g(),o({docId:m.sourceKey.filePath,chunkIndex:m.sourceKey.chunkIndex,source:"backlink"})},onMouseEnter:u=>r(m.id,u.currentTarget.getBoundingClientRect()),onMouseLeave:c,children:[i.jsx("span",{className:"ws-rail-item-title",children:y}),i.jsxs("span",{className:"ws-rail-item-meta",children:["Chunk #",m.sourceKey.chunkIndex]}),m.label&&i.jsx("span",{className:"ws-rail-item-label",children:m.label}),i.jsxs("p",{className:"ws-rail-item-excerpt",children:[m.sourceText.slice(0,120),"..."]})]})}}),f&&i.jsx(ie,{docTitle:f.sourceKey.filePath.split("/").pop()??f.sourceKey.filePath,excerpt:f.sourceText,backlinkCount:e,position:t.position,onNavigate:()=>{g(),o({docId:f.sourceKey.filePath,chunkIndex:f.sourceKey.chunkIndex,source:"backlink"})},onMouseEnter:l,onMouseLeave:h})]})}function is(){const{selection:n,select:o}=V(),{related:s,isLoading:e}=_e(n.docId??null,n.chunkIndex??null),{state:t,onHoverStart:r,onHoverEnd:c,onPreviewEnter:l,onPreviewLeave:h,hide:g}=ae();if(!n.docId)return i.jsx(L,{message:"Select a document to see related passages"});if(e)return i.jsx("div",{className:"ws-rail-loading",children:"Loading related..."});if(!s||s.length===0)return i.jsx(L,{message:"No related passages found"});const f=t.isVisible?s.find(m=>`${m.filePath}-${m.chunkIndex}`===t.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:s,getKey:m=>`${m.filePath}-${m.chunkIndex}`,renderItem:m=>{const y=`${m.filePath}-${m.chunkIndex}`;return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{g(),o({docId:m.filePath,chunkIndex:m.chunkIndex,source:"backlink"})},onMouseEnter:u=>r(y,u.currentTarget.getBoundingClientRect()),onMouseLeave:c,children:[i.jsx("span",{className:"ws-rail-item-title",children:m.filePath.split("/").pop()}),i.jsxs("span",{className:"ws-rail-item-meta",children:["Score: ",m.score.toFixed(3)]}),i.jsxs("p",{className:"ws-rail-item-excerpt",children:[m.text.slice(0,120),"..."]})]})}}),f&&i.jsx(ie,{docTitle:f.filePath.split("/").pop()??f.filePath,excerpt:f.text,score:f.score,position:t.position,onNavigate:()=>{g(),o({docId:f.filePath,chunkIndex:f.chunkIndex,source:"backlink"})},onMouseEnter:l,onMouseLeave:h})]})}function cs(){const{selection:n}=V(),{chunks:o}=bn(n.docId??null),{entries:s}=Tn({chunks:o??[]});return n.docId?s.length===0?i.jsx(L,{message:"No headings found in this document"}):i.jsx("nav",{className:"ws-rail-list",children:s.map(e=>i.jsx("button",{type:"button",className:"ws-rail-item",style:{paddingLeft:`calc(var(--ws-space-3) + ${(e.level-1)*12}px)`},children:i.jsx("span",{className:"ws-rail-item-title",children:e.text})},e.id))}):i.jsx(L,{message:"Select a document to see its outline"})}function ls(){const n=a.useRef(null),[o,s]=a.useState(null),[e,t]=a.useState(!1),[r,c]=a.useState(null);a.useEffect(()=>{const g=new Worker(new URL("/assets/link-indexer.worker-DGXNsXmZ.js",import.meta.url),{type:"module"});return g.onmessage=f=>{const m=f.data;m.type==="scan-complete"&&m.index?(s(m.index),t(!1),c(null)):m.type==="error"&&(c(new Error(m.message??"Worker error")),t(!1))},g.onerror=f=>{c(new Error(f.message||"Worker initialization error")),t(!1)},n.current=g,()=>{g.terminate(),n.current=null}},[]);const l=a.useCallback(g=>{n.current&&(t(!0),c(null),n.current.postMessage({type:"scan",documents:g}))},[]),h=a.useCallback(async()=>{t(!0),c(null);try{const g=await Pe(),f=await Promise.all(g.map(async m=>{const y=await Me(m.filePath);return{filePath:m.filePath,chunks:y.map(u=>({chunkIndex:u.chunkIndex,text:u.text}))}}));if(!n.current)return;n.current.postMessage({type:"scan",documents:f})}catch(g){c(g instanceof Error?g:new Error("Failed to fetch documents for scan")),t(!1)}},[]);return{index:o,isScanning:e,error:r,scan:l,rescan:h}}const Ve=a.createContext(null);function ds({children:n}){const{index:o,isScanning:s,rescan:e}=ls(),t=q();a.useEffect(()=>{e()},[e]),a.useEffect(()=>t.getQueryCache().subscribe(m=>{m.type==="updated"&&m.query.queryKey[0]==="files"&&m.action.type==="success"&&e()}),[t,e]);const r=a.useMemo(()=>{if(!o)return new Set;const f=new Set,m=new Set;if(o.outgoing)for(const y of Object.keys(o.outgoing))m.add(y);if(o.incoming)for(const y of Object.values(o.incoming))for(const u of y)m.add(u.sourceDoc);for(const y of m){const u=y.split("/"),v=u[u.length-1]??y,w=v.replace(/\.[^.]+$/,"");f.add(w.toLowerCase()),f.add(v.toLowerCase())}return f},[o]),c=a.useCallback(f=>o?o.outgoing[f]??[]:[],[o]),l=a.useCallback(f=>o?o.incoming[f]??[]:[],[o]),h=a.useCallback(f=>r.has(f.toLowerCase()),[r]),g=a.useMemo(()=>({index:o,isScanning:s,rescan:e,getOutgoingLinks:c,getIncomingLinks:l,isResolved:h}),[o,s,e,c,l,h]);return i.jsx(Ve.Provider,{value:g,children:n})}function Ge(){const n=a.useContext(Ve);if(!n)throw new Error("useLinkIndexContext must be used within a LinkIndexProvider");return n}function us(){const{selection:n,select:o}=V(),{getOutgoingLinks:s,isResolved:e,isScanning:t}=Ge(),{state:r,onHoverStart:c,onHoverEnd:l,onPreviewEnter:h,onPreviewLeave:g,hide:f}=ae(),m=a.useMemo(()=>n.docId?s(n.docId):[],[n.docId,s]);if(!n.docId)return i.jsx(L,{message:"Select a document to see outgoing links"});if(t)return i.jsx("div",{className:"ws-rail-loading",children:"Scanning links..."});if(m.length===0)return i.jsx(L,{message:"No outgoing links found"});const y=r.isVisible?m.find((u,v)=>`${u.targetTitle}-${u.chunkIndex}-${v}`===r.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:m,getKey:(u,v)=>`${u.targetTitle}-${u.chunkIndex}-${v}`,renderItem:(u,v)=>{const w=e(u.targetTitle),k=`${u.targetTitle}-${u.chunkIndex}-${v}`,x=[];return u.heading&&x.push(`# ${u.heading}`),u.blockRef&&x.push(`^ ${u.blockRef}`),x.push(`Chunk #${u.chunkIndex}`),i.jsxs("button",{type:"button",className:"ws-rail-item",disabled:!w,onClick:()=>{w&&(f(),o({docId:u.targetTitle,source:"backlink"}))},onMouseEnter:b=>{w&&c(k,b.currentTarget.getBoundingClientRect())},onMouseLeave:l,children:[i.jsx("span",{className:"ws-rail-item-title",children:u.alias??u.targetTitle}),i.jsx("span",{className:"ws-rail-item-meta",children:x.join(" - ")}),i.jsx(oe,{variant:w?"link-explicit":"link-unresolved",children:w?"Resolved":"Unresolved"})]})}}),y&&i.jsx(ie,{docTitle:y.alias??y.targetTitle,excerpt:y.heading?`# ${y.heading}`:void 0,position:r.position,onNavigate:()=>{f(),o({docId:y.targetTitle,source:"backlink"})},onMouseEnter:h,onMouseLeave:g})]})}function hs(n){const o=n.split("/");return(o[o.length-1]??n).replace(/\.[^.]+$/,"")}function fs(){const{selection:n,select:o}=V(),{index:s,isScanning:e,getIncomingLinks:t}=Ge(),r=a.useMemo(()=>n.docId?hs(n.docId):null,[n.docId]),c=a.useMemo(()=>{if(!r)return[];const g=t(r);if(g.length===0)return[];const f=new Map;for(const m of g){const y=f.get(m.sourceDoc);y?y.push(m):f.set(m.sourceDoc,[m])}return Array.from(f.entries()).map(([m,y])=>({sourceDoc:m,edges:y}))},[r,t]),l=a.useMemo(()=>{if(!r||!s)return 0;const g=new Set(t(r).map(m=>m.sourceDoc));let f=0;for(const m of Object.keys(s.outgoing))m!==n.docId&&(g.has(m)||f++);return f},[r,s,n.docId,t]);if(!n.docId)return i.jsx(L,{message:"Select a document to see unlinked mentions"});if(e)return i.jsx("div",{className:"ws-rail-loading",children:"Scanning for mentions..."});if(!s)return i.jsx(L,{message:"Link index not available"});const h=c.length>0;return!h&&l===0?i.jsx(L,{message:"No mentions found for this document"}):i.jsxs("div",{className:"ws-rail-list",children:[h&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"ws-rail-item-meta",style:{padding:"0.5rem 0.75rem"},children:["Linked mentions",i.jsx(oe,{variant:"success",count:c.length,style:{marginLeft:"0.5rem"},children:"linked"})]}),i.jsx(ne,{items:c,getKey:g=>g.sourceDoc,renderItem:g=>{const f=g.sourceDoc.split("/").pop()??g.sourceDoc,m=g.edges.map(y=>`#${y.chunkIndex}`).join(", ");return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{o({docId:g.sourceDoc,source:"backlink"})},children:[i.jsx("span",{className:"ws-rail-item-title",children:f}),i.jsxs("span",{className:"ws-rail-item-meta",children:[g.edges.length," link",g.edges.length!==1?"s":""," - Chunks"," ",m]})]})}})]}),l>0&&i.jsxs("div",{className:"ws-rail-item-meta",style:{padding:"0.5rem 0.75rem",marginTop:h?"0.75rem":0},children:[i.jsx(oe,{variant:"info",count:l,style:{marginRight:"0.5rem"},children:"unlinked"}),l," document",l!==1?"s":"",' scanned without a link to "',r,'".',i.jsx("p",{className:"ws-rail-item-excerpt",style:{marginTop:"0.375rem"},children:"Full text scanning for unlinked mentions requires fetching all document chunks and is planned for a future update."})]})]})}const Je={nodeRadius:8,activeNodeRadius:12,currentNodeColor:"#3b82f6",defaultNodeColor:"#9ca3af",pinnedNodeColor:"#10b981",edgeWidth:1.5,pinnedEdgeColor:"#3b82f6",semanticEdgeColor:"#d1d5db",backlinkEdgeColor:"#8b5cf6",repulsionStrength:150,attractionStrength:.3,centerGravity:.05,velocityDecay:.4,maxNodes:150,neighborsToShow:10};function gs({graphData:n,config:o,width:s,height:e,enabled:t=!0}){const r=a.useMemo(()=>({...Je,...o}),[o]),[c,l]=a.useState([]),[h,g]=a.useState(!1),f=a.useRef(null),m=a.useRef(0);a.useEffect(()=>{const w=s/2,k=e/2,x=n.nodes.map((b,d)=>{const p=c.find(A=>A.id===b.id);if(p&&p.x!==void 0&&p.y!==void 0)return{...b,x:p.x,y:p.y,vx:0,vy:0};const S=d/n.nodes.length*Math.PI*2,j=Math.min(s,e)*.3;return{...b,x:w+Math.cos(S)*j+(Math.random()-.5)*50,y:k+Math.sin(S)*j+(Math.random()-.5)*50,vx:0,vy:0}});l(x),g(!1),m.current=0},[n.nodes.length,s,e,n.nodes.map,c.find]);const y=a.useRef(new Map);a.useEffect(()=>{const w=new Map;for(const k of n.edges){const x=w.get(k.source)||[];x.push(k.target),w.set(k.source,x);const b=w.get(k.target)||[];b.push(k.source),w.set(k.target,b)}y.current=w},[n.edges]);const u=a.useCallback(()=>{if(!t||c.length===0)return!1;const w=s/2,k=e/2;let x=0;const b=c.map(d=>{let p=0,S=0;if(d.fx!==void 0&&d.fx!==null&&d.fy!==void 0&&d.fy!==null)return{...d,x:d.fx,y:d.fy};for(const I of c){if(I.id===d.id)continue;const N=(d.x??0)-(I.x??0),E=(d.y??0)-(I.y??0),P=Math.sqrt(N*N+E*E)||1,D=r.repulsionStrength/(P*P);p+=N/P*D,S+=E/P*D}const j=y.current.get(d.id)||[];for(const I of j){const N=c.find(D=>D.id===I);if(!N)continue;const E=(N.x??0)-(d.x??0),P=(N.y??0)-(d.y??0);p+=E*r.attractionStrength,S+=P*r.attractionStrength}p+=(w-(d.x??0))*r.centerGravity,S+=(k-(d.y??0))*r.centerGravity;const A=((d.vx??0)+p)*(1-r.velocityDecay),M=((d.vy??0)+S)*(1-r.velocityDecay),z=(d.x??0)+A,W=(d.y??0)+M,U=40,R=Math.max(U,Math.min(s-U,z)),T=Math.max(U,Math.min(e-U,W)),C=Math.sqrt(A*A+M*M);return x=Math.max(x,C),{...d,x:R,y:T,vx:A,vy:M}});return l(b),m.current++,x>.5&&m.current<300},[c,t,s,e,r]);a.useEffect(()=>{if(!t){f.current&&cancelAnimationFrame(f.current);return}const w=()=>{u()?f.current=requestAnimationFrame(w):g(!0)};return f.current=requestAnimationFrame(w),()=>{f.current&&cancelAnimationFrame(f.current)}},[u,t]);const v=a.useCallback(()=>{g(!1),m.current=0,l(w=>w.map(k=>({...k,vx:(Math.random()-.5)*10,vy:(Math.random()-.5)*10})))},[]);return{nodes:c,isStable:h,reheat:v}}function ms({graphData:n,currentNodeId:o,pinnedNodeIds:s,onNodeClick:e,config:t}){const r=a.useRef(null),c=a.useRef(null),[l,h]=a.useState({width:600,height:300}),[g,f]=a.useState(null),[m,y]=a.useState(null),[u,v]=a.useState({x:0,y:0}),[w,k]=a.useState(1),x=a.useRef(!1),b=a.useRef({x:0,y:0}),d=a.useMemo(()=>({...Je,...t}),[t]),{nodes:p,isStable:S}=gs({graphData:n,config:t,width:l.width,height:l.height,enabled:n.nodes.length>0});a.useEffect(()=>{const C=c.current;if(!C)return;const I=new ResizeObserver(N=>{const E=N[0];E&&h({width:E.contentRect.width,height:E.contentRect.height})});return I.observe(C),()=>I.disconnect()},[]);const j=a.useCallback((C,I)=>{const N=r.current;if(!N)return{x:0,y:0};const E=N.getBoundingClientRect(),P=(C-E.left-u.x)/w,D=(I-E.top-u.y)/w;return{x:P,y:D}},[u,w]),A=a.useCallback((C,I)=>{for(const N of p){if(N.x===void 0||N.y===void 0)continue;const E=C-N.x,P=I-N.y,D=N.id===o?d.activeNodeRadius:d.nodeRadius;if(E*E+P*P<=D*D*1.5)return N}return null},[p,o,d.nodeRadius,d.activeNodeRadius]),M=a.useCallback(C=>{x.current=!0,b.current={x:C.clientX,y:C.clientY}},[]),z=a.useCallback(()=>{x.current=!1},[]),W=a.useCallback(C=>{if(x.current){const P=C.clientX-b.current.x,D=C.clientY-b.current.y;v($=>({x:$.x+P,y:$.y+D})),b.current={x:C.clientX,y:C.clientY};return}const{x:I,y:N}=j(C.clientX,C.clientY),E=A(I,N);if(f(E),E){const P=r.current;if(P){const D=P.getBoundingClientRect();y({x:C.clientX-D.left,y:C.clientY-D.top,node:E})}}else y(null)},[j,A]),U=a.useCallback(C=>{const{x:I,y:N}=j(C.clientX,C.clientY),E=A(I,N);E&&e&&e(E)},[j,A,e]),R=a.useCallback(C=>{C.preventDefault();const I=C.deltaY>0?.9:1.1;k(N=>Math.max(.3,Math.min(3,N*I)))},[]);a.useEffect(()=>{const C=r.current;if(!C)return;const I=C.getContext("2d");if(!I)return;C.width=l.width*window.devicePixelRatio,C.height=l.height*window.devicePixelRatio,I.scale(window.devicePixelRatio,window.devicePixelRatio),I.clearRect(0,0,l.width,l.height),I.save(),I.translate(u.x,u.y),I.scale(w,w);const N=new Map;for(const E of p)E.x!==void 0&&E.y!==void 0&&N.set(E.id,{x:E.x,y:E.y});for(const E of n.edges){const P=N.get(E.source),D=N.get(E.target);!P||!D||(I.beginPath(),I.moveTo(P.x,P.y),I.lineTo(D.x,D.y),I.strokeStyle=E.type==="pinned"?d.pinnedEdgeColor:E.type==="backlink"?d.backlinkEdgeColor:d.semanticEdgeColor,I.lineWidth=E.type==="pinned"?d.edgeWidth*1.5:d.edgeWidth,E.type==="semantic"?I.setLineDash([4,4]):I.setLineDash([]),I.stroke())}I.setLineDash([]);for(const E of p){if(E.x===void 0||E.y===void 0)continue;const P=E.id===o,D=s.has(E.id),$=g?.id===E.id,Y=P?d.activeNodeRadius:d.nodeRadius,Xe=P?d.currentNodeColor:D?d.pinnedNodeColor:d.defaultNodeColor;I.beginPath(),I.arc(E.x,E.y,$?Y*1.3:Y,0,Math.PI*2),I.fillStyle=Xe,I.fill(),I.strokeStyle=$?"#fff":"rgba(0,0,0,0.2)",I.lineWidth=$?2:1,I.stroke(),P&&(I.font="10px sans-serif",I.fillStyle="#fff",I.textAlign="center",I.textBaseline="middle",I.fillText("●",E.x,E.y))}I.restore()},[p,n.edges,l,u,w,o,s,g,d]);const T=C=>{const I=C.split(/[/\\]/);return I[I.length-1]||C};return i.jsxs("div",{ref:c,className:"w-full h-full relative rounded-lg overflow-hidden",style:{background:"var(--ws-surface-1)"},children:[i.jsx("canvas",{ref:r,className:"w-full h-full cursor-grab active:cursor-grabbing",style:{width:l.width,height:l.height},onMouseDown:M,onMouseUp:z,onMouseMove:W,onMouseLeave:()=>{f(null),y(null),x.current=!1},onClick:U,onWheel:R}),m&&i.jsxs("div",{className:"absolute pointer-events-none z-10 max-w-xs px-3 py-2 text-xs rounded-lg shadow-lg",style:{background:"var(--ws-surface-0)",color:"var(--ws-text)",left:Math.min(m.x+10,l.width-200),top:Math.min(m.y+10,l.height-60)},children:[i.jsx("p",{className:"font-medium truncate",children:T(m.node.filePath)}),i.jsxs("p",{style:{color:"var(--ws-text-faint)"},children:["Chunk #",m.node.chunkIndex]}),i.jsx("p",{className:"mt-1 line-clamp-2",style:{color:"var(--ws-text-muted)"},children:m.node.text})]}),i.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1",children:[i.jsx("button",{type:"button",onClick:()=>k(C=>Math.min(3,C*1.2)),className:"p-1.5 rounded shadow",style:{background:"var(--ws-surface-raised)",color:"var(--ws-text-secondary)"},title:"Zoom in",children:i.jsx(ps,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>k(C=>Math.max(.3,C*.8)),className:"p-1.5 rounded shadow",style:{background:"var(--ws-surface-raised)",color:"var(--ws-text-secondary)"},title:"Zoom out",children:i.jsx(bs,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>{v({x:0,y:0}),k(1)},className:"p-1.5 rounded shadow",style:{background:"var(--ws-surface-raised)",color:"var(--ws-text-secondary)"},title:"Reset view",children:i.jsx(xs,{className:"w-4 h-4"})}),!S&&i.jsx("span",{className:"p-1.5 text-xs",style:{color:"var(--ws-text-muted)"},children:"Simulating..."})]}),i.jsxs("div",{className:"absolute top-2 left-2 text-xs px-2 py-1 rounded",style:{color:"var(--ws-text-secondary)",background:"var(--ws-surface-raised)"},children:[i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:d.currentNodeColor}}),"Current"]}),i.jsxs("span",{className:"inline-flex items-center gap-1 ml-3",children:[i.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:d.pinnedNodeColor}}),"Pinned"]}),i.jsxs("span",{className:"inline-flex items-center gap-1 ml-3",children:[i.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:d.defaultNodeColor}}),"Related"]})]})]})}function ps({className:n}){return i.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function bs({className:n}){return i.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}function xs({className:n}){return i.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function ys(){const{selection:n,select:o}=V(),s=n.docId??null,e=n.chunkIndex??null,{related:t,isLoading:r}=_e(s,e),{pins:c}=wn(),{graphData:l,currentNodeId:h}=Pn({filePath:s??"",activeChunkIndex:e,relatedChunks:t,pins:c}),g=a.useMemo(()=>{const m=new Set;for(const y of c)m.add(`${y.sourceKey.filePath}:${y.sourceKey.chunkIndex}`),m.add(`${y.targetKey.filePath}:${y.targetKey.chunkIndex}`);return m},[c]),f=m=>{o({docId:m.filePath,chunkIndex:m.chunkIndex,source:"graph"})};return s?r?i.jsx("div",{className:"ws-rail-loading",children:"Loading graph..."}):l.nodes.length===0?i.jsx(L,{message:"No graph data available"}):i.jsx("div",{style:{height:"100%",minHeight:300},children:i.jsx(ms,{graphData:l,currentNodeId:h,pinnedNodeIds:g,onNodeClick:f})}):i.jsx(L,{message:"Select a document to see its graph"})}const ws=[{id:"backlinks",label:"Backlinks"},{id:"outgoing",label:"Outgoing"},{id:"related",label:"Related"},{id:"mentions",label:"Mentions"},{id:"outline",label:"Outline"},{id:"graph",label:"Graph"}],ks={backlinks:He,outgoing:us,related:is,mentions:fs,outline:cs,graph:ys};function vs({collapsed:n,onToggle:o,width:s}){const[e,t]=F("ws-right-rail-tab","backlinks");if(n)return i.jsx("aside",{className:"ws-right-rail ws-right-rail--collapsed",children:i.jsx("button",{type:"button",className:"ws-rail-toggle",onClick:o,"aria-label":"Toggle right rail",children:"‹"})});const r=ks[e]??He;return i.jsxs("aside",{className:"ws-right-rail",style:{width:s},children:[i.jsxs("div",{className:"ws-right-rail-header",children:[i.jsx(Fe,{tabs:ws,activeId:e,onSelect:c=>t(c),variant:"pill",className:"ws-right-rail-tabs"}),i.jsx("button",{type:"button",className:"ws-rail-toggle",onClick:o,"aria-label":"Toggle right rail",children:"›"})]}),i.jsx("div",{className:"ws-right-rail-content",children:i.jsx(r,{})})]})}function Ss(){const n=ue({storageKey:"left-rail",defaultWidth:220,min:180,max:320}),o=ue({storageKey:"right-rail",defaultWidth:300,min:240,max:420}),{selection:s,select:e}=V(),t=dt(),r=a.useRef(!1);a.useEffect(()=>{if(r.current){r.current=!1;return}s.docId&&t.push(s.docId,s.chunkIndex)},[s.docId,s.chunkIndex]);const c=a.useCallback(()=>{const h=t.goBack();h&&(r.current=!0,e({docId:h.docId,chunkIndex:h.chunkIndex,source:"backlink"}))},[t,e]),l=a.useCallback(()=>{const h=t.goForward();h&&(r.current=!0,e({docId:h.docId,chunkIndex:h.chunkIndex,source:"backlink"}))},[t,e]);return ut({onToggleLeftRail:n.toggleCollapsed,onToggleRightRail:o.toggleCollapsed,onNavigateBack:c,onNavigateForward:l}),i.jsxs("div",{className:"ws-shell",children:[i.jsx(Nt,{}),i.jsx(Bn,{collapsed:n.collapsed,onToggle:n.toggleCollapsed,width:n.width}),!n.collapsed&&i.jsx(Se,{direction:"left",onResize:h=>n.setWidth(n.width+h)}),i.jsx(Gt,{}),!o.collapsed&&i.jsx(Se,{direction:"right",onResize:h=>o.setWidth(o.width+h)}),i.jsx(vs,{collapsed:o.collapsed,onToggle:o.toggleCollapsed,width:o.width})]})}function Cs(){return i.jsx(ct,{children:i.jsx(Ss,{})})}const Is=a.createContext(null);function js({children:n,vaultId:o="default"}){const s=`rag-vault-reading-mode-${o}`,[e,t]=F(s,"full"),r=a.useCallback(h=>{t(h)},[t]),c=a.useCallback(()=>{t(h=>h==="skim"?"full":"skim")},[t]),l=a.useMemo(()=>({mode:e,setMode:r,toggleMode:c,isSkimMode:e==="skim",isFullMode:e==="full"}),[e,r,c]);return i.jsx(Is.Provider,{value:l,children:n})}const Es=new Ye({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}}),Qe=document.getElementById("root");if(!Qe)throw new Error('Root element not found. Ensure index.html has <div id="root"></div>');it.createRoot(Qe).render(i.jsx(a.StrictMode,{children:i.jsx(Ze,{client:Es,children:i.jsx(rt,{children:i.jsx(Xt,{children:i.jsx(jt,{children:i.jsx(lt,{children:i.jsx(Mt,{dbId:"default",children:i.jsx(yn,{children:i.jsx(ds,{children:i.jsx(Rn,{children:i.jsx(Dn,{children:i.jsx(Fn,{children:i.jsx(_n,{children:i.jsx(js,{children:i.jsx(Wn,{children:i.jsx(Cs,{})})})})})})})})})})})})})})})}));export{Fs as A,Ks as B,Zs as C,$s as D,_s as E,zs as F,Ws as G,qs as H,ms as K,xt as S,Xs as T,Fe as W,F as a,Qs as b,Pn as c,bn as d,Tn as e,wn as f,Ds as g,Rs as h,Ps as i,Et as j,to as k,Ys as l,eo as m,Ms as n,Os as o,Bs as p,Us as q,Hs as r,Ns as s,Vs as t,ze as u,K as v,Gs as w,Js as x,pn as y,Ls as z};
@@ -1,9 +0,0 @@
1
- import{a as x,j as Y}from"./query-DPt-uCb6.js";const _e=x.createContext({});function Xe(t){const e=x.useRef(null);return e.current===null&&(e.current=t()),e.current}const Lo=typeof window<"u",Hs=Lo?x.useLayoutEffect:x.useEffect,ne=x.createContext(null);function Ye(t,e){t.indexOf(e)===-1&&t.push(e)}function Xt(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const X=(t,e,n)=>n>e?e:n<t?t:n;let qe=()=>{};const q={},zs=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Gs(t){return typeof t=="object"&&t!==null}const _s=t=>/^0[^.\s]+$/u.test(t);function Xs(t){let e;return()=>(e===void 0&&(e=t()),e)}const W=t=>t,ko=(t,e)=>n=>e(t(n)),Lt=(...t)=>t.reduce(ko),Ct=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Ze{constructor(){this.subscriptions=[]}add(e){return Ye(this.subscriptions,e),()=>Xt(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const H=t=>t*1e3,U=t=>t/1e3;function Ys(t,e){return e?t*(1e3/e):0}const qs=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Fo=1e-7,Io=12;function Bo(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=qs(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Fo&&++a<Io);return o}function kt(t,e,n,s){if(t===e&&n===s)return W;const i=r=>Bo(r,0,1,t,n);return r=>r===0||r===1?r:qs(i(r),e,s)}const Zs=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Js=t=>e=>1-t(1-e),Qs=kt(.33,1.53,.69,.99),Je=Js(Qs),ti=Zs(Je),ei=t=>(t*=2)<1?.5*Je(t):.5*(2-Math.pow(2,-10*(t-1))),Qe=t=>1-Math.sin(Math.acos(t)),ni=Js(Qe),si=Zs(Qe),jo=kt(.42,0,1,1),Oo=kt(0,0,.58,1),ii=kt(.42,0,.58,1),No=t=>Array.isArray(t)&&typeof t[0]!="number",oi=t=>Array.isArray(t)&&typeof t[0]=="number",Uo={linear:W,easeIn:jo,easeInOut:ii,easeOut:Oo,circIn:Qe,circInOut:si,circOut:ni,backIn:Je,backInOut:ti,backOut:Qs,anticipate:ei},Wo=t=>typeof t=="string",Cn=t=>{if(oi(t)){qe(t.length===4);const[e,n,s,i]=t;return kt(e,n,s,i)}else if(Wo(t))return Uo[t];return t},jt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ko(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){o.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,f=!1,h=!1)=>{const p=h&&i?n:s;return f&&o.add(l),p.has(l)||p.add(l),l},cancel:l=>{s.delete(l),o.delete(l)},process:l=>{if(a=l,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,r&&(r=!1,u.process(l))}};return u}const $o=40;function ri(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=jt.reduce((g,P)=>(g[P]=Ko(r),g),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:f,preRender:h,render:d,postRender:p}=o,m=()=>{const g=q.useManualTiming?i.timestamp:performance.now();n=!1,q.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(g-i.timestamp,$o),1)),i.timestamp=g,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),f.process(i),h.process(i),d.process(i),p.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(m))},y=()=>{n=!0,s=!0,i.isProcessing||t(m)};return{schedule:jt.reduce((g,P)=>{const S=o[P];return g[P]=(V,M=!1,b=!1)=>(n||y(),S.schedule(V,M,b)),g},{}),cancel:g=>{for(let P=0;P<jt.length;P++)o[jt[P]].cancel(g)},state:i,steps:o}}const{schedule:C,cancel:tt,state:I,steps:re}=ri(typeof requestAnimationFrame<"u"?requestAnimationFrame:W,!0);let Wt;function Ho(){Wt=void 0}const j={now:()=>(Wt===void 0&&j.set(I.isProcessing||q.useManualTiming?I.timestamp:performance.now()),Wt),set:t=>{Wt=t,queueMicrotask(Ho)}},ai=t=>e=>typeof e=="string"&&e.startsWith(t),li=ai("--"),zo=ai("var(--"),tn=t=>zo(t)?Go.test(t.split("/*")[0].trim()):!1,Go=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Mn(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const vt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Mt={...vt,transform:t=>X(0,1,t)},Ot={...vt,default:1},St=t=>Math.round(t*1e5)/1e5,en=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function _o(t){return t==null}const Xo=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,nn=(t,e)=>n=>!!(typeof n=="string"&&Xo.test(n)&&n.startsWith(t)||e&&!_o(n)&&Object.prototype.hasOwnProperty.call(n,e)),ci=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(en);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Yo=t=>X(0,255,t),ae={...vt,transform:t=>Math.round(Yo(t))},rt={test:nn("rgb","red"),parse:ci("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+ae.transform(t)+", "+ae.transform(e)+", "+ae.transform(n)+", "+St(Mt.transform(s))+")"};function qo(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const Se={test:nn("#"),parse:qo,transform:rt.transform},Ft=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),J=Ft("deg"),_=Ft("%"),w=Ft("px"),Zo=Ft("vh"),Jo=Ft("vw"),Dn={..._,parse:t=>_.parse(t)/100,transform:t=>_.transform(t*100)},ht={test:nn("hsl","hue"),parse:ci("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+_.transform(St(e))+", "+_.transform(St(n))+", "+St(Mt.transform(s))+")"},R={test:t=>rt.test(t)||Se.test(t)||ht.test(t),parse:t=>rt.test(t)?rt.parse(t):ht.test(t)?ht.parse(t):Se.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?rt.transform(t):ht.transform(t),getAnimatableNone:t=>{const e=R.parse(t);return e.alpha=0,R.transform(e)}},Qo=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tr(t){return isNaN(t)&&typeof t=="string"&&(t.match(en)?.length||0)+(t.match(Qo)?.length||0)>0}const ui="number",hi="color",er="var",nr="var(",En="${}",sr=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Dt(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(sr,c=>(R.test(c)?(s.color.push(r),i.push(hi),n.push(R.parse(c))):c.startsWith(nr)?(s.var.push(r),i.push(er),n.push(c)):(s.number.push(r),i.push(ui),n.push(parseFloat(c))),++r,En)).split(En);return{values:n,split:a,indexes:s,types:i}}function fi(t){return Dt(t).values}function di(t){const{split:e,types:n}=Dt(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===ui?r+=St(i[o]):a===hi?r+=R.transform(i[o]):r+=i[o]}return r}}const ir=t=>typeof t=="number"?0:R.test(t)?R.getAnimatableNone(t):t;function or(t){const e=fi(t);return di(t)(e.map(ir))}const z={test:tr,parse:fi,createTransformer:di,getAnimatableNone:or};function le(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function rr({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=le(c,a,t+1/3),r=le(c,a,t),o=le(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Yt(t,e){return n=>n>0?e:t}const D=(t,e,n)=>t+(e-t)*n,ce=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},ar=[Se,rt,ht],lr=t=>ar.find(e=>e.test(t));function Rn(t){const e=lr(t);if(!e)return!1;let n=e.parse(t);return e===ht&&(n=rr(n)),n}const Ln=(t,e)=>{const n=Rn(t),s=Rn(e);if(!n||!s)return Yt(t,e);const i={...n};return r=>(i.red=ce(n.red,s.red,r),i.green=ce(n.green,s.green,r),i.blue=ce(n.blue,s.blue,r),i.alpha=D(n.alpha,s.alpha,r),rt.transform(i))},be=new Set(["none","hidden"]);function cr(t,e){return be.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function ur(t,e){return n=>D(t,e,n)}function sn(t){return typeof t=="number"?ur:typeof t=="string"?tn(t)?Yt:R.test(t)?Ln:dr:Array.isArray(t)?pi:typeof t=="object"?R.test(t)?Ln:hr:Yt}function pi(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>sn(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function hr(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=sn(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function fr(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const dr=(t,e)=>{const n=z.createTransformer(e),s=Dt(t),i=Dt(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?be.has(t)&&!i.values.length||be.has(e)&&!s.values.length?cr(t,e):Lt(pi(fr(s,i),i.values),n):Yt(t,e)};function mi(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?D(t,e,n):sn(t)(t,e)}const pr=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>C.update(e,n),stop:()=>tt(e),now:()=>I.isProcessing?I.timestamp:j.now()}},gi=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},qt=2e4;function on(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<qt;)e+=n,s=t.next(e);return e>=qt?1/0:e}function mr(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(on(s),qt);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:U(i)}}const gr=5;function yi(t,e,n){const s=Math.max(e-gr,0);return Ys(n-t(s),e-s)}const E={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},ue=.001;function yr({duration:t=E.duration,bounce:e=E.bounce,velocity:n=E.velocity,mass:s=E.mass}){let i,r,o=1-e;o=X(E.minDamping,E.maxDamping,o),t=X(E.minDuration,E.maxDuration,U(t)),o<1?(i=u=>{const l=u*o,f=l*t,h=l-n,d=Ae(u,o),p=Math.exp(-f);return ue-h/d*p},r=u=>{const f=u*o*t,h=f*n+n,d=Math.pow(o,2)*Math.pow(u,2)*t,p=Math.exp(-f),m=Ae(Math.pow(u,2),o);return(-i(u)+ue>0?-1:1)*((h-d)*p)/m}):(i=u=>{const l=Math.exp(-u*t),f=(u-n)*t+1;return-ue+l*f},r=u=>{const l=Math.exp(-u*t),f=(n-u)*(t*t);return l*f});const a=5/t,c=Tr(i,r,a);if(t=H(t),isNaN(c))return{stiffness:E.stiffness,damping:E.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const vr=12;function Tr(t,e,n){let s=n;for(let i=1;i<vr;i++)s=s-t(s)/e(s);return s}function Ae(t,e){return t*Math.sqrt(1-e*e)}const xr=["duration","bounce"],wr=["stiffness","damping","mass"];function kn(t,e){return e.some(n=>t[n]!==void 0)}function Pr(t){let e={velocity:E.velocity,stiffness:E.stiffness,damping:E.damping,mass:E.mass,isResolvedFromDuration:!1,...t};if(!kn(t,wr)&&kn(t,xr))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*X(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:E.mass,stiffness:i,damping:r}}else{const n=yr({...t,velocity:0});e={...e,...n,mass:E.mass},e.isResolvedFromDuration=!0}return e}function Zt(t=E.visualDuration,e=E.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:c,damping:u,mass:l,duration:f,velocity:h,isResolvedFromDuration:d}=Pr({...n,velocity:-U(n.velocity||0)}),p=h||0,m=u/(2*Math.sqrt(c*l)),y=o-r,v=U(Math.sqrt(c/l)),T=Math.abs(y)<5;s||(s=T?E.restSpeed.granular:E.restSpeed.default),i||(i=T?E.restDelta.granular:E.restDelta.default);let g;if(m<1){const S=Ae(v,m);g=V=>{const M=Math.exp(-m*v*V);return o-M*((p+m*v*y)/S*Math.sin(S*V)+y*Math.cos(S*V))}}else if(m===1)g=S=>o-Math.exp(-v*S)*(y+(p+v*y)*S);else{const S=v*Math.sqrt(m*m-1);g=V=>{const M=Math.exp(-m*v*V),b=Math.min(S*V,300);return o-M*((p+m*v*y)*Math.sinh(b)+S*y*Math.cosh(b))/S}}const P={calculatedDuration:d&&f||null,next:S=>{const V=g(S);if(d)a.done=S>=f;else{let M=S===0?p:0;m<1&&(M=S===0?H(p):yi(g,S,V));const b=Math.abs(M)<=s,A=Math.abs(o-V)<=i;a.done=b&&A}return a.value=a.done?o:V,a},toString:()=>{const S=Math.min(on(P),qt),V=gi(M=>P.next(S*M).value,S,30);return S+"ms "+V},toTransition:()=>{}};return P}Zt.applyToOptions=t=>{const e=mr(t,100,Zt);return t.ease=e.ease,t.duration=H(e.duration),t.type="keyframes",t};function Ve({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:c,restDelta:u=.5,restSpeed:l}){const f=t[0],h={done:!1,value:f},d=b=>a!==void 0&&b<a||c!==void 0&&b>c,p=b=>a===void 0?c:c===void 0||Math.abs(a-b)<Math.abs(c-b)?a:c;let m=n*e;const y=f+m,v=o===void 0?y:o(y);v!==y&&(m=v-f);const T=b=>-m*Math.exp(-b/s),g=b=>v+T(b),P=b=>{const A=T(b),L=g(b);h.done=Math.abs(A)<=u,h.value=h.done?v:L};let S,V;const M=b=>{d(h.value)&&(S=b,V=Zt({keyframes:[h.value,p(h.value)],velocity:yi(g,b,h.value),damping:i,stiffness:r,restDelta:u,restSpeed:l}))};return M(0),{calculatedDuration:null,next:b=>{let A=!1;return!V&&S===void 0&&(A=!0,P(b),M(b)),S!==void 0&&b>=S?V.next(b-S):(!A&&P(b),h)}}}function Sr(t,e,n){const s=[],i=n||q.mix||mi,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const c=Array.isArray(e)?e[o]||W:e;a=Lt(c,a)}s.push(a)}return s}function br(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(qe(r===e.length),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Sr(e,s,i),c=a.length,u=l=>{if(o&&l<t[0])return e[0];let f=0;if(c>1)for(;f<t.length-2&&!(l<t[f+1]);f++);const h=Ct(t[f],t[f+1],l);return a[f](h)};return n?l=>u(X(t[0],t[r-1],l)):u}function Ar(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ct(0,e,s);t.push(D(n,1,i))}}function Vr(t){const e=[0];return Ar(e,t.length-1),e}function Cr(t,e){return t.map(n=>n*e)}function Mr(t,e){return t.map(()=>e||ii).splice(0,t.length-1)}function bt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=No(s)?s.map(Cn):Cn(s),r={done:!1,value:e[0]},o=Cr(n&&n.length===e.length?n:Vr(e),t),a=br(o,e,{ease:Array.isArray(i)?i:Mr(e,i)});return{calculatedDuration:t,next:c=>(r.value=a(c),r.done=c>=t,r)}}const Dr=t=>t!==null;function rn(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(Dr),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Er={decay:Ve,inertia:Ve,tween:bt,keyframes:bt,spring:Zt};function vi(t){typeof t.type=="string"&&(t.type=Er[t.type])}class an{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Rr=t=>t/100;class ln extends an{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==j.now()&&this.tick(j.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;vi(e);const{type:n=bt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const c=n||bt;c!==bt&&typeof a[0]!="number"&&(this.mixKeyframes=Lt(Rr,mi(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=on(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:f,repeatType:h,repeatDelay:d,type:p,onUpdate:m,finalKeyframe:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?v<0:v>i;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let g=this.currentTime,P=s;if(f){const b=Math.min(this.currentTime,i)/a;let A=Math.floor(b),L=b%1;!L&&b>=1&&(L=1),L===1&&A--,A=Math.min(A,f+1),A%2&&(h==="reverse"?(L=1-L,d&&(L-=d/a)):h==="mirror"&&(P=o)),g=X(0,1,L)*a}const S=T?{done:!1,value:l[0]}:P.next(g);r&&(S.value=r(S.value));let{done:V}=S;!T&&c!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return M&&p!==Ve&&(S.value=rn(l,this.options,y,this.speed)),m&&m(S.value),M&&this.finish(),S}then(e,n){return this.finished.then(e,n)}get duration(){return U(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+U(e)}get time(){return U(this.currentTime)}set time(e){e=H(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(j.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=U(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=pr,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(j.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Lr(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const at=t=>t*180/Math.PI,Ce=t=>{const e=at(Math.atan2(t[1],t[0]));return Me(e)},kr={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Ce,rotateZ:Ce,skewX:t=>at(Math.atan(t[1])),skewY:t=>at(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Me=t=>(t=t%360,t<0&&(t+=360),t),Fn=Ce,In=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Bn=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Fr={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:In,scaleY:Bn,scale:t=>(In(t)+Bn(t))/2,rotateX:t=>Me(at(Math.atan2(t[6],t[5]))),rotateY:t=>Me(at(Math.atan2(-t[2],t[0]))),rotateZ:Fn,rotate:Fn,skewX:t=>at(Math.atan(t[4])),skewY:t=>at(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function De(t){return t.includes("scale")?1:0}function Ee(t,e){if(!t||t==="none")return De(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Fr,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=kr,i=a}if(!i)return De(e);const r=s[e],o=i[1].split(",").map(Br);return typeof r=="function"?r(o):o[r]}const Ir=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Ee(n,e)};function Br(t){return parseFloat(t.trim())}const Tt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],xt=new Set(Tt),jn=t=>t===vt||t===w,jr=new Set(["x","y","z"]),Or=Tt.filter(t=>!jr.has(t));function Nr(t){const e=[];return Or.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Q={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>Ee(e,"x"),y:(t,{transform:e})=>Ee(e,"y")};Q.translateX=Q.x;Q.translateY=Q.y;const lt=new Set;let Re=!1,Le=!1,ke=!1;function Ti(){if(Le){const t=Array.from(lt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Nr(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Le=!1,Re=!1,lt.forEach(t=>t.complete(ke)),lt.clear()}function xi(){lt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Le=!0)})}function Ur(){ke=!0,xi(),Ti(),ke=!1}class cn{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(lt.add(this),Re||(Re=!0,C.read(xi),C.resolveKeyframes(Ti))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}Lr(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),lt.delete(this)}cancel(){this.state==="scheduled"&&(lt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wr=t=>t.startsWith("--");function Kr(t,e,n){Wr(e)?t.style.setProperty(e,n):t.style[e]=n}const $r={};function wi(t,e){const n=Xs(t);return()=>$r[e]??n()}const Hr=wi(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Pi=wi(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Pt=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,On={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Pt([0,.65,.55,1]),circOut:Pt([.55,0,1,.45]),backIn:Pt([.31,.01,.66,-.59]),backOut:Pt([.33,1.53,.69,.99])};function Si(t,e){if(t)return typeof t=="function"?Pi()?gi(t,e):"ease-out":oi(t)?Pt(t):Array.isArray(t)?t.map(n=>Si(n,e)||On.easeOut):On[t]}function zr(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const f=Si(a,i);Array.isArray(f)&&(l.easing=f);const h={delay:s,duration:i,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(h.pseudoElement=u),t.animate(l,h)}function bi(t){return typeof t=="function"&&"applyToOptions"in t}function Gr({type:t,...e}){return bi(t)&&Pi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Ai extends an{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,qe(typeof e.type!="string");const u=Gr(e);this.animation=zr(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const l=rn(i,this.options,a,this.speed);this.updateMotionValue&&this.updateMotionValue(l),Kr(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return U(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+U(e)}get time(){return U(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=H(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:s,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Hr()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),s&&(this.animation.rangeEnd=s),W):i(this)}}const Vi={anticipate:ei,backInOut:ti,circInOut:si};function _r(t){return t in Vi}function Xr(t){typeof t.ease=="string"&&_r(t.ease)&&(t.ease=Vi[t.ease])}const he=10;class Yr extends Ai{constructor(e){Xr(e),vi(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new ln({...o,autoplay:!1}),c=Math.max(he,j.now()-this.startTime),u=X(0,he,c-he);n.setWithVelocity(a.sample(Math.max(0,c-u)).value,a.sample(c).value,u),a.stop()}}const Nn=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(z.test(t)||t==="0")&&!t.startsWith("url("));function qr(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Zr(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=Nn(i,e),a=Nn(r,e);return!o||!a?!1:qr(t)||(n==="spring"||bi(n))&&s}function Fe(t){t.duration=0,t.type="keyframes"}const Jr=new Set(["opacity","clipPath","filter","transform"]),Qr=Xs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ta(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Qr()&&n&&Jr.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const ea=40;class na extends an{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:c,motionValue:u,element:l,...f}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=j.now();const h={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:c,motionValue:u,element:l,...f},d=l?.KeyframeResolver||cn;this.keyframeResolver=new d(a,(p,m,y)=>this.onKeyframesResolved(p,m,h,!y),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=j.now(),Zr(e,r,o,a)||((q.instantAnimations||!c)&&l?.(rn(e,s,n)),e[0]=e[e.length-1],Fe(s),s.repeat=0);const h={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>ea?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},d=!u&&ta(h),p=h.motionValue?.owner?.current,m=d?new Yr({...h,element:p}):new ln(h);m.finished.then(()=>{this.notifyFinished()}).catch(W),this.pendingTimeline&&(this.stopTimeline=m.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ur()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function Ci(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}const sa=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ia(t){const e=sa.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}function Mi(t,e,n=1){const[s,i]=ia(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return zs(o)?parseFloat(o):o}return tn(i)?Mi(i,e,n+1):i}const oa={type:"spring",stiffness:500,damping:25,restSpeed:10},ra=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),aa={type:"keyframes",duration:.8},la={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ca=(t,{keyframes:e})=>e.length>2?aa:xt.has(t)?t.startsWith("scale")?ra(e[1]):oa:la,ua=t=>t!==null;function ha(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ua),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}function Di(t,e){if(t?.inherit&&e){const{inherit:n,...s}=t;return{...e,...s}}return t}function un(t,e){const n=t?.[e]??t?.default??t;return n!==t?Di(n,t):n}function fa({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const hn=(t,e,n,s={},i,r)=>o=>{const a=un(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-H(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:h=>{e.set(h),a.onUpdate&&a.onUpdate(h)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};fa(a)||Object.assign(l,ca(t,l)),l.duration&&(l.duration=H(l.duration)),l.repeatDelay&&(l.repeatDelay=H(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let f=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(Fe(l),l.delay===0&&(f=!0)),(q.instantAnimations||q.skipAnimations||i?.shouldSkipAnimations)&&(f=!0,Fe(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,f&&!r&&e.get()!==void 0){const h=ha(l.keyframes,a);if(h!==void 0){C.update(()=>{l.onUpdate(h),l.onComplete()});return}}return a.isSync?new ln(l):new na(l)};function Un(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function fn(t,e,n,s){if(typeof e=="function"){const[i,r]=Un(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=Un(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function gt(t,e,n){const s=t.getProps();return fn(s,e,n!==void 0?n:s.custom,t)}const Ei=new Set(["width","height","top","left","right","bottom",...Tt]),Wn=30,da=t=>!isNaN(parseFloat(t));class pa{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=j.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=j.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=da(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Ze);const s=this.events[e].add(n);return e==="change"?()=>{s(),C.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=j.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Wn)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Wn);return Ys(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function yt(t,e){return new pa(t,e)}const Ie=t=>Array.isArray(t);function ma(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,yt(n))}function ga(t){return Ie(t)?t[t.length-1]||0:t}function ya(t,e){const n=gt(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=ga(r[o]);ma(t,o,a)}}const B=t=>!!(t&&t.getVelocity);function va(t){return!!(B(t)&&t.add)}function Be(t,e){const n=t.getValue("willChange");if(va(n))return n.add(e);if(!n&&q.WillChange){const s=new q.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function dn(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Ta="framerAppearId",Ri="data-"+dn(Ta);function Li(t){return t.props[Ri]}function xa({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ki(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r,transitionEnd:o,...a}=e;const c=t.getDefaultTransition();r=r?Di(r,c):c;const u=r?.reduceMotion;s&&(r=s);const l=[],f=i&&t.animationState&&t.animationState.getState()[i];for(const h in a){const d=t.getValue(h,t.latestValues[h]??null),p=a[h];if(p===void 0||f&&xa(f,h))continue;const m={delay:n,...un(r||{},h)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(p)&&p===y&&!m.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const P=Li(t);if(P){const S=window.MotionHandoffAnimation(P,h,C);S!==null&&(m.startTime=S,v=!0)}}Be(t,h);const T=u??t.shouldReduceMotion;d.start(hn(h,d,p,T&&Ei.has(h)?{type:!1}:m,t,v));const g=d.animation;g&&l.push(g)}if(o){const h=()=>C.update(()=>{o&&ya(t,o)});l.length?Promise.all(l).then(h):h()}return l}function je(t,e,n={}){const s=gt(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(ki(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:f}=i;return wa(t,e,c,u,l,f,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[r,o]:[o,r];return c().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function wa(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(je(c,e,{...o,delay:n+(typeof s=="function"?0:s)+Ci(t.variantChildren,c,s,i,r)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function Pa(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>je(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=je(t,e,n);else{const i=typeof e=="function"?gt(t,e,n.custom):e;s=Promise.all(ki(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}const Sa={test:t=>t==="auto",parse:t=>t},Fi=t=>e=>e.test(t),Ii=[vt,w,_,J,Jo,Zo,Sa],Kn=t=>Ii.find(Fi(t));function ba(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_s(t):!0}const Aa=new Set(["brightness","contrast","saturate","opacity"]);function Va(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(en)||[];if(!s)return t;const i=n.replace(s,"");let r=Aa.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const Ca=/\b([a-z-]*)\(.*?\)/gu,Oe={...z,getAnimatableNone:t=>{const e=t.match(Ca);return e?e.map(Va).join(" "):t}},Ne={...z,getAnimatableNone:t=>{const e=z.parse(t);return z.createTransformer(t)(e.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},$n={...vt,transform:Math.round},Ma={rotate:J,rotateX:J,rotateY:J,rotateZ:J,scale:Ot,scaleX:Ot,scaleY:Ot,scaleZ:Ot,skew:J,skewX:J,skewY:J,distance:w,translateX:w,translateY:w,translateZ:w,x:w,y:w,z:w,perspective:w,transformPerspective:w,opacity:Mt,originX:Dn,originY:Dn,originZ:w},pn={borderWidth:w,borderTopWidth:w,borderRightWidth:w,borderBottomWidth:w,borderLeftWidth:w,borderRadius:w,borderTopLeftRadius:w,borderTopRightRadius:w,borderBottomRightRadius:w,borderBottomLeftRadius:w,width:w,maxWidth:w,height:w,maxHeight:w,top:w,right:w,bottom:w,left:w,inset:w,insetBlock:w,insetBlockStart:w,insetBlockEnd:w,insetInline:w,insetInlineStart:w,insetInlineEnd:w,padding:w,paddingTop:w,paddingRight:w,paddingBottom:w,paddingLeft:w,paddingBlock:w,paddingBlockStart:w,paddingBlockEnd:w,paddingInline:w,paddingInlineStart:w,paddingInlineEnd:w,margin:w,marginTop:w,marginRight:w,marginBottom:w,marginLeft:w,marginBlock:w,marginBlockStart:w,marginBlockEnd:w,marginInline:w,marginInlineStart:w,marginInlineEnd:w,fontSize:w,backgroundPositionX:w,backgroundPositionY:w,...Ma,zIndex:$n,fillOpacity:Mt,strokeOpacity:Mt,numOctaves:$n},Da={...pn,color:R,backgroundColor:R,outlineColor:R,fill:R,stroke:R,borderColor:R,borderTopColor:R,borderRightColor:R,borderBottomColor:R,borderLeftColor:R,filter:Oe,WebkitFilter:Oe,mask:Ne,WebkitMask:Ne},Bi=t=>Da[t],Ea=new Set([Oe,Ne]);function ji(t,e){let n=Bi(t);return Ea.has(n)||(n=z),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ra=new Set(["auto","none","0"]);function La(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!Ra.has(r)&&Dt(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=ji(n,i)}class ka extends cn{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let f=e[l];if(typeof f=="string"&&(f=f.trim(),tn(f))){const h=Mi(f,n.current);h!==void 0&&(e[l]=h),l===e.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!Ei.has(s)||e.length!==2)return;const[i,r]=e,o=Kn(i),a=Kn(r),c=Mn(i),u=Mn(r);if(c!==u&&Q[s]){this.needsMeasurement=!0;return}if(o!==a)if(jn(o)&&jn(a))for(let l=0;l<e.length;l++){const f=e[l];typeof f=="string"&&(e[l]=parseFloat(f))}else Q[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||ba(e[i]))&&s.push(i);s.length&&La(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Q[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=Q[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}const Fa=new Set(["opacity","clipPath","filter","transform"]);function Oi(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(s=>s!=null)}const Ni=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Ue(t){return Gs(t)&&"offsetHeight"in t}const{schedule:mn}=ri(queueMicrotask,!1),$={x:!1,y:!1};function Ui(){return $.x||$.y}function Ia(t){return t==="x"||t==="y"?$[t]?null:($[t]=!0,()=>{$[t]=!1}):$.x||$.y?null:($.x=$.y=!0,()=>{$.x=$.y=!1})}function Wi(t,e){const n=Oi(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Ba(t){return!(t.pointerType==="touch"||Ui())}function ja(t,e,n={}){const[s,i,r]=Wi(t,n);return s.forEach(o=>{let a=!1,c=!1,u;const l=()=>{o.removeEventListener("pointerleave",p)},f=y=>{u&&(u(y),u=void 0),l()},h=y=>{a=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),c&&(c=!1,f(y))},d=()=>{a=!0,window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",h,i)},p=y=>{if(y.pointerType!=="touch"){if(a){c=!0;return}f(y)}},m=y=>{if(!Ba(y))return;c=!1;const v=e(o,y);typeof v=="function"&&(u=v,o.addEventListener("pointerleave",p,i))};o.addEventListener("pointerenter",m,i),o.addEventListener("pointerdown",d,i)}),r}const Ki=(t,e)=>e?t===e?!0:Ki(t,e.parentElement):!1,gn=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Oa=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Na(t){return Oa.has(t.tagName)||t.isContentEditable===!0}const Ua=new Set(["INPUT","SELECT","TEXTAREA"]);function Wa(t){return Ua.has(t.tagName)||t.isContentEditable===!0}const Kt=new WeakSet;function Hn(t){return e=>{e.key==="Enter"&&t(e)}}function fe(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Ka=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Hn(()=>{if(Kt.has(n))return;fe(n,"down");const i=Hn(()=>{fe(n,"up")}),r=()=>fe(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function zn(t){return gn(t)&&!Ui()}const Gn=new WeakSet;function $a(t,e,n={}){const[s,i,r]=Wi(t,n),o=a=>{const c=a.currentTarget;if(!zn(a)||Gn.has(a))return;Kt.add(c),n.stopPropagation&&Gn.add(a);const u=e(c,a),l=(d,p)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),Kt.has(c)&&Kt.delete(c),zn(d)&&typeof u=="function"&&u(d,{success:p})},f=d=>{l(d,c===window||c===document||n.useGlobalTarget||Ki(c,d.target))},h=d=>{l(d,!1)};window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",h,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Ue(a)&&(a.addEventListener("focus",u=>Ka(u,i)),!Na(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function yn(t){return Gs(t)&&"ownerSVGElement"in t}const $t=new WeakMap;let Ht;const $i=(t,e,n)=>(s,i)=>i&&i[0]?i[0][t+"Size"]:yn(s)&&"getBBox"in s?s.getBBox()[e]:s[n],Ha=$i("inline","width","offsetWidth"),za=$i("block","height","offsetHeight");function Ga({target:t,borderBoxSize:e}){$t.get(t)?.forEach(n=>{n(t,{get width(){return Ha(t,e)},get height(){return za(t,e)}})})}function _a(t){t.forEach(Ga)}function Xa(){typeof ResizeObserver>"u"||(Ht=new ResizeObserver(_a))}function Ya(t,e){Ht||Xa();const n=Oi(t);return n.forEach(s=>{let i=$t.get(s);i||(i=new Set,$t.set(s,i)),i.add(e),Ht?.observe(s)}),()=>{n.forEach(s=>{const i=$t.get(s);i?.delete(e),i?.size||Ht?.unobserve(s)})}}const zt=new Set;let ft;function qa(){ft=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};zt.forEach(e=>e(t))},window.addEventListener("resize",ft)}function Za(t){return zt.add(t),ft||qa(),()=>{zt.delete(t),!zt.size&&typeof ft=="function"&&(window.removeEventListener("resize",ft),ft=void 0)}}function _n(t,e){return typeof t=="function"?Za(t):Ya(t,e)}function Ja(t){return yn(t)&&t.tagName==="svg"}const Qa=[...Ii,R,z],tl=t=>Qa.find(Fi(t)),Xn=()=>({translate:0,scale:1,origin:0,originPoint:0}),dt=()=>({x:Xn(),y:Xn()}),Yn=()=>({min:0,max:0}),k=()=>({x:Yn(),y:Yn()}),el=new WeakMap;function se(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Et(t){return typeof t=="string"||Array.isArray(t)}const vn=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Tn=["initial",...vn];function ie(t){return se(t.animate)||Tn.some(e=>Et(t[e]))}function Hi(t){return!!(ie(t)||t.variants)}function nl(t,e,n){for(const s in e){const i=e[s],r=n[s];if(B(i))t.addValue(s,i);else if(B(r))t.addValue(s,yt(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,yt(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const We={current:null},zi={current:!1},sl=typeof window<"u";function il(){if(zi.current=!0,!!sl)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>We.current=t.matches;t.addEventListener("change",e),e()}else We.current=!1}const qn=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Jt={};function Gi(t){Jt=t}function ol(){return Jt}class rl{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,skipAnimations:r,blockInitialAnimation:o,visualState:a},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=cn,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const d=j.now();this.renderScheduledAt<d&&(this.renderScheduledAt=d,C.render(this.render,!1,!0))};const{latestValues:u,renderState:l}=a;this.latestValues=u,this.baseTarget={...u},this.initialValues=n.initial?{...u}:{},this.renderState=l,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=r,this.options=c,this.blockInitialAnimation=!!o,this.isControllingVariants=ie(n),this.isVariantNode=Hi(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:f,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const d in h){const p=h[d];u[d]!==void 0&&B(p)&&p.set(u[d])}}mount(e){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=e,el.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(zi.current||il(),this.shouldReduceMotion=We.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),tt(this.notifyUpdate),tt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&Fa.has(e)&&this.current instanceof HTMLElement){const{factory:o,keyframes:a,times:c,ease:u,duration:l}=n.accelerate,f=new Ai({element:this.current,name:e,keyframes:a,times:c,ease:u,duration:H(l)}),h=o(f);this.valueSubscriptions.set(e,()=>{h(),f.cancel()});return}const s=xt.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&C.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;typeof window<"u"&&window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Jt){const n=Jt[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):k()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<qn.length;s++){const i=qn[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=nl(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=yt(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(zs(s)||_s(s))?s=parseFloat(s):!tl(s)&&z.test(n)&&(s=ji(e,n)),this.setBaseTarget(e,B(s)?s.get():s)),B(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=fn(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!B(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Ze),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){mn.render(this.render)}}class _i extends rl{constructor(){super(...arguments),this.KeyframeResolver=ka}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const s=e.style;return s?s[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;B(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class et{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Xi({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function al({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function ll(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function de(t){return t===void 0||t===1}function Ke({scale:t,scaleX:e,scaleY:n}){return!de(t)||!de(e)||!de(n)}function ot(t){return Ke(t)||Yi(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Yi(t){return Zn(t.x)||Zn(t.y)}function Zn(t){return t&&t!=="0%"}function Qt(t,e,n){const s=t-n,i=e*s;return n+i}function Jn(t,e,n,s,i){return i!==void 0&&(t=Qt(t,i,s)),Qt(t,n,s)+e}function $e(t,e=0,n=1,s,i){t.min=Jn(t.min,e,n,s,i),t.max=Jn(t.max,e,n,s,i)}function qi(t,{x:e,y:n}){$e(t.x,e.translate,e.scale,e.originPoint),$e(t.y,n.translate,n.scale,n.originPoint)}const Qn=.999999999999,ts=1.0000000000001;function cl(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:c}=r.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&mt(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,qi(t,o)),s&&ot(r.latestValues)&&mt(t,r.latestValues))}e.x<ts&&e.x>Qn&&(e.x=1),e.y<ts&&e.y>Qn&&(e.y=1)}function pt(t,e){t.min=t.min+e,t.max=t.max+e}function es(t,e,n,s,i=.5){const r=D(t.min,t.max,i);$e(t,e,n,r,s)}function ns(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function mt(t,e){es(t.x,ns(e.x,t.x),e.scaleX,e.scale,e.originX),es(t.y,ns(e.y,t.y),e.scaleY,e.scale,e.originY)}function Zi(t,e){return Xi(ll(t.getBoundingClientRect(),e))}function ul(t,e,n){const s=Zi(t,n),{scroll:i}=e;return i&&(pt(s.x,i.offset.x),pt(s.y,i.offset.y)),s}const hl={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fl=Tt.length;function dl(t,e,n){let s="",i=!0;for(let r=0;r<fl;r++){const o=Tt[r],a=t[o];if(a===void 0)continue;let c=!0;if(typeof a=="number")c=a===(o.startsWith("scale")?1:0);else{const u=parseFloat(a);c=o.startsWith("scale")?u===1:u===0}if(!c||n){const u=Ni(a,pn[o]);if(!c){i=!1;const l=hl[o]||o;s+=`${l}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function xn(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const c in e){const u=e[c];if(xt.has(c)){o=!0;continue}else if(li(c)){i[c]=u;continue}else{const l=Ni(u,pn[c]);c.startsWith("origin")?(a=!0,r[c]=l):s[c]=l}}if(e.transform||(o||n?s.transform=dl(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=r;s.transformOrigin=`${c} ${u} ${l}`}}function Ji(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function ss(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const wt={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(w.test(t))t=parseFloat(t);else return t;const n=ss(t,e.target.x),s=ss(t,e.target.y);return`${n}% ${s}%`}},pl={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=z.parse(t);if(i.length>5)return s;const r=z.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=c;const u=D(a,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}},He={borderRadius:{...wt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:wt,borderTopRightRadius:wt,borderBottomLeftRadius:wt,borderBottomRightRadius:wt,boxShadow:pl};function Qi(t,{layout:e,layoutId:n}){return xt.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!He[t]||t==="opacity")}function wn(t,e,n){const s=t.style,i=e?.style,r={};if(!s)return r;for(const o in s)(B(s[o])||i&&B(i[o])||Qi(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}function ml(t){return window.getComputedStyle(t)}class gl extends _i{constructor(){super(...arguments),this.type="html",this.renderInstance=Ji}readValueFromInstance(e,n){if(xt.has(n))return this.projection?.isProjecting?De(n):Ir(e,n);{const s=ml(e),i=(li(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Zi(e,n)}build(e,n,s){xn(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return wn(e,n,s)}}const yl={offset:"stroke-dashoffset",array:"stroke-dasharray"},vl={offset:"strokeDashoffset",array:"strokeDasharray"};function Tl(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?yl:vl;t[r.offset]=`${-s}`,t[r.array]=`${e} ${n}`}const xl=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function to(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},c,u,l){if(xn(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:h}=t;f.transform&&(h.transform=f.transform,delete f.transform),(h.transform||f.transformOrigin)&&(h.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),h.transform&&(h.transformBox=l?.transformBox??"fill-box",delete f.transformBox);for(const d of xl)f[d]!==void 0&&(h[d]=f[d],delete f[d]);e!==void 0&&(f.x=e),n!==void 0&&(f.y=n),s!==void 0&&(f.scale=s),i!==void 0&&Tl(f,i,r,o,!1)}const eo=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),no=t=>typeof t=="string"&&t.toLowerCase()==="svg";function wl(t,e,n,s){Ji(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(eo.has(i)?i:dn(i),e.attrs[i])}function so(t,e,n){const s=wn(t,e,n);for(const i in t)if(B(t[i])||B(e[i])){const r=Tt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}class Pl extends _i{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=k}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(xt.has(n)){const s=Bi(n);return s&&s.default||0}return n=eo.has(n)?n:dn(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return so(e,n,s)}build(e,n,s){to(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){wl(e,n,s,i)}mount(e){this.isSVGTag=no(e.tagName),super.mount(e)}}const Sl=Tn.length;function io(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?io(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Sl;n++){const s=Tn[n],i=t.props[s];(Et(i)||i===!1)&&(e[s]=i)}return e}function oo(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const bl=[...vn].reverse(),Al=vn.length;function Vl(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Pa(t,n,s)))}function Cl(t){let e=Vl(t),n=is(),s=!0,i=!1;const r=u=>(l,f)=>{const h=gt(t,f,u==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:d,transitionEnd:p,...m}=h;l={...l,...m,...p}}return l};function o(u){e=u(t)}function a(u){const{props:l}=t,f=io(t.parent)||{},h=[],d=new Set;let p={},m=1/0;for(let v=0;v<Al;v++){const T=bl[v],g=n[T],P=l[T]!==void 0?l[T]:f[T],S=Et(P),V=T===u?g.isActive:null;V===!1&&(m=v);let M=P===f[T]&&P!==l[T]&&S;if(M&&(s||i)&&t.manuallyAnimateOnMount&&(M=!1),g.protectedKeys={...p},!g.isActive&&V===null||!P&&!g.prevProp||se(P)||typeof P=="boolean")continue;if(T==="exit"&&g.isActive&&V!==!0){g.prevResolvedValues&&(p={...p,...g.prevResolvedValues});continue}const b=Ml(g.prevProp,P);let A=b||T===u&&g.isActive&&!M&&S||v>m&&S,L=!1;const nt=Array.isArray(P)?P:[P];let Z=nt.reduce(r(T),{});V===!1&&(Z={});const{prevResolvedValues:Bt={}}=g,Eo={...Bt,...Z},An=F=>{A=!0,d.has(F)&&(L=!0,d.delete(F)),g.needsAnimating[F]=!0;const N=t.getValue(F);N&&(N.liveStyle=!1)};for(const F in Eo){const N=Z[F],st=Bt[F];if(p.hasOwnProperty(F))continue;let ct=!1;Ie(N)&&Ie(st)?ct=!oo(N,st):ct=N!==st,ct?N!=null?An(F):d.add(F):N!==void 0&&d.has(F)?An(F):g.protectedKeys[F]=!0}g.prevProp=P,g.prevResolvedValues=Z,g.isActive&&(p={...p,...Z}),(s||i)&&t.blockInitialAnimation&&(A=!1);const Vn=M&&b;A&&(!Vn||L)&&h.push(...nt.map(F=>{const N={type:T};if(typeof F=="string"&&(s||i)&&!Vn&&t.manuallyAnimateOnMount&&t.parent){const{parent:st}=t,ct=gt(st,F);if(st.enteringChildren&&ct){const{delayChildren:Ro}=ct.transition||{};N.delay=Ci(st.enteringChildren,t,Ro)}}return{animation:F,options:N}}))}if(d.size){const v={};if(typeof l.initial!="boolean"){const T=gt(t,Array.isArray(l.initial)?l.initial[0]:l.initial);T&&T.transition&&(v.transition=T.transition)}d.forEach(T=>{const g=t.getBaseTarget(T),P=t.getValue(T);P&&(P.liveStyle=!0),v[T]=g??null}),h.push({animation:v})}let y=!!h.length;return s&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(y=!1),s=!1,i=!1,y?e(h):Promise.resolve()}function c(u,l){if(n[u].isActive===l)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(u,l)),n[u].isActive=l;const f=a(u);for(const h in n)n[h].protectedKeys={};return f}return{animateChanges:a,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=is(),i=!0}}}function Ml(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!oo(e,t):!1}function it(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function is(){return{animate:it(!0),whileInView:it(),whileHover:it(),whileTap:it(),whileDrag:it(),whileFocus:it(),exit:it()}}function os(t,e){t.min=e.min,t.max=e.max}function K(t,e){os(t.x,e.x),os(t.y,e.y)}function rs(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const ro=1e-4,Dl=1-ro,El=1+ro,ao=.01,Rl=0-ao,Ll=0+ao;function O(t){return t.max-t.min}function kl(t,e,n){return Math.abs(t-e)<=n}function as(t,e,n,s=.5){t.origin=s,t.originPoint=D(e.min,e.max,t.origin),t.scale=O(n)/O(e),t.translate=D(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Dl&&t.scale<=El||isNaN(t.scale))&&(t.scale=1),(t.translate>=Rl&&t.translate<=Ll||isNaN(t.translate))&&(t.translate=0)}function At(t,e,n,s){as(t.x,e.x,n.x,s?s.originX:void 0),as(t.y,e.y,n.y,s?s.originY:void 0)}function ls(t,e,n){t.min=n.min+e.min,t.max=t.min+O(e)}function Fl(t,e,n){ls(t.x,e.x,n.x),ls(t.y,e.y,n.y)}function cs(t,e,n){t.min=e.min-n.min,t.max=t.min+O(e)}function te(t,e,n){cs(t.x,e.x,n.x),cs(t.y,e.y,n.y)}function us(t,e,n,s,i){return t-=e,t=Qt(t,1/n,s),i!==void 0&&(t=Qt(t,1/i,s)),t}function Il(t,e=0,n=1,s=.5,i,r=t,o=t){if(_.test(e)&&(e=parseFloat(e),e=D(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=D(r.min,r.max,s);t===r&&(a-=e),t.min=us(t.min,e,n,a,i),t.max=us(t.max,e,n,a,i)}function hs(t,e,[n,s,i],r,o){Il(t,e[n],e[s],e[i],e.scale,r,o)}const Bl=["x","scaleX","originX"],jl=["y","scaleY","originY"];function fs(t,e,n,s){hs(t.x,e,Bl,n?n.x:void 0,s?s.x:void 0),hs(t.y,e,jl,n?n.y:void 0,s?s.y:void 0)}function ds(t){return t.translate===0&&t.scale===1}function lo(t){return ds(t.x)&&ds(t.y)}function ps(t,e){return t.min===e.min&&t.max===e.max}function Ol(t,e){return ps(t.x,e.x)&&ps(t.y,e.y)}function ms(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function co(t,e){return ms(t.x,e.x)&&ms(t.y,e.y)}function gs(t){return O(t.x)/O(t.y)}function ys(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function G(t){return[t("x"),t("y")]}function Nl(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:f,rotateY:h,skewX:d,skewY:p}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),f&&(s+=`rotateX(${f}deg) `),h&&(s+=`rotateY(${h}deg) `),d&&(s+=`skewX(${d}deg) `),p&&(s+=`skewY(${p}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const uo=["TopLeft","TopRight","BottomLeft","BottomRight"],Ul=uo.length,vs=t=>typeof t=="string"?parseFloat(t):t,Ts=t=>typeof t=="number"||w.test(t);function Wl(t,e,n,s,i,r){i?(t.opacity=D(0,n.opacity??1,Kl(s)),t.opacityExit=D(e.opacity??1,0,$l(s))):r&&(t.opacity=D(e.opacity??1,n.opacity??1,s));for(let o=0;o<Ul;o++){const a=`border${uo[o]}Radius`;let c=xs(e,a),u=xs(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||Ts(c)===Ts(u)?(t[a]=Math.max(D(vs(c),vs(u),s),0),(_.test(u)||_.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=D(e.rotate||0,n.rotate||0,s))}function xs(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Kl=ho(0,.5,ni),$l=ho(.5,.95,W);function ho(t,e,n){return s=>s<t?0:s>e?1:n(Ct(t,e,s))}function Hl(t,e,n){const s=B(t)?t:yt(t);return s.start(hn("",s,e,n)),s.animation}function Rt(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}const zl=(t,e)=>t.depth-e.depth;class Gl{constructor(){this.children=[],this.isDirty=!1}add(e){Ye(this.children,e),this.isDirty=!0}remove(e){Xt(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(zl),this.isDirty=!1,this.children.forEach(e)}}function _l(t,e){const n=j.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(tt(s),t(r-e))};return C.setup(s,!0),()=>tt(s)}function Gt(t){return B(t)?t.get():t}class Xl{constructor(){this.members=[]}add(e){Ye(this.members,e);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===e||s===this.lead||s===this.prevLead)continue;const i=s.instance;(!i||i.isConnected===!1)&&!s.snapshot&&(Xt(this.members,s),s.unmount())}e.scheduleRender()}remove(e){if(Xt(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){for(let n=this.members.indexOf(e)-1;n>=0;n--){const s=this.members[n];if(s.isPresent!==!1&&s.instance?.isConnected!==!1)return this.promote(s),!0}return!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=s.options,{layoutDependency:r}=e.options;(i===void 0||i!==r)&&(e.resumeFrom=s,n&&(s.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const _t={hasAnimatedSinceResize:!0,hasEverUpdated:!1},pe=["","X","Y","Z"],Yl=1e3;let ql=0;function me(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function fo(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Li(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",C,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&fo(s)}function po({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=ql++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Ql),this.nodes.forEach(sc),this.nodes.forEach(ic),this.nodes.forEach(tc)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Gl)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Ze),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const c=this.eventHandlers.get(o);c&&c.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=yn(o)&&!Ja(o),this.instance=o;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,f=0;const h=()=>this.root.updateBlockedByResize=!1;C.read(()=>{f=window.innerWidth}),t(o,()=>{const d=window.innerWidth;d!==f&&(f=d,this.root.updateBlockedByResize=!0,l&&l(),l=_l(h,250),_t.hasAnimatedSinceResize&&(_t.hasAnimatedSinceResize=!1,this.nodes.forEach(Ss)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:f,hasRelativeLayoutChanged:h,layout:d})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const p=this.options.transition||u.getDefaultTransition()||cc,{onLayoutAnimationStart:m,onLayoutAnimationComplete:y}=u.getProps(),v=!this.targetLayout||!co(this.targetLayout,d),T=!f&&h;if(this.options.layoutRoot||this.resumeFrom||T||f&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const g={...un(p,"layout"),onPlay:m,onComplete:y};(u.shouldReduceMotion||this.options.layoutRoot)&&(g.delay=0,g.type=!1),this.startAnimation(g),this.setAnimationOrigin(l,T)}else f||Ss(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=d})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),tt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(oc),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&fo(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const f=this.path[l];f.shouldResetTransform=!0,f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(ws);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ps);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(nc),this.nodes.forEach(Zl),this.nodes.forEach(Jl)):this.nodes.forEach(Ps),this.clearAllSnapshots();const a=j.now();I.delta=X(0,1e3/60,a-I.timestamp),I.timestamp=a,I.isProcessing=!0,re.update.process(I),re.preRender.process(I),re.render.process(I),I.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,mn.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ec),this.sharedNodes.forEach(rc)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,C.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){C.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!O(this.snapshot.measuredBox.x)&&!O(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=k(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!lo(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||ot(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return o&&(c=this.removeTransform(c)),uc(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return k();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(hc))){const{scroll:u}=this.root;u&&(pt(a.x,u.offset.x),pt(a.y,u.offset.y))}return a}removeElementScroll(o){const a=k();if(K(a,o),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:f}=u;u!==this.root&&l&&f.layoutScroll&&(l.wasRoot&&K(a,o),pt(a.x,l.offset.x),pt(a.y,l.offset.y))}return a}applyTransform(o,a=!1){const c=k();K(c,o);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&mt(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ot(l.latestValues)&&mt(c,l.latestValues)}return ot(this.latestValues)&&mt(c,this.latestValues),c}removeTransform(o){const a=k();K(a,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ot(u.latestValues))continue;Ke(u.latestValues)&&u.updateSnapshot();const l=k(),f=u.measurePageBox();K(l,f),fs(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ot(this.latestValues)&&fs(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==I.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(o||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:f}=this.options;if(!this.layout||!(l||f))return;this.resolvedRelativeTargetAt=I.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=k(),this.targetWithTransforms=k()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Fl(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):K(this.target,this.layout.layoutBox),qi(this.target,this.targetDelta)):K(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Ke(this.parent.latestValues)||Yi(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,a,c){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=k(),this.relativeTargetOrigin=k(),te(this.relativeTargetOrigin,a,c),K(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===I.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;K(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,h=this.treeScale.y;cl(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=k());const{target:d}=o;if(!d){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(rs(this.prevProjectionDelta.x,this.projectionDelta.x),rs(this.prevProjectionDelta.y,this.projectionDelta.y)),At(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==h||!ys(this.projectionDelta.x,this.prevProjectionDelta.x)||!ys(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",d))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=dt(),this.projectionDelta=dt(),this.projectionDeltaWithTransform=dt()}setAnimationOrigin(o,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},f=dt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const h=k(),d=c?c.source:void 0,p=this.layout?this.layout.source:void 0,m=d!==p,y=this.getStack(),v=!y||y.members.length<=1,T=!!(m&&!v&&this.options.crossfade===!0&&!this.path.some(lc));this.animationProgress=0;let g;this.mixTargetDelta=P=>{const S=P/1e3;bs(f.x,o.x,S),bs(f.y,o.y,S),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(te(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ac(this.relativeTarget,this.relativeTargetOrigin,h,S),g&&Ol(this.relativeTarget,g)&&(this.isProjectionDirty=!1),g||(g=k()),K(g,this.relativeTarget)),m&&(this.animationValues=l,Wl(l,u,this.latestValues,S,T,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=S},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(tt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=C.update(()=>{_t.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=yt(0)),this.motionValue.jump(0,!1),this.currentAnimation=Hl(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Yl),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=o;if(!(!a||!c||!u)){if(this!==o&&this.layout&&u&&mo(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||k();const f=O(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+f;const h=O(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+h}K(a,c),mt(a,l),At(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Xl),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&me("z",o,u,this.animationValues);for(let l=0;l<pe.length;l++)me(`rotate${pe[l]}`,o,u,this.animationValues),me(`skew${pe[l]}`,o,u,this.animationValues);o.render();for(const l in u)o.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Gt(a?.pointerEvents)||"",o.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Gt(a?.pointerEvents)||""),this.hasProjected&&!ot(this.latestValues)&&(o.transform=c?c({},""):"none",this.hasProjected=!1);return}o.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let f=Nl(this.projectionDeltaWithTransform,this.treeScale,l);c&&(f=c(l,f)),o.transform=f;const{x:h,y:d}=this.projectionDelta;o.transformOrigin=`${h.origin*100}% ${d.origin*100}% 0`,u.animationValues?o.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:o.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const p in He){if(l[p]===void 0)continue;const{correct:m,applyTo:y,isCSSVariable:v}=He[p],T=f==="none"?l[p]:m(l[p],u);if(y){const g=y.length;for(let P=0;P<g;P++)o[y[P]]=T}else v?this.options.visualElement.renderState.vars[p]=T:o[p]=T}this.options.layoutId&&(o.pointerEvents=u===this?Gt(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(ws),this.root.sharedNodes.clear()}}}function Zl(t){t.updateLayout()}function Jl(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,r=e.source!==t.layout.source;i==="size"?G(l=>{const f=r?e.measuredBox[l]:e.layoutBox[l],h=O(f);f.min=n[l].min,f.max=f.min+h}):mo(i,e.layoutBox,n)&&G(l=>{const f=r?e.measuredBox[l]:e.layoutBox[l],h=O(n[l]);f.max=f.min+h,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+h)});const o=dt();At(o,n,e.layoutBox);const a=dt();r?At(a,t.applyTransform(s,!0),e.measuredBox):At(a,n,e.layoutBox);const c=!lo(o);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:f,layout:h}=l;if(f&&h){const d=k();te(d,e.layoutBox,f.layoutBox);const p=k();te(p,n,h.layoutBox),co(d,p)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=p,t.relativeTargetOrigin=d,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Ql(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function tc(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ec(t){t.clearSnapshot()}function ws(t){t.clearMeasurements()}function Ps(t){t.isLayoutDirty=!1}function nc(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Ss(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function sc(t){t.resolveTargetDelta()}function ic(t){t.calcProjection()}function oc(t){t.resetSkewAndRotation()}function rc(t){t.removeLeadSnapshot()}function bs(t,e,n){t.translate=D(e.translate,0,n),t.scale=D(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function As(t,e,n,s){t.min=D(e.min,n.min,s),t.max=D(e.max,n.max,s)}function ac(t,e,n,s){As(t.x,e.x,n.x,s),As(t.y,e.y,n.y,s)}function lc(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const cc={duration:.45,ease:[.4,0,.1,1]},Vs=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Cs=Vs("applewebkit/")&&!Vs("chrome/")?Math.round:W;function Ms(t){t.min=Cs(t.min),t.max=Cs(t.max)}function uc(t){Ms(t.x),Ms(t.y)}function mo(t,e,n){return t==="position"||t==="preserve-aspect"&&!kl(gs(e),gs(n),.2)}function hc(t){return t!==t.root&&t.scroll?.wasRoot}const fc=po({attachResizeListener:(t,e)=>Rt(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ge={current:void 0},go=po({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!ge.current){const t=new fc({});t.mount(window),t.setOptions({layoutScroll:!0}),ge.current=t}return ge.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Pn=x.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Ds(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function dc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=Ds(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():Ds(t[i],null)}}}}function pc(...t){return x.useCallback(dc(...t),t)}class mc extends x.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,i=Ue(s)&&s.offsetWidth||0,r=Ue(s)&&s.offsetHeight||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left,o.bottom=r-o.height-o.top}return null}componentDidUpdate(){}render(){return this.props.children}}function gc({children:t,isPresent:e,anchorX:n,anchorY:s,root:i,pop:r}){const o=x.useId(),a=x.useRef(null),c=x.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:u}=x.useContext(Pn),l=t.props?.ref??t?.ref,f=pc(a,l);return x.useInsertionEffect(()=>{const{width:h,height:d,top:p,left:m,right:y,bottom:v}=c.current;if(e||r===!1||!a.current||!h||!d)return;const T=n==="left"?`left: ${m}`:`right: ${y}`,g=s==="bottom"?`bottom: ${v}`:`top: ${p}`;a.current.dataset.motionPopId=o;const P=document.createElement("style");u&&(P.nonce=u);const S=i??document.head;return S.appendChild(P),P.sheet&&P.sheet.insertRule(`
2
- [data-motion-pop-id="${o}"] {
3
- position: absolute !important;
4
- width: ${h}px !important;
5
- height: ${d}px !important;
6
- ${T}px !important;
7
- ${g}px !important;
8
- }
9
- `),()=>{S.contains(P)&&S.removeChild(P)}},[e]),Y.jsx(mc,{isPresent:e,childRef:a,sizeRef:c,pop:r,children:r===!1?t:x.cloneElement(t,{ref:f})})}const yc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,anchorY:c,root:u})=>{const l=Xe(vc),f=x.useId();let h=!0,d=x.useMemo(()=>(h=!1,{id:f,initial:e,isPresent:n,custom:i,onExitComplete:p=>{l.set(p,!0);for(const m of l.values())if(!m)return;s&&s()},register:p=>(l.set(p,!1),()=>l.delete(p))}),[n,l,s]);return r&&h&&(d={...d}),x.useMemo(()=>{l.forEach((p,m)=>l.set(m,!1))},[n]),x.useEffect(()=>{!n&&!l.size&&s&&s()},[n]),t=Y.jsx(gc,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:c,root:u,children:t}),Y.jsx(ne.Provider,{value:d,children:t})};function vc(){return new Map}function yo(t=!0){const e=x.useContext(ne);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=x.useId();x.useEffect(()=>{if(t)return i(r)},[t]);const o=x.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const Nt=t=>t.key||"";function Es(t){const e=[];return x.Children.forEach(t,n=>{x.isValidElement(n)&&e.push(n)}),e}const Du=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[l,f]=yo(o),h=x.useMemo(()=>Es(t),[t]),d=o&&!l?[]:h.map(Nt),p=x.useRef(!0),m=x.useRef(h),y=Xe(()=>new Map),v=x.useRef(new Set),[T,g]=x.useState(h),[P,S]=x.useState(h);Hs(()=>{p.current=!1,m.current=h;for(let b=0;b<P.length;b++){const A=Nt(P[b]);d.includes(A)?(y.delete(A),v.current.delete(A)):y.get(A)!==!0&&y.set(A,!1)}},[P,d.length,d.join("-")]);const V=[];if(h!==T){let b=[...h];for(let A=0;A<P.length;A++){const L=P[A],nt=Nt(L);d.includes(nt)||(b.splice(A,0,L),V.push(L))}return r==="wait"&&V.length&&(b=V),S(Es(b)),g(h),null}const{forceRender:M}=x.useContext(_e);return Y.jsx(Y.Fragment,{children:P.map(b=>{const A=Nt(b),L=o&&!l?!1:h===P||d.includes(A),nt=()=>{if(v.current.has(A))return;if(v.current.add(A),y.has(A))y.set(A,!0);else return;let Z=!0;y.forEach(Bt=>{Bt||(Z=!1)}),Z&&(M?.(),S(m.current),o&&f?.(),s&&s())};return Y.jsx(yc,{isPresent:L,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:u,onExitComplete:L?void 0:nt,anchorX:a,anchorY:c,children:b},A)})})},vo=x.createContext({strict:!1}),Rs={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Ls=!1;function Tc(){if(Ls)return;const t={};for(const e in Rs)t[e]={isEnabled:n=>Rs[e].some(s=>!!n[s])};Gi(t),Ls=!0}function To(){return Tc(),ol()}function xc(t){const e=To();for(const n in t)e[n]={...e[n],...t[n]};Gi(e)}const wc=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function ee(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||wc.has(t)}let xo=t=>!ee(t);function Pc(t){typeof t=="function"&&(xo=e=>e.startsWith("on")?!ee(e):t(e))}try{Pc(require("@emotion/is-prop-valid").default)}catch{}function Sc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(xo(i)||n===!0&&ee(i)||!e&&!ee(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const oe=x.createContext({});function bc(t,e){if(ie(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Et(n)?n:void 0,animate:Et(s)?s:void 0}}return t.inherit!==!1?e:{}}function Ac(t){const{initial:e,animate:n}=bc(t,x.useContext(oe));return x.useMemo(()=>({initial:e,animate:n}),[ks(e),ks(n)])}function ks(t){return Array.isArray(t)?t.join(" "):t}const Sn=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function wo(t,e,n){for(const s in e)!B(e[s])&&!Qi(s,n)&&(t[s]=e[s])}function Vc({transformTemplate:t},e){return x.useMemo(()=>{const n=Sn();return xn(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Cc(t,e){const n=t.style||{},s={};return wo(s,n,t),Object.assign(s,Vc(t,e)),s}function Mc(t,e){const n={},s=Cc(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const Po=()=>({...Sn(),attrs:{}});function Dc(t,e,n,s){const i=x.useMemo(()=>{const r=Po();return to(r,e,no(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};wo(r,t.style,t),i.style={...r,...i.style}}return i}const Ec=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function bn(t){return typeof t!="string"||t.includes("-")?!1:!!(Ec.indexOf(t)>-1||/[A-Z]/u.test(t))}function Rc(t,e,n,{latestValues:s},i,r=!1,o){const c=(o??bn(t)?Dc:Mc)(e,s,i,t),u=Sc(e,typeof t=="string",r),l=t!==x.Fragment?{...u,...c,ref:n}:{},{children:f}=e,h=x.useMemo(()=>B(f)?f.get():f,[f]);return x.createElement(t,{...l,children:h})}function Lc({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:kc(n,s,i,t),renderState:e()}}function kc(t,e,n,s){const i={},r=s(t,{});for(const h in r)i[h]=Gt(r[h]);let{initial:o,animate:a}=t;const c=ie(t),u=Hi(t);e&&u&&!c&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||o===!1;const f=l?a:o;if(f&&typeof f!="boolean"&&!se(f)){const h=Array.isArray(f)?f:[f];for(let d=0;d<h.length;d++){const p=fn(t,h[d]);if(p){const{transitionEnd:m,transition:y,...v}=p;for(const T in v){let g=v[T];if(Array.isArray(g)){const P=l?g.length-1:0;g=g[P]}g!==null&&(i[T]=g)}for(const T in m)i[T]=m[T]}}}return i}const So=t=>(e,n)=>{const s=x.useContext(oe),i=x.useContext(ne),r=()=>Lc(t,e,s,i);return n?r():Xe(r)},Fc=So({scrapeMotionValuesFromProps:wn,createRenderState:Sn}),Ic=So({scrapeMotionValuesFromProps:so,createRenderState:Po}),Bc=Symbol.for("motionComponentSymbol");function jc(t,e,n){const s=x.useRef(n);x.useInsertionEffect(()=>{s.current=n});const i=x.useRef(null);return x.useCallback(r=>{r&&t.onMount?.(r);const o=s.current;if(typeof o=="function")if(r){const a=o(r);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):o(r);else o&&(o.current=r);e&&(r?e.mount(r):e.unmount())},[e])}const bo=x.createContext({});function ut(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Oc(t,e,n,s,i,r){const{visualElement:o}=x.useContext(oe),a=x.useContext(vo),c=x.useContext(ne),u=x.useContext(Pn),l=u.reducedMotion,f=u.skipAnimations,h=x.useRef(null),d=x.useRef(!1);s=s||a.renderer,!h.current&&s&&(h.current=s(t,{visualState:e,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:l,skipAnimations:f,isSVG:r}),d.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const p=h.current,m=x.useContext(bo);p&&!p.projection&&i&&(p.type==="html"||p.type==="svg")&&Nc(h.current,n,i,m);const y=x.useRef(!1);x.useInsertionEffect(()=>{p&&y.current&&p.update(n,c)});const v=n[Ri],T=x.useRef(!!v&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return Hs(()=>{d.current=!0,p&&(y.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),T.current&&p.animationState&&p.animationState.animateChanges())}),x.useEffect(()=>{p&&(!T.current&&p.animationState&&p.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),T.current=!1),p.enteringChildren=void 0)}),p}function Nc(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Ao(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&ut(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Ao(t){if(t)return t.options.allowProjection!==!1?t.projection:Ao(t.parent)}function ye(t,{forwardMotionProps:e=!1,type:n}={},s,i){s&&xc(s);const r=n?n==="svg":bn(t),o=r?Ic:Fc;function a(u,l){let f;const h={...x.useContext(Pn),...u,layoutId:Uc(u)},{isStatic:d}=h,p=Ac(u),m=o(u,d);if(!d&&typeof window<"u"){Wc();const y=Kc(h);f=y.MeasureLayout,p.visualElement=Oc(t,m,h,i,y.ProjectionNode,r)}return Y.jsxs(oe.Provider,{value:p,children:[f&&p.visualElement?Y.jsx(f,{visualElement:p.visualElement,...h}):null,Rc(t,u,jc(m,p.visualElement,l),m,d,e,r)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=x.forwardRef(a);return c[Bc]=t,c}function Uc({layoutId:t}){const e=x.useContext(_e).id;return e&&t!==void 0?e+"-"+t:t}function Wc(t,e){x.useContext(vo).strict}function Kc(t){const e=To(),{drag:n,layout:s}=e;if(!n&&!s)return{};const i={...n,...s};return{MeasureLayout:n?.isEnabled(t)||s?.isEnabled(t)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function $c(t,e){if(typeof Proxy>"u")return ye;const n=new Map,s=(r,o)=>ye(r,o,t,e),i=(r,o)=>s(r,o);return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,ye(o,void 0,t,e)),n.get(o))})}const Hc=(t,e)=>e.isSVG??bn(t)?new Pl(e):new gl(e,{allowProjection:t!==x.Fragment});class zc extends et{constructor(e){super(e),e.animationState||(e.animationState=Cl(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();se(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Gc=0;class _c extends et{constructor(){super(...arguments),this.id=Gc++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Xc={animation:{Feature:zc},exit:{Feature:_c}};function It(t){return{point:{x:t.pageX,y:t.pageY}}}const Yc=t=>e=>gn(e)&&t(e,It(e));function Vt(t,e,n,s){return Rt(t,e,Yc(n),s)}const Vo=({current:t})=>t?t.ownerDocument.defaultView:null,Fs=(t,e)=>Math.abs(t-e);function qc(t,e){const n=Fs(t.x,e.x),s=Fs(t.y,e.y);return Math.sqrt(n**2+s**2)}const Is=new Set(["auto","scroll"]);class Co{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=d=>{this.handleScroll(d.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const d=Te(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,m=qc(d.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!m)return;const{point:y}=d,{timestamp:v}=I;this.history.push({...y,timestamp:v});const{onStart:T,onMove:g}=this.handlers;p||(T&&T(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),g&&g(this.lastMoveEvent,d)},this.handlePointerMove=(d,p)=>{this.lastMoveEvent=d,this.lastMoveEventInfo=ve(p,this.transformPagePoint),C.update(this.updatePoint,!0)},this.handlePointerUp=(d,p)=>{this.end();const{onEnd:m,onSessionEnd:y,resumeAnimation:v}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&v&&v(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const T=Te(d.type==="pointercancel"?this.lastMoveEventInfo:ve(p,this.transformPagePoint),this.history);this.startEvent&&m&&m(d,T),y&&y(d,T)},!gn(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const c=It(e),u=ve(c,this.transformPagePoint),{point:l}=u,{timestamp:f}=I;this.history=[{...l,timestamp:f}];const{onSessionStart:h}=n;h&&h(e,Te(u,this.history)),this.removeListeners=Lt(Vt(this.contextWindow,"pointermove",this.handlePointerMove),Vt(this.contextWindow,"pointerup",this.handlePointerUp),Vt(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let n=e.parentElement;for(;n;){const s=getComputedStyle(n);(Is.has(s.overflowX)||Is.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const s=e===window,i=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},r={x:i.x-n.x,y:i.y-n.y};r.x===0&&r.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=r.x,this.lastMoveEventInfo.point.y+=r.y):this.history.length>0&&(this.history[0].x-=r.x,this.history[0].y-=r.y),this.scrollPositions.set(e,i),C.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),tt(this.updatePoint)}}function ve(t,e){return e?{point:e(t.point)}:t}function Bs(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Te({point:t},e){return{point:t,delta:Bs(t,Mo(e)),offset:Bs(t,Zc(e)),velocity:Jc(e,.1)}}function Zc(t){return t[0]}function Mo(t){return t[t.length-1]}function Jc(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Mo(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>H(e)));)n--;if(!s)return{x:0,y:0};s===t[0]&&t.length>2&&i.timestamp-s.timestamp>H(e)*2&&(s=t[1]);const r=U(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Qc(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?D(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?D(n,t,s.max):Math.min(t,n)),t}function js(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function tu(t,{top:e,left:n,bottom:s,right:i}){return{x:js(t.x,n,i),y:js(t.y,e,s)}}function Os(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function eu(t,e){return{x:Os(t.x,e.x),y:Os(t.y,e.y)}}function nu(t,e){let n=.5;const s=O(t),i=O(e);return i>s?n=Ct(e.min,e.max-s,t.min):s>i&&(n=Ct(t.min,t.max-i,e.min)),X(0,1,n)}function su(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const ze=.35;function iu(t=ze){return t===!1?t=0:t===!0&&(t=ze),{x:Ns(t,"left","right"),y:Ns(t,"top","bottom")}}function Ns(t,e,n){return{min:Us(t,e),max:Us(t,n)}}function Us(t,e){return typeof t=="number"?t:t[e]||0}const ou=new WeakMap;class ru{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=k(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=f=>{n&&this.snapToCursor(It(f).point),this.stopAnimation()},o=(f,h)=>{const{drag:d,dragPropagation:p,onDragStart:m}=this.getProps();if(d&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ia(d),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),G(v=>{let T=this.getAxisMotionValue(v).get()||0;if(_.test(T)){const{projection:g}=this.visualElement;if(g&&g.layout){const P=g.layout.layoutBox[v];P&&(T=O(P)*(parseFloat(T)/100))}}this.originPoint[v]=T}),m&&C.update(()=>m(f,h),!1,!0),Be(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},a=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h;const{dragPropagation:d,dragDirectionLock:p,onDirectionLock:m,onDrag:y}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:v}=h;if(p&&this.currentDirection===null){this.currentDirection=lu(v),this.currentDirection!==null&&m&&m(this.currentDirection);return}this.updateAxis("x",h.point,v),this.updateAxis("y",h.point,v),this.visualElement.render(),y&&C.update(()=>y(f,h),!1,!0)},c=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h,this.stop(f,h),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Co(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:Vo(this.visualElement),element:this.visualElement.current})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&C.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,s){const{drag:i}=this.getProps();if(!s||!Ut(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=Qc(o,this.constraints[e],this.elastic[e])),r.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&ut(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=tu(s.layoutBox,e):this.constraints=!1,this.elastic=iu(n),i!==this.constraints&&!ut(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&G(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=su(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!ut(e))return!1;const s=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=ul(s,i.root,this.visualElement.getTransformPagePoint());let o=eu(i.layout.layoutBox,r);if(n){const a=n(al(o));this.hasMutatedConstraints=!!a,a&&(o=Xi(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=G(l=>{if(!Ut(l,n,this.currentDirection))return;let f=c&&c[l]||{};o&&(f={min:0,max:0});const h=i?200:1e6,d=i?40:1e7,p={type:"inertia",velocity:s?e[l]:0,bounceStiffness:h,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...r,...f};return this.startAxisValueAnimation(l,p)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Be(this.visualElement,e),s.start(hn(e,s,0,n,this.visualElement,!1))}stopAnimation(){G(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){G(n=>{const{drag:s}=this.getProps();if(!Ut(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n],c=r.get()||0;r.set(e[n]-D(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!ut(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};G(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=nu({min:c,max:c},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),G(o=>{if(!Ut(o,e,null))return;const a=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];a.set(D(c,u,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;ou.set(this.visualElement,this);const e=this.visualElement.current,n=Vt(e,"pointerdown",u=>{const{drag:l,dragListener:f=!0}=this.getProps(),h=u.target,d=h!==e&&Wa(h);l&&f&&!d&&this.start(u)});let s;const i=()=>{const{dragConstraints:u}=this.getProps();ut(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=au(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:r}=this.visualElement,o=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),C.read(i);const a=Rt(window,"resize",()=>this.scalePositionWithinConstraints()),c=r.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:l})=>{this.isDragging&&l&&(G(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=u[f].translate,h.set(h.get()+u[f].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),c&&c(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=ze,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Ws(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function au(t,e,n){const s=_n(t,Ws(n)),i=_n(e,Ws(n));return()=>{s(),i()}}function Ut(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function lu(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class cu extends et{constructor(e){super(e),this.removeGroupControls=W,this.removeListeners=W,this.controls=new ru(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||W}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xe=t=>(e,n)=>{t&&C.update(()=>t(e,n),!1,!0)};class uu extends et{constructor(){super(...arguments),this.removePointerDownListener=W}onPointerDown(e){this.session=new Co(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Vo(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:xe(e),onStart:xe(n),onMove:xe(s),onEnd:(r,o)=>{delete this.session,i&&C.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=Vt(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let we=!1;class hu extends x.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),we&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),_t.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,e.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),we=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||C.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),mn.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;we=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Do(t){const[e,n]=yo(),s=x.useContext(_e);return Y.jsx(hu,{...t,layoutGroup:s,switchLayoutGroup:x.useContext(bo),isPresent:e,safeToRemove:n})}const fu={pan:{Feature:uu},drag:{Feature:cu,ProjectionNode:go,MeasureLayout:Do}};function Ks(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&C.postRender(()=>r(e,It(e)))}class du extends et{mount(){const{current:e}=this.node;e&&(this.unmount=ja(e,(n,s)=>(Ks(this.node,s,"Start"),i=>Ks(this.node,i,"End"))))}unmount(){}}class pu extends et{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Lt(Rt(this.node.current,"focus",()=>this.onFocus()),Rt(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function $s(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&C.postRender(()=>r(e,It(e)))}class mu extends et{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=$a(e,(i,r)=>($s(this.node,r,"Start"),(o,{success:a})=>$s(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Ge=new WeakMap,Pe=new WeakMap,gu=t=>{const e=Ge.get(t.target);e&&e(t)},yu=t=>{t.forEach(gu)};function vu({root:t,...e}){const n=t||document;Pe.has(n)||Pe.set(n,{});const s=Pe.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(yu,{root:t,...e})),s[i]}function Tu(t,e,n){const s=vu(e);return Ge.set(t,n),s.observe(t),()=>{Ge.delete(t),s.unobserve(t)}}const xu={some:0,all:1};class wu extends et{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:xu[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:f}=this.node.getProps(),h=u?l:f;h&&h(c)};return Tu(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Pu(e,n))&&this.startObserver()}unmount(){}}function Pu({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Su={inView:{Feature:wu},tap:{Feature:mu},focus:{Feature:pu},hover:{Feature:du}},bu={layout:{ProjectionNode:go,MeasureLayout:Do}},Au={...Xc,...Su,...fu,...bu},Eu=$c(Au,Hc);export{Du as A,Eu as m};