- Added primary_keyword, secondary_keywords, tags, and categories fields to Tasks model - Updated generate_content function to handle full JSON response with all SEO fields - Improved progress bar animation: smooth 1% increments every 300ms - Enhanced step detection for content generation vs clustering vs ideas - Fixed progress modal to show correct messages for each function type - Added comprehensive logging to Keywords and Tasks pages for AI functions - Fixed error handling to show meaningful error messages instead of generic failures
13 lines
31 KiB
JavaScript
13 lines
31 KiB
JavaScript
import{r as l}from"./vendor-react-core-DjsjKnCi.js";import"./vendor-other-CdRIx1s3.js";/**
|
|
* react-router v7.1.5
|
|
*
|
|
* Copyright (c) Remix Software Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE.md file in the root directory of this source tree.
|
|
*
|
|
* @license MIT
|
|
*/var le="popstate";function Se(e={}){function t(a,r){let{pathname:o,search:s,hash:c}=a.location;return G("",{pathname:o,search:s,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(a,r){return typeof r=="string"?r:M(r)}return ke(t,n,null,e)}function E(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function P(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Le(){return Math.random().toString(36).substring(2,10)}function ie(e,t){return{usr:e.state,key:e.key,idx:t}}function G(e,t,n=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?T(t):t,state:n,key:t&&t.key||a||Le()}}function M({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function T(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function ke(e,t,n,a={}){let{window:r=document.defaultView,v5Compat:o=!1}=a,s=r.history,c="POP",u=null,i=f();i==null&&(i=0,s.replaceState({...s.state,idx:i},""));function f(){return(s.state||{idx:null}).idx}function h(){c="POP";let d=f(),p=d==null?null:d-i;i=d,u&&u({action:c,location:v.location,delta:p})}function g(d,p){c="PUSH";let x=G(v.location,d,p);i=f()+1;let y=ie(x,i),R=v.createHref(x);try{s.pushState(y,"",R)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;r.location.assign(R)}o&&u&&u({action:c,location:v.location,delta:1})}function m(d,p){c="REPLACE";let x=G(v.location,d,p);i=f();let y=ie(x,i),R=v.createHref(x);s.replaceState(y,"",R),o&&u&&u({action:c,location:v.location,delta:0})}function w(d){let p=r.location.origin!=="null"?r.location.origin:r.location.href,x=typeof d=="string"?d:M(d);return x=x.replace(/ $/,"%20"),E(p,`No window.location.(origin|href) available to create URL for href: ${x}`),new URL(x,p)}let v={get action(){return c},get location(){return e(r,s)},listen(d){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(le,h),u=d,()=>{r.removeEventListener(le,h),u=null}},createHref(d){return t(r,d)},createURL:w,encodeLocation(d){let p=w(d);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:g,replace:m,go(d){return s.go(d)}};return v}function fe(e,t,n="/"){return $e(e,t,n,!1)}function $e(e,t,n,a){let r=typeof t=="string"?T(t):t,o=$(r.pathname||"/",n);if(o==null)return null;let s=he(e);Fe(s);let c=null;for(let u=0;c==null&&u<s.length;++u){let i=He(o);c=Ue(s[u],i,a)}return c}function he(e,t=[],n=[],a=""){let r=(o,s,c)=>{let u={relativePath:c===void 0?o.path||"":c,caseSensitive:o.caseSensitive===!0,childrenIndex:s,route:o};u.relativePath.startsWith("/")&&(E(u.relativePath.startsWith(a),`Absolute route path "${u.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(a.length));let i=k([a,u.relativePath]),f=n.concat(u);o.children&&o.children.length>0&&(E(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${i}".`),he(o.children,t,f,i)),!(o.path==null&&!o.index)&&t.push({path:i,score:Me(i,o.index),routesMeta:f})};return e.forEach((o,s)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))r(o,s);else for(let u of de(o.path))r(o,s,u)}),t}function de(e){let t=e.split("/");if(t.length===0)return[];let[n,...a]=t,r=n.endsWith("?"),o=n.replace(/\?$/,"");if(a.length===0)return r?[o,""]:[o];let s=de(a.join("/")),c=[];return c.push(...s.map(u=>u===""?o:[o,u].join("/"))),r&&c.push(...s),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function Fe(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ae(t.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var Ne=/^:[\w-]+$/,Te=3,Ie=2,De=1,Be=10,Oe=-2,ue=e=>e==="*";function Me(e,t){let n=e.split("/"),a=n.length;return n.some(ue)&&(a+=Oe),t&&(a+=Ie),n.filter(r=>!ue(r)).reduce((r,o)=>r+(Ne.test(o)?Te:o===""?De:Be),a)}function Ae(e,t){return e.length===t.length&&e.slice(0,-1).every((a,r)=>a===t[r])?e[e.length-1]-t[t.length-1]:0}function Ue(e,t,n=!1){let{routesMeta:a}=e,r={},o="/",s=[];for(let c=0;c<a.length;++c){let u=a[c],i=c===a.length-1,f=o==="/"?t:t.slice(o.length)||"/",h=J({path:u.relativePath,caseSensitive:u.caseSensitive,end:i},f),g=u.route;if(!h&&i&&n&&!a[a.length-1].route.index&&(h=J({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},f)),!h)return null;Object.assign(r,h.params),s.push({params:r,pathname:k([o,h.pathname]),pathnameBase:Je(k([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=k([o,h.pathnameBase]))}return s}function J(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=We(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let o=r[0],s=o.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:a.reduce((i,{paramName:f,isOptional:h},g)=>{if(f==="*"){let w=c[g]||"";s=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const m=c[g];return h&&!m?i[f]=void 0:i[f]=(m||"").replace(/%2F/g,"/"),i},{}),pathname:o,pathnameBase:s,pattern:e}}function We(e,t=!1,n=!0){P(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,c,u)=>(a.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(a.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),a]}function He(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return P(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function $(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,a=e.charAt(n);return a&&a!=="/"?null:e.slice(n)||"/"}function _e(e,t="/"){let{pathname:n,search:a="",hash:r=""}=typeof e=="string"?T(e):e;return{pathname:n?n.startsWith("/")?n:Ve(n,t):t,search:Ke(a),hash:je(r)}}function Ve(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Y(e,t,n,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ze(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Q(e){let t=ze(e);return t.map((n,a)=>a===t.length-1?n.pathname:n.pathnameBase)}function Z(e,t,n,a=!1){let r;typeof e=="string"?r=T(e):(r={...e},E(!r.pathname||!r.pathname.includes("?"),Y("?","pathname","search",r)),E(!r.pathname||!r.pathname.includes("#"),Y("#","pathname","hash",r)),E(!r.search||!r.search.includes("#"),Y("#","search","hash",r)));let o=e===""||r.pathname==="",s=o?"/":r.pathname,c;if(s==null)c=n;else{let h=t.length-1;if(!a&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),h-=1;r.pathname=g.join("/")}c=h>=0?t[h]:"/"}let u=_e(r,c),i=s&&s!=="/"&&s.endsWith("/"),f=(o||s===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(i||f)&&(u.pathname+="/"),u}var k=e=>e.join("/").replace(/\/\/+/g,"/"),Je=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ke=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,je=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Ye(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var me=["POST","PUT","PATCH","DELETE"];new Set(me);var qe=["GET",...me];new Set(qe);var I=l.createContext(null);I.displayName="DataRouter";var K=l.createContext(null);K.displayName="DataRouterState";var pe=l.createContext({isTransitioning:!1});pe.displayName="ViewTransition";var Ge=l.createContext(new Map);Ge.displayName="Fetchers";var Xe=l.createContext(null);Xe.displayName="Await";var S=l.createContext(null);S.displayName="Navigation";var A=l.createContext(null);A.displayName="Location";var L=l.createContext({outlet:null,matches:[],isDataRoute:!1});L.displayName="Route";var ee=l.createContext(null);ee.displayName="RouteError";function Qe(e,{relative:t}={}){E(D(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=l.useContext(S),{hash:r,pathname:o,search:s}=U(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:k([n,o])),a.createHref({pathname:c,search:s,hash:r})}function D(){return l.useContext(A)!=null}function F(){return E(D(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(A).location}var ye="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ge(e){l.useContext(S).static||l.useLayoutEffect(e)}function ve(){let{isDataRoute:e}=l.useContext(L);return e?dt():Ze()}function Ze(){E(D(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(I),{basename:t,navigator:n}=l.useContext(S),{matches:a}=l.useContext(L),{pathname:r}=F(),o=JSON.stringify(Q(a)),s=l.useRef(!1);return ge(()=>{s.current=!0}),l.useCallback((u,i={})=>{if(P(s.current,ye),!s.current)return;if(typeof u=="number"){n.go(u);return}let f=Z(u,JSON.parse(o),r,i.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:k([t,f.pathname])),(i.replace?n.replace:n.push)(f,i.state,i)},[t,n,o,r,e])}var et=l.createContext(null);function tt(e){let t=l.useContext(L).outlet;return t&&l.createElement(et.Provider,{value:e},t)}function U(e,{relative:t}={}){let{matches:n}=l.useContext(L),{pathname:a}=F(),r=JSON.stringify(Q(n));return l.useMemo(()=>Z(e,JSON.parse(r),a,t==="path"),[e,r,a,t])}function nt(e,t){return we(e,t)}function we(e,t,n,a){var x;E(D(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r,static:o}=l.useContext(S),{matches:s}=l.useContext(L),c=s[s.length-1],u=c?c.params:{},i=c?c.pathname:"/",f=c?c.pathnameBase:"/",h=c&&c.route;{let y=h&&h.path||"";xe(i,!h||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${i}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
|
|
Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let g=F(),m;if(t){let y=typeof t=="string"?T(t):t;E(f==="/"||((x=y.pathname)==null?void 0:x.startsWith(f)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${y.pathname}" was given in the \`location\` prop.`),m=y}else m=g;let w=m.pathname||"/",v=w;if(f!=="/"){let y=f.replace(/^\//,"").split("/");v="/"+w.replace(/^\//,"").split("/").slice(y.length).join("/")}let d=!o&&n&&n.matches&&n.matches.length>0?n.matches:fe(e,{pathname:v});P(h||d!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),P(d==null||d[d.length-1].route.element!==void 0||d[d.length-1].route.Component!==void 0||d[d.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let p=it(d&&d.map(y=>Object.assign({},y,{params:Object.assign({},u,y.params),pathname:k([f,r.encodeLocation?r.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?f:k([f,r.encodeLocation?r.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),s,n,a);return t&&p?l.createElement(A.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},p):p}function rt(){let e=ht(),t=Ye(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:o},"ErrorBoundary")," or"," ",l.createElement("code",{style:o},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:r},n):null,s)}var at=l.createElement(rt,null),ot=class extends l.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error!==void 0?l.createElement(L.Provider,{value:this.props.routeContext},l.createElement(ee.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function lt({routeContext:e,match:t,children:n}){let a=l.useContext(I);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(L.Provider,{value:e},n)}function it(e,t=[],n=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let r=e,o=n==null?void 0:n.errors;if(o!=null){let u=r.findIndex(i=>i.route.id&&(o==null?void 0:o[i.route.id])!==void 0);E(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,u+1))}let s=!1,c=-1;if(n)for(let u=0;u<r.length;u++){let i=r[u];if((i.route.HydrateFallback||i.route.hydrateFallbackElement)&&(c=u),i.route.id){let{loaderData:f,errors:h}=n,g=i.route.loader&&!f.hasOwnProperty(i.route.id)&&(!h||h[i.route.id]===void 0);if(i.route.lazy||g){s=!0,c>=0?r=r.slice(0,c+1):r=[r[0]];break}}}return r.reduceRight((u,i,f)=>{let h,g=!1,m=null,w=null;n&&(h=o&&i.route.id?o[i.route.id]:void 0,m=i.route.errorElement||at,s&&(c<0&&f===0?(xe("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,w=null):c===f&&(g=!0,w=i.route.hydrateFallbackElement||null)));let v=t.concat(r.slice(0,f+1)),d=()=>{let p;return h?p=m:g?p=w:i.route.Component?p=l.createElement(i.route.Component,null):i.route.element?p=i.route.element:p=u,l.createElement(lt,{match:i,routeContext:{outlet:u,matches:v,isDataRoute:n!=null},children:p})};return n&&(i.route.ErrorBoundary||i.route.errorElement||f===0)?l.createElement(ot,{location:n.location,revalidation:n.revalidation,component:m,error:h,children:d(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):d()},null)}function te(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ut(e){let t=l.useContext(I);return E(t,te(e)),t}function st(e){let t=l.useContext(K);return E(t,te(e)),t}function ct(e){let t=l.useContext(L);return E(t,te(e)),t}function ne(e){let t=ct(e),n=t.matches[t.matches.length-1];return E(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ft(){return ne("useRouteId")}function ht(){var a;let e=l.useContext(ee),t=st("useRouteError"),n=ne("useRouteError");return e!==void 0?e:(a=t.errors)==null?void 0:a[n]}function dt(){let{router:e}=ut("useNavigate"),t=ne("useNavigate"),n=l.useRef(!1);return ge(()=>{n.current=!0}),l.useCallback(async(r,o={})=>{P(n.current,ye),n.current&&(typeof r=="number"?e.navigate(r):await e.navigate(r,{fromRouteId:t,...o}))},[e,t])}var se={};function xe(e,t,n){!t&&!se[e]&&(se[e]=!0,P(!1,n))}l.memo(mt);function mt({routes:e,future:t,state:n}){return we(e,void 0,n,t)}function Xt({to:e,replace:t,state:n,relative:a}){E(D(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=l.useContext(S);P(!r,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=l.useContext(L),{pathname:s}=F(),c=ve(),u=Z(e,Q(o),s,a==="path"),i=JSON.stringify(u);return l.useEffect(()=>{c(JSON.parse(i),{replace:t,state:n,relative:a})},[c,i,a,t,n]),null}function Qt(e){return tt(e.context)}function pt(e){E(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function yt({basename:e="/",children:t=null,location:n,navigationType:a="POP",navigator:r,static:o=!1}){E(!D(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=e.replace(/^\/*/,"/"),c=l.useMemo(()=>({basename:s,navigator:r,static:o,future:{}}),[s,r,o]);typeof n=="string"&&(n=T(n));let{pathname:u="/",search:i="",hash:f="",state:h=null,key:g="default"}=n,m=l.useMemo(()=>{let w=$(u,s);return w==null?null:{location:{pathname:w,search:i,hash:f,state:h,key:g},navigationType:a}},[s,u,i,f,h,g,a]);return P(m!=null,`<Router basename="${s}"> is not able to match the URL "${u}${i}${f}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:l.createElement(S.Provider,{value:c},l.createElement(A.Provider,{children:t,value:m}))}function Zt({children:e,location:t}){return nt(X(e),t)}function X(e,t=[]){let n=[];return l.Children.forEach(e,(a,r)=>{if(!l.isValidElement(a))return;let o=[...t,r];if(a.type===l.Fragment){n.push.apply(n,X(a.props.children,o));return}E(a.type===pt,`[${typeof a.type=="string"?a.type:a.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),E(!a.props.index||!a.props.children,"An index route cannot have child routes.");let s={id:a.props.id||o.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,loader:a.props.loader,action:a.props.action,hydrateFallbackElement:a.props.hydrateFallbackElement,HydrateFallback:a.props.HydrateFallback,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.hasErrorBoundary===!0||a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(s.children=X(a.props.children,o)),n.push(s)}),n}var V="get",z="application/x-www-form-urlencoded";function j(e){return e!=null&&typeof e.tagName=="string"}function gt(e){return j(e)&&e.tagName.toLowerCase()==="button"}function vt(e){return j(e)&&e.tagName.toLowerCase()==="form"}function wt(e){return j(e)&&e.tagName.toLowerCase()==="input"}function xt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Et(e,t){return e.button===0&&(!t||t==="_self")&&!xt(e)}var _=null;function Rt(){if(_===null)try{new FormData(document.createElement("form"),0),_=!1}catch{_=!0}return _}var Ct=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function q(e){return e!=null&&!Ct.has(e)?(P(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${z}"`),null):e}function bt(e,t){let n,a,r,o,s;if(vt(e)){let c=e.getAttribute("action");a=c?$(c,t):null,n=e.getAttribute("method")||V,r=q(e.getAttribute("enctype"))||z,o=new FormData(e)}else if(gt(e)||wt(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||c.getAttribute("action");if(a=u?$(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||V,r=q(e.getAttribute("formenctype"))||q(c.getAttribute("enctype"))||z,o=new FormData(c,e),!Rt()){let{name:i,type:f,value:h}=e;if(f==="image"){let g=i?`${i}.`:"";o.append(`${g}x`,"0"),o.append(`${g}y`,"0")}else i&&o.append(i,h)}}else{if(j(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=V,a=null,r=z,s=e}return o&&r==="text/plain"&&(s=o,o=void 0),{action:a,method:n.toLowerCase(),encType:r,formData:o,body:s}}function re(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}async function Pt(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function St(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Lt(e,t,n){let a=await Promise.all(e.map(async r=>{let o=t.routes[r.route.id];if(o){let s=await Pt(o,n);return s.links?s.links():[]}return[]}));return Nt(a.flat(1).filter(St).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function ce(e,t,n,a,r,o){let s=(u,i)=>n[i]?u.route.id!==n[i].route.id:!0,c=(u,i)=>{var f;return n[i].pathname!==u.pathname||((f=n[i].route.path)==null?void 0:f.endsWith("*"))&&n[i].params["*"]!==u.params["*"]};return o==="assets"?t.filter((u,i)=>s(u,i)||c(u,i)):o==="data"?t.filter((u,i)=>{var h;let f=a.routes[u.route.id];if(!f||!f.hasLoader)return!1;if(s(u,i)||c(u,i))return!0;if(u.route.shouldRevalidate){let g=u.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function kt(e,t){return $t(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let r=[a.module];return a.imports&&(r=r.concat(a.imports)),r}).flat(1))}function $t(e){return[...new Set(e)]}function Ft(e){let t={},n=Object.keys(e).sort();for(let a of n)t[a]=e[a];return t}function Nt(e,t){let n=new Set;return new Set(t),e.reduce((a,r)=>{let o=JSON.stringify(Ft(r));return n.has(o)||(n.add(o),a.push({key:o,link:r})),a},[])}function Tt(e){let t=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return t.pathname==="/"?t.pathname="_root.data":t.pathname=`${t.pathname.replace(/\/$/,"")}.data`,t}function It(){let e=l.useContext(I);return re(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Dt(){let e=l.useContext(K);return re(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ae=l.createContext(void 0);ae.displayName="FrameworkContext";function Ee(){let e=l.useContext(ae);return re(e,"You must render this element inside a <HydratedRouter> element"),e}function Bt(e,t){let n=l.useContext(ae),[a,r]=l.useState(!1),[o,s]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:i,onMouseLeave:f,onTouchStart:h}=t,g=l.useRef(null);l.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let v=p=>{p.forEach(x=>{s(x.isIntersecting)})},d=new IntersectionObserver(v,{threshold:.5});return g.current&&d.observe(g.current),()=>{d.disconnect()}}},[e]),l.useEffect(()=>{if(a){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[a]);let m=()=>{r(!0)},w=()=>{r(!1),s(!1)};return n?e!=="intent"?[o,g,{}]:[o,g,{onFocus:O(c,m),onBlur:O(u,w),onMouseEnter:O(i,m),onMouseLeave:O(f,w),onTouchStart:O(h,m)}]:[!1,g,{}]}function O(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ot({page:e,...t}){let{router:n}=It(),a=l.useMemo(()=>fe(n.routes,e,n.basename),[n.routes,e,n.basename]);return a?l.createElement(At,{page:e,matches:a,...t}):null}function Mt(e){let{manifest:t,routeModules:n}=Ee(),[a,r]=l.useState([]);return l.useEffect(()=>{let o=!1;return Lt(e,t,n).then(s=>{o||r(s)}),()=>{o=!0}},[e,t,n]),a}function At({page:e,matches:t,...n}){let a=F(),{manifest:r,routeModules:o}=Ee(),{loaderData:s,matches:c}=Dt(),u=l.useMemo(()=>ce(e,t,c,r,a,"data"),[e,t,c,r,a]),i=l.useMemo(()=>ce(e,t,c,r,a,"assets"),[e,t,c,r,a]),f=l.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let m=new Set,w=!1;if(t.forEach(d=>{var x;let p=r.routes[d.route.id];!p||!p.hasLoader||(!u.some(y=>y.route.id===d.route.id)&&d.route.id in s&&((x=o[d.route.id])!=null&&x.shouldRevalidate)||p.hasClientLoader?w=!0:m.add(d.route.id))}),m.size===0)return[];let v=Tt(e);return w&&m.size>0&&v.searchParams.set("_routes",t.filter(d=>m.has(d.route.id)).map(d=>d.route.id).join(",")),[v.pathname+v.search]},[s,a,r,u,t,e,o]),h=l.useMemo(()=>kt(i,r),[i,r]),g=Mt(i);return l.createElement(l.Fragment,null,f.map(m=>l.createElement("link",{key:m,rel:"prefetch",as:"fetch",href:m,...n})),h.map(m=>l.createElement("link",{key:m,rel:"modulepreload",href:m,...n})),g.map(({key:m,link:w})=>l.createElement("link",{key:m,...w})))}function Ut(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Re=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Re&&(window.__reactRouterVersion="7.1.5")}catch{}function en({basename:e,children:t,window:n}){let a=l.useRef();a.current==null&&(a.current=Se({window:n,v5Compat:!0}));let r=a.current,[o,s]=l.useState({action:r.action,location:r.location}),c=l.useCallback(u=>{l.startTransition(()=>s(u))},[s]);return l.useLayoutEffect(()=>r.listen(c),[r,c]),l.createElement(yt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:r})}var Ce=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,be=l.forwardRef(function({onClick:t,discover:n="render",prefetch:a="none",relative:r,reloadDocument:o,replace:s,state:c,target:u,to:i,preventScrollReset:f,viewTransition:h,...g},m){let{basename:w}=l.useContext(S),v=typeof i=="string"&&Ce.test(i),d,p=!1;if(typeof i=="string"&&v&&(d=i,Re))try{let b=new URL(window.location.href),N=i.startsWith("//")?new URL(b.protocol+i):new URL(i),oe=$(N.pathname,w);N.origin===b.origin&&oe!=null?i=oe+N.search+N.hash:p=!0}catch{P(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let x=Qe(i,{relative:r}),[y,R,C]=Bt(a,g),W=Vt(i,{replace:s,state:c,target:u,preventScrollReset:f,relative:r,viewTransition:h});function B(b){t&&t(b),b.defaultPrevented||W(b)}let H=l.createElement("a",{...g,...C,href:d||x,onClick:p||o?t:B,ref:Ut(m,R),target:u,"data-discover":!v&&n==="render"?"true":void 0});return y&&!v?l.createElement(l.Fragment,null,H,l.createElement(Ot,{page:x})):H});be.displayName="Link";var Wt=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:a="",end:r=!1,style:o,to:s,viewTransition:c,children:u,...i},f){let h=U(s,{relative:i.relative}),g=F(),m=l.useContext(K),{navigator:w,basename:v}=l.useContext(S),d=m!=null&&Yt(h)&&c===!0,p=w.encodeLocation?w.encodeLocation(h).pathname:h.pathname,x=g.pathname,y=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(x=x.toLowerCase(),y=y?y.toLowerCase():null,p=p.toLowerCase()),y&&v&&(y=$(y,v)||y);const R=p!=="/"&&p.endsWith("/")?p.length-1:p.length;let C=x===p||!r&&x.startsWith(p)&&x.charAt(R)==="/",W=y!=null&&(y===p||!r&&y.startsWith(p)&&y.charAt(p.length)==="/"),B={isActive:C,isPending:W,isTransitioning:d},H=C?t:void 0,b;typeof a=="function"?b=a(B):b=[a,C?"active":null,W?"pending":null,d?"transitioning":null].filter(Boolean).join(" ");let N=typeof o=="function"?o(B):o;return l.createElement(be,{...i,"aria-current":H,className:b,ref:f,style:N,to:s,viewTransition:c},typeof u=="function"?u(B):u)});Wt.displayName="NavLink";var Ht=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:a,replace:r,state:o,method:s=V,action:c,onSubmit:u,relative:i,preventScrollReset:f,viewTransition:h,...g},m)=>{let w=Kt(),v=jt(c,{relative:i}),d=s.toLowerCase()==="get"?"get":"post",p=typeof c=="string"&&Ce.test(c),x=y=>{if(u&&u(y),y.defaultPrevented)return;y.preventDefault();let R=y.nativeEvent.submitter,C=(R==null?void 0:R.getAttribute("formmethod"))||s;w(R||y.currentTarget,{fetcherKey:t,method:C,navigate:n,replace:r,state:o,relative:i,preventScrollReset:f,viewTransition:h})};return l.createElement("form",{ref:m,method:d,action:v,onSubmit:a?u:x,...g,"data-discover":!p&&e==="render"?"true":void 0})});Ht.displayName="Form";function _t(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Pe(e){let t=l.useContext(I);return E(t,_t(e)),t}function Vt(e,{target:t,replace:n,state:a,preventScrollReset:r,relative:o,viewTransition:s}={}){let c=ve(),u=F(),i=U(e,{relative:o});return l.useCallback(f=>{if(Et(f,t)){f.preventDefault();let h=n!==void 0?n:M(u)===M(i);c(e,{replace:h,state:a,preventScrollReset:r,relative:o,viewTransition:s})}},[u,c,i,n,a,t,e,r,o,s])}var zt=0,Jt=()=>`__${String(++zt)}__`;function Kt(){let{router:e}=Pe("useSubmit"),{basename:t}=l.useContext(S),n=ft();return l.useCallback(async(a,r={})=>{let{action:o,method:s,encType:c,formData:u,body:i}=bt(a,t);if(r.navigate===!1){let f=r.fetcherKey||Jt();await e.fetch(f,n,r.action||o,{preventScrollReset:r.preventScrollReset,formData:u,body:i,formMethod:r.method||s,formEncType:r.encType||c,flushSync:r.flushSync})}else await e.navigate(r.action||o,{preventScrollReset:r.preventScrollReset,formData:u,body:i,formMethod:r.method||s,formEncType:r.encType||c,replace:r.replace,state:r.state,fromRouteId:n,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,t,n])}function jt(e,{relative:t}={}){let{basename:n}=l.useContext(S),a=l.useContext(L);E(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),o={...U(e||".",{relative:t})},s=F();if(e==null){o.search=s.search;let c=new URLSearchParams(o.search),u=c.getAll("index");if(u.some(f=>f==="")){c.delete("index"),u.filter(h=>h).forEach(h=>c.append("index",h));let f=c.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&r.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:k([n,o.pathname])),M(o)}function Yt(e,t={}){let n=l.useContext(pe);E(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=Pe("useViewTransitionState"),r=U(e,{relative:t.relative});if(!n.isTransitioning)return!1;let o=$(n.currentLocation.pathname,a)||n.currentLocation.pathname,s=$(n.nextLocation.pathname,a)||n.nextLocation.pathname;return J(r.pathname,s)!=null||J(r.pathname,o)!=null}new TextEncoder;export{en as B,be as L,Xt as N,Qt as O,Zt as R,F as a,pt as b,ve as u};
|