@robthepcguy/rag-vault 1.7.2 → 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.
- package/README.md +92 -40
- package/dist/chunker/semantic-chunker.d.ts +0 -1
- package/dist/chunker/semantic-chunker.d.ts.map +1 -1
- package/dist/chunker/semantic-chunker.js +1 -1
- package/dist/chunker/semantic-chunker.js.map +1 -1
- package/dist/embedder/index.d.ts +5 -0
- package/dist/embedder/index.d.ts.map +1 -1
- package/dist/embedder/index.js +40 -5
- package/dist/embedder/index.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/flywheel/feedback.d.ts +1 -1
- package/dist/flywheel/feedback.d.ts.map +1 -1
- package/dist/flywheel/feedback.js +1 -1
- package/dist/flywheel/feedback.js.map +1 -1
- package/dist/hyde/index.d.ts +47 -0
- package/dist/hyde/index.d.ts.map +1 -0
- package/dist/hyde/index.js +203 -0
- package/dist/hyde/index.js.map +1 -0
- package/dist/parser/pdf-filter.d.ts +3 -5
- package/dist/parser/pdf-filter.d.ts.map +1 -1
- package/dist/parser/pdf-filter.js +1 -1
- package/dist/parser/pdf-filter.js.map +1 -1
- package/dist/query/parser.d.ts +2 -6
- package/dist/query/parser.d.ts.map +1 -1
- package/dist/query/parser.js +14 -22
- package/dist/query/parser.js.map +1 -1
- package/dist/reranker/index.d.ts +76 -0
- package/dist/reranker/index.d.ts.map +1 -0
- package/dist/reranker/index.js +199 -0
- package/dist/reranker/index.js.map +1 -0
- package/dist/server/index.d.ts +25 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +140 -48
- package/dist/server/index.js.map +1 -1
- package/dist/server/raw-data-utils.d.ts +0 -40
- package/dist/server/raw-data-utils.d.ts.map +1 -1
- package/dist/server/raw-data-utils.js +9 -8
- package/dist/server/raw-data-utils.js.map +1 -1
- package/dist/server/remote-transport.d.ts +2 -1
- package/dist/server/remote-transport.d.ts.map +1 -1
- package/dist/server/remote-transport.js +26 -6
- package/dist/server/remote-transport.js.map +1 -1
- package/dist/server/schemas.d.ts +26 -129
- package/dist/server/schemas.d.ts.map +1 -1
- package/dist/server/schemas.js +9 -9
- package/dist/server/schemas.js.map +1 -1
- package/dist/utils/config-parsers.d.ts +14 -0
- package/dist/utils/config-parsers.d.ts.map +1 -1
- package/dist/utils/config-parsers.js +26 -0
- package/dist/utils/config-parsers.js.map +1 -1
- package/dist/utils/config.d.ts +23 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +39 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +17 -1
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/vectordb/index.d.ts +45 -16
- package/dist/vectordb/index.d.ts.map +1 -1
- package/dist/vectordb/index.js +363 -170
- package/dist/vectordb/index.js.map +1 -1
- package/dist/web/api-routes.d.ts.map +1 -1
- package/dist/web/api-routes.js +23 -10
- package/dist/web/api-routes.js.map +1 -1
- package/dist/web/database-manager.d.ts.map +1 -1
- package/dist/web/database-manager.js +32 -25
- package/dist/web/database-manager.js.map +1 -1
- package/dist/web/http-server.d.ts +0 -5
- package/dist/web/http-server.d.ts.map +1 -1
- package/dist/web/http-server.js +3 -7
- package/dist/web/http-server.js.map +1 -1
- package/dist/web/middleware/async-handler.d.ts +2 -1
- package/dist/web/middleware/async-handler.d.ts.map +1 -1
- package/dist/web/middleware/rate-limit.d.ts +2 -1
- package/dist/web/middleware/rate-limit.d.ts.map +1 -1
- package/dist/web/middleware/request-logger.d.ts +1 -1
- package/dist/web/middleware/request-logger.d.ts.map +1 -1
- package/package.json +8 -7
- package/skills/rag-vault/SKILL.md +3 -3
- package/skills/rag-vault/references/html-ingestion.md +1 -1
- package/web-ui/dist/assets/{CollectionsPage-BDmEfv3V.js → CollectionsPage-wbfgYFTw.js} +1 -1
- package/web-ui/dist/assets/{FilesPage-pG9HmpgQ.js → FilesPage-D6TlldaR.js} +1 -1
- package/web-ui/dist/assets/ReaderPage-Sgy0vMZ6.js +28 -0
- package/web-ui/dist/assets/{ReaderSettingsContext-CkSjqsRh.js → ReaderSettingsContext-DsvLXuaf.js} +1 -1
- package/web-ui/dist/assets/{SearchPage-DAltjnLL.js → SearchPage-mPKXZEyq.js} +1 -1
- package/web-ui/dist/assets/{SettingsPage-C6J5BITP.js → SettingsPage-DXeWwfvd.js} +1 -1
- package/web-ui/dist/assets/{StatusPage-powRGmW3.js → StatusPage-AirpfsGF.js} +1 -1
- package/web-ui/dist/assets/{UploadPage-eyfSjL4u.js → UploadPage-Cob25kDa.js} +5 -5
- package/web-ui/dist/assets/index-BZMzEssr.js +6 -0
- package/web-ui/dist/assets/index-DovQIIL4.css +1 -0
- package/web-ui/dist/assets/motion-DdHBXDWx.js +9 -0
- package/web-ui/dist/assets/query-DbAD_nLW.js +1 -0
- package/web-ui/dist/assets/vendor-DNJ-hWNb.js +10 -0
- package/web-ui/dist/index.html +4 -4
- package/web-ui/dist/assets/ReaderPage-CwMN03NU.js +0 -28
- package/web-ui/dist/assets/index-BpwaiuGL.css +0 -1
- package/web-ui/dist/assets/index-D068MV_o.js +0 -6
- package/web-ui/dist/assets/motion-CKwJwI3J.js +0 -9
- package/web-ui/dist/assets/query-DPt-uCb6.js +0 -1
- package/web-ui/dist/assets/vendor-C2QPsZ3S.js +0 -10
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ReaderPage-CwMN03NU.js","assets/query-DPt-uCb6.js","assets/ReaderSettingsContext-CkSjqsRh.js","assets/vendor-C2QPsZ3S.js","assets/motion-CKwJwI3J.js","assets/SearchPage-DAltjnLL.js","assets/UploadPage-eyfSjL4u.js","assets/FilesPage-pG9HmpgQ.js","assets/CollectionsPage-BDmEfv3V.js","assets/StatusPage-powRGmW3.js","assets/format-DOJ3IkRX.js","assets/SettingsPage-C6J5BITP.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-C2QPsZ3S.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 l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&e(l)}).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={},le;function at(){if(le)return ee;le=1;var n=et();return ee.createRoot=n.createRoot,ee.hydrateRoot=n.hydrateRoot,ee}var it=at();class lt 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 ce={docId:null,chunkIndex:null,chunkRef:null,source:null},Ne=a.createContext(null);function ct({children:n}){const[o,s]=a.useState(ce),e=a.useCallback(r=>{s({docId:r.docId,chunkIndex:r.chunkIndex??null,chunkRef:r.chunkRef??null,source:r.source})},[]),t=a.useCallback(()=>{s(ce)},[]);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.useMemo(()=>s>=0&&s<n.length?n[s]??null:null,[n,s]),r=s>0,l=s<n.length-1,c=a.useCallback((f,g)=>{o(y=>{const u=s,v=u>=0&&u<y.length?y[u]:null;if(v&&v.docId===f&&v.chunkIndex===g)return y;const w={docId:f,chunkIndex:g??null,timestamp:Date.now()},b=[...y.slice(0,u+1),w];if(b.length>de){const p=b.slice(b.length-de);return e(p.length-1),p}return e(b.length-1),b})},[s]),h=a.useCallback(()=>{if(s<=0)return null;const f=s-1;return e(f),n[f]??null},[s,n]),m=a.useCallback(()=>{if(s>=n.length-1)return null;const f=s+1;return e(f),n[f]??null},[s,n]);return{push:c,goBack:h,goForward:m,canGoBack:r,canGoForward:l,current:t,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(l=>{const c=r instanceof Function?r(l):r;try{window.localStorage.setItem(n,JSON.stringify(c))}catch(h){console.warn(`Failed to persist "${n}" to localStorage:`,h)}return c})},[n]);return a.useEffect(()=>{const r=l=>{if(l.key===n&&l.newValue!==null)try{e(JSON.parse(l.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,l]=F(`ws-panel-${o}`,{width:s,collapsed:!1}),c=a.useCallback(f=>{const g=Math.max(e,Math.min(t,f));l(y=>({...y,width:g}))},[e,t,l]),h=a.useCallback(()=>{l(f=>({...f,collapsed:!f.collapsed}))},[l]),m=a.useCallback(f=>{l(g=>({...g,collapsed:f}))},[l]);return{width:r.width,collapsed:r.collapsed,setWidth:c,toggleCollapsed:h,setCollapsed:m}}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 Pe="/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(`${Pe}${n}`,{headers:{"Content-Type":"application/json",...o?.headers},...o,signal:e.signal}),l=await r.json();if(!r.ok)throw new Error(l.error||"Request failed");return l}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 Ps(n){const o=new AbortController,s=setTimeout(()=>o.abort(),ft);try{const e=new FormData;e.append("file",n);const t=await fetch(`${Pe}/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 Rs(n,o,s){return B("/data",{method:"POST",body:JSON.stringify({content:n,metadata:{source:o,format:s}})})}async function Re(){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[l]=t.split(":");e[t]=r.map(c=>({...c,connectionReason:De(c.score,c.filePath===l)}))}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 c=setTimeout(()=>{t(!0),setTimeout(()=>r.current(n.id),200)},5e3);return()=>clearTimeout(c)},[n.id]);const l=()=>{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:l,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 l=`${Date.now()}-${Math.random().toString(36).slice(2,9)}`;s(c=>[...c,{...r,id:l}])},[]),t=a.useCallback(r=>{s(l=>l.filter(c=>c.id!==r))},[]);return i.jsxs(Oe.Provider,{value:{addToast:e,removeToast:t},children:[n,i.jsx(It,{toasts:o,onDismiss:t})]})}function _(){const n=a.useContext(Oe);if(!n)throw new Error("useToast must be used within a ToastProvider");return n}function Tt(){const n=q(),{addToast:o}=_(),{data:s=[],isLoading:e,error:t}=H({queryKey:["files"],queryFn:Re}),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:l=>{o({type:"error",title:"Failed to delete file",message:l.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 Et(){const[n,o]=a.useState(!1),[s,e]=a.useState(""),[t,r]=a.useState(0),{files:l}=Tt(),{select:c}=V(),h=tt(),m=a.useCallback(()=>{o(!0),e(""),r(0)},[]),f=a.useCallback(()=>{o(!1)},[]),g=a.useCallback(()=>{o(w=>(w||(e(""),r(0)),!w))},[]),y=a.useMemo(()=>{const w=l.map(p=>{const d=p.filePath.split("/").pop()||p.filePath;return{id:`doc:${p.filePath}`,label:d,description:p.filePath,icon:"D",category:"document",onSelect:()=>{c({docId:p.filePath,source:"command-palette"}),h(`/reader?doc=${encodeURIComponent(p.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")}],b=[{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,...b]},[l,c,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(),g())}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[g]),{isOpen:n,open:m,close:f,toggle:g,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:l,executeSelected:c}=Et(),h=a.useRef(null),m=a.useRef(null);a.useEffect(()=>{if(n){const u=requestAnimationFrame(()=>{h.current?.focus()});return()=>cancelAnimationFrame(u)}},[n]),a.useEffect(()=>{if(!n||!m.current)return;const u=m.current.querySelector('[data-selected="true"]');u&&u.scrollIntoView({block:"nearest"})},[r,n]);function f(u){switch(u.key){case"ArrowDown":u.preventDefault(),l(Math.min(r+1,t.length-1));break;case"ArrowUp":u.preventDefault(),l(Math.max(r-1,0));break;case"Enter":u.preventDefault(),c();break;case"Escape":u.preventDefault(),o();break}}if(!n)return null;const g=[],y=new Set;for(let u=0;u<t.length;u++){const v=t[u];y.has(v.category)||(y.add(v.category),g.push({category:v.category,items:[]})),g.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:m,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"}),g.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:()=>{l(w),v.onSelect(),o()},onMouseEnter:()=>l(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 Pt="modulepreload",Rt=function(n){return"/"+n},ge={},G=function(o,s,e){let t=Promise.resolve();if(s&&s.length>0){let h=function(m){return Promise.all(m.map(f=>Promise.resolve(f).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");t=h(s.map(m=>{if(m=Rt(m),m in ge)return;ge[m]=!0;const f=m.endsWith(".css"),g=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=f?"stylesheet":Pt,f||(y.as="script"),y.crossOrigin="",y.href=m,c&&y.setAttribute("nonce",c),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 ${m}`)))})}))}function r(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return t.then(l=>{for(const c of l||[])c.status==="rejected"&&r(c.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 b=k.tabs.find(x=>x.kind==="doc"&&x.docId===u);if(b)return{...k,activeTabId:b.tabId,tabs:k.tabs.map(x=>x.tabId===b.tabId?{...x,lastActiveAt:Date.now()}:x)};const p={tabId:crypto.randomUUID(),kind:"doc",docId:u,chunkRef:w,title:v,scrollTop:0,lastActiveAt:Date.now(),pinned:!1};let d=[...k.tabs,p];return d.length>me&&(d=be(d,p.tabId)),{tabs:d,activeTabId:p.tabId}})},[t]),l=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 b={tabId:crypto.randomUUID(),kind:u,title:v,scrollTop:0,lastActiveAt:Date.now(),pinned:!1};let p=[...w.tabs,b];return p.length>me&&(p=be(p,b.tabId)),{tabs:p,activeTabId:b.tabId}})},[t]),c=a.useCallback(u=>{t(v=>{const w=v.tabs.findIndex(p=>p.tabId===u);if(w===-1)return v;const k=v.tabs.filter(p=>p.tabId!==u);if(k.length===0)return pe();let b=v.activeTabId;if(v.activeTabId===u){const p=Math.min(w,k.length-1);b=k[p].tabId}return{tabs:k,activeTabId:b}})},[t]),h=a.useCallback(u=>{t(v=>({...v,activeTabId:u,tabs:v.tabs.map(w=>w.tabId===u?{...w,lastActiveAt:Date.now()}:w)}))},[t]),m=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]),g=a.useMemo(()=>e.tabs.find(u=>u.tabId===e.activeTabId),[e.tabs,e.activeTabId]),y=a.useMemo(()=>({tabs:e.tabs,activeTabId:e.activeTabId,activeTab:g,openDoc:r,openPage:l,closeTab:c,setActiveTab:h,updateTabScroll:m,pinTab:f}),[e.tabs,e.activeTabId,g,r,l,c,h,m,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 l=a.useRef(null),c=h=>{const m=l.current?.querySelectorAll('[role="tab"]');if(!m?.length)return;const f=Array.from(m).indexOf(document.activeElement);let g=f;if(h.key==="ArrowRight"?(h.preventDefault(),g=f+1>=m.length?0:f+1):h.key==="ArrowLeft"&&(h.preventDefault(),g=f-1<0?m.length-1:f-1),g!==f){const y=m[g];if(y){y.focus();const u=y.dataset.tabId;u&&s(u)}}};return i.jsx("div",{ref:l,role:"tablist",className:`ws-tabs ws-tabs--${t} ${r}`,onKeyDown:c,children:n.map(h=>{const m=h.id===o;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?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),l=a.useRef(null),c=a.useCallback(()=>{l.current=setTimeout(()=>r(!0),s)},[s]),h=a.useCallback(()=>{l.current&&(clearTimeout(l.current),l.current=null),r(!1)},[]);return a.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),i.jsxs("span",{className:"ws-tooltip-anchor",onMouseEnter:c,onMouseLeave:h,onFocus:c,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-CwMN03NU.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.ReaderPage}))),zt=a.lazy(()=>G(()=>import("./SearchPage-DAltjnLL.js"),__vite__mapDeps([5,1,3])).then(n=>({default:n.SearchPage}))),Wt=a.lazy(()=>G(()=>import("./UploadPage-eyfSjL4u.js"),__vite__mapDeps([6,1,3])).then(n=>({default:n.UploadPage}))),qt=a.lazy(()=>G(()=>import("./FilesPage-pG9HmpgQ.js"),__vite__mapDeps([7,1,3])).then(n=>({default:n.FilesPage}))),Bt=a.lazy(()=>G(()=>import("./CollectionsPage-BDmEfv3V.js"),__vite__mapDeps([8,1,4,3])).then(n=>({default:n.CollectionsPage}))),Ut=a.lazy(()=>G(()=>import("./StatusPage-powRGmW3.js"),__vite__mapDeps([9,1,10,3])).then(n=>({default:n.StatusPage}))),Ht=a.lazy(()=>G(()=>import("./SettingsPage-C6J5BITP.js"),__vite__mapDeps([11,1,10,4,3])).then(n=>({default:n.SettingsPage}))),Vt=a.lazy(()=>G(()=>import("./ReaderSettingsContext-CkSjqsRh.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)"),m=()=>{const f=document.documentElement;h.matches?f.classList.add("dark"):f.classList.remove("dark")};return h.addEventListener("change",m),()=>h.removeEventListener("change",m)},[o.theme]);const t=a.useCallback(h=>{s(m=>({...m,theme:h}))},[s]),r=a.useCallback(h=>{s(m=>({...m,lastBrowsedPath:h}))},[s]),l=a.useCallback(h=>{s(m=>({...m,showHiddenFiles:h}))},[s]),c=a.useCallback(h=>{s(m=>({...m,statsRefreshInterval:h}))},[s]);return i.jsx($e.Provider,{value:{preferences:o,setTheme:t,setLastBrowsedPath:r,setShowHiddenFiles:l,setStatsRefreshInterval:c,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}),l=await r.json();if(!r.ok)throw new Error(l.error||"Request failed");return l}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 ln(n){return O("/allowed-roots",{method:"POST",body:JSON.stringify({path:n})})}async function cn(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}=_(),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}=_(),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}=_(),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}=_(),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}=_(),s=$({mutationFn:e=>ln(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}=_(),s=$({mutationFn:e=>cn(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}=_(),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}=_(),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}=_(),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}=_(),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:l}=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:l}}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((P,E,C,I,N)=>{const T={id:te(),createdAt:new Date().toISOString(),sourceKey:P,sourceText:C.slice(0,200),sourceFingerprint:"",targetKey:E,targetText:I.slice(0,200),targetFingerprint:"",label:N?.label,autoGenerated:N?.autoGenerated??!1,originalScore:N?.originalScore};return Promise.all([ye(C),ye(I)]).then(([R,D])=>{t(W=>({...W,pins:W.pins.map(Y=>Y.id===T.id?{...Y,sourceFingerprint:R,targetFingerprint:D}:Y)})),he("pin",{...P,fingerprint:R},{...E,fingerprint:D}).catch(()=>{})}).catch(R=>{console.warn("Failed to hash text for pin fingerprints:",R)}),t(R=>({...R,pins:[...R.pins,T]})),T},[t]),l=a.useCallback(P=>{const E=e.pins.find(C=>C.id===P);t(C=>({...C,pins:C.pins.filter(I=>I.id!==P)})),E&&he("unpin",{...E.sourceKey,fingerprint:E.sourceFingerprint},{...E.targetKey,fingerprint:E.targetFingerprint}).catch(()=>{})},[t,e.pins]),c=a.useCallback((P,E)=>{t(C=>({...C,pins:C.pins.map(I=>I.id===P?{...I,label:E}:I)}))},[t]),h=a.useCallback(P=>e.pins.filter(E=>Q(E.sourceKey,P)),[e.pins]),m=a.useCallback(P=>e.pins.filter(E=>Q(E.targetKey,P)),[e.pins]),f=a.useCallback((P,E)=>e.pins.some(C=>Q(C.sourceKey,P)&&Q(C.targetKey,E)),[e.pins]),[g,y]=F(`rag-vault-current-trail-${o}`,null),u=a.useCallback(()=>{const P={id:te(),name:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),steps:[]};y(P)},[y]),v=a.useCallback((P,E)=>{y(C=>{if(!C)return{id:te(),name:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),steps:[{chunkKey:P,visitedAt:new Date().toISOString(),connectionReason:E}]};const I=C.steps[C.steps.length-1];return I&&Q(I.chunkKey,P)?C:{...C,updatedAt:new Date().toISOString(),steps:[...C.steps,{chunkKey:P,visitedAt:new Date().toISOString(),connectionReason:E}]}})},[y]),w=a.useCallback(P=>{if(!g)throw new Error("No current trail to save");const E={...g,name:P,updatedAt:new Date().toISOString()};return t(C=>({...C,trails:[...C.trails,E]})),y(null),E},[g,t,y]),k=a.useCallback(P=>{const E=e.trails.find(C=>C.id===P);return E&&y({...E}),E||null},[e.trails,y]),b=a.useCallback(P=>{t(E=>({...E,trails:E.trails.filter(C=>C.id!==P)}))},[t]),p=a.useCallback(()=>{y(null)},[y]),d=a.useCallback((P,E)=>{const C={id:te(),chunkKey:P,note:E,createdAt:new Date().toISOString()};return t(I=>({...I,bookmarks:[...I.bookmarks||[],C]})),C},[t]),x=a.useCallback(P=>{t(E=>({...E,bookmarks:(E.bookmarks||[]).filter(C=>C.id!==P)}))},[t]),S=a.useCallback((P,E)=>{t(C=>({...C,bookmarks:(C.bookmarks||[]).map(I=>I.id===P?{...I,note:E}:I)}))},[t]),j=a.useCallback(P=>(e.bookmarks||[]).filter(E=>E.chunkKey.filePath===P).sort((E,C)=>E.chunkKey.chunkIndex-C.chunkKey.chunkIndex),[e.bookmarks]),A=a.useCallback(P=>(e.bookmarks||[]).some(E=>Q(E.chunkKey,P)),[e.bookmarks]),M=a.useCallback(P=>{const E=(e.bookmarks||[]).find(C=>Q(C.chunkKey,P));return E?(x(E.id),!1):(d(P),!0)},[e.bookmarks,d,x]),K=a.useCallback(()=>JSON.stringify(e,null,2),[e]),z=a.useCallback(P=>{const E=[];let C=0;try{const I=JSON.parse(P);if(I.version!==1)return E.push(`Unsupported version: ${I.version}`),{imported:C,errors:E};if(Array.isArray(I.pins))for(const N of I.pins)N.id&&N.sourceKey&&N.targetKey&&!e.pins.some(T=>T.id===N.id)&&(t(T=>({...T,pins:[...T.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(T=>T.id===N.id)&&(t(T=>({...T,trails:[...T.trails,N]})),C++);if(Array.isArray(I.bookmarks))for(const N of I.bookmarks)N.id&&N.chunkKey&&!(e.bookmarks||[]).some(T=>T.id===N.id)&&(t(T=>({...T,bookmarks:[...T.bookmarks||[],N]})),C++)}catch(I){E.push(`Invalid JSON: ${I.message}`)}return{imported:C,errors:E}},[e,t]),U=a.useMemo(()=>({pins:e.pins,createPin:r,deletePin:l,updatePinLabel:c,getPinsFromChunk:h,getBacklinks:m,isPinned:f,trails:e.trails,currentTrail:g,startNewTrail:u,addToTrail:v,saveTrail:w,loadTrail:k,deleteTrail:b,clearCurrentTrail:p,bookmarks:e.bookmarks||[],createBookmark:d,deleteBookmark:x,updateBookmarkNote:S,getBookmarksForDocument:j,isBookmarked:A,toggleBookmark:M,exportLinks:K,importLinks:z}),[e.pins,e.trails,e.bookmarks,r,l,c,h,m,f,g,u,v,w,k,b,p,d,x,S,j,A,M,K,z]);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,l,c)=>{const h=n.pins.find(m=>m.sourceKey.filePath===e.filePath&&m.sourceKey.chunkIndex===e.chunkIndex&&m.targetKey.filePath===t.filePath&&m.targetKey.chunkIndex===t.chunkIndex);h?n.deletePin(h.id):n.createPin(e,t,r,l,{autoGenerated:!1,originalScore:c})},[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 l=t.split(".").length;return{text:`${t} ${r.trim()}`,level:l,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 Tn(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 En({chunks:n,minHeadings:o=2}){return a.useMemo(()=>{if(n.length===0)return{entries:[],hasHeadings:!1,isFallback:!1};const e=[];for(const l of n){const c=jn(l.text,l.chunkIndex);e.push(...c)}const t=[];for(const l of e){const c=t[t.length-1];(!c||c.text!==l.text||c.chunkIndex!==l.chunkIndex)&&t.push(l)}return t.length<o?{entries:Tn(n),hasHeadings:!1,isFallback:!0}:{entries:t.map((l,c)=>({...l,id:`toc-${c}-${l.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 Pn({children:n,vaultId:o="default"}){const s=`rag-vault-annotations-v1-${o}`,[e,t]=F(s,{...Nn,vaultId:o}),r=a.useCallback((k,b,p,d,x,S)=>{const j={id:we(),chunkKey:k,range:b,text:p,contextBefore:d.slice(-30),contextAfter:x.slice(0,30),color:S,createdAt:new Date().toISOString()};return t(A=>({...A,highlights:[...A.highlights,j]})),j},[t]),l=a.useCallback(k=>{t(b=>({...b,highlights:b.highlights.filter(p=>p.id!==k),annotations:b.annotations.filter(p=>p.highlightId!==k)}))},[t]),c=a.useCallback((k,b)=>{t(p=>({...p,highlights:p.highlights.map(d=>d.id===k?{...d,color:b}:d)}))},[t]),h=a.useCallback(k=>e.highlights.filter(b=>An(b.chunkKey,k)).sort((b,p)=>b.range.startOffset-p.range.startOffset),[e.highlights]),m=a.useCallback((k,b)=>{const p={id:we(),highlightId:k,note:b,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return t(d=>({...d,annotations:[...d.annotations,p]})),p},[t]),f=a.useCallback((k,b)=>{t(p=>({...p,annotations:p.annotations.map(d=>d.id===k?{...d,note:b,updatedAt:new Date().toISOString()}:d)}))},[t]),g=a.useCallback(k=>{t(b=>({...b,annotations:b.annotations.filter(p=>p.id!==k)}))},[t]),y=a.useCallback(k=>e.annotations.find(b=>b.highlightId===k),[e.annotations]),u=a.useCallback(()=>JSON.stringify(e,null,2),[e]),v=a.useCallback(k=>{const b=[];let p=0;try{const d=JSON.parse(k);if(d.version!==1)return b.push(`Unsupported version: ${d.version}`),{imported:p,errors:b};if(Array.isArray(d.highlights))for(const x of d.highlights)x.id&&x.chunkKey&&x.range&&!e.highlights.some(S=>S.id===x.id)&&(t(S=>({...S,highlights:[...S.highlights,x]})),p++);if(Array.isArray(d.annotations))for(const x of d.annotations)x.id&&x.highlightId&&!e.annotations.some(S=>S.id===x.id)&&(t(S=>({...S,annotations:[...S.annotations,x]})),p++)}catch(d){b.push(`Invalid JSON: ${d.message}`)}return{imported:p,errors:b}},[e,t]),w=a.useMemo(()=>({highlights:e.highlights,createHighlight:r,deleteHighlight:l,updateHighlightColor:c,getHighlightsForChunk:h,annotations:e.annotations,createAnnotation:m,updateAnnotation:f,deleteAnnotation:g,getAnnotationForHighlight:y,exportAnnotations:u,importAnnotations:v}),[e.highlights,e.annotations,r,l,c,h,m,f,g,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 Rn({filePath:n,activeChunkIndex:o,relatedChunks:s,pins:e,maxNodes:t=150}){const r=a.useMemo(()=>{const c=new Map,h=[],m=o!==null?`${n}:${o}`:null;m&&c.set(m,{id:m,filePath:n,chunkIndex:o,text:"(current chunk)"});for(const u of s){const v=`${u.filePath}:${u.chunkIndex}`;c.has(v)||c.set(v,{id:v,filePath:u.filePath,chunkIndex:u.chunkIndex,text:u.text.slice(0,100)+(u.text.length>100?"...":"")}),m&&m!==v&&h.push({source:m,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}`;c.has(v)||c.set(v,{id:v,filePath:u.sourceKey.filePath,chunkIndex:u.sourceKey.chunkIndex,text:u.sourceText.slice(0,100)+(u.sourceText.length>100?"...":"")}),c.has(w)||c.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(b=>b.source===v&&b.target===w);if(k>=0){const b=h[k];b&&(h[k]={...b,type:"pinned",label:u.label||b.label})}else h.push({source:v,target:w,score:u.originalScore??.5,type:"pinned",label:u.label})}let f=Array.from(c.values());if(f.length>t){const u=new Set(e.flatMap(b=>[`${b.sourceKey.filePath}:${b.sourceKey.chunkIndex}`,`${b.targetKey.filePath}:${b.targetKey.chunkIndex}`])),v=f.filter(b=>b.id===m||u.has(b.id)),w=Math.max(0,t-v.length),k=f.filter(b=>b.id!==m&&!u.has(b.id)).slice(0,w);f=v.concat(k)}const g=new Set(f.map(u=>u.id)),y=h.filter(u=>g.has(u.source)&&g.has(u.target));return{nodes:f,edges:y}},[n,o,s,e,t]),l=o!==null?`${n}:${o}`:null;return{graphData:r,currentNodeId:l}}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,x)=>{const S={id:ke(),name:d.trim(),color:x,usageCount:0,lastUsedAt:new Date().toISOString(),createdAt:new Date().toISOString()};return t(j=>({...j,updatedAt:new Date().toISOString(),tags:[...j.tags,S]})),S},[t]),l=a.useCallback((d,x)=>{t(S=>({...S,updatedAt:new Date().toISOString(),tags:S.tags.map(j=>{if(j.id!==d)return j;const A={...x};return A.name!==void 0&&(A.name=A.name.trim()),{...j,...A}})}))},[t]),c=a.useCallback(d=>{t(x=>({...x,updatedAt:new Date().toISOString(),tags:x.tags.filter(S=>S.id!==d),taggedItems:x.taggedItems.filter(S=>S.tagId!==d)}))},[t]),h=a.useCallback(d=>e.tags.find(x=>x.id===d),[e.tags]),m=a.useCallback((d,x,S)=>{const j={id:ke(),tagId:d,targetType:x,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(x=>({...x,updatedAt:new Date().toISOString(),taggedItems:x.taggedItems.filter(S=>S.id!==d)}))},[t]),g=a.useCallback((d,x,S)=>{t(j=>({...j,updatedAt:new Date().toISOString(),taggedItems:j.taggedItems.filter(A=>!(A.tagId===d&&A.targetType===x&&A.targetKey===S))}))},[t]),y=a.useCallback((d,x)=>{const S=e.taggedItems.filter(j=>j.targetType===d&&j.targetKey===x).map(j=>j.tagId);return e.tags.filter(j=>S.includes(j.id))},[e.tags,e.taggedItems]),u=a.useCallback(d=>e.taggedItems.filter(x=>x.tagId===d),[e.taggedItems]),v=a.useCallback((d,x,S)=>e.taggedItems.some(j=>j.tagId===d&&j.targetType===x&&j.targetKey===S),[e.taggedItems]),w=a.useCallback((d=10)=>[...e.tags].sort((x,S)=>S.usageCount!==x.usageCount?S.usageCount-x.usageCount:new Date(S.lastUsedAt).getTime()-new Date(x.lastUsedAt).getTime()).slice(0,d),[e.tags]),k=a.useCallback(()=>JSON.stringify(e,null,2),[e]),b=a.useCallback(d=>{const x=[];let S=0;try{const j=JSON.parse(d);if(j.version!==1)return x.push(`Unsupported version: ${j.version}`),{imported:S,errors:x};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){x.push(`Invalid JSON: ${j.message}`)}return{imported:S,errors:x}},[e,t]),p=a.useMemo(()=>({tags:e.tags,createTag:r,updateTag:l,deleteTag:c,getTag:h,taggedItems:e.taggedItems,addTag:m,removeTag:f,removeTagFromTarget:g,getTagsForTarget:y,getTargetsForTag:u,isTagged:v,getTagSuggestions:w,exportTags:k,importTags:b}),[e.tags,e.taggedItems,r,l,c,h,m,f,g,y,u,v,w,k,b]);return i.jsx(qe.Provider,{value:p,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((b,p,d)=>{const x={id:On(),name:b.trim(),description:d?.trim(),color:p,documents:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return t(S=>({...S,updatedAt:new Date().toISOString(),collections:[...S.collections,x]})),x},[t]),l=a.useCallback((b,p)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(x=>x.id===b?{...x,...p,updatedAt:new Date().toISOString()}:x)}))},[t]),c=a.useCallback(b=>{t(p=>({...p,updatedAt:new Date().toISOString(),collections:p.collections.filter(d=>d.id!==b)}))},[t]),h=a.useCallback(b=>e.collections.find(p=>p.id===b),[e.collections]),m=a.useCallback((b,p)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(x=>x.id!==b||x.documents.includes(p)?x:{...x,documents:[...x.documents,p],updatedAt:new Date().toISOString()})}))},[t]),f=a.useCallback((b,p)=>{t(d=>({...d,updatedAt:new Date().toISOString(),collections:d.collections.map(x=>x.id!==b?x:{...x,documents:x.documents.filter(S=>S!==p),updatedAt:new Date().toISOString()})}))},[t]),g=a.useCallback(b=>e.collections.filter(p=>p.documents.includes(b)),[e.collections]),y=a.useCallback(b=>e.collections.find(d=>d.id===b)?.documents??[],[e.collections]),u=a.useCallback((b,p)=>e.collections.find(x=>x.id===b)?.documents.includes(p)??!1,[e.collections]),v=a.useCallback(()=>JSON.stringify(e,null,2),[e]),w=a.useCallback(b=>{const p=[];let d=0;try{const x=JSON.parse(b);if(x.version!==1)return p.push(`Unsupported version: ${x.version}`),{imported:d,errors:p};if(Array.isArray(x.collections))for(const S of x.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(x){p.push(`Invalid JSON: ${x.message}`)}return{imported:d,errors:p}},[e,t]),k=a.useMemo(()=>({collections:e.collections,createCollection:r,updateCollection:l,deleteCollection:c,getCollection:h,addDocumentToCollection:m,removeDocumentFromCollection:f,getCollectionsForDocument:g,getDocumentsInCollection:y,isDocumentInCollection:u,exportCollections:v,importCollections:w}),[e.collections,r,l,c,h,m,f,g,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]),l=a.useCallback((k,b)=>{t(p=>({...p,nodePositions:{...p.nodePositions,[k]:{x:b.x,y:b.y,fixedAt:new Date().toISOString()}}}))},[t]),c=a.useCallback(()=>{t(k=>({...k,nodePositions:{}}))},[t]),h=a.useCallback(k=>{t(b=>({...b,viewState:{...b.viewState,pan:k}}))},[t]),m=a.useCallback(k=>{t(b=>({...b,viewState:{...b.viewState,zoom:k}}))},[t]),f=a.useCallback(k=>{t(b=>({...b,viewState:k}))},[t]),g=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 b=JSON.parse(k);return b.version!==1?{success:!1,error:`Unsupported version: ${b.version}`}:(t(p=>({...p,nodePositions:b.nodePositions||{},viewState:b.viewState||re})),{success:!0})}catch(b){return{success:!1,error:`Invalid JSON: ${b.message}`}}},[t]),w=a.useMemo(()=>({nodePositions:e.nodePositions,getNodePosition:r,setNodePosition:l,clearNodePositions:c,viewState:e.viewState,setPan:h,setZoom:m,setViewState:f,resetViewState:g,resetAll:y,exportGraphState:u,importGraphState:v}),[e.nodePositions,e.viewState,r,l,c,h,m,f,g,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(p=>e.documents[p],[e.documents]),l=a.useCallback((p,d)=>{const x=e.documents[p];if(x)return x.chunkStats[d]},[e.documents]),c=a.useCallback((p,d)=>{const x=e.documents[p];return x?x.totalChunks!==d?{...x,totalChunks:d}:x:{filePath:p,totalChunks:d,chunksRead:0,totalTimeMs:0,sessions:[],chunkStats:{}}},[e.documents]),h=a.useCallback((p,d,x)=>{t(S=>{const j=c(p,x),A=j.chunkStats[d]||{totalTimeMs:0,readCount:0,lastReadAt:""},M=A.readCount===0,K={...A,readCount:A.readCount+1,lastReadAt:new Date().toISOString()},z={...j,chunksRead:M?j.chunksRead+1:j.chunksRead,chunkStats:{...j.chunkStats,[d]:K}};return{...S,documents:{...S.documents,[p]:z}}})},[t,c]),m=a.useCallback((p,d,x)=>{x<=0||t(S=>{const j=S.documents[p];if(!j)return S;const A=j.chunkStats[d]||{totalTimeMs:0,readCount:0,lastReadAt:new Date().toISOString()},M={...A,totalTimeMs:A.totalTimeMs+x},K=!j.chunkStats[d],z={...j,totalTimeMs:j.totalTimeMs+x,chunksRead:K?j.chunksRead+1:j.chunksRead,chunkStats:{...j.chunkStats,[d]:M}};return{...S,documents:{...S.documents,[p]:z}}})},[t]),f=a.useCallback(p=>{t(d=>{const x=d.documents[p];if(!x)return d;const S=x.sessions[x.sessions.length-1];if(S&&!S.endedAt)return d;const j={startedAt:new Date().toISOString(),endedAt:"",durationMs:0},A=[...x.sessions,j].slice(-10);return{...d,documents:{...d.documents,[p]:{...x,sessions:A}}}})},[t]),g=a.useCallback(p=>{t(d=>{const x=d.documents[p];if(!x)return d;const S=[...x.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,[p]:{...x,sessions:S}}}})},[t]),y=a.useCallback(p=>{const d=e.documents[p];return!d||d.totalChunks===0?0:Math.round(d.chunksRead/d.totalChunks*100)},[e.documents]),u=a.useCallback(p=>e.documents[p]?.totalTimeMs??0,[e.documents]),v=a.useCallback(p=>{const d=e.documents[p];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(p=>{t(p?d=>{const{[p]:x,...S}=d.documents;return{...d,documents:S}}:d=>({...d,documents:{}}))},[t]),b=a.useMemo(()=>({getDocumentStats:r,getChunkStats:l,recordChunkView:h,recordTimeSpent:m,startSession:f,endSession:g,getCompletionPercent:y,getTotalReadingTime:u,getAverageTimePerChunk:v,exportStats:w,clearStats:k}),[r,l,h,m,f,g,y,u,v,w,k]);return i.jsx(zn.Provider,{value:b,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.useCallback(t=>{t.preventDefault(),s.current=t.clientX;const r=c=>{const h=c.clientX-s.current;s.current=c.clientX,n(o==="right"?-h:h)},l=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",l),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",r),document.addEventListener("mouseup",l),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[n,o]);return i.jsx("div",{className:"ws-resize-handle",onMouseDown:e,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),l=a.useRef(null),c=a.useCallback(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),h=a.useCallback(()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)},[]),m=a.useCallback(()=>{c(),h()},[c,h]),f=a.useCallback((w,k)=>{h();const b=k.left+k.width/2,p=k.bottom+8,d=Math.max(Ce,Math.min(b,window.innerWidth-Ce)),S=window.innerHeight-k.bottom<200?k.top-8:p;c(),r.current=setTimeout(()=>{t({isVisible:!0,position:{x:d,y:S},targetRef:w})},o)},[o,h,c]),g=a.useCallback(()=>{c(),l.current=setTimeout(()=>{t(w=>({...w,isVisible:!1,targetRef:null}))},s)},[s,c]),y=a.useCallback(()=>{h()},[h]),u=a.useCallback(()=>{l.current=setTimeout(()=>{t(w=>({...w,isVisible:!1,targetRef:null}))},s)},[s]),v=a.useCallback(()=>{m(),t({isVisible:!1,position:{x:0,y:0},targetRef:null})},[m]);return a.useEffect(()=>()=>m(),[m]),{state:e,onHoverStart:f,onHoverEnd:g,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:l,onPinAsLink:c,onMouseEnter:h,onMouseLeave:m}){const f=a.useRef(null),[g,y]=a.useState(t),[u,v]=a.useState(!0),w=s!==void 0&&s>0||e!==void 0,k=l!==void 0||c!==void 0;return a.useEffect(()=>{const b=f.current;if(!b)return;const p=b.getBoundingClientRect();let{x:d,y:x}=t;d=d-p.width/2,d+p.width>window.innerWidth-X&&(d=window.innerWidth-X-p.width),d<X&&(d=X),x+p.height>window.innerHeight-X&&(x=t.y-p.height-16),x<X&&(x=X),y({x:d,y:x})},[t]),a.useEffect(()=>{const b=requestAnimationFrame(()=>{v(!1)});return()=>cancelAnimationFrame(b)},[]),i.jsxs("div",{ref:f,className:`ws-hover-preview ${u?"ws-hover-preview--entering":""}`,style:{left:g.x,top:g.y},onMouseEnter:h,onMouseLeave:m,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:[l&&i.jsx("button",{type:"button",className:"ws-button","data-variant":"ghost","data-size":"sm",onClick:l,children:"New Tab"}),c&&i.jsx("button",{type:"button",className:"ws-button","data-variant":"ghost","data-size":"sm",onClick:c,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 l(){var c,h,m;let f;s.key&&((c=s.debug)!=null&&c.call(s))&&(f=Date.now());const g=n();if(!(g.length!==e.length||g.some((v,w)=>e[w]!==v)))return t;e=g;let u;if(s.key&&((h=s.debug)!=null&&h.call(s))&&(u=Date.now()),t=o(...g),s.key&&((m=s.debug)!=null&&m.call(s))){const v=Math.round((Date.now()-f)*100)/100,w=Math.round((Date.now()-u)*100)/100,k=w/16,b=(p,d)=>{for(p=String(p);p.length<d;)p=" "+p;return p};console.info(`%c⏱ ${b(w,5)} /${b(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 l.updateDeps=c=>{e=c},l}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=l=>{const{width:c,height:h}=l;o({width:Math.round(c),height:Math.round(h)})};if(t(je(s)),!e.ResizeObserver)return()=>{};const r=new e.ResizeObserver(l=>{const c=()=>{const h=l[0];if(h?.borderBoxSize){const m=h.borderBoxSize[0];if(m){t({width:m.inlineSize,height:m.blockSize});return}}t(je(s))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return r.observe(s,{box:"border-box"}),()=>{r.unobserve(s)}},Te={passive:!0},Ee=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&&Ee?()=>{}:Gn(e,()=>{o(t,!1)},n.options.isScrollingResetDelay),l=f=>()=>{const{horizontal:g,isRtl:y}=n.options;t=g?s.scrollLeft*(y&&-1||1):s.scrollTop,r(),o(t,f)},c=l(!0),h=l(!1);s.addEventListener("scroll",c,Te);const m=n.options.useScrollendEvent&&Ee;return m&&s.addEventListener("scrollend",h,Te),()=>{s.removeEventListener("scroll",c),m&&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 l=n+o;(r=(t=e.scrollElement)==null?void 0:t.scrollTo)==null||r.call(t,{[e.options.horizontal?"left":"top"]:l,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 l=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));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 l=e-1;l>=0;l--){const c=s[l];if(t.has(c.lane))continue;const h=r.get(c.lane);if(h==null||c.end>h.end?r.set(c.lane,c):c.end<h.end&&t.set(c.lane,!0),t.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((l,c)=>l.end===c.end?l.index-c.index:l.end-c.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,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:e,scrollMargin:t,getItemKey:r,enabled:l,lanes:c}),{key:!1}),this.getMeasurements=Z(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:e,scrollMargin:t,getItemKey:r,enabled:l,lanes:c},h)=>{if(!l)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 m=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,m),g=new Array(c).fill(void 0);for(let y=0;y<m;y++){const u=f[y];u&&(g[u.lane]=y)}for(let y=m;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 x=g[w],S=x!==void 0?f[x]:void 0;k=S?S.end+this.options.gap:e+t}else{const x=this.options.lanes===1?f[y-1]:this.getFurthestMeasurement(f,y);k=x?x.end+this.options.gap:e+t,w=x?x.lane:y%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(y,w)}const b=h.get(u),p=typeof b=="number"?b:this.options.estimateSize(y),d=k+p;f[y]={index:y,start:k,size:p,end:d,key:u,lane:w},g[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,l)=>r===null||l===null?[]:s({startIndex:r,endIndex:l,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 l=r.key,c=this.elementsCache.get(l);c!==s&&(c&&this.observer.unobserve(c),this.observer.observe(s),this.elementsCache.set(l,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,l=e-r;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(t,l,this):t.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,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,l=s.length;r<l;r++){const c=s[r],h=e[c];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(),l=this.getScrollOffset();e==="auto"&&(e=s>=l+r?"end":"start"),e==="center"?s+=(t-r)/2:e==="end"&&(s-=r);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,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(),l=this.getScrollOffset();if(e==="auto")if(t.end>=l+r-this.options.scrollPaddingEnd)e="end";else if(t.start<=l+this.options.scrollPaddingStart)e="start";else return[l,e];if(e==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),e];const c=e==="end"?t.end+this.options.scrollPaddingEnd:t.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,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 l=10,c=m=>{if(!this.targetWindow)return;const f=this.getOffsetForIndex(s,m);if(!f){console.warn("Failed to get offset for index:",s);return}const[g,y]=f;this._scrollToOffset(g,{adjustments:void 0,behavior:t}),this.targetWindow.requestAnimationFrame(()=>{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=m=>{this.targetWindow&&this.currentScrollToIndex===s&&(r++,r<l?this.targetWindow.requestAnimationFrame(()=>c(m)):console.warn(`Failed to scroll to index ${s} after ${l} attempts.`))};c(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 l=e.length-1;for(;l>=0&&r.some(c=>c===null);){const c=e[l];r[c.lane]===null&&(r[c.lane]=c.end),l--}t=Math.max(...r.filter(c=>c!==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 l=Ue(0,t,r,s),c=l;if(e===1)for(;c<t&&n[c].end<s+o;)c++;else if(e>1){const h=Array(e).fill(0);for(;c<t&&h.some(f=>f<s+o);){const f=n[c];h[f.lane]=f.end,c++}const m=Array(e).fill(s+o);for(;l>=0&&m.some(f=>f>=s);){const f=n[l];m[f.lane]=f.start,l--}l=Math.max(0,l-l%e),c=Math.min(t,c+(e-1-c%e))}return{startIndex:l,endIndex:c}}const Ae=typeof document<"u"?a.useLayoutEffect:a.useEffect;function ss({useFlushSync:n=!0,...o}){const s=a.useReducer(()=>({}),{})[1],e={...o,onChange:(r,l)=>{var c;n&&l?ot.flushSync(s):s(),(c=o.onChange)==null||c.call(o,r,l)}},[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,l)=>i.jsx("div",{children:o(r,l)},s(r,l)))}):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 l=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(l,r.index)},s(l,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:l,onPreviewEnter:c,onPreviewLeave:h,hide:m}=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(g=>g.id===t.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:s,getKey:g=>g.id,renderItem:g=>{const y=g.sourceKey.filePath.split("/").pop()??g.sourceKey.filePath;return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{m(),o({docId:g.sourceKey.filePath,chunkIndex:g.sourceKey.chunkIndex,source:"backlink"})},onMouseEnter:u=>r(g.id,u.currentTarget.getBoundingClientRect()),onMouseLeave:l,children:[i.jsx("span",{className:"ws-rail-item-title",children:y}),i.jsxs("span",{className:"ws-rail-item-meta",children:["Chunk #",g.sourceKey.chunkIndex]}),g.label&&i.jsx("span",{className:"ws-rail-item-label",children:g.label}),i.jsxs("p",{className:"ws-rail-item-excerpt",children:[g.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:()=>{m(),o({docId:f.sourceKey.filePath,chunkIndex:f.sourceKey.chunkIndex,source:"backlink"})},onMouseEnter:c,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:l,onPreviewEnter:c,onPreviewLeave:h,hide:m}=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(g=>`${g.filePath}-${g.chunkIndex}`===t.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:s,getKey:g=>`${g.filePath}-${g.chunkIndex}`,renderItem:g=>{const y=`${g.filePath}-${g.chunkIndex}`;return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{m(),o({docId:g.filePath,chunkIndex:g.chunkIndex,source:"backlink"})},onMouseEnter:u=>r(y,u.currentTarget.getBoundingClientRect()),onMouseLeave:l,children:[i.jsx("span",{className:"ws-rail-item-title",children:g.filePath.split("/").pop()}),i.jsxs("span",{className:"ws-rail-item-meta",children:["Score: ",g.score.toFixed(3)]}),i.jsxs("p",{className:"ws-rail-item-excerpt",children:[g.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:()=>{m(),o({docId:f.filePath,chunkIndex:f.chunkIndex,source:"backlink"})},onMouseEnter:c,onMouseLeave:h})]})}function ls(){const{selection:n}=V(),{chunks:o}=bn(n.docId??null),{entries:s}=En({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 cs(){const n=a.useRef(null),[o,s]=a.useState(null),[e,t]=a.useState(!1),[r,l]=a.useState(null);a.useEffect(()=>{const m=new Worker(new URL("/assets/link-indexer.worker-DGXNsXmZ.js",import.meta.url),{type:"module"});return m.onmessage=f=>{const g=f.data;g.type==="scan-complete"&&g.index?(s(g.index),t(!1),l(null)):g.type==="error"&&(l(new Error(g.message??"Worker error")),t(!1))},m.onerror=f=>{l(new Error(f.message||"Worker initialization error")),t(!1)},n.current=m,()=>{m.terminate(),n.current=null}},[]);const c=a.useCallback(m=>{n.current&&(t(!0),l(null),n.current.postMessage({type:"scan",documents:m}))},[]),h=a.useCallback(async()=>{t(!0),l(null);try{const m=await Re(),f=await Promise.all(m.map(async g=>{const y=await Me(g.filePath);return{filePath:g.filePath,chunks:y.map(u=>({chunkIndex:u.chunkIndex,text:u.text}))}}));if(!n.current)return;n.current.postMessage({type:"scan",documents:f})}catch(m){l(m instanceof Error?m:new Error("Failed to fetch documents for scan")),t(!1)}},[]);return{index:o,isScanning:e,error:r,scan:c,rescan:h}}const Ve=a.createContext(null);function ds({children:n}){const{index:o,isScanning:s,rescan:e}=cs(),t=q();a.useEffect(()=>{e()},[e]),a.useEffect(()=>t.getQueryCache().subscribe(g=>{g.type==="updated"&&g.query.queryKey[0]==="files"&&g.action.type==="success"&&e()}),[t,e]);const r=a.useMemo(()=>{if(!o)return new Set;const f=new Set,g=new Set;if(o.outgoing)for(const y of Object.keys(o.outgoing))g.add(y);if(o.incoming)for(const y of Object.values(o.incoming))for(const u of y)g.add(u.sourceDoc);for(const y of g){const u=y.split("/"),v=u[u.length-1]??y,w=v.replace(/\.[^.]+$/,"");f.add(w.toLowerCase()),f.add(v.toLowerCase())}return f},[o]),l=a.useCallback(f=>o?o.outgoing[f]??[]:[],[o]),c=a.useCallback(f=>o?o.incoming[f]??[]:[],[o]),h=a.useCallback(f=>r.has(f.toLowerCase()),[r]),m=a.useMemo(()=>({index:o,isScanning:s,rescan:e,getOutgoingLinks:l,getIncomingLinks:c,isResolved:h}),[o,s,e,l,c,h]);return i.jsx(Ve.Provider,{value:m,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:l,onHoverEnd:c,onPreviewEnter:h,onPreviewLeave:m,hide:f}=ae(),g=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(g.length===0)return i.jsx(L,{message:"No outgoing links found"});const y=r.isVisible?g.find((u,v)=>`${u.targetTitle}-${u.chunkIndex}-${v}`===r.targetRef):null;return i.jsxs(i.Fragment,{children:[i.jsx(ne,{items:g,getKey:(u,v)=>`${u.targetTitle}-${u.chunkIndex}-${v}`,renderItem:(u,v)=>{const w=e(u.targetTitle),k=`${u.targetTitle}-${u.chunkIndex}-${v}`,b=[];return u.heading&&b.push(`# ${u.heading}`),u.blockRef&&b.push(`^ ${u.blockRef}`),b.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:p=>{w&&l(k,p.currentTarget.getBoundingClientRect())},onMouseLeave:c,children:[i.jsx("span",{className:"ws-rail-item-title",children:u.alias??u.targetTitle}),i.jsx("span",{className:"ws-rail-item-meta",children:b.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:m})]})}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]),l=a.useMemo(()=>{if(!r)return[];const m=t(r);if(m.length===0)return[];const f=new Map;for(const g of m){const y=f.get(g.sourceDoc);y?y.push(g):f.set(g.sourceDoc,[g])}return Array.from(f.entries()).map(([g,y])=>({sourceDoc:g,edges:y}))},[r,t]),c=a.useMemo(()=>{if(!r||!s)return 0;const m=new Set(t(r).map(g=>g.sourceDoc));let f=0;for(const g of Object.keys(s.outgoing))g!==n.docId&&(m.has(g)||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=l.length>0;return!h&&c===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:l.length,style:{marginLeft:"0.5rem"},children:"linked"})]}),i.jsx(ne,{items:l,getKey:m=>m.sourceDoc,renderItem:m=>{const f=m.sourceDoc.split("/").pop()??m.sourceDoc,g=m.edges.map(y=>`#${y.chunkIndex}`).join(", ");return i.jsxs("button",{type:"button",className:"ws-rail-item",onClick:()=>{o({docId:m.sourceDoc,source:"backlink"})},children:[i.jsx("span",{className:"ws-rail-item-title",children:f}),i.jsxs("span",{className:"ws-rail-item-meta",children:[m.edges.length," link",m.edges.length!==1?"s":""," - Chunks"," ",g]})]})}})]}),c>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:c,style:{marginRight:"0.5rem"},children:"unlinked"}),c," document",c!==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]),[l,c]=a.useState([]),[h,m]=a.useState(!1),f=a.useRef(null),g=a.useRef(0);a.useEffect(()=>{const w=s/2,k=e/2,b=n.nodes.map((p,d)=>{const x=l.find(A=>A.id===p.id);if(x&&x.x!==void 0&&x.y!==void 0)return{...p,x:x.x,y:x.y,vx:0,vy:0};const S=d/n.nodes.length*Math.PI*2,j=Math.min(s,e)*.3;return{...p,x:w+Math.cos(S)*j+(Math.random()-.5)*50,y:k+Math.sin(S)*j+(Math.random()-.5)*50,vx:0,vy:0}});c(b),m(!1),g.current=0},[n.nodes.length,s,e,n.nodes.map,l.find]);const y=a.useRef(new Map);a.useEffect(()=>{const w=new Map;for(const k of n.edges){const b=w.get(k.source)||[];b.push(k.target),w.set(k.source,b);const p=w.get(k.target)||[];p.push(k.source),w.set(k.target,p)}y.current=w},[n.edges]);const u=a.useCallback(()=>{if(!t||l.length===0)return!1;const w=s/2,k=e/2;let b=0;const p=l.map(d=>{let x=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 l){if(I.id===d.id)continue;const N=(d.x??0)-(I.x??0),T=(d.y??0)-(I.y??0),R=Math.sqrt(N*N+T*T)||1,D=r.repulsionStrength/(R*R);x+=N/R*D,S+=T/R*D}const j=y.current.get(d.id)||[];for(const I of j){const N=l.find(D=>D.id===I);if(!N)continue;const T=(N.x??0)-(d.x??0),R=(N.y??0)-(d.y??0);x+=T*r.attractionStrength,S+=R*r.attractionStrength}x+=(w-(d.x??0))*r.centerGravity,S+=(k-(d.y??0))*r.centerGravity;const A=((d.vx??0)+x)*(1-r.velocityDecay),M=((d.vy??0)+S)*(1-r.velocityDecay),K=(d.x??0)+A,z=(d.y??0)+M,U=40,P=Math.max(U,Math.min(s-U,K)),E=Math.max(U,Math.min(e-U,z)),C=Math.sqrt(A*A+M*M);return b=Math.max(b,C),{...d,x:P,y:E,vx:A,vy:M}});return c(p),g.current++,b>.5&&g.current<300},[l,t,s,e,r]);a.useEffect(()=>{if(!t){f.current&&cancelAnimationFrame(f.current);return}const w=()=>{u()?f.current=requestAnimationFrame(w):m(!0)};return f.current=requestAnimationFrame(w),()=>{f.current&&cancelAnimationFrame(f.current)}},[u,t]);const v=a.useCallback(()=>{m(!1),g.current=0,c(w=>w.map(k=>({...k,vx:(Math.random()-.5)*10,vy:(Math.random()-.5)*10})))},[]);return{nodes:l,isStable:h,reheat:v}}function ms({graphData:n,currentNodeId:o,pinnedNodeIds:s,onNodeClick:e,config:t}){const r=a.useRef(null),l=a.useRef(null),[c,h]=a.useState({width:600,height:300}),[m,f]=a.useState(null),[g,y]=a.useState(null),[u,v]=a.useState({x:0,y:0}),[w,k]=a.useState(1),b=a.useRef(!1),p=a.useRef({x:0,y:0}),d=a.useMemo(()=>({...Je,...t}),[t]),{nodes:x,isStable:S}=gs({graphData:n,config:t,width:c.width,height:c.height,enabled:n.nodes.length>0});a.useEffect(()=>{const C=l.current;if(!C)return;const I=new ResizeObserver(N=>{const T=N[0];T&&h({width:T.contentRect.width,height:T.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 T=N.getBoundingClientRect(),R=(C-T.left-u.x)/w,D=(I-T.top-u.y)/w;return{x:R,y:D}},[u,w]),A=a.useCallback((C,I)=>{for(const N of x){if(N.x===void 0||N.y===void 0)continue;const T=C-N.x,R=I-N.y,D=N.id===o?d.activeNodeRadius:d.nodeRadius;if(T*T+R*R<=D*D*1.5)return N}return null},[x,o,d.nodeRadius,d.activeNodeRadius]),M=a.useCallback(C=>{b.current=!0,p.current={x:C.clientX,y:C.clientY}},[]),K=a.useCallback(()=>{b.current=!1},[]),z=a.useCallback(C=>{if(b.current){const R=C.clientX-p.current.x,D=C.clientY-p.current.y;v(W=>({x:W.x+R,y:W.y+D})),p.current={x:C.clientX,y:C.clientY};return}const{x:I,y:N}=j(C.clientX,C.clientY),T=A(I,N);if(f(T),T){const R=r.current;if(R){const D=R.getBoundingClientRect();y({x:C.clientX-D.left,y:C.clientY-D.top,node:T})}}else y(null)},[j,A]),U=a.useCallback(C=>{const{x:I,y:N}=j(C.clientX,C.clientY),T=A(I,N);T&&e&&e(T)},[j,A,e]),P=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=c.width*window.devicePixelRatio,C.height=c.height*window.devicePixelRatio,I.scale(window.devicePixelRatio,window.devicePixelRatio),I.clearRect(0,0,c.width,c.height),I.save(),I.translate(u.x,u.y),I.scale(w,w);const N=new Map;for(const T of x)T.x!==void 0&&T.y!==void 0&&N.set(T.id,{x:T.x,y:T.y});for(const T of n.edges){const R=N.get(T.source),D=N.get(T.target);!R||!D||(I.beginPath(),I.moveTo(R.x,R.y),I.lineTo(D.x,D.y),I.strokeStyle=T.type==="pinned"?d.pinnedEdgeColor:T.type==="backlink"?d.backlinkEdgeColor:d.semanticEdgeColor,I.lineWidth=T.type==="pinned"?d.edgeWidth*1.5:d.edgeWidth,T.type==="semantic"?I.setLineDash([4,4]):I.setLineDash([]),I.stroke())}I.setLineDash([]);for(const T of x){if(T.x===void 0||T.y===void 0)continue;const R=T.id===o,D=s.has(T.id),W=m?.id===T.id,Y=R?d.activeNodeRadius:d.nodeRadius,Xe=R?d.currentNodeColor:D?d.pinnedNodeColor:d.defaultNodeColor;I.beginPath(),I.arc(T.x,T.y,W?Y*1.3:Y,0,Math.PI*2),I.fillStyle=Xe,I.fill(),I.strokeStyle=W?"#fff":"rgba(0,0,0,0.2)",I.lineWidth=W?2:1,I.stroke(),R&&(I.font="10px sans-serif",I.fillStyle="#fff",I.textAlign="center",I.textBaseline="middle",I.fillText("●",T.x,T.y))}I.restore()},[x,n.edges,c,u,w,o,s,m,d]);const E=C=>{const I=C.split(/[/\\]/);return I[I.length-1]||C};return i.jsxs("div",{ref:l,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:c.width,height:c.height},onMouseDown:M,onMouseUp:K,onMouseMove:z,onMouseLeave:()=>{f(null),y(null),b.current=!1},onClick:U,onWheel:P}),g&&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(g.x+10,c.width-200),top:Math.min(g.y+10,c.height-60)},children:[i.jsx("p",{className:"font-medium truncate",children:E(g.node.filePath)}),i.jsxs("p",{style:{color:"var(--ws-text-faint)"},children:["Chunk #",g.node.chunkIndex]}),i.jsx("p",{className:"mt-1 line-clamp-2",style:{color:"var(--ws-text-muted)"},children:g.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:l}=wn(),{graphData:c,currentNodeId:h}=Rn({filePath:s??"",activeChunkIndex:e,relatedChunks:t,pins:l}),m=a.useMemo(()=>{const g=new Set;for(const y of l)g.add(`${y.sourceKey.filePath}:${y.sourceKey.chunkIndex}`),g.add(`${y.targetKey.filePath}:${y.targetKey.chunkIndex}`);return g},[l]),f=g=>{o({docId:g.filePath,chunkIndex:g.chunkIndex,source:"graph"})};return s?r?i.jsx("div",{className:"ws-rail-loading",children:"Loading graph..."}):c.nodes.length===0?i.jsx(L,{message:"No graph data available"}):i.jsx("div",{style:{height:"100%",minHeight:300},children:i.jsx(ms,{graphData:c,currentNodeId:h,pinnedNodeIds:m,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:ls,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:l=>t(l),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 l=a.useCallback(()=>{const h=t.goBack();h&&(r.current=!0,e({docId:h.docId,chunkIndex:h.chunkIndex,source:"backlink"}))},[t,e]),c=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:l,onNavigateForward:c}),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(lt,{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]),l=a.useCallback(()=>{t(h=>h==="skim"?"full":"skim")},[t]),c=a.useMemo(()=>({mode:e,setMode:r,toggleMode:l,isSkimMode:e==="skim",isFullMode:e==="full"}),[e,r,l]);return i.jsx(Is.Provider,{value:c,children:n})}const Ts=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:Ts,children:i.jsx(rt,{children:i.jsx(Xt,{children:i.jsx(jt,{children:i.jsx(ct,{children:i.jsx(Mt,{dbId:"default",children:i.jsx(yn,{children:i.jsx(ds,{children:i.jsx(Pn,{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,Rn as c,bn as d,En as e,wn as f,Ds as g,Ps as h,Rs as i,Tt 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,_ as v,Gs as w,Js as x,pn as y,Ls as z};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{a as T,j as Y}from"./query-DPt-uCb6.js";const Ge=T.createContext({});function _e(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const $s=typeof window<"u",Hs=$s?T.useLayoutEffect:T.useEffect,ee=T.createContext(null);function Xe(t,e){t.indexOf(e)===-1&&t.push(e)}function _t(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 Ye=()=>{};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 qe(t){let e;return()=>(e===void 0&&(e=t()),e)}const W=t=>t,Do=(t,e)=>n=>e(t(n)),Lt=(...t)=>t.reduce(Do),Ct=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Ze{constructor(){this.subscriptions=[]}add(e){return Xe(this.subscriptions,e),()=>_t(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 Xs(t,e){return e?t*(1e3/e):0}const Ys=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Eo=1e-7,Ro=12;function Lo(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=Ys(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Eo&&++a<Ro);return o}function kt(t,e,n,s){if(t===e&&n===s)return W;const i=r=>Lo(r,0,1,t,n);return r=>r===0||r===1?r:Ys(i(r),e,s)}const qs=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Zs=t=>e=>1-t(1-e),Js=kt(.33,1.53,.69,.99),Je=Zs(Js),Qs=qs(Je),ti=t=>(t*=2)<1?.5*Je(t):.5*(2-Math.pow(2,-10*(t-1))),Qe=t=>1-Math.sin(Math.acos(t)),ei=Zs(Qe),ni=qs(Qe),ko=kt(.42,0,1,1),Fo=kt(0,0,.58,1),si=kt(.42,0,.58,1),Io=t=>Array.isArray(t)&&typeof t[0]!="number",ii=t=>Array.isArray(t)&&typeof t[0]=="number",Bo={linear:W,easeIn:ko,easeInOut:si,easeOut:Fo,circIn:Qe,circInOut:ni,circOut:ei,backIn:Je,backInOut:Qs,backOut:Js,anticipate:ti},jo=t=>typeof t=="string",Cn=t=>{if(ii(t)){Ye(t.length===4);const[e,n,s,i]=t;return kt(e,n,s,i)}else if(jo(t))return Bo[t];return t},Bt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Oo(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 l(u){o.has(u)&&(c.schedule(u),t()),u(a)}const c={schedule:(u,h=!1,f=!1)=>{const p=f&&i?n:s;return h&&o.add(u),p.has(u)||p.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const No=40;function oi(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Bt.reduce((v,S)=>(v[S]=Oo(r),v),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:h,preRender:f,render:d,postRender:p}=o,y=()=>{const v=q.useManualTiming?i.timestamp:performance.now();n=!1,q.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(v-i.timestamp,No),1)),i.timestamp=v,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),h.process(i),f.process(i),d.process(i),p.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(y))},g=()=>{n=!0,s=!0,i.isProcessing||t(y)};return{schedule:Bt.reduce((v,S)=>{const P=o[S];return v[S]=(V,E=!1,b=!1)=>(n||g(),P.schedule(V,E,b)),v},{}),cancel:v=>{for(let S=0;S<Bt.length;S++)o[Bt[S]].cancel(v)},state:i,steps:o}}const{schedule:C,cancel:Q,state:I,steps:re}=oi(typeof requestAnimationFrame<"u"?requestAnimationFrame:W,!0);let Ut;function Uo(){Ut=void 0}const j={now:()=>(Ut===void 0&&j.set(I.isProcessing||q.useManualTiming?I.timestamp:performance.now()),Ut),set:t=>{Ut=t,queueMicrotask(Uo)}},ri=t=>e=>typeof e=="string"&&e.startsWith(t),ai=ri("--"),Wo=ri("var(--"),tn=t=>Wo(t)?Ko.test(t.split("/*")[0].trim()):!1,Ko=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Mn(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Mt={...yt,transform:t=>X(0,1,t)},jt={...yt,default:1},St=t=>Math.round(t*1e5)/1e5,en=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function $o(t){return t==null}const Ho=/^(?:#[\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"&&Ho.test(n)&&n.startsWith(t)||e&&!$o(n)&&Object.prototype.hasOwnProperty.call(n,e)),li=(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}},zo=t=>X(0,255,t),ae={...yt,transform:t=>Math.round(zo(t))},ot={test:nn("rgb","red"),parse:li("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 Go(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:Go,transform:ot.transform},Ft=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Z=Ft("deg"),_=Ft("%"),w=Ft("px"),_o=Ft("vh"),Xo=Ft("vw"),Dn={..._,parse:t=>_.parse(t)/100,transform:t=>_.transform(t*100)},ut={test:nn("hsl","hue"),parse:li("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=>ot.test(t)||Se.test(t)||ut.test(t),parse:t=>ot.test(t)?ot.parse(t):ut.test(t)?ut.parse(t):Se.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ot.transform(t):ut.transform(t),getAnimatableNone:t=>{const e=R.parse(t);return e.alpha=0,R.transform(e)}},Yo=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function qo(t){return isNaN(t)&&typeof t=="string"&&(t.match(en)?.length||0)+(t.match(Yo)?.length||0)>0}const ci="number",ui="color",Zo="var",Jo="var(",En="${}",Qo=/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(Qo,l=>(R.test(l)?(s.color.push(r),i.push(ui),n.push(R.parse(l))):l.startsWith(Jo)?(s.var.push(r),i.push(Zo),n.push(l)):(s.number.push(r),i.push(ci),n.push(parseFloat(l))),++r,En)).split(En);return{values:n,split:a,indexes:s,types:i}}function hi(t){return Dt(t).values}function fi(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===ci?r+=St(i[o]):a===ui?r+=R.transform(i[o]):r+=i[o]}return r}}const tr=t=>typeof t=="number"?0:R.test(t)?R.getAnimatableNone(t):t;function er(t){const e=hi(t);return fi(t)(e.map(tr))}const tt={test:qo,parse:hi,createTransformer:fi,getAnimatableNone:er};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 nr({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,l=2*n-a;i=le(l,a,t+1/3),r=le(l,a,t),o=le(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Xt(t,e){return n=>n>0?e:t}const M=(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)},sr=[Se,ot,ut],ir=t=>sr.find(e=>e.test(t));function Rn(t){const e=ir(t);if(!e)return!1;let n=e.parse(t);return e===ut&&(n=nr(n)),n}const Ln=(t,e)=>{const n=Rn(t),s=Rn(e);if(!n||!s)return Xt(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=M(n.alpha,s.alpha,r),ot.transform(i))},be=new Set(["none","hidden"]);function or(t,e){return be.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function rr(t,e){return n=>M(t,e,n)}function sn(t){return typeof t=="number"?rr:typeof t=="string"?tn(t)?Xt:R.test(t)?Ln:cr:Array.isArray(t)?di:typeof t=="object"?R.test(t)?Ln:ar:Xt}function di(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 ar(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 lr(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 cr=(t,e)=>{const n=tt.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?or(t,e):Lt(di(lr(s,i),i.values),n):Xt(t,e)};function pi(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?M(t,e,n):sn(t)(t,e)}const ur=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>C.update(e,n),stop:()=>Q(e),now:()=>I.isProcessing?I.timestamp:j.now()}},mi=(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)})`},Yt=2e4;function on(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Yt;)e+=n,s=t.next(e);return e>=Yt?1/0:e}function hr(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(on(s),Yt);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:U(i)}}const fr=5;function gi(t,e,n){const s=Math.max(e-fr,0);return Xs(n-t(s),e-s)}const D={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 dr({duration:t=D.duration,bounce:e=D.bounce,velocity:n=D.velocity,mass:s=D.mass}){let i,r,o=1-e;o=X(D.minDamping,D.maxDamping,o),t=X(D.minDuration,D.maxDuration,U(t)),o<1?(i=c=>{const u=c*o,h=u*t,f=u-n,d=Ae(c,o),p=Math.exp(-h);return ue-f/d*p},r=c=>{const h=c*o*t,f=h*n+n,d=Math.pow(o,2)*Math.pow(c,2)*t,p=Math.exp(-h),y=Ae(Math.pow(c,2),o);return(-i(c)+ue>0?-1:1)*((f-d)*p)/y}):(i=c=>{const u=Math.exp(-c*t),h=(c-n)*t+1;return-ue+u*h},r=c=>{const u=Math.exp(-c*t),h=(n-c)*(t*t);return u*h});const a=5/t,l=mr(i,r,a);if(t=H(t),isNaN(l))return{stiffness:D.stiffness,damping:D.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:t}}}const pr=12;function mr(t,e,n){let s=n;for(let i=1;i<pr;i++)s=s-t(s)/e(s);return s}function Ae(t,e){return t*Math.sqrt(1-e*e)}const gr=["duration","bounce"],yr=["stiffness","damping","mass"];function kn(t,e){return e.some(n=>t[n]!==void 0)}function vr(t){let e={velocity:D.velocity,stiffness:D.stiffness,damping:D.damping,mass:D.mass,isResolvedFromDuration:!1,...t};if(!kn(t,yr)&&kn(t,gr))if(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:D.mass,stiffness:i,damping:r}}else{const n=dr(t);e={...e,...n,mass:D.mass},e.isResolvedFromDuration=!0}return e}function qt(t=D.visualDuration,e=D.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:l,damping:c,mass:u,duration:h,velocity:f,isResolvedFromDuration:d}=vr({...n,velocity:-U(n.velocity||0)}),p=f||0,y=c/(2*Math.sqrt(l*u)),g=o-r,m=U(Math.sqrt(l/u)),x=Math.abs(g)<5;s||(s=x?D.restSpeed.granular:D.restSpeed.default),i||(i=x?D.restDelta.granular:D.restDelta.default);let v;if(y<1){const P=Ae(m,y);v=V=>{const E=Math.exp(-y*m*V);return o-E*((p+y*m*g)/P*Math.sin(P*V)+g*Math.cos(P*V))}}else if(y===1)v=P=>o-Math.exp(-m*P)*(g+(p+m*g)*P);else{const P=m*Math.sqrt(y*y-1);v=V=>{const E=Math.exp(-y*m*V),b=Math.min(P*V,300);return o-E*((p+y*m*g)*Math.sinh(b)+P*g*Math.cosh(b))/P}}const S={calculatedDuration:d&&h||null,next:P=>{const V=v(P);if(d)a.done=P>=h;else{let E=P===0?p:0;y<1&&(E=P===0?H(p):gi(v,P,V));const b=Math.abs(E)<=s,A=Math.abs(o-V)<=i;a.done=b&&A}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(on(S),Yt),V=mi(E=>S.next(P*E).value,P,30);return P+"ms "+V},toTransition:()=>{}};return S}qt.applyToOptions=t=>{const e=hr(t,100,qt);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:l,restDelta:c=.5,restSpeed:u}){const h=t[0],f={done:!1,value:h},d=b=>a!==void 0&&b<a||l!==void 0&&b>l,p=b=>a===void 0?l:l===void 0||Math.abs(a-b)<Math.abs(l-b)?a:l;let y=n*e;const g=h+y,m=o===void 0?g:o(g);m!==g&&(y=m-h);const x=b=>-y*Math.exp(-b/s),v=b=>m+x(b),S=b=>{const A=x(b),L=v(b);f.done=Math.abs(A)<=c,f.value=f.done?m:L};let P,V;const E=b=>{d(f.value)&&(P=b,V=qt({keyframes:[f.value,p(f.value)],velocity:gi(v,b,f.value),damping:i,stiffness:r,restDelta:c,restSpeed:u}))};return E(0),{calculatedDuration:null,next:b=>{let A=!1;return!V&&P===void 0&&(A=!0,S(b),E(b)),P!==void 0&&b>=P?V.next(b-P):(!A&&S(b),f)}}}function Tr(t,e,n){const s=[],i=n||q.mix||pi,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||W:e;a=Lt(l,a)}s.push(a)}return s}function xr(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(Ye(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=Tr(e,s,i),l=a.length,c=u=>{if(o&&u<t[0])return e[0];let h=0;if(l>1)for(;h<t.length-2&&!(u<t[h+1]);h++);const f=Ct(t[h],t[h+1],u);return a[h](f)};return n?u=>c(X(t[0],t[r-1],u)):c}function wr(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ct(0,e,s);t.push(M(n,1,i))}}function Pr(t){const e=[0];return wr(e,t.length-1),e}function Sr(t,e){return t.map(n=>n*e)}function br(t,e){return t.map(()=>e||si).splice(0,t.length-1)}function bt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Io(s)?s.map(Cn):Cn(s),r={done:!1,value:e[0]},o=Sr(n&&n.length===e.length?n:Pr(e),t),a=xr(o,e,{ease:Array.isArray(i)?i:br(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const Ar=t=>t!==null;function rn(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(Ar),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Vr={decay:Ve,inertia:Ve,tween:bt,keyframes:bt,spring:qt};function yi(t){typeof t.type=="string"&&(t.type=Vr[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 Cr=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;yi(e);const{type:n=bt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||bt;l!==bt&&typeof a[0]!="number"&&(this.mixKeyframes=Lt(Cr,pi(a[0],a[1])),a=[0,100]);const c=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=on(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=c}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:l}=this;if(this.startTime===null)return s.next(0);const{delay:c=0,keyframes:u,repeat:h,repeatType:f,repeatDelay:d,type:p,onUpdate:y,finalKeyframe:g}=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 m=this.currentTime-c*(this.playbackSpeed>=0?1:-1),x=this.playbackSpeed>=0?m<0:m>i;this.currentTime=Math.max(m,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let v=this.currentTime,S=s;if(h){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,h+1),A%2&&(f==="reverse"?(L=1-L,d&&(L-=d/a)):f==="mirror"&&(S=o)),v=X(0,1,L)*a}const P=x?{done:!1,value:u[0]}:S.next(v);r&&(P.value=r(P.value));let{done:V}=P;!x&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const E=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return E&&p!==Ve&&(P.value=rn(u,this.options,g,this.speed)),y&&y(P.value),E&&this.finish(),P}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=ur,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 Mr(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const rt=t=>t*180/Math.PI,Ce=t=>{const e=rt(Math.atan2(t[1],t[0]));return Me(e)},Dr={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=>rt(Math.atan(t[1])),skewY:t=>rt(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]),Er={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(rt(Math.atan2(t[6],t[5]))),rotateY:t=>Me(rt(Math.atan2(-t[2],t[0]))),rotateZ:Fn,rotate:Fn,skewX:t=>rt(Math.atan(t[4])),skewY:t=>rt(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=Er,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Dr,i=a}if(!i)return De(e);const r=s[e],o=i[1].split(",").map(Lr);return typeof r=="function"?r(o):o[r]}const Rr=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Ee(n,e)};function Lr(t){return parseFloat(t.trim())}const vt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Tt=new Set(vt),jn=t=>t===yt||t===w,kr=new Set(["x","y","z"]),Fr=vt.filter(t=>!kr.has(t));function Ir(t){const e=[];return Fr.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const J={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")};J.translateX=J.x;J.translateY=J.y;const at=new Set;let Re=!1,Le=!1,ke=!1;function vi(){if(Le){const t=Array.from(at).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Ir(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,at.forEach(t=>t.complete(ke)),at.clear()}function Ti(){at.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Le=!0)})}function Br(){ke=!0,Ti(),vi(),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?(at.add(this),Re||(Re=!0,C.read(Ti),C.resolveKeyframes(vi))):(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])}Mr(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),at.delete(this)}cancel(){this.state==="scheduled"&&(at.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const jr=t=>t.startsWith("--");function Or(t,e,n){jr(e)?t.style.setProperty(e,n):t.style[e]=n}const Nr=qe(()=>window.ScrollTimeline!==void 0),Ur={};function Wr(t,e){const n=qe(t);return()=>Ur[e]??n()}const xi=Wr(()=>{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 wi(t,e){if(t)return typeof t=="function"?xi()?mi(t,e):"ease-out":ii(t)?Pt(t):Array.isArray(t)?t.map(n=>wi(n,e)||On.easeOut):On[t]}function Kr(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const h=wi(a,i);Array.isArray(h)&&(u.easing=h);const f={delay:s,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),t.animate(u,f)}function Pi(t){return typeof t=="function"&&"applyToOptions"in t}function $r({type:t,...e}){return Pi(t)&&xi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Si 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:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,Ye(typeof e.type!="string");const c=$r(e);this.animation=Kr(n,s,i,c,r),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=rn(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):Or(n,s,u),this.animation.cancel()}l?.(),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,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Nr()?(this.animation.timeline=e,W):n(this)}}const bi={anticipate:ti,backInOut:Qs,circInOut:ni};function Hr(t){return t in bi}function zr(t){typeof t.ease=="string"&&Hr(t.ease)&&(t.ease=bi[t.ease])}const he=10;class Gr extends Si{constructor(e){zr(e),yi(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}),l=Math.max(he,j.now()-this.startTime),c=X(0,he,l-he);n.setWithVelocity(a.sample(Math.max(0,l-c)).value,a.sample(l).value,c),a.stop()}}const Nn=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(tt.test(t)||t==="0")&&!t.startsWith("url("));function _r(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 Xr(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:_r(t)||(n==="spring"||Pi(n))&&s}function Fe(t){t.duration=0,t.type="keyframes"}const Yr=new Set(["opacity","clipPath","filter","transform"]),qr=qe(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Zr(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:l,transformTemplate:c}=e.owner.getProps();return qr()&&n&&Yr.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const Jr=40;class Qr extends an{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=j.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:c,element:u,...h},d=u?.KeyframeResolver||cn;this.keyframeResolver=new d(a,(p,y,g)=>this.onKeyframesResolved(p,y,f,!g),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=j.now(),Xr(e,r,o,a)||((q.instantAnimations||!l)&&u?.(rn(e,s,n)),e[0]=e[e.length-1],Fe(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Jr?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},d=!c&&Zr(f),p=f.motionValue?.owner?.current,y=d?new Gr({...f,element:p}):new ln(f);y.finished.then(()=>{this.notifyFinished()}).catch(W),this.pendingTimeline&&(this.stopTimeline=y.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=y}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(),Br()),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 Ai(t,e,n,s=0,i=1){const r=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}const ta=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ea(t){const e=ta.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}function Vi(t,e,n=1){const[s,i]=ea(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)?Vi(i,e,n+1):i}const na={type:"spring",stiffness:500,damping:25,restSpeed:10},sa=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),ia={type:"keyframes",duration:.8},oa={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ra=(t,{keyframes:e})=>e.length>2?ia:Tt.has(t)?t.startsWith("scale")?sa(e[1]):na:oa,aa=t=>t!==null;function la(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(aa),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}function Ci(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?Ci(n,t):n}function ca({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const hn=(t,e,n,s={},i,r)=>o=>{const a=un(s,t)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-H(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};ca(a)||Object.assign(u,ra(t,u)),u.duration&&(u.duration=H(u.duration)),u.repeatDelay&&(u.repeatDelay=H(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let h=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Fe(u),u.delay===0&&(h=!0)),(q.instantAnimations||q.skipAnimations||i?.shouldSkipAnimations)&&(h=!0,Fe(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,h&&!r&&e.get()!==void 0){const f=la(u.keyframes,a);if(f!==void 0){C.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new ln(u):new Qr(u)};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 mt(t,e,n){const s=t.getProps();return fn(s,e,n!==void 0?n:s.custom,t)}const Mi=new Set(["width","height","top","left","right","bottom",...vt]),Wn=30,ua=t=>!isNaN(parseFloat(t));class ha{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=ua(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 Xs(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 gt(t,e){return new ha(t,e)}const Ie=t=>Array.isArray(t);function fa(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,gt(n))}function da(t){return Ie(t)?t[t.length-1]||0:t}function pa(t,e){const n=mt(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=da(r[o]);fa(t,o,a)}}const B=t=>!!(t&&t.getVelocity);function ma(t){return!!(B(t)&&t.add)}function Be(t,e){const n=t.getValue("willChange");if(ma(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 ga="framerAppearId",Di="data-"+dn(ga);function Ei(t){return t.props[Di]}function ya({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Ri(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r,transitionEnd:o,...a}=e;const l=t.getDefaultTransition();r=r?Ci(r,l):l;const c=r?.reduceMotion;s&&(r=s);const u=[],h=i&&t.animationState&&t.animationState.getState()[i];for(const f in a){const d=t.getValue(f,t.latestValues[f]??null),p=a[f];if(p===void 0||h&&ya(h,f))continue;const y={delay:n,...un(r||{},f)},g=d.get();if(g!==void 0&&!d.isAnimating&&!Array.isArray(p)&&p===g&&!y.velocity)continue;let m=!1;if(window.MotionHandoffAnimation){const S=Ei(t);if(S){const P=window.MotionHandoffAnimation(S,f,C);P!==null&&(y.startTime=P,m=!0)}}Be(t,f);const x=c??t.shouldReduceMotion;d.start(hn(f,d,p,x&&Mi.has(f)?{type:!1}:y,t,m));const v=d.animation;v&&u.push(v)}if(o){const f=()=>C.update(()=>{o&&pa(t,o)});u.length?Promise.all(u).then(f):f()}return u}function je(t,e,n={}){const s=mt(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(Ri(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:h}=i;return va(t,e,l,c,u,h,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>c())}else return Promise.all([r(),o(n.delay)])}function va(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(je(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Ai(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Ta(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"?mt(t,e,n.custom):e;s=Promise.all(Ri(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}const xa={test:t=>t==="auto",parse:t=>t},Li=t=>e=>e.test(t),ki=[yt,w,_,Z,Xo,_o,xa],Kn=t=>ki.find(Li(t));function wa(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_s(t):!0}const Pa=new Set(["brightness","contrast","saturate","opacity"]);function Sa(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=Pa.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const ba=/\b([a-z-]*)\(.*?\)/gu,Oe={...tt,getAnimatableNone:t=>{const e=t.match(ba);return e?e.map(Sa).join(" "):t}},$n={...yt,transform:Math.round},Aa={rotate:Z,rotateX:Z,rotateY:Z,rotateZ:Z,scale:jt,scaleX:jt,scaleY:jt,scaleZ:jt,skew:Z,skewX:Z,skewY:Z,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,...Aa,zIndex:$n,fillOpacity:Mt,strokeOpacity:Mt,numOctaves:$n},Va={...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},Fi=t=>Va[t];function Ii(t,e){let n=Fi(t);return n!==Oe&&(n=tt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ca=new Set(["auto","none","0"]);function Ma(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!Ca.has(r)&&Dt(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Ii(n,i)}class Da 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 u=0;u<e.length;u++){let h=e[u];if(typeof h=="string"&&(h=h.trim(),tn(h))){const f=Vi(h,n.current);f!==void 0&&(e[u]=f),u===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Mi.has(s)||e.length!==2)return;const[i,r]=e,o=Kn(i),a=Kn(r),l=Mn(i),c=Mn(r);if(l!==c&&J[s]){this.needsMeasurement=!0;return}if(o!==a)if(jn(o)&&jn(a))for(let u=0;u<e.length;u++){const h=e[u];typeof h=="string"&&(e[u]=parseFloat(h))}else J[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||wa(e[i]))&&s.push(i);s.length&&Ma(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=J[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]=J[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}const Ea=new Set(["opacity","clipPath","filter","transform"]);function Bi(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 ji=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Ne(t){return Gs(t)&&"offsetHeight"in t}const{schedule:mn}=oi(queueMicrotask,!1),$={x:!1,y:!1};function Oi(){return $.x||$.y}function Ra(t){return t==="x"||t==="y"?$[t]?null:($[t]=!0,()=>{$[t]=!1}):$.x||$.y?null:($.x=$.y=!0,()=>{$.x=$.y=!1})}function Ni(t,e){const n=Bi(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function La(t){return!(t.pointerType==="touch"||Oi())}function ka(t,e,n={}){const[s,i,r]=Ni(t,n);return s.forEach(o=>{let a=!1,l=!1,c;const u=()=>{o.removeEventListener("pointerleave",p)},h=g=>{c&&(c(g),c=void 0),u()},f=g=>{a=!1,window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),l&&(l=!1,h(g))},d=()=>{a=!0,window.addEventListener("pointerup",f,i),window.addEventListener("pointercancel",f,i)},p=g=>{if(g.pointerType!=="touch"){if(a){l=!0;return}h(g)}},y=g=>{if(!La(g))return;l=!1;const m=e(o,g);typeof m=="function"&&(c=m,o.addEventListener("pointerleave",p,i))};o.addEventListener("pointerenter",y,i),o.addEventListener("pointerdown",d,i)}),r}const Ui=(t,e)=>e?t===e?!0:Ui(t,e.parentElement):!1,gn=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Fa=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Ia(t){return Fa.has(t.tagName)||t.isContentEditable===!0}const Ba=new Set(["INPUT","SELECT","TEXTAREA"]);function ja(t){return Ba.has(t.tagName)||t.isContentEditable===!0}const Wt=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 Oa=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Hn(()=>{if(Wt.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)&&!Oi()}const Gn=new WeakSet;function Na(t,e,n={}){const[s,i,r]=Ni(t,n),o=a=>{const l=a.currentTarget;if(!zn(a)||Gn.has(a))return;Wt.add(l),n.stopPropagation&&Gn.add(a);const c=e(l,a),u=(d,p)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",f),Wt.has(l)&&Wt.delete(l),zn(d)&&typeof c=="function"&&c(d,{success:p})},h=d=>{u(d,l===window||l===document||n.useGlobalTarget||Ui(l,d.target))},f=d=>{u(d,!1)};window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Ne(a)&&(a.addEventListener("focus",c=>Oa(c,i)),!Ia(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function yn(t){return Gs(t)&&"ownerSVGElement"in t}const Kt=new WeakMap;let $t;const Wi=(t,e,n)=>(s,i)=>i&&i[0]?i[0][t+"Size"]:yn(s)&&"getBBox"in s?s.getBBox()[e]:s[n],Ua=Wi("inline","width","offsetWidth"),Wa=Wi("block","height","offsetHeight");function Ka({target:t,borderBoxSize:e}){Kt.get(t)?.forEach(n=>{n(t,{get width(){return Ua(t,e)},get height(){return Wa(t,e)}})})}function $a(t){t.forEach(Ka)}function Ha(){typeof ResizeObserver>"u"||($t=new ResizeObserver($a))}function za(t,e){$t||Ha();const n=Bi(t);return n.forEach(s=>{let i=Kt.get(s);i||(i=new Set,Kt.set(s,i)),i.add(e),$t?.observe(s)}),()=>{n.forEach(s=>{const i=Kt.get(s);i?.delete(e),i?.size||$t?.unobserve(s)})}}const Ht=new Set;let ht;function Ga(){ht=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Ht.forEach(e=>e(t))},window.addEventListener("resize",ht)}function _a(t){return Ht.add(t),ht||Ga(),()=>{Ht.delete(t),!Ht.size&&typeof ht=="function"&&(window.removeEventListener("resize",ht),ht=void 0)}}function _n(t,e){return typeof t=="function"?_a(t):za(t,e)}function Xa(t){return yn(t)&&t.tagName==="svg"}const Ya=[...ki,R,tt],qa=t=>Ya.find(Li(t)),Xn=()=>({translate:0,scale:1,origin:0,originPoint:0}),ft=()=>({x:Xn(),y:Xn()}),Yn=()=>({min:0,max:0}),k=()=>({x:Yn(),y:Yn()}),Za=new WeakMap;function ne(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 se(t){return ne(t.animate)||Tn.some(e=>Et(t[e]))}function Ki(t){return!!(se(t)||t.variants)}function Ja(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,gt(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,gt(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Ue={current:null},$i={current:!1},Qa=typeof window<"u";function tl(){if($i.current=!0,!!Qa)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Ue.current=t.matches;t.addEventListener("change",e),e()}else Ue.current=!1}const qn=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Zt={};function Hi(t){Zt=t}function el(){return Zt}class nl{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,skipAnimations:r,blockInitialAnimation:o,visualState:a},l={}){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:c,renderState:u}=a;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=r,this.options=l,this.blockInitialAnimation=!!o,this.isControllingVariants=se(n),this.isVariantNode=Ki(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:h,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const d in f){const p=f[d];c[d]!==void 0&&B(p)&&p.set(c[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,Za.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:($i.current||tl(),this.shouldReduceMotion=Ue.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(),Q(this.notifyUpdate),Q(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&&Ea.has(e)&&this.current instanceof HTMLElement){const{factory:o,keyframes:a,times:l,ease:c,duration:u}=n.accelerate,h=new Si({element:this.current,name:e,keyframes:a,times:l,ease:c,duration:H(u)}),f=o(h);this.valueSubscriptions.set(e,()=>{f(),h.cancel()});return}const s=Tt.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 Zt){const n=Zt[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=Ja(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=gt(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):!qa(s)&&tt.test(n)&&(s=Ii(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 zi extends nl{constructor(){super(...arguments),this.KeyframeResolver=Da}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 Gi({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function sl({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function il(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 We({scale:t,scaleX:e,scaleY:n}){return!de(t)||!de(e)||!de(n)}function it(t){return We(t)||_i(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function _i(t){return Zn(t.x)||Zn(t.y)}function Zn(t){return t&&t!=="0%"}function Jt(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=Jt(t,i,s)),Jt(t,n,s)+e}function Ke(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 Xi(t,{x:e,y:n}){Ke(t.x,e.translate,e.scale,e.originPoint),Ke(t.y,n.translate,n.scale,n.originPoint)}const Qn=.999999999999,ts=1.0000000000001;function ol(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:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&pt(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,Xi(t,o)),s&&it(r.latestValues)&&pt(t,r.latestValues))}e.x<ts&&e.x>Qn&&(e.x=1),e.y<ts&&e.y>Qn&&(e.y=1)}function dt(t,e){t.min=t.min+e,t.max=t.max+e}function es(t,e,n,s,i=.5){const r=M(t.min,t.max,i);Ke(t,e,n,r,s)}function pt(t,e){es(t.x,e.x,e.scaleX,e.scale,e.originX),es(t.y,e.y,e.scaleY,e.scale,e.originY)}function Yi(t,e){return Gi(il(t.getBoundingClientRect(),e))}function rl(t,e,n){const s=Yi(t,n),{scroll:i}=e;return i&&(dt(s.x,i.offset.x),dt(s.y,i.offset.y)),s}const al={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ll=vt.length;function cl(t,e,n){let s="",i=!0;for(let r=0;r<ll;r++){const o=vt[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number")l=a===(o.startsWith("scale")?1:0);else{const c=parseFloat(a);l=o.startsWith("scale")?c===1:c===0}if(!l||n){const c=ji(a,pn[o]);if(!l){i=!1;const u=al[o]||o;s+=`${u}(${c}) `}n&&(e[o]=c)}}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 l in e){const c=e[l];if(Tt.has(l)){o=!0;continue}else if(ai(l)){i[l]=c;continue}else{const u=ji(c,pn[l]);l.startsWith("origin")?(a=!0,r[l]=u):s[l]=u}}if(e.transform||(o||n?s.transform=cl(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=r;s.transformOrigin=`${l} ${c} ${u}`}}function qi(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 ns(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=ns(t,e.target.x),s=ns(t,e.target.y);return`${n}% ${s}%`}},ul={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=tt.parse(t);if(i.length>5)return s;const r=tt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const c=M(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),r(i)}},$e={borderRadius:{...wt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:wt,borderTopRightRadius:wt,borderBottomLeftRadius:wt,borderBottomRightRadius:wt,boxShadow:ul};function Zi(t,{layout:e,layoutId:n}){return Tt.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!$e[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])||Zi(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}function hl(t){return window.getComputedStyle(t)}class fl extends zi{constructor(){super(...arguments),this.type="html",this.renderInstance=qi}readValueFromInstance(e,n){if(Tt.has(n))return this.projection?.isProjecting?De(n):Rr(e,n);{const s=hl(e),i=(ai(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Yi(e,n)}build(e,n,s){xn(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return wn(e,n,s)}}const dl={offset:"stroke-dashoffset",array:"stroke-dasharray"},pl={offset:"strokeDashoffset",array:"strokeDasharray"};function ml(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?dl:pl;t[r.offset]=`${-s}`,t[r.array]=`${e} ${n}`}const gl=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Ji(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,c,u){if(xn(t,a,c),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:h,style:f}=t;h.transform&&(f.transform=h.transform,delete h.transform),(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete h.transformBox);for(const d of gl)h[d]!==void 0&&(f[d]=h[d],delete h[d]);e!==void 0&&(h.x=e),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),i!==void 0&&ml(h,i,r,o,!1)}const Qi=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"]),to=t=>typeof t=="string"&&t.toLowerCase()==="svg";function yl(t,e,n,s){qi(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Qi.has(i)?i:dn(i),e.attrs[i])}function eo(t,e,n){const s=wn(t,e,n);for(const i in t)if(B(t[i])||B(e[i])){const r=vt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}class vl extends zi{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=k}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Tt.has(n)){const s=Fi(n);return s&&s.default||0}return n=Qi.has(n)?n:dn(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return eo(e,n,s)}build(e,n,s){Ji(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){yl(e,n,s,i)}mount(e){this.isSVGTag=to(e.tagName),super.mount(e)}}const Tl=Tn.length;function no(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?no(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Tl;n++){const s=Tn[n],i=t.props[s];(Et(i)||i===!1)&&(e[s]=i)}return e}function so(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 xl=[...vn].reverse(),wl=vn.length;function Pl(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Ta(t,n,s)))}function Sl(t){let e=Pl(t),n=ss(),s=!0;const i=l=>(c,u)=>{const h=mt(t,u,l==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:f,transitionEnd:d,...p}=h;c={...c,...p,...d}}return c};function r(l){e=l(t)}function o(l){const{props:c}=t,u=no(t.parent)||{},h=[],f=new Set;let d={},p=1/0;for(let g=0;g<wl;g++){const m=xl[g],x=n[m],v=c[m]!==void 0?c[m]:u[m],S=Et(v),P=m===l?x.isActive:null;P===!1&&(p=g);let V=v===u[m]&&v!==c[m]&&S;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),x.protectedKeys={...d},!x.isActive&&P===null||!v&&!x.prevProp||ne(v)||typeof v=="boolean")continue;if(m==="exit"&&x.isActive&&P!==!0){x.prevResolvedValues&&(d={...d,...x.prevResolvedValues});continue}const E=bl(x.prevProp,v);let b=E||m===l&&x.isActive&&!V&&S||g>p&&S,A=!1;const L=Array.isArray(v)?v:[v];let z=L.reduce(i(m),{});P===!1&&(z={});const{prevResolvedValues:xt={}}=x,oe={...xt,...z},An=F=>{b=!0,f.has(F)&&(A=!0,f.delete(F)),x.needsAnimating[F]=!0;const N=t.getValue(F);N&&(N.liveStyle=!1)};for(const F in oe){const N=z[F],nt=xt[F];if(d.hasOwnProperty(F))continue;let lt=!1;Ie(N)&&Ie(nt)?lt=!so(N,nt):lt=N!==nt,lt?N!=null?An(F):f.add(F):N!==void 0&&f.has(F)?An(F):x.protectedKeys[F]=!0}x.prevProp=v,x.prevResolvedValues=z,x.isActive&&(d={...d,...z}),s&&t.blockInitialAnimation&&(b=!1);const Vn=V&&E;b&&(!Vn||A)&&h.push(...L.map(F=>{const N={type:m};if(typeof F=="string"&&s&&!Vn&&t.manuallyAnimateOnMount&&t.parent){const{parent:nt}=t,lt=mt(nt,F);if(nt.enteringChildren&<){const{delayChildren:Mo}=lt.transition||{};N.delay=Ai(nt.enteringChildren,t,Mo)}}return{animation:F,options:N}}))}if(f.size){const g={};if(typeof c.initial!="boolean"){const m=mt(t,Array.isArray(c.initial)?c.initial[0]:c.initial);m&&m.transition&&(g.transition=m.transition)}f.forEach(m=>{const x=t.getBaseTarget(m),v=t.getValue(m);v&&(v.liveStyle=!0),g[m]=x??null}),h.push({animation:g})}let y=!!h.length;return s&&(c.initial===!1||c.initial===c.animate)&&!t.manuallyAnimateOnMount&&(y=!1),s=!1,y?e(h):Promise.resolve()}function a(l,c){if(n[l].isActive===c)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(l,c)),n[l].isActive=c;const u=o(l);for(const h in n)n[h].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=ss()}}}function bl(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!so(e,t):!1}function st(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ss(){return{animate:st(!0),whileInView:st(),whileHover:st(),whileTap:st(),whileDrag:st(),whileFocus:st(),exit:st()}}function is(t,e){t.min=e.min,t.max=e.max}function K(t,e){is(t.x,e.x),is(t.y,e.y)}function os(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const io=1e-4,Al=1-io,Vl=1+io,oo=.01,Cl=0-oo,Ml=0+oo;function O(t){return t.max-t.min}function Dl(t,e,n){return Math.abs(t-e)<=n}function rs(t,e,n,s=.5){t.origin=s,t.originPoint=M(e.min,e.max,t.origin),t.scale=O(n)/O(e),t.translate=M(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Al&&t.scale<=Vl||isNaN(t.scale))&&(t.scale=1),(t.translate>=Cl&&t.translate<=Ml||isNaN(t.translate))&&(t.translate=0)}function At(t,e,n,s){rs(t.x,e.x,n.x,s?s.originX:void 0),rs(t.y,e.y,n.y,s?s.originY:void 0)}function as(t,e,n){t.min=n.min+e.min,t.max=t.min+O(e)}function El(t,e,n){as(t.x,e.x,n.x),as(t.y,e.y,n.y)}function ls(t,e,n){t.min=e.min-n.min,t.max=t.min+O(e)}function Qt(t,e,n){ls(t.x,e.x,n.x),ls(t.y,e.y,n.y)}function cs(t,e,n,s,i){return t-=e,t=Jt(t,1/n,s),i!==void 0&&(t=Jt(t,1/i,s)),t}function Rl(t,e=0,n=1,s=.5,i,r=t,o=t){if(_.test(e)&&(e=parseFloat(e),e=M(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=M(r.min,r.max,s);t===r&&(a-=e),t.min=cs(t.min,e,n,a,i),t.max=cs(t.max,e,n,a,i)}function us(t,e,[n,s,i],r,o){Rl(t,e[n],e[s],e[i],e.scale,r,o)}const Ll=["x","scaleX","originX"],kl=["y","scaleY","originY"];function hs(t,e,n,s){us(t.x,e,Ll,n?n.x:void 0,s?s.x:void 0),us(t.y,e,kl,n?n.y:void 0,s?s.y:void 0)}function fs(t){return t.translate===0&&t.scale===1}function ro(t){return fs(t.x)&&fs(t.y)}function ds(t,e){return t.min===e.min&&t.max===e.max}function Fl(t,e){return ds(t.x,e.x)&&ds(t.y,e.y)}function ps(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function ao(t,e){return ps(t.x,e.x)&&ps(t.y,e.y)}function ms(t){return O(t.x)/O(t.y)}function gs(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function G(t){return[t("x"),t("y")]}function Il(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:c,rotate:u,rotateX:h,rotateY:f,skewX:d,skewY:p}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}deg) `),h&&(s+=`rotateX(${h}deg) `),f&&(s+=`rotateY(${f}deg) `),d&&(s+=`skewX(${d}deg) `),p&&(s+=`skewY(${p}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const lo=["TopLeft","TopRight","BottomLeft","BottomRight"],Bl=lo.length,ys=t=>typeof t=="string"?parseFloat(t):t,vs=t=>typeof t=="number"||w.test(t);function jl(t,e,n,s,i,r){i?(t.opacity=M(0,n.opacity??1,Ol(s)),t.opacityExit=M(e.opacity??1,0,Nl(s))):r&&(t.opacity=M(e.opacity??1,n.opacity??1,s));for(let o=0;o<Bl;o++){const a=`border${lo[o]}Radius`;let l=Ts(e,a),c=Ts(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||vs(l)===vs(c)?(t[a]=Math.max(M(ys(l),ys(c),s),0),(_.test(c)||_.test(l))&&(t[a]+="%")):t[a]=c}(e.rotate||n.rotate)&&(t.rotate=M(e.rotate||0,n.rotate||0,s))}function Ts(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Ol=co(0,.5,ei),Nl=co(.5,.95,W);function co(t,e,n){return s=>s<t?0:s>e?1:n(Ct(t,e,s))}function Ul(t,e,n){const s=B(t)?t:gt(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 Wl=(t,e)=>t.depth-e.depth;class Kl{constructor(){this.children=[],this.isDirty=!1}add(e){Xe(this.children,e),this.isDirty=!0}remove(e){_t(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Wl),this.isDirty=!1,this.children.forEach(e)}}function $l(t,e){const n=j.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Q(s),t(r-e))};return C.setup(s,!0),()=>Q(s)}function zt(t){return B(t)?t.get():t}class Hl{constructor(){this.members=[]}add(e){Xe(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.isPresent!==!1&&!s.snapshot&&_t(this.members,s)}e.scheduleRender()}remove(e){if(_t(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){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i],o=r.instance;if(r.isPresent!==!1&&(!o||o.isConnected!==!1)){s=r;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender();const i=s.options.layoutDependency,r=e.options.layoutDependency;if(!(i!==void 0&&r!==void 0&&i===r)){const l=s.instance;l&&l.isConnected===!1&&!s.snapshot||(e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0))}const{crossfade:a}=e.options;a===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const Gt={hasAnimatedSinceResize:!0,hasEverUpdated:!1},pe=["","X","Y","Z"],zl=1e3;let Gl=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 uo(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ei(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&&uo(s)}function ho({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Gl++,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(Yl),this.nodes.forEach(Ql),this.nodes.forEach(tc),this.nodes.forEach(ql)},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 l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Kl)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Ze),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=yn(o)&&!Xa(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let u,h=0;const f=()=>this.root.updateBlockedByResize=!1;C.read(()=>{h=window.innerWidth}),t(o,()=>{const d=window.innerWidth;d!==h&&(h=d,this.root.updateBlockedByResize=!0,u&&u(),u=$l(f,250),Gt.hasAnimatedSinceResize&&(Gt.hasAnimatedSinceResize=!1,this.nodes.forEach(Ps)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h,hasRelativeLayoutChanged:f,layout:d})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const p=this.options.transition||c.getDefaultTransition()||oc,{onLayoutAnimationStart:y,onLayoutAnimationComplete:g}=c.getProps(),m=!this.targetLayout||!ao(this.targetLayout,d),x=!h&&f;if(this.options.layoutRoot||this.resumeFrom||x||h&&(m||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const v={...un(p,"layout"),onPlay:y,onComplete:g};(c.shouldReduceMotion||this.options.layoutRoot)&&(v.delay=0,v.type=!1),this.startAnimation(v),this.setAnimationOrigin(u,x)}else h||Ps(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(),Q(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(ec),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&&uo(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const h=this.path[u];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(xs);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(ws);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Jl),this.nodes.forEach(_l),this.nodes.forEach(Xl)):this.nodes.forEach(ws),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(Zl),this.sharedNodes.forEach(nc)}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 l=0;l<this.path.length;l++)this.path[l].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 l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ro(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||it(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),rc(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,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(ac))){const{scroll:c}=this.root;c&&(dt(a.x,c.offset.x),dt(a.y,c.offset.y))}return a}removeElementScroll(o){const a=k();if(K(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:h}=c;c!==this.root&&u&&h.layoutScroll&&(u.wasRoot&&K(a,o),dt(a.x,u.offset.x),dt(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const l=k();K(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&pt(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),it(u.latestValues)&&pt(l,u.latestValues)}return it(this.latestValues)&&pt(l,this.latestValues),l}removeTransform(o){const a=k();K(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!it(c.latestValues))continue;We(c.latestValues)&&c.updateSnapshot();const u=k(),h=c.measurePageBox();K(u,h),hs(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return it(this.latestValues)&&hs(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 l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:h}=this.options;if(!this.layout||!(u||h))return;this.resolvedRelativeTargetAt=I.timestamp;const f=this.getClosestProjectingParent();f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.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(),El(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):K(this.target,this.layout.layoutBox),Xi(this.target,this.targetDelta)):K(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||We(this.parent.latestValues)||_i(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,l){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=k(),this.relativeTargetOrigin=k(),Qt(this.relativeTargetOrigin,a,l),K(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===I.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;K(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;ol(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():(os(this.prevProjectionDelta.x,this.projectionDelta.x),os(this.prevProjectionDelta.y,this.projectionDelta.y)),At(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!gs(this.projectionDelta.x,this.prevProjectionDelta.x)||!gs(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=ft(),this.projectionDelta=ft(),this.projectionDeltaWithTransform=ft()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},h=ft();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=k(),d=l?l.source:void 0,p=this.layout?this.layout.source:void 0,y=d!==p,g=this.getStack(),m=!g||g.members.length<=1,x=!!(y&&!m&&this.options.crossfade===!0&&!this.path.some(ic));this.animationProgress=0;let v;this.mixTargetDelta=S=>{const P=S/1e3;Ss(h.x,o.x,P),Ss(h.y,o.y,P),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qt(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),sc(this.relativeTarget,this.relativeTargetOrigin,f,P),v&&Fl(this.relativeTarget,v)&&(this.isProjectionDirty=!1),v||(v=k()),K(v,this.relativeTarget)),y&&(this.animationValues=u,jl(u,c,this.latestValues,P,x,m)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Q(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=C.update(()=>{Gt.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=gt(0)),this.currentAnimation=Ul(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(zl),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&fo(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||k();const h=O(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+h;const f=O(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}K(a,l),pt(a,u),At(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Hl),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.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:l}={}){const c=this.getStack();c&&c.promote(this,l),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:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&me("z",o,c,this.animationValues);for(let u=0;u<pe.length;u++)me(`rotate${pe[u]}`,o,c,this.animationValues),me(`skew${pe[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=zt(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=zt(a?.pointerEvents)||""),this.hasProjected&&!it(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let h=Il(this.projectionDeltaWithTransform,this.treeScale,u);l&&(h=l(u,h)),o.transform=h;const{x:f,y:d}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${d.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const p in $e){if(u[p]===void 0)continue;const{correct:y,applyTo:g,isCSSVariable:m}=$e[p],x=h==="none"?u[p]:y(u[p],c);if(g){const v=g.length;for(let S=0;S<v;S++)o[g[S]]=x}else m?this.options.visualElement.renderState.vars[p]=x:o[p]=x}this.options.layoutId&&(o.pointerEvents=c===this?zt(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(xs),this.root.sharedNodes.clear()}}}function _l(t){t.updateLayout()}function Xl(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(u=>{const h=r?e.measuredBox[u]:e.layoutBox[u],f=O(h);h.min=n[u].min,h.max=h.min+f}):fo(i,e.layoutBox,n)&&G(u=>{const h=r?e.measuredBox[u]:e.layoutBox[u],f=O(n[u]);h.max=h.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=ft();At(o,n,e.layoutBox);const a=ft();r?At(a,t.applyTransform(s,!0),e.measuredBox):At(a,n,e.layoutBox);const l=!ro(o);let c=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:h,layout:f}=u;if(h&&f){const d=k();Qt(d,e.layoutBox,h.layoutBox);const p=k();Qt(p,n,f.layoutBox),ao(d,p)||(c=!0),u.options.layoutRoot&&(t.relativeTarget=p,t.relativeTargetOrigin=d,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Yl(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 ql(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Zl(t){t.clearSnapshot()}function xs(t){t.clearMeasurements()}function ws(t){t.isLayoutDirty=!1}function Jl(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Ps(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ql(t){t.resolveTargetDelta()}function tc(t){t.calcProjection()}function ec(t){t.resetSkewAndRotation()}function nc(t){t.removeLeadSnapshot()}function Ss(t,e,n){t.translate=M(e.translate,0,n),t.scale=M(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function bs(t,e,n,s){t.min=M(e.min,n.min,s),t.max=M(e.max,n.max,s)}function sc(t,e,n,s){bs(t.x,e.x,n.x,s),bs(t.y,e.y,n.y,s)}function ic(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const oc={duration:.45,ease:[.4,0,.1,1]},As=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Vs=As("applewebkit/")&&!As("chrome/")?Math.round:W;function Cs(t){t.min=Vs(t.min),t.max=Vs(t.max)}function rc(t){Cs(t.x),Cs(t.y)}function fo(t,e,n){return t==="position"||t==="preserve-aspect"&&!Dl(ms(e),ms(n),.2)}function ac(t){return t!==t.root&&t.scroll?.wasRoot}const lc=ho({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},po=ho({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!ge.current){const t=new lc({});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=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Ms(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function cc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=Ms(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():Ms(t[i],null)}}}}function uc(...t){return T.useCallback(cc(...t),t)}class hc extends T.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=Ne(s)&&s.offsetWidth||0,r=Ne(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 fc({children:t,isPresent:e,anchorX:n,anchorY:s,root:i,pop:r}){const o=T.useId(),a=T.useRef(null),l=T.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:c}=T.useContext(Pn),u=t.props?.ref??t?.ref,h=uc(a,u);return T.useInsertionEffect(()=>{const{width:f,height:d,top:p,left:y,right:g,bottom:m}=l.current;if(e||r===!1||!a.current||!f||!d)return;const x=n==="left"?`left: ${y}`:`right: ${g}`,v=s==="bottom"?`bottom: ${m}`:`top: ${p}`;a.current.dataset.motionPopId=o;const S=document.createElement("style");c&&(S.nonce=c);const P=i??document.head;return P.appendChild(S),S.sheet&&S.sheet.insertRule(`
|
|
2
|
-
[data-motion-pop-id="${o}"] {
|
|
3
|
-
position: absolute !important;
|
|
4
|
-
width: ${f}px !important;
|
|
5
|
-
height: ${d}px !important;
|
|
6
|
-
${x}px !important;
|
|
7
|
-
${v}px !important;
|
|
8
|
-
}
|
|
9
|
-
`),()=>{P.contains(S)&&P.removeChild(S)}},[e]),Y.jsx(hc,{isPresent:e,childRef:a,sizeRef:l,pop:r,children:r===!1?t:T.cloneElement(t,{ref:h})})}const dc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,anchorY:l,root:c})=>{const u=_e(pc),h=T.useId();let f=!0,d=T.useMemo(()=>(f=!1,{id:h,initial:e,isPresent:n,custom:i,onExitComplete:p=>{u.set(p,!0);for(const y of u.values())if(!y)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return r&&f&&(d={...d}),T.useMemo(()=>{u.forEach((p,y)=>u.set(y,!1))},[n]),T.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),t=Y.jsx(fc,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:l,root:c,children:t}),Y.jsx(ee.Provider,{value:d,children:t})};function pc(){return new Map}function mo(t=!0){const e=T.useContext(ee);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=T.useId();T.useEffect(()=>{if(t)return i(r)},[t]);const o=T.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const Ot=t=>t.key||"";function Ds(t){const e=[];return T.Children.forEach(t,n=>{T.isValidElement(n)&&e.push(n)}),e}const Au=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",anchorY:l="top",root:c})=>{const[u,h]=mo(o),f=T.useMemo(()=>Ds(t),[t]),d=o&&!u?[]:f.map(Ot),p=T.useRef(!0),y=T.useRef(f),g=_e(()=>new Map),m=T.useRef(new Set),[x,v]=T.useState(f),[S,P]=T.useState(f);Hs(()=>{p.current=!1,y.current=f;for(let b=0;b<S.length;b++){const A=Ot(S[b]);d.includes(A)?(g.delete(A),m.current.delete(A)):g.get(A)!==!0&&g.set(A,!1)}},[S,d.length,d.join("-")]);const V=[];if(f!==x){let b=[...f];for(let A=0;A<S.length;A++){const L=S[A],z=Ot(L);d.includes(z)||(b.splice(A,0,L),V.push(L))}return r==="wait"&&V.length&&(b=V),P(Ds(b)),v(f),null}const{forceRender:E}=T.useContext(Ge);return Y.jsx(Y.Fragment,{children:S.map(b=>{const A=Ot(b),L=o&&!u?!1:f===S||d.includes(A),z=()=>{if(m.current.has(A))return;if(m.current.add(A),g.has(A))g.set(A,!0);else return;let xt=!0;g.forEach(oe=>{oe||(xt=!1)}),xt&&(E?.(),P(y.current),o&&h?.(),s&&s())};return Y.jsx(dc,{isPresent:L,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:c,onExitComplete:L?void 0:z,anchorX:a,anchorY:l,children:b},A)})})},go=T.createContext({strict:!1}),Es={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 Rs=!1;function mc(){if(Rs)return;const t={};for(const e in Es)t[e]={isEnabled:n=>Es[e].some(s=>!!n[s])};Hi(t),Rs=!0}function yo(){return mc(),el()}function gc(t){const e=yo();for(const n in t)e[n]={...e[n],...t[n]};Hi(e)}const yc=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 te(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||yc.has(t)}let vo=t=>!te(t);function vc(t){typeof t=="function"&&(vo=e=>e.startsWith("on")?!te(e):t(e))}try{vc(require("@emotion/is-prop-valid").default)}catch{}function Tc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(vo(i)||n===!0&&te(i)||!e&&!te(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const ie=T.createContext({});function xc(t,e){if(se(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 wc(t){const{initial:e,animate:n}=xc(t,T.useContext(ie));return T.useMemo(()=>({initial:e,animate:n}),[Ls(e),Ls(n)])}function Ls(t){return Array.isArray(t)?t.join(" "):t}const Sn=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function To(t,e,n){for(const s in e)!B(e[s])&&!Zi(s,n)&&(t[s]=e[s])}function Pc({transformTemplate:t},e){return T.useMemo(()=>{const n=Sn();return xn(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Sc(t,e){const n=t.style||{},s={};return To(s,n,t),Object.assign(s,Pc(t,e)),s}function bc(t,e){const n={},s=Sc(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 xo=()=>({...Sn(),attrs:{}});function Ac(t,e,n,s){const i=T.useMemo(()=>{const r=xo();return Ji(r,e,to(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};To(r,t.style,t),i.style={...r,...i.style}}return i}const Vc=["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:!!(Vc.indexOf(t)>-1||/[A-Z]/u.test(t))}function Cc(t,e,n,{latestValues:s},i,r=!1,o){const l=(o??bn(t)?Ac:bc)(e,s,i,t),c=Tc(e,typeof t=="string",r),u=t!==T.Fragment?{...c,...l,ref:n}:{},{children:h}=e,f=T.useMemo(()=>B(h)?h.get():h,[h]);return T.createElement(t,{...u,children:f})}function Mc({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Dc(n,s,i,t),renderState:e()}}function Dc(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=zt(r[f]);let{initial:o,animate:a}=t;const l=se(t),c=Ki(t);e&&c&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const h=u?a:o;if(h&&typeof h!="boolean"&&!ne(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const p=fn(t,f[d]);if(p){const{transitionEnd:y,transition:g,...m}=p;for(const x in m){let v=m[x];if(Array.isArray(v)){const S=u?v.length-1:0;v=v[S]}v!==null&&(i[x]=v)}for(const x in y)i[x]=y[x]}}}return i}const wo=t=>(e,n)=>{const s=T.useContext(ie),i=T.useContext(ee),r=()=>Mc(t,e,s,i);return n?r():_e(r)},Ec=wo({scrapeMotionValuesFromProps:wn,createRenderState:Sn}),Rc=wo({scrapeMotionValuesFromProps:eo,createRenderState:xo}),Lc=Symbol.for("motionComponentSymbol");function kc(t,e,n){const s=T.useRef(n);T.useInsertionEffect(()=>{s.current=n});const i=T.useRef(null);return T.useCallback(r=>{r&&t.onMount?.(r),e&&(r?e.mount(r):e.unmount());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])}const Po=T.createContext({});function ct(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Fc(t,e,n,s,i,r){const{visualElement:o}=T.useContext(ie),a=T.useContext(go),l=T.useContext(ee),c=T.useContext(Pn),u=c.reducedMotion,h=c.skipAnimations,f=T.useRef(null),d=T.useRef(!1);s=s||a.renderer,!f.current&&s&&(f.current=s(t,{visualState:e,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,skipAnimations:h,isSVG:r}),d.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const p=f.current,y=T.useContext(Po);p&&!p.projection&&i&&(p.type==="html"||p.type==="svg")&&Ic(f.current,n,i,y);const g=T.useRef(!1);T.useInsertionEffect(()=>{p&&g.current&&p.update(n,l)});const m=n[Di],x=T.useRef(!!m&&!window.MotionHandoffIsComplete?.(m)&&window.MotionHasOptimisedAnimation?.(m));return Hs(()=>{d.current=!0,p&&(g.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),x.current&&p.animationState&&p.animationState.animateChanges())}),T.useEffect(()=>{p&&(!x.current&&p.animationState&&p.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(m)}),x.current=!1),p.enteringChildren=void 0)}),p}function Ic(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:So(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&ct(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:l,layoutRoot:c})}function So(t){if(t)return t.options.allowProjection!==!1?t.projection:So(t.parent)}function ye(t,{forwardMotionProps:e=!1,type:n}={},s,i){s&&gc(s);const r=n?n==="svg":bn(t),o=r?Rc:Ec;function a(c,u){let h;const f={...T.useContext(Pn),...c,layoutId:Bc(c)},{isStatic:d}=f,p=wc(c),y=o(c,d);if(!d&&$s){jc();const g=Oc(f);h=g.MeasureLayout,p.visualElement=Fc(t,y,f,i,g.ProjectionNode,r)}return Y.jsxs(ie.Provider,{value:p,children:[h&&p.visualElement?Y.jsx(h,{visualElement:p.visualElement,...f}):null,Cc(t,c,kc(y,p.visualElement,u),y,d,e,r)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=T.forwardRef(a);return l[Lc]=t,l}function Bc({layoutId:t}){const e=T.useContext(Ge).id;return e&&t!==void 0?e+"-"+t:t}function jc(t,e){T.useContext(go).strict}function Oc(t){const e=yo(),{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 Nc(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 Uc=(t,e)=>e.isSVG??bn(t)?new vl(e):new fl(e,{allowProjection:t!==T.Fragment});class Wc extends et{constructor(e){super(e),e.animationState||(e.animationState=Sl(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ne(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 Kc=0;class $c extends et{constructor(){super(...arguments),this.id=Kc++}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 Hc={animation:{Feature:Wc},exit:{Feature:$c}};function It(t){return{point:{x:t.pageX,y:t.pageY}}}const zc=t=>e=>gn(e)&&t(e,It(e));function Vt(t,e,n,s){return Rt(t,e,zc(n),s)}const bo=({current:t})=>t?t.ownerDocument.defaultView:null,ks=(t,e)=>Math.abs(t-e);function Gc(t,e){const n=ks(t.x,e.x),s=ks(t.y,e.y);return Math.sqrt(n**2+s**2)}const Fs=new Set(["auto","scroll"]);class Ao{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,y=Gc(d.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:g}=d,{timestamp:m}=I;this.history.push({...g,timestamp:m});const{onStart:x,onMove:v}=this.handlers;p||(x&&x(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),v&&v(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:y,onSessionEnd:g,resumeAnimation:m}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&m&&m(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Te(d.type==="pointercancel"?this.lastMoveEventInfo:ve(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(d,x),g&&g(d,x)},!gn(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const l=It(e),c=ve(l,this.transformPagePoint),{point:u}=c,{timestamp:h}=I;this.history=[{...u,timestamp:h}];const{onSessionStart:f}=n;f&&f(e,Te(c,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);(Fs.has(s.overflowX)||Fs.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,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),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(),Q(this.updatePoint)}}function ve(t,e){return e?{point:e(t.point)}:t}function Is(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Te({point:t},e){return{point:t,delta:Is(t,Vo(e)),offset:Is(t,_c(e)),velocity:Xc(e,.1)}}function _c(t){return t[0]}function Vo(t){return t[t.length-1]}function Xc(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Vo(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 Yc(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?M(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?M(n,t,s.max):Math.min(t,n)),t}function Bs(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 qc(t,{top:e,left:n,bottom:s,right:i}){return{x:Bs(t.x,n,i),y:Bs(t.y,e,s)}}function js(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 Zc(t,e){return{x:js(t.x,e.x),y:js(t.y,e.y)}}function Jc(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 Qc(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 He=.35;function tu(t=He){return t===!1?t=0:t===!0&&(t=He),{x:Os(t,"left","right"),y:Os(t,"top","bottom")}}function Os(t,e,n){return{min:Ns(t,e),max:Ns(t,n)}}function Ns(t,e){return typeof t=="number"?t:t[e]||0}const eu=new WeakMap;class nu{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=h=>{n&&this.snapToCursor(It(h).point),this.stopAnimation()},o=(h,f)=>{const{drag:d,dragPropagation:p,onDragStart:y}=this.getProps();if(d&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ra(d),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),G(m=>{let x=this.getAxisMotionValue(m).get()||0;if(_.test(x)){const{projection:v}=this.visualElement;if(v&&v.layout){const S=v.layout.layoutBox[m];S&&(x=O(S)*(parseFloat(x)/100))}}this.originPoint[m]=x}),y&&C.update(()=>y(h,f),!1,!0),Be(this.visualElement,"transform");const{animationState:g}=this.visualElement;g&&g.setActive("whileDrag",!0)},a=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:d,dragDirectionLock:p,onDirectionLock:y,onDrag:g}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:m}=f;if(p&&this.currentDirection===null){this.currentDirection=iu(m),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",f.point,m),this.updateAxis("y",f.point,m),this.visualElement.render(),g&&C.update(()=>g(h,f),!1,!0)},l=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new Ao(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:bo(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||!Nt(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=Yc(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&&ct(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=qc(s.layoutBox,e):this.constraints=!1,this.elastic=tu(n),i!==this.constraints&&!ct(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&G(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=Qc(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!ct(e))return!1;const s=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=rl(s,i.root,this.visualElement.getTransformPagePoint());let o=Zc(i.layout.layoutBox,r);if(n){const a=n(sl(o));this.hasMutatedConstraints=!!a,a&&(o=Gi(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=G(u=>{if(!Nt(u,n,this.currentDirection))return;let h=l&&l[u]||{};o&&(h={min:0,max:0});const f=i?200:1e6,d=i?40:1e7,p={type:"inertia",velocity:s?e[u]:0,bounceStiffness:f,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...r,...h};return this.startAxisValueAnimation(u,p)});return Promise.all(c).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(!Nt(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],l=r.get()||0;r.set(e[n]-M(o,a,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!ct(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 l=a.get();i[o]=Jc({min:l,max:l},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(!Nt(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(M(l,c,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;eu.set(this.visualElement,this);const e=this.visualElement.current,n=Vt(e,"pointerdown",c=>{const{drag:u,dragListener:h=!0}=this.getProps(),f=c.target,d=f!==e&&ja(f);u&&h&&!d&&this.start(c)});let s;const i=()=>{const{dragConstraints:c}=this.getProps();ct(c)&&c.current&&(this.constraints=this.resolveRefConstraints(),s||(s=su(e,c.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()),l=r.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(G(h=>{const f=this.getAxisMotionValue(h);f&&(this.originPoint[h]+=c[h].translate,f.set(f.get()+c[h].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=He,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Us(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function su(t,e,n){const s=_n(t,Us(n)),i=_n(e,Us(n));return()=>{s(),i()}}function Nt(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function iu(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class ou extends et{constructor(e){super(e),this.removeGroupControls=W,this.removeListeners=W,this.controls=new nu(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 ru extends et{constructor(){super(...arguments),this.removePointerDownListener=W}onPointerDown(e){this.session=new Ao(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:bo(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 au extends T.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()})),Gt.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 Co(t){const[e,n]=mo(),s=T.useContext(Ge);return Y.jsx(au,{...t,layoutGroup:s,switchLayoutGroup:T.useContext(Po),isPresent:e,safeToRemove:n})}const lu={pan:{Feature:ru},drag:{Feature:ou,ProjectionNode:po,MeasureLayout:Co}};function Ws(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 cu extends et{mount(){const{current:e}=this.node;e&&(this.unmount=ka(e,(n,s)=>(Ws(this.node,s,"Start"),i=>Ws(this.node,i,"End"))))}unmount(){}}class uu 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 Ks(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 hu extends et{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Na(e,(i,r)=>(Ks(this.node,r,"Start"),(o,{success:a})=>Ks(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const ze=new WeakMap,Pe=new WeakMap,fu=t=>{const e=ze.get(t.target);e&&e(t)},du=t=>{t.forEach(fu)};function pu({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(du,{root:t,...e})),s[i]}function mu(t,e,n){const s=pu(e);return ze.set(t,n),s.observe(t),()=>{ze.delete(t),s.unobserve(t)}}const gu={some:0,all:1};class yu 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:gu[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,r&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:h}=this.node.getProps(),f=c?u:h;f&&f(l)};return mu(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(vu(e,n))&&this.startObserver()}unmount(){}}function vu({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Tu={inView:{Feature:yu},tap:{Feature:hu},focus:{Feature:uu},hover:{Feature:cu}},xu={layout:{ProjectionNode:po,MeasureLayout:Co}},wu={...Hc,...Tu,...lu,...xu},Vu=Nc(wu,Uc);export{Au as A,Vu as m};
|